大理水控初始版本
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6496c34
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,27 @@
+*.uvgui.*
+*.bak
+*.o
+*.d
+*.crf
+*.__i
+*.bin
+
+*.map
+*.htm
+*.lst
+*.sct
+*.lnp
+*.plg
+*.axf
+*.tra
+*.orig
+*.Opt
+.browse.VC.db
+*.dep
+*._ia
+*build*
+*JLinkLog.txt
+Out
+g401302/outTimer
+g401302/outFlow
+supwisdom/sp_version.h
\ No newline at end of file
diff --git a/COM.ini b/COM.ini
new file mode 100644
index 0000000..f32bf8a
--- /dev/null
+++ b/COM.ini
@@ -0,0 +1,15 @@
+/******************************************************************************/
+/* FLASH.INI: FLASH Initialization File */
+/******************************************************************************/
+// <<< Use Configuration Wizard in Context Menu >>> //
+/******************************************************************************/
+/* This file is part of the uVision/ARM development tools. */
+/* Copyright (c) 2005-2006 Keil Software. All rights reserved. */
+/* This software may only be used under the terms of a valid, current, */
+/* end user licence from KEIL for a compatible version of KEIL software */
+/* development tools. Nothing else gives you the right to use this software. */
+/******************************************************************************/
+//MODE COM3 9600,1,8,1
+ASSIGN COM3 <S1IN>S1OUT
+
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ea4310f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
+TARGET=g40130x
+UV4=/C/Keil/UV4/Uv4.exe
+
+.PHONY: clean all
+
+timer: clean
+ @echo "build std version ..."
+ $(UV4) -cr -j0 -b g401302/project/g401302.uvproj -t"timer" -o"outTimer/OUTPUTFILE.TXT"
+
+flow: clean
+ @echo "build shu version ..."
+ $(UV4) -cr -j0 -b g401302/project/g401302.uvproj -t"flow" -o"outFlow/OUTPUTFILE.TXT"
+
+all: timer flow
+
+clean:
+
\ No newline at end of file
diff --git a/RAM.ini b/RAM.ini
new file mode 100644
index 0000000..ceb6901
--- /dev/null
+++ b/RAM.ini
@@ -0,0 +1,17 @@
+FUNC void Setup (void) {
+
+ SP = _RDWORD(0x08000000); // Setup Stack Pointer
+
+ PC = _RDWORD(0x08000004); // Setup Program Counter
+
+ _WDWORD(0xE000ED08, 0x08004000); // Setup Vector Table Offset Register
+
+}
+
+
+LOAD CSC105.axf INCREMENTAL // Download
+
+Setup(); // Setup for Running
+
+
+g, main
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..2b0893f
--- /dev/null
+++ b/config.h
@@ -0,0 +1,36 @@
+#ifndef _N_CONFIG_H_
+#define _N_CONFIG_H_
+
+#include "./g401302/src/G401_drv_hw_V01.h"
+#include "./sys_hw/drv_usart.h"
+
+#ifndef int8
+#define int8 signed char
+#endif
+
+#ifndef uint8
+#define uint8 unsigned char
+#endif
+
+#ifndef uint16
+#define uint16 unsigned short
+#endif
+
+#ifndef int16
+#define int16 signed short
+#endif
+
+#ifndef uint32
+#define uint32 unsigned int
+#endif
+
+#ifndef int32
+#define int32 signed int
+#endif
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+#endif
+
diff --git a/g401302/hex/STM32IAPCombine51.hex b/g401302/hex/STM32IAPCombine51.hex
new file mode 100644
index 0000000..1e44517
--- /dev/null
+++ b/g401302/hex/STM32IAPCombine51.hex
@@ -0,0 +1,1026 @@
+:020000040800F2
+:10000000F0370020F5010008FD010008FF0100089D
+:1000100001020008030200080502000800000000B9
+:1000200000000000000000000000000007020008BF
+:1000300009020008000000000B0200081513000868
+:100040000F0200080F0200080F0200080F0200084C
+:100050000F0200080F0200080F0200080F0200083C
+:100060000F0200080F0200080F0200080F0200082C
+:100070000F0200080F0200080F0200080F0200081C
+:100080000F0200080F0200080F0200080F0200080C
+:100090000F0200080F0200080F0200080F020008FC
+:1000A0000F0200080F0200080F0200080F020008EC
+:1000B0000F0200080F0200080F0200080F020008DC
+:1000C0000F0200080F0200080F0200080F020008CC
+:1000D0000F0200080F0200080F0200080F020008BC
+:1000E0000F0200080F0200080F0200080F020008AC
+:1000F0000F0200080F0200080F0200080F0200089C
+:100100000F0200080F0200080F0200080F0200088B
+:100110000F0200080F0200080F0200080F0200087B
+:100120000F0200080F0200080F0200080F0200086B
+:1001300000F002F800F03FF80AA090E8000C8244BA
+:100140008344AAF10107DA4501D100F034F8AFF297
+:10015000090EBAE80F0013F0010F18BFFB1A43F0A5
+:1001600001031847542B0000742B0000103A24BFE1
+:1001700078C878C1FAD8520724BF30C830C144BF0C
+:1001800004680C607047000000230024002500264E
+:10019000103A28BF78C1FBD8520728BF30C148BFEA
+:1001A0000B607047642900F08180002070471FB504
+:1001B0001FBD10B510BD00F067FA1146FFF7F7FF3D
+:1001C00001F0ECFC00F085FA03B4FFF7F2FF03BC8A
+:1001D00000F08CFAEFF30980704780F309887047CC
+:1001E000EFF30880704780F30888704740BA704783
+:1001F000C0BA70470948804709480047FEE7FEE754
+:10020000FEE7FEE7FEE7FEE7FEE7FEE7FEE7FEE7C6
+:1002100004480549034A054B70470000991300083C
+:1002200031010008F0070020F0370020F00700201F
+:100230000FB41CB5074B06AA7B446946009005988D
+:1002400000F0E3F90020694600F0F2F91CBC5DF80B
+:1002500014FB0000F503000070B5044685690068D2
+:10026000C10601D5302600E02026C00708D070BDA9
+:10027000D4E9012130469047206A00F10100206254
+:100280006D1EF5D570BD70B5044685690078C00750
+:1002900008D170BDD4E9012120209047206A00F1E7
+:1002A000010020626D1EF5D570BD00002DE9F04102
+:1002B0000646002410687529314616A511D0AFF303
+:1002C0000080002803DAC0F1000013A507E03168C0
+:1002D0008A0701D511A502E0490704D510A501241C
+:1002E00001E0AFF3008000210A2306F1240707E0B4
+:1002F000B0FBF3F203FB1200303078541046491C77
+:100300000028F5D123462A463046BDE8F04100F0EA
+:100310001BB90000000000002D0000002B000000B1
+:10032000200000002DE9F0474FF0000A89460446FE
+:10033000C0F820A02046E1688847002876D025280C
+:1003400006D0D4E901219047206A401C2062F1E7E1
+:10035000E168204600258847C4F81CA0064600270F
+:10036000C4F818A02A2E09D0304601F045F838B359
+:1003700004EB8708303EC8F8186019E059F8041BF0
+:10038000204604EB87029161E1688847012F064609
+:1003900018D1E069002820DA25F020051DE0D8F802
+:1003A000180000EB800006EB40003038C8F8180059
+:1003B0002046E1688847064601F01EF80028EED185
+:1003C000012F0AD02E2E08D12046E16888477F1CD5
+:1003D0000646022F45F02005C4DBA069002803DA99
+:1003E000404245F00105A061E80701D025F0100565
+:1003F000B6B1A6F14100192802D8203645F40065AF
+:100400004A463146204625604D46FFF7CBFE58B19F
+:10041000012806D0ED1D25F0070000F1080989E745
+:1004200004E005F1040985E730468AE7206ABDE863
+:10043000F08740EA010310B59B070FD1042A0DD3C2
+:1004400010C808C9121F9C42F8D020BA19BA8842B5
+:1004500001D9012010BD4FF0FF3010BD1AB1D307F4
+:1004600003D0521C07E0002010BD10F8013B11F82A
+:10047000014B1B1B07D110F8013B11F8014B1B1B53
+:1004800001D1921EF1D1184610BD10B5203AC0F02E
+:100490000B80B1E81850203AA0E81850B1E8185085
+:1004A000A0E81850BFF4F5AF5FEA027C24BFB1E8C2
+:1004B0001850A0E8185044BF18C918C0BDE8104033
+:1004C0005FEA827C24BF51F8043B40F8043B08BF3C
+:1004D0007047D20728BF31F8023B48BF11F8012B03
+:1004E00028BF20F8023B48BF00F8012B704702F0FC
+:1004F000FF0343EA032242EA024200F002B84FF04F
+:1005000000020429C0F0128010F0030C00F0978064
+:10051000CCF1040CBCF1020F18BF00F8012BA8BFEE
+:1005200020F8022BA1EB0C0100F089B85FEAC17C36
+:1005300024BF00F8012B00F8012B48BF00F8012B65
+:1005400070477047704770472DE9F0470D46994650
+:100550009246044600F124080168880604D5E06943
+:1005600021F01001216000E00120A84202DDA0EB93
+:10057000050700E00027A16907EB050202EB09006F
+:10058000A1EB0000A0612078C00602D42046FFF74E
+:1005900063FE002608E0D4E901211AF8060090471E
+:1005A000206A401C761C20624E45F4DB2078C00691
+:1005B0000AD52046FFF750FE06E0D4E9012130209D
+:1005C0009047206A401C2062381EA7F10107F4DC26
+:1005D00007E0D4E9012118F805009047206A401C83
+:1005E0002062281EA5F10105F3DC2046FFF74BFE33
+:1005F0002078000602D50220BDE8F0870120FBE745
+:1006000001694A1C02610878704700B58FB0CDE9D6
+:1006100001310021059105497944CDE903101146C6
+:100620006846FFF77FFE0FB000BD0000E5FFFFFF4B
+:100630000A6802F8010B0A6070474FF0000200B52B
+:10064000134694469646203922BFA0E80C50A0E8F5
+:100650000C50B1F12001BFF4F7AF090728BFA0E8A3
+:100660000C5048BF0CC05DF804EB890028BF40F86F
+:10067000042B08BF704748BF20F8022B11F0804FB1
+:1006800018BF00F8012B7047754600F029F8AE46F8
+:1006900005006946534620F00700854618B020B58E
+:1006A000FFF7B6FDBDE820404FF000064FF0000711
+:1006B0004FF000084FF0000B21F00701AC46ACE80A
+:1006C000C009ACE8C009ACE8C009ACE8C0098D4677
+:1006D00070470446AFF300802046FFF775FD000029
+:1006E000004870478C07002070470000014918201F
+:1006F000ABBEFEE7260002007CB503460C46002098
+:100700000190002112E0585C9DF8055068400F4DA3
+:1007100035F8100000909DF801009DF804506840E5
+:100720008DF80100BDF800000190491CA142EAD3F8
+:10073000012A07D19DF801600846491C1E549DF806
+:1007400000005854BDF804007CBD0000B62A000823
+:10075000F0B585B006464FF414270EBB14222C4981
+:100760006846FFF792FE2B48C068CDF8060029487E
+:100770008068CDF80A0001220E216846FFF7BCFF11
+:10078000002409E06A461021384600F0D1FAC5B2CB
+:1007900005B903E0601CC4B20A2CF3DB00BF2FE0F4
+:1007A000012E20D114221A4914316846FFF76DFE3C
+:1007B000FF2208210DF10600FFF799FE01220E210C
+:1007C0006846FFF799FF002409E06A461021384681
+:1007D00000F0AEFAC5B205B903E0601CC4B20A2C41
+:1007E000F3DB00BF0CE0002407E0380B00F022FA36
+:1007F000C5B205B903E0601CC4B20A2CF5DB00BF2A
+:100800000A2C02DA002005B0F0BD0120FBE7000051
+:10081000902A00087C0400200149C860704700004D
+:100820000020024030B5044604254FF4302000F08B
+:100830007BF80546042D17D10C48006940F00200F2
+:100840000A49086108464461006940F040000861B7
+:100850004FF4302000F068F805460448006941F67E
+:10086000FD71084001490861284630BD0020024062
+:1008700004200B49C96811F0010F01D001200EE0DE
+:100880000749C96811F0040F01D0022007E00449AC
+:10089000C96811F0100F01D0032000E00420704758
+:1008A0000020024078B506460C4604250020009042
+:1008B000E80200F039F80546042D24D113480069F8
+:1008C00040F00100114908613480E80200F02CF882
+:1008D0000546042D10D1B01C0090200C0099088012
+:1008E000E80200F021F805460848006941F6FE716B
+:1008F00008400649086106E00448006941F6FE71B7
+:10090000084002490861284678BD000000200240E6
+:10091000024803494860034848607047230167451F
+:1009200000200240AB89EFCD00B502460423FFF75B
+:100930009FFF034603E0FFF79BFF0346521E012B78
+:1009400001D1002AF7D102B90523184600BD0000E5
+:100950002DE9FC4105460E46174600F017F91E48E2
+:1009600000F036F900F0FF0808F00200022802D07B
+:100970004046BDE8FC818021184800F003F9B6F537
+:10098000807F01D90120F4E702208DF80000280CB7
+:100990008DF80100280A8DF80200E8B28DF80300F6
+:1009A000002405E01DF804000B4901F0CDFA641C99
+:1009B000042CF7D3002404E0385D074901F0C4FAA1
+:1009C000641CB442F8D38021044800F0DDF80248EA
+:1009D00000F0F2F8CDE70000A08601000010014011
+:1009E0002DE9F041024600250026002000230024C6
+:1009F000002791F803C00CF00F0591F803C01CF01C
+:100A0000100F03D091F802C04CEA050591F800C020
+:100A1000BCF1000F31D0146800202BE04FF0010C26
+:100A20000CFA00F3B1F800C00CEA03069E4220D194
+:100A300083004FF00F0C0CFA03F7BC4305FA03FCDC
+:100A40004CEA040491F803C0BCF1280F06D14FF022
+:100A5000010C0CFA00FCC2F814C00AE091F803C0C3
+:100A6000BCF1480F05D14FF0010C0CFA00FCC2F8A4
+:100A700010C0401C0828D1D31460B1F800C0BCF1EC
+:100A8000FF0F34DD546800202EE000F1080C4FF019
+:100A9000010808FA0CF3B1F800C00CEA03069E4204
+:100AA00021D183004FF00F0C0CFA03F7BC4305FA79
+:100AB00003FC4CEA040491F803C0BCF1280F05D1F3
+:100AC00000F1080C08FA0CF8C2F8148091F803C081
+:100AD000BCF1480F07D100F1080C4FF0010808FAEB
+:100AE0000CF8C2F81080401C0828CED35460BDE832
+:100AF000F0810000F0B50A46002300240021002503
+:100B000000F00046B6F1004F02D11D4EF16901E040
+:100B10001B4E7168C0F3034583B200F44016B6F56E
+:100B2000401F08D121F07061154E766826F070667E
+:100B3000134F7E6012E000F48016B6F5801F06D1D8
+:100B4000032606FA05F4A14341F0706106E0460D64
+:100B5000360103FA06F6B14341F0706122B1460D49
+:100B6000360103FA06F6314300F00046B6F1004FB5
+:100B700002D1034EF16101E0014E7160F0BD000051
+:100B800000000140416170470161704708B5802154
+:100B90000748FFF7F7FF06208DF800009DF80000DA
+:100BA000044901F0D1F980210148FFF7EDFF08BDAC
+:100BB00000100140A086010070B50446204600F0F8
+:100BC00007F8C5B2FF2D01D1012070BD0020FCE760
+:100BD00038B5044680211348FFF7D4FF05208DF86F
+:100BE00000009DF80000214601F0AEF900BF9DF81D
+:100BF0000000214601F0A8F98DF8010004B1641E3F
+:100C00009DF8010010F0010F01D0002CEFD18021E0
+:100C10000448FFF7B9FF0CB9FF2038BD9DF801006B
+:100C2000FBE700000010014010B501F05BF9002067
+:100C300010BD00002DE9FC410646FFF7A7FF17484D
+:100C4000FFF7C6FF074607F00200022802D0384629
+:100C5000BDE8FC8180211248FFF794FF3403202077
+:100C60008DF80000200C8DF80100200A8DF802009C
+:100C7000E0B28DF80300002505E01DF805000749E6
+:100C800001F062F96D1C042DF7D380210448FFF7B1
+:100C90007BFF0448FFF790FFDAE70000A086010021
+:100CA00000100140002D31012DE9FC4105460E46A2
+:100CB00017461D48FFF780FF00F0FF08B8F1000F4E
+:100CC00002D04046BDE8FC8180211848FFF75AFF5A
+:100CD000A819B0F5800F01D90120F3E703208DF8A2
+:100CE0000000280C8DF80100280A8DF80200E8B2F7
+:100CF0008DF80300002405E01DF804000A4901F006
+:100D000023F9641C042CF7D3002405E00649AA202B
+:100D100001F01AF93855641CB442F7D38021034816
+:100D2000FFF732FF0020CDE7A08601000010014050
+:100D30002DE9F84F04460E469346CDF800B02948F9
+:100D4000844200D200BFA019B0F5800F02D9012063
+:100D5000BDE8F88FB1462746C4F30B00251A1AE008
+:100D600007EB090105F58050814202D9A0EB070885
+:100D700000E0C846AF4209D1280BFFF75BFF00F047
+:100D8000FF0ABAF1000F01D05046E1E705F58055A2
+:100D9000A9EB08094744B9F1000FE1D1E0B2251AE7
+:100DA0001CE0A11905F58070814202D9A0EB04086E
+:100DB00000E0B04641462046009AFFF7C9FD00F02A
+:100DC000FF0ABAF1000F01D05046C1E705F5807562
+:100DD000A6EB08064444009840440090002EE0D161
+:100DE0000020B5E7007012000446204600F0D8F954
+:100DF0002DE9F04FADF20C4D4AA103C90DF580620B
+:100E000003C2002609E06A4610214FF41420FFF7C0
+:100E10004BFF054605B902E0761C032EF3D300BF55
+:100E2000032E04D301200DF20C4DBDE8F08F0022FB
+:100E300010216846FFF760FC05460DB10220F2E77D
+:100E4000062269460DF58060FFF7F3FA08B103202A
+:100E5000E9E79DF809909DF8080040EA09299DF806
+:100E6000070040EA09299DF8060040EA09299DF893
+:100E70000D409DF80C0040EA04249DF80B0040EA68
+:100E800004249DF80A0040EA04244FF4162BB4F51C
+:100E9000A05F01D20420C6E70020CDF80804A246D6
+:100EA00000262CE0BAF5806F02D34FF4806800E092
+:100EB000D046002709E00BEB06006A464146FFF7E3
+:100EC000F3FE054605B902E07F1C052FF3D300BFF2
+:100ED00025B10220FFF73CFC0520A4E7002709E02C
+:100EE0001DF80700C043C1B2DDF808040844CDF87E
+:100EF00008047F1C4745F3D34644AAEB080AA642E0
+:100F0000D0D3DDF80804484504D00220FFF720FCC8
+:100F1000062088E70548C0F800B0054804600020B6
+:100F200081E700005A4B3C2D1E0F000050000020AE
+:100F3000540000202DE9F04FADF5077D81468A462B
+:100F400015462F46002443E0B7F5007F02D34FF447
+:100F5000007600E03E464FF0000B0EE00AEB040086
+:100F600007AA3146FFF7A0FE8046B8F1000F00D176
+:100F700006E00BF1010000F0FF0BBBF1050FEDDB0C
+:100F800000BFB8F1000F04D001200DF5077DBDE8CA
+:100F9000F08F09EB0400324607A900F041F88046C3
+:100FA000B8F1000F01D00120EFE73444BF1B6420EB
+:100FB0006043B0FBF5F0024607A1019002A8FFF7DD
+:100FC00037F902AA1021552000F00AFC00F0ACFD10
+:100FD000AC42B9D30020D8E72533642525000000B2
+:100FE00010B50220FFF7B4FB002010BD4CF6CC403A
+:100FF0000149086070470000003000400149486026
+:1010000070470000003000400149886070470000D0
+:101010000030004001490860704700000030004087
+:101020002DE9F04107468846154615F0030F01D11A
+:10103000AD0802E0012000EB95053E46002406E0E5
+:1010400058F824103046FFF72DFC361D641CAC42C6
+:10105000F6D33E46002409E058F824103068884250
+:1010600002D00120BDE8F081361D641CAC42F3D3F0
+:101070000020F7E710B500214FF0006000F002F803
+:1010800010BD0000024A0A400243024B1A6070473A
+:1010900080FFFF1F08ED00E029B1064AD269024334
+:1010A000044BDA6104E0034AD2698243014BDA61FE
+:1010B000704700000010024029B1064A92690243BD
+:1010C000044B9A6104E0034A92698243014B9A619E
+:1010D000704700000010024070B58AB02F4A07CA5E
+:1010E00007AB07C32D4A0C3207CA04AB07C34FF442
+:1010F0001526FFF799FD002508E001AA0C213046CE
+:10110000FFF7D2FD044604B902E06D1C052DF4D3AF
+:1011100000BF00220C2101A8FFF7EEFA04460CB133
+:101120000AB070BD0A2201A907A8FFF782F960B1D1
+:10113000002506E0300BFFF77DFD044604B902E010
+:101140006D1C052DF6D300BFEAE701220A2104A891
+:10115000FFF7D2FA04A807C801AB07C3002518E0BF
+:1011600001AA0C213046FFF7E3FD044604B10FE06D
+:1011700001AA0C213046FFF797FD044604B107E0B1
+:101180000C2204A901A8FFF754F900B903E000BF3D
+:101190006D1C052DE4D300BF00BFC1E7782A00080D
+:1011A000044645F25550FFF735FF0520FFF726FFAF
+:1011B000C4F38F00FFF728FFFFF718FF00BFFEE71B
+:1011C00021B1028842F04002028004E002884FF61A
+:1011D000BF731A40028070470246002013890B42F9
+:1011E00001D0012000E00020704701468889704747
+:1011F0008181704710B50022028802F441520B88A9
+:101200004C8823438C882343CC8823430C89234375
+:101210004C8923438C892343CC8923431A4302807E
+:10122000838B4FF2FF74234083830B8A038210BDAC
+:1012300010B500F001F810BD0CB500200190009031
+:101240003248006840F480303049086000BF2F48C1
+:10125000006800F4003000900198401C0190009854
+:1012600018B90198B0F5A06FF1D12848006810F4C2
+:10127000003F02D00120009001E000200090009883
+:10128000012842D12248006840F01000204908603F
+:101290000846006820F0030008600846006840F037
+:1012A00002000860194840681849486008464068CC
+:1012B00048600846406840F48060486008464068DE
+:1012C00020F47C1048600846406840F4E81048600C
+:1012D0000846006840F08070086000BF0B48006856
+:1012E00010F0007FFAD00948406820F00300074959
+:1012F00048600846406840F00200486000BF03486C
+:10130000406800F00C000828F9D10CBD0010024024
+:101310000020024010B500F07BFD03480068401C2F
+:101320000149086010BD00006800002030B50020B1
+:1013300015490860154800684FF47A72B0FBF2F165
+:10134000B1F1807F00D31DE021F07F40401E4FF0BF
+:10135000E022506150170F22002807DA13071D0EF4
+:101360000B4B00F00F04241F1D5503E013071C0E48
+:10137000084B1C5400BF00204FF0E0229061072072
+:10138000106100BF30BD0000680000202000002078
+:1013900018ED00E000E400E010B51348006840F0EC
+:1013A00001001149086008464068104908400E498C
+:1013B0004860084600680E4908400B490860084626
+:1013C000006820F4802008600846406820F4FE0091
+:1013D00048604FF41F008860FFF72AFF4FF000605D
+:1013E0000449086010BD0000001002400000FFF832
+:1013F000FFFFF6FE08ED00E030380A2801D2012098
+:101400007047002070470000044A116800BF034A7B
+:101410001268521A8242FAD3704700006800002016
+:1014200010B5E22000F060F8A22000F05DF8A020E6
+:1014300000F05AF8C82000F057F8A42000F054F843
+:10144000402000F051F8252000F04EF805480078C3
+:1014500000F09FFA2F2000F047F8AF2000F044F88A
+:1014600010BD00001C00002010B5A52000F03CF8C5
+:1014700010BD000010B54FF4806106480068FFF70A
+:101480003EF83F237F220021084600F01DFB00F0BC
+:101490004BFB10BD1400002010B54FF480610548CF
+:1014A0000068FFF72CF83F237F220021084600F058
+:1014B0000BFB10BD1400002070B5002410E0204686
+:1014C00000F0D6FA002000F0CAFA002504E000205F
+:1014D00000F018F8681CC5B2802DF8DB601CC4B29F
+:1014E000102CECDB70BD000010B504464FF4806199
+:1014F0000348FFF747FB204600F0C4FA10BD000088
+:101500000010014010B504464FF480610348FFF716
+:101510003BFB204600F0B6FA10BD00000010014071
+:101520002DE9FF5F05460E469246AC48807950454E
+:1015300003DCAA48C079504501DA4FF02E0AA748CB
+:10154000007A00283AD1002431E0A4480068A34979
+:101550008979AAEB0101A14A127901FB020010F876
+:10156000048000271FE02819802802DAF01940289B
+:1015700003DB002004B0BDE8F09F0120B84010EA72
+:10158000080F07D0F219D1B22A19D0B2012200F007
+:101590000FFA06E0F219D1B22A19D0B2002200F0F7
+:1015A00007FA781CC7B2082FDDDB601CC4B28B4879
+:1015B0000079A042C9DC89480079DBE78748007AD6
+:1015C000012878D185494879C11700EB5171C910BC
+:1015D000A0EBC101002908DD80494879C11700EB63
+:1015E0005171C91001F1010806E07C494879C11721
+:1015F00000EB51714FEAE1087848007900FB08F0F0
+:10160000401CC0B20390754801688079AAEB0002C3
+:10161000039802FB00100290029890F800B0029824
+:10162000401C0290002741E000243BE0029807FBA9
+:101630000800005D01904FF000092EE0E8198028B5
+:1016400004DA06EBC4004844402801DB002091E79F
+:1016500009EBC40061494979884200DB19E00120A7
+:1016600000FA09F00199084209D006EBC4024A4485
+:10167000D1B2EA19D0B2012200F09AF908E006EBE3
+:10168000C4024A44D1B2EA19D0B2002200F090F963
+:1016900000BF09F1010000F0FF09B9F1080FCDDB2F
+:1016A000601CC4B24445C1DB781CC7B25F45BBDBDC
+:1016B00058465FE7FFE74948007A02286FD147495B
+:1016C0004879C11700EB5171C91001F1010B434872
+:1016D000007900FB0BF0C0B20290404801688079AD
+:1016E000AAEB0002029802FB001001903B4890F820
+:1016F0000490002003901FE00021002000BF0AE0BA
+:10170000364B1B795B1E039FDB1B4343DAB2019B05
+:10171000995C421CD0B25845F2DB39B9A9F10102FB
+:1017200002F0FF09B9F1000F01D106E005E0039ACC
+:10173000521CD2B2039200BFDEE700BF002446E095
+:101740004FF000083FE025480179019804FB0100B3
+:1017500010F80800009000272FE005EB0800802813
+:1017600004DA06EBC4003844402801DB002001E71E
+:1017700007EBC40019494979884200DB1BE00120CE
+:10178000B840009908420BD006EBC4023A44D1B2EB
+:1017900005EB0802D0B2012200F00AF90AE01AE0D3
+:1017A00006EBC4023A44D1B205EB0802D0B20022E3
+:1017B00000F0FEF800BF781CC7B2082FCDDB08F19F
+:1017C000010000F0FF08C845BDDB601CC4B25C45E9
+:1017D000B6DB4846CEE60020CCE6000070040020D0
+:1017E0002DE9F04106460F4614460C484079C0F1F9
+:1017F0003F00B84201DABDE8F08109E022783946BD
+:101800003046FFF78DFE0546681C3044C6B2641CA6
+:1018100020780028F2D100BFEDE70000700400201E
+:1018200008B501211020FFF747FC4FF48060ADF8A8
+:10183000000003208DF8020010208DF80300694697
+:101840002648FFF7CDF84FF40060ADF80000032004
+:101850008DF8020010208DF8030069461F48FFF73D
+:10186000BFF801210420FFF727FC01211C48FFF7E6
+:1018700041F94FF40040ADF8000003208DF802005C
+:1018800010208DF8030069461648FFF7A9F84FF4B9
+:1018900000411448FFF778F94FF480711148FFF7C1
+:1018A00073F900F01FFB00F029F80120FFF7ACFDF1
+:1018B000FFF7B6FDFFF7D8FD4FF4FA70FFF7A4FD70
+:1018C00000F016F8002000F0C1F8FFF7F5FD06491A
+:1018D000064800F045F8FFF7CDFD08BD00100140B7
+:1018E00000023000000801401000002070000020BD
+:1018F00010B5A420FFF7F8FD10BD000010B54FF49F
+:1019000080710B48FFF73EF94FF400610948FFF77B
+:1019100039F90120FFF778FD4FF400610548FFF722
+:1019200033F94FF480710248FFF72EF910BD000023
+:1019300000080140001001407F2008490968087034
+:1019400000200649096888703F20044909684870EA
+:10195000002002490968C870704700001800002084
+:10196000024A1060024A1160704700001400002013
+:101970001800002010B5044604F00F00FFF7B4FD76
+:1019800010BD10B50446102141EA2410FFF7ACFD4C
+:1019900010BD10B504468120FFF7A6FD3F2C03DDE6
+:1019A0003F20FFF7A1FD02E02046FFF79DFD10BD9F
+:1019B0002DE9F04105460C4616467F2D01DC3F2CF3
+:1019C00001DDBDE8F081E6B1E21704EB5272D210FE
+:1019D00005EBC2121C4B9A5C2146E31704EB5373D0
+:1019E000DB10A4EBC3070123BB401A43D3B220464C
+:1019F000E21704EB5272D21005EBC212124FBB5425
+:101A00001AE0E21704EB5272D21005EBC2120E4B31
+:101A10009A5C2146E31704EB5373DB10A4EBC30776
+:101A20000123BB409A432046E31704EB5373DB10BA
+:101A300005EBC313044FFA5423462A462146284691
+:101A400000F042F800BFBCE77000002010B504466B
+:101A500004F03F0141F04000FFF746FD10BD10B516
+:101A600004462046FFF78DFF2046FFF783FF10BD99
+:101A700010B5044604F00F0141F0B000FFF734FD4B
+:101A800010BD000010B504464FF480710648FFF702
+:101A900079F84FF47A71204600F056FA4FF48071CD
+:101AA0000148FFF771F810BD0008014070B5049CB3
+:101AB000044D286029716A71AB71EC710025014EEB
+:101AC000357270BD7004002010B57F2800DD7F20C6
+:101AD0007F2A00DD7F223F2900DD3F213F2B00DDF3
+:101AE0003F23104C24682478844202DD0D4C246886
+:101AF00020700C4C2468A478944202DA094C2468C3
+:101B0000A270084C246864788C4202DD054C24687D
+:101B10006170044C2468E4789C4202DA014C246829
+:101B2000E37010BD1800002070B500242CE01948A7
+:101B300000684178601CB1EBC00F00DB22E0154863
+:101B40000068C078B0EBC40F00DA1FE02046FFF752
+:101B50008FFF104909680878FFF781FF0D4800687A
+:101B6000057809E0802101FB04510B4A1268505CA2
+:101B7000FFF7C8FC681CC5B2064800688078A84218
+:101B8000F0DA00BF601CC4B2102CD0DB00BFFFF73E
+:101B9000D3FE70BD180000201400002008B50025F9
+:101BA00000266748406867490860FFF763FAFFF757
+:101BB000BDFBFFF739F8FFF733FEFFF75BFC7F2033
+:101BC00020230722052100905F48FFF76FFF4FF4A5
+:101BD00000415E48FEF7D8FFFFF70AF95C4908604C
+:101BE00008460068002870D1FFF756FC59A2002172
+:101BF0000846FFF7F5FDFFF797FFFEF789FE352052
+:101C0000FEF70AFE4E4D05F57036584805601EE099
+:101C100056480068FEF706FE0446042C11D0FFF774
+:101C20003BFC53A200210846FFF7DAFD55A2102124
+:101C30000020FFF7D5FDFFF777FF4FF47A70FFF72D
+:101C4000D3F84A48006800F50060484908604748F2
+:101C50000068B042DCD3FFF71FFC4EA2002108460B
+:101C6000FFF7BEFD51A210210020FFF7B9FDFFF7DD
+:101C70005BFF52480268524801683148FFF75AF941
+:101C8000334908600846006890B14EA22021002028
+:101C9000FFF7A6FD3BA230210020FFF7A1FDFFF7D3
+:101CA00043FF0220FEF754FD4FF47A70FFF79CF8D3
+:101CB000FFF796F947A220210020FFF791FDFFF7DB
+:101CC00033FF4FF47A70FFF76BFAFFF705FA1C4801
+:101CD00000681F49086008460068B0F1005F1ED91F
+:101CE000084600684049884219D2164800681449DD
+:101CF000884214D9134800683C4988420FD21148E1
+:101D000000683B4908600E490868FEF76CFA4FF41A
+:101D100080414803FFF7B6F9354800688047FFF770
+:101D2000BBFB34A200210846FFF75AFD34A2102164
+:101D30000020FFF755FDFFF7F7FE00BFFEE70000AC
+:101D400000400008080000208C1F00080008014027
+:101D5000040000204572617365204170706C6963F6
+:101D60006174696F6E2E2E2E0000000000000020AE
+:101D7000457261736520466C617368204661696CC9
+:101D8000000000005761697420746F2052657374FD
+:101D90006172740050726F6772616D204170706C77
+:101DA00069636174696F6E2E00000000506C65619C
+:101DB000736520576169742E2E2E00005400002098
+:101DC0005000002050726F6772616D204661696C2F
+:101DD00000000000526561647920746F20526573C1
+:101DE000746172740000000000C00020000004084C
+:101DF0000C0000204E6F20417070436F646521001D
+:101E00005665723A4941505F76312E3031000000FC
+:101E10000648002107E0026812B10268521E026003
+:101E2000001D4A1CD1B20029F5D070476C0000207B
+:101E300008B501211C20FFF73FF94FF48050ADF8A1
+:101E4000000003208DF8020010208DF80300694681
+:101E50001048FEF7C5FD8020ADF8000069460E4829
+:101E6000FEF7BEFD4FF48070ADF8000069460B48E8
+:101E7000FEF7B6FD4FF480510648FEF785FE80213F
+:101E80000548FEF781FE4FF480710448FEF77CFEA2
+:101E900008BD0000000C0140001001400008014096
+:101EA00008B501210920FFF707F94FF42040ADF8EC
+:101EB000000003208DF8020018208DF80300694609
+:101EC0000748FEF78DFD4FF48040ADF80000042078
+:101ED0008DF8030069460248FEF782FD08BD000048
+:101EE000000C014000B585B0FFF7A2FFFFF7D8FF57
+:101EF00001218803FFF7D0F80020ADF800004FF46F
+:101F00008270ADF802000020ADF804000220ADF8A8
+:101F100006000120ADF808004002ADF80A001820C4
+:101F2000ADF80C000020ADF80E000720ADF8100051
+:101F300069460448FFF75EF901210248FFF740F9BE
+:101F400005B000BD0038004070B506460D462C4671
+:101F500000E0641E02210C48FFF73EF908B9002C8E
+:101F6000F7D131460848FFF743F92C4600E0641EDC
+:101F700001210548FFF730F908B9002CF7D10248D4
+:101F8000FFF733F9C0B270BD003800400000000018
+:101F90000000005F00000007000700147F147F149A
+:101FA000242A7F2A122313086462364955225000DE
+:101FB00005030000001C2241000041221C00082AE9
+:101FC0001C2A0808083E08080050300000080808CD
+:101FD0000808006060000020100804023E514945D6
+:101FE0003E00427F400042615149462141454B310C
+:101FF0001814127F1027454545393C4A494930019C
+:10200000710905033649494936064949291E0036F2
+:102010003600000056360000000814224114141443
+:102020001414412214080002015109063249794171
+:102030003E7E1111117E7F494949363E4141412280
+:102040007F4141221C7F494949417F090901013EE5
+:10205000414151327F0808087F00417F4100204004
+:10206000413F017F081422417F404040407F0204ED
+:10207000027F7F0408107F3E4141413E7F090909EC
+:10208000063E4151215E7F09192946464949493199
+:1020900001017F01013F4040403F1F2040201F7F42
+:1020A0002018207F6314081463030478040361512B
+:1020B00049454300007F4141020408102041417F0F
+:1020C00000000402010204404040404000010204BC
+:1020D0000020545454787F484444383844444420C1
+:1020E000384444487F3854545418087E0901020883
+:1020F0001454543C7F0804047800447D4000204080
+:10210000443D00007F10284400417F40007C0418BB
+:1021100004787C0804047838444444387C1414144B
+:1021200008081414187C7C080404084854545420EB
+:10213000043F4440203C4040207C1C2040201C3C6C
+:102140004030403C44281028440C5050503C4464DB
+:10215000544C44000836410000007F000000413626
+:10216000080008082A1C08081C2A080800E0F038A3
+:102170000C0C0C0C38F8C000001F7FE080808080C1
+:10218000E0FF1F000000000101010101000000004C
+:1021900000101818FCFC0000000000000000000007
+:1021A000FFFF00000000000000000000010100002F
+:1021B0000000000000081C0C0C0C0C8CF8F0000057
+:1021C00000F0F89C8C86868383800000000101016A
+:1021D000010101010101000000081C0C0C0C0C8C19
+:1021E000F8F000000080C080818383C7FF7C00007E
+:1021F0000000010101010101000000000000008059
+:10220000C07038FCFC000000001C1E1B111810FFE1
+:10221000FF10180000000000000000010100000095
+:102220000000F4FC1C0C0C0C0C0000000080C383AC
+:10223000838383C7FE7800000000000101010101D3
+:102240000000000000C0F0781C0C0C0C080000001E
+:10225000003FFFC3838383C3FE7C000000000001B6
+:102260000101010100000000000C0C0C0C8CCC7C66
+:102270003C0C0000000080F07C0F03000000000018
+:1022800000000101000000000000000000F0F81C48
+:102290000C0C0C0CF8F0000000F8FF8F0706068FFE
+:1022A000FFF8000000000103030303010100000028
+:1022B00000F0F81C0C0C0C1CF8E000000001878EEC
+:1022C0008C8C8CEE7F1F00000000010101010100D9
+:1022D000000000000600000000000000000F0000E9
+:1022E0000F00000F00000F000000000000000000C1
+:1022F00000000000000000000000000000000000DE
+:1023000000000700001E00E01F00FF1FF8FF03FF92
+:102310001F00FF01000F000000000000000000008F
+:1023200000000000000000000000000000000000AD
+:102330000E000000C07F00F8FF01FCFF07FCFF0754
+:102340003E800F0E000E0E000E0E000E1E800FFCC3
+:10235000FF07FCFF07F8FF01C07F000000000E0030
+:10236000000070000E38000E38000E1C000E0E002B
+:102370000EFEFF0FFEFF0FFEFF0FFEFF0F00000E11
+:1023800000000E00000E00000E0000000E00000015
+:1023900060000F78800F7CC00F7CE00F1EF00F0EE6
+:1023A000F80E0E7C0E0E3E0E1E1F0EFE0F0EFC07CC
+:1023B0000EF8030EF0010E0000000E000000308049
+:1023C000013880033C80073C800F1E000F0E0E0E6C
+:1023D0000E0E0E0E0E0E1E1F0FFEFF0FFCFB07FC57
+:1023E000F903F0E0010000000F00000000F0000021
+:1023F000F80000FE0080EF00C0E700F0E1007CE0A4
+:10240000003EE000FEFF0FFEFF0FFEFF0FFEFF0F7E
+:1024100000E00000E0000E000000008001F88703EB
+:10242000FE8707FE870FFE070F0E030E8E030E8E2C
+:10243000030E8E070F8EFF070EFF070EFE0300FC34
+:10244000000000000E000000C07F00F0FF01F8FF58
+:1024500007FCFF073E0E0F0E070E0E070E0E070EAF
+:102460001E0F0F3EFF0F3CFE0738FE0330F8010041
+:1024700000000E0000000E00000E00000E00000E16
+:10248000000F0EE00F0EF80F0EFE0F8EFF00CE0FA6
+:1024900000FE0300FE00003E00001E0000000000E1
+:1024A0000E000000F0E001F8FB03FCFB07FEFF0F4D
+:1024B0001E1F0F0E0E0E0E0E0E0E0E0E1E1F0FFE08
+:1024C000FF0FFCFB07FCFB03F0E0010000000E0027
+:1024D0000000F08301F88703FC8F07FE9F0F1E1E8C
+:1024E0000F0E1C0E0E1C0E0E1C0E1E8E0FFCFF0778
+:1024F000FCFF03F8FF01C07F0000000000000000A7
+:102500000000005F00000007000700147F147F1424
+:10251000242A7F2A12231308646236495522500068
+:1025200005030000001C2241000041221C00082A73
+:102530001C2A0808083E0808005030000008080857
+:102540000808006060000020100804023E51494560
+:102550003E00427F400042615149462141454B3196
+:102560001814127F1027454545393C4A4949300126
+:10257000710905033649494936064949291E00367D
+:1025800036000000563600000008142241141414CE
+:1025900014144122140800020151090632497941FC
+:1025A0003E7E1111117E7F494949363E414141220B
+:1025B0007F4141221C7F494949417F090901013E70
+:1025C000414151327F0808087F00417F410020408F
+:1025D000413F017F081422417F404040407F020478
+:1025E000027F7F0408107F3E4141413E7F09090977
+:1025F000063E4151215E7F09192946464949493124
+:1026000001017F01013F4040403F1F2040201F7FCC
+:102610002018207F631408146303047804036151B5
+:1026200049454300007F4141020408102041417F99
+:102630000000040201020440404040400001020446
+:102640000020545454787F4844443838444444204B
+:10265000384444487F3854545418087E090102080D
+:102660001454543C7F0804047800447D400020400A
+:10267000443D00007F10284400417F40007C041846
+:1026800004787C0804047838444444387C141414D6
+:1026900008081414187C7C08040408485454542076
+:1026A000043F4440203C4040207C1C2040201C3CF7
+:1026B0004030403C44281028440C5050503C446466
+:1026C000544C44000836410000007F0000004136B1
+:1026D000080008082A1C08081C2A080800E0F0382E
+:1026E0000C0C0C0C38F8C000001F7FE0808080804C
+:1026F000E0FF1F00000000010101010100000000D7
+:1027000000101818FCFC0000000000000000000091
+:10271000FFFF0000000000000000000001010000B9
+:102720000000000000081C0C0C0C0C8CF8F00000E1
+:1027300000F0F89C8C8686838380000000010101F4
+:10274000010101010101000000081C0C0C0C0C8CA3
+:10275000F8F000000080C080818383C7FF7C000008
+:1027600000000101010101010000000000000080E3
+:10277000C07038FCFC000000001C1E1B111810FF6C
+:10278000FF10180000000000000000010100000020
+:102790000000F4FC1C0C0C0C0C0000000080C38337
+:1027A000838383C7FE78000000000001010101015E
+:1027B0000000000000C0F0781C0C0C0C08000000A9
+:1027C000003FFFC3838383C3FE7C00000000000141
+:1027D0000101010100000000000C0C0C0C8CCC7CF1
+:1027E0003C0C0000000080F07C0F030000000000A3
+:1027F00000000101000000000000000000F0F81CD3
+:102800000C0C0C0CF8F0000000F8FF8F0706068F88
+:10281000FFF80000000001030303030101000000B2
+:1028200000F0F81C0C0C0C1CF8E000000001878E76
+:102830008C8C8CEE7F1F0000000001010101010063
+:10284000000000000600000000000000000F000073
+:102850000F00000F00000F0000000000000000004B
+:102860000000000000000000000000000000000068
+:1028700000000700001E00E01F00FF1FF8FF03FF1D
+:102880001F00FF01000F000000000000000000001A
+:102890000000000000000000000000000000000038
+:1028A0000E000000C07F00F8FF01FCFF07FCFF07DF
+:1028B0003E800F0E000E0E000E0E000E1E800FFC4E
+:1028C000FF07FCFF07F8FF01C07F000000000E00BB
+:1028D000000070000E38000E38000E1C000E0E00B6
+:1028E0000EFEFF0FFEFF0FFEFF0FFEFF0F00000E9C
+:1028F00000000E00000E00000E0000000E000000A0
+:1029000060000F78800F7CC00F7CE00F1EF00F0E70
+:10291000F80E0E7C0E0E3E0E1E1F0EFE0F0EFC0756
+:102920000EF8030EF0010E0000000E0000003080D3
+:10293000013880033C80073C800F1E000F0E0E0EF6
+:102940000E0E0E0E0E0E1E1F0FFEFF0FFCFB07FCE1
+:10295000F903F0E0010000000F00000000F00000AB
+:10296000F80000FE0080EF00C0E700F0E1007CE02E
+:10297000003EE000FEFF0FFEFF0FFEFF0FFEFF0F09
+:1029800000E00000E0000E000000008001F8870376
+:10299000FE8707FE870FFE070F0E030E8E030E8EB7
+:1029A000030E8E070F8EFF070EFF070EFE0300FCBF
+:1029B000000000000E000000C07F00F0FF01F8FFE3
+:1029C00007FCFF073E0E0F0E070E0E070E0E070E3A
+:1029D0001E0F0F3EFF0F3CFE0738FE0330F80100CC
+:1029E00000000E0000000E00000E00000E00000EA1
+:1029F000000F0EE00F0EF80F0EFE0F8EFF00CE0F31
+:102A000000FE0300FE00003E00001E00000000006B
+:102A10000E000000F0E001F8FB03FCFB07FEFF0FD7
+:102A20001E1F0F0E0E0E0E0E0E0E0E0E1E1F0FFE92
+:102A3000FF0FFCFB07FCFB03F0E0010000000E00B1
+:102A40000000F08301F88703FC8F07FE9F0F1E1E16
+:102A50000F0E1C0E0E1C0E0E1C0E1E8E0FFCFF0702
+:102A6000FCFF03F8FF01C07F00000000D0B2CFAA36
+:102A7000C6D5AABBCCDD0000D0B2CFAAC6D5AABBB2
+:102A8000CCDD0000A0A1A2A3A4A50E0F0A050000A2
+:102A90005A4B3C2D1E0F00000000000000000000FB
+:102AA000000000000F1E2D3C4B5A000000000000EB
+:102AB000000000000000000021104220633084402C
+:102AC000A550C660E770088129914AA16BB18CC1FD
+:102AD000ADD1CEE1EFF13112100273325222B55274
+:102AE0009442F772D662399318837BB35AA3BDD34D
+:102AF0009CC3FFF3DEE36224433420040114E66444
+:102B0000C774A44485546AA54BB528850995EEE59C
+:102B1000CFF5ACC58DD55336722611163006D77653
+:102B2000F6669556B4465BB77AA719973887DFF7EC
+:102B3000FEE79DD7BCC7C448E5588668A77840081B
+:102B4000611802282338CCC9EDD98EE9AFF948893C
+:102B500069990AA92BB9F55AD44AB77A966A711AB3
+:102B6000500A333A122AFDDBDCCBBFFB9EEB799B8C
+:102B7000588B3BBB1AABA66C877CE44CC55C222C03
+:102B8000033C600C411CAEED8FFDECCDCDDD2AADDC
+:102B90000BBD688D499D977EB66ED55EF44E133E93
+:102BA000322E511E700E9FFFBEEFDDDFFCCF1BBF2C
+:102BB0003AAF599F788F8891A981CAB1EBA10CD106
+:102BC0002DC14EF16FE18010A100C230E32004500E
+:102BD000254046706760B9839893FBA3DAB33DC381
+:102BE0001CD37FE35EF3B1029012F322D23235425E
+:102BF000145277625672EAB5CBA5A89589856EF511
+:102C00004FE52CD50DC5E234C324A01481046674AD
+:102C1000476424540544DBA7FAB79987B8975FE760
+:102C20007EF71DC73CD7D326F2369106B0165766FD
+:102C30007676154634564CD96DC90EF92FE9C899E8
+:102C4000E9898AB9ABA94458654806782768C0184D
+:102C5000E1088238A3287DCB5CDB3FEB1EFBF98BC0
+:102C6000D89BBBAB9ABB754A545A376A167AF10A9D
+:102C7000D01AB32A923A2EFD0FED6CDD4DCDAABDD0
+:102C80008BADE89DC98D267C076C645C454CA23CED
+:102C9000832CE01CC10C1FEF3EFF5DCF7CDF9BAFA0
+:102CA000BABFD98FF89F176E367E554E745E932E3D
+:102CB000B23ED10EF01E0000D82C0008000000200B
+:102CC000700000006C010008482D00087000002012
+:102CD00080370000880100080000000000000000AC
+:102CE00000000000000000000000000000000000E4
+:102CF000000000002500000000A24A0400000000BF
+:102D0000000000000102030406070809000080C05B
+:102D1000E0F0F8FCFE01FF000000000000000000F1
+:102D200000600900FF00000000000000000000003B
+:102D30000000000000000000000000000000000093
+:102D40000000000000000000000000000000000083
+:102D50000000000000000000000000000000000073
+:102D60000000000000000000000000000000000063
+:102D70000000000000000000000000000000000053
+:102D80000000000000000000000000000000000043
+:102D90000000000000000000000000000000000033
+:102DA0000000000000000000000000000000000023
+:102DB0000000000000000000000000000000000013
+:102DC0000000000000000000000000000000000003
+:102DD00000000000000000000000000000000000F3
+:102DE00000000000000000000000000000000000E3
+:102DF00000000000000000000000000000000000D3
+:102E000000000000000000000000000000000000C2
+:102E100000000000000000000000000000000000B2
+:102E200000000000000000000000000000000000A2
+:102E30000000000000000000000000000000000092
+:102E40000000000000000000000000000000000082
+:102E50000000000000000000000000000000000072
+:102E60000000000000000000000000000000000062
+:102E70000000000000000000000000000000000052
+:102E80000000000000000000000000000000000042
+:102E90000000000000000000000000000000000032
+:102EA0000000000000000000000000000000000022
+:102EB0000000000000000000000000000000000012
+:102EC0000000000000000000000000000000000002
+:102ED00000000000000000000000000000000000F2
+:102EE00000000000000000000000000000000000E2
+:102EF00000000000000000000000000000000000D2
+:102F000000000000000000000000000000000000C1
+:102F100000000000000000000000000000000000B1
+:102F200000000000000000000000000000000000A1
+:102F30000000000000000000000000000000000091
+:102F40000000000000000000000000000000000081
+:102F50000000000000000000000000000000000071
+:102F60000000000000000000000000000000000061
+:102F70000000000000000000000000000000000051
+:102F80000000000000000000000000000000000041
+:102F90000000000000000000000000000000000031
+:102FA0000000000000000000000000000000000021
+:102FB0000000000000000000000000000000000011
+:102FC0000000000000000000000000000000000001
+:102FD00000000000000000000000000000000000F1
+:102FE00000000000000000000000000000000000E1
+:102FF00000000000000000000000000000000000D1
+:1030000000000000000000000000000000000000C0
+:1030100000000000000000000000000000000000B0
+:1030200000000000000000000000000000000000A0
+:103030000000000000000000000000000000000090
+:103040000000000000000000000000000000000080
+:103050000000000000000000000000000000000070
+:103060000000000000000000000000000000000060
+:103070000000000000000000000000000000000050
+:103080000000000000000000000000000000000040
+:103090000000000000000000000000000000000030
+:1030A0000000000000000000000000000000000020
+:1030B0000000000000000000000000000000000010
+:1030C0000000000000000000000000000000000000
+:1030D00000000000000000000000000000000000F0
+:1030E00000000000000000000000000000000000E0
+:1030F00000000000000000000000000000000000D0
+:1031000000000000000000000000000000000000BF
+:1031100000000000000000000000000000000000AF
+:10312000000000000000000000000000000000009F
+:10313000000000000000000000000000000000008F
+:10314000000000000000000000000000000000007F
+:10315000000000000000000000000000000000006F
+:10316000000000000000000000000000000000005F
+:10317000000000000000000000000000000000004F
+:10318000000000000000000000000000000000003F
+:10319000000000000000000000000000000000002F
+:1031A000000000000000000000000000000000001F
+:1031B000000000000000000000000000000000000F
+:1031C00000000000000000000000000000000000FF
+:1031D00000000000000000000000000000000000EF
+:1031E00000000000000000000000000000000000DF
+:1031F00000000000000000000000000000000000CF
+:1032000000000000000000000000000000000000BE
+:1032100000000000000000000000000000000000AE
+:10322000000000000000000000000000000000009E
+:10323000000000000000000000000000000000008E
+:10324000000000000000000000000000000000007E
+:10325000000000000000000000000000000000006E
+:10326000000000000000000000000000000000005E
+:10327000000000000000000000000000000000004E
+:10328000000000000000000000000000000000003E
+:10329000000000000000000000000000000000002E
+:1032A000000000000000000000000000000000001E
+:1032B000000000000000000000000000000000000E
+:1032C00000000000000000000000000000000000FE
+:1032D00000000000000000000000000000000000EE
+:1032E00000000000000000000000000000000000DE
+:1032F00000000000000000000000000000000000CE
+:1033000000000000000000000000000000000000BD
+:1033100000000000000000000000000000000000AD
+:10332000000000000000000000000000000000009D
+:10333000000000000000000000000000000000008D
+:10334000000000000000000000000000000000007D
+:10335000000000000000000000000000000000006D
+:10336000000000000000000000000000000000005D
+:10337000000000000000000000000000000000004D
+:10338000000000000000000000000000000000003D
+:10339000000000000000000000000000000000002D
+:1033A000000000000000000000000000000000001D
+:1033B000000000000000000000000000000000000D
+:1033C00000000000000000000000000000000000FD
+:1033D00000000000000000000000000000000000ED
+:1033E00000000000000000000000000000000000DD
+:1033F00000000000000000000000000000000000CD
+:1034000000000000000000000000000000000000BC
+:1034100000000000000000000000000000000000AC
+:10342000000000000000000000000000000000009C
+:10343000000000000000000000000000000000008C
+:10344000000000000000000000000000000000007C
+:10345000000000000000000000000000000000006C
+:10346000000000000000000000000000000000005C
+:10347000000000000000000000000000000000004C
+:10348000000000000000000000000000000000003C
+:10349000000000000000000000000000000000002C
+:1034A000000000000000000000000000000000001C
+:1034B000000000000000000000000000000000000C
+:1034C00000000000000000000000000000000000FC
+:1034D00000000000000000000000000000000000EC
+:1034E00000000000000000000000000000000000DC
+:1034F00000000000000000000000000000000000CC
+:1035000000000000000000000000000000000000BB
+:1035100000000000000000000000000000000000AB
+:10352000000000000000000000000000000000009B
+:10353000000000000000000000000000000000008B
+:10354000000000000000000000000000000000007B
+:10355000000000000000000000000000000000006B
+:10356000000000000000000000000000000000005B
+:10357000000000000000000000000000000000004B
+:10358000000000000000000000000000000000003B
+:10359000000000000000000000000000000000002B
+:1035A000000000000000000000000000000000001B
+:1035B000000000000000000000000000000000000B
+:1035C00000000000000000000000000000000000FB
+:1035D00000000000000000000000000000000000EB
+:1035E00000000000000000000000000000000000DB
+:1035F00000000000000000000000000000000000CB
+:1036000000000000000000000000000000000000BA
+:1036100000000000000000000000000000000000AA
+:10362000000000000000000000000000000000009A
+:10363000000000000000000000000000000000008A
+:10364000000000000000000000000000000000007A
+:10365000000000000000000000000000000000006A
+:10366000000000000000000000000000000000005A
+:10367000000000000000000000000000000000004A
+:10368000000000000000000000000000000000003A
+:10369000000000000000000000000000000000002A
+:1036A000000000000000000000000000000000001A
+:1036B000000000000000000000000000000000000A
+:1036C00000000000000000000000000000000000FA
+:1036D00000000000000000000000000000000000EA
+:1036E00000000000000000000000000000000000DA
+:1036F00000000000000000000000000000000000CA
+:1037000000000000000000000000000000000000B9
+:1037100000000000000000000000000000000000A9
+:103720000000000000000000000000000000000099
+:103730000000000000000000000000000000000089
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037A0000000000000000000000000000000000019
+:1037B0000000000000000000000000000000000009
+:1037C00000000000000000000000000000000000F9
+:1037D00000000000000000000000000000000000E9
+:1037E00000000000000000000000000000000000D9
+:1037F00000000000000000000000000000000000C9
+:1038000080656778000000000000000000000000F4
+:1038100000000000000000000000000000000000A8
+:103820000000000000000000000000000000000098
+:103830000000000000000000000000000000000088
+:103840000000000000000000000000000000000078
+:103850000000000000000000000000000000000068
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038A0000000000000000000000000000000000018
+:1038B0000000000000000000000000000000000008
+:1038C00000000000000000000000000000000000F8
+:1038D00000000000000000000000000000000000E8
+:1038E00000000000000000000000000000000000D8
+:1038F00000000000000000000000000000000000C8
+:1039000000000000000000000000000000000000B7
+:1039100000000000000000000000000000000000A7
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:103980000000000000000000000000000000000037
+:103990000000000000000000000000000000000027
+:1039A0000000000000000000000000000000000017
+:1039B0000000000000000000000000000000000007
+:1039C00000000000000000000000000000000000F7
+:1039D00000000000000000000000000000000000E7
+:1039E00000000000000000000000000000000000D7
+:1039F00000000000000000000000000000000000C7
+:103A000000000000000000000000000000000000B6
+:103A100000000000000000000000000000000000A6
+:103A20000000000000000000000000000000000096
+:103A30000000000000000000000000000000000086
+:103A40000000000000000000000000000000000076
+:103A50000000000000000000000000000000000066
+:103A60000000000000000000000000000000000056
+:103A70000000000000000000000000000000000046
+:103A80000000000000000000000000000000000036
+:103A90000000000000000000000000000000000026
+:103AA0000000000000000000000000000000000016
+:103AB0000000000000000000000000000000000006
+:103AC00000000000000000000000000000000000F6
+:103AD00000000000000000000000000000000000E6
+:103AE00000000000000000000000000000000000D6
+:103AF00000000000000000000000000000000000C6
+:103B000000000000000000000000000000000000B5
+:103B100000000000000000000000000000000000A5
+:103B20000000000000000000000000000000000095
+:103B30000000000000000000000000000000000085
+:103B40000000000000000000000000000000000075
+:103B50000000000000000000000000000000000065
+:103B60000000000000000000000000000000000055
+:103B70000000000000000000000000000000000045
+:103B80000000000000000000000000000000000035
+:103B90000000000000000000000000000000000025
+:103BA0000000000000000000000000000000000015
+:103BB0000000000000000000000000000000000005
+:103BC00000000000000000000000000000000000F5
+:103BD00000000000000000000000000000000000E5
+:103BE00000000000000000000000000000000000D5
+:103BF00000000000000000000000000000000000C5
+:103C000000000000000000000000000000000000B4
+:103C100000000000000000000000000000000000A4
+:103C20000000000000000000000000000000000094
+:103C30000000000000000000000000000000000084
+:103C40000000000000000000000000000000000074
+:103C50000000000000000000000000000000000064
+:103C60000000000000000000000000000000000054
+:103C70000000000000000000000000000000000044
+:103C80000000000000000000000000000000000034
+:103C90000000000000000000000000000000000024
+:103CA0000000000000000000000000000000000014
+:103CB0000000000000000000000000000000000004
+:103CC00000000000000000000000000000000000F4
+:103CD00000000000000000000000000000000000E4
+:103CE00000000000000000000000000000000000D4
+:103CF00000000000000000000000000000000000C4
+:103D000000000000000000000000000000000000B3
+:103D100000000000000000000000000000000000A3
+:103D20000000000000000000000000000000000093
+:103D30000000000000000000000000000000000083
+:103D40000000000000000000000000000000000073
+:103D50000000000000000000000000000000000063
+:103D60000000000000000000000000000000000053
+:103D70000000000000000000000000000000000043
+:103D80000000000000000000000000000000000033
+:103D90000000000000000000000000000000000023
+:103DA0000000000000000000000000000000000013
+:103DB0000000000000000000000000000000000003
+:103DC00000000000000000000000000000000000F3
+:103DD00000000000000000000000000000000000E3
+:103DE00000000000000000000000000000000000D3
+:103DF00000000000000000000000000000000000C3
+:103E000000000000000000000000000000000000B2
+:103E100000000000000000000000000000000000A2
+:103E20000000000000000000000000000000000092
+:103E30000000000000000000000000000000000082
+:103E40000000000000000000000000000000000072
+:103E50000000000000000000000000000000000062
+:103E60000000000000000000000000000000000052
+:103E70000000000000000000000000000000000042
+:103E80000000000000000000000000000000000032
+:103E90000000000000000000000000000000000022
+:103EA0000000000000000000000000000000000012
+:103EB0000000000000000000000000000000000002
+:103EC00000000000000000000000000000000000F2
+:103ED00000000000000000000000000000000000E2
+:103EE00000000000000000000000000000000000D2
+:103EF00000000000000000000000000000000000C2
+:103F000000000000000000000000000000000000B1
+:103F100000000000000000000000000000000000A1
+:103F20000000000000000000000000000000000091
+:103F30000000000000000000000000000000000081
+:103F40000000000000000000000000000000000071
+:103F50000000000000000000000000000000000061
+:103F60000000000000000000000000000000000051
+:103F70000000000000000000000000000000000041
+:103F80000000000000000000000000000000000031
+:103F90000000000000000000000000000000000021
+:103FA0000000000000000000000000000000000011
+:103FB0000000000000000000000000000000000001
+:103FC00000000000000000000000000000000000F1
+:103FD00000000000000000000000000000000000E1
+:103FE00000000000000000000000000000000000D1
+:103FF00000000000000000000000000000000000C1
+:00000001FF
diff --git a/g401302/hex/readme.txt b/g401302/hex/readme.txt
new file mode 100644
index 0000000..8a9f258
--- /dev/null
+++ b/g401302/hex/readme.txt
@@ -0,0 +1,14 @@
+Éú³É°üº¬bootloaderºÍapplicationµÄºÏ²¢.hex,²»ÐèÒª¼ÓÃÜ
+1£¬ÔÚapplicationĿ¼Ï±àдmerge.iniÎļþ
+2£¬ÔÚhexĿ¼Ï·ÅbootloaderµÄ.hexÎļþ£¬ÕâÀïÊÇSTM32IAPCombine.hex
+3£¬keil optionsÀïµÄdebugÀïÃæÑ¡Ôñuse simulator£¬°´ctrl+F5ÔÚhexĿ¼ÏÂÉú³ÉºÏ²¢.hex,ÕâÀïÊÇwaterctrl_combine.hex
+4£¬´ò¿ªseggerÏÂJ-Flash
+1) File ->open data file (Ñ¡ÔñÉú³ÉµÄwaterctrl_combine.hex)
+2) Option->
+project settings --Target InterfaceÑ¡ÔñSWD
+project settings --CPUÑ¡ÔñDevice,ST STM32F101RB,¹´Ñ¡Check core ID
+3)target --connect,Á¬½Ó³É¹¦ºó°´F7ÏÂÔØ£¬F9ÔËÐÐ
+
+
+##STM32IAPCombine51.hex G401302µÄbootloader
+##STM32IAPCombine50.hex G401300µÄbootloader
\ No newline at end of file
diff --git a/g401302/lib/G401_drv_hw_V04.lib b/g401302/lib/G401_drv_hw_V04.lib
new file mode 100644
index 0000000..d744d92
--- /dev/null
+++ b/g401302/lib/G401_drv_hw_V04.lib
Binary files differ
diff --git a/g401302/lib/g401_uart5_v001.lib b/g401302/lib/g401_uart5_v001.lib
new file mode 100644
index 0000000..94ae122
--- /dev/null
+++ b/g401302/lib/g401_uart5_v001.lib
Binary files differ
diff --git a/g401302/project/JLinkSettings.ini b/g401302/project/JLinkSettings.ini
new file mode 100644
index 0000000..2d53bb4
--- /dev/null
+++ b/g401302/project/JLinkSettings.ini
@@ -0,0 +1,35 @@
+[BREAKPOINTS]
+ForceImpTypeAny = 0
+ShowInfoWin = 1
+EnableFlashBP = 2
+BPDuringExecution = 0
+[CFI]
+CFISize = 0x00
+CFIAddr = 0x00
+[CPU]
+OverrideMemMap = 0
+AllowSimulation = 1
+ScriptFile=""
+[FLASH]
+CacheExcludeSize = 0x00
+CacheExcludeAddr = 0x00
+MinNumBytesFlashDL = 0
+SkipProgOnCRCMatch = 1
+VerifyDownload = 1
+AllowCaching = 1
+EnableFlashDL = 2
+Override = 0
+Device="UNSPECIFIED"
+[GENERAL]
+WorkRAMSize = 0x00
+WorkRAMAddr = 0x00
+RAMUsageLimit = 0x00
+[SWO]
+SWOLogFile=""
+[MEM]
+RdOverrideOrMask = 0x00
+RdOverrideAndMask = 0xFFFFFFFF
+RdOverrideAddr = 0xFFFFFFFF
+WrOverrideOrMask = 0x00
+WrOverrideAndMask = 0xFFFFFFFF
+WrOverrideAddr = 0xFFFFFFFF
diff --git a/g401302/project/g401302.uvopt b/g401302/project/g401302.uvopt
new file mode 100644
index 0000000..156579a
--- /dev/null
+++ b/g401302/project/g401302.uvopt
@@ -0,0 +1,1388 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_opt.xsd">
+
+ <SchemaVersion>1.0</SchemaVersion>
+
+ <Header>### uVision Project, (C) Keil Software</Header>
+
+ <Extensions>
+ <cExt>*.c</cExt>
+ <aExt>*.s*; *.src; *.a*</aExt>
+ <oExt>*.obj</oExt>
+ <lExt>*.lib</lExt>
+ <tExt>*.txt; *.h; *.inc</tExt>
+ <pExt>*.plm</pExt>
+ <CppX>*.cpp</CppX>
+ </Extensions>
+
+ <DaveTm>
+ <dwLowDateTime>0</dwLowDateTime>
+ <dwHighDateTime>0</dwHighDateTime>
+ </DaveTm>
+
+ <Target>
+ <TargetName>flow</TargetName>
+ <ToolsetNumber>0x4</ToolsetNumber>
+ <ToolsetName>ARM-ADS</ToolsetName>
+ <TargetOption>
+ <CLKADS>8000000</CLKADS>
+ <OPTTT>
+ <gFlags>1</gFlags>
+ <BeepAtEnd>1</BeepAtEnd>
+ <RunSim>1</RunSim>
+ <RunTarget>0</RunTarget>
+ </OPTTT>
+ <OPTHX>
+ <HexSelection>1</HexSelection>
+ <FlashByte>65535</FlashByte>
+ <HexRangeLowAddress>0</HexRangeLowAddress>
+ <HexRangeHighAddress>0</HexRangeHighAddress>
+ <HexOffset>0</HexOffset>
+ </OPTHX>
+ <OPTLEX>
+ <PageWidth>79</PageWidth>
+ <PageLength>66</PageLength>
+ <TabStop>8</TabStop>
+ <ListingPath>..\outFlow\</ListingPath>
+ </OPTLEX>
+ <ListingPage>
+ <CreateCListing>1</CreateCListing>
+ <CreateAListing>1</CreateAListing>
+ <CreateLListing>1</CreateLListing>
+ <CreateIListing>0</CreateIListing>
+ <AsmCond>1</AsmCond>
+ <AsmSymb>1</AsmSymb>
+ <AsmXref>0</AsmXref>
+ <CCond>1</CCond>
+ <CCode>0</CCode>
+ <CListInc>0</CListInc>
+ <CSymb>0</CSymb>
+ <LinkerCodeListing>0</LinkerCodeListing>
+ </ListingPage>
+ <OPTXL>
+ <LMap>1</LMap>
+ <LComments>1</LComments>
+ <LGenerateSymbols>1</LGenerateSymbols>
+ <LLibSym>1</LLibSym>
+ <LLines>1</LLines>
+ <LLocSym>1</LLocSym>
+ <LPubSym>1</LPubSym>
+ <LXref>0</LXref>
+ <LExpSel>0</LExpSel>
+ </OPTXL>
+ <OPTFL>
+ <tvExp>1</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <IsCurrentTarget>1</IsCurrentTarget>
+ </OPTFL>
+ <CpuCode>255</CpuCode>
+ <Books>
+ <Book>
+ <Number>0</Number>
+ <Title>Reference Manual</Title>
+ <Path>DATASHTS\ST\STM32F10xxx.PDF</Path>
+ </Book>
+ <Book>
+ <Number>1</Number>
+ <Title>Technical Reference Manual</Title>
+ <Path>datashts\arm\cortex_m3\r1p1\DDI0337E_CORTEX_M3_R1P1_TRM.PDF</Path>
+ </Book>
+ <Book>
+ <Number>2</Number>
+ <Title>Generic User Guide</Title>
+ <Path>datashts\arm\cortex_m3\r2p1\DUI0552A_CORTEX_M3_DGUG.PDF</Path>
+ </Book>
+ </Books>
+ <DllOpt>
+ <SimDllName>SARMCM3.DLL</SimDllName>
+ <SimDllArguments>-REMAP</SimDllArguments>
+ <SimDlgDllName>DCM.DLL</SimDlgDllName>
+ <SimDlgDllArguments>-pCM3</SimDlgDllArguments>
+ <TargetDllName>SARMCM3.DLL</TargetDllName>
+ <TargetDllArguments></TargetDllArguments>
+ <TargetDlgDllName>TCM.DLL</TargetDlgDllName>
+ <TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
+ </DllOpt>
+ <DebugOpt>
+ <uSim>0</uSim>
+ <uTrg>1</uTrg>
+ <sLdApp>1</sLdApp>
+ <sGomain>1</sGomain>
+ <sRbreak>1</sRbreak>
+ <sRwatch>1</sRwatch>
+ <sRmem>1</sRmem>
+ <sRfunc>1</sRfunc>
+ <sRbox>1</sRbox>
+ <tLdApp>1</tLdApp>
+ <tGomain>1</tGomain>
+ <tRbreak>1</tRbreak>
+ <tRwatch>1</tRwatch>
+ <tRmem>1</tRmem>
+ <tRfunc>0</tRfunc>
+ <tRbox>1</tRbox>
+ <sRunDeb>0</sRunDeb>
+ <sLrtime>0</sLrtime>
+ <nTsel>7</nTsel>
+ <sDll></sDll>
+ <sDllPa></sDllPa>
+ <sDlgDll></sDlgDll>
+ <sDlgPa></sDlgPa>
+ <sIfile>.\merge.ini</sIfile>
+ <tDll></tDll>
+ <tDllPa></tDllPa>
+ <tDlgDll></tDlgDll>
+ <tDlgPa></tDlgPa>
+ <tIfile></tIfile>
+ <pMon>Segger\JL2CM3.dll</pMon>
+ </DebugOpt>
+ <TargetDriverDllRegistry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>JL2CM3</Key>
+ <Name>-U20370421 -O718 -S9 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC2000 -FN1 -FF0STM32F10x_512 -FS08000000 -FL080000</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>DLGUARM</Key>
+ <Name>(106=-1,-1,-1,-1,0)(107=-1,-1,-1,-1,0)</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>DLGTARM</Key>
+ <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>UL2CM3</Key>
+ <Name>-UV0010M9E -O718 -S10 -C0 -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC2000 -FN1 -FF0STM32F10x_512 -FS08000000 -FL040000</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>DLGDARM</Key>
+ <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=90,120,456,345,0)(1009=-1,-1,-1,-1,0)</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>ARMDBGFLAGS</Key>
+ <Name>-T0</Name>
+ </SetRegEntry>
+ </TargetDriverDllRegistry>
+ <Breakpoint>
+ <Bp>
+ <Number>0</Number>
+ <Type>0</Type>
+ <LineNumber>296</LineNumber>
+ <EnabledFlag>0</EnabledFlag>
+ <Address>134296172</Address>
+ <ByteObject>0</ByteObject>
+ <ManyObjects>0</ManyObjects>
+ <SizeOfObject>0</SizeOfObject>
+ <BreakByAccess>0</BreakByAccess>
+ <BreakIfRCount>1</BreakIfRCount>
+ <Filename></Filename>
+ <ExecCommand></ExecCommand>
+ <Expression>\\G401302_flow\../../supwisdom/sp_data.c\296</Expression>
+ </Bp>
+ <Bp>
+ <Number>1</Number>
+ <Type>0</Type>
+ <LineNumber>623</LineNumber>
+ <EnabledFlag>0</EnabledFlag>
+ <Address>134295132</Address>
+ <ByteObject>0</ByteObject>
+ <ManyObjects>0</ManyObjects>
+ <SizeOfObject>0</SizeOfObject>
+ <BreakByAccess>0</BreakByAccess>
+ <BreakIfRCount>1</BreakIfRCount>
+ <Filename></Filename>
+ <ExecCommand></ExecCommand>
+ <Expression>\\G401302_flow\../../supwisdom/sp_consume.c\623</Expression>
+ </Bp>
+ <Bp>
+ <Number>2</Number>
+ <Type>0</Type>
+ <LineNumber>206</LineNumber>
+ <EnabledFlag>1</EnabledFlag>
+ <Address>134291598</Address>
+ <ByteObject>0</ByteObject>
+ <ManyObjects>0</ManyObjects>
+ <SizeOfObject>0</SizeOfObject>
+ <BreakByAccess>0</BreakByAccess>
+ <BreakIfRCount>1</BreakIfRCount>
+ <Filename></Filename>
+ <ExecCommand></ExecCommand>
+ <Expression>\\G401302_flow\../../supwisdom/sp_communicate.c\206</Expression>
+ </Bp>
+ </Breakpoint>
+ <WatchWindow1>
+ <Ww>
+ <count>0</count>
+ <WinNumber>1</WinNumber>
+ <ItemText>60*4095/653</ItemText>
+ </Ww>
+ <Ww>
+ <count>1</count>
+ <WinNumber>1</WinNumber>
+ <ItemText>cardkey
+</ItemText>
+ </Ww>
+ <Ww>
+ <count>2</count>
+ <WinNumber>1</WinNumber>
+ <ItemText>usart_info</ItemText>
+ </Ww>
+ </WatchWindow1>
+ <MemoryWindow1>
+ <Mm>
+ <WinNumber>1</WinNumber>
+ <SubType>0</SubType>
+ <ItemText>0x20004EC0</ItemText>
+ </Mm>
+ </MemoryWindow1>
+ <MemoryWindow2>
+ <Mm>
+ <WinNumber>2</WinNumber>
+ <SubType>2</SubType>
+ <ItemText>0X20002F10</ItemText>
+ </Mm>
+ </MemoryWindow2>
+ <MemoryWindow3>
+ <Mm>
+ <WinNumber>3</WinNumber>
+ <SubType>2</SubType>
+ <ItemText>0x200000ee</ItemText>
+ </Mm>
+ </MemoryWindow3>
+ <MemoryWindow4>
+ <Mm>
+ <WinNumber>4</WinNumber>
+ <SubType>2</SubType>
+ <ItemText>0x08007C84</ItemText>
+ </Mm>
+ </MemoryWindow4>
+ <DebugFlag>
+ <trace>0</trace>
+ <periodic>1</periodic>
+ <aLwin>1</aLwin>
+ <aCover>0</aCover>
+ <aSer1>0</aSer1>
+ <aSer2>0</aSer2>
+ <aPa>0</aPa>
+ <viewmode>1</viewmode>
+ <vrSel>0</vrSel>
+ <aSym>0</aSym>
+ <aTbox>0</aTbox>
+ <AscS1>1</AscS1>
+ <AscS2>0</AscS2>
+ <AscS3>0</AscS3>
+ <aSer3>0</aSer3>
+ <eProf>0</eProf>
+ <aLa>0</aLa>
+ <aPa1>0</aPa1>
+ <AscS4>0</AscS4>
+ <aSer4>0</aSer4>
+ <StkLoc>0</StkLoc>
+ <TrcWin>0</TrcWin>
+ <newCpu>0</newCpu>
+ <uProt>0</uProt>
+ </DebugFlag>
+ <LintExecutable></LintExecutable>
+ <LintConfigFile></LintConfigFile>
+ </TargetOption>
+ </Target>
+
+ <Target>
+ <TargetName>timer</TargetName>
+ <ToolsetNumber>0x4</ToolsetNumber>
+ <ToolsetName>ARM-ADS</ToolsetName>
+ <TargetOption>
+ <CLKADS>8000000</CLKADS>
+ <OPTTT>
+ <gFlags>1</gFlags>
+ <BeepAtEnd>1</BeepAtEnd>
+ <RunSim>1</RunSim>
+ <RunTarget>0</RunTarget>
+ </OPTTT>
+ <OPTHX>
+ <HexSelection>1</HexSelection>
+ <FlashByte>65535</FlashByte>
+ <HexRangeLowAddress>0</HexRangeLowAddress>
+ <HexRangeHighAddress>0</HexRangeHighAddress>
+ <HexOffset>0</HexOffset>
+ </OPTHX>
+ <OPTLEX>
+ <PageWidth>79</PageWidth>
+ <PageLength>66</PageLength>
+ <TabStop>8</TabStop>
+ <ListingPath>..\outTimer\</ListingPath>
+ </OPTLEX>
+ <ListingPage>
+ <CreateCListing>1</CreateCListing>
+ <CreateAListing>1</CreateAListing>
+ <CreateLListing>1</CreateLListing>
+ <CreateIListing>0</CreateIListing>
+ <AsmCond>1</AsmCond>
+ <AsmSymb>1</AsmSymb>
+ <AsmXref>0</AsmXref>
+ <CCond>1</CCond>
+ <CCode>0</CCode>
+ <CListInc>0</CListInc>
+ <CSymb>0</CSymb>
+ <LinkerCodeListing>0</LinkerCodeListing>
+ </ListingPage>
+ <OPTXL>
+ <LMap>1</LMap>
+ <LComments>1</LComments>
+ <LGenerateSymbols>1</LGenerateSymbols>
+ <LLibSym>1</LLibSym>
+ <LLines>1</LLines>
+ <LLocSym>1</LLocSym>
+ <LPubSym>1</LPubSym>
+ <LXref>0</LXref>
+ <LExpSel>0</LExpSel>
+ </OPTXL>
+ <OPTFL>
+ <tvExp>1</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <IsCurrentTarget>0</IsCurrentTarget>
+ </OPTFL>
+ <CpuCode>255</CpuCode>
+ <Books>
+ <Book>
+ <Number>0</Number>
+ <Title>Reference Manual</Title>
+ <Path>DATASHTS\ST\STM32F10xxx.PDF</Path>
+ </Book>
+ <Book>
+ <Number>1</Number>
+ <Title>Technical Reference Manual</Title>
+ <Path>datashts\arm\cortex_m3\r1p1\DDI0337E_CORTEX_M3_R1P1_TRM.PDF</Path>
+ </Book>
+ <Book>
+ <Number>2</Number>
+ <Title>Generic User Guide</Title>
+ <Path>datashts\arm\cortex_m3\r2p1\DUI0552A_CORTEX_M3_DGUG.PDF</Path>
+ </Book>
+ </Books>
+ <DllOpt>
+ <SimDllName>SARMCM3.DLL</SimDllName>
+ <SimDllArguments>-REMAP</SimDllArguments>
+ <SimDlgDllName>DCM.DLL</SimDlgDllName>
+ <SimDlgDllArguments>-pCM3</SimDlgDllArguments>
+ <TargetDllName>SARMCM3.DLL</TargetDllName>
+ <TargetDllArguments></TargetDllArguments>
+ <TargetDlgDllName>TCM.DLL</TargetDlgDllName>
+ <TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
+ </DllOpt>
+ <DebugOpt>
+ <uSim>1</uSim>
+ <uTrg>0</uTrg>
+ <sLdApp>1</sLdApp>
+ <sGomain>1</sGomain>
+ <sRbreak>1</sRbreak>
+ <sRwatch>1</sRwatch>
+ <sRmem>1</sRmem>
+ <sRfunc>1</sRfunc>
+ <sRbox>1</sRbox>
+ <tLdApp>1</tLdApp>
+ <tGomain>1</tGomain>
+ <tRbreak>1</tRbreak>
+ <tRwatch>1</tRwatch>
+ <tRmem>1</tRmem>
+ <tRfunc>0</tRfunc>
+ <tRbox>1</tRbox>
+ <sRunDeb>0</sRunDeb>
+ <sLrtime>0</sLrtime>
+ <nTsel>5</nTsel>
+ <sDll></sDll>
+ <sDllPa></sDllPa>
+ <sDlgDll></sDlgDll>
+ <sDlgPa></sDlgPa>
+ <sIfile>.\merge.ini</sIfile>
+ <tDll></tDll>
+ <tDllPa></tDllPa>
+ <tDlgDll></tDlgDll>
+ <tDlgPa></tDlgPa>
+ <tIfile></tIfile>
+ <pMon>Segger\JL2CM3.dll</pMon>
+ </DebugOpt>
+ <TargetDriverDllRegistry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>JL2CM3</Key>
+ <Name>-U20370421 -O718 -S9 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC2000 -FN1 -FF0STM32F10x_512 -FS08000000 -FL080000</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>DLGUARM</Key>
+ <Name>(106=-1,-1,-1,-1,0)(107=-1,-1,-1,-1,0)</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>DLGTARM</Key>
+ <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>UL2CM3</Key>
+ <Name>-UV0010M9E -O718 -S10 -C0 -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC2000 -FN1 -FF0STM32F10x_512 -FS08000000 -FL040000</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>DLGDARM</Key>
+ <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=90,120,456,345,0)(1009=-1,-1,-1,-1,0)</Name>
+ </SetRegEntry>
+ <SetRegEntry>
+ <Number>0</Number>
+ <Key>ARMDBGFLAGS</Key>
+ <Name>-T0</Name>
+ </SetRegEntry>
+ </TargetDriverDllRegistry>
+ <WatchWindow1>
+ <Ww>
+ <count>0</count>
+ <WinNumber>1</WinNumber>
+ <ItemText>60*4095/653</ItemText>
+ </Ww>
+ <Ww>
+ <count>1</count>
+ <WinNumber>1</WinNumber>
+ <ItemText>cardkey
+</ItemText>
+ </Ww>
+ </WatchWindow1>
+ <MemoryWindow1>
+ <Mm>
+ <WinNumber>1</WinNumber>
+ <SubType>0</SubType>
+ <ItemText>rd_buff</ItemText>
+ </Mm>
+ </MemoryWindow1>
+ <MemoryWindow2>
+ <Mm>
+ <WinNumber>2</WinNumber>
+ <SubType>2</SubType>
+ <ItemText>0X20002F10</ItemText>
+ </Mm>
+ </MemoryWindow2>
+ <MemoryWindow3>
+ <Mm>
+ <WinNumber>3</WinNumber>
+ <SubType>2</SubType>
+ <ItemText>0x200000ee</ItemText>
+ </Mm>
+ </MemoryWindow3>
+ <MemoryWindow4>
+ <Mm>
+ <WinNumber>4</WinNumber>
+ <SubType>2</SubType>
+ <ItemText>0x08007C84</ItemText>
+ </Mm>
+ </MemoryWindow4>
+ <DebugFlag>
+ <trace>0</trace>
+ <periodic>1</periodic>
+ <aLwin>1</aLwin>
+ <aCover>0</aCover>
+ <aSer1>0</aSer1>
+ <aSer2>0</aSer2>
+ <aPa>0</aPa>
+ <viewmode>1</viewmode>
+ <vrSel>0</vrSel>
+ <aSym>0</aSym>
+ <aTbox>0</aTbox>
+ <AscS1>1</AscS1>
+ <AscS2>0</AscS2>
+ <AscS3>0</AscS3>
+ <aSer3>0</aSer3>
+ <eProf>0</eProf>
+ <aLa>0</aLa>
+ <aPa1>0</aPa1>
+ <AscS4>0</AscS4>
+ <aSer4>0</aSer4>
+ <StkLoc>0</StkLoc>
+ <TrcWin>0</TrcWin>
+ <newCpu>0</newCpu>
+ <uProt>0</uProt>
+ </DebugFlag>
+ <LintExecutable></LintExecutable>
+ <LintConfigFile></LintConfigFile>
+ </TargetOption>
+ </Target>
+
+ <Group>
+ <GroupName>lcd</GroupName>
+ <tvExp>1</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <File>
+ <GroupNumber>1</GroupNumber>
+ <FileNumber>1</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>101</TopLine>
+ <CurrentLine>110</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\lcd\glcd.c</PathWithFileName>
+ <FilenameWithoutPath>glcd.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>1</GroupNumber>
+ <FileNumber>2</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\lcd\graphics.c</PathWithFileName>
+ <FilenameWithoutPath>graphics.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>1</GroupNumber>
+ <FileNumber>3</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\lcd\graphs.c</PathWithFileName>
+ <FilenameWithoutPath>graphs.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>1</GroupNumber>
+ <FileNumber>4</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\lcd\text.c</PathWithFileName>
+ <FilenameWithoutPath>text.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>1</GroupNumber>
+ <FileNumber>5</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\lcd\text_tiny.c</PathWithFileName>
+ <FilenameWithoutPath>text_tiny.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>1</GroupNumber>
+ <FileNumber>6</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\lcd\unit_tests.c</PathWithFileName>
+ <FilenameWithoutPath>unit_tests.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>1</GroupNumber>
+ <FileNumber>7</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\lcd\glcd_spi.c</PathWithFileName>
+ <FilenameWithoutPath>glcd_spi.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>1</GroupNumber>
+ <FileNumber>8</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\lcd\ST7565R.c</PathWithFileName>
+ <FilenameWithoutPath>ST7565R.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>1</GroupNumber>
+ <FileNumber>9</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>54</TopLine>
+ <CurrentLine>76</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\lcd\spi.c</PathWithFileName>
+ <FilenameWithoutPath>spi.c</FilenameWithoutPath>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>icc_apdu_lib</GroupName>
+ <tvExp>1</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <File>
+ <GroupNumber>2</GroupNumber>
+ <FileNumber>10</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\icc_apdu_lib\des.c</PathWithFileName>
+ <FilenameWithoutPath>des.c</FilenameWithoutPath>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>sw</GroupName>
+ <tvExp>1</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>11</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\src\nec_apdu.c</PathWithFileName>
+ <FilenameWithoutPath>nec_apdu.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>12</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>1</TopLine>
+ <CurrentLine>1</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\src\nec_hardware.c</PathWithFileName>
+ <FilenameWithoutPath>nec_hardware.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>13</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>31</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>132</TopLine>
+ <CurrentLine>139</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\src\stm32f10x_it.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_it.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>14</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>11</TopLine>
+ <CurrentLine>15</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\main.c</PathWithFileName>
+ <FilenameWithoutPath>main.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>15</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>25</TopLine>
+ <CurrentLine>25</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_card.c</PathWithFileName>
+ <FilenameWithoutPath>sp_card.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>16</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>196</TopLine>
+ <CurrentLine>208</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_communicate.c</PathWithFileName>
+ <FilenameWithoutPath>sp_communicate.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>17</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>551</TopLine>
+ <CurrentLine>558</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_consume.c</PathWithFileName>
+ <FilenameWithoutPath>sp_consume.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>18</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>208</TopLine>
+ <CurrentLine>215</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_data.c</PathWithFileName>
+ <FilenameWithoutPath>sp_data.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>19</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_des.c</PathWithFileName>
+ <FilenameWithoutPath>sp_des.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>20</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>56</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>208</TopLine>
+ <CurrentLine>228</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_display.c</PathWithFileName>
+ <FilenameWithoutPath>sp_display.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>21</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_flash.c</PathWithFileName>
+ <FilenameWithoutPath>sp_flash.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>22</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>9</TopLine>
+ <CurrentLine>9</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_menu.c</PathWithFileName>
+ <FilenameWithoutPath>sp_menu.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>23</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>15</TopLine>
+ <CurrentLine>21</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_msgpack.c</PathWithFileName>
+ <FilenameWithoutPath>sp_msgpack.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>24</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>175</TopLine>
+ <CurrentLine>175</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_util.c</PathWithFileName>
+ <FilenameWithoutPath>sp_util.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>3</GroupNumber>
+ <FileNumber>25</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\supwisdom\sp_upgrade.c</PathWithFileName>
+ <FilenameWithoutPath>sp_upgrade.c</FilenameWithoutPath>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>lib</GroupName>
+ <tvExp>1</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>26</FileNumber>
+ <FileType>4</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\lib\G401_drv_hw_V04.lib</PathWithFileName>
+ <FilenameWithoutPath>G401_drv_hw_V04.lib</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>4</GroupNumber>
+ <FileNumber>27</FileNumber>
+ <FileType>4</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\lib\g401_uart5_v001.lib</PathWithFileName>
+ <FilenameWithoutPath>g401_uart5_v001.lib</FilenameWithoutPath>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>st_fw_lib</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>28</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\core_cm3.c</PathWithFileName>
+ <FilenameWithoutPath>core_cm3.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>29</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\misc.c</PathWithFileName>
+ <FilenameWithoutPath>misc.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>30</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_adc.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_adc.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>31</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_bkp.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_bkp.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>32</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_can.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_can.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>33</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_cec.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_cec.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>34</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_crc.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_crc.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>35</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_dac.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_dac.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>36</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_dbgmcu.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_dbgmcu.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>37</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_dma.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_dma.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>38</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_exti.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_exti.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>39</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_flash.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_flash.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>40</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_fsmc.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_fsmc.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>41</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>232</TopLine>
+ <CurrentLine>236</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_gpio.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_gpio.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>42</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_i2c.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_i2c.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>43</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_pwr.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_pwr.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>44</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_iwdg.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_iwdg.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>45</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_rcc.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_rcc.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>46</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_rtc.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_rtc.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>47</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_sdio.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_sdio.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>48</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_spi.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_spi.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>49</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_tim.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_tim.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>50</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_usart.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_usart.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>51</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\src\stm32f10x_wwdg.c</PathWithFileName>
+ <FilenameWithoutPath>stm32f10x_wwdg.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>52</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\system_stm32f10x.c</PathWithFileName>
+ <FilenameWithoutPath>system_stm32f10x.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>5</GroupNumber>
+ <FileNumber>53</FileNumber>
+ <FileType>2</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\st_fw_lib\startup_stm32f10x_hd.s</PathWithFileName>
+ <FilenameWithoutPath>startup_stm32f10x_hd.s</FilenameWithoutPath>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>sys_hw</GroupName>
+ <tvExp>1</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <File>
+ <GroupNumber>6</GroupNumber>
+ <FileNumber>54</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>58</TopLine>
+ <CurrentLine>62</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\sys_hw\keypad.c</PathWithFileName>
+ <FilenameWithoutPath>keypad.c</FilenameWithoutPath>
+ </File>
+ <File>
+ <GroupNumber>6</GroupNumber>
+ <FileNumber>55</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\sys_hw\drv_adc.c</PathWithFileName>
+ <FilenameWithoutPath>drv_adc.c</FilenameWithoutPath>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>zk</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <File>
+ <GroupNumber>7</GroupNumber>
+ <FileNumber>56</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\zk\gb2312_16.c</PathWithFileName>
+ <FilenameWithoutPath>gb2312_16.c</FilenameWithoutPath>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>libqr</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <File>
+ <GroupNumber>8</GroupNumber>
+ <FileNumber>57</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\libqr\qrencode.c</PathWithFileName>
+ <FilenameWithoutPath>qrencode.c</FilenameWithoutPath>
+ </File>
+ </Group>
+
+ <Group>
+ <GroupName>msgpack</GroupName>
+ <tvExp>0</tvExp>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <cbSel>0</cbSel>
+ <File>
+ <GroupNumber>9</GroupNumber>
+ <FileNumber>58</FileNumber>
+ <FileType>1</FileType>
+ <tvExp>0</tvExp>
+ <Focus>0</Focus>
+ <ColumnNumber>0</ColumnNumber>
+ <tvExpOptDlg>0</tvExpOptDlg>
+ <TopLine>0</TopLine>
+ <CurrentLine>0</CurrentLine>
+ <bDave2>0</bDave2>
+ <PathWithFileName>..\..\msgpack\cwpack.c</PathWithFileName>
+ <FilenameWithoutPath>cwpack.c</FilenameWithoutPath>
+ </File>
+ </Group>
+
+</ProjectOpt>
diff --git a/g401302/project/g401302.uvproj b/g401302/project/g401302.uvproj
new file mode 100644
index 0000000..eb083a6
--- /dev/null
+++ b/g401302/project/g401302.uvproj
@@ -0,0 +1,1439 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_proj.xsd">
+
+ <SchemaVersion>1.1</SchemaVersion>
+
+ <Header>### uVision Project, (C) Keil Software</Header>
+
+ <Targets>
+ <Target>
+ <TargetName>flow</TargetName>
+ <ToolsetNumber>0x4</ToolsetNumber>
+ <ToolsetName>ARM-ADS</ToolsetName>
+ <TargetOption>
+ <TargetCommonOption>
+ <Device>STM32F103RC</Device>
+ <Vendor>STMicroelectronics</Vendor>
+ <Cpu>IRAM(0x20000000-0x2000BFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3")</Cpu>
+ <FlashUtilSpec></FlashUtilSpec>
+ <StartupFile>"STARTUP\ST\STM32F10x\startup_stm32f10x_hd.s" ("STM32 High Density Line Startup Code")</StartupFile>
+ <FlashDriverDll>UL2CM3(-O14 -S0 -C0 -N00("ARM Cortex-M3") -D00(1BA00477) -L00(4) -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_512 -FS08000000 -FL040000)</FlashDriverDll>
+ <DeviceId>4230</DeviceId>
+ <RegisterFile>stm32f10x.h</RegisterFile>
+ <MemoryEnv></MemoryEnv>
+ <Cmp></Cmp>
+ <Asm></Asm>
+ <Linker></Linker>
+ <OHString></OHString>
+ <InfinionOptionDll></InfinionOptionDll>
+ <SLE66CMisc></SLE66CMisc>
+ <SLE66AMisc></SLE66AMisc>
+ <SLE66LinkerMisc></SLE66LinkerMisc>
+ <SFDFile></SFDFile>
+ <UseEnv>0</UseEnv>
+ <BinPath></BinPath>
+ <IncludePath></IncludePath>
+ <LibPath></LibPath>
+ <RegisterFilePath>ST\STM32F10x\</RegisterFilePath>
+ <DBRegisterFilePath>ST\STM32F10x\</DBRegisterFilePath>
+ <TargetStatus>
+ <Error>0</Error>
+ <ExitCodeStop>0</ExitCodeStop>
+ <ButtonStop>0</ButtonStop>
+ <NotGenerated>0</NotGenerated>
+ <InvalidFlash>1</InvalidFlash>
+ </TargetStatus>
+ <OutputDirectory>..\outFlow\</OutputDirectory>
+ <OutputName>G401302_flow</OutputName>
+ <CreateExecutable>1</CreateExecutable>
+ <CreateLib>0</CreateLib>
+ <CreateHexFile>1</CreateHexFile>
+ <DebugInformation>1</DebugInformation>
+ <BrowseInformation>1</BrowseInformation>
+ <ListingPath>..\outFlow\</ListingPath>
+ <HexFormatSelection>1</HexFormatSelection>
+ <Merge32K>0</Merge32K>
+ <CreateBatchFile>0</CreateBatchFile>
+ <BeforeCompile>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name></UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ </BeforeCompile>
+ <BeforeMake>
+ <RunUserProg1>1</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name>cmd /c gitver.bat</UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ </BeforeMake>
+ <AfterMake>
+ <RunUserProg1>1</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name>fromelf --bin -o ..\outFlow\@l.bin ..\outFlow\@l.axf</UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ </AfterMake>
+ <SelectedForBatchBuild>0</SelectedForBatchBuild>
+ <SVCSIdString></SVCSIdString>
+ </TargetCommonOption>
+ <CommonProperty>
+ <UseCPPCompiler>0</UseCPPCompiler>
+ <RVCTCodeConst>0</RVCTCodeConst>
+ <RVCTZI>0</RVCTZI>
+ <RVCTOtherData>0</RVCTOtherData>
+ <ModuleSelection>0</ModuleSelection>
+ <IncludeInBuild>1</IncludeInBuild>
+ <AlwaysBuild>0</AlwaysBuild>
+ <GenerateAssemblyFile>0</GenerateAssemblyFile>
+ <AssembleAssemblyFile>0</AssembleAssemblyFile>
+ <PublicsOnly>0</PublicsOnly>
+ <StopOnExitCode>3</StopOnExitCode>
+ <CustomArgument></CustomArgument>
+ <IncludeLibraryModules></IncludeLibraryModules>
+ </CommonProperty>
+ <DllOption>
+ <SimDllName>SARMCM3.DLL</SimDllName>
+ <SimDllArguments>-REMAP</SimDllArguments>
+ <SimDlgDll>DCM.DLL</SimDlgDll>
+ <SimDlgDllArguments>-pCM3</SimDlgDllArguments>
+ <TargetDllName>SARMCM3.DLL</TargetDllName>
+ <TargetDllArguments></TargetDllArguments>
+ <TargetDlgDll>TCM.DLL</TargetDlgDll>
+ <TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
+ </DllOption>
+ <DebugOption>
+ <OPTHX>
+ <HexSelection>1</HexSelection>
+ <HexRangeLowAddress>0</HexRangeLowAddress>
+ <HexRangeHighAddress>0</HexRangeHighAddress>
+ <HexOffset>0</HexOffset>
+ <Oh166RecLen>16</Oh166RecLen>
+ </OPTHX>
+ <Simulator>
+ <UseSimulator>0</UseSimulator>
+ <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
+ <RunToMain>1</RunToMain>
+ <RestoreBreakpoints>1</RestoreBreakpoints>
+ <RestoreWatchpoints>1</RestoreWatchpoints>
+ <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
+ <RestoreFunctions>1</RestoreFunctions>
+ <RestoreToolbox>1</RestoreToolbox>
+ <LimitSpeedToRealTime>0</LimitSpeedToRealTime>
+ </Simulator>
+ <Target>
+ <UseTarget>1</UseTarget>
+ <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
+ <RunToMain>1</RunToMain>
+ <RestoreBreakpoints>1</RestoreBreakpoints>
+ <RestoreWatchpoints>1</RestoreWatchpoints>
+ <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
+ <RestoreFunctions>0</RestoreFunctions>
+ <RestoreToolbox>1</RestoreToolbox>
+ </Target>
+ <RunDebugAfterBuild>0</RunDebugAfterBuild>
+ <TargetSelection>7</TargetSelection>
+ <SimDlls>
+ <CpuDll></CpuDll>
+ <CpuDllArguments></CpuDllArguments>
+ <PeripheralDll></PeripheralDll>
+ <PeripheralDllArguments></PeripheralDllArguments>
+ <InitializationFile>.\merge.ini</InitializationFile>
+ </SimDlls>
+ <TargetDlls>
+ <CpuDll></CpuDll>
+ <CpuDllArguments></CpuDllArguments>
+ <PeripheralDll></PeripheralDll>
+ <PeripheralDllArguments></PeripheralDllArguments>
+ <InitializationFile></InitializationFile>
+ <Driver>Segger\JL2CM3.dll</Driver>
+ </TargetDlls>
+ </DebugOption>
+ <Utilities>
+ <Flash1>
+ <UseTargetDll>1</UseTargetDll>
+ <UseExternalTool>0</UseExternalTool>
+ <RunIndependent>0</RunIndependent>
+ <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
+ <Capability>1</Capability>
+ <DriverSelection>4099</DriverSelection>
+ </Flash1>
+ <Flash2>Segger\JL2CM3.dll</Flash2>
+ <Flash3>"" ()</Flash3>
+ <Flash4></Flash4>
+ </Utilities>
+ <TargetArmAds>
+ <ArmAdsMisc>
+ <GenerateListings>0</GenerateListings>
+ <asHll>1</asHll>
+ <asAsm>1</asAsm>
+ <asMacX>1</asMacX>
+ <asSyms>1</asSyms>
+ <asFals>1</asFals>
+ <asDbgD>1</asDbgD>
+ <asForm>1</asForm>
+ <ldLst>0</ldLst>
+ <ldmm>1</ldmm>
+ <ldXref>1</ldXref>
+ <BigEnd>0</BigEnd>
+ <AdsALst>1</AdsALst>
+ <AdsACrf>1</AdsACrf>
+ <AdsANop>0</AdsANop>
+ <AdsANot>0</AdsANot>
+ <AdsLLst>1</AdsLLst>
+ <AdsLmap>1</AdsLmap>
+ <AdsLcgr>1</AdsLcgr>
+ <AdsLsym>1</AdsLsym>
+ <AdsLszi>1</AdsLszi>
+ <AdsLtoi>1</AdsLtoi>
+ <AdsLsun>1</AdsLsun>
+ <AdsLven>1</AdsLven>
+ <AdsLsxf>1</AdsLsxf>
+ <RvctClst>0</RvctClst>
+ <GenPPlst>0</GenPPlst>
+ <AdsCpuType>"Cortex-M3"</AdsCpuType>
+ <RvctDeviceName></RvctDeviceName>
+ <mOS>0</mOS>
+ <uocRom>0</uocRom>
+ <uocRam>0</uocRam>
+ <hadIROM>1</hadIROM>
+ <hadIRAM>1</hadIRAM>
+ <hadXRAM>0</hadXRAM>
+ <uocXRam>0</uocXRam>
+ <RvdsVP>0</RvdsVP>
+ <hadIRAM2>0</hadIRAM2>
+ <hadIROM2>0</hadIROM2>
+ <StupSel>8</StupSel>
+ <useUlib>0</useUlib>
+ <EndSel>0</EndSel>
+ <uLtcg>0</uLtcg>
+ <RoSelD>3</RoSelD>
+ <RwSelD>3</RwSelD>
+ <CodeSel>0</CodeSel>
+ <OptFeed>0</OptFeed>
+ <NoZi1>0</NoZi1>
+ <NoZi2>0</NoZi2>
+ <NoZi3>0</NoZi3>
+ <NoZi4>0</NoZi4>
+ <NoZi5>0</NoZi5>
+ <Ro1Chk>0</Ro1Chk>
+ <Ro2Chk>0</Ro2Chk>
+ <Ro3Chk>0</Ro3Chk>
+ <Ir1Chk>1</Ir1Chk>
+ <Ir2Chk>0</Ir2Chk>
+ <Ra1Chk>0</Ra1Chk>
+ <Ra2Chk>0</Ra2Chk>
+ <Ra3Chk>0</Ra3Chk>
+ <Im1Chk>1</Im1Chk>
+ <Im2Chk>0</Im2Chk>
+ <OnChipMemories>
+ <Ocm1>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm1>
+ <Ocm2>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm2>
+ <Ocm3>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm3>
+ <Ocm4>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm4>
+ <Ocm5>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm5>
+ <Ocm6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm6>
+ <IRAM>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0xc000</Size>
+ </IRAM>
+ <IROM>
+ <Type>1</Type>
+ <StartAddress>0x8000000</StartAddress>
+ <Size>0x40000</Size>
+ </IROM>
+ <XRAM>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </XRAM>
+ <OCR_RVCT1>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT1>
+ <OCR_RVCT2>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT2>
+ <OCR_RVCT3>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT3>
+ <OCR_RVCT4>
+ <Type>1</Type>
+ <StartAddress>0x8004000</StartAddress>
+ <Size>0x3c000</Size>
+ </OCR_RVCT4>
+ <OCR_RVCT5>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT5>
+ <OCR_RVCT6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT6>
+ <OCR_RVCT7>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT7>
+ <OCR_RVCT8>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT8>
+ <OCR_RVCT9>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0xc000</Size>
+ </OCR_RVCT9>
+ <OCR_RVCT10>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT10>
+ </OnChipMemories>
+ <RvctStartVector></RvctStartVector>
+ </ArmAdsMisc>
+ <Cads>
+ <interw>1</interw>
+ <Optim>1</Optim>
+ <oTime>0</oTime>
+ <SplitLS>0</SplitLS>
+ <OneElfS>1</OneElfS>
+ <Strict>0</Strict>
+ <EnumInt>0</EnumInt>
+ <PlainCh>0</PlainCh>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <wLevel>0</wLevel>
+ <uThumb>0</uThumb>
+ <VariousControls>
+ <MiscControls>--c99 --diag_suppress=188 -DFLOWSENSOR</MiscControls>
+ <Define>STM32F10X_HD,USE_STDPERIPH_DRIVER,HW_V02</Define>
+ <Undefine></Undefine>
+ <IncludePath>..\src;..\lib;..\..\icc_apdu_lib;..\..\st_fw_lib\inc;..\..\st_fw_lib;..\..\lcd;.\;..\..\sys_hw;..\..\zk;..\..\app_drv;..\..\libqr;..\..\msgpack;</IncludePath>
+ </VariousControls>
+ </Cads>
+ <Aads>
+ <interw>1</interw>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <thumb>0</thumb>
+ <SplitLS>0</SplitLS>
+ <SwStkChk>0</SwStkChk>
+ <NoWarn>0</NoWarn>
+ <VariousControls>
+ <MiscControls></MiscControls>
+ <Define></Define>
+ <Undefine></Undefine>
+ <IncludePath></IncludePath>
+ </VariousControls>
+ </Aads>
+ <LDads>
+ <umfTarg>1</umfTarg>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <noStLib>0</noStLib>
+ <RepFail>1</RepFail>
+ <useFile>0</useFile>
+ <TextAddressRange>0x08000000</TextAddressRange>
+ <DataAddressRange>0x20000000</DataAddressRange>
+ <ScatterFile></ScatterFile>
+ <IncludeLibs></IncludeLibs>
+ <IncludeLibsPath></IncludeLibsPath>
+ <Misc></Misc>
+ <LinkerInputFile></LinkerInputFile>
+ <DisabledWarnings></DisabledWarnings>
+ </LDads>
+ </TargetArmAds>
+ </TargetOption>
+ <Groups>
+ <Group>
+ <GroupName>lcd</GroupName>
+ <Files>
+ <File>
+ <FileName>glcd.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\glcd.c</FilePath>
+ </File>
+ <File>
+ <FileName>graphics.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\graphics.c</FilePath>
+ </File>
+ <File>
+ <FileName>graphs.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\graphs.c</FilePath>
+ </File>
+ <File>
+ <FileName>text.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\text.c</FilePath>
+ </File>
+ <File>
+ <FileName>text_tiny.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\text_tiny.c</FilePath>
+ </File>
+ <File>
+ <FileName>unit_tests.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\unit_tests.c</FilePath>
+ </File>
+ <File>
+ <FileName>glcd_spi.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\glcd_spi.c</FilePath>
+ </File>
+ <File>
+ <FileName>ST7565R.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\ST7565R.c</FilePath>
+ </File>
+ <File>
+ <FileName>spi.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\spi.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>icc_apdu_lib</GroupName>
+ <Files>
+ <File>
+ <FileName>des.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\icc_apdu_lib\des.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>sw</GroupName>
+ <Files>
+ <File>
+ <FileName>nec_apdu.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\src\nec_apdu.c</FilePath>
+ </File>
+ <File>
+ <FileName>nec_hardware.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\src\nec_hardware.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_it.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\src\stm32f10x_it.c</FilePath>
+ </File>
+ <File>
+ <FileName>main.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\main.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_card.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_card.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_communicate.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_communicate.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_consume.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_consume.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_data.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_data.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_des.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_des.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_display.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_display.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_flash.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_flash.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_menu.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_menu.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_msgpack.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_msgpack.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_util.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_util.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_upgrade.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_upgrade.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>lib</GroupName>
+ <Files>
+ <File>
+ <FileName>G401_drv_hw_V04.lib</FileName>
+ <FileType>4</FileType>
+ <FilePath>..\lib\G401_drv_hw_V04.lib</FilePath>
+ </File>
+ <File>
+ <FileName>g401_uart5_v001.lib</FileName>
+ <FileType>4</FileType>
+ <FilePath>..\lib\g401_uart5_v001.lib</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>st_fw_lib</GroupName>
+ <Files>
+ <File>
+ <FileName>core_cm3.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\core_cm3.c</FilePath>
+ </File>
+ <File>
+ <FileName>misc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\misc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_adc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_adc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_bkp.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_bkp.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_can.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_can.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_cec.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_cec.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_crc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_crc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_dac.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_dac.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_dbgmcu.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_dbgmcu.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_dma.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_dma.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_exti.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_exti.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_flash.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_flash.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_fsmc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_fsmc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_gpio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_gpio.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_i2c.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_i2c.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_pwr.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_pwr.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_iwdg.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_iwdg.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_rcc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_rcc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_rtc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_rtc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_sdio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_sdio.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_spi.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_spi.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_tim.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_tim.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_usart.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_usart.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_wwdg.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_wwdg.c</FilePath>
+ </File>
+ <File>
+ <FileName>system_stm32f10x.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\system_stm32f10x.c</FilePath>
+ </File>
+ <File>
+ <FileName>startup_stm32f10x_hd.s</FileName>
+ <FileType>2</FileType>
+ <FilePath>..\..\st_fw_lib\startup_stm32f10x_hd.s</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>sys_hw</GroupName>
+ <Files>
+ <File>
+ <FileName>keypad.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\sys_hw\keypad.c</FilePath>
+ </File>
+ <File>
+ <FileName>drv_adc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\sys_hw\drv_adc.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>zk</GroupName>
+ <Files>
+ <File>
+ <FileName>gb2312_16.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\zk\gb2312_16.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>libqr</GroupName>
+ <Files>
+ <File>
+ <FileName>qrencode.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\libqr\qrencode.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>msgpack</GroupName>
+ <Files>
+ <File>
+ <FileName>cwpack.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\msgpack\cwpack.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ </Groups>
+ </Target>
+ <Target>
+ <TargetName>timer</TargetName>
+ <ToolsetNumber>0x4</ToolsetNumber>
+ <ToolsetName>ARM-ADS</ToolsetName>
+ <TargetOption>
+ <TargetCommonOption>
+ <Device>STM32F103RC</Device>
+ <Vendor>STMicroelectronics</Vendor>
+ <Cpu>IRAM(0x20000000-0x2000BFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3")</Cpu>
+ <FlashUtilSpec></FlashUtilSpec>
+ <StartupFile>"STARTUP\ST\STM32F10x\startup_stm32f10x_hd.s" ("STM32 High Density Line Startup Code")</StartupFile>
+ <FlashDriverDll>UL2CM3(-O14 -S0 -C0 -N00("ARM Cortex-M3") -D00(1BA00477) -L00(4) -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_512 -FS08000000 -FL040000)</FlashDriverDll>
+ <DeviceId>4230</DeviceId>
+ <RegisterFile>stm32f10x.h</RegisterFile>
+ <MemoryEnv></MemoryEnv>
+ <Cmp></Cmp>
+ <Asm></Asm>
+ <Linker></Linker>
+ <OHString></OHString>
+ <InfinionOptionDll></InfinionOptionDll>
+ <SLE66CMisc></SLE66CMisc>
+ <SLE66AMisc></SLE66AMisc>
+ <SLE66LinkerMisc></SLE66LinkerMisc>
+ <SFDFile></SFDFile>
+ <UseEnv>0</UseEnv>
+ <BinPath></BinPath>
+ <IncludePath></IncludePath>
+ <LibPath></LibPath>
+ <RegisterFilePath>ST\STM32F10x\</RegisterFilePath>
+ <DBRegisterFilePath>ST\STM32F10x\</DBRegisterFilePath>
+ <TargetStatus>
+ <Error>0</Error>
+ <ExitCodeStop>0</ExitCodeStop>
+ <ButtonStop>0</ButtonStop>
+ <NotGenerated>0</NotGenerated>
+ <InvalidFlash>1</InvalidFlash>
+ </TargetStatus>
+ <OutputDirectory>..\outTimer\</OutputDirectory>
+ <OutputName>G401302_timer</OutputName>
+ <CreateExecutable>1</CreateExecutable>
+ <CreateLib>0</CreateLib>
+ <CreateHexFile>1</CreateHexFile>
+ <DebugInformation>1</DebugInformation>
+ <BrowseInformation>1</BrowseInformation>
+ <ListingPath>..\outTimer\</ListingPath>
+ <HexFormatSelection>1</HexFormatSelection>
+ <Merge32K>0</Merge32K>
+ <CreateBatchFile>0</CreateBatchFile>
+ <BeforeCompile>
+ <RunUserProg1>0</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name></UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ </BeforeCompile>
+ <BeforeMake>
+ <RunUserProg1>1</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name>cmd /c gitver.bat</UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ </BeforeMake>
+ <AfterMake>
+ <RunUserProg1>1</RunUserProg1>
+ <RunUserProg2>0</RunUserProg2>
+ <UserProg1Name>fromelf --bin -o ..\outTimer\@l.bin ..\outTimer\@l.axf</UserProg1Name>
+ <UserProg2Name></UserProg2Name>
+ <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
+ <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+ </AfterMake>
+ <SelectedForBatchBuild>0</SelectedForBatchBuild>
+ <SVCSIdString></SVCSIdString>
+ </TargetCommonOption>
+ <CommonProperty>
+ <UseCPPCompiler>0</UseCPPCompiler>
+ <RVCTCodeConst>0</RVCTCodeConst>
+ <RVCTZI>0</RVCTZI>
+ <RVCTOtherData>0</RVCTOtherData>
+ <ModuleSelection>0</ModuleSelection>
+ <IncludeInBuild>1</IncludeInBuild>
+ <AlwaysBuild>0</AlwaysBuild>
+ <GenerateAssemblyFile>0</GenerateAssemblyFile>
+ <AssembleAssemblyFile>0</AssembleAssemblyFile>
+ <PublicsOnly>0</PublicsOnly>
+ <StopOnExitCode>3</StopOnExitCode>
+ <CustomArgument></CustomArgument>
+ <IncludeLibraryModules></IncludeLibraryModules>
+ </CommonProperty>
+ <DllOption>
+ <SimDllName>SARMCM3.DLL</SimDllName>
+ <SimDllArguments>-REMAP</SimDllArguments>
+ <SimDlgDll>DCM.DLL</SimDlgDll>
+ <SimDlgDllArguments>-pCM3</SimDlgDllArguments>
+ <TargetDllName>SARMCM3.DLL</TargetDllName>
+ <TargetDllArguments></TargetDllArguments>
+ <TargetDlgDll>TCM.DLL</TargetDlgDll>
+ <TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
+ </DllOption>
+ <DebugOption>
+ <OPTHX>
+ <HexSelection>1</HexSelection>
+ <HexRangeLowAddress>0</HexRangeLowAddress>
+ <HexRangeHighAddress>0</HexRangeHighAddress>
+ <HexOffset>0</HexOffset>
+ <Oh166RecLen>16</Oh166RecLen>
+ </OPTHX>
+ <Simulator>
+ <UseSimulator>1</UseSimulator>
+ <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
+ <RunToMain>1</RunToMain>
+ <RestoreBreakpoints>1</RestoreBreakpoints>
+ <RestoreWatchpoints>1</RestoreWatchpoints>
+ <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
+ <RestoreFunctions>1</RestoreFunctions>
+ <RestoreToolbox>1</RestoreToolbox>
+ <LimitSpeedToRealTime>0</LimitSpeedToRealTime>
+ </Simulator>
+ <Target>
+ <UseTarget>0</UseTarget>
+ <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
+ <RunToMain>1</RunToMain>
+ <RestoreBreakpoints>1</RestoreBreakpoints>
+ <RestoreWatchpoints>1</RestoreWatchpoints>
+ <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
+ <RestoreFunctions>0</RestoreFunctions>
+ <RestoreToolbox>1</RestoreToolbox>
+ </Target>
+ <RunDebugAfterBuild>0</RunDebugAfterBuild>
+ <TargetSelection>5</TargetSelection>
+ <SimDlls>
+ <CpuDll></CpuDll>
+ <CpuDllArguments></CpuDllArguments>
+ <PeripheralDll></PeripheralDll>
+ <PeripheralDllArguments></PeripheralDllArguments>
+ <InitializationFile>.\merge.ini</InitializationFile>
+ </SimDlls>
+ <TargetDlls>
+ <CpuDll></CpuDll>
+ <CpuDllArguments></CpuDllArguments>
+ <PeripheralDll></PeripheralDll>
+ <PeripheralDllArguments></PeripheralDllArguments>
+ <InitializationFile></InitializationFile>
+ <Driver>Segger\JL2CM3.dll</Driver>
+ </TargetDlls>
+ </DebugOption>
+ <Utilities>
+ <Flash1>
+ <UseTargetDll>1</UseTargetDll>
+ <UseExternalTool>0</UseExternalTool>
+ <RunIndependent>0</RunIndependent>
+ <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
+ <Capability>1</Capability>
+ <DriverSelection>4099</DriverSelection>
+ </Flash1>
+ <Flash2>Segger\JL2CM3.dll</Flash2>
+ <Flash3>"" ()</Flash3>
+ <Flash4></Flash4>
+ </Utilities>
+ <TargetArmAds>
+ <ArmAdsMisc>
+ <GenerateListings>0</GenerateListings>
+ <asHll>1</asHll>
+ <asAsm>1</asAsm>
+ <asMacX>1</asMacX>
+ <asSyms>1</asSyms>
+ <asFals>1</asFals>
+ <asDbgD>1</asDbgD>
+ <asForm>1</asForm>
+ <ldLst>0</ldLst>
+ <ldmm>1</ldmm>
+ <ldXref>1</ldXref>
+ <BigEnd>0</BigEnd>
+ <AdsALst>1</AdsALst>
+ <AdsACrf>1</AdsACrf>
+ <AdsANop>0</AdsANop>
+ <AdsANot>0</AdsANot>
+ <AdsLLst>1</AdsLLst>
+ <AdsLmap>1</AdsLmap>
+ <AdsLcgr>1</AdsLcgr>
+ <AdsLsym>1</AdsLsym>
+ <AdsLszi>1</AdsLszi>
+ <AdsLtoi>1</AdsLtoi>
+ <AdsLsun>1</AdsLsun>
+ <AdsLven>1</AdsLven>
+ <AdsLsxf>1</AdsLsxf>
+ <RvctClst>0</RvctClst>
+ <GenPPlst>0</GenPPlst>
+ <AdsCpuType>"Cortex-M3"</AdsCpuType>
+ <RvctDeviceName></RvctDeviceName>
+ <mOS>0</mOS>
+ <uocRom>0</uocRom>
+ <uocRam>0</uocRam>
+ <hadIROM>1</hadIROM>
+ <hadIRAM>1</hadIRAM>
+ <hadXRAM>0</hadXRAM>
+ <uocXRam>0</uocXRam>
+ <RvdsVP>0</RvdsVP>
+ <hadIRAM2>0</hadIRAM2>
+ <hadIROM2>0</hadIROM2>
+ <StupSel>8</StupSel>
+ <useUlib>0</useUlib>
+ <EndSel>0</EndSel>
+ <uLtcg>0</uLtcg>
+ <RoSelD>3</RoSelD>
+ <RwSelD>3</RwSelD>
+ <CodeSel>0</CodeSel>
+ <OptFeed>0</OptFeed>
+ <NoZi1>0</NoZi1>
+ <NoZi2>0</NoZi2>
+ <NoZi3>0</NoZi3>
+ <NoZi4>0</NoZi4>
+ <NoZi5>0</NoZi5>
+ <Ro1Chk>0</Ro1Chk>
+ <Ro2Chk>0</Ro2Chk>
+ <Ro3Chk>0</Ro3Chk>
+ <Ir1Chk>1</Ir1Chk>
+ <Ir2Chk>0</Ir2Chk>
+ <Ra1Chk>0</Ra1Chk>
+ <Ra2Chk>0</Ra2Chk>
+ <Ra3Chk>0</Ra3Chk>
+ <Im1Chk>1</Im1Chk>
+ <Im2Chk>0</Im2Chk>
+ <OnChipMemories>
+ <Ocm1>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm1>
+ <Ocm2>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm2>
+ <Ocm3>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm3>
+ <Ocm4>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm4>
+ <Ocm5>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm5>
+ <Ocm6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </Ocm6>
+ <IRAM>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0xc000</Size>
+ </IRAM>
+ <IROM>
+ <Type>1</Type>
+ <StartAddress>0x8000000</StartAddress>
+ <Size>0x40000</Size>
+ </IROM>
+ <XRAM>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </XRAM>
+ <OCR_RVCT1>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT1>
+ <OCR_RVCT2>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT2>
+ <OCR_RVCT3>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT3>
+ <OCR_RVCT4>
+ <Type>1</Type>
+ <StartAddress>0x8004000</StartAddress>
+ <Size>0x3c000</Size>
+ </OCR_RVCT4>
+ <OCR_RVCT5>
+ <Type>1</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT5>
+ <OCR_RVCT6>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT6>
+ <OCR_RVCT7>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT7>
+ <OCR_RVCT8>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT8>
+ <OCR_RVCT9>
+ <Type>0</Type>
+ <StartAddress>0x20000000</StartAddress>
+ <Size>0xc000</Size>
+ </OCR_RVCT9>
+ <OCR_RVCT10>
+ <Type>0</Type>
+ <StartAddress>0x0</StartAddress>
+ <Size>0x0</Size>
+ </OCR_RVCT10>
+ </OnChipMemories>
+ <RvctStartVector></RvctStartVector>
+ </ArmAdsMisc>
+ <Cads>
+ <interw>1</interw>
+ <Optim>1</Optim>
+ <oTime>0</oTime>
+ <SplitLS>0</SplitLS>
+ <OneElfS>1</OneElfS>
+ <Strict>0</Strict>
+ <EnumInt>0</EnumInt>
+ <PlainCh>0</PlainCh>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <wLevel>0</wLevel>
+ <uThumb>0</uThumb>
+ <VariousControls>
+ <MiscControls>--c99 --diag_suppress=188</MiscControls>
+ <Define>STM32F10X_HD,USE_STDPERIPH_DRIVER,HW_V02</Define>
+ <Undefine></Undefine>
+ <IncludePath>..\src;..\lib;..\..\icc_apdu_lib;..\..\st_fw_lib\inc;..\..\st_fw_lib;..\..\lcd;.\;..\..\sys_hw;..\..\zk;..\..\app_drv;..\..\libqr;..\..\msgpack;</IncludePath>
+ </VariousControls>
+ </Cads>
+ <Aads>
+ <interw>1</interw>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <thumb>0</thumb>
+ <SplitLS>0</SplitLS>
+ <SwStkChk>0</SwStkChk>
+ <NoWarn>0</NoWarn>
+ <VariousControls>
+ <MiscControls></MiscControls>
+ <Define></Define>
+ <Undefine></Undefine>
+ <IncludePath></IncludePath>
+ </VariousControls>
+ </Aads>
+ <LDads>
+ <umfTarg>1</umfTarg>
+ <Ropi>0</Ropi>
+ <Rwpi>0</Rwpi>
+ <noStLib>0</noStLib>
+ <RepFail>1</RepFail>
+ <useFile>0</useFile>
+ <TextAddressRange>0x08000000</TextAddressRange>
+ <DataAddressRange>0x20000000</DataAddressRange>
+ <ScatterFile></ScatterFile>
+ <IncludeLibs></IncludeLibs>
+ <IncludeLibsPath></IncludeLibsPath>
+ <Misc></Misc>
+ <LinkerInputFile></LinkerInputFile>
+ <DisabledWarnings></DisabledWarnings>
+ </LDads>
+ </TargetArmAds>
+ </TargetOption>
+ <Groups>
+ <Group>
+ <GroupName>lcd</GroupName>
+ <Files>
+ <File>
+ <FileName>glcd.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\glcd.c</FilePath>
+ </File>
+ <File>
+ <FileName>graphics.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\graphics.c</FilePath>
+ </File>
+ <File>
+ <FileName>graphs.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\graphs.c</FilePath>
+ </File>
+ <File>
+ <FileName>text.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\text.c</FilePath>
+ </File>
+ <File>
+ <FileName>text_tiny.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\text_tiny.c</FilePath>
+ </File>
+ <File>
+ <FileName>unit_tests.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\unit_tests.c</FilePath>
+ </File>
+ <File>
+ <FileName>glcd_spi.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\glcd_spi.c</FilePath>
+ </File>
+ <File>
+ <FileName>ST7565R.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\ST7565R.c</FilePath>
+ </File>
+ <File>
+ <FileName>spi.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\lcd\spi.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>icc_apdu_lib</GroupName>
+ <Files>
+ <File>
+ <FileName>des.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\icc_apdu_lib\des.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>sw</GroupName>
+ <Files>
+ <File>
+ <FileName>nec_apdu.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\src\nec_apdu.c</FilePath>
+ </File>
+ <File>
+ <FileName>nec_hardware.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\src\nec_hardware.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_it.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\src\stm32f10x_it.c</FilePath>
+ </File>
+ <File>
+ <FileName>main.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\main.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_card.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_card.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_communicate.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_communicate.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_consume.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_consume.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_data.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_data.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_des.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_des.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_display.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_display.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_flash.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_flash.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_menu.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_menu.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_msgpack.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_msgpack.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_util.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_util.c</FilePath>
+ </File>
+ <File>
+ <FileName>sp_upgrade.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\supwisdom\sp_upgrade.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>lib</GroupName>
+ <Files>
+ <File>
+ <FileName>G401_drv_hw_V04.lib</FileName>
+ <FileType>4</FileType>
+ <FilePath>..\lib\G401_drv_hw_V04.lib</FilePath>
+ </File>
+ <File>
+ <FileName>g401_uart5_v001.lib</FileName>
+ <FileType>4</FileType>
+ <FilePath>..\lib\g401_uart5_v001.lib</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>st_fw_lib</GroupName>
+ <Files>
+ <File>
+ <FileName>core_cm3.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\core_cm3.c</FilePath>
+ </File>
+ <File>
+ <FileName>misc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\misc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_adc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_adc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_bkp.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_bkp.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_can.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_can.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_cec.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_cec.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_crc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_crc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_dac.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_dac.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_dbgmcu.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_dbgmcu.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_dma.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_dma.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_exti.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_exti.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_flash.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_flash.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_fsmc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_fsmc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_gpio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_gpio.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_i2c.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_i2c.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_pwr.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_pwr.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_iwdg.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_iwdg.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_rcc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_rcc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_rtc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_rtc.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_sdio.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_sdio.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_spi.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_spi.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_tim.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_tim.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_usart.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_usart.c</FilePath>
+ </File>
+ <File>
+ <FileName>stm32f10x_wwdg.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\src\stm32f10x_wwdg.c</FilePath>
+ </File>
+ <File>
+ <FileName>system_stm32f10x.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\st_fw_lib\system_stm32f10x.c</FilePath>
+ </File>
+ <File>
+ <FileName>startup_stm32f10x_hd.s</FileName>
+ <FileType>2</FileType>
+ <FilePath>..\..\st_fw_lib\startup_stm32f10x_hd.s</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>sys_hw</GroupName>
+ <Files>
+ <File>
+ <FileName>keypad.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\sys_hw\keypad.c</FilePath>
+ </File>
+ <File>
+ <FileName>drv_adc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\sys_hw\drv_adc.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>zk</GroupName>
+ <Files>
+ <File>
+ <FileName>gb2312_16.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\zk\gb2312_16.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>libqr</GroupName>
+ <Files>
+ <File>
+ <FileName>qrencode.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\libqr\qrencode.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ <Group>
+ <GroupName>msgpack</GroupName>
+ <Files>
+ <File>
+ <FileName>cwpack.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\msgpack\cwpack.c</FilePath>
+ </File>
+ </Files>
+ </Group>
+ </Groups>
+ </Target>
+ </Targets>
+
+</Project>
diff --git a/g401302/project/gitver.bat b/g401302/project/gitver.bat
new file mode 100644
index 0000000..996c3ce
--- /dev/null
+++ b/g401302/project/gitver.bat
@@ -0,0 +1,10 @@
+@echo off
+SET LINE1=#ifndef GIT_VERSION
+SET LINE2=#define GIT_VERSION
+SET LINE3=#endif
+
+FOR /F %%I IN ('git describe --dirty --always --tags --abbrev=4') DO SET VERSTR=%%I
+
+echo %LINE1% > ../../supwisdom/sp_version.h
+echo %LINE2% ^"%VERSTR%^" >> ../../supwisdom/sp_version.h
+echo %LINE3% >> ../../supwisdom/sp_version.h
\ No newline at end of file
diff --git a/g401302/project/merge.ini b/g401302/project/merge.ini
new file mode 100644
index 0000000..8efd9d0
--- /dev/null
+++ b/g401302/project/merge.ini
@@ -0,0 +1,16 @@
+/******************************************************************************/
+/* FLASH.INI: FLASH Initialization File */
+/******************************************************************************/
+// <<< Use Configuration Wizard in Context Menu >>> //
+/******************************************************************************/
+/* This file is part of the uVision/ARM development tools. */
+/* Copyright (c) 2005-2006 Keil Software. All rights reserved. */
+/* This software may only be used under the terms of a valid, current, */
+/* end user licence from KEIL for a compatible version of KEIL software */
+/* development tools. Nothing else gives you the right to use this software. */
+/******************************************************************************/
+LOAD ..\hex\STM32IAPCombine51.hex // Download
+save ..\hex\G401302_combine.hex 0x08000000,0x0803FFFF
+//g,main
+
+
diff --git a/g401302/src/G401_drv_hw_V01.h b/g401302/src/G401_drv_hw_V01.h
new file mode 100644
index 0000000..0a63590
--- /dev/null
+++ b/g401302/src/G401_drv_hw_V01.h
@@ -0,0 +1,623 @@
+
+#ifndef __G401_HWDRV_LIB_H__
+#define __G401_HWDRV_LIB_H__
+
+#include "stdint.h"
+#include "stm32f10x.h"
+#include "drv_usart.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/*
+ ³õʼ»¯Ê±»ù¶¨Ê±Æ÷(1ms)
+*/
+extern u32 SysTick_cfg(void);
+/*
+ Çý¶¯Ê¹ÓÃSYSTICK²úÉúʱ»ù£¬²¢ÅäÖÃSYSTICKΪ1msÒç³öÖжϣ¬Ó¦ÓòãÐèÍê
+ ³ÉSYSTICKÖжϷþÎñº¯ÊýSysTick_Handler£¬²¢µ÷ÓÃTimerTickº¯Êý£¬
+ Íê³ÉÏÔʾɨÃ衢ͨѶËùÐ趨ʱµÈ²Ù×÷
+*/
+extern void TimerTick(void);
+
+
+/*
+ »ñÈ¡Çý¶¯²ãά»¤µÄ32λms¼¶µÎ´ðµ±Ç°Öµ£¬¸Ãֵÿms¸üÐÂ1´Î£¬Ã¿´Î¼Ó1
+*/
+extern u32 timer_get_ticker(void);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/*
+ ¹¦ÄÜ: ¼ÆËãÖ¸¶¨³¤¶ÈÊý¾ÝÁ÷µÄcrcУÑéÖµ
+ ÊäÈë: pBuffer£¬Êý¾ÝÁ÷Ö¸Õë BufferLength: Êý¾ÝÁ÷×Ö½Ú³¤¶È
+ Êä³ö: crc16
+*/
+extern u16 calcCRC( u8 *pBuffer, u16 BufferLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//RTCÇý¶¯Ïà¹Ø
+//ʱ¼ä½á¹¹Ìå
+typedef struct
+{
+ uint8_t year; //Äê
+ uint8_t month; //ÔÂ
+ uint8_t day; //ÈÕ
+ uint8_t week; //ÐÇÆÚ
+ uint8_t hour; //ʱ
+ uint8_t minute; //·Ö
+ uint8_t second; //Ãë
+}_SystemTime ;
+/*
+ RTC³õʼ»¯
+*/
+extern void rtc_init(void);
+/*
+ »ñȡϵͳÈÕÆÚ
+*/
+extern uint8_t rtc_get_time(_SystemTime* t);
+
+/*
+ ÉèÖÃϵͳÈÕÆÚ
+*/
+extern uint8_t rtc_set_time(_SystemTime* t);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//EEPROMÏà¹Ø
+
+////#define E2PROM_SIZE (64*1024/8UL)
+/*
+ ʹÄÜE2PROMд±£»¤
+*/
+extern void e2prom_lock(void);
+/*
+ ʧÄÜE2PROMд±£»¤
+*/
+extern void e2prom_unlock(void);
+/*********************************************
+*¹¦ÄÜ:I2C×ÜÏß³õʼ»¯,Ö÷³ÌÐòÊ×Ïȵ÷ÓøóÌÐò
+*²ÎÊý:time_factor ÑÓʱϵÊý,Ò»°ã´«0£¬Ê¹ÓÃĬÈϵľÍÐÐ
+*********************************************/
+extern void e2prom_init(u32 time_factor);
+
+/******************************************************************************
+¹¦ÄÜ£º´ÓÖ¸¶¨µØÖ·¿ªÊ¼¶Áȡָ¶¨³¤¶ÈµÄÊý¾Ý
+²ÎÊý£º
+ *dest_buff - ´æ·Å¶Á³öÊý¾ÝµÄÖ¸Õë
+ addr - ¿ªÊ¼µØÖ·
+ len - Òª¶Á³öµÄ³¤¶È
+·µ»ØÖµ£º
+ 0 - ³É¹¦
+ 1 - ʧ°Ü
+******************************************************************************/
+extern u8 e2prom_read(u8 *dest_buff, u16 addr, u16 len);
+
+/******************************************************************************
+¹¦ÄÜ£ºÐ´EEPROM¡£ÏòÖ¸¶¨µØÖ·¿ªÊ¼Ð´ÈëÖ¸¶¨³¤¶ÈµÄÊý¾Ý¡£
+²ÎÊý£º
+ *src_buff - ´æ·ÅдÈëÊý¾ÝµÄÖ¸Õë
+ addr - ¿ªÊ¼µØÖ·
+ len - ҪдÈëµÄ³¤¶È
+·µ»ØÖµ£º
+ 0 - ³É¹¦
+ 1 - ʧ°Ü
+******************************************************************************/
+extern u8 e2prom_write(u8 *src_buff, u16 addr, u16 len);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//ADCÏà¹Ø
+/*
+ ADC³õʼ»¯
+*/
+//extern void adc_init(void);
+/*
+ Ó¦ÓòãÐèÍê³ÉSYSTICKÖжϷþÎñº¯ÊýDMA1_Channel1_IRQHandler£¬²¢µ÷ÓÃDMA1_Channel1_readº¯Êý
+*/
+extern void DMA1_Channel1_read(void);
+/*
+ ²»ÐèÒªÌṩ
+*/
+//extern uint16_t adc_get_val(uint8_t ch);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//·§ÃÅÇý¶¯Ïà¹Ø
+#define valve_state_on 1
+#define valve_state_off 0
+
+/*
+ ³õʼ»¯·§ÃÅÇý¶¯IO
+*/
+extern void valve_init(void);
+
+/*
+ ÉèÖ÷§ÃÅ״̬
+ state: valve_state_on »ò valve_state_off
+*/
+extern void valve_sta_set(uint8_t sta);
+
+/*
+ »ñÈ¡·§ÃÅ״̬
+ ·µ»ØÖµ: valve_state_on »ò valve_state_off
+*/
+extern uint8_t valve_sta_get(void);
+
+/*
+ ·§ÃÅ¿ØÖÆÂß¼£¬Ð趨ÆÚµ÷ÓÃÒÑÇý¶¯·§ÃÅ¿ØÖÆ×´Ì¬»ú£¬½¨Òé
+ ÔÚÖ÷Ñ»·Öе÷ÓÃ
+*/
+extern void valve_ctrl(void);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//Á÷Á¿¼ÆÏà¹Ø
+/*
+ Á÷Á¿¼Æ³õʼ»¯
+*/
+extern void initFlowSensorDriver(void);
+/*
+ ¸üÐÂÁ÷Á¿¼ÆÂö³å¼ÆÊýÖµ£¬Ð趨ÆÚµ÷Óøú¯Êý£¬½¨ÒéÔÚSysTick_Handlerµ÷ÓÃ
+*/
+//extern void flowsensor_update_count(void);
+/*
+ »ñÈ¡Á÷Á¿¼ÆÂö³å¼ÆÊýÖµ
+*/
+extern u32 flowsensor_get_count(void);
+/*
+ ÉèÖÃÁ÷Á¿¼ÆÂö³å¼ÆÊýÖµ
+*/
+extern void flowsensor_set_count(u32 val);
+
+/*
+ »ñÈ¡Á÷Á¿¼ÆµçÁ÷AD²ÉÑùÖµ£¬ÒÔ´ËÅжÏÁ÷Á¿¼ÆÊÇ·ñÒì³££¬½¨ÒéÔÚÖ÷Ñ»·Öе÷ÓÃ(µçÁ÷Öµ=ADÖµ/4095*3.3/9.1)
+*/
+extern u16 flowsensor_sta(void);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//¼üÅÌÏà¹Ø
+//¼üÖµ¶¨Òå
+#define KEY_NONE ( 0u) //¿ÕÏÐ״̬
+#define KEY_DIG0 (10u) //Êý×Ö¼ü0
+#define KEY_DIG1 ( 1u) //Êý×Ö¼ü1
+#define KEY_DIG2 ( 2u) //Êý×Ö¼ü2
+#define KEY_DIG3 ( 3u) //Êý×Ö¼ü3
+#define KEY_DIG4 ( 4u) //Êý×Ö¼ü4
+#define KEY_DIG5 ( 5u) //Êý×Ö¼ü5
+#define KEY_DIG6 ( 6u) //Êý×Ö¼ü6
+#define KEY_DIG7 ( 7u) //Êý×Ö¼ü7
+#define KEY_DIG8 ( 8u) //Êý×Ö¼ü8
+#define KEY_DIG9 ( 9u) //Êý×Ö¼ü9
+#define KEY_ENTER (12u) //È·Èϼü
+#define KEY_CANCEL (11u) //È¡Ïû¼ü
+
+/*
+ ¼üÅ̳õʼ»¯
+*/
+//extern uint8_t keypad_init(void);
+/*
+ ¶ÁÈ¡°´¼üÖµ
+*/
+//extern uint8_t keypad_get_key(void);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//flashÏà¹Ø
+
+//¹æ¸ñ¶¨Òå
+#define FLASH_PAGE_SIZE_W25X32 256
+#define FLASH_SIZE (4 * 1024 * 1024)
+#define FLASH_PAGE_NUM 8192
+#define FLASH_SECTOR_SIZE (4*1024)
+#define FLASH_SECTOR_NUMBER 512
+#define FLASH_BLOCK_SIZE (64*1024)
+#define FLASH_BLOCK_NUM 64
+//·µ»ØÖµ
+#define NC_OK 0 //²Ù×÷³É¹¦
+#define NC_FlashErr 0x0000ffff //´íÎó
+#define NC_ElseERR 0x01 //ÆäÓà´íÎó
+#define NC_Writeable 0x02 //ÔÊÐíд
+
+/*
+ ³õʼ»¯
+*/
+extern u32 HW_Flash_Init(void);
+/*
+ ¶ÁDEVICE ID
+*/
+extern void HW_FLASH_JEDEC_ID(uint8_t *buf);
+
+/*
+ ¶ÁFLASH
+*/
+extern u32 HW_Flash_Read(uint32_t addr, uint32_t size, uint8_t *buffer);
+/*
+ Ò³²Á³ý
+*/
+extern u32 HW_Flash_PageErase(uint32_t page);
+/*
+ Ò³±à³Ì
+*/
+extern u32 Flash_Page_Program(uint32_t addr, uint32_t size, uint8_t *pbuf);
+/*
+ ÕûƬ²Á³ý£ºÐèÒªºÜ³¤Ê±¼ä£¬Êµ¼Ê²âÊÔ40s
+*/
+extern u32 HW_Flash_ChipErase(void);
+/*
+ ²»´ø²Á³ýµÄд
+*/
+extern u32 HW_Flash_NotEraseWrite(uint32_t dest, uint32_t size, uint8_t *src);
+/*
+ ´ø²Á³ýµÄд
+*/
+extern u32 HW_Flash_SmartWrite(uint32_t addr, uint32_t size, uint8_t *src);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//¿´ÃŹ·Ïà¹Ø
+/*
+ ¹¦ÄÜ:³õʼ»¯¿´ÃŹ·
+*/
+extern void initWatchDog(void);
+/*
+ ι¹·£¬ÐèÒªÔÚÖ÷Ñ»·Öе÷ÓÃ
+*/
+extern void feedWatchDog(void);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//mifare one hw lib
+
+#define KEYA 0x60 //AÃÜÂë
+#define KEYB 0x61 //BÃÜÂë
+
+//²ÎÊýRequestMode£º
+#define PICC_REQ_ALL 0x52
+#define PICC_REQ_IDLE 0x26
+
+/*
+ ³õʼ»¯¶Á¿¨½Ó¿Ú
+*/
+extern void HW_SPI_RF_CfgInit(void);
+
+/*
+
+ ¹¦ÄÜ: RC530Éϵ縴λ
+ 1. ½«RC530´Óµôµçģʽ»½ÐÑ£¬²¢Íê³É³õʼ»¯
+ 2. »ò½«RC530ÖØÐ¸´Î»
+*/
+ extern u8 M1_RCReset(void);
+
+/*
+ ¹¦ÄÜ: È¡µÃ¿¨ÐòÁкÅ
+ Êä³ö: uchar *pSN - ¿¨ÐòÁкÅ
+ ·µ»Ø: 0-²Ù×÷³É¹¦ ÆäËûÖµ-²Ù×÷ʧ°Ü
+*/
+extern u8 GetM1SN( u8 *pSN );
+
+/*
+
+ ¹¦ÄÜ: Ѱ¿¨
+ ²ÎÊý: RequestMode-Ѱ¿¨Ä£Ê½£¬ÎªIDLE »ò ALL atq-¿¨Æ¬µÄÀàÐÍ ÔÝÎÞÓÃ
+ ·µ»Ø: µ±Îª0x00 ʱ±íʾÓп¨£¬·ñÔòÎÞ¿¨
+*/
+extern u8 M1_Request(u8 RequestMode, u8 * atq );
+
+/*
+
+ ¹¦ÄÜ: ¼ÓÔØÃÜÔ¿
+ ²ÎÊý: ÃÜÔ¿
+ ·µ»Ø: 0-²Ù×÷³É¹¦ ÆäËûÖµ-²Ù×÷ʧ°Ü
+*/
+//extern u8 Load_RAM ( u8 * RawCode );
+
+/*
+
+ ¹¦ÄÜ: ͨ¹ý¿éºÅ½øÐÐУÑ飬֧³ÖS50£¬S70¿¨
+ ²ÎÊý: AuthMode-AÃÜÂë »ò BÃÜÂë snr:¿¨Î¨Ò»ºÅ block:¿éºÅ key:ÃÜÔ¿
+ ·µ»Ø: 0-²Ù×÷³É¹¦ ÆäËûÖµ-²Ù×÷ʧ°Ü
+*/
+extern u8 M1_AuthBlk( u8 AuthMode, u8 *Snr, u8 Block, u8 *key );
+
+extern u8 M1_Select(u8 *Snr);
+/*
+ M1_E2Read ¶ÁÈ¡RC500µÄE2ÖеÄÊý¾Ý
+ Addr :E2ÆðʼµØÖ·(Addr < 80H )
+ length :ÒªÇó¶ÁÈ¡µÄ×Ö½ÚÊý( СÓÚµÈÓÚ16 )
+ pBuffer :¶Á³öÊý¾ÝµÄ»º³åÇø
+ ·µ»ØÖµ £º0±íʾд³É¹¦
+*/
+//extern u8 M1_E2Read( u8 Addr, u8 length, u8 * pBuffer);
+
+/*
+ M1_E2Write ½«Êý¾ÝдÈëRC500µÄE2ÖÐ
+ Addr :E2ÆðʼµØÖ·( 0x10 <=Addr < 0x1ff )
+ length :ÒªÇóдÈëµÄ×Ö½ÚÊý( СÓÚµÈÓÚ16 )
+ pBuffer :ҪдÈëÊý¾ÝµÄ»º³åÇø
+ ·µ»ØÖµ £º0±íʾд³É¹¦
+*/
+//extern u8 M1_E2Write( unsigned int Addr, u8 length, u8 * pBuffer);
+
+/*
+ ¹¦ÄÜ£º ¶Á¿¨°åÓ²¼þµôµç£º
+ º¯ÊýÔÐÍ£º void HardPwrDwn() ÔÝûÓÐд
+ ²ÎÊý£º ÎÞ
+ ·µ»ØÖµ£º ÎÞ
+ ˵Ã÷£º
+ ½«¶Á¿¨°åµÄRF¡ªRST¿ØÖÆÏßÖÃΪ¸ßµçƽ£¬¶Á¿¨°å´¦ÓÚÓ²¼þµôµç״̬£¨µçÔ´Õý³£Ìṩ£©¡£
+*/
+extern void M1_HardPwrDwn( void );
+
+/*
+ M1_PCDSn ¶ÁÈ¡RC500µÈ¶Á¿¨Ð¾Æ¬µÄÐòÁкÅ
+ pSn :ÐòÁкŻº³åÇø
+ ·µ»ØÖµ £º0±íʾд³É¹¦
+*/
+extern unsigned char M1_PCDSn( unsigned char * pBuffer);
+
+/*
+ ¹¦ÄÜ£º ¶Á¿¨°å¶Á¿¨Ð¾Æ¬É䯵¹Ø±Õ£º
+ º¯ÊýÔÐÍ£º void M1_RadioOff()
+ ²ÎÊý£º ÎÞ
+ ·µ»ØÖµ£º ÎÞ
+ ˵Ã÷£º
+ ½«¶Á¿¨°åÉϵĶÁ¿¨Ð¾Æ¬µÄÉ䯵·¢Ë͹صô,½µµÍ¹¦ºÄºÍ¶ÔÍâ¸ÉÈÅ
+ ´Ëʱ¶Á¿¨Ð¾Æ¬»¹ÔÚ¹¤×÷.
+*/
+extern void M1_RadioOff( void );
+
+/*
+ ¹¦ÄÜ£º ¶Á¿¨°å¶Á¿¨Ð¾Æ¬É䯵´ò¿ª£º
+ º¯ÊýÔÐÍ£º void M1_RadioOn()
+ ²ÎÊý£º ÎÞ
+ ·µ»ØÖµ£º ÎÞ
+ ˵Ã÷£º
+ ½«¶Á¿¨°åÉϵĶÁ¿¨Ð¾Æ¬µÄÉ䯵·¢ËÍ´ò¿ª
+
+ M1_RadioOn() ºÍ M1_RadioOff()ÊÇÒ»¶Ôº¯Êý,ÓÃÔÚÒ»°ãÇé¿öϵĽÚÄܺͽµµÍÉ䯵¸ÉÈÅÉÏ.
+*/
+extern void M1_RadioOn( void );
+
+/*
+ Fread ¶Á¿éÊý¾Ý
+ Block :¶Á¿éºÅ
+ ReadBuffer :¶Á³öµÄÊý¾ÝµÄ»º³åÇø
+ ·µ»ØÖµ £º0±íʾ¶Á³É¹¦
+*/
+extern u8 M1_Read(u8 Block, u8 * ReadBuffer);
+
+/*
+ Fwrite д¿éÊý¾Ý
+ Block :д¿éºÅ
+ ReadBuffer :ҪдÊý¾ÝµÄ»º³åÇø
+ ·µ»ØÖµ £º0±íʾд³É¹¦
+*/
+extern u8 M1_Write( u8 Block, u8 * WriteBuffer);
+
+/*
+ ¹¦ÄÜ£º ¼ì²é¶Á¿¨Ð¾Æ¬ÊÇ·ñ·¢ÉäÕý³£
+ º¯ÊýÔÐÍ£º u8 M1_TranSta()
+ ²ÎÊý£º ÎÞ
+ ·µ»ØÖµ£º 1 - ÔØ²¨Î´·¢Éä
+ 0 - ÔØ²¨·¢Éä
+*/
+//extern u8 M1_TranSta( void );
+
+/*
+ Halt
+ ¹¦ÄÜ£º ÖÕÖ¹¿¨
+ ²ÎÊý: ÎÞ
+ ·µ»ØÖµ£ºµ±Îª0x00 ʱ±íʾ¿¨ÖÕÖ¹³É¹¦
+*/
+extern u8 M1_Halt( void );
+
+/*
+ ¹¦ÄÜ£º Mifare¿¨¿é¶Á(º¬Ñ°¿¨, Ñ¡¿¨, УÑé, ¶Á¿¨(Ò»¿é), ¿É¹©Ñ¡Ôñ)£º
+ ÊäÈ룺 u8 *pSN - ¿¨ÐòÁкÅ
+ u8 Mode - ( ¸ù¾Ý¶¨ÒåµÄ³£Á¿±í½øÐÐ"»ò"×éºÏ )
+ bit0 - AÃÜÂë»òBÃÜÂë( 0 - A 1 - B)
+ bit2 - 0 - Ѱ¿¨ 1 - ²»Ñ°¿¨
+ bit3 - 0 - ²»Ð£ÑéÃÜÂë 1 - ҪУÑéÃÜÂë
+ u8 Block - Òª¶ÁµÄ¿éºÅ
+ u8 *pKey - ÉÈÇø¶ÁдÃÜÂë
+
+ Êä³ö£º u8 *pBuffer - ¶Á³öµÄ16×Ö½ÚÊý¾Ý
+ ·µ»ØÖµ£ºµ±Îª0x00 ʱÕýÈ·¶Á³ö
+*/
+extern u8 M1_BlkRead( u8 Mode, u8 Block, u8 *pSN, u8 * pBuffer, u8 *pKey );
+
+/*
+ ¹¦ÄÜ£º Mifare¿¨¿éд(º¬Ñ°¿¨, Ñ¡¿¨, УÑé, ¶Á¿¨(Ò»¿é), ¿É¹©Ñ¡Ôñ)£º
+ ÊäÈ룺 u8 *pSN - ¿¨ÐòÁкÅ
+ u8 Mode - ( ¸ù¾Ý¶¨ÒåµÄ³£Á¿±í½øÐÐ"»ò"×éºÏ )
+ bit0 - AÃÜÂë»òBÃÜÂë( 0 - A 1 - B)
+ bit2 - 0 - Ѱ¿¨ 1 - ²»Ñ°¿¨
+ bit3 - 0 - ²»Ð£ÑéÃÜÂë 1 - ҪУÑéÃÜÂë
+ u8 Block - Òª¶ÁµÄ¿éºÅ
+ u8 *pKey - ÉÈÇø¶ÁдÃÜÂë
+ u8 *pBuffer - ҪдÈëµÄ16×Ö½ÚÊý¾Ý
+ ·µ»ØÖµ£ºµ±Îª0x00 ʱÕýÈ·¶Á³ö
+*/
+extern u8 M1_BlkWrite( u8 Mode, u8 Block, u8 *pSN, u8 * pBuffer, u8 *pKey );
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//CPU¿¨ºÍESAMÄ£¿é
+
+//¹¦ÄÜ£º³õʼ»¯SAMͨѶ½Ó¿Ú
+//²ÎÊý£ºÎÞ
+//·µ»Ø£ºÎÞ
+extern void ISO7816_USART_Init(void);
+
+//ich¶¨Òå
+#define PROTOCOL_T0_CH1 1 // ESAMÄ£¿é
+#define PROTOCOL_TCL_PCD0 0x80 //·Ç½Ó´¥Ê½¿¨
+
+//¿¨Éϵ磬ÓÃÓÚSAM¿¨À临λ
+//²ÎÊý£ºcid=0
+// ich ͨµÀºÅ
+//·µ»Ø£º0³É¹¦
+extern unsigned short Gen_PowerOnCard(unsigned char cid, int ich);
+
+//¹Ø±ÕSAM¿¨µçÔ´
+//²ÎÊý£ºich ͨµÀºÅ
+extern void Gen_PowerOffCard(int ich);
+
+//¹¦ÄÜ£º¿¨¸´Î»Ç°³õʼ»¯Ïà¹ØÊý¾Ý½á¹¹£¨ÓÃÓÚSAM»ò¿¨Æ¬£©
+//²ÎÊý£ºcid=0
+// ich ͨµÀºÅ
+void Gen_ResetInfo( unsigned char cid, int ich );
+//¹¦ÄÜ£º¿¨¸´Î»£¨¿ÉÓÃÓÚ¸´Î»SAM»ò¿¨Æ¬£©
+//²ÎÊý£ºcid=0
+// ich ͨµÀºÅ
+//·µ»Ø£º0³É¹¦
+extern unsigned short Gen_ResetCard(unsigned char cid, int ich);
+
+//¹¦ÄÜ£ºActivation of a PICC in IDLE mode.£¨ÓÃÓÚ¿¨Æ¬£©
+//²ÎÊý£ºbr (IN) Baudrate for MIFARE communication 0 106 kBaud
+// atq (OUT) Answer to Request
+// sak (OUT) Select acknowledge
+// uid (OUT) up to 10 bytes UID
+// uid_len (OUT) length of the UID
+//·µ»Ø£º0 ok
+extern short Mf500PiccActivateIdle(unsigned char br,
+ unsigned char *atq,
+ unsigned char *sak,
+ unsigned char *uid,
+ unsigned char *uid_len);
+
+//¹¦ÄÜ£ºSends the PICC into the halt state.
+//²ÎÊý£ºNone
+//·µ»Ø£º0 ok
+//extern short Mf500PiccHalt(void);
+
+//¹¦ÄÜ£ºÔÚÉ䯵¿¨¼ÓµçÇÒ½øÈë144433-4Çé¿öϲâÊÔ¿¨Æ¬µÄ´æÔÚ
+//²ÎÊý£ºÎÞ
+//·µ»Ø£º0 ¿¨´æÔÚ
+// ÆäËû ¿¨²»´æÔÚ
+extern unsigned char PICC_TclCheckRFRounge(void);
+
+//¹¦ÄÜ£ºÊý¾Ý½»»»£¨¿ÉÓÃÓÚ¸´Î»SAM»ò¿¨Æ¬£©
+//²ÎÊý£ºcid=0
+// nad_send=0
+// cmd_buf ÃüÁ³åÇø
+// cmd_len ÃüÁ¶È
+// ExpectedResponseLength ÆÚÍû¿¨Æ¬»Ø¸´µÄÊý¾Ý³¤¶È
+// rec_buf ÓÃÓÚ»ñÈ¡·µ»ØÊý¾ÝµÄÖ¸Õë
+// rec_buf_len ʵ¼Ê½ÓÊÕµ½µÄÊý¾Ý³¤¶È
+// ich ͨµÀºÅ
+//·µ»Ø£º0³É¹¦
+extern unsigned short Gen_Exchange(unsigned char cid,
+ unsigned char nad_send,
+ unsigned char *cmd_buf,
+ unsigned char cmd_len,
+ unsigned char ExpectedResponseLength,
+ unsigned char **rec_buf,
+ unsigned char *rec_buf_len,
+ int ich);
+
+//¹¦ÄÜ: ÉèÖÃ3DES(Ë«±¶³¤)ÃÜÔ¿
+//²ÎÊý: 16×Ö½ÚÃÜÔ¿Öµ
+//·µ»Ø: 0 ³É¹¦
+// ÆäËû ʧ°Ü
+//extern u8 des_set_keys(u8 key[16]);
+
+//¹¦ÄÜ: 3des¼ÓÃÜ
+//²ÎÊý: src[8] ÊäÈë8×Ö½ÚÃ÷ÎÄÊý¾Ý
+// dest[8] Êä³ö8×Ö½ÚÃÜÎÄÊý¾Ý
+//·µ»Ø: ÎÞ
+//extern void des_encrypt(u8 src [ 8 ], u8 dest [ 8 ]);
+
+//¹¦ÄÜ: 3des½âÃÜ
+//²ÎÊý: src[8] ÊäÈë8×Ö½ÚÃÜÎÄÊý¾Ý
+// dest[8] Êä³ö8×Ö½ÚÃ÷ÎÄÊý¾Ý
+//·µ»Ø: ÎÞ
+//extern void des_decrypt(u8 src [ 8 ], u8 dest [ 8 ]);
+
+//¹¦ÄÜ: ²Á³ýESAM¿ªÆÕ¿¨½á¹¹£¬²¢Ìæ»»³õʼÖ÷¿ØÃÜԿΪ16×Ö½ÚÈ«0
+//²ÎÊý: ÎÞ
+//·µ»Ø: 0x9000 ³É¹¦
+// 0x0000 ²»ÊÇ¿ªÆÕ³õʼESAM¿¨¿Õ¼ä£¬²»ÄܽøÐвÁ³ý²Ù×÷
+// ÆäËû ʧ°Ü
+//extern u16 erase_mf(void);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//CANͨѶÏà¹Ø
+typedef struct
+{
+ unsigned int id; /* 29 bit identifier */
+ unsigned char data[8]; /* Data field */
+ unsigned char len; /* Length of data field in bytes */
+ unsigned char ch; /* Object channel */
+ unsigned char format; /* 0 - STANDARD, 1- EXTENDED IDENTIFIER */
+ unsigned char type; /* 0 - DATA FRAME, 1 - REMOTE FRAME */
+}CAN_msg; //CANͨѶÏûÏ¢¶¨Òå
+
+//CANͨѶͨµÀ¶¨Òå(Object channel)
+#define DEF_CAN_CHANNEL_SEND 0x01
+#define DEF_CAN_CHANNEL_RECV 0x01
+
+//CANÖ¡¸ñʽ
+#define STANDARD_FORMAT 0
+#define EXTENDED_FORMAT 1
+
+//CANÖ¡ÀàÐÍ
+#define DATA_FRAME 0
+#define REMOTE_FRAME 1
+
+
+/**********************************************************************************************
+;º¯ÊýÔÐÍ£ºunsigned int APP_CAN_Init( U32 baud, U08 addr )
+;º¯Êý¹¦ÄÜ£º³õʼ»¯ºÍÆô¶¯CAN¿ØÖÆÆ÷
+;Êä È룺baud - CAN²¨ÌØÂÊ addr - ´Ó»úµØÖ·
+;·µ »Ø Öµ£º0 - ³É¹¦ ÆäËû - ʧ°Ü
+**********************************************************************************************/
+extern unsigned int APP_CAN_Init( u32 baud, u8 addr );
+
+//ʹÓÃCAN¿ØÖÆÆ÷·¢ËÍÏûÏ¢
+extern unsigned int CAN_Send(unsigned int ctrl, CAN_msg *msg, unsigned short timeout);
+
+//CAN¿ØÖÆÆ÷½ÓÊÕÏûÏ¢
+extern unsigned int CAN_Recieve( CAN_msg *msg );
+
+//»ñÈ¡CAN·¢ËÍ״̬ 0£ºÃ»·¢ËÍ 1£ºÔÚ·¢ËÍ
+extern unsigned char Get_CAN_TxState(void);
+
+//»ñÈ¡CAN·¢ËÍ״̬ 0£ºÃ»½ÓÊÕ 1£ºÔÚ½ÓÊÕ
+extern unsigned char Get_CAN_RxState(void);
+
+extern void USB_HP_CAN1_TX (void);
+
+
+extern void USB_LP_CAN1_RX0(void);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//ÏÔʾÏà¹Ø
+/**
+ * ´ò¿ª±³¹â
+ */
+void glcd_bkl_on(void);
+
+/**
+ * ¹Ø±Õ±³¹â
+ */
+void glcd_bkl_off(void);
+
+/**
+ * ³õʼ»¯LCDÏÔʾ
+ */
+void glcd_init(void);
+
+/**
+ * ÏÔʾÊý¾Ý
+ */
+void glcd_write(void);
+
+/**
+ * Çå³ýÏÔʾ
+ */
+void glcd_clear(void);
+
+/**
+ * Çå³ýÏÔʾ»º³åÇø
+ */
+void glcd_clear_buffer(void);
+
+//ÏÔʾ²¿·ÖÇë²Î¼ûËùÌṩԴÂ룬ÐèÒªµÄ×ÔÐÐÔö¼Ó
+
+#endif
diff --git a/g401302/src/nec_apdu.c b/g401302/src/nec_apdu.c
new file mode 100644
index 0000000..5e31693
--- /dev/null
+++ b/g401302/src/nec_apdu.c
@@ -0,0 +1,100 @@
+#include <string.h>
+#include "../../nec_hardware.h"
+#include "../../nec_apdu.h"
+
+#define RETCODE_OK 0x9000
+
+int8 psam_poweron(uint8 cid)
+{
+ return Gen_PowerOnCard(cid, PROTOCOL_T0_CH1);
+}
+void psam_powreoff(uint8 cid)
+{
+ Gen_PowerOffCard(cid);
+}
+
+static uint8 gPICC_SNR[8]; /* å¡çSNå? */
+int8 card_request(uint8* sak,uint8 snr[8])
+{
+ uint8 gPICC_SNR_LEN; /* æ?è·åçå¡çSNæ°æ®é¿åº¦ */
+ uint8 gPICC_ATQA[2]; /* */
+ uint8 gPICC_SAK; /* */
+
+ if(!Mf500PiccActivateIdle(0, gPICC_ATQA, &gPICC_SAK, gPICC_SNR, &gPICC_SNR_LEN))
+ {
+ *sak = gPICC_SAK;
+ memcpy(snr,gPICC_SNR,8);
+ return 0;
+ }
+ return -1;
+}
+int8 card_m1_mode(uint8 cardphyid[8])
+{
+ uint8 buff[2];
+ if(M1_Request(PICC_REQ_IDLE, buff))
+ {
+ if(M1_Request(PICC_REQ_IDLE, buff))
+ {
+ return -1;
+ }
+ }
+ if(!GetM1SN(cardphyid))
+ {
+ if(!M1_Select(cardphyid))
+ {
+ return 0;
+ }
+ }
+ return -1;
+}
+int8 card_rf_reset(void)
+{
+ return M1_RCReset();
+}
+int8 card_cpu_mode(void)
+{
+ Gen_ResetInfo(0, PROTOCOL_TCL_PCD0);
+ return Gen_ResetCard(0, PROTOCOL_TCL_PCD0);
+}
+int8 card_cpu_exist(void)
+{
+ return PICC_TclCheckRFRounge();
+}
+
+void card_radio_on(void)
+{
+ M1_RadioOn();
+}
+void card_radio_off(void)
+{
+ M1_RadioOff();
+}
+uint16 card_m1_auth(uint8* cardphyid,uint8 blockno, uint8 key[6])
+{
+ return M1_AuthBlk(KEYA,cardphyid,blockno,key);
+}
+uint16 card_m1_read(uint8 blockno,uint8 readbuf[16])
+{
+ return M1_Read(blockno,readbuf);
+}
+uint16 card_m1_write(uint8 blockno,uint8 writebuf[16])
+{
+ return M1_Write(blockno,writebuf);
+}
+uint16 card_cpu_exchange(uint8* cmd_buf,
+ uint8 cmd_len,
+ uint8 ExpectedResponseLength,
+ uint8** rec_buf,
+ uint8* rec_buf_len)
+{
+ uint16 ret;
+ ret =Gen_Exchange(0,0, cmd_buf, cmd_len, ExpectedResponseLength, rec_buf, rec_buf_len,
+ PROTOCOL_TCL_PCD0);
+ if(ret != RETCODE_OK)
+ {
+ return Gen_Exchange(0,0, cmd_buf, cmd_len, ExpectedResponseLength, rec_buf, rec_buf_len,
+ PROTOCOL_TCL_PCD0);
+ }
+ return RETCODE_OK;
+}
+
diff --git a/g401302/src/nec_hardware.c b/g401302/src/nec_hardware.c
new file mode 100644
index 0000000..3f86ff3
--- /dev/null
+++ b/g401302/src/nec_hardware.c
@@ -0,0 +1,59 @@
+#include "../../nec_hardware.h"
+
+/*Ó²¼þ³õʼ»¯*/
+uint16 sp_init(void)
+{
+ valve_init();
+ initFlowSensorDriver();
+ SysTick_cfg();
+ e2prom_init(0);
+ HW_Flash_Init();
+ rtc_init();
+ glcd_init();
+ usart_init();
+ initWatchDog();
+
+ HW_SPI_RF_CfgInit();
+
+ ISO7816_USART_Init(); //SAMÄ£¿é³õʼ»¯
+
+ if(Gen_PowerOnCard(0,PROTOCOL_T0_CH1)) //¸´Î»SAMÄ£¿éʧ°Ü
+ {
+ return 1;
+ }
+ return 0;
+}
+/*ι¹·*/
+void sp_feed_dog(void)
+{
+ feedWatchDog();
+}
+
+/*Ö÷Ñ»·µ÷Óà ·§ÃÅ¿ØÖÆ*/
+void sp_valve_control(void)
+{
+ valve_ctrl();
+}
+/*Ö÷Ñ»·µ÷Óà Âö³å¼ÆÊý¸üпØÖÆ*/
+void sp_flowsensor_control(void)
+{
+ //flowsensor_update_count();
+}
+
+/*»ñÈ¡µ±Ç°Á÷Á¿¼ÆÂö³å¼ÆÊý*/
+uint32 sp_flowsensor_get_count(void)
+{
+ return flowsensor_get_count();
+}
+
+/*Á÷Á¿¼ÆÂö³å¼ÆÊýÇåÁã */
+void sp_flowsensor_count_clear(void)
+{
+ flowsensor_set_count(0);
+}
+/*0--Á÷Á¿¼ÆÕý³£ 1--Á÷Á¿¼ÆÒì³£*/
+uint8 sp_flowsensor_check_valid(void)
+{
+ return flowsensor_sta();
+}
+
diff --git a/g401302/src/stm32f10x_it.c b/g401302/src/stm32f10x_it.c
new file mode 100644
index 0000000..82b6810
--- /dev/null
+++ b/g401302/src/stm32f10x_it.c
@@ -0,0 +1,168 @@
+/**
+ ******************************************************************************
+ * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 08-April-2011
+ * @brief Main Interrupt Service Routines.
+ * This file provides template for all exceptions handler and
+ * peripherals interrupt service routine.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_it.h"
+#include "G401_drv_hw_V01.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Template
+ * @{
+ */
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/******************************************************************************/
+/* Cortex-M3 Processor Exceptions Handlers */
+/******************************************************************************/
+
+/**
+ * @brief This function handles NMI exception.
+ * @param None
+ * @retval None
+ */
+void NMI_Handler(void)
+{
+}
+
+/**
+ * @brief This function handles Hard Fault exception.
+ * @param None
+ * @retval None
+ */
+void HardFault_Handler(void)
+{
+ /* Go to infinite loop when Hard Fault exception occurs */
+ while (1)
+ {
+ }
+}
+
+/**
+ * @brief This function handles Memory Manage exception.
+ * @param None
+ * @retval None
+ */
+void MemManage_Handler(void)
+{
+ /* Go to infinite loop when Memory Manage exception occurs */
+ while (1)
+ {
+ }
+}
+
+/**
+ * @brief This function handles Bus Fault exception.
+ * @param None
+ * @retval None
+ */
+void BusFault_Handler(void)
+{
+ /* Go to infinite loop when Bus Fault exception occurs */
+ while (1)
+ {
+ }
+}
+
+/**
+ * @brief This function handles Usage Fault exception.
+ * @param None
+ * @retval None
+ */
+void UsageFault_Handler(void)
+{
+ /* Go to infinite loop when Usage Fault exception occurs */
+ while (1)
+ {
+ }
+}
+
+/**
+ * @brief This function handles SVCall exception.
+ * @param None
+ * @retval None
+ */
+void SVC_Handler(void)
+{
+}
+
+/**
+ * @brief This function handles Debug Monitor exception.
+ * @param None
+ * @retval None
+ */
+void DebugMon_Handler(void)
+{
+}
+
+/**
+ * @brief This function handles PendSVC exception.
+ * @param None
+ * @retval None
+ */
+void PendSV_Handler(void)
+{
+}
+
+/**
+ * @brief This function handles SysTick Handler.
+ * @param None
+ * @retval None
+ */
+void SysTick_Handler(void)
+{
+ TimerTick();
+ ComOverTimeProceed();
+}
+
+void USART1_IRQHandler(void)
+{
+}
+
+void UART5_IRQHandler(void)
+{
+ usart_isr_proc();
+
+ //´Ë´¦¿ÉÌí¼ÓÓ¦Óòã´úÂë
+}
+
+void ADC_IRQHandler(void)
+{
+}
+
+void DMA1_Channel1_IRQHandler(void)
+{
+ //DMA1_Channel1_read();
+}
+void USB_HP_CAN1_TX_IRQHandler (void)
+{
+ USB_HP_CAN1_TX ();
+}
+void USB_LP_CAN1_RX0_IRQHandler (void)
+{
+ USB_LP_CAN1_RX0();
+}
diff --git a/g401302/src/stm32f10x_it.h b/g401302/src/stm32f10x_it.h
new file mode 100644
index 0000000..9fd17c0
--- /dev/null
+++ b/g401302/src/stm32f10x_it.h
@@ -0,0 +1,65 @@
+/**
+ ******************************************************************************
+ * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 08-April-2011
+ * @brief This file contains the headers of the interrupt handlers.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_IT_H
+#define __STM32F10x_IT_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "stm32f10x.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+
+void NMI_Handler(void);
+void HardFault_Handler(void);
+void MemManage_Handler(void);
+void BusFault_Handler(void);
+void UsageFault_Handler(void);
+void SVC_Handler(void);
+void DebugMon_Handler(void);
+void PendSV_Handler(void);
+void SysTick_Handler(void);
+void TIM4_IRQHandler(void);
+void USART1_IRQHandler(void);
+void UART5_IRQHandler(void);
+void DMAChannel4_IRQHandler(void);
+void DMAChannel5_IRQHandler(void);
+void EXTI0_IRQHandler(void);
+void EXTI1_IRQHandler(void);
+void DMA1_Channel1_IRQHandler(void);
+void USB_HP_CAN1_TX_IRQHandler (void);
+void USB_LP_CAN1_RX0_IRQHandler (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_IT_H */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/icc_apdu_lib/CPU.H b/icc_apdu_lib/CPU.H
new file mode 100644
index 0000000..da932ce
--- /dev/null
+++ b/icc_apdu_lib/CPU.H
@@ -0,0 +1,52 @@
+/*
+**************************************************************************************************************
+* C P U Ïà ¹Ø µÄ Ó² ¼þ ¶¨ Òå
+*
+* ×÷ Õߣº ÕŽø
+* °æ ±¾£º
+* ÈÕ ÆÚ£º
+**************************************************************************************************************
+*/
+
+#ifndef __CPU_H__
+#define __CPU_H__
+
+
+/*
+**************************************************************************************************************
+* Àà ÐÍ ¶¨ Òå
+**************************************************************************************************************
+*/
+ typedef void CPU_VOID;
+ typedef unsigned char CPU_CHAR; /* 8-bit character */
+ typedef unsigned char CPU_BOOLEAN; /* 8-bit boolean or logical */
+ typedef unsigned char CPU_INT08U; /* 8-bit unsigned integer */
+ typedef signed char CPU_INT08S; /* 8-bit signed integer */
+ typedef unsigned short CPU_INT16U; /* 16-bit unsigned integer */
+ typedef signed short CPU_INT16S; /* 16-bit signed integer */
+ typedef unsigned int CPU_INT32U; /* 32-bit unsigned integer */
+ typedef signed int CPU_INT32S; /* 32-bit signed integer */
+ typedef float CPU_FP32; /* 32-bit floating point */
+ typedef double CPU_FP64; /* 64-bit floating point */
+
+
+ typedef unsigned char uchar;
+ typedef unsigned short ushort;
+ typedef unsigned int uint;
+
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+
+
+/*
+**************************************************************************************************************
+* ±ä Á¿
+**************************************************************************************************************
+*/
+
+
+#endif
+
diff --git a/icc_apdu_lib/CardErrorCode.h b/icc_apdu_lib/CardErrorCode.h
new file mode 100644
index 0000000..3957e63
--- /dev/null
+++ b/icc_apdu_lib/CardErrorCode.h
@@ -0,0 +1,58 @@
+
+#ifndef CARDERRNO_H
+#define CARDERRNO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+// T=CL Error Codes Base Address Start: -1100
+// Base Address End: -1150
+//////////////////////////////////////////////////////////////////////////////
+#define TCL_ERR_BASE_START 0x1000
+
+#define TCL_OK 0
+//#define TCL_NOTAGERR (TCL_ERR_BASE_START +0x1)
+#define TCL_CRCERR (TCL_ERR_BASE_START +0x2)
+//#define TCL_PRITYERR (TCL_ERR_BASE_START +0x3)
+#define TCL_OTHERERR (TCL_ERR_BASE_START +0x4)
+//#define TCL_SERNRERR (TCL_ERR_BASE_START +0x5)
+//#define TCL_BITCOUNTERR (TCL_ERR_BASE_START +0x6)
+//#define TCL_POLLING (TCL_ERR_BASE_START +0x7)
+//#define TCL_RF_CHANNEL (TCL_ERR_BASE_START +0x8)
+//#define TCL_MULTACT_DISABLED (TCL_ERR_BASE_START +0x9)
+//#define TCL_MULTACT_ENABLED (TCL_ERR_BASE_START +0x10)
+//#define TCL_CID_NOT_ACTIVE (TCL_ERR_BASE_START +0x11)
+//#define TCL_BITANTICOLL (TCL_ERR_BASE_START +0x12)
+//#define TCL_UIDLEN (TCL_ERR_BASE_START +0x13)
+#define TCL_CIDINVALID (TCL_ERR_BASE_START +0x14)
+#define TCL_ATSLEN (TCL_ERR_BASE_START +0x15)
+//#define TCL_NO_ATS_AVAILABLE (TCL_ERR_BASE_START +0x16)
+//#define TCL_ATS_ERROR (TCL_ERR_BASE_START +0x17)
+#define TCL_FATAL_PROTOCOL (TCL_ERR_BASE_START +0x18)
+//#define TCL_RECBUF_OVERFLOW (TCL_ERR_BASE_START +0x19)
+//#define TCL_SENDBYTENR (TCL_ERR_BASE_START +0x20)
+//#define TCL_TRANSMERR_HALTED (TCL_ERR_BASE_START +0x21)
+//#define TCL_TRANSMERR_NOTAG (TCL_ERR_BASE_START +0x22)
+//#define TCL_BAUDRATE_NOT_SUPPORTED_PICC (TCL_ERR_BASE_START +0x23)
+//#define TCL_CID_NOT_SUPPORTED (TCL_ERR_BASE_START +0x24)
+//#define TCL_NAD_NOT_SUPPORTED (TCL_ERR_BASE_START +0x25)
+//#define TCL_PROTOCOL_NOT_SUPPORTED (TCL_ERR_BASE_START +0x26)
+#define TCL_PPS_FORMAT (TCL_ERR_BASE_START +0x27)
+//#define TCL_ERROR (TCL_ERR_BASE_START +0x28)
+#define TCL_NADINVALID (TCL_ERR_BASE_START +0x30)
+//#define TCL_OTHER_ERR (TCL_ERR_BASE_START +0x31)
+//#define TCL_BAUDRATE_NOT_SUPPORTED_PCD (TCL_ERR_BASE_START +0x32)
+//#define TCL_CID_ACTIVE (TCL_ERR_BASE_START +0x33)
+
+#define TCL_ERR_BASE_END (TCL_ERR_BASE_START +0x49)
+
+#define TCL_2LAYER_ERR (TCL_ERR_BASE_START +0x80)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // CARDERRNO_H
+
diff --git a/icc_apdu_lib/ICC_APDU_LIB.H b/icc_apdu_lib/ICC_APDU_LIB.H
new file mode 100644
index 0000000..4ce4646
--- /dev/null
+++ b/icc_apdu_lib/ICC_APDU_LIB.H
@@ -0,0 +1,68 @@
+/*
+**************************************************************************************************************
+* RF Ä£ ¿é Óë SAM Ä£ ¿é ISO7816 Çý ¶¯ ¿â
+*
+* _____ ISO7816-2 Ó¦ÓÃÐÒéÊý¾Ýµ¥Î» Çý ¶¯_____
+*
+* Ãè Êö£º ½«Ó¦ÓÃÐÒ飨APDU£©Ó°Éäµ½É趨µÄ´«ÊäÐÒé(TPDU)ºÍ½Ó¿ÚÉÏ
+*
+* Åä Öãº
+* CPU :
+* ÍâʱÖÓ :
+* CPUÔËÐÐʱÖÓ :
+* ÔËÐл·¾³ : Keil ARM ( RealView MDK ) v3.50ÆÆ½â°æ±¾
+* »·¾³ÉèÖà : 1) ģʽ:
+* 2) ÓÅ»¯: ĬÈÏ ( Level 0 (-00) ...)
+*
+* ×¢ Ò⣺ ¶ÔRFÄ£¿é²Ù×÷ʱµÄSPI½Ó¿Ú¹²ÓÃÎÊÌâµÄ´¦Àí¡£
+*
+* ¿â Ãû£º ICC_APDU_LIB_V2.0.LIB
+*
+* ×÷ Õߣº Zhang_OS@163.com
+*
+* °æ ±¾£º 2.0
+*
+* ÈÕ ÆÚ£º 2009-05-31
+*
+* Copyright (c) 2008-2009 Brand-NEW C.A.P Electronics Technology CO.,LTD
+*
+**************************************************************************************************************
+*/
+
+#ifndef __ICC_APDU_LIB_H__
+#define __ICC_APDU_LIB_H__
+
+
+
+ #include "ICC_APDU_Maper.H"
+ #include "T0T1.H"
+ #include "TCL.H"
+ #include "ISOUSARTDriver.H"
+ #include "MFRC500.h"
+ #include "MfErrNo.h"
+ #include "RICReg.h"
+
+
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+
+
+/*
+**************************************************************************************************************
+* ±ä Á¿
+**************************************************************************************************************
+*/
+
+
+/*
+**************************************************************************************************************
+* º¯ Êý
+**************************************************************************************************************
+*/
+
+
+
+#endif
diff --git a/icc_apdu_lib/ICC_APDU_Maper.c b/icc_apdu_lib/ICC_APDU_Maper.c
new file mode 100644
index 0000000..69b1b39
--- /dev/null
+++ b/icc_apdu_lib/ICC_APDU_Maper.c
@@ -0,0 +1,264 @@
+/*
+**************************************************************************************************************
+* ISO7816-1 T0,T1( Ó¦ÓÃÐÒéÊý¾Ýµ¥Î»²ã ) Ó¦ Óà РÒé ²ã Çý ¶¯
+*
+* _____ ISO7816-2 Ó¦ÓÃÐÒéÊý¾Ýµ¥Î» Çý ¶¯_____
+*
+* Ãè Êö£º IC¿¨Ó¦ÓòãÐÒéÓ°Éä³ÌÐò,½«Ó¦ÓÃÐÒ飨APDU£©Ó°Éäµ½É趨µÄ´«ÊäÐÒé(TPDU)ºÍ½Ó¿ÚÉÏ
+*
+* Åä Öãº
+* ÔËÐл·¾³ : Keil ARM ( RealView MDK ) v3.23AÆÆ½â°æ±¾
+* »·¾³ÉèÖà : 1) ģʽ:
+* 2) ÓÅ»¯: ĬÈÏ ( Level 0 (-00) ...)
+*
+* ×¢ Ò⣺ T0,T1´«ÊäÐÒé·ûºÏISO7816-2£¬EMV±ê×¼£»
+*
+* ²ã Ãû£º ICC_APDU_Maper.H
+*
+* ×÷ Õߣº Zhang_OS@163.com
+*
+* °æ ±¾£º V1.0
+*
+* ÈÕ ÆÚ£º 2008-03-31
+*
+* Copyright (c) 2008 Brand-NEW C.A.P Electronics Technology CO.,LTD
+*
+**************************************************************************************************************
+*/
+
+ #include "LIB_Includes.H"
+
+
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+
+
+/*
+**************************************************************************************************************
+* Àà ÐÍ
+**************************************************************************************************************
+*/
+
+/*
+**************************************************************************************************************
+* ±ä Á¿
+**************************************************************************************************************
+*/
+//====>>È«¾Ö±äÁ¿
+ unsigned char ucMemPool[MEMORY_BUFFER_SIZE]; /* ͨÐÅ»º³åÇø,Óû§¿¨Êý¾Ý²Ù×÷µÄʵ¼ÊÄÚ´æ¿Õ¼ä */
+ unsigned char scMemPool[MEMORY_BUFFER_SIZE]; /* ͨÐÅ»º³åÇø,SAM¿¨Êý¾Ý²Ù×÷µÄʵ¼ÊÄÚ´æ¿Õ¼ä */
+
+
+//====>>¾Ö²¿±äÁ¿
+ ICCSTRUCT IccInfo; /* IC¿¨×´Ì¬¶¨Òå */
+ PICCSTRUCT PiccInfo; /* RF¿¨Í¨ÐÅÐÅÏ¢Êý¾Ý½á¹¹ */
+
+
+/*
+**************************************************************************************************************
+* º¯ Êý
+**************************************************************************************************************
+*/
+
+/*
+**************************************************************************************************************
+* ³õ ʼ »¯ ¿¨ ЊϢ Êý ¾Ý ½á ¹¹
+*
+* Ãè Êö£º½Ó´¥Ê½·Ç½Ó´¥Ê½ ³õ ʼ »¯ ¿¨ ЊϢ Êý ¾Ý ½á ¹¹
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+*
+* ·µ »Ø£ºÎÞ
+*
+**************************************************************************************************************
+*/
+ void Gen_ResetInfo( unsigned char cid, int ich )
+ {
+ switch (ich){
+ case PROTOCOL_T0_CH0: //PSAM1
+ case PROTOCOL_T0_CH1: //PSAM2
+ case PROTOCOL_T0_CH2: //½Ó´¥Ê½CPU
+ case PROTOCOL_T1_CH0:
+ ResetIccInfo( cid,&IccInfo );
+ break;
+
+ case PROTOCOL_TCL_PCD0:
+ ResetPiccInfo( cid, &PiccInfo );
+ break;
+ }
+ }
+
+/*
+**************************************************************************************************************
+* ¿¨ ÉÏ µç£¬Àä ¸´ λ
+*
+* Ãè Êö£º½Ó´¥Ê½·Ç½Ó´¥Ê½ ÉϵçÀ临λ
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+*
+* ·µ »Ø£ºICErrorCode
+*
+**************************************************************************************************************
+*/
+ unsigned short Gen_PowerOnCard( unsigned char cid, int ich )
+ {
+ unsigned short rcode = 0x003A;
+ switch (ich){
+ case PROTOCOL_T0_CH0: //PSAM1
+ case PROTOCOL_T0_CH1: //PSAM2
+ case PROTOCOL_T0_CH2: //½Ó´¥Ê½CPU
+ case PROTOCOL_T1_CH0:
+ ResetIccInfo(cid,&IccInfo);
+ rcode = T0PowerOnCard(ich);
+ break;
+
+ case PROTOCOL_TCL_PCD0:
+ rcode = TclGetAts(cid,&PiccInfo);
+ break;
+ }
+ return rcode;
+ }
+
+/*
+**************************************************************************************************************
+* ¿¨ Ï µç
+*
+* Ãè Êö£º¿¨Ïµç
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+*
+* ·µ »Ø£ºICErrorCode
+*
+**************************************************************************************************************
+*/
+ void Gen_PowerOffCard( int ich )
+ {
+ switch (ich){
+ case PROTOCOL_T0_CH0: //PSAM1
+ case PROTOCOL_T0_CH1: //PSAM2
+ case PROTOCOL_T0_CH2: //½Ó´¥Ê½CPU
+ case PROTOCOL_T1_CH0:
+ ResetIccInfo(0,&IccInfo);
+ T0PowerOffCard(ich);
+ break;
+
+ case PROTOCOL_TCL_PCD0:
+ break;
+ }
+ return ;
+ }
+
+/*
+**************************************************************************************************************
+* ¿¨ ÈÈ ¸´ λ
+*
+* Ãè Êö£º½Ó´¥Ê½·Ç½Ó´¥Ê½ ÉϵçÀ临λ
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+*
+* ·µ »Ø£ºICErrorCode
+*
+**************************************************************************************************************
+*/
+ unsigned short Gen_ResetCard( unsigned char cid, int ich )
+ {
+ unsigned short rcode = 0x003A;
+ switch (ich){
+ case PROTOCOL_T0_CH0: //PSAM1
+ case PROTOCOL_T0_CH1: //PSAM2
+ case PROTOCOL_T0_CH2: //½Ó´¥Ê½CPU
+ rcode = T0ResetCard(ich,&IccInfo);
+ //if(IccInfo.T == 1) ich++;
+ break;
+
+ case PROTOCOL_T1_CH0:
+ rcode = T0ResetCard(ich,&IccInfo);
+ break;
+
+ case PROTOCOL_TCL_PCD0:
+ rcode = TclGetAts(cid,&PiccInfo);
+ break;
+ }
+ return rcode;
+ }
+
+/*
+**************************************************************************************************************
+* ¿¨ Êý ¾Ý ½» »» ³Ì Ðò
+*
+* Ãè Êö£º¿¨Êý¾Ý½»»»³ÌÐò,Êý¾Ý´«ÊäÓë½ÓÊÕ ÔÝûÓÐʹÓÃ?
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+* nad_send
+*
+* ·µ »Ø£ºICErrorCode
+*
+**************************************************************************************************************
+*/
+ unsigned short Gen_ChangeISFC( unsigned char cid, unsigned char nad_send, int ich )
+ {
+ unsigned short rcode = 0x003A;
+ switch (ich){
+ case PROTOCOL_T1_CH0:
+ rcode = T1IFSC(cid,nad_send,ich&0xfffffffe);
+ break;
+ }
+ return rcode;
+ }
+
+/*
+**************************************************************************************************************
+* ¿¨ Êý ¾Ý ½» »» ³Ì Ðò
+*
+* Ãè Êö£º¿¨Êý¾Ý½»»»³ÌÐò,Êý¾Ý´«ÊäÓë½ÓÊÕ
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+* *cmd_buf ·¢Ë͵ÄÃüÁ³åÇøÖ¸Õë
+* cmd_len ·¢Ë͵ÄÃüÁ¶È
+* ExpectedResponseLength
+* **rec_buf ½ÓÊÕÊý¾Ý»º³åÇøÖ¸Õë
+* *rec_buf_len ½ÓÊÕÊý¾Ý³¤¶È
+* ich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+*
+* ·µ »Ø£ºICErrorCode
+*
+**************************************************************************************************************
+*/
+ unsigned short Gen_Exchange( unsigned char cid,
+ unsigned char nad_send,
+ unsigned char *cmd_buf,
+ unsigned char cmd_len,
+ unsigned char ExpectedResponseLength,
+ unsigned char **rec_buf,
+ unsigned char *rec_buf_len,
+ int ich )
+ {
+ unsigned short rcode = 0x003A;
+// printsend(cmd_buf,cmd_len);
+ switch (ich){
+ case PROTOCOL_T0_CH0: //PSAM1
+ case PROTOCOL_T0_CH1: //PSAM2
+ case PROTOCOL_T0_CH2: //½Ó´¥Ê½CPU
+ rcode = T0Exchange(cmd_buf,cmd_len,rec_buf,rec_buf_len,ich);
+ break;
+
+ case PROTOCOL_T1_CH0:
+ rcode = T1Exchange(cid,nad_send,cmd_buf,cmd_len,rec_buf,rec_buf_len,ich&0xfffffffe);
+ break;
+
+ case PROTOCOL_TCL_PCD0:
+ rcode = TclExchange(cid,nad_send,cmd_buf,cmd_len,ExpectedResponseLength,rec_buf,rec_buf_len);
+ break;
+ }
+// printrcv(*rec_buf,*rec_buf_len);
+ return rcode;
+ }
+
diff --git a/icc_apdu_lib/ICC_APDU_Maper.h b/icc_apdu_lib/ICC_APDU_Maper.h
new file mode 100644
index 0000000..7d7bac2
--- /dev/null
+++ b/icc_apdu_lib/ICC_APDU_Maper.h
@@ -0,0 +1,198 @@
+/*
+**************************************************************************************************************
+* ISO7816-1 T0,T1( Ó¦ÓÃÐÒéÊý¾Ýµ¥Î»²ã ) Ó¦ Óà РÒé ²ã Çý ¶¯
+*
+* _____ ISO7816-2 Ó¦ÓÃÐÒéÊý¾Ýµ¥Î» Çý ¶¯_____
+*
+* Ãè Êö£º ½«Ó¦ÓÃÐÒ飨APDU£©Ó°Éäµ½É趨µÄ´«ÊäÐÒé(TPDU)ºÍ½Ó¿ÚÉÏ
+*
+* Åä Öãº
+* CPU :
+* ÍâʱÖÓ :
+* CPUÔËÐÐʱÖÓ :
+* ÔËÐл·¾³ : Keil ARM ( RealView MDK ) v3.50ÆÆ½â°æ±¾
+* »·¾³ÉèÖà : 1) ģʽ:
+* 2) ÓÅ»¯: ĬÈÏ ( Level 0 (-00) ...)
+*
+* ×¢ Ò⣺ T0,T1´«ÊäÐÒé·ûºÏISO7816-2£¬EMV±ê×¼£»
+*
+* ²ã Ãû£º ICC_APDU_Maper.H
+*
+* ×÷ Õߣº Zhang_OS@163.com
+*
+* °æ ±¾£º V2.0
+*
+* ÈÕ ÆÚ£º 2009-05-21
+*
+* Copyright (c) 2008-2009 Brand-NEW C.A.P Electronics Technology CO.,LTD
+*
+**************************************************************************************************************
+*/
+
+#ifndef __ICC_APDU_Maper_H__
+#define __ICC_APDU_Maper_H__
+
+
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+ #define PROTOCOL_T0_CH0 SLOT_PSAM1_ICC /* PSAM1 */
+ #define PROTOCOL_T0_CH1 SLOT_PSAM2_ICC /* PSAM2 */
+ #define PROTOCOL_T0_CH2 SLOT_CPU_ICC /* PSAM3 ÕâÀïÖ÷ÒªÊǽӽӴ¥Ê½CPU¿¨ */
+
+//#define SLOT_PSAM1_ICC 0 // PSAM1
+//#define SLOT_PSAM2_ICC 1 // PSAM2
+//#define SLOT_CPU_ICC 2 // ½Ó´¥Ê½CPU
+
+
+ #define PROTOCOL_T1_CH0 (1<<4)+1 /* PSAM_POWER 7816-3 T=1 */
+
+ #define PROTOCOL_TCL_PCD0 0x80 /* 14443-4 T=CL */
+
+
+ #define MEMORY_BUFFER_SIZE 256 /* ͨÐÅ»º³åÇø´óС¶¨Òå PSAM¿¨µÈ */
+
+/*
+**************************************************************************************************************
+* Àà ÐÍ
+**************************************************************************************************************
+*/
+
+/*
+**************************************************************************************************************
+* ±ä Á¿
+**************************************************************************************************************
+*/
+
+ extern unsigned char ucMemPool[MEMORY_BUFFER_SIZE]; /* ͨÐÅ»º³åÇø,Óû§¿¨Êý¾Ý²Ù×÷µÄʵ¼ÊÄÚ´æ¿Õ¼ä */
+ extern unsigned char scMemPool[MEMORY_BUFFER_SIZE]; /* ͨÐÅ»º³åÇø,SAM¿¨Êý¾Ý²Ù×÷µÄʵ¼ÊÄÚ´æ¿Õ¼ä */
+
+
+/*
+**************************************************************************************************************
+* º¯ Êý
+**************************************************************************************************************
+*/
+ extern void Gen_ResetInfo( unsigned char cid, int ich );
+ /* ³õ ʼ »¯ ¿¨ ЊϢ Êý ¾Ý ½á ¹¹ */
+ extern unsigned short Gen_PowerOnCard( unsigned char cid, int ich );
+ /* ¿¨ ÉÏ µç£¬Àä ¸´ λ */
+ extern void Gen_PowerOffCard( int ich );
+ /* ¿¨ Ï µç */
+ extern unsigned short Gen_ResetCard( unsigned char cid, int ich );
+ /* ¿¨ ÈÈ ¸´ λ */
+ extern unsigned short Gen_ChangeISFC( unsigned char cid, unsigned char nad_send, int ich );
+ /* ¿¨ Êý ¾Ý ½» »» ³Ì Ðò */
+ extern unsigned short Gen_Exchange( unsigned char cid, unsigned char nad_send, unsigned char *cmd_buf,
+ unsigned char cmd_len, unsigned char ExpectedResponseLength,
+ unsigned char **rec_buf, unsigned char *rec_buf_len, int ich );
+ /* ¿¨ Êý ¾Ý ½» »» ³Ì Ðò */
+
+
+/*
+**************************************************************************************************************
+* ³õ ʼ »¯ ¿¨ ЊϢ Êý ¾Ý ½á ¹¹
+*
+* Ãè Êö£º½Ó´¥Ê½·Ç½Ó´¥Ê½ ³õ ʼ »¯ ¿¨ ЊϢ Êý ¾Ý ½á ¹¹
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+*
+* ·µ »Ø£ºÎÞ
+*
+**************************************************************************************************************
+*/
+// void Gen_ResetInfo( unsigned char cid, int ich )
+/*
+**************************************************************************************************************
+* ¿¨ ÉÏ µç£¬Àä ¸´ λ
+*
+* Ãè Êö£º½Ó´¥Ê½·Ç½Ó´¥Ê½ ÉϵçÀ临λ
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+*
+* ·µ »Ø£ºICErrorCode
+*
+**************************************************************************************************************
+*/
+// unsigned short Gen_PowerOnCard( unsigned char cid, int ich )
+/*
+**************************************************************************************************************
+* ¿¨ Ï µç
+*
+* Ãè Êö£º¿¨Ïµç
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+*
+* ·µ »Ø£ºICErrorCode
+*
+**************************************************************************************************************
+*/
+// void Gen_PowerOffCard( int ich )
+/*
+**************************************************************************************************************
+* ¿¨ ÈÈ ¸´ λ
+*
+* Ãè Êö£º½Ó´¥Ê½·Ç½Ó´¥Ê½ ÉϵçÀ临λ
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+*
+* ·µ »Ø£ºICErrorCode
+*
+**************************************************************************************************************
+*/
+// unsigned short Gen_ResetCard( unsigned char cid, int ich )
+/*
+**************************************************************************************************************
+* ¿¨ Êý ¾Ý ½» »» ³Ì Ðò
+*
+* Ãè Êö£º¿¨Êý¾Ý½»»»³ÌÐò,Êý¾Ý´«ÊäÓë½ÓÊÕ ÔÝûÓÐʹÓÃ?
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+* nad_send
+*
+* ·µ »Ø£ºICErrorCode
+*
+**************************************************************************************************************
+*/
+// unsigned short Gen_ChangeISFC( unsigned char cid, unsigned char nad_send, int ich )
+/*
+**************************************************************************************************************
+* ¿¨ Êý ¾Ý ½» »» ³Ì Ðò
+*
+* Ãè Êö£º¿¨Êý¾Ý½»»»³ÌÐò,Êý¾Ý´«ÊäÓë½ÓÊÕ
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+* *cmd_buf ·¢Ë͵ÄÃüÁ³åÇøÖ¸Õë
+* cmd_len ·¢Ë͵ÄÃüÁ¶È
+* ExpectedResponseLength
+* **rec_buf ½ÓÊÕÊý¾Ý»º³åÇøÖ¸Õë
+* *rec_buf_len ½ÓÊÕÊý¾Ý³¤¶È
+* ich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+*
+* ·µ »Ø£ºICErrorCode
+*
+**************************************************************************************************************
+*/
+// unsigned short Gen_Exchange( unsigned char cid,
+// unsigned char nad_send,
+// unsigned char *cmd_buf,
+// unsigned char cmd_len,
+// unsigned char ExpectedResponseLength,
+// unsigned char **rec_buf,
+// unsigned char *rec_buf_len,
+// int ich )
+
+
+
+
+
+
+
+#endif
diff --git a/icc_apdu_lib/ISOUSARTDriver.H b/icc_apdu_lib/ISOUSARTDriver.H
new file mode 100644
index 0000000..24c23d0
--- /dev/null
+++ b/icc_apdu_lib/ISOUSARTDriver.H
@@ -0,0 +1,176 @@
+/*
+**************************************************************************************************************
+* ISO7816 USART µ× ²ã Ó² ¼þ ½Ó ¿Ú Çý ¶¯
+*
+* _____Ó² ¼þ µ× ²ã (7816) Çý ¶¯_____
+*
+* Ãè Êö£º Ö÷ÒªÍê³É
+* 1) Òì²½¿¨²éѯ·½Ê½¶ÁÈ¡/·¢ËÍÒ»¸ö×Ö·û (Ö÷ÒªÊÇÔÚ±¾²ãµ÷ÓÃ)
+* 2) IC¿¨µÄ¸´Î»£¬Éϵ磬ϵ磬¼ì²âµÈÓ²¼þ²Ù×÷ (ÔÚ±¾²ãÓëT0T1²ã»áµ÷ÓÃ)
+* 3) T0,T1ÐÒé´«ÊäÊý¾Ýµ¥ÔªÓ³Éä (Ö÷ÒªÊÇÔÚT0T1²ãµ÷ÓÃ)
+*
+* Åä Öãº
+* CPU :
+* ÍâʱÖÓ :
+* CPUÔËÐÐʱÖÓ :
+* ÔËÐл·¾³ : Keil ARM ( RealView MDK ) v3.50ÆÆ½â°æ±¾
+* »·¾³ÉèÖà : 1) ģʽ:
+* 2) ÓÅ»¯: ĬÈÏ ( Level 0 (-00) ...)
+*
+* ×¢ Ò⣺ ¸´Î»Ó¦´ðµÈ¹ý³Ì·ûºÏISO7816-2£¬EMV±ê×¼£»
+*
+* ²ã Ãû£º ISOUSARTDriver.C
+*
+* ×÷ Õߣº Zhang_OS@163.com
+*
+* °æ ±¾£º V2.0
+*
+* ÈÕ ÆÚ£º 2008-05-21
+*
+* Copyright (c) 2008-2009 Brand-NEW C.A.P Electronics Technology CO.,LTD
+*
+**************************************************************************************************************
+*/
+
+
+#ifndef __ISOUSARTDriver_H__
+#define __ISOUSARTDriver_H__
+
+
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+//Óû§¶¨Ê±Æ÷
+#define MAXUSERTIMERS 16 //Óû§¶¨Ê±Æ÷ÊýÁ¿
+#define MAXTIMERSTICK 100000 //Óû§¶¨Ê±Æ÷×î´óʱ¼ä³¤¶È(µ¥Î»1ms)
+//
+#define UERTIMESTATUS_STOP 0 //Óû§¶¨Ê±Æ÷״̬-Í£Ö¹
+#define UERTIMESTATUS_RUN 1 //Óû§¶¨Ê±Æ÷״̬-ÔËÐÐ
+#define UERTIMESTATUS_RINING 2 //Óû§¶¨Ê±Æ÷״̬-µ½Ê±
+#define UERTIMESTATUS_ERROR 3 //Óû§¶¨Ê±Æ÷״̬-µ½Ê±
+
+//Óû§¶¨Ê±Æ÷ID
+#define TID_GENTIMER 0 //ͨÓö¨Ê±Æ÷,ÓÃÓÚÑÓʱDelay
+#define TID_MAINLOOPTIMER 1 //Ö÷Ñ»·¿ØÖÆ¿¨¶¨Ê±Æ÷
+#define TID_ICCCHARTIMER 2 //×Ö·û´«Ê䳬ʱ¶¨Ê±Æ÷
+#define TID_ICCTIMER 3 //IC¿¨¶¨Ê±Æ÷
+#define TID_PICCTIMER 4 //IC¿¨¶¨Ê±Æ÷
+
+#define TID_LEDATIMER 5 //LED-A¶¨Ê±Æ÷
+#define TID_LEDBTIMER 6 //LED-B¶¨Ê±Æ÷
+#define TID_LEDCTIMER 7 //LED-C¶¨Ê±Æ÷
+#define TID_BEEPTIMER 8 //BEEP¶¨Ê±Æ÷
+
+
+//============>> SAM Card USART¶¨Òå
+#define PSAM1_USART USART2 // PSAM1 //ÕŽΰ£¬Ë®¿ØÆ÷ÓõÄÊÇUART2
+//2014.08.19 ¾£Ç¿ G2101300Ë®¿ØÆ÷ SAMʹÓÃUSART3
+#define PSAM2_USART USART3 // PSAM2
+#define CPU_USART USART2 // ½Ó´¥Ê½CPU¿¨
+
+
+//============>> PSAM1 Card
+
+
+#define Pin_SAM1_CARD_IO GPIO_Pin_9 /* PA9 ¿¨Êý¾Ý IRQ 7816*/
+#define Pin_SAM1_CARD_CLK GPIO_Pin_8 /* PA8 ¿¨Ê±ÖÓ IRQ 7816*/
+#define Pin_SAM1_CARD_READY GPIO_Pin_12 /* PA12 ¿¨¾ÍÐ÷¼ì²âÐźŠIRQ 7816*/
+#define Pin_SAM1_CARD_RESET GPIO_Pin_11 /* PA11 ¿¨¸´Î»¿ØÖÆÐźŠRST7816*/
+#define Pin_SAM1_CARD_VCC GPIO_Pin_0 /* PB0 ¿¨µçÔ´¿ØÖÆÐźŠPowerOn*/
+//#define Pin_SAM1_CARD_35 GPIO_Pin_7 /* PC07 µçÔ´µçѹ¿ØÖÆ¿ØÖÆÐźÅ*/
+//#define Pin_SAM1_CARD_CARD GPIO_Pin_8 /* PC08 ¿¨Æ¬²åÈë¼ì²âÐźÅ*/
+
+#define GPIO_SAM1_CARD_IOCLK GPIOA
+#define GPIO_SAM1_CARD_READY GPIOA
+#define GPIO_SAM1_CARD_RESET GPIOA
+#define GPIO_SAM1_CARD_VCC GPIOB
+
+//============>> PSAM2 Card
+//2009.06.04ÑîÎÄÊٸ͝£¬°Ñ¹Ü½Å¶¨Òå¸ÄΪCPU¿¨Ë®¿ØÆ÷ÔÀíͼ¶ÔÓ¦µÄ¹Ü½Å
+#define Pin_SAM2_CARD_IO GPIO_Pin_10 /* PB10 ¿¨Êý¾Ý IRQ 7816*/
+#define Pin_SAM2_CARD_CLK GPIO_Pin_11 /* PB10 ¿¨Ê±ÖÓ IRQ 7816*/
+#define Pin_SAM2_CARD_RESET GPIO_Pin_8 /* PA0 ¿¨¸´Î»¿ØÖÆÐźŠRST7816*/
+//2014.08.19 ¾£Ç¿ G2101300Ë®¿ØÆ÷ ²»ÔÙʹÓÃREADY,VCC,VCC_SELECTÐźÅ
+//#define Pin_SAM2_CARD_READY GPIO_Pin_5 /* PA1 ¿¨¾ÍÐ÷¼ì²âÐźŠIRQ 7816*/
+//#define Pin_SAM2_CARD_VCC GPIO_Pin_6 /* PC3 ¿¨µçÔ´¿ØÖÆÐźŠPowerOn*/
+//#define Pin_SAM2_CARD_VCC_SELECT GPIO_Pin_7 /* PA4 ¿¨µçÔ´¿ØÖÆÐźŠPowerOn*/
+
+#define GPIO_SAM2_CARD_IOCLK GPIOB
+#define GPIO_SAM2_CARD_RESET GPIOC
+//2014.08.19 ¾£Ç¿ G2101300Ë®¿ØÆ÷ ²»ÔÙʹÓÃREADY,VCC,VCC_SELECTÐźÅ
+//#define GPIO_SAM2_CARD_READY GPIOB
+//#define GPIO_SAM2_CARD_VCC_SELECT GPIOB
+//#define GPIO_SAM2_CARD_VCC GPIOB
+
+//============>> CPU Card
+
+#define Pin_CPU_CARD_IO GPIO_Pin_8 /* PD8 ¿¨Êý¾Ý IRQ 7816 */
+#define Pin_CPU_CARD_CLK GPIO_Pin_10 /* PD10 ¿¨Ê±ÖÓ IRQ 7816*/
+#define Pin_CPU_CARD_READY GPIO_Pin_1 /* PB1 ¿¨¾ÍÐ÷¼ì²âÐźŠIRQ 7816*/
+#define Pin_CPU_CARD_RESET GPIO_Pin_9 /* PD9 ¿¨¸´Î»¿ØÖÆÐźŠRST7816*/
+#define Pin_CPU_CARD_VCC GPIO_Pin_0 /* PD0 ¿¨µçÔ´¿ØÖÆÐźŠPowerOn*/
+#define Pin_CPU_CARD_35 GPIO_Pin_1 /* PD1 µçÔ´µçѹ¿ØÖÆ¿ØÖÆÐźÅ*/
+#define Pin_CPU_CARD_CARD GPIO_Pin_2 /* PD2 ¿¨Æ¬²åÈë¼ì²âÐźÅ*/
+
+#define GPIO_CPU_CARD_IOCLK GPIOD
+#define GPIO_CPU_CARD_READY GPIOB
+#define GPIO_CPU_CARD_RESET GPIOD
+#define GPIO_CPU_CARD_VCC GPIOD
+#define GPIO_CPU_CARD_35 GPIOD
+#define GPIO_CPU_CARD_CARD GPIOD
+
+///////////////////////
+
+//´®Ðнӿڶ¨Òå
+
+#define SLOT_PSAM1_ICC 0 // PSAM1
+#define SLOT_PSAM2_ICC 1 // PSAM2
+#define SLOT_CPU_ICC 2 // ½Ó´¥Ê½CPU
+
+/*
+**************************************************************************************************************
+* Àà ÐÍ
+**************************************************************************************************************
+*/
+//¶¨Ê±Æ÷½á¹¹¶¨Òå
+typedef struct _SUserTimer{
+ volatile unsigned int Deadline;
+ volatile unsigned int ReLoadTickNum;
+} SUserTimer,*PSUserTimer;
+
+/*
+**************************************************************************************************************
+* ±ä Á¿
+**************************************************************************************************************
+*/
+
+ extern volatile unsigned int PSAM_TimeTick; /* Current Time Tick */
+ extern SUserTimer UserTimer[MAXUSERTIMERS]; /* User Program Timer*/
+
+/*
+**************************************************************************************************************
+* º¯ Êý
+**************************************************************************************************************
+*/
+
+ extern void ISO7816_USART_Init( void );
+
+ extern void ResetTickCount(void);
+ extern void CheckResetTickCount(void);
+ extern unsigned int BeginTimer(unsigned int TimerID, unsigned int TimerTickCount);
+ extern unsigned int StopTimer(unsigned int TimerID);
+ extern unsigned int GetTimerStatus(const unsigned int TimerID,const int AutoStop);
+ extern void Delay (int tick);
+
+
+
+
+
+
+
+
+
+#endif
+
diff --git a/icc_apdu_lib/ISOUSARTDriver.c b/icc_apdu_lib/ISOUSARTDriver.c
new file mode 100644
index 0000000..2e7d301
--- /dev/null
+++ b/icc_apdu_lib/ISOUSARTDriver.c
@@ -0,0 +1,987 @@
+/*
+**************************************************************************************************************
+* ISO7816 USART µ× ²ã Ó² ¼þ ½Ó ¿Ú Çý ¶¯
+*
+* _____Ó² ¼þ µ× ²ã (7816) Çý ¶¯_____
+*
+* Ãè Êö£º Ö÷ÒªÍê³É
+* 1) Òì²½¿¨²éѯ·½Ê½¶ÁÈ¡/·¢ËÍÒ»¸ö×Ö·û (Ö÷ÒªÊÇÔÚ±¾²ãµ÷ÓÃ)
+* 2) IC¿¨µÄ¸´Î»£¬Éϵ磬ϵ磬¼ì²âµÈÓ²¼þ²Ù×÷ (ÔÚ±¾²ãÓëT0T1²ã»áµ÷ÓÃ)
+* 3) T0,T1ÐÒé´«ÊäÊý¾Ýµ¥ÔªÓ³Éä (Ö÷ÒªÊÇÔÚT0T1²ãµ÷ÓÃ)
+*
+* Åä Öãº
+*
+* ×¢ Ò⣺ ¸´Î»Ó¦´ðµÈ¹ý³Ì·ûºÏISO7816-2£¬EMV±ê×¼£»
+*
+* ²ã Ãû£º ISOUSARTDriver.C
+*
+* ×÷ Õߣº Zhang_OS@163.com
+*
+* °æ ±¾£º V1.0
+*
+* ÈÕ ÆÚ£º 2008-03-25
+*
+* Copyright (c) 2008 Brand-NEW C.A.P Electronics Technology CO.,LTD
+*
+**************************************************************************************************************
+*/
+
+
+#include "LIB_Includes.H"
+
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+ unsigned short FITable[] = {372,372,558,744,1116,1488,1860,372,128,512,768,1024,1536,2048}; /* FI */
+ unsigned char DITable[] = {1,1,2,4,8,16,32,1,12,20}; /* DI */
+
+volatile unsigned int bFeFlags[3];
+volatile unsigned char bFeCount[3];
+volatile unsigned char ibSlot;
+
+
+ICCSTRUCT *T01CurrentIccInfo; /* ICCSTRUCTÔÚT0T1.hÖж¨ÒåµÄµ±Ç°¿¨ÐÅϢ״̬½á¹¹Ìå */
+
+volatile unsigned int PSAM_TimeTick; /* Current Time Tick */
+SUserTimer UserTimer[MAXUSERTIMERS]; /* User Program Timer*/
+
+
+/*
+**************************************************************************************************************
+* º¯ Êý
+**************************************************************************************************************
+*/
+
+
+/*
+**************************************************************************************************************
+* Èí ¼þ ¶¨ ʱ ²¿ ·Ö
+**************************************************************************************************************
+*/
+
+//*--------------------------------------------------------------------------------------
+//* Function Name : ResetTickCount()
+//* Object : systimer tick = 0
+//* Input Parameters :
+//* Output Parameters :
+//*--------------------------------------------------------------------------------------
+void ResetTickCount(void)
+{
+ int TimerID;
+ PSAM_TimeTick = 0;
+ for(TimerID=0;TimerID<MAXUSERTIMERS;TimerID++)
+ {
+ UserTimer[TimerID].Deadline = 0;
+ }
+}
+void update_sam_ticker(void)
+{
+ PSAM_TimeTick++;
+}
+//*--------------------------------------------------------------------------------------
+//* Function Name : CheckResetTickCount()
+//* Object : systimer tick = 0
+//* Input Parameters :
+//* Output Parameters :
+//*--------------------------------------------------------------------------------------
+void CheckResetTickCount(void)
+{
+ int TimerID;
+ for(TimerID=0;TimerID<MAXUSERTIMERS;TimerID++)
+ {
+ if(UserTimer[TimerID].Deadline != 0)
+ {
+ UserTimer[TimerID].Deadline -= 0x10000000;
+ }
+ }
+ PSAM_TimeTick -= 0x10000000;
+}
+//*--------------------------------------------------------------------------------------
+//* Function Name : BeginTimer()
+//* Object : Begin a user timer with tick
+//* Input Parameters :
+//* Output Parameters :
+//*--------------------------------------------------------------------------------------
+unsigned int BeginTimer(unsigned int TimerID, unsigned int TimerTickCount)
+{
+ if( TimerID >= MAXUSERTIMERS) return 0;
+ if(TimerTickCount == 0)
+ TimerTickCount = UserTimer[TimerID].ReLoadTickNum;
+ if(TimerTickCount > MAXTIMERSTICK)
+ TimerTickCount = MAXTIMERSTICK;
+ UserTimer[TimerID].ReLoadTickNum = TimerTickCount;
+ UserTimer[TimerID].Deadline = PSAM_TimeTick+TimerTickCount;
+ return TimerID;
+}
+
+//*--------------------------------------------------------------------------------------
+//* Function Name : StopTimer()
+//* Object : Stop a user timer with tick
+//* Input Parameters :
+//* Output Parameters :
+//*--------------------------------------------------------------------------------------
+unsigned int StopTimer(unsigned int TimerID)
+{
+ if( TimerID >= MAXUSERTIMERS) return UERTIMESTATUS_ERROR;
+ UserTimer[TimerID].Deadline = 0;
+ return TimerID;
+}
+
+//*--------------------------------------------------------------------------------------
+//* Function Name : GetTimerStatus()
+//* Object : Begin a user timer with tick
+//* Input Parameters :
+//* Output Parameters :
+//*--------------------------------------------------------------------------------------
+unsigned int GetTimerStatus(const unsigned int TimerID,const int AutoStop) //·´ÈÆÎÊÌâ
+{
+ unsigned int retcode = UERTIMESTATUS_ERROR;
+
+ if(TimerID > MAXUSERTIMERS)
+ retcode = UERTIMESTATUS_ERROR;
+
+ else if(UserTimer[TimerID].Deadline == 0)
+ retcode = UERTIMESTATUS_STOP;
+ else if(UserTimer[TimerID].Deadline > PSAM_TimeTick)
+ {
+ if((UserTimer[TimerID].Deadline - PSAM_TimeTick) > PSAM_TimeTick+UserTimer[TimerID].ReLoadTickNum)
+ BeginTimer(TimerID,0);
+ else
+ retcode = UERTIMESTATUS_RUN;
+ }
+ else
+ {
+ if(AutoStop)
+ UserTimer[TimerID].Deadline = 0;
+ else
+ UserTimer[TimerID].Deadline = PSAM_TimeTick+UserTimer[TimerID].ReLoadTickNum;
+
+ retcode = UERTIMESTATUS_RINING;
+ }
+ return retcode;
+}
+
+//*--------------------------------------------------------------------------------------
+//* Function Name : Delay()
+//* Object : Delay with tick
+//* Input Parameters :
+//* Output Parameters :
+//*--------------------------------------------------------------------------------------
+//void Delay (int tick) {
+// BeginTimer(TID_GENTIMER,tick);
+// while(GetTimerStatus(TID_GENTIMER,1) != UERTIMESTATUS_RINING);
+//}
+
+/*
+**************************************************************************************************************
+* Èí ¼þ ¶¨ ʱ ²¿ ·Ö END
+**************************************************************************************************************
+*/
+
+unsigned char ISO_GetChar( int ich ); /* Òì²½¿¨²éѯ·½Ê½¶Áȡһ¸ö×Ö·û Ö»ÔÚ±¾ÎļþÖе÷Óà */
+
+
+//ʹÓö¨Ê±Æ÷TIM2 CH4£¬²úÉúESAMʱÖÓÐźÅ
+static void SAM2_CLK_Init(void)
+{
+ TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;
+ TIM_OCInitTypeDef TIM_OCInitStruct;
+
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
+
+ GPIO_PinRemapConfig(GPIO_PartialRemap2_TIM2, ENABLE);
+
+ TIM_TimeBaseInitStruct.TIM_Period = 8;
+ TIM_TimeBaseInitStruct.TIM_Prescaler = 1;
+ TIM_TimeBaseInitStruct.TIM_ClockDivision = 0;
+ TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
+ TIM_TimeBaseInit(TIM2, &TIM_TimeBaseInitStruct);
+
+ TIM_OCInitStruct.TIM_OCMode = TIM_OCMode_PWM1;
+ TIM_OCInitStruct.TIM_OutputState = TIM_OutputState_Enable;
+ TIM_OCInitStruct.TIM_Pulse = 4;
+ TIM_OCInitStruct.TIM_OCPolarity = TIM_OCPolarity_High;
+ TIM_OC4Init(TIM2, &TIM_OCInitStruct);
+
+ TIM_Cmd(TIM2, ENABLE);
+}
+
+// PSAM2¿¨×ù³õʼ»¯
+void SAM2_Card_Init( void )
+{
+ GPIO_InitTypeDef GPIO_InitStructure;
+ USART_InitTypeDef USART_InitStructure;
+ USART_ClockInitTypeDef USART_ClockInitStructure;
+
+ /* Enable clocks 36M*/
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO, ENABLE);
+
+ //=====>> SAM2_CARD_IO | SAM2_CARD_CLK
+ GPIO_InitStructure.GPIO_Pin = Pin_SAM2_CARD_IO;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
+ GPIO_Init( GPIO_SAM2_CARD_IOCLK, &GPIO_InitStructure );
+
+ GPIO_InitStructure.GPIO_Pin = Pin_SAM2_CARD_CLK;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
+ GPIO_Init( GPIO_SAM2_CARD_IOCLK, &GPIO_InitStructure );
+
+ //=====>> SAM2_CARD_RESET
+ GPIO_InitStructure.GPIO_Pin = Pin_SAM2_CARD_RESET;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
+ GPIO_Init( GPIO_SAM2_CARD_RESET, &GPIO_InitStructure);
+
+ GPIO_ResetBits(GPIO_SAM2_CARD_RESET, Pin_SAM2_CARD_RESET);
+
+ USART_SetPrescaler(PSAM2_USART, 0x05);
+
+ /* USART1 Guard Time set to 2 Bit */
+ USART_SetGuardTime(PSAM2_USART, 2);
+
+ USART_StructInit(&USART_InitStructure);
+ USART_InitStructure.USART_BaudRate = 10753;
+ USART_InitStructure.USART_WordLength = USART_WordLength_9b;
+ USART_InitStructure.USART_StopBits = USART_StopBits_1_5;
+ USART_InitStructure.USART_Parity = USART_Parity_Even;
+
+
+ USART_ClockInitStructure.USART_Clock = USART_Clock_Enable;
+
+ USART_Init(PSAM2_USART, &USART_InitStructure);
+ USART_ClockInit( PSAM2_USART, &USART_ClockInitStructure );
+
+ /* Enable USART2 */
+ USART_Cmd(PSAM2_USART, ENABLE);
+
+ /* Enable the NACK Transmission */
+ USART_SmartCardNACKCmd(PSAM2_USART, ENABLE);
+
+ /* Enable the Smart Card Interface */
+ USART_SmartCardCmd(PSAM2_USART, ENABLE);
+}
+
+/*
+*************************************************************************************************************
+ ³õʼ»¯
+*************************************************************************************************************
+*/
+void ISO7816_USART_Init( void )
+{
+ SAM2_Card_Init();
+ SAM2_CLK_Init();
+
+ /* Configure the System Tick */
+ ResetTickCount();
+}
+
+/*******************************************************************************
+* Function Name : ParityErrorHandler
+* Description : Resends the byte that failed to be received (by the Smartcard)
+* correctly.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void ParityErrorHandler(USART_TypeDef * pUSART)
+{
+ bFeFlags[ibSlot] = 1;
+}
+
+//*----------------------------------------------------------------------------
+//* Function Name : isICCardReady
+//* Object : ¼ì²â¿¨¼°µçԴ״̬
+//* Input Parameters : none
+//* Output Parameters : ·µ»ØÖµ£º1-Õý³£,0=¾¯±¨×´Ì¬
+//* Functions called : ¿¨Æ¬PowerOnÒÔºóµ÷ÓÃ
+//*----------------------------------------------------------------------------
+char isICCardReady(int ich)
+{
+ return 1;
+}
+
+
+//*----------------------------------------------------------------------------
+//* Function Name : ICC_ResetCard
+//* Object : ¿¨Èȸ´Î»
+//* Input Parameters : ich = CHNL_ICC/PSAM1_POWER/PSAM2_POWER_ON
+//* Output Parameters : ·µ»ØÖµ£ºICErrorCode
+//* Functions called : none
+//*----------------------------------------------------------------------------
+unsigned short ICC_ResetCard(int ich)
+{
+ u32 y;
+ u32 pps = 0;
+ u8 temp_buffer[12];
+ u8 c_tmp;
+ u8 ta2;
+ USART_InitTypeDef USART_InitStructure;
+ USART_ClockInitTypeDef USART_ClockInitStructure;
+
+ //RESETÖÃµÍµçÆ½£¬½øÈ븴λ״̬
+ GPIO_ResetBits(GPIO_SAM2_CARD_RESET, Pin_SAM2_CARD_RESET);
+ /* Enable USART1 */
+ USART_Cmd(USART3, DISABLE);
+
+ /* Enable the Smart Card Interface */
+ USART_SmartCardCmd(USART3, DISABLE);
+
+ USART_SetPrescaler(USART3, 0x05);
+
+ /* USART1 Guard Time set to 2 Bit */
+ USART_SetGuardTime(USART3, 2);
+
+ USART_StructInit(&USART_InitStructure);
+ USART_InitStructure.USART_BaudRate = 10753 * T01CurrentIccInfo->EXDI;
+ USART_InitStructure.USART_WordLength = USART_WordLength_9b;
+ USART_InitStructure.USART_StopBits = USART_StopBits_1_5;
+ USART_InitStructure.USART_Parity = USART_Parity_Even;
+
+ USART_ClockInitStructure.USART_Clock = USART_Clock_Enable;
+
+ USART_Init(USART3, &USART_InitStructure);
+ USART_ClockInit( USART3, &USART_ClockInitStructure );
+
+ /* Enable USART1 */
+ USART_Cmd(USART3, ENABLE);
+
+ /* Enable the NACK Transmission */
+ USART_SmartCardNACKCmd(USART3, ENABLE);
+
+ /* Enable the Smart Card Interface */
+ USART_SmartCardCmd(USART3, ENABLE);
+
+ //Æô¶¯¸´Î»ÐźÅÑÓʱ¶¨Ê±
+ BeginTimer(TID_ICCTIMER, 12);
+ while ( GetTimerStatus(TID_ICCTIMER,1) != UERTIMESTATUS_RINING)
+ {
+ //µÈ´ý40000-45000¸ö¿¨Ê±ÖÓ//¸´Î»ÐźÅʱ¼ä=12ms ¼ÆËãÒÀ¾Ý£º(MCK/13 = 3.68640MHz)£¬12ms Ï൱ÓÚ44236.8¸ö¿¨Ê±ÖÓ£¬Êµ¼Ê¶¨Ê±Ê±¼äµÄ×î´óÖµ
+ if(isICCardReady(ich)==0)
+ {
+ StopTimer(TID_ICCTIMER);
+ break;
+ }
+ }
+
+ //RESETÖÃ¸ßµçÆ½£¬½øÈëATR¶Áȡ״̬
+ GPIO_SetBits(GPIO_SAM2_CARD_RESET, Pin_SAM2_CARD_RESET);
+
+ T01CurrentIccInfo->TS = 0x3b; //Ê×ÏÈĬÈÏÕýÏòÔ¼¶¨
+
+ //¶ÁÈ¡¿¨Ó¦´ðÐòÁÐATR
+ // Read ATR TS
+ T01CurrentIccInfo->TS = ISO_GetChar(ich); //ÕâÀïÐèÒªÒ»¸ö42000CLOCKµÄ³¬Ê±¶¨Ê±
+ if(T01CurrentIccInfo->TS == 0xff)
+ {
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ {
+ if(T01CurrentIccInfo->ICErrorCode==5)
+ {
+ T01CurrentIccInfo->ICErrorCode=0x003A; //¶ÁÈ¡TS³¬Ê±,PSAM¿¨×ùΪ¿Õ£¡
+ }
+ if(T01CurrentIccInfo->ICErrorCode==4)
+ {
+ T01CurrentIccInfo->ICErrorCode=3; //¶Ì·±£»¤,ÊÓͬ½ðÊô½éÖÊ
+ }
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+ }
+ if((T01CurrentIccInfo->TS!=0x3b) && (T01CurrentIccInfo->TS!=0x3f))
+ {
+ T01CurrentIccInfo->ICErrorCode=6;
+ return T01CurrentIccInfo->ICErrorCode; //TS²»ÊǺϷ¨µÄIC¿¨£¬¾Ü¾ø
+ }
+ // Read ATR T0
+ T01CurrentIccInfo->T0 = ISO_GetChar(ich);
+ if(T01CurrentIccInfo->T0 == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ y = T01CurrentIccInfo->T0 & 0xF0;
+
+ // Read ATR T1
+ if (y) {
+ if (y & 0x10) // TA[i] //ATR-TA1 TA1´«ËÍFIºÍDIµÄÖµ(T=0ʱΪ0x00»ò0x11,T=1ʱ£¬DÖ§³Ö1¡¢2¡¢4¼°Î´À´ÆäËûµÄȡֵ)
+ {
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ T01CurrentIccInfo->DI = c_tmp & 0x0f;
+ T01CurrentIccInfo->FI = (c_tmp>>4) & 0x0f;
+ pps = 1;
+ if((T01CurrentIccInfo->FI==7)||(T01CurrentIccInfo->FI==8)||(T01CurrentIccInfo->FI>=0x0E))
+ {
+ T01CurrentIccInfo->FI = 1;
+ pps = 0;
+ }
+ if((T01CurrentIccInfo->DI==0)||(T01CurrentIccInfo->DI==7)||(T01CurrentIccInfo->FI>=0x0A))
+ {
+ T01CurrentIccInfo->FI = 1;
+ pps = 0;
+ }
+ if((T01CurrentIccInfo->DI > 1 || T01CurrentIccInfo->FI > 1) && ((T01CurrentIccInfo->T0 & 0xf0)==0x60))
+ {
+ T01CurrentIccInfo->ICErrorCode=6;
+ return T01CurrentIccInfo->ICErrorCode; //TS²»ÊǺϷ¨µÄIC¿¨£¬¾Ü¾ø
+ }
+ }
+ else
+ {
+ T01CurrentIccInfo->DI = 1;
+ T01CurrentIccInfo->FI = 1;
+ pps = 0;
+ }
+ if (y & 0x20) // TB[i] //ATR-TB1 TB1´«ËÍPI1ºÍIIÖµ(±à³ÌµçѹºÍµçÁ÷)
+ {
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp != 0x0) //Ö»½ÓÊÜTB1=0µÄÓ¦´ð,±à³ÌµçѹºÍµçÁ÷
+ {
+ T01CurrentIccInfo->ICErrorCode=6;
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+ }
+ if (y & 0x40) // TC[i] //ATR-TC1 ´«ËÍNÖµ,±íʾÔö¼Óµ½×îС³ÖÐøÊ±¼äµÄ¶îÍâ±£»¤Ê±¼ä(etuÊý)
+ {
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+
+ T01CurrentIccInfo->N = c_tmp;
+ }
+ else
+ {
+ T01CurrentIccInfo->N = 2;
+ }
+
+ if (y & 0x80) // TD[i] //ATR-TD1 ÊÇ·ñ»¹Òª·¢Ë͸ü¶àµÄ½Ó¿Ú×Ö½ÚÒÔ¼°ºóÐø´«ÊäËùʹÓõÄÐÒéÀàÐÍ,(½öÖ§³Ö0ºÍ1ÐÒé0x81£¬¾Ü¾øÆäËûÖµ)
+ {
+ T01CurrentIccInfo->TD1 = ISO_GetChar(ich);
+ if(T01CurrentIccInfo->TD1 == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ y = T01CurrentIccInfo->TD1 & 0xF0;
+ T01CurrentIccInfo->T = T01CurrentIccInfo->TD1 & 0x0F; //T=?
+ }
+ else
+ {
+ T01CurrentIccInfo->TD1 = 0;
+ T01CurrentIccInfo->T = 0;
+ y = 0;
+ }
+ }
+
+ //T01CurrentIccInfo->SPMOD = 0; // ÌØ¶¨Ä£Ê½»¹Êǽ»»¥Ä£Ê½
+
+ // Read ATR T2
+ ta2 = 0;
+ if (y) {
+ if (y & 0x10) // TA[i] //ATR-TA2 ÌØ¶¨Ä£Ê½»¹ÊÇÒÔ½»»¥Ä£Ê½
+ {
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ {
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+ T01CurrentIccInfo->SPMOD = c_tmp; //ÌØ¶¨Ä£Ê½ »¹ÊÇ ½»»¥Ä£Ê½ b8=0ÓиıäÄÜÁ¦£¬=1Î޸ıäÄÜÁ¦£»b5=1²»ÓɽӿÚ×Ö½Ú¶¨Ò壬=0½Ó¿Ú×Ö½Ú¶¨Ò壻b4-b1 ÐÒéT
+ ta2 = 1;
+ }
+ if (y & 0x20) // TB[i] //ATR-TB2 TB2´«ËÍPI2£¬PI2ÓÃÓÚÈ·¶¨IC¿¨ËùÐèµÄ±à³ÌµçѹPµÄÖµ
+ {
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp != 0x0) //Ö»½ÓÊÜTB1=0µÄÓ¦´ð,±à³ÌµçѹºÍµçÁ÷
+ {
+ T01CurrentIccInfo->ICErrorCode=6;
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+ }
+ if (y & 0x40) // TC[i] //ATR-TC2 TC2 רÓÃÓÚT=0 ÐÒ飬²¢´«Ë͹¤×÷µÈ´ýʱ¼äÕûÊý(WI),¹¤×÷µÈ´ýʱ¼äΪ£º960¡ÁD¡ÁWI
+ {
+ c_tmp = ISO_GetChar(ich);
+ T01CurrentIccInfo->WI = c_tmp;
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+ else
+ {
+ T01CurrentIccInfo->WI = 10;
+ }
+ if (y & 0x80) // TD[i] //ATR-TD2 TD2±íʾÊÇ·ñ»¹Òª·¢Ë͸ü¶àµÄ½Ó¿Ú×Ö½ÚÒÔ¼°ºóÐø´«ÊäËùʹÓõÄÐÒéÀàÐÍ(0x31)
+ {
+ T01CurrentIccInfo->TD2 = ISO_GetChar(ich);
+ if(T01CurrentIccInfo->TD2 == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ y = T01CurrentIccInfo->TD2 & 0xF0;
+ }
+ else
+ {
+ T01CurrentIccInfo->TD2 = 0;
+ y = 0;
+ }
+ }
+ else
+ {
+ T01CurrentIccInfo->WI = 10;
+ }
+ // Read ATR T3
+ if (y) {
+ if (y & 0x10) // TA[i] //ATR-TA3 »ØËÍIC¿¨µÄÐÅÏ¢Óò´óСÕûÊý(IFSI)
+ {
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ T01CurrentIccInfo->IFSI = c_tmp;
+ }
+ else
+ {
+ T01CurrentIccInfo->IFSI = 32;
+ }
+ if (y & 0x20) // TB[i] //ATR-TB3 ÓÃÀ´¼ÆËãCWTºÍBWTµÄCWIºÍBWIÖµ
+ {
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ T01CurrentIccInfo->CWI = c_tmp & 0x07;
+ T01CurrentIccInfo->BWI = (c_tmp & 0x70)>>4;
+ }
+ else
+ {
+ T01CurrentIccInfo->BWI = 0;
+ T01CurrentIccInfo->CWI = 0;
+ }
+ if (y & 0x40) // TC[i] //ATR-TC3 ËùÓõĿé´íÎó¼ì²â´úÂëµÄÀàÐÍ
+ {
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ T01CurrentIccInfo->Crc = c_tmp & 0x01;
+ }
+ else
+ {
+ T01CurrentIccInfo->Crc = 0; //CRC
+ }
+ if (y & 0x80) // TD[i] //ATR-TD3 TD3ºóÐøTA
+ {
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ if((c_tmp & 0x1f) == 0x1f)
+ c_tmp = ISO_GetChar(ich);
+ }
+ }
+ for(y = 0;y < (T01CurrentIccInfo->T0 & 0x0f) && y < 16; y++)
+ {
+ T01CurrentIccInfo->MRcvBuffer[y] = ISO_GetChar(ich);
+ if(T01CurrentIccInfo->MRcvBuffer[y] == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+ T01CurrentIccInfo->MRcvBuffer[y] = 0;
+
+ // Read ATR TCK
+ if (T01CurrentIccInfo->T == 1) {
+ T01CurrentIccInfo->ETCK = ISO_GetChar(ich);
+ if(T01CurrentIccInfo->ETCK == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+ else
+ {
+ T01CurrentIccInfo->ETCK = 0;
+ }
+
+ //°´ÕÕATRÖ¸¶¨²ÎÊýÖØÐ³õʼ»¯½Ó¿Ú
+ if(T01CurrentIccInfo->T == 0 || T01CurrentIccInfo->T == 1)
+ {
+ USART_SetGuardTime(USART3, T01CurrentIccInfo->N);
+ USART_StructInit(&USART_InitStructure);
+
+ if(ta2 != 0)
+ {
+ if((T01CurrentIccInfo->SPMOD&0x10) == 0)
+ {
+ USART_InitStructure.USART_BaudRate = 4000000ul/(FITable[T01CurrentIccInfo->FI]/DITable[T01CurrentIccInfo->DI]);
+ }
+ else //ÐÉÌģʽµÄFn/Dn»ñµÃ,ÔÝʱ±£Áôȱʡֵ
+ {
+ USART_InitStructure.USART_BaudRate = 10753* T01CurrentIccInfo->EXDI;
+ }
+ }
+ else
+ {
+ pps = 0;
+ if(pps)
+ {
+ char ISO_PutStr(unsigned char *pch, int len, int ich);
+
+ BeginTimer(TID_ICCTIMER, 10);
+ temp_buffer[0] = 0xFF;
+ temp_buffer[1] = 0x10;
+ temp_buffer[2] = 0x95;//(T01CurrentIccInfo->FI<<4)|(T01CurrentIccInfo->DI);
+ temp_buffer[3] = (temp_buffer[0]^temp_buffer[1])^temp_buffer[2];
+ if(ISO_PutStr(temp_buffer, 4, ich) == 0)
+ {
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ temp_buffer[4] = c_tmp;
+
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ temp_buffer[5] = c_tmp;
+
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ temp_buffer[6] = c_tmp;
+
+ c_tmp = ISO_GetChar(ich);
+ if(c_tmp == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ temp_buffer[7] = c_tmp;
+ if(memcmp(temp_buffer, temp_buffer+4, 4) == 0)
+ {
+ USART_InitStructure.USART_BaudRate = 4000000ul/(FITable[T01CurrentIccInfo->FI]/DITable[T01CurrentIccInfo->DI]);
+ }
+ else //ÐÉÌģʽµÄFn/Dn»ñµÃ,ÔÝʱ±£Áôȱʡֵ
+ {
+ USART_InitStructure.USART_BaudRate = 10753* T01CurrentIccInfo->EXDI;
+ }
+ }
+ }
+ else
+ {
+ USART_InitStructure.USART_BaudRate = 10753* T01CurrentIccInfo->EXDI;
+ }
+ }
+
+ USART_InitStructure.USART_WordLength = USART_WordLength_9b;
+ USART_InitStructure.USART_StopBits = USART_StopBits_1_5;
+ USART_InitStructure.USART_Parity = USART_Parity_Even;
+
+ USART_ClockInitStructure.USART_Clock = USART_Clock_Enable;
+
+ USART_Init(USART3, &USART_InitStructure);
+ USART_ClockInit( USART3, &USART_ClockInitStructure );
+
+ /* Enable USART1 */
+ USART_Cmd(USART3, ENABLE);
+
+ /* Enable the NACK Transmission */
+ USART_SmartCardNACKCmd(USART3, ENABLE);
+
+ /* Enable the Smart Card Interface */
+ USART_SmartCardCmd(USART3, ENABLE);
+ }
+ else
+ {
+ T01CurrentIccInfo->ICErrorCode=6;
+ return T01CurrentIccInfo->ICErrorCode; //TS²»ÊǺϷ¨µÄIC¿¨£¬¾Ü¾ø
+ }
+ T01CurrentIccInfo->ICErrorCode = 0;
+ return T01CurrentIccInfo->ICErrorCode;
+}
+
+//*----------------------------------------------------------------------------
+//* Function Name : ICC_PowerOnCard
+//* Object : ¿¨Éϵç,¸´Î»
+//* Input Parameters : ich =
+//* Output Parameters : ·µ»ØÖµ£ºICErrorCode
+//* Functions called : none
+//*----------------------------------------------------------------------------
+unsigned short ICC_PowerOnCard(int ich)
+{
+ int rcode;
+
+ //RESETÖÃµÍµçÆ½£¬½øÈ븴λ״̬
+ GPIO_ResetBits(GPIO_SAM2_CARD_RESET, Pin_SAM2_CARD_RESET);
+
+ //µÈ´ý¿¨µçÔ´¾ÍÐ÷
+ BeginTimer(TID_ICCTIMER, 20); //µÈ´ýµçÔ´¾ÍÐ÷ÐźÅʱ¼ä=10ms Õý³£Çé¿öÏÂLTC1756 5us
+ while (isICCardReady(ich) == 0)
+ { //δ¾ÍÐ÷״̬
+ if(GetTimerStatus(TID_ICCTIMER,1) == UERTIMESTATUS_RINING)
+ {
+ break;
+ }
+ }
+ USART_SmartCardCmd(USART3, ENABLE);
+
+ rcode = ICC_ResetCard(ich);
+ if(rcode)
+ {
+ T01CurrentIccInfo->EXDI = 4;
+ rcode = ICC_ResetCard(ich); //Èȸ´Î»Ê§°Ü,ÔÙÀ´Ò»´Î
+ }
+ return rcode;
+}
+
+//*----------------------------------------------------------------------------
+//* Function Name : ICC_PowerOffCard
+//* Object : ¿¨Ïµç
+//* Input Parameters : ich = CHNL_ICC/PSAM1_POWER/PSAM2_POWER_ON
+//* Output Parameters : none
+//* Functions called : none
+//*----------------------------------------------------------------------------
+void ICC_PowerOffCard(int ich)
+{
+ GPIO_ResetBits(GPIO_SAM2_CARD_RESET, Pin_SAM2_CARD_RESET);
+ BeginTimer(TID_ICCTIMER, 2);
+ while (GetTimerStatus(TID_ICCTIMER,1) != UERTIMESTATUS_RINING){};
+ //ʱÖÓÍ£Ö¹
+ USART_SmartCardCmd(PSAM2_USART, DISABLE);
+ return ;
+}
+
+//*----------------------------------------------------------------------------
+//* Function Name : ISO_GetChar
+//* Object : Òì²½¿¨²éѯ·½Ê½¶Áȡһ¸ö×Ö·û
+//* Input Parameters : ich=IC¿¨½Ó¿Ú
+//* Output Parameters : ·µ»Ø0xffʱ,ÐèÒª¼ì²âICErrorCode£¬ÆäËüֵΪ½ÓÊÕµ½µÄ×Ö·û
+//* Functions called : none
+//*----------------------------------------------------------------------------
+unsigned char ISO_GetChar(int ich)
+{
+ char rcode;
+
+ BeginTimer(TID_ICCCHARTIMER,300); //2011.3.4ºÅÕŽΰµ÷Õû£¬²»µ÷ÕûMAC2УÑ鳬ʱ
+ while(USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET) //ÊÕµ½×Ö·û
+ {
+ if(USART_GetFlagStatus(USART3, USART_FLAG_PE) != RESET) //ÆæÅ¼Ð£Ñé
+ {
+ USART_ReceiveData(USART3); //¸´Î»×´Ì¬¼Ä´æÆ÷
+ T01CurrentIccInfo->ICErrorCode = 0x0007;
+ return 0xff;
+ }
+ //test
+ if(GetTimerStatus(TID_ICCCHARTIMER,1) == UERTIMESTATUS_RINING) //½ÓÊÕ»ú³¬Ê±
+ {
+ T01CurrentIccInfo->ICErrorCode = 0x0005;
+ return 0xff;
+ }
+ if(isICCardReady(ich)==0)
+ {
+ T01CurrentIccInfo->ICErrorCode = 0x0004;
+ return 0xff;
+ }
+ }
+ T01CurrentIccInfo->ICErrorCode = 0;
+ rcode = USART_ReceiveData(USART3); //½ÓÊÕÒ»¸ö×Ö·û
+ if(T01CurrentIccInfo->TS == 0x3f)
+ rcode = ~rcode;
+ return rcode;}
+
+//*----------------------------------------------------------------------------
+//* Function Name : ISO_GetProcByte
+//* Object : µÃµ½¹ý³Ì×Ö½Ú£¬²¢×÷ÅжϽøÒ»²½½ÓÊÕSW2
+//* Input Parameters : ch=INS,ich=IC¿¨½Ó¿Ú
+//* Output Parameters : ·µ»Ø0=¹ý³Ì×Ö½ÚÓëINSÏàͬ,1-255=´íÎó(T01CurrentIccInfo->ICErrorCode´íÎó´úÂë),6xxx/9xxx=SW1SW2
+//* Functions called : none
+//*----------------------------------------------------------------------------
+unsigned short ISO_GetProcByte(unsigned char ch, int ich)
+{
+ unsigned char cch1,cch2;
+
+// USART3->US_CR = AT91C_US_RETTO; //ÖØÔØ½ÓÊÕÆ÷³¬Ê±
+ rvccch1:
+ cch1 = ISO_GetChar(ich);
+ if(cch1 == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return (unsigned short)T01CurrentIccInfo->ICErrorCode;
+ if((cch1 == ch || cch1 == ~ch || cch1 == 0x60) && ch != 0x00)
+ {
+ if(cch1 == 0x60)
+ goto rvccch1;
+ return (unsigned short) 0;
+ }
+ else
+ {
+ cch2 = ISO_GetChar(ich);
+ if(cch2 == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return (unsigned short)T01CurrentIccInfo->ICErrorCode;
+ T01CurrentIccInfo->ICErrorCode = (cch1<<8 | cch2);
+ return (unsigned short)T01CurrentIccInfo->ICErrorCode; //SW1.SW2
+ }
+}
+
+//*----------------------------------------------------------------------------
+//* Function Name : ISO_PutStr
+//* Object : Òì²½¿¨²éѯ·½Ê½·¢³öÒ»¸ö×Ö·û´®
+//* Input Parameters : ich=IC¿¨½Ó¿Ú
+//* Output Parameters : ·µ»Ø·Ç0ʱ,ÐèÒª¼ì²âICErrorCode
+//* Functions called : none
+//*----------------------------------------------------------------------------
+char ISO_PutStr(unsigned char *pch, int len, int ich)
+{
+ unsigned char i,rcode;
+ char ch;
+
+ //Æô¶¯ÐźÅÑÓʱ¶¨Ê±//ÎÕÆæ¿¨ÐèÒªÑÓʱ ±¨ÎÄÖ®¼ä
+ BeginTimer(TID_ICCTIMER, 2); //ÐźÅʱ¼ä=1ms
+ while ( GetTimerStatus(TID_ICCTIMER,1) != UERTIMESTATUS_RINING);
+
+ rcode = 0;
+
+ for(i=0;i<len;i++)
+ {
+ ch = pch[i];
+ if(T01CurrentIccInfo->TS == 0x3f)
+ ch = ~ch; //·´ÏòÔ¼¶¨
+
+ ibSlot = ich;
+ bFeFlags[ibSlot] = 0;
+ bFeCount[ibSlot] = 0;
+ USART_SendData(USART3,ch); //·¢ËÍÒ»¸ö×Ö·û
+
+ while(USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET) //»º³åÆ÷¿Õ£¿
+ {
+ if(bFeFlags[ibSlot])
+ {
+ if(bFeCount[ibSlot] >=3 ) //´«ÊäÖØ·¢£¬´íÎó´ïµ½×î´óÊý
+ {
+ USART_ClearFlag(USART3,USART_FLAG_PE|USART_FLAG_FE|USART_FLAG_NE|USART_FLAG_ORE|USART_FLAG_RXNE|USART_FLAG_TXE); //¸´Î»×´Ì¬¼Ä´æÆ÷
+ T01CurrentIccInfo->ICErrorCode = 0x0007;
+ rcode = T01CurrentIccInfo->ICErrorCode;
+ break;
+ }
+ ibSlot = ich;
+ bFeFlags[ibSlot] = 0;
+ bFeCount[ibSlot]++;
+ USART_SendData(USART3,ch); //ÖØ·¢ËÍÒ»¸ö×Ö·û
+ }
+ if(isICCardReady(ich)==0)
+ {
+ T01CurrentIccInfo->ICErrorCode = 4;
+ rcode = T01CurrentIccInfo->ICErrorCode;
+ break;
+ }
+ }
+ if(rcode != 0)
+ break;
+ }
+ (void)USART_ReceiveData(USART3);
+ return rcode;
+ }
+
+
+//*----------------------------------------------------------------------------
+//* Function Name : ICC_TPDU
+//* Object : ÐÒé´«ÊäÊý¾Ýµ¥ÔªÓ³Éä
+//* Input Parameters : scmd=5×Ö½ÚÃüÁî×Ö·û´®Ö¸Õ루CLA¡¢INS¡¢P1¡¢P2ºÍP3£©,
+//* sdata=·¢ËÍ/½ÓÊÕÊý¾Ý»º³åÈ¥Ö¸Õ룬ctl=ÐÒé¿ØÖÆ×Ö·û£¨¼ûÏÂÊö£©, *rec_bytelen½ÓÊÜÊý¾ÝµÄ³¤¶È£¬ich=IC¿¨½Ó¿Ú
+//* ctl=0ÎÞÊý¾ÝÖ¡scmd[4]=0, ctl=1·¢ËÍÊý¾ÝÖ¡/Ö¡³¤¶ÈÓÉscmd[4]È·¶¨, ctl=2½ÓÊÕÊý¾ÝÖ¡
+//* Output Parameters : ·µ»ØICErrorCode=SW1 SW2»òÕß0-255µÄÎïÀí²ã´íÎó´úÂë
+//* Functions called : none
+//*----------------------------------------------------------------------------
+unsigned short T0_TPDU(unsigned char * scmd, unsigned char * sdata, int ctl, unsigned char *rec_bytelen, int ich)
+{
+ unsigned char cch1;
+ unsigned short rcode,i,ilen;
+
+ USART_ClearFlag(USART3,USART_FLAG_PE|USART_FLAG_FE|USART_FLAG_NE|USART_FLAG_ORE|USART_FLAG_RXNE|USART_FLAG_TXE); //¸´Î»×´Ì¬¼Ä´æÆ÷
+
+ if(ISO_PutStr(scmd, 5, ich) != 0x0) //·¢ËÍÃüÁîÍ·
+ {
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+
+ *rec_bytelen = 0;
+
+ rcode = ISO_GetProcByte(scmd[1], ich);
+ if(rcode == 0)
+ { //·µ»ØÖµÓëINSÏàͬ»òΪ0x60
+ if(ctl == 1)
+ { //¸úËæÃüÁîÊý¾ÝÐèÒª·¢ËÍ
+ if(ISO_PutStr(sdata, scmd[4], ich) != 0x0) //·¢ËÍÊý¾Ý
+ {
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+ }
+ else
+ {
+ ilen = scmd[4];
+ for(i=0;i<ilen;i++)
+ {
+ cch1 = ISO_GetChar(ich);
+ if(cch1 == 0xff)
+ if(T01CurrentIccInfo->ICErrorCode!=0)
+ return T01CurrentIccInfo->ICErrorCode;
+ sdata[i]=cch1;
+ }
+ *rec_bytelen = ilen;
+ }
+ rcode = ISO_GetProcByte(0, ich);
+ }
+ T01CurrentIccInfo->ICErrorCode = rcode;
+ return rcode;
+}
+
+//*----------------------------------------------------------------------------
+//* Function Name : T1_TPDU
+//* Object : T=1 ÐÒé´«ÊäÊý¾Ýµ¥ÔªÓ³Éä
+//* Input Parameters :
+//* Output Parameters : ·µ»ØICErrorCode=SW1 SW2»òÕß0-255µÄÎïÀí²ã´íÎó´úÂë
+//* Functions called : none
+//*----------------------------------------------------------------------------
+unsigned short T1_TPDU(unsigned char *send_data,unsigned char send_bytelen,unsigned char *rec_data,unsigned char *rec_bytelen, int ich)
+{
+ unsigned char cch1;
+ unsigned char i,rLen;
+
+ USART_ClearFlag(USART3,USART_FLAG_PE|USART_FLAG_FE|USART_FLAG_NE|USART_FLAG_ORE|USART_FLAG_RXNE|USART_FLAG_TXE); //¸´Î»×´Ì¬¼Ä´æÆ÷
+
+ if(ISO_PutStr(send_data, send_bytelen, ich) != 0x0) //·¢ËÍÊý¾ÝÖ¡
+ {
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+
+ rLen = 3;
+ for(i=0;i<rLen;i++) //½ÓÊÕNAD¡¢PCB¡¢LEN
+ {
+ cch1 = ISO_GetChar(ich);
+ if(cch1 == 0xff)
+ {
+ if(T01CurrentIccInfo->ICErrorCode==5)
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+ *(rec_data+i)=cch1;
+ }
+
+ rLen += *(rec_data+2); //Êý¾Ý³¤¶È
+ if(T01CurrentIccInfo->Crc == 1)
+ rLen += 2;
+ else
+ rLen += 1;
+
+ for(i=3;i<rLen;i++) //½ÓÊÕÊý¾ÝÖ¡ºÍLRC
+ {
+ cch1 = ISO_GetChar(ich);
+ if(cch1 == 0xff)
+ {
+ if(T01CurrentIccInfo->ICErrorCode==5)
+ return T01CurrentIccInfo->ICErrorCode;
+ }
+ *(rec_data+i)=cch1;
+ }
+ *rec_bytelen = rLen;
+ T01CurrentIccInfo->ICErrorCode = 0;
+ return T01CurrentIccInfo->ICErrorCode;
+}
+
diff --git a/icc_apdu_lib/LIB_Includes.H b/icc_apdu_lib/LIB_Includes.H
new file mode 100644
index 0000000..1b37e44
--- /dev/null
+++ b/icc_apdu_lib/LIB_Includes.H
@@ -0,0 +1,54 @@
+
+
+#ifndef __LIB_Includes_H__
+#define __LIB_Includes_H__
+
+
+
+ #include <string.h>
+ #include "CPU.H"
+ #include "stm32f10x.h"
+
+ #include "ICC_APDU_LIB.H"
+
+ #include "CardErrorCode.H"
+ #include "Mifare_One_HW_LIB.H"
+
+
+//2009.06.04ÑîÎÄÊٸ͝£¬°Ñ¹Ü½Å¶¨Òå¸ÄΪCPU¿¨Ë®¿ØÆ÷ÔÀíͼ¶ÔÓ¦µÄ¹Ü½Å
+#define Pin_Mifare_SCK GPIO_Pin_13
+#define Pin_Mifare_MISO GPIO_Pin_14
+#define Pin_Mifare_MOSI GPIO_Pin_15
+
+#define Pin_Mifare_RST GPIO_Pin_6
+#define Pin_Mifare_NSS GPIO_Pin_12
+
+#define GPIO_MAFIRE_SPI GPIOB
+#define GPIO_MAFIRE_RST GPIOC
+#define GPIO_MAFIRE_NSS GPIOB
+
+
+#define Mifare_SPIx SPI2
+
+
+
+//DataConvert================================================================================
+extern unsigned char * LEIntTo4Str(int i,unsigned char * str);
+extern unsigned char * LEIntTo3Str(int i,unsigned char * str);
+extern unsigned char * LEIntTo2Str(int i,unsigned char * str);
+extern unsigned int BE4StrToInt(unsigned char *str);
+extern unsigned int BE3StrToInt(unsigned char *str);
+extern unsigned short BE2StrToInt(unsigned char *str);
+extern int Compare_two_data(unsigned char *xp1,unsigned char *xp2,unsigned char n);
+extern unsigned char isLeap(unsigned short year);
+extern unsigned char isValidDate(unsigned char * psClock);
+extern unsigned char XOR(unsigned char *buffer,unsigned char length);
+extern unsigned short get_crc_16 (unsigned short start, char *p, unsigned short n);
+extern void CalCrc16(unsigned char* input, unsigned char* Crc16, unsigned int len);
+
+
+
+
+
+#endif
+
diff --git a/icc_apdu_lib/MfErrNo.h b/icc_apdu_lib/MfErrNo.h
new file mode 100644
index 0000000..1d3eeeb
--- /dev/null
+++ b/icc_apdu_lib/MfErrNo.h
@@ -0,0 +1,114 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c), Philips Semiconductors Gratkorn
+//
+// (C)PHILIPS Electronics N.V. 2000
+// All rights are reserved.
+// Philips reserves the right to make changes without notice at any time.
+// Philips makes no warranty, expressed, implied or statutory, including but
+// not limited to any implied warranty of merchantibility or fitness for any
+//particular purpose, or that the use will not infringe any third party patent,
+// copyright or trademark. Philips must not be liable for any loss or damage
+// arising from its use.
+///////////////////////////////////////////////////////////////////////////////
+#ifndef MFERRNO_H
+#define MFERRNO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+// Reader Error Codes Base Address Start: 0x2000
+// Base Address End: 0x2999
+//////////////////////////////////////////////////////////////////////////////
+#define READER_ERR_BASE_START (0x2000)
+#define MI_OK (0)
+#define MI_CHK_OK (0)
+#define MI_CRC_ZERO (0)
+// ICODE1 Error Codes
+#define I1_OK (0)
+#define I1_NO_ERR (0)
+
+#define MI_NOTAGERR (READER_ERR_BASE_START + 0x1)
+#define MI_CHK_FAILED (READER_ERR_BASE_START + 0x1)
+#define MI_CRCERR (READER_ERR_BASE_START + 0x2)
+#define MI_CHK_COMPERR (READER_ERR_BASE_START + 0x2)
+#define MI_EMPTY (READER_ERR_BASE_START + 0x3)
+#define MI_AUTHERR (READER_ERR_BASE_START + 0x4)
+#define MI_PARITYERR (READER_ERR_BASE_START + 0x5)
+#define MI_CODEERR (READER_ERR_BASE_START + 0x6)
+
+#define MI_SERNRERR (READER_ERR_BASE_START + 0x8)
+#define MI_KEYERR (READER_ERR_BASE_START + 0x9)
+#define MI_NOTAUTHERR (READER_ERR_BASE_START + 0x10)
+#define MI_BITCOUNTERR (READER_ERR_BASE_START + 0x11)
+#define MI_BYTECOUNTERR (READER_ERR_BASE_START + 0x12)
+#define MI_IDLE (READER_ERR_BASE_START + 0x13)
+#define MI_TRANSERR (READER_ERR_BASE_START + 0x14)
+#define MI_WRITEERR (READER_ERR_BASE_START + 0x15)
+#define MI_INCRERR (READER_ERR_BASE_START + 0x16)
+#define MI_DECRERR (READER_ERR_BASE_START + 0x17)
+#define MI_READERR (READER_ERR_BASE_START + 0x18)
+#define MI_OVFLERR (READER_ERR_BASE_START + 0x19)
+#define MI_POLLING (READER_ERR_BASE_START + 0x20)
+#define MI_FRAMINGERR (READER_ERR_BASE_START + 0x21)
+#define MI_ACCESSERR (READER_ERR_BASE_START + 0x22)
+#define MI_UNKNOWN_COMMAND (READER_ERR_BASE_START + 0x23)
+#define MI_COLLERR (READER_ERR_BASE_START + 0x24)
+#define MI_RESETERR (READER_ERR_BASE_START + 0x25)
+#define MI_INITERR (READER_ERR_BASE_START + 0x25)
+#define MI_INTERFACEERR (READER_ERR_BASE_START + 0x26)
+#define MI_ACCESSTIMEOUT (READER_ERR_BASE_START + 0x27)
+#define MI_NOBITWISEANTICOLL (READER_ERR_BASE_START + 0x28)
+#define MI_QUIT (READER_ERR_BASE_START + 0x30)
+#define MI_CODINGERR (READER_ERR_BASE_START + 0x31)
+#define MI_SENDBYTENR (READER_ERR_BASE_START + 0x51)
+#define MI_CASCLEVEX (READER_ERR_BASE_START + 0x52)
+#define MI_SENDBUF_OVERFLOW (READER_ERR_BASE_START + 0x53)
+#define MI_BAUDRATE_NOT_SUPPORTED (READER_ERR_BASE_START + 0x54)
+#define MI_SAME_BAUDRATE_REQUIRED (READER_ERR_BASE_START + 0x55)
+
+#define MI_WRONG_PARAMETER_VALUE (READER_ERR_BASE_START + 0x60)
+
+// ICODE1 Error Codes
+#define I1_WRONGPARAM (READER_ERR_BASE_START + 0x61)
+#define I1_NYIMPLEMENTED (READER_ERR_BASE_START + 0x62)
+#define I1_TSREADY (READER_ERR_BASE_START + 0x63)
+
+#define I1_TIMEOUT (READER_ERR_BASE_START + 0x70)
+#define I1_NOWRITE (READER_ERR_BASE_START + 0x71)
+#define I1_NOHALT (READER_ERR_BASE_START + 0x72)
+#define I1_MISS_ANTICOLL (READER_ERR_BASE_START + 0x73)
+
+#define I1_COMM_ABORT (READER_ERR_BASE_START + 0x82)
+
+#define MI_BREAK (READER_ERR_BASE_START + 0x99)
+#define MI_NY_IMPLEMENTED (READER_ERR_BASE_START + 0x100)
+#define MI_NO_MFRC (READER_ERR_BASE_START + 0x101)
+#define MI_MFRC_NOTAUTH (READER_ERR_BASE_START + 0x102)
+#define MI_WRONG_DES_MODE (READER_ERR_BASE_START + 0x103)
+#define MI_HOST_AUTH_FAILED (READER_ERR_BASE_START + 0x104)
+
+#define MI_WRONG_LOAD_MODE (READER_ERR_BASE_START + 0x106)
+#define MI_WRONG_DESKEY (READER_ERR_BASE_START + 0x107)
+#define MI_MKLOAD_FAILED (READER_ERR_BASE_START + 0x108)
+#define MI_FIFOERR (READER_ERR_BASE_START + 0x109)
+#define MI_WRONG_ADDR (READER_ERR_BASE_START + 0x110)
+#define MI_DESKEYLOAD_FAILED (READER_ERR_BASE_START + 0x111)
+#define MI_RECBUF_OVERFLOW (READER_ERR_BASE_START + 0x112)
+#define MI_WRONG_SEL_CNT (READER_ERR_BASE_START + 0x114)
+
+#define MI_WRONG_TEST_MODE (READER_ERR_BASE_START + 0x117)
+#define MI_TEST_FAILED (READER_ERR_BASE_START + 0x118)
+#define MI_TOC_ERROR (READER_ERR_BASE_START + 0x119)
+#define MI_COMM_ABORT (READER_ERR_BASE_START + 0x120)
+#define MI_INVALID_BASE (READER_ERR_BASE_START + 0x121)
+#define MI_MFRC_RESET (READER_ERR_BASE_START + 0x122)
+#define MI_WRONG_VALUE (READER_ERR_BASE_START + 0x123)
+#define MI_VALERR (READER_ERR_BASE_START + 0x124)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MFERRNO_H
diff --git a/icc_apdu_lib/MfRc500.h b/icc_apdu_lib/MfRc500.h
new file mode 100644
index 0000000..46ac3a8
--- /dev/null
+++ b/icc_apdu_lib/MfRc500.h
@@ -0,0 +1,182 @@
+/*
+* Copyright (c), Philips Semiconductors Gratkorn / Austria
+*
+* (C)PHILIPS Electronics N.V.2000
+* All rights are reserved. Reproduction in whole or in part is
+* prohibited without the written consent of the copyright owner.
+* Philips reserves the right to make changes without notice at any time.
+* Philips makes no warranty, expressed, implied or statutory, including but
+* not limited to any implied warranty of merchantability or fitness for any
+*particular purpose, or that the use will not infringe any third party patent,
+* copyright or trademark. Philips must not be liable for any loss or damage
+* arising from its use.
+*/
+
+#ifndef MFRC500_H
+#define MFRC500_H
+
+// PCD Configuration
+unsigned short Mf500PcdConfig(void);
+
+// Active Antenna Slave Configuration of the MF RC500.
+unsigned short Mf500ActiveAntennaSlaveConfig(void);
+
+// Active Antenna Master Configuration of the MF RC 500
+unsigned short Mf500ActiveAntennaMasterConfig(void);
+
+// Set default attributes for the baudrate divider
+unsigned short Mf500PcdSetDefaultAttrib(void);
+
+// Set attributes for the baudrate divider
+unsigned short Mf500PcdSetAttrib(unsigned char DSI,
+ unsigned char DRI);
+
+// Get transmission properties of the PCD
+unsigned short Mf500PcdGetAttrib(unsigned char *FSCImax,
+ unsigned char *FSDImax,
+ unsigned char *DSsupp,
+ unsigned char *DRsupp,
+ unsigned char *DREQDS);
+
+// PICC Request command
+unsigned short Mf500PiccRequest(unsigned char req_code,
+ unsigned char *atq);
+
+// PICC Request command for ISO 14443 A-4 Command set
+unsigned short Mf500PiccCommonRequest(unsigned char req_code,
+ unsigned char *atq);
+
+// PICC Anticollision Command
+unsigned short Mf500PiccAnticoll (unsigned char bcnt,
+ unsigned char *snr);
+
+// PICC Cascaded Anticollision Command
+unsigned short Mf500PiccCascAnticoll (unsigned char select_code,
+ unsigned char bcnt,
+ unsigned char *snr);
+
+// PICC Select Command
+unsigned short Mf500PiccSelect(unsigned char *snr,
+ unsigned char *sak);
+
+// PICC Select Command
+unsigned short Mf500PiccCascSelect(unsigned char select_code,
+ unsigned char *snr,
+ unsigned char *sak);
+
+// Activation of a PICC in IDLE mode
+unsigned short Mf500PiccActivateIdle(unsigned char br,
+ unsigned char *atq,
+ unsigned char *sak,
+ unsigned char *uid,
+ unsigned char *uid_len);
+
+// Activation of all PICC's in the RF field
+unsigned short Mf500PiccActivateWakeup(unsigned char br,
+ unsigned char *atq,
+ unsigned char *sak,
+ unsigned char *uid,
+ unsigned char uid_len);
+
+// MIFARE® Authentication
+unsigned short Mf500PiccAuth(unsigned char auth_mode,
+ unsigned char key_sector,
+ unsigned char block);
+
+// MIFARE ® Authentication with keys stored in the MF RC 500's EEPROM.
+unsigned short Mf500PiccAuthE2( unsigned char auth_mode,
+ unsigned char *snr,
+ unsigned char key_sector,
+ unsigned char block);
+
+// Authentication Key Coding
+unsigned short Mf500HostCodeKey(unsigned char *uncoded,
+ unsigned char *coded);
+
+// Key Loading into the MF RC500's EEPROM.
+unsigned short Mf500PcdLoadKeyE2(unsigned char key_type,
+ unsigned char sector,
+ unsigned char *uncoded_keys);
+
+// Authentication with direct key loading form the microcontroller
+unsigned short Mf500PiccAuthKey(unsigned char auth_mode,
+ unsigned char *snr,
+ unsigned char *keys,
+ unsigned char sector);
+
+// PICC Read Block
+unsigned short Mf500PiccRead(unsigned char addr,
+ unsigned char* data);
+
+// PICC Read Block of variable length
+unsigned short Mf500PiccCommonRead(unsigned char cmd,
+ unsigned char addr,
+ unsigned char datalen,
+ unsigned char *data);
+
+// PICC Write Block
+unsigned short Mf500PiccWrite(unsigned char addr,
+ unsigned char *data);
+
+// PICC Write 4 Byte Block
+unsigned short Mf500PiccWrite4(unsigned char addr,
+ unsigned char *data);
+
+// PICC Write Block of variable length
+unsigned short Mf500PiccCommonWrite(unsigned char cmd,
+ unsigned char addr,
+ unsigned char datalen,
+ unsigned char *data);
+
+// PICC Value Block Operation
+unsigned short Mf500PiccValue(unsigned char dd_mode,
+ unsigned char addr,
+ unsigned char *value,
+ unsigned char trans_addr);
+
+// PICC Value Block Operation for Cards with automatic transfer
+unsigned short Mf500PiccValueDebit(unsigned char dd_mode,
+ unsigned char addr,
+ unsigned char *value);
+
+// Exchange Data Blocks PCD --> PICC --> PCD
+unsigned short Mf500PiccExchangeBlock(unsigned char *send_data,
+ unsigned short send_bytelen,
+ unsigned char *rec_data,
+ unsigned short *rec_bytelen,
+ unsigned char append_crc,
+ unsigned long timeout );
+
+// PICC Halt
+unsigned short Mf500PiccHalt(void);
+
+// Reset the reader ic
+unsigned short PcdReset(void);
+
+// Exchange Data Stream PCD --> PICC --> PCD
+unsigned short ExchangeByteStream(unsigned char Cmd,
+ unsigned char *send_data,
+ unsigned short send_bytelen,
+ unsigned char *rec_data,
+ unsigned short *rec_bytelen);
+
+// Set RF communication timeout
+unsigned short PcdSetTmo(unsigned long numberOfEtus);
+
+// Read Serial Number from Reader IC
+unsigned short PcdGetSnr(unsigned char *snr);
+
+// Read EEPROM Memory Block
+unsigned short PcdReadE2(unsigned short startaddr,
+ unsigned char length,
+ unsigned char* data);
+
+// Writes data to the reader IC's EEPROM blocks.
+unsigned short PcdWriteE2( unsigned short startaddr,
+ unsigned char length,
+ unsigned char* data);
+
+// Turns ON/OFF RF field
+unsigned short PcdRfReset(unsigned short ms);
+
+#endif
diff --git a/icc_apdu_lib/MfRc500uC.c b/icc_apdu_lib/MfRc500uC.c
new file mode 100644
index 0000000..d571591
--- /dev/null
+++ b/icc_apdu_lib/MfRc500uC.c
@@ -0,0 +1,1821 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c), Philips Semiconductors Gratkorn
+//
+// (C)PHILIPS Electronics N.V.2000
+// All rights are reserved.
+// Philips reserves the right to make changes without notice at any time.
+// Philips makes no warranty, expressed, implied or statutory, including but
+// not limited to any implied warranty of merchantibility or fitness for any
+//particular purpose, or that the use will not infringe any third party patent,
+// copyright or trademark. Philips must not be liable for any loss or damage
+// arising from its use.
+///////////////////////////////////////////////////////////////////////////////
+#include <string.h>
+#include <stdio.h>
+
+#include "RICReg.h"
+#include "MfRc500.h"
+#include "PICCCmdConst.h"
+#include "MfErrNo.h"
+
+// storage buffer for receive and transmit routines
+//{
+#define MEMORY_BUFFER_SIZE 256
+unsigned char MemPool[MEMORY_BUFFER_SIZE];
+
+unsigned char *MSndBuffer = MemPool; // pointer to the transmit buffer
+unsigned char *MRcvBuffer = MemPool; // pointer to the receive buffer
+//}
+
+extern void HW_SPI_RF_CfgInit(void);
+extern void MFRC500_RstSet(void);
+extern void MFRC500_RstClr(void);
+
+void CalulateCRC(unsigned char *pIndata,unsigned char len,unsigned char *pOutData);
+
+#define READER_RESET MFRC500_RstClr()
+#define READER_CLEAR_RESET MFRC500_RstSet()
+
+// Write one byte to the reader IC address space
+/*!
+* -o address (IN) reader ic register address
+* -o value (IN) 8 bit value
+* return: none
+*
+* Function for writting one char to the reader module
+*
+* The reader module is connected to a 16 bit demultiplexed bus,
+* therefore the address pin of the reader module is mapped as
+* follows: \n
+* uC Reader \n
+* A1 A0 \n
+* A2 A1 \n
+* A3 A2 \n
+*
+* In order to get the correct address, the original address need to
+* be multiplied by 2.
+*/
+
+extern void WriteRawRC(unsigned char value, unsigned char addr);
+
+//! Read one byte from the reader IC address space
+/*!
+* -o address (IN) reader ic register address
+* -o value (IN) 8 bit value
+* return: none
+*
+* Function for reading one char from the reader module
+*
+* The reader module is connected to a 16 bit demultiplexed bus,
+* therefore the address pin of the reader module is mapped as
+* follows: \n
+* uC Reader \n
+* A1 A0 \n
+* A2 A1 \n
+* A3 A2 \n
+*
+* In order to get the correct address, the original address need to
+* be multiplied by 2.
+*/
+extern unsigned char ReadRawRC(unsigned char addr);
+
+
+//! Write one byte to the reader IC address space
+/*!
+* -o address (IN) reader ic register address
+* -o value (IN) 8 bit value
+* return: none
+*
+* This function determines the necessary page address of the
+* reader module and writes the page number to the page
+* register and the value to the specified address.
+*/
+void WriteRC(unsigned char Address, unsigned char value);
+
+//! Write one byte to the reader IC address space
+/*
+* -o address (IN) reader IC register address
+* return: value 8 bit data, read from the reader ic address space
+*
+* This function determines the necessary page address of the
+* reader module and writes the page number to the page
+* register and reads the value from the specified address.
+*/
+unsigned char ReadRC(unsigned char Address);
+
+
+///////////////////////////////////////////////////////////////////////////////
+// G E N E R I C W R I T E
+///////////////////////////////////////////////////////////////////////////////
+void WriteRC(unsigned char Address, unsigned char value)
+{
+ WriteRawRC(value, Address); // write value at the specified
+ // address
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// G E N E R I C R E A D
+///////////////////////////////////////////////////////////////////////////////
+unsigned char ReadRC(unsigned char Address)
+{
+ return ReadRawRC(Address); // read value at the specified
+}
+
+/// Set Reader IC Register Bit
+/*!
+* -o reg (IN)
+* register address
+* -o mask (IN)
+* Bit mask to set
+* return: none
+*
+* This function performs a read - modify - write sequence
+* on the specified register. All bits with a 1 in the mask
+* are set - all other bits keep their original value.
+*/
+void SetBitMask(unsigned char reg,unsigned char mask);
+
+/// Clear Reader IC Register Bit
+/*!
+* -o reg (IN)
+* register address
+* -o mask (IN)
+* Bit mask to clear
+* return: none
+*
+* This function performs a read - modify - write sequence
+* on the specified register. All bits with a 1 in the mask
+* are cleared - all other bits keep their original value.
+*/
+void ClearBitMask(unsigned char reg,unsigned char mask);
+
+/// Flush remaining data from the FIFO
+/*!
+* -o none
+* return: none
+*
+* This function erases all remaining data in the MF RC 500's FIFO .
+* Before writing new data or starting a new command, all remaining data
+* from former commands should be deleted.
+*/
+void FlushFIFO(void);
+
+/// Sleep several milliseconds
+/*
+The implementation of this function depends heavily
+on the microcontroller in use. The measurement need not to be
+very accurate. Only make sure, that the periode is not shorter, than
+the required one.
+*/
+void SleepMs(unsigned short ms)
+{
+ int i;
+ for(i=0;i<4200*ms;i++);
+}
+
+/// Sleep several microseconds
+/*
+The implementation of this function depends heavily
+on the microcontroller in use. The measurement need not to be
+very accurate. Only make sure, that the periode is not shorter, than
+the required one.
+*/
+void SleepUs(unsigned short us)
+{
+ int i;
+ for( i = 0; i < 20 * us; i++ );
+}
+
+///////////////////////////////////////////////////////////////////////
+// S e t T i m e o u t L E N G T H
+///////////////////////////////////////////////////////////////////////
+unsigned short PcdSetTmo(unsigned long tmoLength)
+{
+ WriteRC(TModeReg,0x8D);
+ WriteRC(TPrescalerReg,0x3E);
+ WriteRC(TReloadRegH,0x01);
+ WriteRC(TReloadRegL,0x64);
+ return MI_OK;
+}
+
+//////////////////////////////////////////////////////////////////////
+// R E S E T
+///////////////////////////////////////////////////////////////////////
+unsigned short PcdRfReset(unsigned short ms)
+{
+ char status = MI_OK;
+
+ ClearBitMask(TxControlReg, 0x03); // Tx2RF-En, Tx1RF-En disablen
+ if (ms > 0)
+ {
+ SleepMs(ms); // Delay for 1 ms
+ SetBitMask(TxControlReg, 0x03); // Tx2RF-En, Tx1RF-En enable
+ }
+ return status;
+}
+
+//////////////////////////////////////////////////////////////////////
+// S E T A B I T M A S K
+///////////////////////////////////////////////////////////////////////
+void SetBitMask(unsigned char reg,unsigned char mask) //
+{
+ char tmp = 0x0;
+
+ tmp = ReadRC(reg);
+ WriteRC(reg,tmp | mask); // set bit mask
+}
+
+//////////////////////////////////////////////////////////////////////
+// C L E A R A B I T M A S K
+///////////////////////////////////////////////////////////////////////
+void ClearBitMask(unsigned char reg,unsigned char mask) //
+{
+ char tmp = 0x0;
+
+ tmp = ReadRC(reg);
+ WriteRC(reg,tmp & (~mask)); // clear bit mask
+}
+
+///////////////////////////////////////////////////////////////////////
+// F L U S H F I F O
+///////////////////////////////////////////////////////////////////////
+void FlushFIFO(void)
+{
+ SetBitMask(FIFOLevelReg, 0x80);
+}
+
+void CalulateCRC(unsigned char *pIndata,unsigned char len,unsigned char *pOutData)
+{
+ unsigned char i,n;
+ ClearBitMask(DivIrqReg,0x04);
+ WriteRC(CommandReg,PCD_IDLE);
+ SetBitMask(FIFOLevelReg,0x80);
+ for (i=0; i<len; i++)
+ { WriteRC(FIFODataReg, *(pIndata+i)); }
+ WriteRC(CommandReg, PCD_CALCCRC);
+ i = 0xFF;
+ do
+ {
+ n = ReadRC(DivIrqReg);
+ i--;
+ }
+ while ((i!=0) && !(n&0x04));
+ pOutData[0] = ReadRC(CRCResultRegL);
+ pOutData[1] = ReadRC(CRCResultRegM);
+}
+
+
+
+//M1¿¨²Ù×÷½Ó¿Ú
+#define M1_BIT_AUTH 0x08 // bit3 ÃÜÂëУÑé¿ØÖÆÎ» - 0 - ²»Ð£ÑéÃÜÂë 1 - ҪУÑéÃÜÂë
+#define M1_BIT_RQST 0x04 // bit2 Ѱ¿¨¿ØÖÆÎ» - 0 - Ѱ¿¨ 1 - ²»Ñ°¿¨
+#define M1_BIT_AUTHTYPE 0x03 // bit1 bit0ÃÜÂë¿ØÖÆÎ» - AÃÜÂë»òBÃÜÂë( 0 - A 1 - B)
+
+#define MI_ERR 0x02
+
+#define M1_OK 0x00
+#define M1_ERR_REQUEST 0x01
+#define M1_ERR_ANTI 0x02
+#define M1_ERR_SELECT 0x03
+#define M1_ERR_READ 0x05
+#define M1_ERR_WRITE 0x06
+#define M1_ERR_AUTH 0x07
+#define M1_ERR_TIMEOUT 0x11
+#define M1_ERR_COMM 0x12
+#define M1_ERR_BITS 0x13
+#define M1_ERR_ACK 0x14
+#define M1_ERR_AUTH1 0x15
+#define M1_ERR_AUTH2 0x16
+#define M1_ERR_SNRCHK 0x17
+#define M1_ERR_RCVBITS 0x18
+#define M1_ERR_BADCOMMAND 0x19
+#define M1_ERR_PCDFAIL 0x30
+
+/////////////////////////////////////////////////////////////////////
+//¹¦ ÄÜ£ºÍ¨¹ýRC522ºÍISO14443¿¨Í¨Ñ¶
+//²ÎÊý˵Ã÷£ºCommand[IN]:RC522ÃüÁî×Ö
+// pInData[IN]:ͨ¹ýRC522·¢Ë͵½¿¨Æ¬µÄÊý¾Ý
+// InLenByte[IN]:·¢ËÍÊý¾ÝµÄ×Ö½Ú³¤¶È
+// pOutData[OUT]:½ÓÊÕµ½µÄ¿¨Æ¬·µ»ØÊý¾Ý
+// *pOutLenBit[OUT]:·µ»ØÊý¾ÝµÄ볤¶È
+/////////////////////////////////////////////////////////////////////
+unsigned short PcdComMF522(unsigned char Command,
+ unsigned char *pInData,
+ unsigned char InLenByte,
+ unsigned char *pOutData,
+ unsigned int *pOutLenBit)
+{
+ unsigned short status = MI_ERR;
+ unsigned char irqEn = 0x00;
+ unsigned char waitFor = 0x00;
+ unsigned char lastBits;
+ unsigned char n;
+ unsigned int i;
+
+ switch (Command)
+ {
+ case PCD_AUTHENT:
+ irqEn = 0x12;
+ waitFor = 0x10;
+ break;
+ case PCD_TRANSCEIVE:
+ irqEn = 0x77;
+ waitFor = 0x30;
+ break;
+ default:
+ break;
+ }
+
+ WriteRC(ComIEnReg,irqEn|0x80);
+ ClearBitMask(ComIrqReg,0x80);
+ WriteRC(CommandReg,PCD_IDLE);
+ SetBitMask(FIFOLevelReg,0x80);
+
+ for (i=0; i<InLenByte; i++)
+ { WriteRC(FIFODataReg, pInData[i]); }
+ WriteRC(CommandReg, Command);
+
+
+ if (Command == PCD_TRANSCEIVE)
+ { SetBitMask(BitFramingReg,0x80); }
+
+ i = 500;//¸ù¾ÝʱÖÓÆµÂʵ÷Õû£¬²Ù×÷M1¿¨×î´óµÈ´ýʱ¼ä25ms
+ do
+ {
+ n = ReadRC(ComIrqReg);
+ i--;
+ }
+ while ((i!=0) && !(n&0x01) && !(n&waitFor));
+ ClearBitMask(BitFramingReg,0x80);
+
+ *pOutLenBit = 0;
+ if (i!=0)
+ {
+ if(!(ReadRC(ErrorReg)&0x1B))
+ {
+ status = MI_OK;
+ if (n & irqEn & 0x01)
+ { status = MI_NOTAGERR; }
+ if (Command == PCD_TRANSCEIVE)
+ {
+ n = ReadRC(FIFOLevelReg);
+ lastBits = ReadRC(ControlReg) & 0x07;
+ if (lastBits)
+ { *pOutLenBit = (n-1)*8 + lastBits; }
+ else
+ { *pOutLenBit = n*8; }
+ if (n == 0)
+ { n = 1; }
+ if (n > 18) //m1¿¨×î´ó18×Ö½Ú
+ { n = 18; }
+ for (i=0; i<n; i++)
+ { pOutData[i] = ReadRC(FIFODataReg); }
+ }
+ }
+ else
+ { status = MI_ERR; }
+
+ }
+
+
+ SetBitMask(ControlReg,0x80); // stop timer now
+ WriteRC(CommandReg,PCD_IDLE);
+ return status;
+}
+
+/////////////////////////////////////////////////////////////////////
+//¹¦ ÄÜ£ºÑ°¿¨
+//²ÎÊý˵Ã÷: req_code[IN]:Ѱ¿¨·½Ê½
+// 0x52 = Ѱ¸ÐÓ¦ÇøÄÚËùÓзûºÏ14443A±ê×¼µÄ¿¨
+// 0x26 = Ѱδ½øÈëÐÝÃß״̬µÄ¿¨
+// pTagType[OUT]£º¿¨Æ¬ÀàÐÍ´úÂë
+// 0x4400 = Mifare_UltraLight
+// 0x0400 = Mifare_One(S50)
+// 0x0200 = Mifare_One(S70)
+// 0x0800 = Mifare_Pro(X)
+// 0x4403 = Mifare_DESFire
+//·µ »Ø: ³É¹¦·µ»ØMI_OK
+/////////////////////////////////////////////////////////////////////
+unsigned short PcdRequest(unsigned char req_code,unsigned char *pTagType)
+{
+ unsigned short status;
+ unsigned int unLen;
+
+ ClearBitMask(Status2Reg,0x08);
+ WriteRC(BitFramingReg,0x07);
+ SetBitMask(TxControlReg,0x03);
+
+ MSndBuffer[0] = req_code;
+
+ status = PcdComMF522(PCD_TRANSCEIVE, MSndBuffer, 1, MRcvBuffer, &unLen);
+
+ if ((status == MI_OK) && (unLen == 0x10))
+ {
+ if(pTagType)
+ {
+ *pTagType = MRcvBuffer[0];
+ *(pTagType+1) = MRcvBuffer[1];
+ }
+ }
+ else
+ { status = MI_ERR; }
+
+ return status;
+}
+
+/////////////////////////////////////////////////////////////////////
+//¹¦ ÄÜ£º·À³åײ
+//²ÎÊý˵Ã÷: pSnr[OUT]:¿¨Æ¬ÐòÁкţ¬4×Ö½Ú
+//·µ »Ø: ³É¹¦·µ»ØMI_OK
+/////////////////////////////////////////////////////////////////////
+unsigned short PcdAnticoll(unsigned char *pSnr)
+{
+ unsigned short status;
+ unsigned char i,snr_check=0;
+ unsigned int unLen;
+
+ ClearBitMask(Status2Reg,0x08);
+ WriteRC(BitFramingReg,0x00);
+ ClearBitMask(CollReg,0x80);
+
+ MSndBuffer[0] = PICC_ANTICOLL1;
+ MSndBuffer[1] = 0x20;
+
+ status = PcdComMF522(PCD_TRANSCEIVE, MSndBuffer, 2, MRcvBuffer, &unLen);
+
+ if (status == MI_OK)
+ {
+ for (i=0; i<4; i++)
+ {
+ *(pSnr+i) = MRcvBuffer[i];
+ snr_check ^= MRcvBuffer[i];
+ }
+ if (snr_check != MRcvBuffer[i])
+ { status = MI_ERR; }
+ }
+
+ SetBitMask(CollReg,0x80);
+ return status;
+}
+
+/////////////////////////////////////////////////////////////////////
+//¹¦ ÄÜ£ºÑ¡¶¨¿¨Æ¬
+//²ÎÊý˵Ã÷: pSnr[IN]:¿¨Æ¬ÐòÁкţ¬4×Ö½Ú
+//·µ »Ø: ³É¹¦·µ»ØMI_OK
+/////////////////////////////////////////////////////////////////////
+unsigned short PcdSelect(unsigned char *pSnr, unsigned char* sak)
+{
+ unsigned short status;
+ unsigned char i;
+ unsigned int unLen;
+
+ MSndBuffer[0] = PICC_ANTICOLL1;
+ MSndBuffer[1] = 0x70;
+ MSndBuffer[6] = 0;
+ for (i=0; i<4; i++)
+ {
+ MSndBuffer[i+2] = *(pSnr+i);
+ MSndBuffer[6] ^= *(pSnr+i);
+ }
+ CalulateCRC(MSndBuffer, 7,&MSndBuffer[7]);
+
+ ClearBitMask(Status2Reg,0x08);
+
+ status = PcdComMF522(PCD_TRANSCEIVE, MSndBuffer, 9, MRcvBuffer, &unLen);
+
+ if ((status == MI_OK) && (unLen == 0x18))
+ {
+ *sak = MRcvBuffer[0];
+ status = MI_OK;
+ }
+ else
+ { status = MI_ERR; }
+
+ return status;
+}
+
+/////////////////////////////////////////////////////////////////////
+//¹¦ ÄÜ£ºÑéÖ¤¿¨Æ¬ÃÜÂë
+//²ÎÊý˵Ã÷: auth_mode[IN]: ÃÜÂëÑé֤ģʽ
+// 0x60 = ÑéÖ¤AÃÜÔ¿
+// 0x61 = ÑéÖ¤BÃÜÔ¿
+// addr[IN]£º¿éµØÖ·
+// pKey[IN]£ºÃÜÂë
+// pSnr[IN]£º¿¨Æ¬ÐòÁкţ¬4×Ö½Ú
+//·µ »Ø: ³É¹¦·µ»ØMI_OK
+/////////////////////////////////////////////////////////////////////
+unsigned short PcdAuthState(unsigned char auth_mode,unsigned char addr,unsigned char *pKey,unsigned char *pSnr)
+{
+ unsigned short status;
+ unsigned int unLen;
+ unsigned char i;
+
+ MSndBuffer[0] = auth_mode;
+ MSndBuffer[1] = addr;
+ for (i=0; i<6; i++)
+ { MSndBuffer[i+2] = *(pKey+i); }
+ for (i=0; i<6; i++)
+ { MSndBuffer[i+8] = *(pSnr+i); }
+
+ status = PcdComMF522(PCD_AUTHENT, MSndBuffer, 12, MRcvBuffer, &unLen);
+ if ((status != MI_OK) || (!(ReadRC(Status2Reg) & 0x08)))
+ { status = MI_ERR; }
+
+ return status;
+}
+
+/////////////////////////////////////////////////////////////////////
+//¹¦ ÄÜ£º¶ÁÈ¡M1¿¨Ò»¿éÊý¾Ý
+//²ÎÊý˵Ã÷: addr[IN]£º¿éµØÖ·
+// pData[OUT]£º¶Á³öµÄÊý¾Ý£¬16×Ö½Ú
+//·µ »Ø: ³É¹¦·µ»ØMI_OK
+/////////////////////////////////////////////////////////////////////
+unsigned short PcdRead(unsigned char addr,unsigned char *pData)
+{
+ unsigned short status;
+ unsigned int unLen;
+ unsigned char i;
+
+ MSndBuffer[0] = PICC_READ16;
+ MSndBuffer[1] = addr;
+ CalulateCRC(MSndBuffer, 2, &MSndBuffer[2]);
+
+ status = PcdComMF522(PCD_TRANSCEIVE, MSndBuffer, 4, MRcvBuffer, &unLen);
+ if ((status == MI_OK) && (unLen == 0x90))
+ {
+ for (i=0; i<16; i++)
+ { *(pData+i) = MRcvBuffer[i]; }
+ }
+ else
+ { status = MI_ERR; }
+
+ return status;
+}
+
+/////////////////////////////////////////////////////////////////////
+//¹¦ ÄÜ£ºÐ´Êý¾Ýµ½M1¿¨Ò»¿é
+//²ÎÊý˵Ã÷: addr[IN]£º¿éµØÖ·
+// pData[IN]£ºÐ´ÈëµÄÊý¾Ý£¬16×Ö½Ú
+//·µ »Ø: ³É¹¦·µ»ØMI_OK
+/////////////////////////////////////////////////////////////////////
+unsigned short PcdWrite(unsigned char addr,unsigned char *pData)
+{
+ unsigned short status;
+ unsigned int unLen;
+ unsigned char i;
+
+ MSndBuffer[0] = PICC_WRITE16;
+ MSndBuffer[1] = addr;
+ CalulateCRC(MSndBuffer, 2, &MSndBuffer[2]);
+
+ status = PcdComMF522(PCD_TRANSCEIVE, MSndBuffer, 4, MRcvBuffer, &unLen);
+
+ if ((status != MI_OK) || (unLen != 4) || ((MRcvBuffer[0] & 0x0F) != 0x0A))
+ { status = MI_ERR; }
+
+ if (status == MI_OK)
+ {
+ for (i=0; i<16; i++)
+ { MSndBuffer[i] = *(pData+i); }
+ CalulateCRC(MSndBuffer, 16, &MSndBuffer[16]);
+
+ status = PcdComMF522(PCD_TRANSCEIVE, MSndBuffer, 18, MRcvBuffer, &unLen);
+ if ((status != MI_OK) || (unLen != 4) || ((MRcvBuffer[0] & 0x0F) != 0x0A))
+ { status = MI_ERR; }
+ }
+
+ return status;
+}
+
+/////////////////////////////////////////////////////////////////////
+//¹¦ ÄÜ£ºÃüÁƬ½øÈëÐÝÃß״̬
+//·µ »Ø: ³É¹¦·µ»ØMI_OK
+/////////////////////////////////////////////////////////////////////
+unsigned short PcdHalt(void)
+{
+ unsigned short status;
+ unsigned int unLen;
+
+ MSndBuffer[0] = PICC_HALT;
+ MSndBuffer[1] = 0;
+ CalulateCRC(MSndBuffer, 2, &MSndBuffer[2]);
+
+ status = PcdComMF522(PCD_TRANSCEIVE, MSndBuffer, 4, MRcvBuffer, &unLen);
+
+ return status;
+}
+
+extern void HW_SleepUs( unsigned short us );
+
+/////////////////////////////////////////////////////////////////////
+//¹¦ ÄÜ£º¸´Î»RC522
+//·µ »Ø: ³É¹¦·µ»ØMI_OK
+/////////////////////////////////////////////////////////////////////
+unsigned short PcdReset(void)
+{
+ MFRC500_RstSet();
+ HW_SleepUs(500);
+ MFRC500_RstClr();
+ HW_SleepUs(200);
+ MFRC500_RstSet();
+ HW_SleepUs(500);
+
+ WriteRC(CommandReg,PCD_RESETPHASE);
+ WriteRC(ModeReg,0x3D); //ºÍMifare¿¨Í¨Ñ¶£¬CRC³õʼֵ0x6363
+ WriteRC(TReloadRegL,30);
+ WriteRC(TReloadRegH,0);
+ WriteRC(TModeReg,0x8D);
+ WriteRC(TPrescalerReg,0x3E);
+ WriteRC(TxAskReg,0x40);
+
+ return MI_OK;
+}
+
+unsigned char M1_BlkRead(unsigned char Mode,
+ unsigned char Block,
+ unsigned char *pSN,
+ unsigned char *pBuffer,
+ unsigned char *pKey)
+{
+ unsigned char auth_mode;
+ unsigned char buff[20];
+ unsigned char sak;
+
+ if(Mode&M1_BIT_AUTHTYPE&0x01)
+ {
+ auth_mode = PICC_AUTHENT1B;
+ }
+ else
+ {
+ auth_mode = PICC_AUTHENT1A;
+ }
+
+ if((Mode&M1_BIT_RQST) == 0)
+ {
+ if(PcdRequest(PICC_REQIDL, buff))
+ if(PcdRequest(PICC_REQIDL, buff))
+ return MI_ERR;
+
+ if(PcdAnticoll(pSN))
+ return M1_ERR_ANTI;
+
+ if(PcdSelect(pSN, &sak))
+ return M1_ERR_SELECT;
+
+ if(PcdAuthState(auth_mode, Block, pKey, pSN))
+ return M1_ERR_AUTH;
+ }
+ else
+ { if(Mode& M1_BIT_AUTH)
+ {
+ if(PcdAuthState(auth_mode, Block, pKey, pSN))
+ return M1_ERR_AUTH;
+ }
+ }
+
+ if(PcdRead(Block, buff)) //first read
+ return M1_ERR_READ;
+
+ memcpy(pBuffer, buff, 16);
+
+ if(PcdRead(Block, buff)) //second read
+ return M1_ERR_READ;
+ else
+ {
+ if( memcmp(pBuffer, buff, 16))
+ return M1_ERR_READ;
+ }
+
+ return MI_OK;
+}
+
+
+unsigned char M1_BlkWrite( unsigned char Mode,unsigned char Block, unsigned char *pSN, unsigned char * pBuffer, unsigned char *pKey )
+{
+ unsigned char auth_mode;
+ unsigned char buff[20];
+ unsigned char i;
+ unsigned char sak;
+
+ if(Mode&M1_BIT_AUTHTYPE&0x01)
+ {
+ auth_mode = PICC_AUTHENT1B;
+ }
+ else
+ {
+ auth_mode = PICC_AUTHENT1A;
+ }
+ //PcdReset();
+ if((Mode&M1_BIT_RQST) == 0)
+ {
+ if(PcdRequest(PICC_REQIDL, buff))
+ if(PcdRequest(PICC_REQIDL, buff))
+ return MI_ERR;
+
+ if(PcdAnticoll(pSN))
+ return M1_ERR_ANTI;
+
+ if(PcdSelect(pSN, &sak))
+ return M1_ERR_SELECT;
+
+ if(PcdAuthState(auth_mode, Block, pKey, pSN))
+ return M1_ERR_AUTH;
+ }
+ else
+ { if(Mode& M1_BIT_AUTH)
+ {
+ if(PcdAuthState(auth_mode, Block, pKey, pSN))
+ return M1_ERR_AUTH;
+ }
+ }
+
+ if(PcdWrite( Block, pBuffer))
+ return( M1_ERR_WRITE );
+
+ i = 0;
+ if( Block < 128)
+ {
+ if((Block % 4) == 3 )
+ i = 1;
+ }
+ else
+ {
+ if( (Block - 128) % 16 == 15 )
+ i = 1;
+ }
+ if( i == 0 )
+ {
+ if(PcdRead(Block, buff))
+ return M1_ERR_WRITE;
+ else
+ {
+ if(memcmp(pBuffer, buff, 16) != 0)
+ return M1_ERR_WRITE;
+ }
+ }
+
+ return MI_OK;
+}
+
+void M1_RCReset(void)
+{
+ PcdReset();
+}
+
+unsigned char GetM1SN(unsigned char *pSN)
+{
+ if(PcdAnticoll(pSN))
+ return M1_ERR_ANTI;
+
+ return MI_OK;
+}
+
+unsigned char M1_Request(unsigned char RequestMode, unsigned char* atq)
+{
+ if(PcdRequest(RequestMode, atq))
+ return M1_ERR_REQUEST;
+
+ return MI_OK;
+}
+
+unsigned char M1_Anti(unsigned char Bcnt, unsigned char *Snr)
+{
+ if(PcdAnticoll(Snr))
+ return M1_ERR_ANTI;
+
+ return MI_OK;
+}
+
+unsigned char M1_Select(unsigned char *Snr)
+{
+ unsigned char sak;
+
+ if(PcdSelect(Snr, &sak))
+ return M1_ERR_SELECT;
+
+ return MI_OK;
+}
+
+unsigned char M1_AuthBlk(unsigned char AuthMode, unsigned char *Snr, unsigned char Block, unsigned char *key )
+{
+ if(PcdAuthState(AuthMode, Block, key, Snr))
+ return M1_ERR_AUTH;
+
+ return MI_OK;
+}
+
+void M1_HardPwrDwn(void)
+{
+ READER_RESET;
+}
+
+unsigned char M1_PCDSn(unsigned char * pBuffer)
+{
+ return MI_OK;
+}
+
+void M1_RadioOff(void)
+{
+ PcdRfReset(0);
+}
+
+void M1_RadioOn(void)
+{
+ PcdRfReset(1);
+}
+
+unsigned char M1_Read(unsigned char Block, unsigned char* ReadBuffer)
+{
+ if(PcdRead(Block, ReadBuffer))
+ return M1_ERR_READ;
+
+ return MI_OK;
+}
+
+unsigned char M1_Write(unsigned char Block, unsigned char* WriteBuffer)
+{
+ if(PcdWrite(Block, WriteBuffer))
+ return M1_ERR_WRITE;
+
+ return MI_OK;
+}
+
+unsigned char M1_Halt(void)
+{
+ PcdHalt();
+
+ return MI_OK;
+}
+
+
+#if 0
+///////////////////////////////////////////////////////////////////////
+// M I F A R E P I C C A C T I V A T I O N S E Q E N C E
+///////////////////////////////////////////////////////////////////////
+unsigned short Mf500PiccActivateIdle(unsigned char br,
+ unsigned char *atq,
+ unsigned char *sak,
+ unsigned char *uid,
+ unsigned char *uid_len)
+{
+ unsigned short status = MI_OK;
+
+ status = M1_Request(PICC_REQIDL,atq);
+ if(status != MI_OK) return status;
+
+ status = M1_Anti(0, uid);
+ if(status != MI_OK) return status;
+ *uid_len = 4;
+
+ if(PcdSelect(uid, sak)) return status;
+
+ return MI_OK;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// P I C C E X C H A N G E B L O C K
+///////////////////////////////////////////////////////////////////////
+unsigned short Mf500PiccExchangeBlock(unsigned char *send_data,
+ unsigned short send_bytelen,
+ unsigned char *rec_data,
+ unsigned short *rec_bytelen,
+ unsigned char append_crc,
+ unsigned long timeout )
+{
+ char status = MI_OK;
+
+ send_bytelen -= 2;
+ if (append_crc)
+ {
+ CalulateCRC(send_data, send_bytelen, send_data+send_bytelen);
+ send_bytelen += 2;
+ }
+
+ PcdSetTmo(timeout);
+
+ status = ExchangeByteStream(PCD_TRANSCEIVE,
+ send_data,
+ send_bytelen,
+ rec_data,
+ rec_bytelen);
+ // even if an error occured, the data should be
+ // returned - for debugging reasons
+
+ if (append_crc)
+ {
+ *rec_bytelen += 2; // for two CRC bytes
+ rec_data[*rec_bytelen - 2] = 0x00;
+ rec_data[*rec_bytelen - 1] = 0x00;
+ }
+
+ return status;
+}
+
+///////////////////////////////////////////////////////////////////////
+// E X C H A N G E B Y T E S T R E A M
+///////////////////////////////////////////////////////////////////////
+unsigned short ExchangeByteStream(unsigned char Cmd,
+ unsigned char *send_data,
+ unsigned short send_bytelen,
+ unsigned char *rec_data,
+ unsigned short *rec_bytelen)
+{
+ unsigned short status = MI_OK;
+ unsigned int unLen;
+
+ FlushFIFO(); // empty FIFO
+
+ if (send_bytelen > 0)
+ {
+ memcpy(MSndBuffer, send_data, send_bytelen); // write n bytes
+
+ // write load command
+ status = PcdComMF522(PCD_TRANSCEIVE, MSndBuffer, send_bytelen, MRcvBuffer, &unLen);
+
+ // copy data to output, even in case of an error
+ *rec_bytelen = unLen/8;
+ if (*rec_bytelen)
+ {
+ memcpy(rec_data, MRcvBuffer, *rec_bytelen);
+ }
+ }
+ else
+ {
+ status = MI_WRONG_PARAMETER_VALUE;
+ }
+ return status;
+}
+#else
+// struct definition for a communication channel between function and ISR
+typedef struct
+ {
+ unsigned char cmd; //!< command code
+ unsigned char irqSource; //!< which interrupts have occured
+ unsigned short status; //!< communication status
+ unsigned short nBytesSent; //!< how many bytes already sent
+ unsigned short nBytesToSend; //!< how many bytes to send
+ unsigned short nBytesReceived;//!< how many bytes received
+ unsigned long nBitsReceived; //!< how many bits received
+ unsigned char collPos; /*!< at which position occured a
+ collision*/
+ unsigned char errFlags; //!< error flags
+ unsigned char saveErrorState;//!< accumulated error flags for
+ //!< multiple responses
+ unsigned char RxAlignWA; //!< workaround for RxAlign = 7
+ unsigned char DisableDF; //!< disable disturbance filter
+ } MfCmdInfo;
+
+// Convinience function for initialising the communication structure.
+#define ResetInfo(info) \
+ info.cmd = 0; \
+ info.status = MI_OK;\
+ info.irqSource = 0; \
+ info.nBytesSent = 0; \
+ info.nBytesToSend = 0; \
+ info.nBytesReceived = 0; \
+ info.nBitsReceived = 0; \
+ info.collPos = 0; \
+ info.errFlags = 0; \
+ info.saveErrorState = 0; \
+ info.RxAlignWA = 0; \
+ info.DisableDF = 0;
+
+// In order to exchange some values between the ISR and the calling function,
+// a struct is provided.
+volatile MfCmdInfo MInfo;
+
+// communication info stucture
+static volatile MfCmdInfo *MpIsrInfo = 0;
+// ISR send buffer
+static volatile unsigned char *MpIsrOut = 0;
+// ISR receive buffer
+static volatile unsigned char *MpIsrIn = 0;
+
+// storage of the last selected serial number including check byte.
+// For multi level serial numbers, only the first 4 bytes are stored.
+unsigned char MLastSelectedSnr[5];
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Interrupt Handler RIC
+///////////////////////////////////////////////////////////////////////////////
+//interrupt (READER_INT)
+void SingleResponseIsr(void)
+{
+ static unsigned char irqBits;
+ static unsigned char irqMask;
+ static unsigned char nbytes;
+ static unsigned char cnt;
+ unsigned int i = 0;
+
+ if (MpIsrInfo && MpIsrOut && MpIsrIn) // transfer pointers have to be set
+ // correctly
+ {
+ MpIsrInfo->errFlags = ReadRC(ErrorReg) & 0x0F; // save error state
+
+ //while( (ReadRC(Status1Reg) & 0x10)) // loop while IRQ pending
+ while(1)
+ {
+ if((i++) > 500) break;
+
+ irqMask = ReadRC(ComIEnReg); // read enabled interrupts
+ // read pending interrupts
+ irqBits = ReadRC(ComIrqReg) & irqMask;
+ MpIsrInfo->irqSource |= irqBits; // save pending interrupts
+
+ if(!(irqBits&0x7F)) break;
+
+ //************ LoAlertIRQ ******************
+ if (irqBits & 0x04) // LoAlert
+ {
+ nbytes = DEF_FIFO_LENGTH - ReadRC(FIFOLevelReg);
+ // less bytes to send, than space in FIFO
+ if ((MpIsrInfo->nBytesToSend - MpIsrInfo->nBytesSent) <= nbytes)
+ {
+ nbytes = MpIsrInfo->nBytesToSend - MpIsrInfo->nBytesSent;
+ irqMask &= ~0x04;
+ ClearBitMask(ComIEnReg, 0x04); // disable LoAlert IRQ
+ }
+ // write remaining data to the FIFO
+ for ( cnt = 0;cnt < nbytes;cnt++)
+ {
+ WriteRC(FIFODataReg, MpIsrOut[MpIsrInfo->nBytesSent]);
+ MpIsrInfo->nBytesSent++;
+ }
+ if ((ReadRC(Status2Reg) & 0x07) == 0x01)
+ {
+ SetBitMask(BitFramingReg, 0x80);
+ }
+ WriteRC(ComIrqReg, 0x04); // reset IRQ bit
+ }
+
+ //************* TxIRQ Handling **************
+ if (irqBits & 0x40) // TxIRQ
+ {
+ WriteRC(ComIrqReg, 0x40); // reset IRQ bit
+ SetBitMask(ComIEnReg, 0x08); // enable HiAlert Irq for
+ // response
+ if (MpIsrInfo->RxAlignWA) // if cmd is anticollision and 7 bits are known
+ { // switch off parity generation
+ SetBitMask(RFU1D, 0x10); // RxCRC and TxCRC disable, parity disable
+ ClearBitMask(TxModeReg, 0x80);
+ ClearBitMask(RxModeReg, 0x80);
+ }
+ }
+ //**************** RxIRQ Handling *******************************
+ if (irqBits & 0x20) // RxIRQ - possible End of response processing
+ {
+ // no error or collision during
+ if (MpIsrInfo->DisableDF || (MpIsrInfo->errFlags == 0x00))
+ {
+ WriteRC(CommandReg, 0x00); // cancel current command
+ irqBits |= 0x10; // set idle flag in order to signal the end of
+ // processing. For single reponse processing, this
+ // flag is already set.
+ }
+ else // error occured - flush data and continue receiving
+ {
+ MpIsrInfo->saveErrorState = MpIsrInfo->errFlags; // save error state
+ MpIsrInfo->errFlags = 0; // reset error flags for next receiption
+ WriteRC(FIFOLevelReg, 0x80);
+ MpIsrInfo->nBytesReceived = 0x00;
+ irqBits &= ~0x20; // clear interrupt request
+ WriteRC(ComIrqReg, 0x20);
+ }
+ }
+
+ //************* HiAlertIRQ or RxIRQ Handling ******************
+ if (irqBits & 0x38) // HiAlert, Idle or valid RxIRQ
+ {
+ // read some bytes ( length of FIFO queue)
+ // into the receive buffer
+ nbytes = ReadRC(FIFOLevelReg);
+ // read date from the FIFO and store them in the receive buffer
+ do
+ {
+ for ( cnt = 0; cnt < nbytes; cnt++)
+ {
+ // accept no more data, than reserved memory space
+ if (MpIsrInfo->nBytesReceived < MEMORY_BUFFER_SIZE)
+ {
+ MpIsrIn[MpIsrInfo->nBytesReceived] = ReadRC(FIFODataReg);
+ MpIsrInfo->nBytesReceived++;
+ }
+ else
+ {
+ MpIsrInfo->status = MI_RECBUF_OVERFLOW;
+ break;
+ }
+ }
+ // check for remaining bytes
+ nbytes = ReadRC(FIFOLevelReg);
+ }
+ while (MpIsrInfo->status == MI_OK && nbytes > 0);
+ WriteRC(ComIrqReg, 0x28 & irqBits);
+ // reset IRQ bit - idle irq will
+ // be deleted in a seperate section
+ }
+
+ //************* additional HiAlertIRQ Handling ***
+ if (irqBits & 0x08)
+ {
+ // if highAlertIRQ is pending and the receiver is still
+ // running, then the timeout counter should be stopped,
+ // otherwise a timeout could occure while receiving
+ // correct data
+ if ((ReadRC(Status2Reg) & 0x07) == 0x06)
+ {
+ cnt = ReadRC(ControlReg); // read control register
+ WriteRC(ControlReg, cnt|0x80); // stop reader IC timer
+ // write modified register
+ }
+ }
+
+ //************** additional IdleIRQ Handling ******
+ if (irqBits & 0x10) // Idle IRQ
+ {
+ ClearBitMask(ComIEnReg, 0x01);// disable Timer IRQ
+ WriteRC(ComIrqReg, 0x11); // disable Timer IRQ request
+ irqBits &= ~0x01; // clear Timer IRQ in local var
+ MpIsrInfo->irqSource &= ~0x01; // clear Timer IRQ in info var
+ // when idle received, then cancel
+ // timeout
+ MpIsrInfo->irqSource |= 0x10; // set idle-flag in case of valid rx-irq
+ // status should still be MI_OK
+ // no error - only used for wake up
+ }
+
+ //************* TimerIRQ Handling ***********
+ if (irqBits & 0x01) // timer IRQ
+ {
+ WriteRC(ComIrqReg, 0x01); // reset IRQ bit
+ // only if no other error occured
+ if (MpIsrInfo->status == MI_OK)
+ {
+ MpIsrInfo->status = MI_NOTAGERR; // timeout error
+ // otherwise ignore the interrupt
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////
+// W R I T E A P C D C O M M A N D
+///////////////////////////////////////////////////////////////////////
+unsigned short PcdSingleResponseCmd(unsigned char cmd,
+ volatile unsigned char* send,
+ volatile unsigned char* rcv,
+ volatile MfCmdInfo *info)
+{
+ unsigned short status = MI_OK;
+ unsigned char lastBits;
+ unsigned char validErrorFlags = 0x1F;
+ unsigned char irqEn = 0x00;
+ unsigned char waitFor = 0x00;
+ unsigned char waterLevelBackup;
+ unsigned int i = 0;
+
+ WriteRC(ComIEnReg, 0); // disable all interrupts
+ WriteRC(ComIrqReg, 0x80); // clear all interrupt requests
+
+ // please pay attention to the sequence of following commands
+ // at first empty the FIFO
+ // second wait for probably e2 programming in progress
+ // third cancel command
+ //
+ // ATTENTION: the guard timer must not expire earlier than 10 ms
+ FlushFIFO(); // flush FIFO buffer
+
+ WriteRC(CommandReg, PCD_IDLE);
+
+ // Set water level to the default value (see. 'PcdBasicRegisterConfiguration()')
+ waterLevelBackup = ReadRC(WaterLevelReg);
+ WriteRC(WaterLevelReg, 0x20);
+
+ // save info structures to module pointers
+ MpIsrInfo = info;
+ MpIsrOut = send;
+ MpIsrIn = rcv;
+
+ info->irqSource = 0x0; // reset interrupt flags
+
+ // depending on the command code, appropriate interrupts are enabled (irqEn)
+ // and the commit interrupt is choosen (waitFor).
+ switch(cmd)
+ {
+ case PCD_IDLE: // nothing else required
+ irqEn = 0x00;
+ waitFor = 0x00;
+ break;
+ case PCD_AUTHENT: //IdleIRq
+ irqEn = 0x12;
+ waitFor = 0x10;
+ break;
+ case PCD_TRANSCEIVE: // TxIrq, RxIrq, IdleIRq and LoAlert
+ info->nBitsReceived = -((ReadRC(BitFramingReg) >> 4)&0x07);
+ irqEn = 0x77;
+ waitFor = 0x30;
+ break;
+ default:
+ status = MI_UNKNOWN_COMMAND;
+ break;
+ }
+
+ if (status == MI_OK)
+ {
+ // Initialize uC Timer for global Timeout management
+ irqEn |= 0x01; // always enable timout irq
+ waitFor |= 0x01; // always wait for timeout
+
+ WriteRC(ComIEnReg, irqEn); //necessary interrupts are enabled // count up from 1
+ {
+ unsigned char nbytes;
+
+ if(MpIsrInfo->nBytesToSend>DEF_FIFO_LENGTH)
+ {
+ nbytes = DEF_FIFO_LENGTH;
+ }
+ else
+ {
+ nbytes = MpIsrInfo->nBytesToSend;
+ ClearBitMask(ComIEnReg, 0x04); // disable LoAlert IRQ
+ }
+ // write remaining data to the FIFO
+ for ( i = 0;i < nbytes;i++)
+ {
+ WriteRC(FIFODataReg, MpIsrOut[MpIsrInfo->nBytesSent]);
+ MpIsrInfo->nBytesSent++;
+ }
+ }
+
+ WriteRC(CommandReg, cmd); //start command
+ if(cmd == PCD_TRANSCEIVE)
+ SetBitMask(BitFramingReg, 0x80); //start send
+
+ // wait for commmand completion
+ // a command is completed, if the corresponding interrupt occurs
+ // or a timeout is signaled
+ while(1)
+ {
+ SingleResponseIsr();
+ if(waitFor&0x20)
+ {
+ if(MpIsrInfo->irqSource&0x20)
+ {
+ MpIsrInfo->irqSource &= 0x01;
+ if(MpIsrInfo->status == MI_NOTAGERR)
+ MpIsrInfo->status = MI_OK;
+ break;
+ }
+ }
+ else
+ {
+ if(MpIsrInfo->irqSource&0x10) break;
+ }
+
+ if(MpIsrInfo->irqSource&0x01) break;
+
+ if((i++) > 3000) break;
+ }
+
+ SetBitMask(ControlReg, 0x80); // stop timer now
+ WriteRC(ComIEnReg, 0); // disable all interrupts
+ WriteRC(ComIrqReg, 0x80); // clear all interrupt requests
+
+ WriteRC(CommandReg, PCD_IDLE); // reset command register
+
+ status = MpIsrInfo->status; // set status
+ if (MpIsrInfo->irqSource & 0x01) // if timeout expired - look at old error state
+ MpIsrInfo->errFlags |= MpIsrInfo->saveErrorState;
+ MpIsrInfo->errFlags &= validErrorFlags;
+ if (MpIsrInfo->errFlags) // error occured
+ {
+ if (MpIsrInfo->errFlags & 0x08) // collision detected
+ {
+ info->collPos = ReadRC(CollReg)&0x1F; // read collision position
+ status = MI_COLLERR;
+ }
+ else
+ {
+ if (MpIsrInfo->errFlags & 0x02) // parity error
+ {
+ status = MI_PARITYERR;
+ }
+ }
+ if (MpIsrInfo->errFlags & 0x01) // framing error
+ {
+ status = MI_FRAMINGERR;
+ }
+ else
+ if (MpIsrInfo->errFlags & 0x10) // FIFO overflow
+ {
+ FlushFIFO();
+ status = MI_OVFLERR;
+ }
+ else
+ if (MpIsrInfo->errFlags & 0x04) // CRC error
+ {
+ status = MI_CRCERR;
+ }
+ else
+ if (status == MI_OK)
+ status = MI_NY_IMPLEMENTED;
+ // key error occures always, because of
+ // missing crypto 1 keys loaded
+ }
+ // if the last command was TRANSCEIVE, the number of
+ // received bits must be calculated - even if an error occured
+ if (cmd == PCD_TRANSCEIVE || cmd == PCD_RECEIVE)
+ {
+ // number of bits in the last byte
+ lastBits = ReadRC(ControlReg) & 0x07;
+ if (lastBits)
+ info->nBitsReceived += (info->nBytesReceived-1) * 8 + lastBits;
+ else
+ info->nBitsReceived += info->nBytesReceived * 8;
+ }
+ }
+
+ MpIsrInfo = 0; // reset interface variables for ISR
+ MpIsrOut = 0;
+ MpIsrIn = 0;
+
+ // restore the previous value for the FIFO water level
+ WriteRC(WaterLevelReg, waterLevelBackup);
+
+ return status;
+}
+
+//////////////////////////////////////////////////////////////////////
+// S E T D E F A U L T C O M M A T T R I B S
+///////////////////////////////////////////////////////////////////////
+unsigned short Mf500PcdSetDefaultAttrib(void)
+{
+ WriteRC(TModeReg,0x8D);
+ WriteRC(TPrescalerReg,0x3E);
+ WriteRC(TReloadRegH,0x00);
+ WriteRC(TReloadRegL,0x64);
+ WriteRC(TxAskReg,0x40);
+ WriteRC(ModeReg,0x3D);
+ return MI_OK;
+}
+
+///////////////////////////////////////////////////////////////////////
+// M I F A R E A N T I C O L L I S I O N
+// for extended serial numbers
+///////////////////////////////////////////////////////////////////////
+unsigned short Mf500PiccCascAnticoll (unsigned char select_code,
+ unsigned char bcnt,
+ unsigned char *snr)
+{
+ unsigned short status = MI_OK;
+ char snr_in[4]; // copy of the input parameter snr
+ char nbytes = 0; // how many bytes received
+ char nbits = 0; // how many bits received
+ char complete = 0; // complete snr recived
+ short i = 0;
+ char byteOffset = 0;
+ unsigned char snr_crc; // check byte calculation
+ unsigned char snr_check;
+ unsigned char dummyShift1; // dummy byte for snr shift
+ unsigned char dummyShift2; // dummy byte for snr shift
+
+ //************* Initialisierung ******************************
+ if ((status = Mf500PcdSetDefaultAttrib()) == MI_OK)
+ {
+ PcdSetTmo(106);
+
+ memcpy(snr_in,snr,4);
+
+ ClearBitMask(Status2Reg, 0x08);
+ WriteRC(BitFramingReg, 0);
+ ClearBitMask(CollReg, 0x08);
+
+ //************** Anticollision Loop ***************************
+ complete=0;
+ while (!complete && (status == MI_OK) )
+ {
+ // if there is a communication problem on the RF interface, bcnt
+ // could be larger than 32 - folowing loops will be defective.
+ if (bcnt > 32)
+ {
+ status = MI_WRONG_PARAMETER_VALUE;
+ continue;
+ }
+ ResetInfo(MInfo);
+ MInfo.cmd = select_code; // pass command flag to ISR
+ MInfo.DisableDF = 1;
+ //WriteRC(RegChannelRedundancy,0x03); // RxCRC and TxCRC disable, parity enable
+ ClearBitMask(TxModeReg, 0x80);
+ ClearBitMask(RxModeReg, 0x80);
+ nbits = bcnt % 8; // remaining number of bits
+ if (nbits)
+ {
+ WriteRC(BitFramingReg, nbits << 4 | nbits); // TxLastBits/RxAlign auf nb_bi
+ nbytes = bcnt / 8 + 1;
+ // number of bytes known
+
+ // in order to solve an inconsistancy in the anticollision sequence
+ // (will be solved soon), the case of 7 bits has to be treated in a
+ // separate way
+ if (nbits == 7 )
+ {
+ MInfo.RxAlignWA = 1;
+ MInfo.nBitsReceived = 7; // set flag for 7 bit anticoll, which is evaluated
+ // in the ISRnBitsReceived
+ WriteRC(BitFramingReg, nbits); // reset RxAlign to zero
+ }
+ }
+ else
+ {
+ nbytes = bcnt / 8;
+ }
+
+ MSndBuffer[0] = select_code;
+ MSndBuffer[1] = 0x20 + ((bcnt/8) << 4) + nbits; //number of bytes send
+
+ for (i = 0; i < nbytes; i++) // Sende Buffer beschreiben
+ {
+ MSndBuffer[i + 2] = snr_in[i];
+ }
+ MInfo.nBytesToSend = 2 + nbytes;
+
+ status = PcdSingleResponseCmd(PCD_TRANSCEIVE,
+ MSndBuffer,
+ MRcvBuffer,
+ &MInfo);
+
+ // in order to solve an inconsistancy in the anticollision sequence
+ // (will be solved soon), the case of 7 bits has to be treated in a
+ // separate way
+ if (MInfo.RxAlignWA)
+ {
+ // reorder received bits
+ dummyShift1 = 0x00;
+ for (i = 0; i < MInfo.nBytesReceived; i++)
+ {
+ dummyShift2 = MRcvBuffer[i];
+ MRcvBuffer[i] = (dummyShift1 >> (i+1)) | (MRcvBuffer[i] << (7-i));
+ dummyShift1 = dummyShift2;
+ }
+ MInfo.nBitsReceived -= MInfo.nBytesReceived; // subtract received parity bits
+ // recalculation of collision position
+ if ( MInfo.collPos ) MInfo.collPos += 7 - (MInfo.collPos + 6) / 9;
+ }
+
+ if ( status == MI_OK || status == MI_COLLERR) // no other occured
+ {
+
+ byteOffset = 0;
+ if ( nbits != 0 ) // last byte was not complete
+ {
+ snr_in[nbytes - 1] = snr_in[nbytes - 1] | MRcvBuffer[0];
+ byteOffset = 1;
+ }
+ for ( i =0; i < (4 - nbytes); i++)
+ {
+ snr_in[nbytes + i] = MRcvBuffer[i + byteOffset];
+ }
+ // R e s p o n s e P r o c e s s i n g
+ if ( MInfo.nBitsReceived != (40 - bcnt) ) // not 5 bytes answered
+ {
+ status = MI_BITCOUNTERR;
+ }
+ else
+ {
+ if (status != MI_COLLERR ) // no error and no collision
+ {
+ // SerCh check
+ snr_crc = snr_in[0] ^ snr_in[1] ^ snr_in[2] ^ snr_in[3];
+ snr_check = MRcvBuffer[MInfo.nBytesReceived - 1];
+ if (snr_crc != snr_check)
+ {
+ status = MI_SERNRERR;
+ }
+ else
+ {
+ complete = 1;
+ }
+ }
+ else // collision occured
+ {
+ bcnt = bcnt + MInfo.collPos - nbits;
+ status = MI_OK;
+ }
+ }
+ }
+ }
+ }
+ // transfer snr_in to snr - even in case of an error - for
+ // debugging reasons
+ memcpy(snr,snr_in,4);
+
+ //----------------------Einstellungen aus Initialisierung ruecksetzen
+ SetBitMask(CollReg, 0x80);
+
+ return status;
+}
+
+///////////////////////////////////////////////////////////////////////
+// M I F A R E C O M M O N R E Q U E S T
+///////////////////////////////////////////////////////////////////////
+unsigned short Mf500PiccCommonRequest(unsigned char req_code,
+ unsigned char *atq)
+{
+ unsigned short status = MI_OK;
+
+ //************* initialize ******************************
+ if ((status = Mf500PcdSetDefaultAttrib()) == MI_OK)
+ {
+
+ PcdSetTmo(60);
+
+ ClearBitMask(TxModeReg, 0x80); // RxCRC and TxCRC disable, parity enable
+ ClearBitMask(RxModeReg, 0x80);
+ ClearBitMask(RFU1D, 0x10);
+
+ ClearBitMask(Status2Reg, 0x08); // disable crypto 1 unit
+ WriteRC(BitFramingReg, 0x07); // set TxLastBits to 7
+ SetBitMask(TxControlReg,0x03);
+
+ ResetInfo(MInfo);
+ MSndBuffer[0] = req_code;
+ MInfo.nBytesToSend = 1;
+ MInfo.DisableDF = 1;
+ status = PcdSingleResponseCmd(PCD_TRANSCEIVE,
+ MSndBuffer,
+ MRcvBuffer,
+ &MInfo);
+ if ((status == MI_OK) && (MInfo.nBitsReceived != 16)) // 2 bytes expected
+ {
+ status = MI_BITCOUNTERR;
+ }
+ if ((status == MI_COLLERR) && (MInfo.nBitsReceived == 16)) //
+ status = MI_OK; // all received tag-types are combined to the 16 bit
+
+ // in any case, copy received data to output - for debugging reasons
+ if (MInfo.nBytesReceived >= 2)
+ {
+ memcpy(atq,(unsigned char*)MRcvBuffer,2);
+ }
+ else
+ {
+ if (MInfo.nBytesReceived == 1)
+ atq[0] = MRcvBuffer[0];
+ else
+ atq[0] = 0x00;
+ atq[1] = 0x00;
+ }
+ }
+ return status;
+}
+///////////////////////////////////////////////////////////////////////
+// M I F A R E C A S C A D E D S E L E C T
+// for extended serial number
+///////////////////////////////////////////////////////////////////////
+unsigned short Mf500PiccCascSelect(unsigned char select_code,
+ unsigned char *snr,
+ unsigned char *sak)
+{
+ unsigned short status = MI_OK;
+
+ if ((status = Mf500PcdSetDefaultAttrib()) == MI_OK)
+ {
+ PcdSetTmo(106);
+
+ //WriteRC(RegChannelRedundancy,0x0F); // RxCRC,TxCRC, Parity enable
+ //ClearBitMask(RegControl,0x08); // disable crypto 1 unit
+
+ //************* Cmd Sequence **********************************
+ ResetInfo(MInfo);
+ MSndBuffer[0] = select_code;
+ MSndBuffer[1] = 0x70; // number of bytes send
+
+ memcpy((unsigned char*)MSndBuffer + 2,snr,4);
+ MSndBuffer[6] = MSndBuffer[2]
+ ^ MSndBuffer[3]
+ ^ MSndBuffer[4]
+ ^ MSndBuffer[5];
+ MInfo.nBytesToSend = 7;
+ MInfo.DisableDF = 1;
+
+ WriteRC(ModeReg, 0x01);
+ SetBitMask(TxModeReg, 0x80);
+ SetBitMask(RxModeReg, 0x80);
+ ClearBitMask(RFU1D, 0x10);
+ ClearBitMask(Status2Reg, 0x08);
+ status = PcdSingleResponseCmd(PCD_TRANSCEIVE,
+ MSndBuffer,
+ MRcvBuffer,
+ &MInfo);
+
+ *sak = 0;
+ if (status == MI_OK) // no timeout occured
+ {
+ if (MInfo.nBitsReceived != 8) // last byte is not complete
+ {
+ status = MI_BITCOUNTERR;
+ }
+ else
+ {
+ memcpy(MLastSelectedSnr,snr,4);
+ }
+ }
+ // copy received data in any case - for debugging reasons
+ *sak = MRcvBuffer[0];
+ }
+ return status;
+}
+
+///////////////////////////////////////////////////////////////////////
+// M I F A R E P I C C A C T I V A T I O N S E Q E N C E
+///////////////////////////////////////////////////////////////////////
+unsigned short Mf500PiccActivateIdle(unsigned char br,
+ unsigned char *atq,
+ unsigned char *sak,
+ unsigned char *uid,
+ unsigned char *uid_len)
+{
+ unsigned char cascade_level;
+ unsigned char sel_code;
+ unsigned char uid_index;
+ unsigned short status = MI_OK;
+ unsigned char cmdASEL;
+
+ *uid_len = 0;
+
+ //call activation with def. divs
+ status = Mf500PcdSetDefaultAttrib();
+ if (status == MI_OK)
+ {
+ status = Mf500PiccCommonRequest(PICC_REQIDL,atq);
+ }
+ if (status == MI_OK)
+ {
+ if((atq[0] & 0x1F) == 0x00) // check lower 5 bits, for tag-type
+ // all tags within this 5 bits have to
+ // provide a bitwise anticollision
+ {
+ status = MI_NOBITWISEANTICOLL;
+ }
+ }
+ if (status == MI_OK)
+ {
+ //Get UID in 1 - 3 levels (standard, [double], [triple] )
+ //-------
+ switch(br)
+ {
+ case 0: cmdASEL = PICC_ANTICOLL1; break;
+ case 1: cmdASEL = PICC_ANTICOLL11; break;
+ case 2: cmdASEL = PICC_ANTICOLL12; break;
+ case 3: cmdASEL = PICC_ANTICOLL13; break;
+ default:
+ status = MI_BAUDRATE_NOT_SUPPORTED; break;
+ }
+ }
+ if (status == MI_OK)
+ {
+ cascade_level = 0;
+ uid_index = 0;
+ do
+ {
+ //Select code depends on cascade level
+ sel_code = cmdASEL + (2 * cascade_level);
+ cmdASEL = PICC_ANTICOLL1; // reset anticollistion level for calculation
+ //ANTICOLLISION
+ status = Mf500PiccCascAnticoll(sel_code, 0, &uid[uid_index]);
+ //SELECT
+ if (status == MI_OK)
+ {
+ status = Mf500PiccCascSelect(sel_code, &uid[uid_index], sak);
+ if (status == MI_OK)
+ {
+ cascade_level++;
+
+ //we differ cascaded and uncascaded UIDs
+ if (*sak & 0x04) // if cascaded, bit 2 is set in answer to select
+ {
+ //this UID is cascaded, remove the cascaded tag that is
+ //0x88 as first of the 4 byte received
+ memmove(&uid[uid_index], &uid[uid_index + 1], 3);
+ uid_index += 3;
+ *uid_len += 3;
+ }
+ else
+ {
+ //this UID is not cascaded -> the length is 4 bytes
+ uid_index += 4;
+ *uid_len += 4;
+ }
+ }
+ }
+ }
+ while((status == MI_OK) // error status
+ && (*sak & 0x04) // no further cascade level
+ && (cascade_level < 3)); // highest cascade level is reached
+ }
+ if (status == MI_OK)
+ {
+ //Exit function, if cascade level is triple and sak indicates another
+ //cascase level.
+ if ((cascade_level == 3) && (*sak & 0x04))
+ {
+ *uid_len = 0;
+ status = MI_CASCLEVEX;
+ }
+ //Mf500PcdSetAttrib(br,br);
+ }
+ return (status);
+}
+
+///////////////////////////////////////////////////////////////////////
+// E X C H A N G E B Y T E S T R E A M
+///////////////////////////////////////////////////////////////////////
+unsigned short ExchangeByteStream(unsigned char Cmd,
+ unsigned char *send_data,
+ unsigned short send_bytelen,
+ unsigned char *rec_data,
+ unsigned short *rec_bytelen)
+{
+ unsigned short status = MI_OK;
+
+ FlushFIFO(); // empty FIFO
+ ResetInfo(MInfo); // initialise ISR Info structure
+
+ if (send_bytelen > 0)
+ {
+ memcpy((unsigned char *)MSndBuffer,send_data,send_bytelen); // write n bytes
+ MInfo.nBytesToSend = send_bytelen;
+ // write load command
+ status = PcdSingleResponseCmd(Cmd,
+ MSndBuffer,
+ MRcvBuffer,
+ &MInfo);
+ *rec_bytelen = MInfo.nBytesReceived;
+ // copy data to output, even in case of an error
+ if (*rec_bytelen)
+ {
+ memcpy(rec_data,(unsigned char *)MRcvBuffer,*rec_bytelen);
+ }
+ }
+ else
+ {
+ status = MI_WRONG_PARAMETER_VALUE;
+ }
+ return status;
+}
+
+//////////////////////////////////////////////////////////////////////
+// P I C C E X C H A N G E B L O C K
+///////////////////////////////////////////////////////////////////////
+unsigned short Mf500PiccExchangeBlock(unsigned char *send_data,
+ unsigned short send_bytelen,
+ unsigned char *rec_data,
+ unsigned short *rec_bytelen,
+ unsigned char append_crc,
+ unsigned long timeout )
+{
+ char status = MI_OK;
+
+ if (append_crc)
+ {
+ // RxCRC and TxCRC enable, parity enable
+ WriteRC(ModeReg, 0x01);
+ SetBitMask(TxModeReg, 0x80);
+ SetBitMask(RxModeReg, 0x80);
+ ClearBitMask(RFU1D, 0x10);
+ WriteRC(ModeReg, 0x01);
+ send_bytelen -= 2;
+ }
+ else
+ {
+ // RxCRC and TxCRC disable, parity enable
+ ClearBitMask(TxModeReg, 0x80);
+ ClearBitMask(RxModeReg, 0x80);
+ ClearBitMask(RFU1D, 0x10);
+ }
+
+ PcdSetTmo(timeout);
+
+ status = ExchangeByteStream(PCD_TRANSCEIVE,
+ send_data,
+ send_bytelen,
+ rec_data,
+ rec_bytelen);
+ // even if an error occured, the data should be
+ // returned - for debugging reasons
+
+ if (append_crc)
+ {
+ *rec_bytelen += 2; // for two CRC bytes
+ rec_data[*rec_bytelen - 2] = 0x00;
+ rec_data[*rec_bytelen - 1] = 0x00;
+ }
+
+ return status;
+}
+
+#endif
+
diff --git a/icc_apdu_lib/MfRcSPI.c b/icc_apdu_lib/MfRcSPI.c
new file mode 100644
index 0000000..d7c200c
--- /dev/null
+++ b/icc_apdu_lib/MfRcSPI.c
@@ -0,0 +1,108 @@
+#include "spi.h"
+
+#define Dummy_Byte 0xA5
+
+#define MFRC500_CS_LOW() SPI_SELECT_CH1()
+#define MFRC500_CS_HIGH() SPI_DESELECT_CH1()
+
+#define MFRC500_RST_LOW() GPIO_ResetBits(GPIOC, GPIO_Pin_6)
+#define MFRC500_RST_HIGH() GPIO_SetBits(GPIOC, GPIO_Pin_6)
+
+/*
+**************************************************************************************************************
+* ÑÓ Ê± º¯ Êý uS
+* ×¢ Ò⣺ ¾«¶ÈÎÊÌâ
+**************************************************************************************************************
+*/
+ void HW_SleepUs(uint16_t us)
+{
+ uint32_t i;
+
+ for( i = 0; i < 6 * us; i++);
+}
+
+/*
+**************************************************************************************************************
+* ÑÓ Ê± º¯ Êý mS
+* ×¢ Ò⣺ ¾«¶ÈÎÊÌâ
+**************************************************************************************************************
+*/
+void HW_SleepMs(uint16_t ms)
+{
+ uint32_t i;
+
+ for( i = 0; i < 3361 * ms; i++ );
+}
+
+/*
+**************************************************************************************************************
+* RF SPI Åä Öà ³õ ʼ »¯
+*
+**************************************************************************************************************
+*/
+void HW_SPI_RF_CfgInit(void)
+{
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
+ GPIO_Init(GPIOC, &GPIO_InitStructure);
+ MFRC500_RST_HIGH();
+ spi_init();
+}
+
+uint8_t spi_rc500_send_byte(uint8_t byte)
+{
+ return spi_transive(byte, 100);
+}
+
+
+/*
+**************************************************************************************************************
+* P C D ¶Á Ò» ¸ö ×Ö ½Ú
+*
+* Ò» °ã ¶Á
+*
+**************************************************************************************************************
+*/
+uint8_t ReadRawRC(uint8_t addr)
+{
+ u8 i;
+
+ addr = ((addr<<1)|0x80)&0xfe;
+ MFRC500_CS_LOW();
+ spi_rc500_send_byte(addr);
+ i = spi_rc500_send_byte(Dummy_Byte);
+ MFRC500_CS_HIGH();
+ return i;
+}
+
+/*
+**************************************************************************************************************
+* P C D д Ò» ¸ö ×Ö ½Ú
+*
+* Ò» °ã д
+*
+**************************************************************************************************************
+*/
+void WriteRawRC(uint8_t value, uint8_t addr)
+{
+ addr = (addr << 1) & 0x7e;
+ MFRC500_CS_LOW();
+ spi_rc500_send_byte(addr);
+ spi_rc500_send_byte(value);
+ MFRC500_CS_HIGH();
+}
+
+void MFRC500_RstSet(void)
+{
+ MFRC500_RST_HIGH();
+}
+
+void MFRC500_RstClr(void)
+{
+ MFRC500_RST_LOW();
+}
+
diff --git a/icc_apdu_lib/Mifare_One_HW_LIB.H b/icc_apdu_lib/Mifare_One_HW_LIB.H
new file mode 100644
index 0000000..0ab6ba0
--- /dev/null
+++ b/icc_apdu_lib/Mifare_One_HW_LIB.H
@@ -0,0 +1,423 @@
+/*
+**************************************************************************************************************
+* Mifare One Ó² ¼þ µ× ²ã Çý ¶¯ ¿â
+*
+* _____Ó² ¼þ µ× ²ã Çý ¶¯_____
+*
+* Ãè Êö£º Íê³ÉMifare One¿¨µÄÓ²¼þµ×²ã²Ù×÷£»
+*
+* Åä Öãº
+* CPU :
+* ÍâʱÖÓ :
+* CPUÔËÐÐʱÖÓ :
+* ÔËÐл·¾³ : Keil ARM ( RealView MDK ) v3.50ÆÆ½â°æ±¾
+* »·¾³ÉèÖà : 1) ģʽ:
+* 2) ÓÅ»¯: ĬÈÏ ( Level 0 (-00) ...)
+*
+* ×¢ Ò⣺ ³ýReadRC£¬WriteRCº¯ÊýÍ⣬ÆäËüM1¿¨²Ù×÷º¯Êý¶¼ÓÐSPI¶Ë¿ÚÅäÖã¬ËùÒÔÆäËüµØ·½µ÷ÓÃÕâЩº¯Êýʱ£¬¾Í²»ÓýøÐÐ
+* SPI¶Ë¿ÚÅäÖòÙ×÷(HW_SPI_RF_CfgInit)¡£
+*
+* ¿â Ãû£º Mifare_One_HW_V2.0.LIB
+*
+* ×÷ Õߣº Zhang_OS@163.com
+*
+* °æ ±¾£º 2.0
+*
+* ÈÕ ÆÚ£º 2009-05-31
+*
+* Copyright (c) 2008-2009 Brand-NEW C.A.P Electronics Technology CO.,LTD
+*
+**************************************************************************************************************
+*/
+
+
+#ifndef __Mifare_One_HW_LIB_H__
+#define __Mifare_One_HW_LIB_H__
+
+#include "PICCCmdConst.h"
+#include "MFRC500.h"
+
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+
+// RC500µÄ¼Ä´æÆ÷¶¨ÒåºÍ³£Êý¶¨Òå
+ #define MI_OK (0)
+
+ #define BUFFER_SIZE_RFCard 64
+
+/* SPIÇý¶¯Æ÷ÄÚ²¿×´Ì¬ */
+ #define IDLE 0x00
+ #define BUSY 0x01
+ #define ERROR 0x02
+
+/* ¿¨½Ó¿ÚSPI״̬·µ»ØÖµ */
+ #define RFCI_BUSY 0x00
+ #define RFCI_OK 0x01
+ #define RFCI_ERROR 0x02
+
+//RF¿¨¿ØÖÆÐźÅ
+ #define RFC_RESET (1<<9) /* PA9 RF¿¨¸´Î»¿ØÖÆÐźÅ(½ÚÄÜ¿ØÖÆ) */
+
+/* ¼Ä´æÆ÷¶¨Òå */
+ #define RegPage 0x00 //!< Page Select Register
+ #define RegCommand 0x01 //!< Command Register
+ #define RegFIFOData 0x02 //!< FiFo Register
+
+/*
+**************************************************************************************************************
+* ±ä Á¿
+**************************************************************************************************************
+*/
+ typedef struct _RFIDesc
+ {
+ volatile unsigned char state;
+ unsigned char command[2];
+ unsigned char dataBuffer[2];
+ } RFIDesc, *pRFIDesc;
+
+ extern RFIDesc gRFIDesc;
+
+
+
+/*
+**************************************************************************************************************
+* º¯ Êý
+**************************************************************************************************************
+*/
+
+//SPI.C
+/*
+**************************************************************************************************************
+* ÑÓ Ê± º¯ Êý uS
+* Thumbģʽ+½»²æÄ£Ê½
+*
+* ×¢ Ò⣺ÔËÐÐģʽ²»Ò»Ñù£¬Èí¼þÑÓʱ²»Ò»Ñù¡£
+**************************************************************************************************************
+*/
+ extern void HW_SleepUs( unsigned short us ); /* uSÈí¼þÑÓʱº¯Êý */
+/*
+**************************************************************************************************************
+* ÑÓ Ê± º¯ Êý mS
+* Thumbģʽ+½»²æÄ£Ê½
+**************************************************************************************************************
+*/
+ extern void HW_SleepMs( unsigned short ms ); /* mSÈí¼þÑÓʱº¯Êý */
+/*
+**************************************************************************************************************
+* RF SPI Åä Öà ³õ ʼ »¯
+*
+**************************************************************************************************************
+*/
+ extern void HW_SPI_RF_CfgInit( void ); /* SPI RF ÅäÖóõʼ»¯ */
+/*
+**************************************************************************************************************
+* PCD µÈ ´ý ½Ó ÊÕ
+* ÄÚ²¿µ÷ÓÃ
+**************************************************************************************************************
+*/
+ extern unsigned char HW_RFI_WaitReady( unsigned int timeout );
+/*
+**************************************************************************************************************
+* P C D ¶Á Ò» ¸ö ×Ö ½Ú
+*
+*
+**************************************************************************************************************
+*/
+ extern unsigned char ReadRC( unsigned char addr );
+/*
+**************************************************************************************************************
+* P C D д Ò» ¸ö ×Ö ½Ú
+*
+*
+**************************************************************************************************************
+*/
+ extern void WriteRC( unsigned char value, unsigned char addr );
+
+//GetM1Sn.C
+/*
+**************************************************************************************************************
+* ¹¦ ÄÜ£º È¡µÃ¿¨ÐòÁкÅ
+* Êä ³ö£º unsigned char *pSN - ¿¨ÐòÁкÅ
+* ·µ»ØÖµ£º 0³É¹¦
+**************************************************************************************************************
+*/
+ extern unsigned char GetM1SN( unsigned char *pSN );
+
+//M1_Basic.C
+/*
+**************************************************************************************************************
+* Ö´ÐÐÃüÁîǰÉ趨ÏàÓ¦¼Ä´æÆ÷ ÄÚ²¿µ÷ÓÃ
+**************************************************************************************************************
+*/
+ extern void RcRegRst( void );
+/*
+**************************************************************************************************************
+* È¡RC500ÃüÁî½á¹û
+* cmd : RC530ÃüÁî×Ö
+* RcvBuff : ÃüÁîÕýÈ·Ö´ÐкóÊÕµ½µÄÊý¾Ý
+* ·µ»ØÖµ £ºÃüÁîÖ´ÐÐÇé¿ö
+* B: ÊÇ·ñ³É¹¦
+**************************************************************************************************************
+*/
+ extern unsigned char RcComResult(unsigned char cmd, unsigned char *RcvBuff);
+/*
+**************************************************************************************************************
+* ¼ÓÔØÏµÍ³ÃÜÂëµ½RC530 KeyBuffer
+* ²ÎÊý£º RawCode - Òª¼ÓÔØµÄ6×Ö½ÚÃÜÂëµÄÖ¸Õ루´æÓÚIDATAÇø£©
+* ·µ»Ø£º 0 - ²Ù×÷³É¹¦
+* !0 - ²Ù×÷ʧ°Ü
+**************************************************************************************************************
+*/
+ extern unsigned char Load_RAM ( unsigned char * RawCode );
+/*
+**************************************************************************************************************
+*
+* ¹¦ ÄÜ £º Ѱ¿¨
+* ²Î Êý : RequestMode : Ѱ¿¨Ä£Ê½£¬ÎªIDLE »ò ALL
+* atq : ¿¨Æ¬µÄÀàÐÍ ÔÝÎÞÓÃ
+* ·µ »Ø Öµ£º µ±Îª0x00 ʱ±íʾÓп¨£¬·ñÔòÎÞ¿¨
+**************************************************************************************************************
+*/
+ extern unsigned char M1_Request( unsigned char RequestMode, unsigned char * atq );
+/*
+**************************************************************************************************************
+* ¹¦ÄÜ£º ¿¹³åÍ»²âÊÔ
+* ²ÎÊý: Bcnt : ¿¹³åÍ»¿¨ÐòÁкÅÔ¤ÖÃλÊý
+* Snr £ºÔ¤ÖûòµÃµ½µÄ¿¨µÄÐòÁкÅ
+* ·µ»ØÖµ£ºµ±Îª0x00 ʱ±íʾÕýÈ·µÃµ½¿¨µÄÐòÁкţ¬·ñÔòδÕýÈ·µÃµ½
+**************************************************************************************************************
+*/
+ extern unsigned char M1_Anti(unsigned char Bcnt, unsigned char *Snr);
+/*
+**************************************************************************************************************
+* ¹¦ÄÜ£º Ñ¡¿¨
+* ²ÎÊý: Snr £º¿¨µÄÐòÁкÅ
+* ·µ»ØÖµ£ºµ±Îª0x00 ʱ±íʾÕýÈ·Ñ¡¿¨³É¹¦
+**************************************************************************************************************
+*/
+ extern unsigned char M1_Select( unsigned char *Snr );
+/*
+**************************************************************************************************************
+* Auth_Block £¨Í¨¹ý¿éºÅ½øÐÐУÑ飬֧³ÖS50£¬S70¿¨£©
+* »òÄÜ£º УÑé
+* ²ÎÊý: AuthMode :AÃÜÂë »ò BÃÜÂë
+* Block :¶Áд¿éºÅ
+* Snr :¿¨ÐòÁкÅ
+* ·µ»ØÖµ£º00±íʾÃÜÂëÕýÈ·
+**************************************************************************************************************
+*/
+ extern unsigned char M1_AuthBlk( unsigned char AuthMode, unsigned char *Snr, unsigned char Block, unsigned char *key );
+/*
+**************************************************************************************************************
+* RC530¼Ä´æÆ÷³õʼ»¯
+**************************************************************************************************************
+*/
+ extern unsigned char RCConfig(void);
+/*
+**************************************************************************************************************
+* RC530Éϵ縴λ
+* 1. ½«RC530´Óµôµçģʽ»½ÐÑ£¬²¢Íê³É³õʼ»¯
+* 2. »ò½«RC530ÖØÐ¸´Î»
+**************************************************************************************************************
+*/
+ extern unsigned char M1_RCReset(void);
+
+//M1_BlkRead.C
+/*
+**************************************************************************************************************
+*¹¦ÄÜ£º Mifare¿¨¿é¶Á(º¬Ñ°¿¨, Ñ¡¿¨, УÑé, ¶Á¿¨(Ò»¿é), ¿É¹©Ñ¡Ôñ)£º
+*ÊäÈ룺 unsigned char *pSN - ¿¨ÐòÁкÅ
+* unsigned char Mode - ( ¸ù¾Ý¶¨ÒåµÄ³£Á¿±í½øÐÐ"»ò"×éºÏ )
+* bit0 - AÃÜÂë»òBÃÜÂë( 0 - A 1 - B)
+* bit2 - 0 - Ѱ¿¨ 1 - ²»Ñ°¿¨
+* bit3 - 0 - ²»Ð£ÑéÃÜÂë 1 - ҪУÑéÃÜÂë
+* unsigned char Block - Òª¶ÁµÄ¿éºÅ
+* unsigned char *pKey - ÉÈÇø¶ÁдÃÜÂë
+*
+*Êä³ö£º unsigned char *pBuffer - ¶Á³öµÄ16×Ö½ÚÊý¾Ý
+*·µ»ØÖµ£ºµ±Îª0x00 ʱÕýÈ·¶Á³ö
+**************************************************************************************************************
+*/
+ extern unsigned char M1_BlkRead( unsigned char Mode, unsigned char Block, unsigned char *pSN, unsigned char * pBuffer, unsigned char *pKey );
+
+//M1_BlkWrite.C
+/*
+**************************************************************************************************************
+*¹¦ÄÜ£º Mifare¿¨¿éд(º¬Ñ°¿¨, Ñ¡¿¨, УÑé, ¶Á¿¨(Ò»¿é), ¿É¹©Ñ¡Ôñ)£º
+*ÊäÈ룺 unsigned char *pSN - ¿¨ÐòÁкÅ
+* unsigned char Mode - ( ¸ù¾Ý¶¨ÒåµÄ³£Á¿±í½øÐÐ"»ò"×éºÏ )
+* bit0 - AÃÜÂë»òBÃÜÂë( 0 - A 1 - B)
+* bit2 - 0 - Ѱ¿¨ 1 - ²»Ñ°¿¨
+* bit3 - 0 - ²»Ð£ÑéÃÜÂë 1 - ҪУÑéÃÜÂë
+* unsigned char Block - Òª¶ÁµÄ¿éºÅ
+* unsigned char *pKey - ÉÈÇø¶ÁдÃÜÂë
+* unsigned char *pBuffer - ҪдÈëµÄ16×Ö½ÚÊý¾Ý
+*·µ»ØÖµ£ºµ±Îª0x00 ʱÕýÈ·¶Á³ö
+**************************************************************************************************************
+*/
+ extern unsigned char M1_BlkWrite( unsigned char Mode, unsigned char Block, unsigned char *pSN, unsigned char * pBuffer, unsigned char *pKey );
+
+//M1_E2Read.C
+/*
+**************************************************************************************************************
+* M1_E2Read ¶ÁÈ¡RC500µÄE2ÖеÄÊý¾Ý
+* Addr :E2ÆðʼµØÖ·(Addr < 80H )
+* length :ÒªÇó¶ÁÈ¡µÄ×Ö½ÚÊý( СÓÚµÈÓÚ16 )
+* pBuffer :¶Á³öÊý¾ÝµÄ»º³åÇø
+* ·µ»ØÖµ £º0±íʾд³É¹¦
+**************************************************************************************************************
+*/
+ extern unsigned char M1_E2Read( unsigned char Addr, unsigned char length, unsigned char * pBuffer);
+
+//M1_E2WRITE.C
+/*
+**************************************************************************************************************
+* M1_E2Write ½«Êý¾ÝдÈëRC500µÄE2ÖÐ
+* Addr :E2ÆðʼµØÖ·( 0x10 <=Addr < 0x1ff )
+* length :ÒªÇóдÈëµÄ×Ö½ÚÊý( СÓÚµÈÓÚ16 )
+* pBuffer :ҪдÈëÊý¾ÝµÄ»º³åÇø
+* ·µ»ØÖµ £º0±íʾд³É¹¦
+**************************************************************************************************************
+*/
+ extern unsigned char M1_E2Write( unsigned int Addr, unsigned char length, unsigned char * pBuffer);
+
+//M1_HardPwrDwn.C
+/*
+**************************************************************************************************************
+* ¹¦ÄÜ£º ¶Á¿¨°åÓ²¼þµôµç£º
+* º¯ÊýÔÐÍ£º void HardPwrDwn() ÔÝûÓÐд
+* ²ÎÊý£º ÎÞ
+* ·µ»ØÖµ£º ÎÞ
+* ˵Ã÷£º
+* ½«¶Á¿¨°åµÄRF¡ªRST¿ØÖÆÏßÖÃΪ¸ßµçƽ£¬¶Á¿¨°å´¦ÓÚÓ²¼þµôµç״̬£¨µçÔ´Õý³£Ìṩ£©¡£
+**************************************************************************************************************
+*/
+ extern void M1_HardPwrDwn( void );
+
+//M1_PCDSn.C
+/*
+**************************************************************************************************************
+* M1_PCDSn ¶ÁÈ¡RC500µÈ¶Á¿¨Ð¾Æ¬µÄÐòÁкÅ
+* pSn :ÐòÁкŻº³åÇø
+* ·µ»ØÖµ £º0±íʾд³É¹¦
+**************************************************************************************************************
+*/
+ extern unsigned char M1_PCDSn( unsigned char * pBuffer);
+
+//M1_RadioOff.C
+/*
+**************************************************************************************************************
+* ¹¦ÄÜ£º ¶Á¿¨°å¶Á¿¨Ð¾Æ¬É䯵¹Ø±Õ£º
+* º¯ÊýÔÐÍ£º void M1_RadioOff()
+* ²ÎÊý£º ÎÞ
+* ·µ»ØÖµ£º ÎÞ
+* ˵Ã÷£º
+* ½«¶Á¿¨°åÉϵĶÁ¿¨Ð¾Æ¬µÄÉ䯵·¢Ë͹صô,½µµÍ¹¦ºÄºÍ¶ÔÍâ¸ÉÈÅ
+* ´Ëʱ¶Á¿¨Ð¾Æ¬»¹ÔÚ¹¤×÷.
+**************************************************************************************************************
+*/
+ extern void M1_RadioOff( void );
+
+//M1_RadioOn.C
+/*
+**************************************************************************************************************
+* ¹¦ÄÜ£º ¶Á¿¨°å¶Á¿¨Ð¾Æ¬É䯵´ò¿ª£º
+* º¯ÊýÔÐÍ£º void M1_RadioOn()
+* ²ÎÊý£º ÎÞ
+* ·µ»ØÖµ£º ÎÞ
+* ˵Ã÷£º
+* ½«¶Á¿¨°åÉϵĶÁ¿¨Ð¾Æ¬µÄÉ䯵·¢ËÍ´ò¿ª
+*
+* M1_RadioOn() ºÍ M1_RadioOff()ÊÇÒ»¶Ôº¯Êý,ÓÃÔÚÒ»°ãÇé¿öϵĽÚÄܺͽµµÍÉ䯵¸ÉÈÅÉÏ.
+**************************************************************************************************************
+*/
+ extern void M1_RadioOn( void );
+
+//M1_RawRead.C
+/*
+**************************************************************************************************************
+* Fread ¶Á¿éÊý¾Ý
+* Block :¶Á¿éºÅ
+* ReadBuffer :¶Á³öµÄÊý¾ÝµÄ»º³åÇø£¬ÔÚIDATAÇø
+* ·µ»ØÖµ £º0±íʾ¶Á³É¹¦
+**************************************************************************************************************
+*/
+ extern unsigned char M1_Read(unsigned char Block, unsigned char * ReadBuffer);
+
+//M1_rawWrite.C
+/*
+**************************************************************************************************************
+* Fwrite д¿éÊý¾Ý
+* Block :д¿éºÅ
+* ReadBuffer :ҪдÊý¾ÝµÄ»º³åÇø£¬ÔÚIDATAÇø
+* ·µ»ØÖµ £º0±íʾд³É¹¦
+**************************************************************************************************************
+*/
+ extern unsigned char M1_Write( unsigned char Block, unsigned char * WriteBuffer);
+
+//M1_Timer.C
+/*
+**************************************************************************************************************
+* ¹¦ÄÜ: Æô¶¯Mifare¶Á¿¨Çý¶¯µÄ³¬Ê±¶¨Ê±Æ÷ ÔÝûÓÐд
+**************************************************************************************************************
+*/
+ extern void M1TimerToStart( void );
+/*
+**************************************************************************************************************
+* ¹¦ÄÜ: Í£Ö¹Mifare¶Á¿¨Çý¶¯µÄ³¬Ê±¶¨Ê±Æ÷ ÔÝûÓÐд
+**************************************************************************************************************
+*/
+ extern void M1TimerToStop( void );
+/*
+**************************************************************************************************************
+* ¹¦ÄÜ: È¡µÃMifare¶Á¿¨Çý¶¯µÄ³¬Ê±¶¨Ê±Æ÷״̬ ÔÝûÓÐд
+* ·µ»ØÖµ: 1 - ³¬Ê±¶¨Ê±Æ÷Òç³ö( ³¬Ê± )
+* 0 - ³¬Ê±¶¨Ê±Æ÷δÒç³ö
+**************************************************************************************************************
+*/
+ extern unsigned char M1TimerToSta( void );
+
+//M1_TranSta.C
+/*
+**************************************************************************************************************
+* ¹¦ÄÜ£º ¼ì²é¶Á¿¨Ð¾Æ¬ÊÇ·ñ·¢ÉäÕý³£
+* º¯ÊýÔÐÍ£º unsigned char M1_TranSta()
+* ²ÎÊý£º ÎÞ
+* ·µ»ØÖµ£º 1 - ÔØ²¨Î´·¢Éä
+* 0 - ÔØ²¨·¢Éä
+**************************************************************************************************************
+*/
+ extern unsigned char M1_TranSta( void );
+//
+
+
+/*
+**************************************************************************************************************
+* Öµ¿éµÄ¼Ó¼õ²Ù×÷: Íê³ÉBlockÖµ¿éµÄ¼Ó¡¢¼õ¡¢Restore£¬²¢½«Öµ´«ÈëTranBlockÖÐ
+* cmd £º¼Ó(PICC_ADD)¡¢¼õ(PICC_SUB)¡¢Restore(PICC_RESTORE)ÃüÁî
+* Block :ÔÖµ¿éºÅ
+* Value :ËÄ×Ö½ÚÖµÇø£¨Õý£©
+* TranBlock £ºÖµ´«ÈëµÄ¿éºÅ
+* ·µ»ØÖµ £º0±íʾ¶Á³É¹¦£¬ÆäËüΪ´íÎó´úÂë
+**************************************************************************************************************
+*/
+
+ extern unsigned char M1_Value( unsigned char cmd, unsigned char Block, unsigned char * Value, unsigned char TranBlock );
+
+/***************************************************************
+ Halt
+ ¹¦ÄÜ£º ÖÕÖ¹¿¨
+ ²ÎÊý: ÎÞ
+ ·µ»ØÖµ£ºµ±Îª0x00 ʱ±íʾ¿¨ÖÕÖ¹³É¹¦
+****************************************************************/
+extern unsigned char M1_Halt( void );
+
+extern unsigned char PICC_TclCheckRFRounge( void ) ;
+
+
+#endif
+
+
diff --git a/icc_apdu_lib/PICCCmdConst.h b/icc_apdu_lib/PICCCmdConst.h
new file mode 100644
index 0000000..8dbfba0
--- /dev/null
+++ b/icc_apdu_lib/PICCCmdConst.h
@@ -0,0 +1,54 @@
+/*
+* Copyright (c), Philips Semiconductors Gratkorn / Austria
+*
+* (C)PHILIPS Electronics N.V.2000
+* All rights are reserved. Reproduction in whole or in part is
+* prohibited without the written consent of the copyright owner.
+* Philips reserves the right to make changes without notice at any time.
+* Philips makes no warranty, expressed, implied or statutory, including but
+* not limited to any implied warranty of merchantability or fitness for any
+*particular purpose, or that the use will not infringe any third party patent,
+* copyright or trademark. Philips must not be liable for any loss or damage
+* arising from its use.
+*/
+
+/*! \file PICCCmdConst.h
+*
+* Projekt: MF EV X00 Firmware
+*
+* $Workfile:: PICCCmdConst.h $
+* $Modtime:: 5.12.01 6:52 $
+* $Author:: Hb $
+* $Revision:: 1 $
+*
+*/
+#ifndef PICCCMDCONST_H
+#define PICCCMDCONST_H
+
+
+/** \name PICC Commands
+* \ingroup mifare
+* Commands which are handled by the tag
+*
+* Each tag command is written to the reader IC and transfered via RF
+*/
+#define PICC_REQIDL 0x26 //!< request idle
+#define PICC_REQALL 0x52 //!< request all
+#define PICC_ANTICOLL1 0x93 //!< anticollision level 1 106 kBaud
+#define PICC_ANTICOLL11 0x92 //!< anticollision level 1 212 kBaud
+#define PICC_ANTICOLL12 0x94 //!< anticollision level 1 424 kBaud
+#define PICC_ANTICOLL13 0x98 //!< anticollision level 1 848 kBaud
+#define PICC_ANTICOLL2 0x95 //!< anticollision level 2
+#define PICC_ANTICOLL3 0x97 //!< anticollision level 3
+#define PICC_AUTHENT1A 0x60 //!< authentication using key A
+#define PICC_AUTHENT1B 0x61 //!< authentication using key B
+#define PICC_READ16 0x30 //!< read 16 byte block
+#define PICC_WRITE16 0xA0 //!< write 16 byte block
+#define PICC_WRITE4 0xA2 //!< write 4 byte block
+#define PICC_DECREMENT 0xC0 //!< decrement value
+#define PICC_INCREMENT 0xC1 //!< increment value
+#define PICC_RESTORE 0xC2 //!< restore command code
+#define PICC_TRANSFER 0xB0 //!< transfer command code
+#define PICC_HALT 0x50 //!< halt
+
+#endif // PICCCMDCONST_H
diff --git a/icc_apdu_lib/RICReg.H b/icc_apdu_lib/RICReg.H
new file mode 100644
index 0000000..f083a3a
--- /dev/null
+++ b/icc_apdu_lib/RICReg.H
@@ -0,0 +1,115 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (c), Philips Semiconductors Gratkorn
+//
+// (C)PHILIPS Electronics N.V. 2000
+// All rights are reserved.
+// Philips reserves the right to make changes without notice at any time.
+// Philips makes no warranty, expressed, implied or statutory, including but
+// not limited to any implied warranty of merchantibility or fitness for any
+//particular purpose, or that the use will not infringe any third party patent,
+// copyright or trademark. Philips must not be liable for any loss or damage
+// arising from its use.
+//////////////////////////////////////////////////////////////////////////////
+/*! \file RICReg.h
+*
+* Register Setting of the reader IC
+*/
+#ifndef RICREG_H
+#define RICREG_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+//CV520 regs
+// PAGE 0
+#define RFU00 0x00
+#define CommandReg 0x01
+#define ComIEnReg 0x02
+#define DivlEnReg 0x03
+#define ComIrqReg 0x04
+#define DivIrqReg 0x05
+#define ErrorReg 0x06
+#define Status1Reg 0x07
+#define Status2Reg 0x08
+#define FIFODataReg 0x09
+#define FIFOLevelReg 0x0A
+#define WaterLevelReg 0x0B
+#define ControlReg 0x0C
+#define BitFramingReg 0x0D
+#define CollReg 0x0E
+#define RFU0F 0x0F
+/*PAGE 1 */
+#define RFU10 0x10
+#define ModeReg 0x11
+#define TxModeReg 0x12
+#define RxModeReg 0x13
+#define TxControlReg 0x14
+#define TxAskReg 0x15
+#define TxSelReg 0x16
+#define RxSelReg 0x17
+#define RxThresholdReg 0x18
+#define DemodReg 0x19
+#define RFU1A 0x1A
+#define RFU1B 0x1B
+#define MifareReg 0x1C
+#define RFU1D 0x1D
+#define RFU1E 0x1E
+#define SerialSpeedReg 0x1F
+/*PAGE 2 */
+#define RFU20 0x20
+#define CRCResultRegM 0x21
+#define CRCResultRegL 0x22
+#define RFU23 0x23
+#define ModWidthReg 0x24
+#define RFU25 0x25
+#define RFCfgReg 0x26
+#define GsNReg 0x27
+#define CWGsCfgReg 0x28
+#define ModGsCfgReg 0x29
+#define TModeReg 0x2A
+#define TPrescalerReg 0x2B
+#define TReloadRegH 0x2C
+#define TReloadRegL 0x2D
+#define TCounterValueRegH 0x2E
+#define TCounterValueRegL 0x2F
+/* PAGE 3 */
+#define RFU30 0x30
+#define TestSel1Reg 0x31
+#define TestSel2Reg 0x32
+#define TestPinEnReg 0x33
+#define TestPinValueReg 0x34
+#define TestBusReg 0x35
+#define AutoTestReg 0x36
+#define VersionReg 0x37
+#define AnalogTestReg 0x38
+#define TestDAC1Reg 0x39
+#define TestDAC2Reg 0x3A
+#define TestADCReg 0x3B
+#define RFU3C 0x3C
+#define RFU3D 0x3D
+#define RFU3E 0x3E
+#define RFU3F 0x3F
+
+
+#define DEF_FIFO_LENGTH 64 //!< default FIFO size
+
+// P C D - C O M M A N D S
+#define PCD_IDLE 0x00 //È¡Ïûµ±Ç°ÃüÁî
+#define PCD_AUTHENT 0x0E //ÑéÖ¤ÃÜÔ¿ MIFARE ±ê×¼ÈÏÖ¤
+#define PCD_RECEIVE 0x08 //½ÓÊÕÊý¾Ý
+#define PCD_TRANSMIT 0x04 //·¢ËÍÊý¾Ý
+#define PCD_TRANSCEIVE 0x0C //·¢ËͲ¢½ÓÊÕÊý¾Ý
+#define PCD_RESETPHASE 0x0F //¸´Î»
+#define PCD_CALCCRC 0x03 //CRC¼ÆËã
+#define PCD_SOFTRST 0x0F //Èí¼þ¸´Î»
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //RICREG_H
+//////////////////////////////////////////////////////////////////////////////
+// End of File
+//////////////////////////////////////////////////////////////////////////////
diff --git a/icc_apdu_lib/T0T1.c b/icc_apdu_lib/T0T1.c
new file mode 100644
index 0000000..f8f9d7b
--- /dev/null
+++ b/icc_apdu_lib/T0T1.c
@@ -0,0 +1,462 @@
+/*
+**************************************************************************************************************
+* ISO7816-1 T0,T1(Á´ · ²ã) ´« Êä Ð Òé Çý ¶¯
+*
+* _____ ISO7816-2 Á´ · ²ã Çý ¶¯_____
+*
+* Ãè Êö£º Ö÷ÒªÍê³É T0,T1(Êý¾ÝÁ´Â·²ã)´«ÊäÐÒé Êý¾Ý½»»»
+*
+* Åä Öãº
+* ÔËÐл·¾³ : Keil ARM ( RealView MDK ) v3.05ÆÆ½â°æ±¾
+* »·¾³ÉèÖà : 1) ģʽ: Thumb-Mode + Use Cross-Module Optimization
+* 2) ÓÅ»¯: ĬÈÏ ( Level 0 (-00) ...)
+*
+* ×¢ Ò⣺ T0,T1´«ÊäÐÒé·ûºÏISO7816-2£¬EMV±ê×¼£»
+*
+* ²ã Ãû£º T0T1.C
+*
+* ×÷ Õߣº Zhang_OS@163.com
+*
+* °æ ±¾£º V1.0
+*
+* ÈÕ ÆÚ£º 2008-03-31
+*
+* Copyright (c) 2008 Brand-NEW C.A.P Electronics Technology CO.,LTD
+*
+**************************************************************************************************************
+*/
+
+ #include "LIB_Includes.H"
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+// #define MEMORY_BUFFER_SIZE 256
+
+/*
+**************************************************************************************************************
+* Àà ÐÍ
+**************************************************************************************************************
+*/
+
+
+/*
+**************************************************************************************************************
+* ±ä Á¿
+**************************************************************************************************************
+*/
+// extern unsigned char ucMemPool[]; //µ½Ê±ºòӦȥµô ICC_ADPU_Maper.CÖж¨Òå¹ý
+// extern unsigned char scMemPool[]; //µ½Ê±ºòӦȥµô ICC_ADPU_Maper.CÖж¨Òå¹ý
+
+// ICCSTRUCT *T01CurrentIccInfo; //µ±Ç°²Ù×÷µÄ¿¨ÐÅÏ¢¶¨Òå ISOUSARTDriver.CÖж¨Òå¹ý
+
+/*
+**************************************************************************************************************
+* º¯ Êý
+**************************************************************************************************************
+*/
+// extern void SleepUs(unsigned short us);
+/***********************************************
+º¯Êý¹¦ÄÜ£º¶ÔÊý×éÖеÄÔªËØ½øÐÐÒì»ò
+Èë¿Ú²ÎÊý£ºbuffer,Êý×éÊ×µØÖ·£»length,Êý×鳤¶È
+***********************************************/
+unsigned char XOR(unsigned char *buffer,unsigned char length)
+{
+ unsigned char result;
+ unsigned char i;
+ result =0;
+ for(i =0;i< length;i++)
+ {
+ result ^=buffer[i];
+ }
+ return(result);
+}
+void CalCrc16(unsigned char* input, unsigned char* Crc16, unsigned int len)
+{
+ unsigned int temp=0x6363;
+ unsigned int i;
+ unsigned char j;
+
+ for( i=0; i<len; i++ )
+ {
+ temp = temp ^((unsigned int)input[i]);
+ for (j = 0; j < 8; j++)
+ {
+ if (temp & 0x0001)
+ {
+ temp = (temp >> 1) ^ 0x8408;
+ }
+ else
+ {
+ temp = (temp >> 1);
+ }
+ }
+ }
+ Crc16[0] = (unsigned char)(temp);
+ Crc16[1] = (unsigned char)(temp>>8);
+}
+/*
+**************************************************************************************************************
+* IC ¿¨ Çå ³ý »ù ±¾ ЊϢ
+*
+* Ãè Êö£º½Ó ´¥ ³õ ʼ »¯ ¿¨ ЊϢ Êý ¾Ý ½á ¹¹
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* cid ÔÝûÓÐʹÓÃ
+*
+* ·µ »Ø£ºÎÞ
+*
+**************************************************************************************************************
+*/
+ void ResetIccInfo( unsigned char cid, ICCSTRUCT *info )
+ {
+ T01CurrentIccInfo = info;
+ info->EXDI = 1;
+ info->blknr = 0;
+ info->MSndBuffer = scMemPool; //·¢ËÍÃüÁ³åÇø SAM¿¨µÄ»º³åÇø£¬¶ÔÓÚ½Ó´¥¿¨Ó¦Ó㬴˴¦ÐèÒªÖØÐÂÉè¼Æ
+ info->MRcvBuffer = scMemPool; //½ÓÊÕÃüÁ³åÇø
+ }
+
+/*
+**************************************************************************************************************
+* IC ¿¨ ÉÏ µç ²¢ ¸´ λ
+*
+* Ãè Êö£ºISO7816 T=0 ÐÒéIC¿¨Éϵ粢¸´Î» ĿǰT=0,T=1ÐÒ鶼ʹÓô˵÷Óô˺¯Êý?
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+*
+* ·µ »Ø£ºÎÞ
+*
+**************************************************************************************************************
+*/
+ unsigned short T0PowerOnCard( int ich )
+ {
+ return ICC_PowerOnCard( ich ); //¿¨ ÉÏ µç ²¢ ¸´ λ
+ }
+
+/*
+**************************************************************************************************************
+* IC ¿¨ Ï µç ´¥ µã ÊÍ ·Å
+*
+* Ãè Êö£ºISO7816 T=0 ÐÒéIC¿¨Ïµ紥µãÊÍ·Å ÉϵçÀ临λºóµ÷ÓÃÁ˴˺¯Êý?
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+*
+* ·µ »Ø£ºÎÞ
+*
+**************************************************************************************************************
+*/
+ void T0PowerOffCard( int ich )
+ {
+ ICC_PowerOffCard( ich );
+ }
+
+/*
+**************************************************************************************************************
+* T0 Ð Òé ¿¨ ÈÈ ¸´ λ (À临λ)
+*
+* Ãè Êö£ºISO7816 T=0 ¿¨ ÈÈ ¸´ λ ĿǰT=0,T=1ÐÒ鶼ʹÓô˸´Î»
+*
+* ²Î Êý£ºich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+* *Info IC¿¨µ±Ç°×´Ì¬¶¨Òå
+*
+* ·µ »Ø£ºÎÞ
+*
+**************************************************************************************************************
+*/
+ unsigned short T0ResetCard( int ich, ICCSTRUCT *Info )
+ {
+ T01CurrentIccInfo = Info; // intialize pointer to Picc info structure
+ // Global pointer to the currently selected Picc
+ // for used in other routine.
+
+ return ICC_ResetCard( ich );
+ }
+
+/*
+**************************************************************************************************************
+* T0 Ð Òé Êý ¾Ý ½» »»
+*
+* Ãè Êö£ºISO7816 T=0´«ÊäÐÒéÊý¾Ý½»»»£¬Ö÷ÒªÊÇͨ¹ý7816ͨ¹ý¿ÚÏß·¢ËÍÊý¾Ý²¢½ÓÊÕÊý¾Ý
+*
+* ²Î Êý£º*send_buf ·¢ËÍÊý¾Ý»º³åÇøÖ¸Õë
+* snd_buf_len ·¢ËÍÊý¾Ý³¤¶È
+* **rec_buf ½ÓÊÕÊý¾Ý»º³åÇøÖ¸Õë
+* *rec_buf_len ½ÓÊÕÊý¾Ý³¤¶È
+* ich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+*
+* ·µ »Ø£º²Ù×÷³É¹¦»òʧ°Ü״̬Âë
+*
+**************************************************************************************************************
+*/
+ unsigned short T0Exchange( unsigned char *snd_buf, unsigned char snd_buf_len, unsigned char **rec_buf,
+ unsigned char *rec_buf_len, int ich )
+ {
+ unsigned short rcode;
+
+ memcpy(T01CurrentIccInfo->MSndBuffer,snd_buf,5);
+ if(snd_buf_len > 5)
+ {
+ rcode = T0_TPDU(T01CurrentIccInfo->MSndBuffer, snd_buf+5, 1,rec_buf_len, ich);
+ }
+ else
+ {
+ rcode = T0_TPDU(T01CurrentIccInfo->MSndBuffer, T01CurrentIccInfo->MRcvBuffer, 0, rec_buf_len, ich);
+ }
+ if((rcode & 0xff00) == 0x6100) //·µ»Ø0x61xx xx¾ÍÊÇ·µ»ØµÄ»ØËÍÊý¾Ý³¤¶È
+ {
+ T01CurrentIccInfo->MSndBuffer[0] = 0x00;
+ T01CurrentIccInfo->MSndBuffer[1] = 0xC0;
+ T01CurrentIccInfo->MSndBuffer[2] = 0x00;
+ T01CurrentIccInfo->MSndBuffer[3] = 0x00;
+ T01CurrentIccInfo->MSndBuffer[4] = rcode & 0xff;
+ rcode = T0_TPDU(T01CurrentIccInfo->MSndBuffer, T01CurrentIccInfo->MRcvBuffer, 2, rec_buf_len, ich); //GetResponse
+ //*rec_buf_len = T01CurrentIccInfo->MSndBuffer[4];
+ }
+ else if((rcode & 0xff00) == 0x6C00) //·µ»Ø0x6Cxx xx¾ÍÊÇ·µ»ØµÄ»ØËÍÊý¾Ý³¤¶È
+ {
+ T01CurrentIccInfo->MSndBuffer[4] = rcode & 0xff;
+ rcode = T0_TPDU(T01CurrentIccInfo->MSndBuffer, T01CurrentIccInfo->MRcvBuffer, 2, rec_buf_len, ich); //¼ÓÈëLeºóµÄÃüÁî
+// *rec_buf_len = T01CurrentIccInfo->MSndBuffer[4];
+ }
+ *rec_buf = T01CurrentIccInfo->MRcvBuffer;
+ return rcode;
+ }
+
+/*
+**************************************************************************************************************
+* T1 Ð Òé Êý ¾Ý ½» »»
+*
+* Ãè Êö£ºISO7816 T=1´«ÊäÐÒéÊý¾Ý½»»»£¬Ö÷ÒªÊÇͨ¹ý7816ͨ¹ý¿ÚÏß·¢ËÍÊý¾Ý²¢½ÓÊÕÊý¾Ý
+*
+* ²Î Êý£º
+* cid ÔÝûÓÐʹÓÃ?
+* nad_send
+* *cmd_buf ·¢ËÍÃüÁ³åÇøÖ¸Õë
+* cmd_len ·¢ËÍÃüÁîÊý¾Ý³¤¶È
+* **rec_buf ½ÓÊÕÊý¾Ý»º³åÇøÖ¸Õë
+* *rec_buf_len ½ÓÊÕÊý¾Ý³¤¶È
+* ich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+*
+* ·µ »Ø£º²Ù×÷³É¹¦»òʧ°Ü״̬Âë
+*
+**************************************************************************************************************
+*/
+ unsigned short T1Exchange(unsigned char cid, unsigned char nad_send,unsigned char *cmd_buf,
+ unsigned char cmd_len, unsigned char **rec_buf, unsigned char *rec_buf_len, int ich)
+ {
+ short wCardStatus=0, wProtocolStatus=0;
+ unsigned char Send_length,ResponseLength;
+ unsigned char BufIndex;
+
+ BufIndex = 0;
+
+ T01CurrentIccInfo->MSndBuffer[BufIndex++] = nad_send; //NAD
+ T01CurrentIccInfo->MSndBuffer[BufIndex++] = T01CurrentIccInfo->blknr<<6; //PCB
+ T01CurrentIccInfo->MSndBuffer[BufIndex++] = cmd_len; //LEN
+ memcpy(&(T01CurrentIccInfo->MSndBuffer[BufIndex]),cmd_buf,cmd_len);
+ Send_length = BufIndex+cmd_len;
+ if(T01CurrentIccInfo->Crc==1)
+ {
+ CalCrc16(T01CurrentIccInfo->MSndBuffer,T01CurrentIccInfo->MSndBuffer+Send_length,Send_length);
+ Send_length += 2;
+ }
+ else
+ {
+ T01CurrentIccInfo->MSndBuffer[Send_length] = XOR(T01CurrentIccInfo->MSndBuffer,Send_length);
+ Send_length += 1;
+ }
+
+ wProtocolStatus = T1_TPDU(T01CurrentIccInfo->MSndBuffer,Send_length,T01CurrentIccInfo->MRcvBuffer,&ResponseLength,ich);
+
+ if( wProtocolStatus != TCL_OK )
+ {
+ // Error: could not exchange info blocks with the card.
+ return (wProtocolStatus);
+ }
+
+ // Check if received block is a S-block for WTX
+ while( (T01CurrentIccInfo->MRcvBuffer[1]&0xe3) == 0xc3 )
+ {
+ T01CurrentIccInfo->MSndBuffer[0] = nad_send;
+ T01CurrentIccInfo->MSndBuffer[1] = 0xe3;
+ T01CurrentIccInfo->MSndBuffer[2] = 1;
+ T01CurrentIccInfo->MSndBuffer[3] = T01CurrentIccInfo->MRcvBuffer[3];
+ Send_length = 4;
+ if(T01CurrentIccInfo->Crc==1)
+ {
+ CalCrc16(T01CurrentIccInfo->MSndBuffer,T01CurrentIccInfo->MSndBuffer+Send_length,Send_length);
+ Send_length += 2;
+ }
+ else
+ {
+ T01CurrentIccInfo->MSndBuffer[Send_length] = XOR(T01CurrentIccInfo->MSndBuffer,Send_length);
+ Send_length += 1;
+ }
+
+ // Communicate the prepared buffer to the card and get its response.
+ wProtocolStatus = T1_TPDU(T01CurrentIccInfo->MSndBuffer,Send_length,T01CurrentIccInfo->MRcvBuffer,&ResponseLength,ich);
+ if( wProtocolStatus != TCL_OK )
+ {
+ // Error: could not exchange info blocks with the card.
+ return (wProtocolStatus);
+ }
+ }
+ // Check if received block is a I-block for chain
+ while( (T01CurrentIccInfo->MRcvBuffer[1]&0xA0) == 0x20 ) //ÐèÒªÖØÉè¼Æ
+ {
+// if(T01CurrentIccInfo->blknr != ((T01CurrentIccInfo->MRcvBuffer[1]>>6)&0x01) )
+// {
+// // Error: block number not equal.
+ return (TCL_FATAL_PROTOCOL);
+// }
+// T01CurrentIccInfo->blknr ^= 1; // Toggle block number
+//
+// T01CurrentIccInfo->MSndBuffer[0] = nad_send;
+// T01CurrentIccInfo->MSndBuffer[1] = 0x80 | T01CurrentIccInfo->blknr<<4;
+// T01CurrentIccInfo->MSndBuffer[2] = 0;
+// Send_length = 3;
+// if(T01CurrentIccInfo->Crc==1)
+// {
+// CalCrc16(T01CurrentIccInfo->MSndBuffer,T01CurrentIccInfo->MSndBuffer+Send_length,Send_length);
+// Send_length += 2;
+// }
+// else
+// {
+// T01CurrentIccInfo->MSndBuffer[Send_length] = XOR(T01CurrentIccInfo->MSndBuffer,Send_length);
+// Send_length += 1;
+// }
+//
+// // Communicate the prepared buffer to the card and get its response.
+// wProtocolStatus = T1_TPDU(T01CurrentIccInfo->MSndBuffer,Send_length,T01CurrentIccInfo->MRcvBuffer,&ResponseLength,ich);
+// if( wProtocolStatus != TCL_OK )
+// {
+// // Error: could not exchange info blocks with the card.
+// return (wProtocolStatus);
+// }
+ }
+ // Check the length of the response. It must be > 1 and <= sgbMAX_INFO_FRAME_SIZE in all cases.
+ if( (ResponseLength < 4) || (ResponseLength > 254))
+ {
+ // Error: block with inappropriate number of bytes received from the card.
+ return TCL_FATAL_PROTOCOL;
+ }
+
+ if(nad_send != T01CurrentIccInfo->MRcvBuffer[0])
+ {
+ // Error: nad not equal.
+ return ( TCL_NADINVALID );
+ }
+ if(T01CurrentIccInfo->Crc != 0)
+ {
+ wCardStatus = TCL_FATAL_PROTOCOL;//ÒÔºó´Óж¨Òå
+ }
+
+ if(XOR(T01CurrentIccInfo->MRcvBuffer,ResponseLength) != 0) //½øÐÐLRCУÑé
+ {
+ return ( TCL_CRCERR );
+ }
+ if((T01CurrentIccInfo->MRcvBuffer[1] & 0x80) != 0x00) //²»ÊÇI¿é
+ {
+ switch(T01CurrentIccInfo->MRcvBuffer[1] & 0x0f)
+ {
+ case 0:
+ return TCL_OTHERERR;
+ case 1:
+ return TCL_CRCERR;
+ case 2:
+ return TCL_OTHERERR;
+ }
+ }
+ //block number equal
+ if(T01CurrentIccInfo->blknr != ((T01CurrentIccInfo->MRcvBuffer[1]>>6)&0x01) )
+ {
+ // Error: block number not equal.
+ return (TCL_FATAL_PROTOCOL);
+ }
+ T01CurrentIccInfo->blknr ^= 1; // Toggle block number
+
+ if((ResponseLength-4) == T01CurrentIccInfo->MRcvBuffer[2])
+ {
+ *rec_buf = T01CurrentIccInfo->MRcvBuffer+3;
+ wCardStatus = T01CurrentIccInfo->MRcvBuffer[ResponseLength-3]<<8 | T01CurrentIccInfo->MRcvBuffer[ResponseLength-2];
+ *rec_buf_len = ResponseLength - 4;
+ }
+ else
+ {
+ wCardStatus = TCL_FATAL_PROTOCOL;//ÒÔºó´Óж¨Òå
+ }
+ return wCardStatus;
+ }
+
+/*
+**************************************************************************************************************
+* T1 Ð Òé Êý ¾Ý ´« ËÍ Óë ½Ó ÊÕ
+*
+* Ãè Êö£ºISO7816 T=1´«ÊäÐÒéÊý¾Ý½»»»£¬Ö÷ÒªÊÇͨ¹ý7816ͨ¹ý¿ÚÏß·¢ËÍÊý¾Ý²¢½ÓÊÕÊý¾Ý ÔÝûÓÐʹÓÃ???
+*
+* ²Î Êý£º
+* cid ÔÝûÓÐʹÓÃ?
+* nad_send
+* ich ic¿¨½Ó¿Ú¶¨Òå ϲãÐÒéÑ¡Ôñ
+*
+* ·µ »Ø£º²Ù×÷³É¹¦»òʧ°Ü״̬Âë
+*
+**************************************************************************************************************
+*/
+ unsigned short T1IFSC( unsigned char cid, unsigned char nad_send, int ich )
+ {
+ short wCardStatus=0, wProtocolStatus=0;
+ unsigned char Send_length,ResponseLength;
+
+ T01CurrentIccInfo->MSndBuffer[0] = nad_send;
+ T01CurrentIccInfo->MSndBuffer[1] = 0xC1; //IFSC Request
+ T01CurrentIccInfo->MSndBuffer[2] = 1;
+ T01CurrentIccInfo->MSndBuffer[3] = T01CurrentIccInfo->IFSI;
+ Send_length = 4;
+ if(T01CurrentIccInfo->Crc==1)
+ {
+ CalCrc16(T01CurrentIccInfo->MSndBuffer,T01CurrentIccInfo->MSndBuffer+Send_length,Send_length);
+ Send_length += 2;
+ }
+ else
+ {
+ T01CurrentIccInfo->MSndBuffer[Send_length] = XOR(T01CurrentIccInfo->MSndBuffer,Send_length);
+ Send_length += 1;
+ }
+
+ // Communicate the prepared buffer to the card and get its response.
+ wProtocolStatus = T1_TPDU(T01CurrentIccInfo->MSndBuffer,Send_length,T01CurrentIccInfo->MRcvBuffer,&ResponseLength,ich);
+ if( wProtocolStatus != TCL_OK )
+ {
+ // Error: could not exchange info blocks with the card.
+ return (wProtocolStatus);
+ }
+ if( (ResponseLength < 4) || (ResponseLength > 254))
+ {
+ // Error: block with inappropriate number of bytes received from the card.
+ return TCL_FATAL_PROTOCOL;
+ }
+
+ if(nad_send != T01CurrentIccInfo->MRcvBuffer[0])
+ {
+ // Error: nad not equal.
+ return ( TCL_NADINVALID );
+ }
+ if(T01CurrentIccInfo->Crc != 0)
+ {
+ wCardStatus = TCL_FATAL_PROTOCOL;//ÒÔºó´Óж¨Òå
+ }
+
+ if(XOR(T01CurrentIccInfo->MRcvBuffer,ResponseLength) != 0) //½øÐÐLRCУÑé
+ {
+ return ( TCL_CRCERR );
+ }
+ if((T01CurrentIccInfo->MRcvBuffer[1] & 0xE1) != 0xE1) //²»ÊÇS¿éIFSC Ack
+ {
+ return TCL_OTHERERR;
+ }
+ return wCardStatus;
+ }
+
diff --git a/icc_apdu_lib/T0T1.h b/icc_apdu_lib/T0T1.h
new file mode 100644
index 0000000..521a610
--- /dev/null
+++ b/icc_apdu_lib/T0T1.h
@@ -0,0 +1,207 @@
+/*
+**************************************************************************************************************
+* ISO7816-1 T0,T1(Á´ · ²ã,Ó² ¼þ ½Ó ¿Ú ²ã ) ´« Êä Ð Òé Çý ¶¯
+*
+* _____ ISO7816-2 Á´ · ²ã Ó² ¼þ ½Ó ¿Ú ²ã Çý ¶¯_____
+*
+* Ãè Êö£º Ö÷ÒªÍê³É T0,T1(Êý¾ÝÁ´Â·²ã)´«ÊäÐÒé Êý¾Ý½»»»
+*
+* Åä Öãº
+* CPU :
+* ÍâʱÖÓ :
+* CPUÔËÐÐʱÖÓ :
+* ÔËÐл·¾³ : Keil ARM ( RealView MDK ) v3.50ÆÆ½â°æ±¾
+* »·¾³ÉèÖà : 1) ģʽ:
+* 2) ÓÅ»¯: ĬÈÏ ( Level 0 (-00) ...)
+*
+* ×¢ Ò⣺ T0,T1´«ÊäÐÒé·ûºÏISO7816-2£¬EMV±ê×¼£»
+*
+* ²ã Ãû£º T0T1.H
+*
+* ×÷ Õߣº Zhang_OS@163.com
+*
+* °æ ±¾£º V2.0
+*
+* ÈÕ ÆÚ£º 2009-05-21
+*
+* Copyright (c) 2008-2009 Brand-NEW C.A.P Electronics Technology CO.,LTD
+*
+**************************************************************************************************************
+*/
+
+#ifndef __T0T1_H__
+#define __T0T1_H__
+
+
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+
+
+/*
+**************************************************************************************************************
+* Àà ÐÍ
+**************************************************************************************************************
+*/
+//========>>IC¿¨µ±Ç°×´Ì¬½á¹¹Ì嶨Òå
+ typedef struct
+ {
+ unsigned char TS; //ATR-TS ½ö½ÓÊÜ3bºÍ3f
+ unsigned char T0; //ATR-T0
+ unsigned char TD1; //ATR-TD1 ÊÇ·ñ»¹Òª·¢Ë͸ü¶àµÄ½Ó¿Ú×Ö½ÚÒÔ¼°ºóÐø´«ÊäËùʹÓõÄÐÒéÀàÐÍ,(½öÖ§³Ö0ºÍ1ÐÒé0x81£¬¾Ü¾øÆäËûÖµ)
+ unsigned char TD2; //ATR-TD2 TD2±íʾÊÇ·ñ»¹Òª·¢Ë͸ü¶àµÄ½Ó¿Ú×Ö½ÚÒÔ¼°ºóÐø´«ÊäËùʹÓõÄÐÒéÀàÐÍ(0x31)
+ unsigned char ETCK; //ATR-TCK ¼ìÑ鸴λӦ´ðÆÚ¼äËù·¢ËÍÊý¾ÝÍêÕûÐÔ
+ unsigned char T; //ÐÒéÀàÐÍ T=0 T=1
+ unsigned char EXDI; //·Ç±ê×¼¸´Î»Ó¦´ðÐòÁеIJ¨ÌØÂÊϵÊý
+ unsigned char SPMOD;//ÌØ¶¨Ä£Ê½ »¹ÊÇ ½»»¥Ä£Ê½ b8=0ÓиıäÄÜÁ¦£¬=1Î޸ıäÄÜÁ¦£»b5=1²»ÓɽӿÚ×Ö½Ú¶¨Ò壬=0½Ó¿Ú×Ö½Ú¶¨Ò壻b4-b1 ÐÒéT
+ unsigned char FI; //ʱÖÓÆµÂÊת»»Òò
+ unsigned char DI; //±ÈÌØÂʵ÷½ÚÒò×Ó
+ unsigned char WI; //IC¿¨·¢Ë͵ÄÈÎÒâÒ»¸ö×Ö·ûÆðʼλÉÏÉýÑØÓëÓÉIC¿¨»òÖÕ¶Ë´«Ë͵Äǰһ×Ö·ûµÄÆðʼλÉÏÉýÑØÖ®¼äµÄ×î´ó¼ä¸ôµÄ¹¤×÷µÈ´ýʱ¼ä
+ unsigned char PI1; //È·¶¨IC¿¨ËùÐèµÄ×î´ó±à³ÌµçѹPÖµ¡£PI1=0±íʾIC¿¨²»Ê¹ÓÃVpp¡£
+ unsigned char II; //I1ÔÚb6~b7λÖж¨Ò壬ÓÃÓÚÈ·¶¨IC¿¨ËùÐèµÄ×î´ó±à³ÌµçÁ÷IÖµ¡£PI1=0±íʾ²»Ê¹Óô˲ÎÊý
+ unsigned char N; //TC1´«ËÍNÖ®Öµ£¬NΪ¶îÍâ±£»¤Ê±¼ä
+ unsigned char IFSI; //±íʾIC¿¨ÐÅÏ¢Óò´óСµÄ³õʼֵÕûÊý
+ unsigned char BWI; //¿éµÈ´ýʱ¼äÕûÊý(Block Waiting Time Integer)
+ unsigned char CWI; //×Ö·ûµÈ´ýʱ¼äÕûÊý(Character Waiting Time Integer)
+ unsigned char Crc; //ÈßÓàУÑé(CRC=1/Longitudinal Redundancy Check=0)
+ unsigned char blknr;//¿ìµÄÐòÁкÅ
+ unsigned char *MSndBuffer; //·¢ËÍÃüÁ³åÇø
+ unsigned char *MRcvBuffer; //½ÓÊÕÃüÁ³åÇø
+
+ int ICErrorCode; //¿¨´íÎó´úÂë ICCard_error_Msg[]
+ }ICCSTRUCT;
+
+/*
+**************************************************************************************************************
+* ±ä Á¿
+**************************************************************************************************************
+*/
+ extern ICCSTRUCT *T01CurrentIccInfo; /* IC¿¨µ±Ç°×´Ì¬¶¨Òå */
+
+/*
+**************************************************************************************************************
+* º¯ Êý
+**************************************************************************************************************
+*/
+
+/*
+**************************************************************************************************************
+* ´«Êä²ã½Ó¿Ú--λÓÚÓ²¼þÇý¶¯³ÌÐòÖÐ ISOUSARTDriver.C ---> (1)
+**************************************************************************************************************
+*/
+ extern unsigned short ICC_PowerOnCard( int ich ); /* ¿¨ ÉÏ µç ²¢ ¸´ λ */
+
+ extern void ICC_PowerOffCard( int ich ); /* ¿¨ Ï µç ´¥ µã ÊÍ ·Å */
+
+ extern unsigned short ICC_ResetCard( int ich ); /* ¿¨ ÈÈ ¸´ λ (À临λ) */
+
+ extern unsigned short T0_TPDU( unsigned char *scmd, unsigned char *sdata, int ctl,
+ unsigned char *rec_bytelen, int ich );
+ /* T0 Ð Òé ´« Êä Êý ¾Ý µ¥ Ôª Ó³ Éä */
+ extern unsigned short T1_TPDU( unsigned char *send_data, unsigned char send_bytelen,
+ unsigned char *rec_data, unsigned char *rec_bytelen, int ich );
+ /* T1 Ð Òé ´« Êä Êý ¾Ý µ¥ Ôª Ó³ Éä */
+
+//========>>´«Êä²ã½Ó¿Ú--λÓÚÓ²¼þÇý¶¯³ÌÐòÖÐ --> ISOUSARTDriver.C
+/*
+**************************************************************************************************************
+* ¿¨ ÉÏ µç ²¢ ¸´ λ
+* Function Name : ICC_PowerOnCard
+* Object : ¿¨Éϵç,¸´Î» Ö÷ÒªÊÇʹÓÃÒÔLTC1756оƬʱʹÓÃ
+* Input Parameters : ich =
+* Output Parameters : ·µ»ØÖµ£ºICErrorCode
+* Functions called : none
+*
+**************************************************************************************************************
+*/
+// unsigned short ICC_PowerOnCard( int ich )
+/*
+**************************************************************************************************************
+* ¿¨ Ï µç ´¥ µã ÊÍ ·Å
+* Function Name : ICC_PowerOffCard
+* Object : ¿¨Ïµç Ðè·ûºÏISO7816-2±ê×¼£¬VCC<0.4VÐèÒªÓ²¼þµÄÅäºÏʵÏÖ
+* Input Parameters : ich = CHNL_ICC/PSAM1_POWER/PSAM2_POWER_ON
+* Output Parameters : none
+* Functions called : none
+*
+**************************************************************************************************************
+*/
+// void ICC_PowerOffCard( int ich )
+/*
+**************************************************************************************************************
+* ¿¨ ÈÈ ¸´ λ (À临λ)
+* Function Name : ICC_ResetCard
+* Object : ¿¨Èȸ´Î» (À临룬Á½Õß±¾Öʶ¼Ò»Ñù£¬Ö»ÊÇÖ´ÐеÄÌõ¼þ²»Ò»Ñù)¡£¸´Î»Ó¦´ð·ûºÏISO7816 EMV2000
+* ±ê×¼.
+* Input Parameters : ich = CHNL_ICC/PSAM1_POWER/PSAM2_POWER_ON
+* Output Parameters : ·µ»ØÖµ£ºICErrorCode
+* Functions called : none
+*
+**************************************************************************************************************
+*/
+// unsigned short ICC_ResetCard( int ich )
+/*
+**************************************************************************************************************
+* T0 Ð Òé ´« Êä Êý ¾Ý µ¥ Ôª Ó³ Éä
+* Function Name : ICC_TPDU
+* Object : ÐÒé´«ÊäÊý¾Ýµ¥ÔªÓ³Éä
+* Input Parameters : scmd=5×Ö½ÚÃüÁî×Ö·û´®Ö¸Õ루CLA¡¢INS¡¢P1¡¢P2ºÍP3£©,
+* sdata=·¢ËÍ/½ÓÊÕÊý¾Ý»º³åÈ¥Ö¸Õ룬ctl=ÐÒé¿ØÖÆ×Ö·û£¨¼ûÏÂÊö£©, *rec_bytelen½ÓÊÜÊý¾ÝµÄ³¤¶È£¬ich=IC¿¨½Ó¿Ú
+* ctl=0ÎÞÊý¾ÝÖ¡scmd[4]=0, ctl=1·¢ËÍÊý¾ÝÖ¡/Ö¡³¤¶ÈÓÉscmd[4]È·¶¨, ctl=2½ÓÊÕÊý¾ÝÖ¡
+* Output Parameters : ·µ»ØICErrorCode=SW1 SW2»òÕß0-255µÄÎïÀí²ã´íÎó´úÂë
+* Functions called : none
+*
+**************************************************************************************************************
+*/
+// unsigned short T0_TPDU( unsigned char *scmd, unsigned char *sdata, int ctl, unsigned char *rec_bytelen, int ich )
+/*
+**************************************************************************************************************
+* T1 Ð Òé ´« Êä Êý ¾Ý µ¥ Ôª Ó³ Éä
+* Function Name : T1_TPDU
+* Object : T=1 ÐÒé´«ÊäÊý¾Ýµ¥ÔªÓ³Éä
+* Input Parameters :
+* Output Parameters : ·µ»ØICErrorCode=SW1 SW2»òÕß0-255µÄÎïÀí²ã´íÎó´úÂë
+* Functions called : none
+*
+**************************************************************************************************************
+*/
+// unsigned short T1_TPDU( unsigned char *send_data, unsigned char send_bytelen, unsigned char *rec_data,
+// unsigned char *rec_bytelen, int ich )
+
+
+
+/*
+**************************************************************************************************************
+* ¶ÔÍ⿪·ÅµÄµ÷Óà T0T1.C ---> (2)
+**************************************************************************************************************
+*/
+ extern void ResetIccInfo( unsigned char cid, ICCSTRUCT *info );
+ /* */
+ extern unsigned short T0PowerOnCard( int ich ); /* */
+
+ extern void T0PowerOffCard( int ich ); /* */
+
+ extern unsigned short T0ResetCard( int ich, ICCSTRUCT *Info );
+ /* */
+ extern unsigned short T0Exchange( unsigned char *snd_buf, unsigned char snd_buf_len,
+ unsigned char **rec_buf, unsigned char *rec_buf_len, int ich );
+ /* */
+ extern unsigned short T1Exchange( unsigned char cid, unsigned char nad_send,
+ unsigned char *snd_buf, unsigned char snd_buf_len,
+ unsigned char **rec_buf, unsigned char *rec_buf_len, int ich );
+ /* */
+ extern unsigned short T1IFSC( unsigned char cid, unsigned char nad_send, int ich );
+ /* */
+
+//========>>¶ÔÍ⿪·ÅµÄµ÷Óà --> T0T1.C
+
+
+
+
+
+
+
+#endif //__T0T1_H__
+
diff --git a/icc_apdu_lib/TCL.C b/icc_apdu_lib/TCL.C
new file mode 100644
index 0000000..74d6678
--- /dev/null
+++ b/icc_apdu_lib/TCL.C
@@ -0,0 +1,502 @@
+/*
+**************************************************************************************************************
+* ISO7816-1 T=CL(Á´ · ²ã) ´« Êä Ð Òé Çý ¶¯
+*
+* _____ ISO7816-2 Á´ · ²ã Çý ¶¯_____
+*
+* Ãè Êö£º Ö÷ÒªÍê³É T=CL(Êý¾ÝÁ´Â·²ã)´«ÊäÐÒé Êý¾Ý½»»» T=CL FCD
+*
+* Åä Öãº
+* ÔËÐл·¾³ : Keil ARM ( RealView MDK ) v3.05ÆÆ½â°æ±¾
+* »·¾³ÉèÖà : 1) ģʽ: Thumb-Mode + Use Cross-Module Optimization
+* 2) ÓÅ»¯: ĬÈÏ ( Level 0 (-00) ...)
+*
+* ×¢ Ò⣺ T=CL ´«ÊäÐÒé·ûºÏISO14443±ê×¼£»
+*
+* ²ã Ãû£º TCL.C
+*
+* ×÷ Õߣº Zhang_OS@163.com
+*
+* °æ ±¾£º V1.0
+*
+* ÈÕ ÆÚ£º 2008-04-07
+*
+* Copyright (c) 2008 Brand-NEW C.A.P Electronics Technology CO.,LTD
+*
+**************************************************************************************************************
+*/
+
+ #include "LIB_Includes.H"
+
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+ const unsigned int fsdTable[9] = {16,24,32,40,48,64,96,128,256};
+
+
+
+/*
+**************************************************************************************************************
+* Àà ÐÍ
+**************************************************************************************************************
+*/
+
+
+/*
+**************************************************************************************************************
+* ±ä Á¿
+**************************************************************************************************************
+*/
+// extern unsigned char ucMemPool[]; /* ICC_APDU_MaperÖж¨Òå¹ý */
+// extern unsigned char scMemPool[]; /* ICC_APDU_MaperÖж¨Òå¹ý */
+
+ PICCSTRUCT *TclCurrentPiccInfo; /* TCL µ±Ç°IC¿¨ÐÅÏ¢ */
+// TTLSTRUCT gICCInfo[3]; /* 3¸ö²å²Û */
+
+/*
+**************************************************************************************************************
+* º¯ Êý
+**************************************************************************************************************
+*/
+
+//extern void RFI_CfgSPIForRFCard(void);
+extern void SetBitMask(unsigned char reg,unsigned char mask);
+extern void ClearBitMask(unsigned char reg,unsigned char mask);
+/*
+**************************************************************************************************************
+* ¸´ λ PICC »ù ±¾ ЊϢ
+*
+* Ãè Êö£º ¸´Î»PICCµÄ»ù±¾ÐÅÏ¢,»Ö¸´ËùÓбäÁ¿µÄÖµ Sends the RATS command and parses the ATS
+*
+* ²Î Êý£º cid : ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+* info : RF¿¨Í¨ÐÅÐÅÏ¢Êý¾Ý½á¹¹
+*
+* ·µ »Ø£º ÎÞ
+*
+**************************************************************************************************************
+*/
+ void ResetPiccInfo( unsigned char cid, PICCSTRUCT *info )
+ {
+ info->cid = cid;
+ info->fsci = TCLFSDSNDMAX;
+ info->fsdi = TCLFSDRECMAX;
+ info->fsc = fsdTable[info->fsci];
+ info->fsd = fsdTable[info->fsdi];
+ info->fwi = 4;
+ info->wtx = 0;
+ info->cidSupp = 1;
+ info->nadSupp = 0;
+ info->piccDiv = 0;
+ info->pcdDiv = 0;
+ info->blknr = 0;
+ info->dsi = 3; //divider PICC -> PCD
+ info->dri = 3; //divider PCD -> PICC
+ info->MSndBuffer = ucMemPool; //·¢ËÍÃüÁ³åÇø Óû§¿¨»º³åÇø ǰÌ᣺·Ç½Ó´¥¿¨¶¼ÊÇÓû§¿¨
+ info->MRcvBuffer = ucMemPool; //½ÓÊÕÃüÁ³åÇø
+ }
+
+/*
+**************************************************************************************************************
+* »ñ È¡ ATS
+*
+* Ãè Êö£º »ñ È¡ ATS Sends the RATS command and parses the ATS
+*
+* ²Î Êý£º cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+* info RF¿¨Í¨ÐÅÐÅÏ¢Êý¾Ý½á¹¹
+*
+* ·µ »Ø£º status
+* TCL_OK
+* TCL_ATSLEN ATS of invalid length
+* TCL_ATS_FORMAT_ERR Error in ATS Format.
+* MI_RECBUF_OVERFLOW ATS buffer too small.
+*
+**************************************************************************************************************
+*/
+ unsigned short TclGetAts( unsigned char cid, PICCSTRUCT *Info )
+ {
+ unsigned short status;
+ unsigned char TL,T0,i=2;
+ unsigned short ats_len=MEMORY_BUFFER_SIZE;
+
+ HW_SPI_RF_CfgInit();
+
+ TclCurrentPiccInfo = Info; // intialize pointer to Picc info structure
+ // Global pointer to the currently selected Picc
+ // for used in other routine.
+
+ TclCurrentPiccInfo->fsdi = TCLFSDRECMAX;
+ TclCurrentPiccInfo->fsd = fsdTable[TCLFSDRECMAX];
+
+ if (cid > 14)
+ return TCL_CIDINVALID;
+
+ TclCurrentPiccInfo->MSndBuffer[0]=0xE0; // RATS commands
+ //TclCurrentPiccInfo->MSndBuffer[1]=TclCurrentPiccInfo->fsdi; // FSDI & CID
+ TclCurrentPiccInfo->MSndBuffer[1]=(TclCurrentPiccInfo->fsdi<<4)|cid; // FSDI & CID
+ if((status=Mf500PiccExchangeBlock(TclCurrentPiccInfo->MSndBuffer,4,TclCurrentPiccInfo->MRcvBuffer,&ats_len,1,641))==MI_OK) // length incl CRC
+ {
+ /* ATS received */
+ TL = TclCurrentPiccInfo->MRcvBuffer[0];
+ if (TL)
+ {
+ T0 = TclCurrentPiccInfo->MRcvBuffer[1];
+ TclCurrentPiccInfo->fsci = T0&0x0f; //max PICC receive lenght
+ TclCurrentPiccInfo->fsc = fsdTable[Info->fsci];
+
+ // TA received?
+ if (T0&0x40){
+ TclCurrentPiccInfo->piccDiv = TclCurrentPiccInfo->MRcvBuffer[i++];
+ }
+ else {
+ TclCurrentPiccInfo->piccDiv = 0; // default value
+ }
+ // TB received?
+ if (T0&0x20){
+ TclCurrentPiccInfo->fwi = (TclCurrentPiccInfo->MRcvBuffer[i++]>>4)&0x0f;
+ }
+ else {
+ Info->fwi = 4; // default value
+ }
+ // TC received?
+ if (T0&0x10){
+ TclCurrentPiccInfo->cidSupp = (TclCurrentPiccInfo->MRcvBuffer[i]>>1)&0x01;
+ TclCurrentPiccInfo->nadSupp = (TclCurrentPiccInfo->MRcvBuffer[i++])&0x01;
+ }
+ else {
+ TclCurrentPiccInfo->cidSupp = 1; // default value
+ TclCurrentPiccInfo->nadSupp = 0; // default value
+ }
+ TclCurrentPiccInfo->cid = cid;
+ TclCurrentPiccInfo->blknr = 0;
+ // application specific data available?
+// if (i != TL){
+// *app_inf_len = TL - i;
+// app_inf = &MRcvBuffer[i];
+// }
+// else {
+// *app_inf_len = 0;
+// }
+// if (i != TL)
+// printf("PICC ATRC = %s\n\r",TclCurrentPiccInfo->MRcvBuffer+i);
+ }
+ else
+ status = TCL_ATSLEN;
+ }
+ else
+ if(status != MI_NOTAGERR)
+ status = TCL_2LAYER_ERR;
+
+ return status;
+ }
+
+/*
+**************************************************************************************************************
+* IC ¿¨ PPS
+*
+* Ãè Êö£º IC¿¨ PPS Sends the Protocol and Parameter selection and checks the answer.
+* If a valid PPS response is received it calls PcdSetAttrib() with dsi and dri.
+* There is no retry attempt.
+*
+* ²Î Êý£º cid ¿¨IDºÅ cid of target picc
+* dsi Divider Send Integer to switch to
+* dri Divider Receive Integer to switch to
+*
+* ·µ »Ø£º TCL.. PPS specific error code
+*
+**************************************************************************************************************
+*/
+ unsigned short TclPps( unsigned char cid, unsigned char dsi, unsigned char dri )
+ {
+ unsigned short status;
+ unsigned short bResponseLength;
+
+ HW_SPI_RF_CfgInit();
+
+ if (cid > 14)
+ return TCL_CIDINVALID;
+
+ TclCurrentPiccInfo->MSndBuffer[0]=0xD0|cid; // PPS commands & CID
+ TclCurrentPiccInfo->MSndBuffer[1]=0x11;
+ TclCurrentPiccInfo->MSndBuffer[2]=dsi<<2 | dri;
+
+ //WriteRC(RegChannelRedundancy,0x0F);
+ WriteRC(ModeReg, 0x01);
+ SetBitMask(TxModeReg, 0x80);
+ SetBitMask(RxModeReg, 0x80);
+ ClearBitMask(RFU1D, 0x10);
+ PcdSetTmo(32*(1<<TclCurrentPiccInfo->fwi)+1); //080512
+
+ status = (short) ExchangeByteStream(PCD_TRANSCEIVE, TclCurrentPiccInfo->MSndBuffer,
+ 3, TclCurrentPiccInfo->MRcvBuffer, &bResponseLength);
+ if( status != MI_OK )
+ {
+ // Error: could not exchange info blocks with the card.
+ if(status != MI_NOTAGERR)
+ status = TCL_2LAYER_ERR;
+ return status;
+ }
+ if(bResponseLength != 1)
+ status = TCL_PPS_FORMAT;
+ if(TclCurrentPiccInfo->MRcvBuffer[0] != 0xD0)
+ status = TCL_PPS_FORMAT;
+
+ return status;
+ }
+
+/*
+**************************************************************************************************************
+* TCL Êý ¾Ý ½» »»
+*
+* Ãè Êö£º TCL Êý ¾Ý ½» »»
+* Exchanges Data with the Picc using the dividers set either during
+* the activation sequence or with TclPps(). On transmission errors like
+* a EDC check error or a Timeout it tries to retransmit
+* data up to 'maxRetries' times specified in TclInit,
+* then it tries to deslect the picc.
+*
+* ²Î Êý£º
+* IN: unsigned char cid cid of target picc
+* IN: unsigned char nad_send Node ADdress for sending
+* IN: unsigned char *snd_buf send data buffer
+* IN: unsigned long snd_buf_len send data length
+* IN: unsigned long ExpectedResponseLength
+*
+* IN/OUT: unsigned long *rec_buf_len rec buf size & rec'd data length
+*
+* OUT: unsigned char *nad_receive Received Node ADdress
+* OUT: unsigned char *rec_buf receive data buffer
+*
+* ·µ »Ø£º TCL_OK Sucess
+* TCL_TRANSMERR_HALTED Error during transmission,
+* Picc was deselected successfully.
+* TCL_TRANSMERR_NOTAG Error during transmission,
+* Picc could not be deselected and is
+* ignoerd.
+* MI_RECBUF_OVERFLOW more than *rec_buf_len bytes rec'd
+*
+**************************************************************************************************************
+*/
+ unsigned short TclExchange( unsigned char cid, unsigned char nad_send, unsigned char *snd_buf,
+ unsigned char snd_buf_len, unsigned char ExpectedResponseLength,
+ unsigned char **rec_buf, unsigned char *rec_buf_len )
+ {
+ short wCardStatus=0, wProtocolStatus=0;
+ unsigned short bResponseLength,BufIndex;
+
+ HW_SPI_RF_CfgInit();
+
+ BufIndex = 0;
+ TclCurrentPiccInfo->MSndBuffer[BufIndex++] = 0x02 | TclCurrentPiccInfo->blknr;
+ if(TclCurrentPiccInfo->cidSupp)
+ {
+ TclCurrentPiccInfo->MSndBuffer[0] |= 0x08;
+ TclCurrentPiccInfo->MSndBuffer[BufIndex++] = cid;
+ }
+ if(TclCurrentPiccInfo->nadSupp)
+ {
+ TclCurrentPiccInfo->MSndBuffer[0] |= 0x04;
+ TclCurrentPiccInfo->MSndBuffer[BufIndex++] = nad_send;
+ }
+ memcpy(&(TclCurrentPiccInfo->MSndBuffer[BufIndex]),snd_buf,snd_buf_len);
+
+ // Communicate the prepared buffer to the card and get its response.
+ // RxCRC and TxCRC enable, parity enable
+ //WriteRC(RegChannelRedundancy,0x0F);
+ WriteRC(ModeReg, 0x01);
+ SetBitMask(TxModeReg, 0x80);
+ SetBitMask(RxModeReg, 0x80);
+ ClearBitMask(RFU1D, 0x10);
+// PcdSetTmo(32*(1<<TclCurrentPiccInfo->fwi)); //080215
+ PcdSetTmo(32*(1<<TclCurrentPiccInfo->fwi)+1); //080512
+
+ wProtocolStatus = (short) ExchangeByteStream(PCD_TRANSCEIVE, TclCurrentPiccInfo->MSndBuffer,
+ snd_buf_len+BufIndex, TclCurrentPiccInfo->MRcvBuffer, &bResponseLength);
+
+ if( wProtocolStatus != MI_OK )
+ {
+ // Error: could not exchange info blocks with the card.
+ if(wProtocolStatus != MI_NOTAGERR)
+ wProtocolStatus = TCL_2LAYER_ERR;
+ return (wProtocolStatus);
+ }
+
+ // Check if received block is a S-block for WTX
+ while( (TclCurrentPiccInfo->MRcvBuffer[0]&0xf0) == 0xf0 )
+ {
+ TclCurrentPiccInfo->MSndBuffer[0] = 0xfa;
+ TclCurrentPiccInfo->MSndBuffer[1] = cid;
+ TclCurrentPiccInfo->MSndBuffer[2] = TclCurrentPiccInfo->MSndBuffer[2]&0x3f;
+
+ // Communicate the prepared buffer to the card and get its response.
+ wProtocolStatus = (short)ExchangeByteStream(PCD_TRANSCEIVE, TclCurrentPiccInfo->MSndBuffer,
+ 3, TclCurrentPiccInfo->MRcvBuffer, &bResponseLength);
+ if( wProtocolStatus != MI_OK )
+ {
+ // Error: could not exchange info blocks with the card.
+ if(wProtocolStatus != MI_NOTAGERR)
+ wProtocolStatus = TCL_2LAYER_ERR;
+ return (wProtocolStatus);
+ }
+ }
+ if(TclCurrentPiccInfo->blknr == (TclCurrentPiccInfo->MRcvBuffer[0]|0x01) ) //block number equal
+ {
+ // Error: block number not equal.
+ return (TCL_FATAL_PROTOCOL);
+ }
+ TclCurrentPiccInfo->blknr ^= 1; // Toggle block number
+
+ BufIndex = 1;
+ if(TclCurrentPiccInfo->MRcvBuffer[0] & 0x08)
+ {
+ if(cid != TclCurrentPiccInfo->MSndBuffer[BufIndex++])
+ {
+ // Error: cid not equal.
+ return (TCL_CIDINVALID);
+ }
+ }
+ if(TclCurrentPiccInfo->MRcvBuffer[0] & 0x04)
+ {
+ if(nad_send != TclCurrentPiccInfo->MSndBuffer[BufIndex++])
+ {
+ // Error: nad not equal.
+ return ( TCL_NADINVALID );
+ }
+ }
+
+// if( (TclCurrentPiccInfo->MRcvBuffer[0]&0xe0) == 0xa0 )
+// {
+// printf("Chaining\r\n");
+// }
+
+ // Check the length of the response. It must be > 1 and <= sgbMAX_INFO_FRAME_SIZE in all cases.
+ // Substract 4 bytes of T=CL overhead (PCB,CID,CRC16)
+ *rec_buf_len = bResponseLength-2;
+ if( (*rec_buf_len == 0) || (*rec_buf_len > TclCurrentPiccInfo->fsc))
+ {
+ // Error: block with inappropriate number of bytes received from the card.
+ return TCL_FATAL_PROTOCOL;
+ }
+ if(*rec_buf_len >= 2)
+ {
+ *rec_buf = TclCurrentPiccInfo->MRcvBuffer+BufIndex;
+ wCardStatus = *(TclCurrentPiccInfo->MRcvBuffer+BufIndex+*rec_buf_len-2)<<8 | *(TclCurrentPiccInfo->MRcvBuffer+BufIndex+*rec_buf_len-1);
+ *rec_buf_len -= 2;
+ }
+ else
+ {
+ return (TCL_FATAL_PROTOCOL);
+ }
+
+ if(((wCardStatus & 0xf000) != 0x6000) && ((wCardStatus & 0xf000) != 0x9000))
+ { return (TCL_FATAL_PROTOCOL); } //Òþ²ØÓйش«Êä¸ñʽ¡¢Í¨ÐÅÐÒéÏà¹ØµÄ´íÎó 080512
+
+ return wCardStatus;
+ }
+
+/*
+**************************************************************************************************************
+* TCL È¡ Ïû Ñ¡ ¶¨
+*
+* Ãè Êö£º TCL È¡ Ïû Ñ¡ ¶¨
+* Deselects the specified Picc using the divider set previously
+* during the activation sequence or using TclPps().
+* On TCL_TRANSMERR_NOTAG the CID is released and so this picc
+* is ignored.
+*
+* ²Î Êý£º cid ¿¨IDºÅ
+* IN: unsigned char cid cid of the target picc
+*
+* ·µ »Ø£º TCL_OK Picc sucessfully deselected
+ TCL_TRANSMERR_NOTAG Picc couldn't be deselected.
+*
+**************************************************************************************************************
+*/
+ unsigned short TclDeselect( unsigned char cid )
+ {
+ unsigned short status;
+ unsigned short bResponseLength;
+
+ HW_SPI_RF_CfgInit();
+
+ if (cid > 14)
+ return TCL_CIDINVALID;
+
+ TclCurrentPiccInfo->MSndBuffer[0]=0xCA; // DeSelect commands
+ TclCurrentPiccInfo->MSndBuffer[1]=cid;
+
+ //WriteRC(RegChannelRedundancy,0x0F);
+ WriteRC(ModeReg, 0x01);
+ SetBitMask(TxModeReg, 0x80);
+ SetBitMask(RxModeReg, 0x80);
+ ClearBitMask(RFU1D, 0x10);
+ PcdSetTmo(32*(1<<TclCurrentPiccInfo->fwi)+1); //080512
+
+ status = (short) ExchangeByteStream(PCD_TRANSCEIVE, TclCurrentPiccInfo->MSndBuffer,
+ 2, TclCurrentPiccInfo->MRcvBuffer, &bResponseLength);
+ if( status != MI_OK )
+ {
+ // Error: could not exchange info blocks with the card.
+ if(status != MI_NOTAGERR)
+ status = TCL_2LAYER_ERR;
+ return status;
+ }
+ if(bResponseLength != 2)
+ status = TCL_FATAL_PROTOCOL;
+ if(TclCurrentPiccInfo->MRcvBuffer[0] != 0xCA)
+ status = TCL_FATAL_PROTOCOL;
+
+ return status;
+ }
+
+/*
+**************************************************************************************************************
+* ÔÚÉ䯵¿¨¼ÓµçÇÒ½øÈë144433-4Çé¿öϲâÊÔ¿¨Æ¬µÄ´æÔÚ
+*
+* Ãè Êö£º ÔÚÉ䯵¿¨¼ÓµçÇÒ½øÈë144433-4Çé¿öϲâÊÔ¿¨Æ¬µÄ´æÔÚ
+*
+* ²Î Êý£º ¼ì²âCPU¿¨ÊÇ·ñÀ뿪
+*
+* ·µ »Ø£º 0 ¿¨»¹´æÔÚ
+* ·Ç0 ¿¨Æ¬À뿪
+*
+**************************************************************************************************************
+*/
+ unsigned char PICC_TclCheckRFRounge( void )
+ {
+ short wProtocolStatus=0;
+ unsigned short bResponseLength;
+ unsigned char cid=0; //×¢Òâ
+
+ HW_SPI_RF_CfgInit();
+
+ TclCurrentPiccInfo->MSndBuffer[0] = 0xBA | TclCurrentPiccInfo->blknr;
+ TclCurrentPiccInfo->MSndBuffer[1] = cid;
+
+ // Communicate the prepared buffer to the card and get its response.
+ // RxCRC and TxCRC enable, parity enable
+ //WriteRC( RegChannelRedundancy, 0x0F );
+ WriteRC(ModeReg, 0x01);
+ SetBitMask(TxModeReg, 0x80);
+ SetBitMask(RxModeReg, 0x80);
+ ClearBitMask(RFU1D, 0x10);
+ PcdSetTmo( 32 * ( 1 << TclCurrentPiccInfo->fwi ) );
+
+ wProtocolStatus = ExchangeByteStream( PCD_TRANSCEIVE,
+ TclCurrentPiccInfo->MSndBuffer,
+ 2,
+ TclCurrentPiccInfo->MRcvBuffer,
+ &bResponseLength );
+ if( wProtocolStatus != 0 )
+ {
+ // Error: could not exchange info blocks with the card.
+ return ( 0xF3 );//SLOTERROR_DEACTIVATED_PROTOCOL
+ }
+ // Check if received block is a S-block for WTX
+ if( ( ( TclCurrentPiccInfo->MRcvBuffer[0] & 0xB0 ) == 0xA0 ) ||
+ ( ( TclCurrentPiccInfo->MRcvBuffer[0] & 0xC0 ) == 0x00 ) )
+ { return 0; } //Óп¨´æÔÚ
+ return 0xF3; //SLOTERROR_DEACTIVATED_PROTOCOL;
+ }
+
diff --git a/icc_apdu_lib/TCL.H b/icc_apdu_lib/TCL.H
new file mode 100644
index 0000000..69dc3a1
--- /dev/null
+++ b/icc_apdu_lib/TCL.H
@@ -0,0 +1,246 @@
+/*
+**************************************************************************************************************
+* ISO7816-1 T=CL(Á´ · ²ã) ´« Êä Ð Òé Çý ¶¯
+*
+* _____ ISO7816-2 Á´ · ²ã Çý ¶¯_____
+*
+* Ãè Êö£º Ö÷ÒªÍê³É T=CL(Êý¾ÝÁ´Â·²ã)´«ÊäÐÒé Êý¾Ý½»»» T=CL FCD
+*
+* Åä Öãº
+* CPU :
+* ÍâʱÖÓ :
+* CPUÔËÐÐʱÖÓ :
+* ÔËÐл·¾³ : Keil ARM ( RealView MDK ) v3.50ÆÆ½â°æ±¾
+* »·¾³ÉèÖà : 1) ģʽ:
+* 2) ÓÅ»¯: ĬÈÏ ( Level 0 (-00) ...)
+*
+* ×¢ Ò⣺ T=CL ´«ÊäÐÒé·ûºÏISO14443±ê×¼£»
+*
+* ²ã Ãû£º TCL.H
+*
+* ×÷ Õߣº Zhang_OS@163.com
+*
+* °æ ±¾£º V2.0
+*
+* ÈÕ ÆÚ£º 2009-05-21
+*
+* Copyright (c) 2008-2009 Brand-NEW C.A.P Electronics Technology CO.,LTD
+*
+**************************************************************************************************************
+*/
+#ifndef __TCL_H__
+#define __TCL_H__
+
+/*
+**************************************************************************************************************
+* ³£ Á¿
+**************************************************************************************************************
+*/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* ISO14443 Support Properties
+* Some of the protokoll functions of ISO14443 needs information about
+* the capability of the reader device, which are provided by this
+* constants.
+*/
+//{
+#define TCLFSDSNDMAX 8 ///< max. frame size send
+#define TCLFSDRECMAX 8 ///< max. frame size rcv
+#define TCLDSMAX 3 ///< max. baudrate divider PICC --> PCD
+#define TCLDRMAX 3 ///< max. baudrate divider PCD --> PICC
+
+#define TCLDSDFLT 0 ///< default baudrate divider PICC --> PCD
+#define TCLDRDFLT 0 ///< default baudrate divider PCD --> PICC
+//}
+
+
+#define DEF_FIFO_LENGTH 64 //!< default FIFO size
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*
+**************************************************************************************************************
+* Àà ÐÍ
+**************************************************************************************************************
+*/
+//PICC info struct
+ typedef struct
+ {
+ unsigned char cid;
+ unsigned char fsci;
+ unsigned char fsdi;
+ unsigned int fsc;
+ unsigned int fsd;
+ unsigned char fwi;
+ unsigned char wtx;
+ unsigned char cidSupp;
+ unsigned char nadSupp;
+ unsigned char piccDiv;
+ unsigned char pcdDiv;
+ unsigned char blknr; ////¿ìµÄÐòÁкÅ
+ unsigned char dsi; //divider PICC -> PCD
+ unsigned char dri; //divider PCD -> PICC
+ unsigned char *MSndBuffer; //·¢ËÍÃüÁ³åÇø
+ unsigned char *MRcvBuffer; //½ÓÊÕÃüÁ³åÇø
+ }PICCSTRUCT;
+
+
+/*
+**************************************************************************************************************
+* ±ä Á¿
+**************************************************************************************************************
+*/
+ extern PICCSTRUCT *TclCurrentPiccInfo; // structure pointer for current selected Picc
+
+/*
+**************************************************************************************************************
+* º¯ Êý
+**************************************************************************************************************
+*/
+
+ extern void ResetPiccInfo( unsigned char cid, PICCSTRUCT *info );
+ /* */
+ extern unsigned short TclGetAts( unsigned char cid, PICCSTRUCT *Info );
+ /* */
+ extern unsigned short TclPps( unsigned char cid, unsigned char dsi, unsigned char dri );
+ /* */
+ extern unsigned short TclExchange( unsigned char cid, unsigned char nad_send, unsigned char *snd_buf,
+ unsigned char snd_buf_len, unsigned char ExpectedResponseLength,
+ unsigned char **rec_buf, unsigned char *rec_buf_len );
+ /* */
+ extern unsigned short TclDeselect( unsigned char cid );
+ /* */
+ extern unsigned char PICC_TclCheckRFRounge( void ); /* */
+
+/*
+**************************************************************************************************************
+* ¸´ λ PICC »ù ±¾ ЊϢ
+*
+* Ãè Êö£º ¸´Î»PICCµÄ»ù±¾ÐÅÏ¢,»Ö¸´ËùÓбäÁ¿µÄÖµ Sends the RATS command and parses the ATS
+*
+* ²Î Êý£º cid : ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+* info : RF¿¨Í¨ÐÅÐÅÏ¢Êý¾Ý½á¹¹
+*
+* ·µ »Ø£º ÎÞ
+*
+**************************************************************************************************************
+*/
+// void ResetPiccInfo( unsigned char cid, PICCSTRUCT *info )
+/*
+**************************************************************************************************************
+* »ñ È¡ ATS
+*
+* Ãè Êö£º »ñ È¡ ATS Sends the RATS command and parses the ATS
+*
+* ²Î Êý£º cid ¿¨IDºÅ ½Ó´¥Ê½Ã»ÓÐʲô´Ë²ÎÊý£¬ ·Ç½Ó´¥Ê½Ê¹Óô˲ÎÊý
+* info RF¿¨Í¨ÐÅÐÅÏ¢Êý¾Ý½á¹¹
+*
+* ·µ »Ø£º status
+* TCL_OK
+* TCL_ATSLEN ATS of invalid length
+* TCL_ATS_FORMAT_ERR Error in ATS Format.
+* MI_RECBUF_OVERFLOW ATS buffer too small.
+*
+**************************************************************************************************************
+*/
+// unsigned short TclGetAts( unsigned char cid, PICCSTRUCT *Info )
+/*
+**************************************************************************************************************
+* IC ¿¨ PPS
+*
+* Ãè Êö£º IC¿¨ PPS Sends the Protocol and Parameter selection and checks the answer.
+* If a valid PPS response is received it calls PcdSetAttrib() with dsi and dri.
+* There is no retry attempt.
+*
+* ²Î Êý£º cid ¿¨IDºÅ cid of target picc
+* dsi Divider Send Integer to switch to
+* dri Divider Receive Integer to switch to
+*
+* ·µ »Ø£º TCL.. PPS specific error code
+*
+**************************************************************************************************************
+*/
+// unsigned short TclPps( unsigned char cid, unsigned char dsi, unsigned char dri )
+/*
+**************************************************************************************************************
+* TCL Êý ¾Ý ½» »»
+*
+* Ãè Êö£º TCL Êý ¾Ý ½» »»
+* Exchanges Data with the Picc using the dividers set either during
+* the activation sequence or with TclPps(). On transmission errors like
+* a EDC check error or a Timeout it tries to retransmit
+* data up to 'maxRetries' times specified in TclInit,
+* then it tries to deslect the picc.
+*
+* ²Î Êý£º
+* IN: unsigned char cid cid of target picc
+* IN: unsigned char nad_send Node ADdress for sending
+* IN: unsigned char *snd_buf send data buffer
+* IN: unsigned long snd_buf_len send data length
+* IN: unsigned long ExpectedResponseLength
+*
+* IN/OUT: unsigned long *rec_buf_len rec buf size & rec'd data length
+*
+* OUT: unsigned char *nad_receive Received Node ADdress
+* OUT: unsigned char *rec_buf receive data buffer
+*
+* ·µ »Ø£º TCL_OK Sucess
+* TCL_TRANSMERR_HALTED Error during transmission,
+* Picc was deselected successfully.
+* TCL_TRANSMERR_NOTAG Error during transmission,
+* Picc could not be deselected and is
+* ignoerd.
+* MI_RECBUF_OVERFLOW more than *rec_buf_len bytes rec'd
+*
+**************************************************************************************************************
+*/
+// unsigned short TclExchange( unsigned char cid, unsigned char nad_send, unsigned char *snd_buf,
+// unsigned char snd_buf_len, unsigned char ExpectedResponseLength,
+// unsigned char **rec_buf, unsigned char *rec_buf_len )
+/*
+**************************************************************************************************************
+* TCL È¡ Ïû Ñ¡ ¶¨
+*
+* Ãè Êö£º TCL È¡ Ïû Ñ¡ ¶¨
+* Deselects the specified Picc using the divider set previously
+* during the activation sequence or using TclPps().
+* On TCL_TRANSMERR_NOTAG the CID is released and so this picc
+* is ignored.
+*
+* ²Î Êý£º cid ¿¨IDºÅ
+* IN: unsigned char cid cid of the target picc
+*
+* ·µ »Ø£º TCL_OK Picc sucessfully deselected
+ TCL_TRANSMERR_NOTAG Picc couldn't be deselected.
+*
+**************************************************************************************************************
+*/
+// unsigned short TclDeselect( unsigned char cid )
+/*
+**************************************************************************************************************
+* ÔÚÉ䯵¿¨¼ÓµçÇÒ½øÈë144433-4Çé¿öϲâÊÔ¿¨Æ¬µÄ´æÔÚ
+*
+* Ãè Êö£º ÔÚÉ䯵¿¨¼ÓµçÇÒ½øÈë144433-4Çé¿öϲâÊÔ¿¨Æ¬µÄ´æÔÚ
+*
+* ²Î Êý£º ¼ì²âCPU¿¨ÊÇ·ñÀ뿪
+*
+* ·µ »Ø£º 0 ¿¨»¹´æÔÚ
+* ·Ç0 ¿¨Æ¬À뿪
+*
+**************************************************************************************************************
+*/
+// unsigned char PICC_TclCheckRFRounge( void )
+
+
+
+
+
+
+
+#endif
diff --git a/icc_apdu_lib/des.c b/icc_apdu_lib/des.c
new file mode 100644
index 0000000..640c7c1
--- /dev/null
+++ b/icc_apdu_lib/des.c
@@ -0,0 +1,493 @@
+/*
+ * FIPS-46-3 compliant 3DES implementation
+ *
+ * Copyright (C) 2001-2003 Christophe Devine
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "des.h"
+
+/* the eight DES S-boxes */
+
+const uint32 SB1[64] =
+{
+ 0x01010400, 0x00000000, 0x00010000, 0x01010404,
+ 0x01010004, 0x00010404, 0x00000004, 0x00010000,
+ 0x00000400, 0x01010400, 0x01010404, 0x00000400,
+ 0x01000404, 0x01010004, 0x01000000, 0x00000004,
+ 0x00000404, 0x01000400, 0x01000400, 0x00010400,
+ 0x00010400, 0x01010000, 0x01010000, 0x01000404,
+ 0x00010004, 0x01000004, 0x01000004, 0x00010004,
+ 0x00000000, 0x00000404, 0x00010404, 0x01000000,
+ 0x00010000, 0x01010404, 0x00000004, 0x01010000,
+ 0x01010400, 0x01000000, 0x01000000, 0x00000400,
+ 0x01010004, 0x00010000, 0x00010400, 0x01000004,
+ 0x00000400, 0x00000004, 0x01000404, 0x00010404,
+ 0x01010404, 0x00010004, 0x01010000, 0x01000404,
+ 0x01000004, 0x00000404, 0x00010404, 0x01010400,
+ 0x00000404, 0x01000400, 0x01000400, 0x00000000,
+ 0x00010004, 0x00010400, 0x00000000, 0x01010004
+};
+
+const uint32 SB2[64] =
+{
+ 0x80108020, 0x80008000, 0x00008000, 0x00108020,
+ 0x00100000, 0x00000020, 0x80100020, 0x80008020,
+ 0x80000020, 0x80108020, 0x80108000, 0x80000000,
+ 0x80008000, 0x00100000, 0x00000020, 0x80100020,
+ 0x00108000, 0x00100020, 0x80008020, 0x00000000,
+ 0x80000000, 0x00008000, 0x00108020, 0x80100000,
+ 0x00100020, 0x80000020, 0x00000000, 0x00108000,
+ 0x00008020, 0x80108000, 0x80100000, 0x00008020,
+ 0x00000000, 0x00108020, 0x80100020, 0x00100000,
+ 0x80008020, 0x80100000, 0x80108000, 0x00008000,
+ 0x80100000, 0x80008000, 0x00000020, 0x80108020,
+ 0x00108020, 0x00000020, 0x00008000, 0x80000000,
+ 0x00008020, 0x80108000, 0x00100000, 0x80000020,
+ 0x00100020, 0x80008020, 0x80000020, 0x00100020,
+ 0x00108000, 0x00000000, 0x80008000, 0x00008020,
+ 0x80000000, 0x80100020, 0x80108020, 0x00108000
+};
+
+const uint32 SB3[64] =
+{
+ 0x00000208, 0x08020200, 0x00000000, 0x08020008,
+ 0x08000200, 0x00000000, 0x00020208, 0x08000200,
+ 0x00020008, 0x08000008, 0x08000008, 0x00020000,
+ 0x08020208, 0x00020008, 0x08020000, 0x00000208,
+ 0x08000000, 0x00000008, 0x08020200, 0x00000200,
+ 0x00020200, 0x08020000, 0x08020008, 0x00020208,
+ 0x08000208, 0x00020200, 0x00020000, 0x08000208,
+ 0x00000008, 0x08020208, 0x00000200, 0x08000000,
+ 0x08020200, 0x08000000, 0x00020008, 0x00000208,
+ 0x00020000, 0x08020200, 0x08000200, 0x00000000,
+ 0x00000200, 0x00020008, 0x08020208, 0x08000200,
+ 0x08000008, 0x00000200, 0x00000000, 0x08020008,
+ 0x08000208, 0x00020000, 0x08000000, 0x08020208,
+ 0x00000008, 0x00020208, 0x00020200, 0x08000008,
+ 0x08020000, 0x08000208, 0x00000208, 0x08020000,
+ 0x00020208, 0x00000008, 0x08020008, 0x00020200
+};
+
+const uint32 SB4[64] =
+{
+ 0x00802001, 0x00002081, 0x00002081, 0x00000080,
+ 0x00802080, 0x00800081, 0x00800001, 0x00002001,
+ 0x00000000, 0x00802000, 0x00802000, 0x00802081,
+ 0x00000081, 0x00000000, 0x00800080, 0x00800001,
+ 0x00000001, 0x00002000, 0x00800000, 0x00802001,
+ 0x00000080, 0x00800000, 0x00002001, 0x00002080,
+ 0x00800081, 0x00000001, 0x00002080, 0x00800080,
+ 0x00002000, 0x00802080, 0x00802081, 0x00000081,
+ 0x00800080, 0x00800001, 0x00802000, 0x00802081,
+ 0x00000081, 0x00000000, 0x00000000, 0x00802000,
+ 0x00002080, 0x00800080, 0x00800081, 0x00000001,
+ 0x00802001, 0x00002081, 0x00002081, 0x00000080,
+ 0x00802081, 0x00000081, 0x00000001, 0x00002000,
+ 0x00800001, 0x00002001, 0x00802080, 0x00800081,
+ 0x00002001, 0x00002080, 0x00800000, 0x00802001,
+ 0x00000080, 0x00800000, 0x00002000, 0x00802080
+};
+
+const uint32 SB5[64] =
+{
+ 0x00000100, 0x02080100, 0x02080000, 0x42000100,
+ 0x00080000, 0x00000100, 0x40000000, 0x02080000,
+ 0x40080100, 0x00080000, 0x02000100, 0x40080100,
+ 0x42000100, 0x42080000, 0x00080100, 0x40000000,
+ 0x02000000, 0x40080000, 0x40080000, 0x00000000,
+ 0x40000100, 0x42080100, 0x42080100, 0x02000100,
+ 0x42080000, 0x40000100, 0x00000000, 0x42000000,
+ 0x02080100, 0x02000000, 0x42000000, 0x00080100,
+ 0x00080000, 0x42000100, 0x00000100, 0x02000000,
+ 0x40000000, 0x02080000, 0x42000100, 0x40080100,
+ 0x02000100, 0x40000000, 0x42080000, 0x02080100,
+ 0x40080100, 0x00000100, 0x02000000, 0x42080000,
+ 0x42080100, 0x00080100, 0x42000000, 0x42080100,
+ 0x02080000, 0x00000000, 0x40080000, 0x42000000,
+ 0x00080100, 0x02000100, 0x40000100, 0x00080000,
+ 0x00000000, 0x40080000, 0x02080100, 0x40000100
+};
+
+const uint32 SB6[64] =
+{
+ 0x20000010, 0x20400000, 0x00004000, 0x20404010,
+ 0x20400000, 0x00000010, 0x20404010, 0x00400000,
+ 0x20004000, 0x00404010, 0x00400000, 0x20000010,
+ 0x00400010, 0x20004000, 0x20000000, 0x00004010,
+ 0x00000000, 0x00400010, 0x20004010, 0x00004000,
+ 0x00404000, 0x20004010, 0x00000010, 0x20400010,
+ 0x20400010, 0x00000000, 0x00404010, 0x20404000,
+ 0x00004010, 0x00404000, 0x20404000, 0x20000000,
+ 0x20004000, 0x00000010, 0x20400010, 0x00404000,
+ 0x20404010, 0x00400000, 0x00004010, 0x20000010,
+ 0x00400000, 0x20004000, 0x20000000, 0x00004010,
+ 0x20000010, 0x20404010, 0x00404000, 0x20400000,
+ 0x00404010, 0x20404000, 0x00000000, 0x20400010,
+ 0x00000010, 0x00004000, 0x20400000, 0x00404010,
+ 0x00004000, 0x00400010, 0x20004010, 0x00000000,
+ 0x20404000, 0x20000000, 0x00400010, 0x20004010
+};
+
+const uint32 SB7[64] =
+{
+ 0x00200000, 0x04200002, 0x04000802, 0x00000000,
+ 0x00000800, 0x04000802, 0x00200802, 0x04200800,
+ 0x04200802, 0x00200000, 0x00000000, 0x04000002,
+ 0x00000002, 0x04000000, 0x04200002, 0x00000802,
+ 0x04000800, 0x00200802, 0x00200002, 0x04000800,
+ 0x04000002, 0x04200000, 0x04200800, 0x00200002,
+ 0x04200000, 0x00000800, 0x00000802, 0x04200802,
+ 0x00200800, 0x00000002, 0x04000000, 0x00200800,
+ 0x04000000, 0x00200800, 0x00200000, 0x04000802,
+ 0x04000802, 0x04200002, 0x04200002, 0x00000002,
+ 0x00200002, 0x04000000, 0x04000800, 0x00200000,
+ 0x04200800, 0x00000802, 0x00200802, 0x04200800,
+ 0x00000802, 0x04000002, 0x04200802, 0x04200000,
+ 0x00200800, 0x00000000, 0x00000002, 0x04200802,
+ 0x00000000, 0x00200802, 0x04200000, 0x00000800,
+ 0x04000002, 0x04000800, 0x00000800, 0x00200002
+};
+
+const uint32 SB8[64] =
+{
+ 0x10001040, 0x00001000, 0x00040000, 0x10041040,
+ 0x10000000, 0x10001040, 0x00000040, 0x10000000,
+ 0x00040040, 0x10040000, 0x10041040, 0x00041000,
+ 0x10041000, 0x00041040, 0x00001000, 0x00000040,
+ 0x10040000, 0x10000040, 0x10001000, 0x00001040,
+ 0x00041000, 0x00040040, 0x10040040, 0x10041000,
+ 0x00001040, 0x00000000, 0x00000000, 0x10040040,
+ 0x10000040, 0x10001000, 0x00041040, 0x00040000,
+ 0x00041040, 0x00040000, 0x10041000, 0x00001000,
+ 0x00000040, 0x10040040, 0x00001000, 0x00041040,
+ 0x10001000, 0x00000040, 0x10000040, 0x10040000,
+ 0x10040040, 0x10000000, 0x00040000, 0x10001040,
+ 0x00000000, 0x10041040, 0x00040040, 0x10000040,
+ 0x10040000, 0x10001000, 0x10001040, 0x00000000,
+ 0x10041040, 0x00041000, 0x00041000, 0x00001040,
+ 0x00001040, 0x00040040, 0x10000000, 0x10041000
+};
+
+/* PC1: left and right halves bit-swap */
+
+const uint32 LHs[16] =
+{
+ 0x00000000, 0x00000001, 0x00000100, 0x00000101,
+ 0x00010000, 0x00010001, 0x00010100, 0x00010101,
+ 0x01000000, 0x01000001, 0x01000100, 0x01000101,
+ 0x01010000, 0x01010001, 0x01010100, 0x01010101
+};
+
+const uint32 RHs[16] =
+{
+ 0x00000000, 0x01000000, 0x00010000, 0x01010000,
+ 0x00000100, 0x01000100, 0x00010100, 0x01010100,
+ 0x00000001, 0x01000001, 0x00010001, 0x01010001,
+ 0x00000101, 0x01000101, 0x00010101, 0x01010101,
+};
+
+/* platform-independant 32-bit integer manipulation macros */
+
+#define GET_UINT32(n,b,i) \
+{ \
+ (n) = ( (uint32) (b)[(i) ] << 24 ) \
+ | ( (uint32) (b)[(i) + 1] << 16 ) \
+ | ( (uint32) (b)[(i) + 2] << 8 ) \
+ | ( (uint32) (b)[(i) + 3] ); \
+}
+
+#define PUT_UINT32(n,b,i) \
+{ \
+ (b)[(i) ] = (uint8) ( (n) >> 24 ); \
+ (b)[(i) + 1] = (uint8) ( (n) >> 16 ); \
+ (b)[(i) + 2] = (uint8) ( (n) >> 8 ); \
+ (b)[(i) + 3] = (uint8) ( (n) ); \
+}
+
+/* Initial Permutation macro */
+
+#define DES_IP(X,Y) \
+{ \
+ T = ((X >> 4) ^ Y) & 0x0F0F0F0F; Y ^= T; X ^= (T << 4); \
+ T = ((X >> 16) ^ Y) & 0x0000FFFF; Y ^= T; X ^= (T << 16); \
+ T = ((Y >> 2) ^ X) & 0x33333333; X ^= T; Y ^= (T << 2); \
+ T = ((Y >> 8) ^ X) & 0x00FF00FF; X ^= T; Y ^= (T << 8); \
+ Y = ((Y << 1) | (Y >> 31)) & 0xFFFFFFFF; \
+ T = (X ^ Y) & 0xAAAAAAAA; Y ^= T; X ^= T; \
+ X = ((X << 1) | (X >> 31)) & 0xFFFFFFFF; \
+}
+
+/* Final Permutation macro */
+
+#define DES_FP(X,Y) \
+{ \
+ X = ((X << 31) | (X >> 1)) & 0xFFFFFFFF; \
+ T = (X ^ Y) & 0xAAAAAAAA; X ^= T; Y ^= T; \
+ Y = ((Y << 31) | (Y >> 1)) & 0xFFFFFFFF; \
+ T = ((Y >> 8) ^ X) & 0x00FF00FF; X ^= T; Y ^= (T << 8); \
+ T = ((Y >> 2) ^ X) & 0x33333333; X ^= T; Y ^= (T << 2); \
+ T = ((X >> 16) ^ Y) & 0x0000FFFF; Y ^= T; X ^= (T << 16); \
+ T = ((X >> 4) ^ Y) & 0x0F0F0F0F; Y ^= T; X ^= (T << 4); \
+}
+
+/* DES round macro */
+
+#define DES_ROUND(X,Y) \
+{ \
+ T = *SK++ ^ X; \
+ Y ^= SB8[ (T ) & 0x3F ] ^ \
+ SB6[ (T >> 8) & 0x3F ] ^ \
+ SB4[ (T >> 16) & 0x3F ] ^ \
+ SB2[ (T >> 24) & 0x3F ]; \
+ \
+ T = *SK++ ^ ((X << 28) | (X >> 4)); \
+ Y ^= SB7[ (T ) & 0x3F ] ^ \
+ SB5[ (T >> 8) & 0x3F ] ^ \
+ SB3[ (T >> 16) & 0x3F ] ^ \
+ SB1[ (T >> 24) & 0x3F ]; \
+}
+
+/* DES key schedule */
+
+int des_main_ks( uint32 SK[32], uint8 key[8] )
+{
+ int i;
+ uint32 X, Y, T;
+
+ GET_UINT32( X, key, 0 );
+ GET_UINT32( Y, key, 4 );
+
+ /* Permuted Choice 1 */
+
+ T = ((Y >> 4) ^ X) & 0x0F0F0F0F; X ^= T; Y ^= (T << 4);
+ T = ((Y ) ^ X) & 0x10101010; X ^= T; Y ^= (T );
+
+ X = (LHs[ (X ) & 0xF] << 3) | (LHs[ (X >> 8) & 0xF ] << 2)
+ | (LHs[ (X >> 16) & 0xF] << 1) | (LHs[ (X >> 24) & 0xF ] )
+ | (LHs[ (X >> 5) & 0xF] << 7) | (LHs[ (X >> 13) & 0xF ] << 6)
+ | (LHs[ (X >> 21) & 0xF] << 5) | (LHs[ (X >> 29) & 0xF ] << 4);
+
+ Y = (RHs[ (Y >> 1) & 0xF] << 3) | (RHs[ (Y >> 9) & 0xF ] << 2)
+ | (RHs[ (Y >> 17) & 0xF] << 1) | (RHs[ (Y >> 25) & 0xF ] )
+ | (RHs[ (Y >> 4) & 0xF] << 7) | (RHs[ (Y >> 12) & 0xF ] << 6)
+ | (RHs[ (Y >> 20) & 0xF] << 5) | (RHs[ (Y >> 28) & 0xF ] << 4);
+
+ X &= 0x0FFFFFFF;
+ Y &= 0x0FFFFFFF;
+
+ /* calculate subkeys */
+
+ for( i = 0; i < 16; i++ )
+ {
+ if( i < 2 || i == 8 || i == 15 )
+ {
+ X = ((X << 1) | (X >> 27)) & 0x0FFFFFFF;
+ Y = ((Y << 1) | (Y >> 27)) & 0x0FFFFFFF;
+ }
+ else
+ {
+ X = ((X << 2) | (X >> 26)) & 0x0FFFFFFF;
+ Y = ((Y << 2) | (Y >> 26)) & 0x0FFFFFFF;
+ }
+
+ *SK++ = ((X << 4) & 0x24000000) | ((X << 28) & 0x10000000)
+ | ((X << 14) & 0x08000000) | ((X << 18) & 0x02080000)
+ | ((X << 6) & 0x01000000) | ((X << 9) & 0x00200000)
+ | ((X >> 1) & 0x00100000) | ((X << 10) & 0x00040000)
+ | ((X << 2) & 0x00020000) | ((X >> 10) & 0x00010000)
+ | ((Y >> 13) & 0x00002000) | ((Y >> 4) & 0x00001000)
+ | ((Y << 6) & 0x00000800) | ((Y >> 1) & 0x00000400)
+ | ((Y >> 14) & 0x00000200) | ((Y ) & 0x00000100)
+ | ((Y >> 5) & 0x00000020) | ((Y >> 10) & 0x00000010)
+ | ((Y >> 3) & 0x00000008) | ((Y >> 18) & 0x00000004)
+ | ((Y >> 26) & 0x00000002) | ((Y >> 24) & 0x00000001);
+
+ *SK++ = ((X << 15) & 0x20000000) | ((X << 17) & 0x10000000)
+ | ((X << 10) & 0x08000000) | ((X << 22) & 0x04000000)
+ | ((X >> 2) & 0x02000000) | ((X << 1) & 0x01000000)
+ | ((X << 16) & 0x00200000) | ((X << 11) & 0x00100000)
+ | ((X << 3) & 0x00080000) | ((X >> 6) & 0x00040000)
+ | ((X << 15) & 0x00020000) | ((X >> 4) & 0x00010000)
+ | ((Y >> 2) & 0x00002000) | ((Y << 8) & 0x00001000)
+ | ((Y >> 14) & 0x00000808) | ((Y >> 9) & 0x00000400)
+ | ((Y ) & 0x00000200) | ((Y << 7) & 0x00000100)
+ | ((Y >> 7) & 0x00000020) | ((Y >> 3) & 0x00000011)
+ | ((Y << 2) & 0x00000004) | ((Y >> 21) & 0x00000002);
+ }
+
+ return( 0 );
+}
+
+int des_set_key( des_context *ctx, uint8 key[8] )
+{
+ int i;
+
+ /* setup encryption subkeys */
+
+ des_main_ks( ctx->esk, key );
+
+ /* setup decryption subkeys */
+
+ for( i = 0; i < 32; i += 2 )
+ {
+ ctx->dsk[i ] = ctx->esk[30 - i];
+ ctx->dsk[i + 1] = ctx->esk[31 - i];
+ }
+
+ return( 0 );
+}
+
+/* DES 64-bit block encryption/decryption */
+
+void des_crypt( uint32 SK[32], uint8 input[8], uint8 output[8] )
+{
+ uint32 X, Y, T;
+
+ GET_UINT32( X, input, 0 );
+ GET_UINT32( Y, input, 4 );
+
+ DES_IP( X, Y );
+
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+
+ DES_FP( Y, X );
+
+ PUT_UINT32( Y, output, 0 );
+ PUT_UINT32( X, output, 4 );
+}
+
+void des_encrypt( des_context *ctx, uint8 input[8], uint8 output[8] )
+{
+ des_crypt( ctx->esk, input, output );
+}
+
+void des_decrypt( des_context *ctx, uint8 input[8], uint8 output[8] )
+{
+ des_crypt( ctx->dsk, input, output );
+}
+
+/* Triple-DES key schedule */
+
+int des3_set_2keys( des3_context *ctx, uint8 key1[8], uint8 key2[8] )
+{
+ int i;
+
+ des_main_ks( ctx->esk , key1 );
+ des_main_ks( ctx->dsk + 32, key2 );
+
+ for( i = 0; i < 32; i += 2 )
+ {
+ ctx->dsk[i ] = ctx->esk[30 - i];
+ ctx->dsk[i + 1] = ctx->esk[31 - i];
+
+ ctx->esk[i + 32] = ctx->dsk[62 - i];
+ ctx->esk[i + 33] = ctx->dsk[63 - i];
+
+ ctx->esk[i + 64] = ctx->esk[ i];
+ ctx->esk[i + 65] = ctx->esk[ 1 + i];
+
+ ctx->dsk[i + 64] = ctx->dsk[ i];
+ ctx->dsk[i + 65] = ctx->dsk[ 1 + i];
+ }
+
+ return( 0 );
+}
+
+int des3_set_3keys( des3_context *ctx, uint8 key1[8], uint8 key2[8],
+ uint8 key3[8] )
+{
+ int i;
+
+ des_main_ks( ctx->esk , key1 );
+ des_main_ks( ctx->dsk + 32, key2 );
+ des_main_ks( ctx->esk + 64, key3 );
+
+ for( i = 0; i < 32; i += 2 )
+ {
+ ctx->dsk[i ] = ctx->esk[94 - i];
+ ctx->dsk[i + 1] = ctx->esk[95 - i];
+
+ ctx->esk[i + 32] = ctx->dsk[62 - i];
+ ctx->esk[i + 33] = ctx->dsk[63 - i];
+
+ ctx->dsk[i + 64] = ctx->esk[30 - i];
+ ctx->dsk[i + 65] = ctx->esk[31 - i];
+ }
+
+ return( 0 );
+}
+
+/* Triple-DES 64-bit block encryption/decryption */
+
+void des3_crypt( uint32 SK[96], uint8 input[8], uint8 output[8] )
+{
+ uint32 X, Y, T;
+
+ GET_UINT32( X, input, 0 );
+ GET_UINT32( Y, input, 4 );
+
+ DES_IP( X, Y );
+
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+
+ DES_ROUND( X, Y ); DES_ROUND( Y, X );
+ DES_ROUND( X, Y ); DES_ROUND( Y, X );
+ DES_ROUND( X, Y ); DES_ROUND( Y, X );
+ DES_ROUND( X, Y ); DES_ROUND( Y, X );
+ DES_ROUND( X, Y ); DES_ROUND( Y, X );
+ DES_ROUND( X, Y ); DES_ROUND( Y, X );
+ DES_ROUND( X, Y ); DES_ROUND( Y, X );
+ DES_ROUND( X, Y ); DES_ROUND( Y, X );
+
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+ DES_ROUND( Y, X ); DES_ROUND( X, Y );
+
+ DES_FP( Y, X );
+
+ PUT_UINT32( Y, output, 0 );
+ PUT_UINT32( X, output, 4 );
+}
+
+void des3_encrypt( des3_context *ctx, uint8 input[8], uint8 output[8] )
+{
+ des3_crypt( ctx->esk, input, output );
+}
+
+void des3_decrypt( des3_context *ctx, uint8 input[8], uint8 output[8] )
+{
+ des3_crypt( ctx->dsk, input, output );
+}
diff --git a/icc_apdu_lib/des.h b/icc_apdu_lib/des.h
new file mode 100644
index 0000000..0f5765e
--- /dev/null
+++ b/icc_apdu_lib/des.h
@@ -0,0 +1,37 @@
+#ifndef _DES_H
+#define _DES_H
+
+#ifndef uint8
+#define uint8 unsigned char
+#endif
+
+#ifndef uint32
+#define uint32 unsigned long
+#endif
+
+typedef struct
+{
+ uint32 esk[32]; /* DES encryption subkeys */
+ uint32 dsk[32]; /* DES decryption subkeys */
+}
+des_context;
+
+typedef struct
+{
+ uint32 esk[96]; /* Triple-DES encryption subkeys */
+ uint32 dsk[96]; /* Triple-DES decryption subkeys */
+}
+des3_context;
+
+int des_set_key( des_context *ctx, uint8 key[8] );
+void des_encrypt( des_context *ctx, uint8 input[8], uint8 output[8] );
+void des_decrypt( des_context *ctx, uint8 input[8], uint8 output[8] );
+
+int des3_set_2keys( des3_context *ctx, uint8 key1[8], uint8 key2[8] );
+int des3_set_3keys( des3_context *ctx, uint8 key1[8], uint8 key2[8],
+ uint8 key3[8] );
+
+void des3_encrypt( des3_context *ctx, uint8 input[8], uint8 output[8] );
+void des3_decrypt( des3_context *ctx, uint8 input[8], uint8 output[8] );
+
+#endif /* des.h */
diff --git a/icc_apdu_lib/erase_mf.c b/icc_apdu_lib/erase_mf.c
new file mode 100644
index 0000000..6b61e5a
--- /dev/null
+++ b/icc_apdu_lib/erase_mf.c
@@ -0,0 +1,138 @@
+#include "des.h"
+#include "string.h"
+#include "erase_mf.h"
+
+#define __recovery_key__ 0
+
+const u8 cmd_sel_mf[] = "\x00\xa4\x00\x00\x02\x3f\x00";
+const u8 cmd_sel_ec01[] = "\x00\xa4\x00\x00\x02\xEC\x01";
+const u8 cmd_get_rand[] = "\x00\x84\x00\x00\x04";
+const u8 initial_key0[] = "\x70\x66\x73\x64\x6f\x63\x66\x73\x27\xa3\x27\x27\x23\x27";
+const u8 cmd_ex_auth[] = "\x00\x82\x00\x00\x08";
+const u8 cmd_erase_mf[] = "\x80\x0E\x00\x00\x00";
+const u8 cmd_creat_key[] = "\x80\xE0\x00\x00\x07\x3F\x01\x20\x01\xFE\xFF\xFF";
+const u8 cmd_write_key[] = "\x80\xD4\x01\x00\x15\xF9\xF0\xAA\x0A\xFF";
+const u8 initial_key1[] = "\xaa\x0e\xaa\xaa\xa8\x46\xab\xeb\xfe\xc3\xc7\xcf\xe9\xe5\xf9\xaa";
+
+#if __recovery_key__
+const u8 temp_key[] = "\x57\x41\x54\x43\x48\x44\x41\x54\x41\x54\x69\x6d\x65\x43\x4f\x53";
+#endif
+
+static u8 des_ctx[768];
+
+u8 single_des_set_keys(u8 key[8])
+{
+ return des_set_key((des_context*)des_ctx, key);
+}
+
+void single_des_encrypt(u8 src[8], u8 dest[8])
+{
+ des_encrypt((des_context*)des_ctx, src, dest);
+}
+
+void single_des_decrypt(u8 src[8], u8 dest[8])
+{
+ des_decrypt((des_context*)des_ctx, src, dest);
+}
+
+u8 triple_des_set_keys(u8 key[16])
+{
+ return des3_set_2keys((des3_context*)des_ctx, key, key+8);
+}
+
+void triple_des_encrypt(u8 src[8], u8 dest[8])
+{
+ des3_encrypt((des3_context*)des_ctx, src, dest);
+}
+
+void triple_des_decrypt(u8 src[8], u8 dest[8])
+{
+ des3_decrypt((des3_context*)des_ctx, src, dest);
+}
+
+u16 erase_mf(void)
+{
+ u16 rcode;
+ u8 cmd_buff[32];
+ u8 temp_buff[16];
+ u8 rcv_len;
+ u8* prcv_buff;
+ u8 i;
+
+ //Ñ¡ÔñMF
+ memcpy(cmd_buff, cmd_sel_mf, 7);
+ rcode = Gen_Exchange(0,0,cmd_buff,7,0,&prcv_buff,&rcv_len, PROTOCOL_T0_CH1);
+ if(rcode != 0x9000)
+ return rcode;
+
+ //Ñ¡ÔñEC01
+ //ÈôÈÔÈ»´æÔÚEC01Ŀ¼£¬ÔòÈÏΪ֮ǰδ½øÐвÁ³ý²Ù×÷
+ memcpy(cmd_buff, cmd_sel_ec01, 7);
+ rcode = Gen_Exchange(0,0,cmd_buff,7,0,&prcv_buff,&rcv_len, PROTOCOL_T0_CH1);
+ if(rcode != 0x9000)
+ {
+ return 0;
+ }
+
+ for(i=0;i<8;i++)
+ temp_buff[i] = initial_key0[i] ^ 0x27;
+
+ //Ñ¡ÔñMF
+ memcpy(cmd_buff, cmd_sel_mf, 7);
+ rcode = Gen_Exchange(0,0,cmd_buff,7,0,&prcv_buff,&rcv_len, PROTOCOL_T0_CH1);
+ if(rcode != 0x9000)
+ return rcode;
+
+ //»ñÈ¡Ëæ»úÊý
+ memcpy(cmd_buff, cmd_get_rand, 5);
+ rcode = Gen_Exchange(0,0,cmd_buff,5,4,&prcv_buff,&rcv_len, PROTOCOL_T0_CH1);
+ if(rcode != 0x9000)
+ return rcode;
+ else
+ {
+ memset(cmd_buff, 0, 8);
+ memcpy(cmd_buff, prcv_buff, 4);
+ }
+
+ for(i=0;i<8;i++)
+ temp_buff[8+i] = initial_key1[i+7] ^ 0xAA;
+
+ //¼ÓÃÜËæ»úÊý
+ #if __recovery_key__
+ memset(temp_buff, 0, 16);
+ #endif
+ triple_des_set_keys(temp_buff);
+ triple_des_encrypt(cmd_buff, temp_buff);
+
+ //Ö´ÐÐÍⲿÈÏÖ¤
+ memcpy(cmd_buff, cmd_ex_auth, 5);
+ memcpy(cmd_buff+5, temp_buff, 8);
+ rcode = Gen_Exchange(0,0,cmd_buff,13,0,&prcv_buff,&rcv_len, PROTOCOL_T0_CH1);
+ if(rcode != 0x9000)
+ return rcode;
+
+ //²Á³ýMF
+ memcpy(cmd_buff, cmd_erase_mf, 5);
+ rcode = Gen_Exchange(0,0,cmd_buff,5,0,&prcv_buff,&rcv_len, PROTOCOL_T0_CH1);
+ if(rcode != 0x9000)
+ return rcode;
+
+ //´´½¨keyÎļþ
+ memcpy(cmd_buff, cmd_creat_key, 12);
+ rcode = Gen_Exchange(0,0,cmd_buff,12,0,&prcv_buff,&rcv_len, PROTOCOL_T0_CH1);
+ if(rcode != 0x9000)
+ return rcode;
+
+ //×°ÔØÐµÄÖ÷¿ØÃÜÔ¿
+ memset(cmd_buff, 0, 32);
+ memcpy(cmd_buff, cmd_write_key, 10);
+ #if __recovery_key__
+ memcpy(cmd_buff+10, temp_key, 16);
+ #endif
+ rcode = Gen_Exchange(0,0,cmd_buff,26,0,&prcv_buff,&rcv_len, PROTOCOL_T0_CH1);
+ if(rcode != 0x9000)
+ return rcode;
+
+ return 0x9000;
+}
+
diff --git a/icc_apdu_lib/erase_mf.h b/icc_apdu_lib/erase_mf.h
new file mode 100644
index 0000000..d803722
--- /dev/null
+++ b/icc_apdu_lib/erase_mf.h
@@ -0,0 +1,9 @@
+#ifndef __erase_mf_h__
+#define __erase_mf_h__
+
+#include "stm32f10x_lib.h"
+#include "icc_apdu_lib.h"
+
+extern u16 erase_mf(void);
+
+#endif
diff --git a/icc_apdu_lib/icc_apdu_lib_v02.h b/icc_apdu_lib/icc_apdu_lib_v02.h
new file mode 100644
index 0000000..5ec22b5
--- /dev/null
+++ b/icc_apdu_lib/icc_apdu_lib_v02.h
@@ -0,0 +1,108 @@
+#ifndef __ICC_APDU_LIB_H__
+#define __ICC_APDU_LIB_H__
+
+#define PROTOCOL_T0_CH1 1 // PSAM2
+#define PROTOCOL_TCL_PCD0 0x80 //·Ç½Ó´¥Ê½¿¨
+
+#define PICC_REQ_ALL 0x52
+#define PICC_REQ_IDLE 0x26
+//¿¨Éϵ磬ÓÃÓÚSAM¿¨À临λ
+//²ÎÊý£ºcid=0
+// ich ͨµÀºÅ
+//·µ»Ø£º0³É¹¦
+extern unsigned short Gen_PowerOnCard(unsigned char cid, int ich);
+
+//¹Ø±ÕSAM¿¨µçÔ´
+//²ÎÊý£ºich ͨµÀºÅ
+extern void Gen_PowerOffCard(int ich);
+
+//¹¦ÄÜ£º¿¨¸´Î»Ç°³õʼ»¯Ïà¹ØÊý¾Ý½á¹¹£¨ÓÃÓÚSAM»ò¿¨Æ¬£©
+//²ÎÊý£ºcid=0
+// ich ͨµÀºÅ
+void Gen_ResetInfo( unsigned char cid, int ich );
+//¹¦ÄÜ£º¿¨¸´Î»£¨¿ÉÓÃÓÚ¸´Î»SAM»ò¿¨Æ¬£©
+//²ÎÊý£ºcid=0
+// ich ͨµÀºÅ
+//·µ»Ø£º0³É¹¦
+extern unsigned short Gen_ResetCard(unsigned char cid, int ich);
+
+//¹¦ÄÜ£º¿¨Êý¾Ý½»»»
+//²ÎÊý£ºcid=0
+// nad_send=0
+// cmd_buf ÃüÁ³åÇø
+// cmd_len ÃüÁ¶È
+// ExpectedResponseLength ÆÚÍû¿¨Æ¬»Ø¸´µÄÊý¾Ý³¤¶È
+// rec_buf ÓÃÓÚ»ñÈ¡·µ»ØÊý¾ÝµÄÖ¸Õë
+// rec_buf_len ʵ¼Ê½ÓÊÕµ½µÄÊý¾Ý³¤¶È
+// ich ͨµÀºÅ
+//·µ»Ø£º0³É¹¦
+extern unsigned short Gen_Exchange(unsigned char cid,
+ unsigned char nad_send,
+ unsigned char *cmd_buf,
+ unsigned char cmd_len,
+ unsigned char ExpectedResponseLength,
+ unsigned char **rec_buf,
+ unsigned char *rec_buf_len,
+ int ich);
+
+//¹¦ÄÜ£ºActivation of a PICC in IDLE mode.
+//²ÎÊý£ºbr (IN) Baudrate for MIFARE communication 0 106 kBaud
+// atq (OUT) Answer to Request
+// sak (OUT) Select acknowledge
+// uid (OUT) up to 10 bytes UID
+// uid_len (OUT) length of the UID
+//·µ»Ø£º0 ok
+extern short Mf500PiccActivateIdle(unsigned char br,
+ unsigned char *atq,
+ unsigned char *sak,
+ unsigned char *uid,
+ unsigned char *uid_len);
+
+//¹¦ÄÜ£ºSends the PICC into the halt state.
+//²ÎÊý£ºNone
+//·µ»Ø£º0 ok
+extern short Mf500PiccHalt(void);
+
+//¹¦ÄÜ£ºÔÚÉ䯵¿¨¼ÓµçÇÒ½øÈë144433-4Çé¿öϲâÊÔ¿¨Æ¬µÄ´æÔÚ
+//²ÎÊý£ºÎÞ
+//·µ»Ø£º0 ¿¨´æÔÚ
+// ÆäËû ¿¨²»´æÔÚ
+extern unsigned char PICC_TclCheckRFRounge(void);
+
+//¹¦ÄÜ£º¸üÐÂsam¿¨¶¨Ê±µ¥ÔªtickÖµ
+// ÐèÔÚ1msÖжϺ¯ÊýÖе÷ÓÃ
+extern void update_sam_ticker(void);
+
+//¹¦ÄÜ£º³õʼ»¯SAMͨѶ½Ó¿Ú
+//²ÎÊý£ºÎÞ
+//·µ»Ø£ºÎÞ
+extern void ISO7816_USART_Init(void);
+
+
+//¹¦ÄÜ: ÉèÖÃ3DES(Ë«±¶³¤)ÃÜÔ¿
+//²ÎÊý: 16×Ö½ÚÃÜÔ¿Öµ
+//·µ»Ø: 0 ³É¹¦
+// ÆäËû ʧ°Ü
+//extern u8 des_set_keys(u8 key[16]);
+
+//¹¦ÄÜ: 3des¼ÓÃÜ
+//²ÎÊý: src[8] ÊäÈë8×Ö½ÚÃ÷ÎÄÊý¾Ý
+// dest[8] Êä³ö8×Ö½ÚÃÜÎÄÊý¾Ý
+//·µ»Ø: ÎÞ
+//extern void des_encrypt(u8 src [ 8 ], u8 dest [ 8 ]);
+
+//¹¦ÄÜ: 3des½âÃÜ
+//²ÎÊý: src[8] ÊäÈë8×Ö½ÚÃÜÎÄÊý¾Ý
+// dest[8] Êä³ö8×Ö½ÚÃ÷ÎÄÊý¾Ý
+//·µ»Ø: ÎÞ
+//extern void des_encrypt(u8 src [ 8 ], u8 dest [ 8 ]);
+
+//¹¦ÄÜ: ²Á³ýESAM¿ªÆÕ¿¨½á¹¹£¬²¢Ìæ»»³õʼÖ÷¿ØÃÜԿΪ16×Ö½ÚÈ«0
+//²ÎÊý: ÎÞ
+//·µ»Ø: 0x9000 ³É¹¦
+// 0x0000 ²»ÊÇ¿ªÆÕ³õʼESAM¿¨¿Õ¼ä£¬²»ÄܽøÐвÁ³ý²Ù×÷
+// ÆäËû ʧ°Ü
+//extern u16 erase_mf(void);
+
+#endif
+
diff --git a/lcd/Bebas_Neue18x36_Numbers.h b/lcd/Bebas_Neue18x36_Numbers.h
new file mode 100644
index 0000000..5a975b2
--- /dev/null
+++ b/lcd/Bebas_Neue18x36_Numbers.h
@@ -0,0 +1,42 @@
+/*
+ * Bebas_Neue18x36_Numberes.h
+ *
+ * Created: 30/03/2012 1:54:32 AM
+ * Author: andy
+ */
+
+
+#ifndef BEBAS_NEUE18X36_NUMBERS_H_
+#define BEBAS_NEUE18X36_NUMBERS_H_
+
+
+//WARNING: This Font Require X-GLCD Lib.
+// You can not use it with MikroE GLCD Lib.
+
+//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
+//MikroElektronika 2011
+//http://www.mikroe.com
+
+//GLCD FontName : Bebas_Neue18x36
+//GLCD FontSize : 18 x 36
+
+static const char Bebas_Neue18x36_Numbers[] PROGMEM = {
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
+ 0x12, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x00, 0xFC, 0x07, 0x00, 0x00, 0x00, 0xFF, 0x07, 0x00, 0x00, 0xE0, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0x3F, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0x00, 0x00, 0xE0, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0x7F, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0x00, 0x00, 0xC0, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0x7F, 0x00, 0x00, 0x00, 0xFE, 0x0F, 0x00, 0x00, 0x00, 0xFE, 0x03, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, // Code for char /
+ 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x7F, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0x01, 0xFC, 0xFF, 0xFF, 0xFF, 0x03, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0x3F, 0x00, 0x00, 0xC0, 0x0F, 0x1F, 0x00, 0x00, 0x80, 0x0F, 0x1F, 0x00, 0x00, 0x80, 0x0F, 0x1F, 0x00, 0x00, 0x80, 0x0F, 0x3F, 0x00, 0x00, 0xC0, 0x0F, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0xFF, 0x01, 0xE0, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 0
+ 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x00, 0x00, 0xF0, 0x01, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 1
+ 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x0F, 0x00, 0xF0, 0x07, 0xF8, 0x0F, 0x00, 0xFE, 0x07, 0xFC, 0x0F, 0x00, 0xFF, 0x07, 0xFE, 0x0F, 0xC0, 0xFF, 0x07, 0xFE, 0x0F, 0xE0, 0xFF, 0x07, 0x3E, 0x00, 0xF0, 0xCF, 0x07, 0x1F, 0x00, 0xF8, 0xC3, 0x07, 0x1F, 0x00, 0xFE, 0xC1, 0x07, 0x1F, 0x00, 0x7F, 0xC0, 0x07, 0x1F, 0x80, 0x3F, 0xC0, 0x07, 0x3F, 0xF0, 0x1F, 0xC0, 0x07, 0xFE, 0xFF, 0x0F, 0xC0, 0x07, 0xFE, 0xFF, 0x03, 0xC0, 0x07, 0xFC, 0xFF, 0x01, 0xC0, 0x07, 0xF8, 0x7F, 0x00, 0xC0, 0x07, 0xE0, 0x0F, 0x00, 0x00, 0x00, // Code for char 2
+ 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x7F, 0x00, 0xF8, 0x07, 0x00, 0xFF, 0x01, 0xFC, 0x07, 0x00, 0xFF, 0x03, 0xFE, 0x07, 0x00, 0xFF, 0x07, 0xFE, 0x07, 0x00, 0xFF, 0x07, 0x3F, 0x80, 0x0F, 0xC0, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x3F, 0xC0, 0x1F, 0xC0, 0x0F, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFD, 0xFF, 0x03, 0xF8, 0xFF, 0xF8, 0xFF, 0x01, 0xE0, 0x1F, 0xC0, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 3
+ 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1F, 0x00, 0x00, 0x00, 0xF0, 0x1F, 0x00, 0x00, 0x00, 0xFC, 0x1F, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0xF8, 0x3F, 0x1F, 0x00, 0x00, 0xFF, 0x0F, 0x1F, 0x00, 0xC0, 0xFF, 0x03, 0x1F, 0x00, 0xF0, 0x7F, 0x00, 0x1F, 0x00, 0xFE, 0x1F, 0x00, 0x1F, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, // Code for char 4
+ 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x1F, 0x7E, 0x00, 0xFE, 0xFF, 0x1F, 0xFE, 0x01, 0xFE, 0xFF, 0x1F, 0xFE, 0x03, 0xFE, 0xFF, 0x1F, 0xFE, 0x07, 0xFE, 0xFF, 0x1F, 0xFE, 0x07, 0xFE, 0xC7, 0x03, 0xC0, 0x0F, 0x3E, 0xE0, 0x01, 0x80, 0x0F, 0x3E, 0xE0, 0x01, 0x80, 0x0F, 0x3E, 0xF0, 0x01, 0x80, 0x0F, 0x3E, 0xF0, 0x03, 0xC0, 0x0F, 0x3E, 0xF0, 0xFF, 0xFF, 0x07, 0x3E, 0xE0, 0xFF, 0xFF, 0x07, 0x3E, 0xE0, 0xFF, 0xFF, 0x03, 0x3E, 0xC0, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 5
+ 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x7F, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0x01, 0xFC, 0xFF, 0xFF, 0xFF, 0x03, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0x3E, 0x80, 0x07, 0xC0, 0x0F, 0x1F, 0xC0, 0x03, 0x80, 0x0F, 0x1F, 0xC0, 0x03, 0x80, 0x0F, 0x1F, 0xE0, 0x03, 0x80, 0x0F, 0x3F, 0xE0, 0x07, 0xC0, 0x0F, 0x3E, 0xE0, 0xFF, 0xFF, 0x07, 0xFE, 0xC3, 0xFF, 0xFF, 0x07, 0xFE, 0xC3, 0xFF, 0xFF, 0x03, 0xFC, 0x83, 0xFF, 0xFF, 0x01, 0xF8, 0x03, 0xFE, 0x7F, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, // Code for char 6
+ 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x06, 0x3E, 0x00, 0x00, 0xE0, 0x07, 0x3E, 0x00, 0x00, 0xFE, 0x07, 0x3E, 0x00, 0xE0, 0xFF, 0x07, 0x3E, 0x00, 0xFC, 0xFF, 0x07, 0x3E, 0xC0, 0xFF, 0xFF, 0x03, 0x3E, 0xFC, 0xFF, 0x3F, 0x00, 0xFE, 0xFF, 0xFF, 0x03, 0x00, 0xFE, 0xFF, 0x3F, 0x00, 0x00, 0xFE, 0xFF, 0x07, 0x00, 0x00, 0xFE, 0x7F, 0x00, 0x00, 0x00, 0xFE, 0x07, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, // Code for char 7
+ 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x1F, 0xC0, 0x3F, 0x00, 0xF8, 0x7F, 0xF8, 0xFF, 0x01, 0xFC, 0xFF, 0xFD, 0xFF, 0x03, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0x7E, 0xC0, 0x3F, 0xC0, 0x07, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x7E, 0xC0, 0x3F, 0xE0, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFD, 0xFF, 0x03, 0xF8, 0x7F, 0xF8, 0xFF, 0x01, 0xC0, 0x1F, 0xC0, 0x3F, 0x00, // Code for char 8
+ 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0xE0, 0xFF, 0x07, 0xFC, 0x01, 0xF8, 0xFF, 0x1F, 0xFC, 0x03, 0xFC, 0xFF, 0x3F, 0xFC, 0x07, 0xFE, 0xFF, 0x3F, 0xFC, 0x07, 0xFE, 0xFF, 0x7F, 0xC0, 0x07, 0x3F, 0x00, 0x7E, 0xC0, 0x0F, 0x1F, 0x00, 0x7C, 0x80, 0x0F, 0x1F, 0x00, 0x3C, 0x80, 0x0F, 0x1F, 0x00, 0x3C, 0x80, 0x0F, 0x3F, 0x00, 0x1E, 0xC0, 0x0F, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0xFF, 0x01, 0xE0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Code for char 9
+ };
+
+
+
+
+
+#endif /* BEBAS_NEUE18X36_NUMBERES_H_ */
diff --git a/lcd/Bebas_Neue20x36_Bold_Numbers.h b/lcd/Bebas_Neue20x36_Bold_Numbers.h
new file mode 100644
index 0000000..63916c5
--- /dev/null
+++ b/lcd/Bebas_Neue20x36_Bold_Numbers.h
@@ -0,0 +1,42 @@
+/*
+ * Bebas_Neue20x36_Numbers.h
+ *
+ * Created: 30/03/2012 1:51:48 AM
+ * Author: andy
+ */
+
+
+#ifndef BEBAS_NEUE20X36_BOLD_NUMBERS_H_
+#define BEBAS_NEUE20X36_BOLD_NUMBERS_H_
+
+
+//WARNING: This Font Require X-GLCD Lib.
+// You can not use it with MikroE GLCD Lib.
+
+//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
+//MikroElektronika 2011
+//http://www.mikroe.com
+
+//GLCD FontName : Bebas_Neue20x36
+//GLCD FontSize : 20 x 36
+
+static const char Bebas_Neue20x36_Bold_Numbers[] PROGMEM = {
+ 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x00, 0xFC, 0x07, 0x00, 0x00, 0x00, 0xFF, 0x07, 0x00, 0x00, 0xE0, 0xFF, 0x07, 0x00, 0x00, 0xF8, 0xFF, 0x07, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xE0, 0xFF, 0x3F, 0x00, 0x00, 0xF8, 0xFF, 0x0F, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xC0, 0xFF, 0x7F, 0x00, 0x00, 0xF8, 0xFF, 0x0F, 0x00, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x00, 0xFE, 0x7F, 0x00, 0x00, 0x00, 0xFE, 0x0F, 0x00, 0x00, 0x00, 0xFE, 0x03, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, // Code for char /
+ 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x7F, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0x01, 0xFC, 0xFF, 0xFF, 0xFF, 0x03, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x3F, 0x00, 0x00, 0xC0, 0x0F, 0x1F, 0x00, 0x00, 0x80, 0x0F, 0x3F, 0x00, 0x00, 0xC0, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0xFF, 0x01, 0xE0, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 0
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x00, 0x00, 0xF0, 0x01, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 1
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x0F, 0x00, 0xF0, 0x07, 0xF8, 0x0F, 0x00, 0xFE, 0x07, 0xFC, 0x0F, 0x00, 0xFF, 0x07, 0xFE, 0x0F, 0xC0, 0xFF, 0x07, 0xFE, 0x0F, 0xE0, 0xFF, 0x07, 0xFE, 0x0F, 0xF0, 0xFF, 0x07, 0xFF, 0x0F, 0xF8, 0xFF, 0x07, 0x3F, 0x00, 0xFE, 0xCF, 0x07, 0x1F, 0x00, 0xFF, 0xC3, 0x07, 0x1F, 0x80, 0xFF, 0xC1, 0x07, 0x3F, 0xF0, 0x7F, 0xC0, 0x07, 0xFF, 0xFF, 0x3F, 0xC0, 0x07, 0xFF, 0xFF, 0x1F, 0xC0, 0x07, 0xFE, 0xFF, 0x0F, 0xC0, 0x07, 0xFE, 0xFF, 0x03, 0xC0, 0x07, 0xFC, 0xFF, 0x01, 0xC0, 0x07, 0xF8, 0x7F, 0x00, 0xC0, 0x07, 0xE0, 0x0F, 0x00, 0x00, 0x00, // Code for char 2
+ 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x7F, 0x00, 0xF8, 0x07, 0x00, 0xFF, 0x01, 0xFC, 0x07, 0x00, 0xFF, 0x03, 0xFE, 0x07, 0x00, 0xFF, 0x07, 0xFE, 0x07, 0x00, 0xFF, 0x07, 0xFF, 0x87, 0x0F, 0xFF, 0x0F, 0xFF, 0x87, 0x0F, 0xFF, 0x0F, 0x3F, 0x80, 0x0F, 0xC0, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x3F, 0xC0, 0x1F, 0xC0, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFD, 0xFF, 0x03, 0xF8, 0xFF, 0xF8, 0xFF, 0x01, 0xE0, 0x1F, 0xC0, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 3
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1F, 0x00, 0x00, 0x00, 0xF0, 0x1F, 0x00, 0x00, 0x00, 0xFC, 0x1F, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0xF8, 0xFF, 0x1F, 0x00, 0x00, 0xFF, 0xFF, 0x1F, 0x00, 0xC0, 0xFF, 0x3F, 0x1F, 0x00, 0xF0, 0xFF, 0x0F, 0x1F, 0x00, 0xFE, 0xFF, 0x03, 0x1F, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, // Code for char 4
+ 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x1F, 0x7E, 0x00, 0xFE, 0xFF, 0x1F, 0xFE, 0x01, 0xFE, 0xFF, 0x1F, 0xFE, 0x03, 0xFE, 0xFF, 0x1F, 0xFE, 0x07, 0xFE, 0xFF, 0x1F, 0xFE, 0x07, 0xFE, 0xFF, 0x1F, 0xFE, 0x0F, 0xFE, 0xFF, 0x1F, 0xFE, 0x0F, 0xFE, 0xE7, 0x03, 0xC0, 0x0F, 0x3E, 0xF0, 0x01, 0x80, 0x0F, 0x3E, 0xF0, 0x03, 0xC0, 0x0F, 0x3E, 0xF0, 0xFF, 0xFF, 0x0F, 0x3E, 0xF0, 0xFF, 0xFF, 0x0F, 0x3E, 0xF0, 0xFF, 0xFF, 0x07, 0x3E, 0xE0, 0xFF, 0xFF, 0x07, 0x3E, 0xE0, 0xFF, 0xFF, 0x03, 0x3E, 0xC0, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 5
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x7F, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0x01, 0xFC, 0xFF, 0xFF, 0xFF, 0x03, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x3F, 0xC0, 0x07, 0xC0, 0x0F, 0x1F, 0xE0, 0x03, 0x80, 0x0F, 0x3F, 0xE0, 0x07, 0xC0, 0x0F, 0x3F, 0xE0, 0xFF, 0xFF, 0x0F, 0xFF, 0xE3, 0xFF, 0xFF, 0x0F, 0xFE, 0xE3, 0xFF, 0xFF, 0x07, 0xFE, 0xC3, 0xFF, 0xFF, 0x07, 0xFE, 0xC3, 0xFF, 0xFF, 0x03, 0xFC, 0x83, 0xFF, 0xFF, 0x01, 0xF8, 0x03, 0xFE, 0x7F, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, // Code for char 6
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x06, 0x3E, 0x00, 0x00, 0xE0, 0x07, 0x3E, 0x00, 0x00, 0xFE, 0x07, 0x3E, 0x00, 0xE0, 0xFF, 0x07, 0x3E, 0x00, 0xFC, 0xFF, 0x07, 0x3E, 0xC0, 0xFF, 0xFF, 0x07, 0x3E, 0xFC, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x03, 0xFE, 0xFF, 0xFF, 0x3F, 0x00, 0xFE, 0xFF, 0xFF, 0x03, 0x00, 0xFE, 0xFF, 0x3F, 0x00, 0x00, 0xFE, 0xFF, 0x07, 0x00, 0x00, 0xFE, 0x7F, 0x00, 0x00, 0x00, 0xFE, 0x07, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, // Code for char 7
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x1F, 0xC0, 0x3F, 0x00, 0xF8, 0x7F, 0xF8, 0xFF, 0x01, 0xFC, 0xFF, 0xFD, 0xFF, 0x03, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x7F, 0xC0, 0x3F, 0xC0, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x1F, 0x80, 0x0F, 0x80, 0x0F, 0x7F, 0xC0, 0x3F, 0xE0, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFD, 0xFF, 0x03, 0xF8, 0x7F, 0xF8, 0xFF, 0x01, 0xC0, 0x1F, 0xC0, 0x3F, 0x00, // Code for char 8
+ 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0xE0, 0xFF, 0x07, 0xFC, 0x01, 0xF8, 0xFF, 0x1F, 0xFC, 0x03, 0xFC, 0xFF, 0x3F, 0xFC, 0x07, 0xFE, 0xFF, 0x3F, 0xFC, 0x07, 0xFE, 0xFF, 0x7F, 0xFC, 0x07, 0xFF, 0xFF, 0x7F, 0xFC, 0x0F, 0xFF, 0xFF, 0x7F, 0xC0, 0x0F, 0x3F, 0x00, 0x7E, 0xC0, 0x0F, 0x1F, 0x00, 0x7C, 0x80, 0x0F, 0x3F, 0x00, 0x3E, 0xC0, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0xFF, 0x01, 0xE0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Code for char 9
+ };
+
+
+
+
+
+#endif /* BEBAS_NEUE20X36_NUMBERS_H_ */
diff --git a/lcd/Earthbound_12x19_48to57.h b/lcd/Earthbound_12x19_48to57.h
new file mode 100644
index 0000000..37d1744
--- /dev/null
+++ b/lcd/Earthbound_12x19_48to57.h
@@ -0,0 +1,19 @@
+#ifndef Earthbound_12x19_48to57_H
+#define Earthbound_12x19_48to57_H
+
+// Size: 12x19
+// Chars: 48 to 57
+static const char font_Earthbound_12x19_48to57[] PROGMEM = {
+0x00, 0xe0, 0xf0, 0x38, 0x0c, 0x0c, 0x0c, 0x0c, 0x38, 0xf8, 0xc0, 0x00, 0x00, 0x1f, 0x7f, 0xe0, 0x80, 0x80, 0x80, 0x80, 0xe0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, // Char '0'
+0x00, 0x10, 0x18, 0x18, 0xfc, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Char '1'
+0x00, 0x08, 0x1c, 0x0c, 0x0c, 0x0c, 0x0c, 0x8c, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0xf0, 0xf8, 0x9c, 0x8c, 0x86, 0x86, 0x83, 0x83, 0x80, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, // Char '2'
+0x00, 0x08, 0x1c, 0x0c, 0x0c, 0x0c, 0x0c, 0x8c, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x80, 0x81, 0x83, 0x83, 0xc7, 0xff, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, // Char '3'
+0x00, 0x00, 0x00, 0x80, 0xc0, 0x70, 0x38, 0xfc, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x1e, 0x1b, 0x11, 0x18, 0x10, 0xff, 0xff, 0x10, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, // Char '4'
+0x00, 0x00, 0xf4, 0xfc, 0x1c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc3, 0x83, 0x83, 0x83, 0x83, 0xc7, 0xfe, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, // Char '5'
+0x00, 0xc0, 0xf0, 0x78, 0x1c, 0x0c, 0x0c, 0x0c, 0x08, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xc3, 0x83, 0x83, 0x83, 0xc3, 0xfe, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, // Char '6'
+0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x8c, 0xcc, 0x7c, 0x3c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf0, 0x7c, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Char '7'
+0x00, 0xf0, 0xf8, 0x1c, 0x0c, 0x0c, 0x0c, 0x0c, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x8f, 0x07, 0x06, 0x06, 0x8f, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, // Char '8'
+0x00, 0xf0, 0xf8, 0x1c, 0x0c, 0x0c, 0x0c, 0x1c, 0xf8, 0xe0, 0x00, 0x00, 0x00, 0x01, 0x87, 0x8e, 0x8c, 0x8c, 0x8c, 0xee, 0x7f, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 // Char '9'
+};
+
+#endif
diff --git a/lcd/Liberation_Sans11x14_Numbers.h b/lcd/Liberation_Sans11x14_Numbers.h
new file mode 100644
index 0000000..d2de386
--- /dev/null
+++ b/lcd/Liberation_Sans11x14_Numbers.h
@@ -0,0 +1,42 @@
+/*
+ * Liberation_Sans11x14_Numbers.h
+ *
+ * Created: 30/03/2012 1:31:10 AM
+ * Author: andy
+ */
+
+
+#ifndef LIBERATION_SANS11X14_NUMBERS_H_
+#define LIBERATION_SANS11X14_NUMBERS_H_
+
+
+//WARNING: This Font Require X-GLCD Lib.
+// You can not use it with MikroE GLCD Lib.
+
+//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
+//MikroElektronika 2011
+//http://www.mikroe.com
+
+//GLCD FontName : Liberation_Sans11x14 46 to 57
+//GLCD FontSize : 11 x 14
+
+static const char Liberation_Sans11x14_Numbers[] PROGMEM = {
+ 0x04, 0x00, 0x00, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
+ 0x05, 0x00, 0x38, 0x80, 0x3F, 0xFC, 0x0F, 0xFF, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char /
+ 0x0A, 0x00, 0x00, 0xF0, 0x07, 0xFC, 0x1F, 0xFE, 0x3F, 0x0E, 0x38, 0x06, 0x30, 0x0E, 0x38, 0xFE, 0x3F, 0xFC, 0x1F, 0xF0, 0x07, 0x00, 0x00, // Code for char 0
+ 0x0B, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x0C, 0x30, 0x0E, 0x30, 0xFE, 0x3F, 0xFE, 0x3F, 0xFE, 0x3F, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, // Code for char 1
+ 0x0A, 0x00, 0x00, 0x18, 0x38, 0x1C, 0x3C, 0x1E, 0x3E, 0x06, 0x37, 0x86, 0x33, 0xC6, 0x31, 0xFE, 0x31, 0xFC, 0x30, 0x78, 0x30, 0x00, 0x00, // Code for char 2
+ 0x0A, 0x00, 0x00, 0x18, 0x0C, 0x1C, 0x1C, 0x1E, 0x3C, 0xC6, 0x30, 0xC6, 0x30, 0xC6, 0x31, 0xFE, 0x3F, 0xBC, 0x1F, 0x3C, 0x0F, 0x00, 0x00, // Code for char 3
+ 0x0B, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x07, 0xE0, 0x06, 0x38, 0x06, 0x1E, 0x06, 0xFE, 0x3F, 0xFE, 0x3F, 0xFE, 0x3F, 0x00, 0x06, 0x00, 0x06, // Code for char 4
+ 0x0A, 0x00, 0x00, 0xFE, 0x0C, 0xFE, 0x1C, 0xC6, 0x3C, 0x66, 0x38, 0x66, 0x30, 0xE6, 0x38, 0xE6, 0x3F, 0xC6, 0x1F, 0x80, 0x0F, 0x00, 0x00, // Code for char 5
+ 0x0A, 0x00, 0x00, 0xF0, 0x07, 0xFC, 0x1F, 0xFC, 0x3F, 0x8E, 0x38, 0xC6, 0x30, 0xC6, 0x30, 0xCE, 0x3F, 0x8C, 0x1F, 0x08, 0x0F, 0x00, 0x00, // Code for char 6
+ 0x0A, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x38, 0x06, 0x3F, 0xC6, 0x3F, 0xE6, 0x03, 0xFE, 0x00, 0x3E, 0x00, 0x0E, 0x00, 0x00, 0x00, // Code for char 7
+ 0x0A, 0x00, 0x00, 0x38, 0x0F, 0xFC, 0x1F, 0xFE, 0x3F, 0xC6, 0x30, 0xC6, 0x30, 0xC6, 0x30, 0xFE, 0x3F, 0xFC, 0x1F, 0x38, 0x0F, 0x00, 0x00, // Code for char 8
+ 0x0A, 0x00, 0x00, 0x78, 0x08, 0xFC, 0x18, 0xFE, 0x39, 0x86, 0x31, 0x86, 0x31, 0x86, 0x38, 0xFE, 0x1F, 0xFC, 0x1F, 0xF0, 0x07, 0x00, 0x00 // Code for char 9
+ };
+
+
+
+
+
+#endif /* LIBERATION_SANS11X14_NUMBERS_H_ */
diff --git a/lcd/Liberation_Sans15x21_Numbers.h b/lcd/Liberation_Sans15x21_Numbers.h
new file mode 100644
index 0000000..21a36f7
--- /dev/null
+++ b/lcd/Liberation_Sans15x21_Numbers.h
@@ -0,0 +1,42 @@
+/*
+ * Liberation_Sans15x21_Numbers.h
+ *
+ * Created: 30/03/2012 1:34:30 AM
+ * Author: andy
+ */
+
+
+#ifndef LIBERATION_SANS15X21_NUMBERS_H_
+#define LIBERATION_SANS15X21_NUMBERS_H_
+
+
+//WARNING: This Font Require X-GLCD Lib.
+// You can not use it with MikroE GLCD Lib.
+
+//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
+//MikroElektronika 2011
+//http://www.mikroe.com
+
+//GLCD FontName : Liberation_Sans15x21 46 to 57
+//GLCD FontSize : 15 x 21
+
+static const char Liberation_Sans15x21_Numbers[] PROGMEM = {
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
+ 0x07, 0x00, 0x00, 0x1E, 0x00, 0xE0, 0x1F, 0x00, 0xFF, 0x1F, 0xF8, 0xFF, 0x03, 0xFF, 0x1F, 0x00, 0xFF, 0x01, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char /
+ 0x0E, 0x00, 0x00, 0x00, 0xC0, 0x7F, 0x00, 0xF8, 0xFF, 0x01, 0xFC, 0xFF, 0x07, 0xFC, 0xFF, 0x07, 0x3E, 0x80, 0x0F, 0x0E, 0x00, 0x0E, 0x0E, 0x00, 0x0E, 0x0E, 0x00, 0x0E, 0x1E, 0x80, 0x0F, 0xFC, 0xFF, 0x07, 0xFC, 0xFF, 0x07, 0xF8, 0xFF, 0x01, 0xC0, 0x7F, 0x00, 0x00, 0x00, 0x00, // Code for char 0
+ 0x0E, 0x00, 0x00, 0x00, 0x70, 0x00, 0x0E, 0x38, 0x00, 0x0E, 0x38, 0x00, 0x0E, 0x1C, 0x00, 0x0E, 0x0E, 0x00, 0x0E, 0xFE, 0xFF, 0x0F, 0xFE, 0xFF, 0x0F, 0xFE, 0xFF, 0x0F, 0xFE, 0xFF, 0x0F, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, // Code for char 1
+ 0x0E, 0x00, 0x00, 0x00, 0x60, 0x00, 0x0F, 0x78, 0x80, 0x0F, 0x7C, 0xC0, 0x0F, 0x7C, 0xE0, 0x0F, 0x1E, 0xF0, 0x0F, 0x0E, 0xF8, 0x0E, 0x0E, 0x7C, 0x0E, 0x0E, 0x3E, 0x0E, 0x1E, 0x1F, 0x0E, 0xFE, 0x0F, 0x0E, 0xFC, 0x07, 0x0E, 0xF8, 0x03, 0x0E, 0xF0, 0x01, 0x0E, 0x00, 0x00, 0x00, // Code for char 2
+ 0x0E, 0x00, 0x00, 0x00, 0x30, 0x80, 0x01, 0x38, 0x80, 0x03, 0x3C, 0x80, 0x07, 0x3C, 0x80, 0x0F, 0x1E, 0x00, 0x0F, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x1E, 0x1F, 0x0F, 0xFE, 0xFF, 0x0F, 0xFC, 0xFB, 0x07, 0xFC, 0xF9, 0x03, 0xF0, 0xE0, 0x01, 0x00, 0x00, 0x00, // Code for char 3
+ 0x0F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xFE, 0x00, 0x80, 0xEF, 0x00, 0xC0, 0xE7, 0x00, 0xF0, 0xE1, 0x00, 0x7C, 0xE0, 0x00, 0x3E, 0xE0, 0x00, 0xFE, 0xFF, 0x0F, 0xFE, 0xFF, 0x0F, 0xFE, 0xFF, 0x0F, 0xFE, 0xFF, 0x0F, 0x00, 0xE0, 0x00, 0x00, 0xE0, 0x00, // Code for char 4
+ 0x0E, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xF8, 0x87, 0x03, 0xFE, 0x87, 0x07, 0xFE, 0x87, 0x0F, 0xFE, 0x07, 0x0F, 0x0E, 0x03, 0x0E, 0x8E, 0x03, 0x0E, 0x8E, 0x03, 0x0E, 0x8E, 0x07, 0x0F, 0x8E, 0xFF, 0x07, 0x0E, 0xFF, 0x07, 0x0E, 0xFE, 0x03, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, // Code for char 5
+ 0x0E, 0x00, 0x00, 0x00, 0xC0, 0x7F, 0x00, 0xF0, 0xFF, 0x01, 0xF8, 0xFF, 0x07, 0xFC, 0xFF, 0x07, 0x3E, 0x0E, 0x0F, 0x0E, 0x07, 0x0E, 0x0E, 0x07, 0x0E, 0x0E, 0x07, 0x0E, 0x1E, 0x0F, 0x0F, 0x3E, 0xFF, 0x0F, 0x3C, 0xFE, 0x07, 0x38, 0xFE, 0x03, 0x30, 0xF8, 0x01, 0x00, 0x00, 0x00, // Code for char 6
+ 0x0E, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x0E, 0x00, 0x0F, 0x0E, 0xE0, 0x0F, 0x0E, 0xF8, 0x0F, 0x0E, 0xFE, 0x0F, 0x8E, 0xFF, 0x00, 0xCE, 0x0F, 0x00, 0xFE, 0x03, 0x00, 0xFE, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 7
+ 0x0E, 0x00, 0x00, 0x00, 0xF0, 0xE0, 0x01, 0xF8, 0xFB, 0x03, 0xFC, 0xFB, 0x07, 0xFE, 0xFF, 0x0F, 0x1E, 0x1F, 0x0F, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x1E, 0x1F, 0x0F, 0xFE, 0xFF, 0x0F, 0xFC, 0xFB, 0x07, 0xFC, 0xFB, 0x03, 0xF0, 0xE0, 0x01, 0x00, 0x00, 0x00, // Code for char 8
+ 0x0E, 0x00, 0x00, 0x00, 0xF0, 0x83, 0x01, 0xF8, 0x87, 0x03, 0xFC, 0x8F, 0x07, 0xFE, 0x9F, 0x0F, 0x1E, 0x1E, 0x0F, 0x0E, 0x1C, 0x0E, 0x0E, 0x1C, 0x0E, 0x0E, 0x1C, 0x0E, 0x1E, 0x8E, 0x0F, 0xFC, 0xFF, 0x07, 0xFC, 0xFF, 0x03, 0xF8, 0xFF, 0x01, 0xC0, 0x7F, 0x00, 0x00, 0x00, 0x00 // Code for char 9
+ };
+
+
+
+
+
+#endif /* LIBERATION_SANS15X21_NUMBERS_H_ */
diff --git a/lcd/Liberation_Sans17x17_Alpha.h b/lcd/Liberation_Sans17x17_Alpha.h
new file mode 100644
index 0000000..83c7264
--- /dev/null
+++ b/lcd/Liberation_Sans17x17_Alpha.h
@@ -0,0 +1,54 @@
+/*
+ * Liberation_Sans17x17_Alpha.h
+ *
+ * Created: 30/03/2012 1:29:55 AM
+ * Author: andy
+ */
+
+
+#ifndef LIBERATION_SANS17X17_ALPHA_H_
+#define LIBERATION_SANS17X17_ALPHA_H_
+
+//WARNING: This Font Require X-GLCD Lib.
+// You can not use it with MikroE GLCD Lib.
+
+//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
+//MikroElektronika 2011
+//http://www.mikroe.com
+
+//GLCD FontName : Liberation_Sans17x17 46 to 90
+//GLCD FontSize : 17 x 17
+
+static const char Liberation_Sans17x17_Alpha[] PROGMEM = {
+ 0x0D, 0x00, 0x10, 0x00, 0x00, 0x1E, 0x00, 0xC0, 0x1F, 0x00, 0xF8, 0x0F, 0x00, 0xFF, 0x03, 0x00, 0x1F, 0x03, 0x00, 0x03, 0x03, 0x00, 0x1F, 0x03, 0x00, 0xFF, 0x03, 0x00, 0xF8, 0x0F, 0x00, 0xC0, 0x1F, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char A
+ 0x0D, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x63, 0x18, 0x00, 0x63, 0x18, 0x00, 0x63, 0x18, 0x00, 0x63, 0x18, 0x00, 0x63, 0x18, 0x00, 0xFF, 0x1C, 0x00, 0xFE, 0x1F, 0x00, 0xDE, 0x0F, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char B
+ 0x0D, 0x00, 0x00, 0x00, 0xF8, 0x01, 0x00, 0xFC, 0x07, 0x00, 0xFE, 0x0F, 0x00, 0x0F, 0x0E, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x07, 0x1C, 0x00, 0x0E, 0x0E, 0x00, 0x0E, 0x0E, 0x00, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char C
+ 0x0D, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x07, 0x1C, 0x00, 0x0E, 0x0E, 0x00, 0xFE, 0x0F, 0x00, 0xFC, 0x07, 0x00, 0xF0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char D
+ 0x0C, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x63, 0x18, 0x00, 0x63, 0x18, 0x00, 0x63, 0x18, 0x00, 0x63, 0x18, 0x00, 0x63, 0x18, 0x00, 0x63, 0x18, 0x00, 0x63, 0x18, 0x00, 0x03, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char E
+ 0x0B, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char F
+ 0x0E, 0x00, 0x00, 0x00, 0xF0, 0x01, 0x00, 0xFC, 0x07, 0x00, 0xFE, 0x0F, 0x00, 0x0E, 0x0E, 0x00, 0x07, 0x1C, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0xC3, 0x18, 0x00, 0xC3, 0x18, 0x00, 0xC7, 0x1C, 0x00, 0xCE, 0x0F, 0x00, 0xCE, 0x0F, 0x00, 0xC4, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char G
+ 0x0C, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x60, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x00, 0x00, 0x60, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char H
+ 0x04, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char I
+ 0x0A, 0x00, 0x06, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x1C, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x1C, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x0F, 0x00, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char J
+ 0x0E, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xE0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x70, 0x00, 0x00, 0xF8, 0x01, 0x00, 0xDC, 0x03, 0x00, 0x8E, 0x07, 0x00, 0x07, 0x0E, 0x00, 0x03, 0x1C, 0x00, 0x01, 0x18, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char K
+ 0x0B, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char L
+ 0x10, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x0F, 0x00, 0x00, 0x7E, 0x00, 0x00, 0xF0, 0x03, 0x00, 0x80, 0x1F, 0x00, 0x00, 0x1C, 0x00, 0x80, 0x1F, 0x00, 0xF0, 0x03, 0x00, 0x7E, 0x00, 0x00, 0x0F, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, // Code for char M
+ 0x0C, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x1F, 0x00, 0x00, 0x7C, 0x00, 0x00, 0xF0, 0x01, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x1E, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char N
+ 0x0E, 0x00, 0x00, 0x00, 0xF0, 0x01, 0x00, 0xFC, 0x07, 0x00, 0xFE, 0x0F, 0x00, 0x0E, 0x0E, 0x00, 0x07, 0x1C, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x07, 0x1C, 0x00, 0x0E, 0x0E, 0x00, 0xFE, 0x0F, 0x00, 0xFC, 0x07, 0x00, 0xF0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char O
+ 0x0C, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char P
+ 0x0E, 0x00, 0x00, 0x00, 0xF0, 0x03, 0x00, 0xFC, 0x07, 0x00, 0xFE, 0x0F, 0x00, 0x0E, 0x1E, 0x00, 0x07, 0x1C, 0x00, 0x03, 0x38, 0x00, 0x03, 0xF8, 0x00, 0x03, 0xF8, 0x01, 0x07, 0xDC, 0x01, 0x0E, 0x9E, 0x01, 0xFE, 0x8F, 0x01, 0xFC, 0x87, 0x01, 0xF0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Q
+ 0x0D, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0x63, 0x00, 0x00, 0xE3, 0x00, 0x00, 0xE3, 0x03, 0x00, 0xBF, 0x0F, 0x00, 0x3E, 0x1F, 0x00, 0x1C, 0x1C, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char R
+ 0x0C, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x1C, 0x0E, 0x00, 0x3E, 0x0E, 0x00, 0x7F, 0x1C, 0x00, 0x73, 0x18, 0x00, 0x63, 0x18, 0x00, 0xE3, 0x18, 0x00, 0xE7, 0x18, 0x00, 0xCF, 0x1F, 0x00, 0xCE, 0x0F, 0x00, 0x8C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char S
+ 0x0C, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0xFF, 0x1F, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char T
+ 0x0C, 0x00, 0x00, 0x00, 0xFF, 0x03, 0x00, 0xFF, 0x0F, 0x00, 0xFF, 0x0F, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x1C, 0x00, 0xFF, 0x0F, 0x00, 0xFF, 0x0F, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char U
+ 0x0D, 0x03, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0xFC, 0x01, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x18, 0x00, 0x00, 0x1F, 0x00, 0xE0, 0x0F, 0x00, 0xF8, 0x01, 0x00, 0x7F, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char V
+ 0x11, 0x07, 0x00, 0x00, 0x7F, 0x00, 0x00, 0xFF, 0x07, 0x00, 0xF0, 0x1F, 0x00, 0x00, 0x1E, 0x00, 0xC0, 0x1F, 0x00, 0xFC, 0x0F, 0x00, 0xFF, 0x00, 0x00, 0x07, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFC, 0x0F, 0x00, 0xC0, 0x1F, 0x00, 0x00, 0x1E, 0x00, 0xF0, 0x1F, 0x00, 0xFF, 0x07, 0x00, 0x7F, 0x00, 0x00, 0x07, 0x00, 0x00, // Code for char W
+ 0x0D, 0x01, 0x10, 0x00, 0x03, 0x18, 0x00, 0x07, 0x1C, 0x00, 0x1E, 0x0F, 0x00, 0xBC, 0x07, 0x00, 0xF0, 0x01, 0x00, 0xE0, 0x00, 0x00, 0xF0, 0x01, 0x00, 0xBC, 0x07, 0x00, 0x1E, 0x0F, 0x00, 0x0F, 0x1E, 0x00, 0x03, 0x18, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char X
+ 0x0C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x7C, 0x00, 0x00, 0xF0, 0x1F, 0x00, 0xC0, 0x1F, 0x00, 0xF0, 0x1F, 0x00, 0x7C, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char Y
+ 0x0A, 0x00, 0x00, 0x00, 0x03, 0x1C, 0x00, 0x03, 0x1E, 0x00, 0x83, 0x1F, 0x00, 0xC3, 0x1B, 0x00, 0xF3, 0x19, 0x00, 0x7B, 0x18, 0x00, 0x3F, 0x18, 0x00, 0x0F, 0x18, 0x00, 0x07, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Code for char Z
+ };
+
+
+
+
+#endif /* LIBERATION_SANS17X17_ALPHA_H_ */
diff --git a/lcd/Liberation_Sans20x28_Numbers.h b/lcd/Liberation_Sans20x28_Numbers.h
new file mode 100644
index 0000000..1f204b8
--- /dev/null
+++ b/lcd/Liberation_Sans20x28_Numbers.h
@@ -0,0 +1,37 @@
+/*
+ * Liberation_Sans20x28_Numbers.h
+ *
+ * Created: 30/03/2012 1:41:05 AM
+ * Author: andy
+ */
+
+
+#ifndef LIBERATION_SANS20X28_NUMBERS_H_
+#define LIBERATION_SANS20X28_NUMBERS_H_
+
+//WARNING: This Font Require X-GLCD Lib.
+// You can not use it with MikroE GLCD Lib.
+
+//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
+//MikroElektronika 2011
+//http://www.mikroe.com
+
+//GLCD FontName : Liberation_Sans20x28_Numbers
+//GLCD FontSize : 20 x 28
+
+static const char Liberation_Sans20x28_Numbers[] PROGMEM = {
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
+ 0x0A, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0xF0, 0x0F, 0x00, 0x00, 0xFF, 0x0F, 0x00, 0xF8, 0xFF, 0x0F, 0x80, 0xFF, 0xFF, 0x03, 0xFC, 0xFF, 0x3F, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xFF, 0x1F, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char /
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x0F, 0x00, 0xC0, 0xFF, 0x3F, 0x00, 0xE0, 0xFF, 0xFF, 0x00, 0xF0, 0xFF, 0xFF, 0x01, 0xF8, 0xFF, 0xFF, 0x03, 0xF8, 0x01, 0xF0, 0x03, 0x7C, 0x00, 0xC0, 0x07, 0x3C, 0x00, 0x80, 0x07, 0x3C, 0x00, 0x80, 0x07, 0x3C, 0x00, 0x80, 0x07, 0x3C, 0x00, 0x80, 0x07, 0x3C, 0x00, 0x80, 0x07, 0x7C, 0x00, 0xC0, 0x07, 0xF8, 0x01, 0xF0, 0x03, 0xF8, 0xFF, 0xFF, 0x03, 0xF0, 0xFF, 0xFF, 0x01, 0xE0, 0xFF, 0xFF, 0x00, 0xC0, 0xFF, 0x3F, 0x00, 0x00, 0xFE, 0x0F, 0x00, // Code for char 0
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x80, 0x07, 0xE0, 0x01, 0x80, 0x07, 0xF0, 0x01, 0x80, 0x07, 0xF0, 0x00, 0x80, 0x07, 0x78, 0x00, 0x80, 0x07, 0x78, 0x00, 0x80, 0x07, 0xFC, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, // Code for char 1
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x07, 0xE0, 0x03, 0xE0, 0x07, 0xF0, 0x03, 0xF0, 0x07, 0xF0, 0x03, 0xF8, 0x07, 0xF8, 0x03, 0xFC, 0x07, 0xF8, 0x00, 0xFE, 0x07, 0x7C, 0x00, 0xBE, 0x07, 0x3C, 0x00, 0x9F, 0x07, 0x3C, 0x80, 0x8F, 0x07, 0x3C, 0x80, 0x87, 0x07, 0x3C, 0xC0, 0x87, 0x07, 0x3C, 0xE0, 0x83, 0x07, 0x7C, 0xF0, 0x81, 0x07, 0x7C, 0xF8, 0x81, 0x07, 0xF8, 0xFF, 0x80, 0x07, 0xF8, 0x7F, 0x80, 0x07, 0xF0, 0x3F, 0x80, 0x07, 0xE0, 0x1F, 0x80, 0x07, 0xC0, 0x07, 0x80, 0x07, // Code for char 2
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x30, 0x00, 0xE0, 0x01, 0xF0, 0x00, 0xF0, 0x01, 0xF0, 0x01, 0xF8, 0x01, 0xF0, 0x03, 0xF8, 0x01, 0xF0, 0x03, 0xFC, 0x00, 0xE0, 0x03, 0x7C, 0x00, 0xC0, 0x07, 0x3C, 0xF0, 0x80, 0x07, 0x3C, 0xF0, 0x80, 0x07, 0x3C, 0xF0, 0x80, 0x07, 0x3C, 0xF0, 0x80, 0x07, 0x3C, 0xF8, 0x80, 0x07, 0x7C, 0xF8, 0xC1, 0x07, 0xF8, 0xFF, 0xE3, 0x07, 0xF8, 0xDF, 0xFF, 0x03, 0xF0, 0x9F, 0xFF, 0x03, 0xF0, 0x8F, 0xFF, 0x01, 0xC0, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x7E, 0x00, // Code for char 3
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0xC0, 0x3F, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0xF8, 0x3D, 0x00, 0x00, 0xFE, 0x3C, 0x00, 0x00, 0x3F, 0x3C, 0x00, 0xC0, 0x1F, 0x3C, 0x00, 0xE0, 0x07, 0x3C, 0x00, 0xF8, 0x03, 0x3C, 0x00, 0xFC, 0x00, 0x3C, 0x00, 0xFC, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x3C, 0x00, // Code for char 4
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0xFF, 0xF0, 0x00, 0xFC, 0xFF, 0xF0, 0x01, 0xFC, 0xFF, 0xF0, 0x03, 0xFC, 0xFF, 0xF0, 0x03, 0xFC, 0xFF, 0xE0, 0x07, 0x3C, 0x78, 0xC0, 0x07, 0x3C, 0x78, 0x80, 0x07, 0x3C, 0x3C, 0x80, 0x07, 0x3C, 0x3C, 0x80, 0x07, 0x3C, 0x3C, 0x80, 0x07, 0x3C, 0x3C, 0x80, 0x07, 0x3C, 0x7C, 0xC0, 0x07, 0x3C, 0xFC, 0xE0, 0x03, 0x3C, 0xF8, 0xFF, 0x03, 0x3C, 0xF8, 0xFF, 0x01, 0x3C, 0xF0, 0xFF, 0x01, 0x00, 0xE0, 0x7F, 0x00, 0x00, 0x80, 0x1F, 0x00, // Code for char 5
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x0F, 0x00, 0x80, 0xFF, 0x3F, 0x00, 0xE0, 0xFF, 0xFF, 0x00, 0xF0, 0xFF, 0xFF, 0x01, 0xF8, 0xFF, 0xFF, 0x03, 0xF8, 0xE1, 0xE1, 0x03, 0x78, 0xF0, 0xC0, 0x07, 0x3C, 0x70, 0x80, 0x07, 0x3C, 0x78, 0x80, 0x07, 0x3C, 0x78, 0x80, 0x07, 0x3C, 0x78, 0x80, 0x07, 0x7C, 0x78, 0x80, 0x07, 0xFC, 0xF8, 0xC0, 0x07, 0xF8, 0xF9, 0xE1, 0x07, 0xF8, 0xF1, 0xFF, 0x03, 0xF0, 0xF1, 0xFF, 0x03, 0xE0, 0xE0, 0xFF, 0x01, 0x80, 0xC0, 0xFF, 0x00, 0x00, 0x00, 0x3F, 0x00, // Code for char 6
+ 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x3C, 0x00, 0xC0, 0x07, 0x3C, 0x00, 0xF8, 0x07, 0x3C, 0x00, 0xFF, 0x07, 0x3C, 0xC0, 0xFF, 0x07, 0x3C, 0xF0, 0xFF, 0x07, 0x3C, 0xFC, 0x3F, 0x00, 0x3C, 0xFE, 0x03, 0x00, 0xBC, 0xFF, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0xFC, 0x0F, 0x00, 0x00, 0xFC, 0x03, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 7
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0xC0, 0x07, 0xFF, 0x00, 0xF0, 0x8F, 0xFF, 0x01, 0xF0, 0x9F, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xE3, 0x07, 0x7C, 0xF8, 0xC1, 0x07, 0x3C, 0xF0, 0x80, 0x07, 0x3C, 0xF0, 0x80, 0x07, 0x3C, 0xF0, 0x80, 0x07, 0x3C, 0xF0, 0x80, 0x07, 0x3C, 0xF0, 0x80, 0x07, 0x7C, 0xF8, 0xC1, 0x07, 0xF8, 0xFF, 0xC1, 0x07, 0xF8, 0xFF, 0xFF, 0x03, 0xF8, 0x9F, 0xFF, 0x03, 0xF0, 0x8F, 0xFF, 0x01, 0xC0, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x7E, 0x00, // Code for char 8
+ 0x14, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1F, 0x20, 0x00, 0xE0, 0x7F, 0xF0, 0x00, 0xF0, 0xFF, 0xF0, 0x01, 0xF8, 0xFF, 0xF1, 0x03, 0xF8, 0xFF, 0xF1, 0x03, 0xF8, 0xF0, 0xE3, 0x07, 0x7C, 0xE0, 0xC3, 0x07, 0x3C, 0xC0, 0x83, 0x07, 0x3C, 0xC0, 0x83, 0x07, 0x3C, 0xC0, 0x83, 0x07, 0x3C, 0xC0, 0x83, 0x07, 0x3C, 0xC0, 0xC1, 0x07, 0x7C, 0xE0, 0xC1, 0x03, 0xF8, 0xF0, 0xF0, 0x03, 0xF8, 0xFF, 0xFF, 0x01, 0xF0, 0xFF, 0xFF, 0x01, 0xE0, 0xFF, 0xFF, 0x00, 0xC0, 0xFF, 0x3F, 0x00, 0x00, 0xFE, 0x07, 0x00 // Code for char 9
+ };
+
+#endif /* LIBERATION_SANS20X28_NUMBERS_H_ */
diff --git a/lcd/Liberation_Sans27x36_Numbers.h b/lcd/Liberation_Sans27x36_Numbers.h
new file mode 100644
index 0000000..06cb3d8
--- /dev/null
+++ b/lcd/Liberation_Sans27x36_Numbers.h
@@ -0,0 +1,37 @@
+/*
+ * Liberation_Sans27x36_Numbers.h
+ *
+ * Created: 30/03/2012 1:43:14 AM
+ * Author: andy
+ */
+
+
+#ifndef LIBERATION_SANS27X36_NUMBERS_H_
+#define LIBERATION_SANS27X36_NUMBERS_H_
+
+//WARNING: This Font Require X-GLCD Lib.
+// You can not use it with MikroE GLCD Lib.
+
+//Font Generated by MikroElektronika GLCD Font Creator 1.2.0.0
+//MikroElektronika 2011
+//http://www.mikroe.com
+
+//GLCD FontName : Liberation_Sans27x36_Numbers
+//GLCD FontSize : 27 x 36
+
+static const char Liberation_Sans27x36_Numbers[] PROGMEM = {
+ 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
+ 0x0D, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0xF0, 0x0F, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0x00, 0x00, 0xF8, 0xFF, 0x0F, 0x00, 0xC0, 0xFF, 0xFF, 0x0F, 0x00, 0xFC, 0xFF, 0xFF, 0x0F, 0xE0, 0xFF, 0xFF, 0x7F, 0x00, 0xFE, 0xFF, 0xFF, 0x07, 0x00, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char /
+ 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x01, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0x01, 0xF8, 0xFF, 0xFF, 0xFF, 0x01, 0xF8, 0xFF, 0xFF, 0xFF, 0x03, 0xF8, 0x07, 0x00, 0xFC, 0x03, 0xFC, 0x00, 0x00, 0xE0, 0x07, 0x7C, 0x00, 0x00, 0xC0, 0x07, 0x7C, 0x00, 0x00, 0xC0, 0x07, 0x7C, 0x00, 0x00, 0xC0, 0x07, 0x7C, 0x00, 0x00, 0xC0, 0x07, 0x7C, 0x00, 0x00, 0xE0, 0x07, 0xFC, 0x00, 0x00, 0xF0, 0x07, 0xF8, 0x07, 0x00, 0xFC, 0x03, 0xF8, 0xFF, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0xFF, 0x01, 0xF0, 0xFF, 0xFF, 0xFF, 0x01, 0xE0, 0xFF, 0xFF, 0xFF, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0xFE, 0xFF, 0x0F, 0x00, 0x00, 0xF0, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 0
+ 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0xC0, 0x07, 0x80, 0x0F, 0x00, 0xC0, 0x07, 0xC0, 0x07, 0x00, 0xC0, 0x07, 0xE0, 0x07, 0x00, 0xC0, 0x07, 0xE0, 0x03, 0x00, 0xC0, 0x07, 0xF0, 0x01, 0x00, 0xC0, 0x07, 0xF8, 0x01, 0x00, 0xC0, 0x07, 0xF8, 0x00, 0x00, 0xC0, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 1
+ 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0xE0, 0x07, 0x80, 0x0F, 0x00, 0xF0, 0x07, 0xE0, 0x0F, 0x00, 0xFC, 0x07, 0xF0, 0x0F, 0x00, 0xFE, 0x07, 0xF0, 0x0F, 0x00, 0xFF, 0x07, 0xF8, 0x0F, 0x80, 0xFF, 0x07, 0xF8, 0x0F, 0xC0, 0xFF, 0x07, 0xFC, 0x03, 0xE0, 0xFF, 0x07, 0xFC, 0x00, 0xF0, 0xDF, 0x07, 0x7C, 0x00, 0xF8, 0xCF, 0x07, 0x7C, 0x00, 0xFC, 0xC7, 0x07, 0x7C, 0x00, 0xFE, 0xC3, 0x07, 0x7C, 0x00, 0xFF, 0xC1, 0x07, 0xFC, 0x80, 0xFF, 0xC0, 0x07, 0xFC, 0xC1, 0x7F, 0xC0, 0x07, 0xF8, 0xFF, 0x3F, 0xC0, 0x07, 0xF8, 0xFF, 0x1F, 0xC0, 0x07, 0xF8, 0xFF, 0x0F, 0xC0, 0x07, 0xF0, 0xFF, 0x07, 0xC0, 0x07, 0xE0, 0xFF, 0x03, 0xC0, 0x07, 0xC0, 0xFF, 0x01, 0xC0, 0x07, 0x00, 0x7F, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 2
+ 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x0E, 0x00, 0x3E, 0x00, 0x80, 0x0F, 0x00, 0x7E, 0x00, 0xE0, 0x0F, 0x00, 0xFE, 0x00, 0xE0, 0x0F, 0x00, 0xFE, 0x01, 0xF0, 0x0F, 0x00, 0xFE, 0x03, 0xF8, 0x0F, 0x00, 0xFE, 0x03, 0xF8, 0x0F, 0x00, 0xF8, 0x03, 0xFC, 0x03, 0x00, 0xE0, 0x07, 0xFC, 0x00, 0x1F, 0xE0, 0x07, 0x7C, 0x00, 0x1F, 0xC0, 0x07, 0x7C, 0x00, 0x1F, 0xC0, 0x07, 0x7C, 0x00, 0x1F, 0xC0, 0x07, 0x7C, 0x00, 0x1F, 0xC0, 0x07, 0xFC, 0x80, 0x3F, 0xC0, 0x07, 0xFC, 0xC1, 0x3F, 0xE0, 0x07, 0xF8, 0xFF, 0x7F, 0xF0, 0x07, 0xF8, 0xFF, 0xFB, 0xFF, 0x03, 0xF8, 0xFF, 0xFB, 0xFF, 0x03, 0xF0, 0xFF, 0xF9, 0xFF, 0x03, 0xE0, 0xFF, 0xF0, 0xFF, 0x01, 0xC0, 0x7F, 0xF0, 0xFF, 0x00, 0x00, 0x3F, 0xE0, 0x7F, 0x00, 0x00, 0x00, 0x80, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 3
+ 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0xE0, 0x0F, 0x00, 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x00, 0x00, 0xFC, 0x0F, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0x00, 0x00, 0x80, 0xFF, 0x0F, 0x00, 0x00, 0xE0, 0x9F, 0x0F, 0x00, 0x00, 0xF0, 0x8F, 0x0F, 0x00, 0x00, 0xFC, 0x83, 0x0F, 0x00, 0x00, 0xFE, 0x81, 0x0F, 0x00, 0x80, 0x7F, 0x80, 0x0F, 0x00, 0xC0, 0x3F, 0x80, 0x0F, 0x00, 0xF0, 0x0F, 0x80, 0x0F, 0x00, 0xF8, 0x07, 0x80, 0x0F, 0x00, 0xFC, 0x01, 0x80, 0x0F, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x80, 0x0F, 0x00, 0x00, 0x00, 0x80, 0x0F, 0x00, 0x00, 0x00, 0x80, 0x0F, 0x00, 0x00, 0x00, 0x80, 0x0F, 0x00, // Code for char 4
+ 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0xF0, 0x0F, 0x3C, 0x00, 0xFC, 0xFF, 0x0F, 0xFC, 0x00, 0xFC, 0xFF, 0x0F, 0xFC, 0x01, 0xFC, 0xFF, 0x0F, 0xFC, 0x01, 0xFC, 0xFF, 0x0F, 0xFC, 0x03, 0xFC, 0xFF, 0x0F, 0xFC, 0x03, 0xFC, 0xFF, 0x0F, 0xF8, 0x07, 0x7C, 0xC0, 0x07, 0xE0, 0x07, 0x7C, 0xC0, 0x03, 0xC0, 0x07, 0x7C, 0xE0, 0x03, 0xC0, 0x07, 0x7C, 0xE0, 0x03, 0xC0, 0x07, 0x7C, 0xE0, 0x03, 0xC0, 0x07, 0x7C, 0xE0, 0x03, 0xC0, 0x07, 0x7C, 0xE0, 0x07, 0xE0, 0x07, 0x7C, 0xE0, 0x07, 0xE0, 0x07, 0x7C, 0xE0, 0x1F, 0xF8, 0x03, 0x7C, 0xC0, 0xFF, 0xFF, 0x03, 0x7C, 0xC0, 0xFF, 0xFF, 0x03, 0x7C, 0x80, 0xFF, 0xFF, 0x01, 0x7C, 0x80, 0xFF, 0xFF, 0x00, 0x7C, 0x00, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 5
+ 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x01, 0x00, 0x00, 0xFE, 0xFF, 0x0F, 0x00, 0x80, 0xFF, 0xFF, 0x3F, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0x00, 0xF0, 0xFF, 0xFF, 0xFF, 0x01, 0xF8, 0xFF, 0xFF, 0xFF, 0x03, 0xF8, 0x03, 0x1F, 0xF8, 0x03, 0xFC, 0x81, 0x0F, 0xE0, 0x07, 0xFC, 0x80, 0x07, 0xE0, 0x07, 0x7C, 0xC0, 0x07, 0xC0, 0x07, 0x7C, 0xC0, 0x07, 0xC0, 0x07, 0x7C, 0xC0, 0x07, 0xC0, 0x07, 0xFC, 0xC0, 0x07, 0xC0, 0x07, 0xFC, 0xC1, 0x0F, 0xE0, 0x07, 0xFC, 0xC3, 0x3F, 0xF8, 0x07, 0xF8, 0xC3, 0xFF, 0xFF, 0x03, 0xF8, 0x83, 0xFF, 0xFF, 0x03, 0xF0, 0x83, 0xFF, 0xFF, 0x01, 0xF0, 0x01, 0xFF, 0xFF, 0x01, 0xC0, 0x01, 0xFE, 0xFF, 0x00, 0x00, 0x01, 0xFC, 0x3F, 0x00, 0x00, 0x00, 0xF0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 6
+ 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0xE0, 0x07, 0x7C, 0x00, 0x00, 0xFC, 0x07, 0x7C, 0x00, 0x80, 0xFF, 0x07, 0x7C, 0x00, 0xE0, 0xFF, 0x07, 0x7C, 0x00, 0xF8, 0xFF, 0x07, 0x7C, 0x00, 0xFE, 0xFF, 0x07, 0x7C, 0x80, 0xFF, 0xFF, 0x07, 0x7C, 0xE0, 0xFF, 0x1F, 0x00, 0x7C, 0xF0, 0xFF, 0x01, 0x00, 0x7C, 0xFC, 0x3F, 0x00, 0x00, 0x7C, 0xFE, 0x0F, 0x00, 0x00, 0x7C, 0xFF, 0x03, 0x00, 0x00, 0xFC, 0xFF, 0x00, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0x00, 0xFC, 0x0F, 0x00, 0x00, 0x00, 0xFC, 0x07, 0x00, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 7
+ 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x1F, 0x00, 0x80, 0x1F, 0xE0, 0x7F, 0x00, 0xC0, 0x7F, 0xF0, 0xFF, 0x00, 0xE0, 0xFF, 0xF8, 0xFF, 0x01, 0xF0, 0xFF, 0xFD, 0xFF, 0x01, 0xF8, 0xFF, 0xFD, 0xFF, 0x03, 0xF8, 0xFF, 0xFD, 0xFF, 0x03, 0xF8, 0xFF, 0x3F, 0xF0, 0x07, 0xFC, 0xE1, 0x1F, 0xE0, 0x07, 0xFC, 0xC0, 0x0F, 0xC0, 0x07, 0x7C, 0x80, 0x0F, 0xC0, 0x07, 0x7C, 0x80, 0x0F, 0xC0, 0x07, 0x7C, 0x80, 0x0F, 0xC0, 0x07, 0x7C, 0x80, 0x0F, 0xC0, 0x07, 0xFC, 0xC0, 0x0F, 0xC0, 0x07, 0xFC, 0xE1, 0x1F, 0xE0, 0x07, 0xFC, 0xFF, 0x3F, 0xF0, 0x07, 0xF8, 0xFF, 0xFD, 0xFF, 0x03, 0xF8, 0xFF, 0xFD, 0xFF, 0x03, 0xF0, 0xFF, 0xFD, 0xFF, 0x01, 0xF0, 0xFF, 0xF8, 0xFF, 0x01, 0xC0, 0x7F, 0xF8, 0xFF, 0x00, 0x80, 0x1F, 0xF0, 0x7F, 0x00, 0x00, 0x00, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 8
+ 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x18, 0x00, 0xE0, 0xFF, 0x0F, 0x78, 0x00, 0xF0, 0xFF, 0x1F, 0xF8, 0x00, 0xF0, 0xFF, 0x3F, 0xFC, 0x01, 0xF8, 0xFF, 0x3F, 0xFC, 0x03, 0xF8, 0xFF, 0x7F, 0xFC, 0x03, 0xFC, 0x83, 0x7F, 0xFC, 0x07, 0xFC, 0x00, 0x7E, 0xF0, 0x07, 0x7C, 0x00, 0x7C, 0xE0, 0x07, 0x7C, 0x00, 0x7C, 0xC0, 0x07, 0x7C, 0x00, 0x7C, 0xC0, 0x07, 0x7C, 0x00, 0x3C, 0xC0, 0x07, 0xFC, 0x00, 0x3C, 0xE0, 0x07, 0xFC, 0x00, 0x1E, 0xF0, 0x07, 0xF8, 0x03, 0x1F, 0xF8, 0x03, 0xF8, 0xFF, 0xFF, 0xFF, 0x03, 0xF0, 0xFF, 0xFF, 0xFF, 0x01, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0xE0, 0xFF, 0xFF, 0x7F, 0x00, 0x80, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0xFE, 0xFF, 0x0F, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Code for char 9
+ };
+
+#endif /* LIBERATION_SANS27X36_NUMBERS_H_ */
diff --git a/lcd/ST7565R.c b/lcd/ST7565R.c
new file mode 100644
index 0000000..9b91610
--- /dev/null
+++ b/lcd/ST7565R.c
@@ -0,0 +1,213 @@
+/**
+ * \file ST7565R.c
+ * \brief Functions relating to ST7565R.
+ * \author Andy Gock
+ * \see glcd.h
+ */
+
+#include "ST7565R.h"
+#include "glcd_spi.h"
+
+void glcd_command(uint8_t c)
+{
+ GLCD_A0_LOW();
+ glcd_spi_write(c);
+}
+
+void glcd_data(uint8_t c)
+{
+ GLCD_A0_HIGH();
+ glcd_spi_write(c);
+}
+
+void glcd_set_contrast(uint8_t val) {
+ /* Can set a 6-bit value (0 to 63) */
+
+ /* Must send this command byte before setting the contrast */
+ glcd_command(0x81);
+
+ /* Set the contrat value ("electronic volumne register") */
+ if (val > 63) {
+ glcd_command(63);
+ } else {
+ glcd_command(val);
+ }
+ return;
+}
+
+void glcd_power_down(void)
+{
+ /* Command sequence as in ST7565 datasheet */
+ glcd_command(0xac); // Static indicator off
+ glcd_command(0x00); // Static indicator register, not blinking
+ glcd_command(0xae); // Display OFF
+ glcd_command(0xa5); // Display all points ON
+
+ /* Display is now in sleep mode */
+}
+
+void glcd_power_up(void)
+{
+ glcd_command(0xa4); // Display all points OFF
+ glcd_command(0xad); // Static indicator ON
+ glcd_command(0x00); // Static indicator register, not Blinking
+ glcd_command(0xaf);
+
+ return;
+}
+
+void glcd_set_y_address(uint8_t y)
+{
+ glcd_command(ST7565R_PAGE_ADDRESS_SET | (0x0F & y)); /* 0x0F = 0b00001111 */
+}
+
+void glcd_set_x_address(uint8_t x)
+{
+ glcd_set_column_upper(x);
+ glcd_set_column_lower(x);
+}
+
+void glcd_all_on(void)
+{
+ glcd_command(ST7565R_DISPLAY_ALL_ON);
+}
+
+void glcd_normal(void)
+{
+ glcd_command(ST7565R_DISPLAY_NORMAL);
+}
+
+void glcd_set_column_upper(uint8_t addr)
+{
+ glcd_command(ST7565R_COLUMN_ADDRESS_SET_UPPER | (addr >> 4));
+}
+
+void glcd_set_column_lower(uint8_t addr)
+{
+ glcd_command(ST7565R_COLUMN_ADDRESS_SET_LOWER | (0x0f & addr));
+}
+
+void glcd_set_start_line(uint8_t addr)
+{
+ glcd_command( ST7565R_SET_START_LINE | (0x3F & addr)); /* 0x3F == 0b00111111 */
+}
+
+/** Clear the display immediately, does not buffer */
+void glcd_clear_now(void)
+{
+ uint8_t page;
+ for (page = 0; page < GLCD_NUMBER_OF_BANKS1; page++) {
+ uint8_t col;
+ glcd_set_y_address(page);
+ glcd_set_x_address(0);
+ for (col = 0; col < GLCD_NUMBER_OF_COLS1; col++) {
+ glcd_data(0);
+ }
+ }
+}
+
+void glcd_pattern(void)
+{
+ uint8_t page;
+ for (page = 0; page < GLCD_NUMBER_OF_BANKS1; page++) {
+ uint8_t col;
+ glcd_set_y_address(page);
+ glcd_set_x_address(0);
+ for (col = 0; col < GLCD_NUMBER_OF_COLS1; col++) {
+ glcd_data( (col / 8 + 2) % 2 == 1 ? 0xff : 0x00 );
+ }
+ }
+}
+
+
+#define GLCD_INIT_NHD_C12864WC_FSW_FBW_3V3_M
+uint8_t contrast = 37;
+void glcd_ST7565R_init(void) {
+
+#if defined(GLCD_INIT_NHD_C12832A1Z_FSW_FBW_3V3)
+
+ /* Init sequence based on datasheet example code for NHD-C12832A1Z-FSW-FBW-3V3 */
+ /* Datasheet says max SCK frequency 20MHz for this LCD */
+ /* We use "reverse direction" for common output mode, as opposed to datasheet specifying "normal direction" */
+
+ glcd_command(0xa0); /* ADC select in normal mode */
+ glcd_command(0xae); /* Display OFF */
+ glcd_command(0xc8); /* Common output mode select: reverse direction (last 3 bits are ignored) */
+ glcd_command(0xa2); /* LCD bias set at 1/9 */
+ glcd_command(0x2f); /* Power control set to operating mode: 7 */
+ glcd_command(0x21); /* Internal resistor ratio, set to: 1 */
+ glcd_set_contrast(40); /* Set contrast, value experimentally determined, can set to 6-bit value, 0 to 63 */
+ glcd_command(0xaf); /* Display on */
+
+#elif defined(GLCD_INIT_NHD_C12864A1Z_FSW_FBW_HTT)
+
+ /* Init sequence based on datasheet example code for NHD-C12864A1Z-FSW-FBW-HTT */
+ /* Datasheet says max SCK frequency 2.5MHz for this LCD */
+ /* We use "reverse direction" for common output mode, as opposed to datasheet specifying "normal direction" */
+
+ glcd_command(0xa0); /* ADC select in normal mode */
+ glcd_command(0xae); /* Display OFF */
+ glcd_command(0xc8); /* Common output mode select: reverse direction (last 3 bits are ignored) */
+ glcd_command(0xa2); /* LCD bias set at 1/9 */
+ glcd_command(0x2f); /* Power control set to operating mode: 7 */
+ glcd_command(0x26); /* Internal resistor ratio, set to: 6 */
+ glcd_set_contrast(30); /* Set contrast, value experimentally determined */
+ glcd_command(0xaf); /* Display on */
+
+#elif defined(GLCD_INIT_NHD_C12864WC_FSW_FBW_3V3_M)
+
+ /* Init sequence for NHD-C12864WC-FSW-FBW-3V3-M */
+
+ glcd_command(ST7565R_RESET); /* Internal reset */
+ glcd_command(0xa2); /* 1/9 bias */
+ glcd_command(0xa0); /* ADC select, normal */
+ glcd_command(0xc8); /* Com output reverse */
+ glcd_command(0xa4); /* Display all points normal */
+ glcd_command(0x40); /* Display start line set */
+ glcd_command(0x25); /* Internal resistor ratio */
+ glcd_set_contrast(contrast); /* Set contrast value, experimentally determined, value 0 to 63 */
+ glcd_command(0x2f); /* Power controller set */
+ glcd_command(0xaf); /* Display on */
+
+#elif defined(GLCD_INIT_ZOLEN_12864_FFSSWE_NAA)
+ /* Init sequence for Zolen 128x64 module with
+ * size 40x35mm. Chip ST7567 */
+
+ glcd_command(0xa0); /* ADC select in normal mode */
+ glcd_command(0xae); /* Display OFF */
+ glcd_command(0xc8); /* Common output mode select: reverse direction (last 3 bits are ignored) */
+ glcd_command(0xa3); /* LCD bias set at 1/9 */
+ glcd_command(0x2f); /* Power control set to operating mode: 7 */
+ glcd_command(0x24); /* Internal resistor ratio, set to: 6 */
+ glcd_set_contrast(45); /* Set contrast, value experimentally determined, value 0 to 63 */
+ glcd_command(0xaf); /* Display on */
+
+#elif defined(GLCD_MY)
+
+ glcd_command(0xa2); /* 1/9 bias */
+ glcd_command(0xa0); /* Select SEG Normal Direction */
+ glcd_command(0xc0); /* Select COM Normal Direction */
+ glcd_command(0x24); /* Select Regulation Ration=5.0 */
+ glcd_command(0x81); /* Set EV Command */
+ glcd_command(0x20); /* Set EV Command */
+ glcd_command(0x2c); /* Power controller set */
+ glcd_command(0x2e); /* Power controller set */
+ glcd_command(0x2f); /* Power controller set */
+ glcd_command(0xaf); /* Display on */
+#else
+
+ /* Default init sequence */
+ /* Currently just set the same as GLCD_INIT_NHD_C12864A1Z_FSW_FBW_HTT */
+
+ glcd_command(0xa0); /* ADC select in normal mode */
+ glcd_command(0xae); /* Display OFF */
+ glcd_command(0xc8); /* Common output mode select: reverse direction (last 3 bits are ignored) */
+ glcd_command(0xa2); /* LCD bias set at 1/9 */
+ glcd_command(0x2f); /* Power control set to operating mode: 7 */
+ glcd_command(0x26); /* Internal resistor ratio, set to: 6 */
+ glcd_set_contrast(20); /* Set contrast, value experimentally determined, value 0 to 63 */
+ glcd_command(0xaf); /* Display on */
+
+#endif
+
+}
diff --git a/lcd/ST7565R.h b/lcd/ST7565R.h
new file mode 100644
index 0000000..1c2b06a
--- /dev/null
+++ b/lcd/ST7565R.h
@@ -0,0 +1,108 @@
+/**
+ * \file ST7565R.h
+ * \brief Constants relating to ST7565R LCD controller.
+ * \author Andy Gock
+ *
+ * Constants and functions specific to ST7565R.
+ * Tested with Newhaven Display model NHD-C12864WC-FSW-FBW-3V3-M
+ *
+ * \todo Need to move functions to be controller independent
+ *
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef ST7565R_H_
+#define ST7565R_H_
+
+#include "stdint.h"
+
+/* Commands */
+#define ST7565R_DISPLAY_ON 0xAF /* 0b10101111 */
+#define ST7565R_DISPLAY_OFF 0xAE /* 0b10101110 */
+#define ST7565R_PAGE_ADDRESS_SET 0xB0 /* 0b10110000 */
+#define ST7565R_COLUMN_ADDRESS_SET_LOWER 0x00
+#define ST7565R_COLUMN_ADDRESS_SET_UPPER 0x10
+#define ST7565R_DISPLAY_NORMAL 0xA4 /* 0b10100100 */
+#define ST7565R_DISPLAY_ALL_ON 0xA5 /* 0b10100101 */
+#define ST7565R_NORMAL 0xA0 /* 0b10100000 */
+#define ST7565R_REVERSE 0xA1 /* 0b10100001 */
+#define ST7565R_RESET 0xE2 /* 0b11100010 */
+#define ST7565R_SET_START_LINE (1<<6)
+
+ /**
+ * User specified GLCD width in pixels
+ * Set to 0 for automatic assignment based on controller.
+ */
+#define GLCD_LCD_WIDTH1 128
+
+ /**
+ * User specified GLCD height in pixels
+ * Set to 0 for automatic assignment based on controller.
+ */
+
+#define GLCD_LCD_HEIGHT1 64
+
+
+#define GLCD_NUMBER_OF_BANKS1 (GLCD_LCD_WIDTH1 / 8)
+#define GLCD_NUMBER_OF_COLS1 GLCD_LCD_WIDTH1
+
+/* These functions only available on ST7565 implementation (for now) */
+
+/* Private functions */
+void glcd_set_column_upper(uint8_t addr);
+void glcd_set_column_lower(uint8_t addr);
+
+/** All display points on (native) */
+void glcd_all_on(void);
+
+/** Set to normal mode */
+void glcd_normal(void);
+
+/** Set start line/page */
+void glcd_set_start_line(uint8_t addr);
+
+/** Clear the display immediately, does not buffer */
+void glcd_clear_now(void);
+
+/** Show a black and white line pattern on the display */
+void glcd_pattern(void);
+
+/** Init ST7565R controller / display */
+void glcd_ST7565R_init(void);
+
+void glcd_write(void);
+
+void glcd_set_y_address(uint8_t y);
+
+void glcd_set_x_address(uint8_t x);
+
+void glcd_data(uint8_t c);
+
+#endif /* ST7565R_H_ */
diff --git a/lcd/font5x7.h b/lcd/font5x7.h
new file mode 100644
index 0000000..b800fbf
--- /dev/null
+++ b/lcd/font5x7.h
@@ -0,0 +1,118 @@
+/*
+ * font5x7.h
+ *
+ * Created: 28/03/2012 1:52:20 AM
+ * Author: andy
+ */
+
+// Title : Graphic LCD Font (Ascii Charaters)
+// Author : Pascal Stang
+
+#ifndef FONT5X7_H_
+#define FONT5X7_H_
+
+// standard ascii 5x7 font
+// defines ascii characters 0x20-0x7F (32-127)
+static const char Font5x7[] PROGMEM = {
+ 0x00, 0x00, 0x00, 0x00, 0x00,// (space)
+ 0x00, 0x00, 0x5F, 0x00, 0x00,// !
+ 0x00, 0x07, 0x00, 0x07, 0x00,// "
+ 0x14, 0x7F, 0x14, 0x7F, 0x14,// #
+ 0x24, 0x2A, 0x7F, 0x2A, 0x12,// $
+ 0x23, 0x13, 0x08, 0x64, 0x62,// %
+ 0x36, 0x49, 0x55, 0x22, 0x50,// &
+ 0x00, 0x05, 0x03, 0x00, 0x00,// '
+ 0x00, 0x1C, 0x22, 0x41, 0x00,// (
+ 0x00, 0x41, 0x22, 0x1C, 0x00,// )
+ 0x08, 0x2A, 0x1C, 0x2A, 0x08,// *
+ 0x08, 0x08, 0x3E, 0x08, 0x08,// +
+ 0x00, 0x50, 0x30, 0x00, 0x00,// ,
+ 0x08, 0x08, 0x08, 0x08, 0x08,// -
+ 0x00, 0x60, 0x60, 0x00, 0x00,// .
+ 0x20, 0x10, 0x08, 0x04, 0x02,// /
+ 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
+ 0x00, 0x42, 0x7F, 0x40, 0x00,// 1
+ 0x42, 0x61, 0x51, 0x49, 0x46,// 2
+ 0x21, 0x41, 0x45, 0x4B, 0x31,// 3
+ 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
+ 0x27, 0x45, 0x45, 0x45, 0x39,// 5
+ 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
+ 0x01, 0x71, 0x09, 0x05, 0x03,// 7
+ 0x36, 0x49, 0x49, 0x49, 0x36,// 8
+ 0x06, 0x49, 0x49, 0x29, 0x1E,// 9
+ 0x00, 0x36, 0x36, 0x00, 0x00,// :
+ 0x00, 0x56, 0x36, 0x00, 0x00,// ;
+ 0x00, 0x08, 0x14, 0x22, 0x41,// <
+ 0x14, 0x14, 0x14, 0x14, 0x14,// =
+ 0x41, 0x22, 0x14, 0x08, 0x00,// >
+ 0x02, 0x01, 0x51, 0x09, 0x06,// ?
+ 0x32, 0x49, 0x79, 0x41, 0x3E,// @
+ 0x7E, 0x11, 0x11, 0x11, 0x7E,// A
+ 0x7F, 0x49, 0x49, 0x49, 0x36,// B
+ 0x3E, 0x41, 0x41, 0x41, 0x22,// C
+ 0x7F, 0x41, 0x41, 0x22, 0x1C,// D
+ 0x7F, 0x49, 0x49, 0x49, 0x41,// E
+ 0x7F, 0x09, 0x09, 0x01, 0x01,// F
+ 0x3E, 0x41, 0x41, 0x51, 0x32,// G
+ 0x7F, 0x08, 0x08, 0x08, 0x7F,// H
+ 0x00, 0x41, 0x7F, 0x41, 0x00,// I
+ 0x20, 0x40, 0x41, 0x3F, 0x01,// J
+ 0x7F, 0x08, 0x14, 0x22, 0x41,// K
+ 0x7F, 0x40, 0x40, 0x40, 0x40,// L
+ 0x7F, 0x02, 0x04, 0x02, 0x7F,// M
+ 0x7F, 0x04, 0x08, 0x10, 0x7F,// N
+ 0x3E, 0x41, 0x41, 0x41, 0x3E,// O
+ 0x7F, 0x09, 0x09, 0x09, 0x06,// P
+ 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
+ 0x7F, 0x09, 0x19, 0x29, 0x46,// R
+ 0x46, 0x49, 0x49, 0x49, 0x31,// S
+ 0x01, 0x01, 0x7F, 0x01, 0x01,// T
+ 0x3F, 0x40, 0x40, 0x40, 0x3F,// U
+ 0x1F, 0x20, 0x40, 0x20, 0x1F,// V
+ 0x7F, 0x20, 0x18, 0x20, 0x7F,// W
+ 0x63, 0x14, 0x08, 0x14, 0x63,// X
+ 0x03, 0x04, 0x78, 0x04, 0x03,// Y
+ 0x61, 0x51, 0x49, 0x45, 0x43,// Z
+ 0x00, 0x00, 0x7F, 0x41, 0x41,// [
+ 0x02, 0x04, 0x08, 0x10, 0x20,// "\"
+ 0x41, 0x41, 0x7F, 0x00, 0x00,// ]
+ 0x04, 0x02, 0x01, 0x02, 0x04,// ^
+ 0x40, 0x40, 0x40, 0x40, 0x40,// _
+ 0x00, 0x01, 0x02, 0x04, 0x00,// `
+ 0x20, 0x54, 0x54, 0x54, 0x78,// a
+ 0x7F, 0x48, 0x44, 0x44, 0x38,// b
+ 0x38, 0x44, 0x44, 0x44, 0x20,// c
+ 0x38, 0x44, 0x44, 0x48, 0x7F,// d
+ 0x38, 0x54, 0x54, 0x54, 0x18,// e
+ 0x08, 0x7E, 0x09, 0x01, 0x02,// f
+ 0x08, 0x14, 0x54, 0x54, 0x3C,// g
+ 0x7F, 0x08, 0x04, 0x04, 0x78,// h
+ 0x00, 0x44, 0x7D, 0x40, 0x00,// i
+ 0x20, 0x40, 0x44, 0x3D, 0x00,// j
+ 0x00, 0x7F, 0x10, 0x28, 0x44,// k
+ 0x00, 0x41, 0x7F, 0x40, 0x00,// l
+ 0x7C, 0x04, 0x18, 0x04, 0x78,// m
+ 0x7C, 0x08, 0x04, 0x04, 0x78,// n
+ 0x38, 0x44, 0x44, 0x44, 0x38,// o
+ 0x7C, 0x14, 0x14, 0x14, 0x08,// p
+ 0x08, 0x14, 0x14, 0x18, 0x7C,// q
+ 0x7C, 0x08, 0x04, 0x04, 0x08,// r
+ 0x48, 0x54, 0x54, 0x54, 0x20,// s
+ 0x04, 0x3F, 0x44, 0x40, 0x20,// t
+ 0x3C, 0x40, 0x40, 0x20, 0x7C,// u
+ 0x1C, 0x20, 0x40, 0x20, 0x1C,// v
+ 0x3C, 0x40, 0x30, 0x40, 0x3C,// w
+ 0x44, 0x28, 0x10, 0x28, 0x44,// x
+ 0x0C, 0x50, 0x50, 0x50, 0x3C,// y
+ 0x44, 0x64, 0x54, 0x4C, 0x44,// z
+ 0x00, 0x08, 0x36, 0x41, 0x00,// {
+ 0x00, 0x00, 0x7F, 0x00, 0x00,// |
+ 0x00, 0x41, 0x36, 0x08, 0x00,// }
+ 0x08, 0x08, 0x2A, 0x1C, 0x08,// ->
+ 0x08, 0x1C, 0x2A, 0x08, 0x08 // <-
+};
+
+
+
+
+#endif /* FONT5X7_H_ */
diff --git a/lcd/glcd.c b/lcd/glcd.c
new file mode 100644
index 0000000..a0f1461
--- /dev/null
+++ b/lcd/glcd.c
@@ -0,0 +1,242 @@
+/**
+ \file glcd.c
+ \author Andy Gock
+ \brief Basic GLCD functions affecting bounding box manipulation,
+ clearing of screen and buffers, and basic scroll functions.
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <string.h>
+#include <stdio.h>
+#include "glcd.h"
+
+/** \addtogroup GlobalVars Global Variables
+ * @{
+ */
+
+/**
+ * Screen buffer
+ *
+ * Requires at least one bit for every pixel (e.g 504 bytes for 48x84 LCD)
+ */
+uint8_t glcd_buffer[GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8];
+
+/**
+ * Keeps track of bounding box of area on LCD which need to be
+ * updated next reresh cycle
+ */
+glcd_BoundingBox_t glcd_bbox;
+
+/**
+ * Pointer to screen buffer currently in use.
+ */
+uint8_t* glcd_buffer_selected;
+
+uint8_t glcd_disp_reverse_en = 0;
+
+/**
+ * Pointer to bounding box currently in use.
+ */
+glcd_BoundingBox_t* glcd_bbox_selected;
+
+/** @} */
+
+void glcd_set_reverse_sta(uint8_t sta)
+{
+ if(!sta)
+ glcd_disp_reverse_en = 0;
+ else
+ glcd_disp_reverse_en = 1;
+}
+
+uint8_t glcd_get_reverse_sta(void)
+{
+ return glcd_disp_reverse_en;
+}
+
+void glcd_update_bbox(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax)
+{
+ /* Keep and check bounding box within limits of LCD screen dimensions */
+ if(xmin > (GLCD_LCD_WIDTH-1))
+ {
+ xmin = GLCD_LCD_WIDTH-1;
+ }
+ if(xmax > (GLCD_LCD_WIDTH-1))
+ {
+ xmax = GLCD_LCD_WIDTH-1;
+ }
+
+ if(ymin > (GLCD_LCD_HEIGHT-1))
+ {
+ ymin = GLCD_LCD_HEIGHT-1;
+ }
+ if(ymax > (GLCD_LCD_HEIGHT-1))
+ {
+ ymax = GLCD_LCD_HEIGHT-1;
+ }
+
+ /* Update the bounding box size */
+ if(xmin < glcd_bbox_selected->x_min)
+ {
+ glcd_bbox_selected->x_min = xmin;
+ }
+ if(xmax > glcd_bbox_selected->x_max)
+ {
+ glcd_bbox_selected->x_max = xmax;
+ }
+ if(ymin < glcd_bbox_selected->y_min)
+ {
+ glcd_bbox_selected->y_min = ymin;
+ }
+ if(ymax > glcd_bbox_selected->y_max)
+ {
+ glcd_bbox_selected->y_max = ymax;
+ }
+}
+
+void glcd_reset_bbox()
+{
+ /* Used after physically writing to the LCD */
+ glcd_bbox_selected->x_min = GLCD_LCD_WIDTH - 1;
+ glcd_bbox_selected->x_max = 0;
+ glcd_bbox_selected->y_min = GLCD_LCD_HEIGHT -1;
+ glcd_bbox_selected->y_max = 0;
+}
+
+void glcd_bbox_reset()
+{
+ glcd_reset_bbox();
+}
+
+void glcd_bbox_refresh()
+{
+ /* Marks bounding box as entire screen, so on next glcd_write(), it writes the entire buffer to the LCD */
+ glcd_bbox_selected->x_min = 0;
+ glcd_bbox_selected->x_max = GLCD_LCD_WIDTH - 1;
+ glcd_bbox_selected->y_min = 0;
+ glcd_bbox_selected->y_max = GLCD_LCD_HEIGHT -1;
+}
+
+void glcd_clear(void)
+{
+ memset(glcd_buffer_selected, 0x00, GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8);
+ glcd_update_bbox(0,0,GLCD_LCD_WIDTH - 1,GLCD_LCD_HEIGHT - 1);
+ glcd_write();
+}
+
+void glcd_clear_buffer(void)
+{
+ memset(glcd_buffer_selected, 0x00, GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8);
+ glcd_update_bbox(0,0,GLCD_LCD_WIDTH - 1,GLCD_LCD_HEIGHT - 1);
+}
+
+void glcd_select_screen(uint8_t* buffer, glcd_BoundingBox_t* bbox)
+{
+ glcd_buffer_selected = buffer;
+ glcd_bbox_selected = bbox;
+}
+
+void glcd_scroll(int8_t x, int8_t y)
+{
+ /** \todo Skeleton */
+
+ uint8_t row;
+
+ for(row=0; row<(GLCD_LCD_HEIGHT / 8); row++)
+ {
+ uint8_t x;
+ for(x=0; x<GLCD_LCD_WIDTH; x++)
+ {
+
+ }
+ }
+}
+
+void glcd_scroll_line(void)
+{
+ uint8_t y;
+ uint8_t number_of_rows = GLCD_LCD_HEIGHT / 8;
+ for(y=0; y<number_of_rows; y++)
+ {
+ if(y < (number_of_rows - 1))
+ {
+ /* All lines except the last */
+ memcpy(glcd_buffer_selected + y*GLCD_LCD_WIDTH,
+ glcd_buffer_selected + y*GLCD_LCD_WIDTH + GLCD_LCD_WIDTH, GLCD_LCD_WIDTH);
+ }
+ else
+ {
+ /* Last line, clear it */
+ memset(glcd_buffer_selected + (number_of_rows - 1)*GLCD_LCD_WIDTH, 0x00, GLCD_LCD_WIDTH);
+ }
+ }
+ glcd_update_bbox(0,0,GLCD_LCD_WIDTH - 1,GLCD_LCD_HEIGHT - 1);
+}
+
+void glcd_init(void)
+{
+ glcd_HW_init();
+
+ glcd_select_screen(glcd_buffer,&glcd_bbox);
+ glcd_clear();
+}
+void glcd_write()
+{
+
+ uint8_t bank;
+
+ for(bank = 0; bank < GLCD_NUMBER_OF_BANKS; bank++)
+ {
+ /* Each bank is a single row 8 bits tall */
+ uint8_t column;
+
+ if(glcd_bbox_selected->y_min >= (bank+1)*8)
+ {
+ continue; /* Skip the entire bank */
+ }
+
+ if(glcd_bbox_selected->y_max < bank*8)
+ {
+ break; /* No more banks need updating */
+ }
+
+ glcd_set_y_address(bank);
+ glcd_set_x_address(glcd_bbox_selected->x_min);
+
+ for(column = glcd_bbox_selected->x_min; column <= glcd_bbox_selected->x_max; column++)
+ {
+ glcd_data(glcd_buffer_selected[GLCD_NUMBER_OF_COLS * bank + column]);
+ }
+ }
+
+ glcd_reset_bbox();
+
+}
+
diff --git a/lcd/glcd.h b/lcd/glcd.h
new file mode 100644
index 0000000..1577878
--- /dev/null
+++ b/lcd/glcd.h
@@ -0,0 +1,251 @@
+/**
+ \file glcd.h
+ \brief GLCD Library main header file. This file must be included into project.
+ \author Andy Gock
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef _GLCD_H
+#define _GLCD_H
+
+#include "stm32f10x.h"
+#include "glcd_spi.h"
+#include "ST7565R.h"
+
+
+extern void delay_ms(uint32_t ms);
+#define PROGMEM
+
+
+/* Macros */
+
+#define swap(a, b) { uint8_t t = a; a = b; b = t; }
+
+/* Defining new types */
+
+/**
+ * Font table type
+ */
+typedef enum {
+ STANG,
+ MIKRO,
+ GLCD_UTILS
+} font_table_type_t;
+
+/**
+ * Bounding box for pixels that need to be updated
+ */
+typedef struct {
+ uint8_t x_min;
+ uint8_t y_min;
+ uint8_t x_max;
+ uint8_t y_max;
+} glcd_BoundingBox_t;
+
+#include <stdint.h>
+#include "glcd_graphics.h"
+#include "glcd_graphs.h"
+#include "glcd_text_tiny.h"
+#include "glcd_text.h"
+#include "unit_tests.h"
+#include "font5x7.h"
+#include "Earthbound_12x19_48to57.h"
+#include "Liberation_Sans15x21_Numbers.h"
+
+/**
+ * \name Colour Constants
+ * @{
+ */
+#define BLACK 1
+#define WHITE 0
+/**@}*/
+
+/**
+ * \name LCD Dimensions
+ * @{
+ */
+#if !defined(GLCD_LCD_WIDTH) || !defined(GLCD_LCD_HEIGHT)
+
+ /**
+ * User specified GLCD width in pixels
+ * Set to 0 for automatic assignment based on controller.
+ */
+ #define GLCD_LCD_WIDTH 128
+
+ /**
+ * User specified GLCD height in pixels
+ * Set to 0 for automatic assignment based on controller.
+ */
+
+ #define GLCD_LCD_HEIGHT 64
+
+ /* Automatic assignment of width and height, if required. */
+ #if !GLCD_LCD_WIDTH && !GLCD_LCD_HEIGHT
+ #undef GLCD_LCD_WIDTH
+ #undef GLCD_LCD_HEIGHT
+ #if defined(GLCD_CONTROLLER_PCD8544)
+ /* 84x48 is standard for the popular Nokia LCD */
+ #define GLCD_LCD_WIDTH 84
+ #define GLCD_LCD_HEIGHT 48
+ #elif defined(GLCD_CONTROLLER_ST7565R) || defined(GLCD_CONTROLLER_NT75451)
+ /* 128x64 is the most popular for this, so we'll use that as default */
+ #define GLCD_LCD_WIDTH 128
+ #define GLCD_LCD_HEIGHT 64
+ #else
+ #define GLCD_LCD_WIDTH 128
+ #define GLCD_LCD_HEIGHT 64
+ #endif
+ #endif
+
+#endif /* !defined(GLCD_LCD_WIDTH) || !defined(GLCD_LCD_HEIGHT) */
+
+/*
+ * GLCD_NUMBER_OF_BANKS is typically GLCD_LCD_HEIGHT/8
+ * Don't adjust these below unless required.
+ */
+#define GLCD_NUMBER_OF_BANKS (GLCD_LCD_WIDTH / 8)
+#define GLCD_NUMBER_OF_COLS GLCD_LCD_WIDTH
+
+/**@}*/
+
+#if !defined(GLCD_RESET_TIME)
+ /** Reset duration by glcd_reset(), in milliseconds */
+ #define GLCD_RESET_TIME 2
+#endif
+/*
+ * Set to custom value, or leave at 0 for automatic assignment.
+ * For custom dimensions, users can define this in their compiler options.
+ */
+
+/* Global variables used for GLCD library */
+extern uint8_t glcd_buffer[GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8];
+extern glcd_BoundingBox_t glcd_bbox;
+extern uint8_t *glcd_buffer_selected;
+extern glcd_BoundingBox_t *glcd_bbox_selected;
+
+/** \name Base Functions
+ * @{
+ */
+
+/**
+ * Update bounding box.
+ *
+ * The bounding box defines a rectangle in which needs to be refreshed next time
+ * glcd_write() is called. glcd_write() only writes to those pixels inside the bounding box plus any
+ * surrounding pixels which are required according to the bank/column write method of the controller.
+ *
+ * Define a rectangle here, and it will be <em>added</em> to the existing bounding box.
+ *
+ * \param xmin Minimum x value of rectangle
+ * \param ymin Minimum y value of rectangle
+ * \param xmax Maximum x value of rectangle
+ * \param ymax Maximum y value of rectangle
+ * \see glcd_bbox
+ * \see glcd_bbox_selected
+ */
+void glcd_update_bbox(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax);
+
+/**
+ * Reset the bounding box.
+ * After resetting the bounding box, no pixels are marked as needing refreshing.
+ */
+void glcd_reset_bbox(void);
+
+/**
+ * Same as glcd_reset_bbox()
+ */
+void glcd_bbox_reset(void);
+
+/**
+ * Marks the entire display for re-writing.
+ */
+void glcd_bbox_refresh(void);
+
+/**
+ * Clear the display. This will clear the buffer and physically write and commit it to the LCD
+ */
+void glcd_clear(void);
+
+/**
+ * Clear the display buffer only. This does not physically write the changes to the LCD
+ */
+void glcd_clear_buffer(void);
+
+/**
+ * Select screen buffer and bounding box structure.
+ * This should be selected at initialisation. There are future plans to support multiple screen buffers
+ * but this not yet available.
+ * \param buffer Pointer to screen buffer
+ * \param bbox Pointer to bounding box object.
+ * \see glcd_BoundingBox_t
+ */
+void glcd_select_screen(uint8_t *buffer, glcd_BoundingBox_t *bbox);
+
+/**
+ * Scroll entire screne buffer by x and y pixels. (not implemented yet)
+ * \note Items scrolled off the extents of the display dimensions will be lost.
+ *
+ * \param x X distance to scroll
+ * \param y Y distance to scroll
+ */
+void glcd_scroll(int8_t x, int8_t y);
+
+/**
+ * Scroll screen buffer up by 8 pixels.
+ * This is designed to be used in conjunciton with tiny text functions which are 8 bits high.
+ * \see Tiny Text
+ */
+void glcd_scroll_line(void);
+
+void glcd_set_reverse_sta(uint8_t sta);
+uint8_t glcd_get_reverse_sta(void);
+
+void glcd_HW_init(void);
+
+void glcd_write(void);
+
+/** @}*/
+
+typedef struct {
+ const char *font_table;
+ uint8_t width;
+ uint8_t height;
+ char start_char;
+ char end_char;
+ font_table_type_t table_type;
+} glcd_FontConfig_t;
+
+
+
+extern uint8_t *glcd_buffer_selected;
+extern glcd_BoundingBox_t *glcd_bbox_selected;
+extern glcd_FontConfig_t font_current;
+
+#endif
diff --git a/lcd/glcd_graphics.h b/lcd/glcd_graphics.h
new file mode 100644
index 0000000..376565f
--- /dev/null
+++ b/lcd/glcd_graphics.h
@@ -0,0 +1,169 @@
+/**
+ \file glcd_graphics.h
+ \brief Graphics routines
+ \author Andy Gock
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef GLCD_GRAPHICS_H_
+#define GLCD_GRAPHICS_H_
+
+/** \addtogroup Graphics Graphics
+ * Graphics specific functions such as drawing lines, circles, rectangles etc.
+ * @{
+ */
+
+/**
+ * Set pixel to specified colour
+ * \param x X-coordinate
+ * \param y Y-coordinate
+ * \param color Colour to set pixel
+ * \see ColourConstants
+ */
+void glcd_set_pixel(uint8_t x, uint8_t y, uint8_t color);
+
+/**
+ * Get state of pixel from specified location
+ * \param x X-coordinate
+ * \param y Y-coordinate
+ * \return Colour
+ */
+uint8_t glcd_get_pixel(uint8_t x, uint8_t y);
+
+/**
+ * Invert state of pixel of specified location
+ * \param x X-coordinate
+ * \param y Y-coordinate
+ */
+void glcd_invert_pixel(uint8_t x, uint8_t y);
+
+/**
+ * Draw line
+ * \param x0 Start x-coordinate
+ * \param y0 Start y-coordinate
+ * \param x1 End x-coordinate
+ * \param y1 End y-coordinate
+ * \param color Colour to set pixels
+ * \see ColourConstants
+ */
+void glcd_draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color);
+
+/**
+ * Draw rectangle and fill with colour.
+ * The border of the rectangle is the same as fill colour
+ * \param x Start x-coordinate (left-most)
+ * \param y Start y-coordinate (top-most)
+ * \param w Width
+ * \param h Height
+ * \param color Colour to fill with
+ * \see ColourConstants
+ */
+void glcd_fill_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color);
+
+/**
+ * Draw rectangle but do not fill.
+ * The border of the rectangle is the same as fill colour
+ * \param x Start x-coordinate (left-most)
+ * \param y Start y-coordinate (top-most)
+ * \param w Width
+ * \param h Height
+ * \param color Colour of border
+ * \see ColourConstants
+ */
+void glcd_draw_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color);
+
+/**
+ * Draw rectangle but do not fill. User specified thickness.
+ * The border of the rectangle is the same as fill colour
+ * \param x Start x-coordinate (left-most)
+ * \param y Start y-coordinate (top-most)
+ * \param w Width (outermost pixels)
+ * \param h Height
+ * \param tx Thickness of horizontal border along X axis
+ * \param ty Thickness of vertical border along Y axis
+ * \param color Colour of border
+ * \see ColourConstants
+ */
+void glcd_draw_rect_thick(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tx, uint8_t ty, uint8_t color);
+
+/**
+ * Draw rectangle but do not fill. Place a shadow line on the bottom-right of the window.
+ * The border of the rectangle is the same as fill colour
+ * \param x Start x-coordinate (left-most)
+ * \param y Start y-coordinate (top-most)
+ * \param w Width
+ * \param h Height
+ * \param color Colour of border
+ * \see ColourConstants
+ */
+void glcd_draw_rect_shadow(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color);
+
+/**
+ * Draw circle but do not fill.
+ * The border of the rectangle is the same as fill colour
+ * \param x0 Centre x-coordinate (left-most)
+ * \param y0 Centre y-coordinate (top-most)
+ * \param r Radius
+ * \param color Colour of border
+ * \see ColourConstants
+ */
+void glcd_draw_circle(uint8_t x0, uint8_t y0, uint8_t r, uint8_t color);
+
+/**
+ * Draw circle and fill.
+ * The border of the rectangle is the same as fill colour
+ * \param x0 Centre x-coordinate (left-most)
+ * \param y0 Centre y-coordinate (top-most)
+ * \param r Radius
+ * \param color Colour of border
+ * \see ColourConstants
+ */
+void glcd_fill_circle(uint8_t x0, uint8_t y0, uint8_t r, uint8_t color);
+
+/**
+ * Invert pixels in a retangular area.
+ * \param x Start x-coordinate (left-most)
+ * \param y Start y-coordinate (top-most)
+ * \param w Width
+ * \param h Height
+ */
+void glcd_invert_area(uint8_t x, uint8_t y, uint8_t w, uint8_t h);
+
+/**
+ * Draw bitmap to screen buffer.
+ * Note this will draw to the entire buffer, its not yet possible to draw partially to the LCD.
+ * Not yet supported with AVR pgmspace.
+ * \param data Pointer to bitmap data.
+ */
+void glcd_draw_bitmap(const unsigned char *data);
+
+/** @}*/
+
+#endif /* GLCD_GRAPHICS_H_ */
diff --git a/lcd/glcd_graphs.h b/lcd/glcd_graphs.h
new file mode 100644
index 0000000..a1aa987
--- /dev/null
+++ b/lcd/glcd_graphs.h
@@ -0,0 +1,88 @@
+/**
+ \file glcd_graphs.h
+ \brief GLCD Library - Graph drawing functions.
+ \author Andy Gock
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef GLCD_GRAPHS_H
+#define GLCD_GRAPHS_H
+
+/** \addtogroup Graphing
+ * Functions for graphing, e.g drawing bar graphs etc.
+ * @{
+ */
+
+/** Draw horizontal bar graph with 1 px wide border.
+ * The bar graph draws from left to right as val increases.
+ * \param x x location for top-left of border
+ * \param y y location for top-left of border
+ * \param width width of the border
+ * \param height height of the border (must be over 2)
+ * \param val value to display in graph (0-255 8 bit value).
+ */
+void glcd_bar_graph_horizontal(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val);
+
+/** Draw horizontal bar graph with no border.
+ * The bar graph draws from left to right as val increases.
+ * \param x x location for top-left of bar
+ * \param y y location for top-left of bar
+ * \param width width of the bar at full val
+ * \param height height of the bar
+ * \param val value to display in graph (0-255 8 bit value).
+ */
+void glcd_bar_graph_horizontal_no_border(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val);
+
+/** Draw vertical bar graph with 1px wide border.
+ * The bar graph draws from bottom to top as val increases.
+ * \param x x location for top-left of border
+ * \param y y location for top-left of border
+ * \param width width of the border
+ * \param height height of the border
+ * \param val value to display in graph (0-255 8 bit value).
+ */
+void glcd_bar_graph_vertical(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val);
+
+/** Draw vertical bar graph with no border.
+ * The bar graph draws from bottom to top as val increases.
+ * \param x x location for top-left of bar
+ * \param y y location for top-left of bar
+ * \param width width of the bar
+ * \param height height of the bar
+ * \param val value to display in graph (0-255 8 bit value).
+ */
+void glcd_bar_graph_vertical_no_border(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val);
+
+/** \todo write doc */
+void glcd_scrolling_bar_graph(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val);
+
+/** @}*/
+
+#endif
diff --git a/lcd/glcd_spi.c b/lcd/glcd_spi.c
new file mode 100644
index 0000000..1e65708
--- /dev/null
+++ b/lcd/glcd_spi.c
@@ -0,0 +1,115 @@
+/**
+ * \file STM32F10x.c
+ * \brief Device implementation for ST STM32F10x ARM Cortex-M3 MCUs
+ * Requires the use of ST's Standard Peripheral Library
+ * \author Andy Gock
+ * \todo Code is untested!
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* Includes from CMSIS and Peripheral Library */
+#include "stm32f10x.h"
+#include "../sys_hw/timer.h"
+#include "glcd_spi.h"
+#include "ST7565R.h"
+
+void glcd_HW_init(void)
+{
+ /* Initialisation of GPIO and SPI */
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ /* Set up GPIO pins */
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
+
+ /* DC pin */
+ GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_DC_PIN;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
+ GPIO_Init(CONTROLLER_SPI_DC_PORT, &GPIO_InitStructure);
+
+ /* RESET pin */
+ GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_RST_PIN;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
+ GPIO_Init(CONTROLLER_SPI_RST_PORT, &GPIO_InitStructure);
+
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
+ GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
+ GPIO_Init(GPIOA, &GPIO_InitStructure);
+
+ GLCD_BKL_ON();
+
+ /* Make sure chip is de-selected by default */
+ GLCD_DESELECT();
+
+ /* Initialise SPI */
+ spi_init();
+
+ /* Send reset pulse to LCD */
+ glcd_reset();
+ delay_ms(1);
+
+ glcd_ST7565R_init();
+
+ /* Set all dots black and hold for 0.5s, then clear it, we do this so we can visually check init sequence is working */
+// glcd_all_on();
+// delay_ms(50);
+ glcd_normal();
+
+ glcd_set_start_line(0);
+ glcd_clear_now();
+}
+
+void glcd_spi_write(uint8_t c)
+{
+ GLCD_SELECT();
+ spi_transive(c, 1000);
+ GLCD_DESELECT();
+}
+
+void glcd_reset(void)
+{
+ GLCD_SELECT();
+ GLCD_RESET_LOW();
+ delay_ms(2);
+ GLCD_RESET_HIGH();
+ GLCD_DESELECT();
+}
+/*void GLCD_BKL_ON(void)
+{
+ GPIO_SetBits(GPIOA, GPIO_Pin_15);
+}
+void GLCD_BKL_OFF(void)
+{
+ GPIO_ResetBits(GPIOA, GPIO_Pin_15);
+}*/
diff --git a/lcd/glcd_spi.h b/lcd/glcd_spi.h
new file mode 100644
index 0000000..64a6249
--- /dev/null
+++ b/lcd/glcd_spi.h
@@ -0,0 +1,100 @@
+/**
+ * \file STM32F10x.h
+ * \brief Device implementation for ST STM32F10x ARM Cortex-M3 MCUs
+ * Requires the use of ST's Standard Peripheral Library
+ * \author Andy Gock
+ *
+ * \todo Code is untested!
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#ifndef __glcd_spi_h__
+#define __glcd_spi_h__
+
+#include "spi.h"
+
+/** SPI port number e.g SPI1, SPI2 (not to be confused with GPIOA, GPIOB, etc) */
+#define CONTROLLER_SPI_NUMBER
+#define CONTROLLER_SPI_PORT
+#define CONTROLLER_SPI_SCK_PIN
+#define CONTROLLER_SPI_SCK_PINSRC
+#define CONTROLLER_SPI_MISO_PIN
+#define CONTROLLER_SPI_MISO_PINSRC
+#define CONTROLLER_SPI_MOSI_PIN
+#define CONTROLLER_SPI_MOSI_PINSRC
+
+#define CONTROLLER_SPI_SS_PORT
+#define CONTROLLER_SPI_SS_PIN
+#define CONTROLLER_SPI_DC_PORT GPIOC
+#define CONTROLLER_SPI_DC_PIN GPIO_Pin_10
+#define CONTROLLER_SPI_RST_PORT GPIOC
+#define CONTROLLER_SPI_RST_PIN GPIO_Pin_11
+
+#define GLCD_SELECT() SPI_SELECT_CH2()
+#define GLCD_DESELECT() SPI_DESELECT_CH2()
+#define GLCD_DC_LOW() GPIO_ResetBits(CONTROLLER_SPI_DC_PORT,CONTROLLER_SPI_DC_PIN)
+#define GLCD_DC_HIGH() GPIO_SetBits(CONTROLLER_SPI_DC_PORT,CONTROLLER_SPI_DC_PIN)
+#define GLCD_A0_LOW() GPIO_ResetBits(CONTROLLER_SPI_DC_PORT,CONTROLLER_SPI_DC_PIN)
+#define GLCD_A0_HIGH() GPIO_SetBits(CONTROLLER_SPI_DC_PORT,CONTROLLER_SPI_DC_PIN)
+#define GLCD_RESET_LOW() GPIO_ResetBits(CONTROLLER_SPI_RST_PORT,CONTROLLER_SPI_RST_PIN)
+#define GLCD_RESET_HIGH() GPIO_SetBits(CONTROLLER_SPI_RST_PORT,CONTROLLER_SPI_RST_PIN)
+/*#ifdef HW_V01
+#define GLCD_BKL_ON() GPIO_SetBits(GPIOD, GPIO_Pin_2)
+#define GLCD_BKL_OFF() GPIO_ResetBits(GPIOD, GPIO_Pin_2)
+#endif
+#ifdef HW_V02*/
+#define GLCD_BKL_ON() GPIO_SetBits(GPIOA, GPIO_Pin_15)
+#define GLCD_BKL_OFF() GPIO_ResetBits(GPIOA, GPIO_Pin_15)
+//#endif
+
+/**
+ * Initialise the LCD. This function is platform and controller specific.
+ */
+void glcd_HW_init(void);
+
+/**
+ * Write a byte to the connected SPI slave.
+ * \param c Byte to be written
+ * \return Returned value from SPI (often not used)
+ */
+void glcd_spi_write(uint8_t c);
+
+
+/**
+ * Reset the LCD.
+ * \note Not all LCD controllers support reset.
+ */
+void glcd_reset(void);
+
+void glcd_bkl_on(void);
+
+void glcd_bkl_off(void);
+
+#endif
+/* __glcd_spi_h__ */
diff --git a/lcd/glcd_text.h b/lcd/glcd_text.h
new file mode 100644
index 0000000..85b4e61
--- /dev/null
+++ b/lcd/glcd_text.h
@@ -0,0 +1,109 @@
+/**
+ \file glcd_text.h
+ \brief GLCD Library - Text functions
+ \author Andy Gock
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef GLCD_TEXT_H
+#define GLCD_TEXT_H
+
+/** \addtogroup Text
+ * Functions relating to using text fonts.
+ * @{
+ */
+
+/** \addtogroup StandardText Standard Text
+ * Functions relating to using text fonts of all sizes.
+ * @{
+ */
+
+/** Set GLCD font to predefined font table. Only suitable for MikroElektronika font storage format.
+ *
+ * \param font_table pointer to font table to be used
+ * \param width width of each character
+ * \param height height of each character
+ * \param start_char first character of font table
+ * \param end_char last character of font table
+ * \note Only suitable for MikroElektronika font storage format. For Stang format, use
+ * glcd_tiny_set_font()
+ * \see glcd_tiny_set_font()
+ */
+#if defined(GLCD_DEVICE_AVR8)
+void glcd_set_font(PGM_P font_table, uint8_t width, uint8_t height, char start_char, char end_char);
+#else
+void glcd_set_font(const char * font_table, uint8_t width, uint8_t height, char start_char, char end_char);
+#endif
+
+/** Set GLCD font to predefined font table. Suitable for different different types of font tables.
+ *
+ * \param font_table pointer to font table to be used
+ * \param width width of each character
+ * \param height height of each character
+ * \param start_char first character of font table
+ * \param end_char last character of font table
+ * \param type font table type
+ * \note Only suitable for MikroElektronika font storage format. For Stang format, use
+ * glcd_tiny_set_font()
+ * \see glcd_tiny_set_font()
+ */
+#if defined(GLCD_DEVICE_AVR8)
+void glcd_font(PGM_P font_table, uint8_t width, uint8_t height, char start_char, char end_char, font_table_type_t type);
+#else
+void glcd_font(const char * font_table, uint8_t width, uint8_t height, char start_char, char end_char, font_table_type_t type);
+#endif
+
+/** Draw a char at specified location.
+ * \param x x location to place top-left of character frame
+ * \param y y location to place top-left of character frame
+ * \param c character to be drawn
+ * \return width of character, 0 on error (e.g could not read font table)
+ */
+uint8_t glcd_draw_char_xy(uint8_t x, uint8_t y, char c);
+
+/** Draw a string at specified location.
+ * \param x x location to place top-left of character frame
+ * \param y y location to place top-left of character frame
+ * \param c pointer to string to be drawn
+ */
+void glcd_draw_string_xy(uint8_t x, uint8_t y, char *c);
+
+/** Draw a string from program memory at specified location.
+ * \param x x location to place top-left of character frame
+ * \param y y location to place top-left of character frame
+ * \param str pointer to string in program memory to be drawn
+ */
+void glcd_draw_string_xy_P(uint8_t x, uint8_t y, const char *str);
+
+/** @}*/
+
+/** @}*/
+
+#endif
diff --git a/lcd/glcd_text_tiny.h b/lcd/glcd_text_tiny.h
new file mode 100644
index 0000000..e8dc4d7
--- /dev/null
+++ b/lcd/glcd_text_tiny.h
@@ -0,0 +1,138 @@
+/**
+ \file glcd_text_tiny.h
+ \brief GLCD Library - Tiny Text functions.
+ \author Andy Gock
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef GLCD_TEXT_TINY_H
+#define GLCD_TEXT_TINY_H
+
+#include "stdint.h"
+
+/** \addtogroup TinyText Tiny Text
+ * Functions relating to using tiny 5x7 text fonts.
+ *
+ * Tiny text functions are usually used on a line by line basis. Each line being 8 bits high.
+ * Characters start on the top most bit and are 7 bits high, leaving a one bit space underneath.
+ *
+ * @{
+ */
+
+/** Set font to be used from now on. This is the tiny 5x7 monospace font.
+ * \param font_table flash pointer to start from font table
+ * \param width width of each character
+ * \param height height of each character
+ * \param start_char start character
+ * \param end_char end character
+ * \note Only suitable for Stang font storage format. For MikroElektronika format, use
+ * glcd_set_font()
+ * \see glcd_set_font()
+ */
+#if defined(GLCD_DEVICE_AVR8)
+void glcd_tiny_set_font(PGM_P font_table, uint8_t width, uint8_t height, char start_char, char end_char);
+#else
+void glcd_tiny_set_font(const char *font_table, uint8_t width, uint8_t height, char start_char, char end_char);
+#endif
+
+/** Write character to LCD in tiny 5x7 font.
+ * \param x column position to start
+ * \param line line number to be written (each line is 8 pixels high)
+ * \param c char to be written
+ */
+void glcd_tiny_draw_char(uint8_t x, uint8_t line, char c);
+
+/** Write string to display buffer in tiny 5x7 font.
+ * Will wrap to next line if needed. Screen is not updated. Use glcd_write() to physically update display.
+ * \param x column position to start
+ * \param line line number to be written (each line is 8 pixels high)
+ * \param str string to be written
+ */
+void glcd_tiny_draw_string(uint8_t x, uint8_t line, char *str);
+
+/** Write flash string to display buffer in tiny 5x7 font.
+ * Will wrap to next line if needed. Screen is not updated. Use glcd_write() to physically update display.
+ * \param x column position to start
+ * \param line line to be written (each line is 8 pixels high)
+ * \param str string stored in flash memory to be written
+ */
+#if defined(GLCD_DEVICE_AVR8)
+void glcd_tiny_draw_string_P(uint8_t x, uint8_t line, PGM_P str);
+#else
+void glcd_tiny_draw_string_P(uint8_t x, uint8_t line, const char *str);
+#endif
+
+/** Write string to bottom row of display.
+ * Screen buffer is scrolled up by one line. Screen is then physically updated.
+ * \param str string to be written
+ */
+void glcd_tiny_draw_string_ammend(char *str);
+
+/** Write string from flash memory to bottom row of display.
+ * Screen buffer is scrolled up by one line. Screen is then physically updated.
+ * \param str string to be written
+ */
+#if defined(GLCD_DEVICE_AVR8)
+void glcd_tiny_draw_string_ammend_P(PGM_P str);
+#else
+void glcd_tiny_draw_string_ammend_P(const char *str);
+#endif
+
+/**
+ * Invert all contents of line number. Line 0 is the top most line.
+ * \param line Line number (0 is top most line)
+ */
+void glcd_tiny_invert_line(uint8_t line);
+
+/** Write character to LCD in tiny 5x7 font to specified X, Y location.
+ * If position is aligned with 8 bit line heights, use glcd_tiny_draw_char() instead
+ * as it will be faster.
+ *
+ * \param x column position to start
+ * \param y row position to start (pixel based, not 8 bit high rows)
+ * \param c char to be written
+ * \see glcd_tiny_draw_char()
+ * \note This does the same thing as glcd_tiny_draw_char_xy() but is limited to Stang format
+ * font tables.
+ */
+void glcd_tiny_draw_char_xy(uint8_t x, uint8_t y, char c);
+
+/** Initialise 5x7 text */
+#define GLCD_TEXT_INIT() glcd_tiny_set_font(Font5x7,5,7,32,127);
+
+/** Write string to bottom-most line after scrolling everything else up */
+#define GLCD_WRITE(str) glcd_tiny_draw_string_ammend(str)
+
+/** Write string from program memory to bottom-most line after scrolling everything else up */
+#define GLCD_WRITE_P(str) glcd_tiny_draw_string_ammend_P(str)
+
+/** @}*/
+
+#endif
diff --git a/lcd/graphics.c b/lcd/graphics.c
new file mode 100644
index 0000000..dec75c0
--- /dev/null
+++ b/lcd/graphics.c
@@ -0,0 +1,309 @@
+/**
+ \file graphics.c
+ \brief Functions relating to graphics. e.g drawing lines, rectangles, circles etc.
+ \author Andy Gock
+
+ Some functions based on Limor Fried's PCD8544 Arduino library.
+
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ Copyright (c) 2012, Adafruit Industries
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "glcd.h"
+
+/* Based on PCD8544 library by Limor Fried */
+void glcd_set_pixel(uint8_t x, uint8_t y, uint8_t color) {
+ if (x > (GLCD_LCD_WIDTH-1) || y > (GLCD_LCD_HEIGHT-1)) {
+ /* don't do anything if x/y is outside bounds of display size */
+ return;
+ }
+
+ if (color) {
+ /* Set black */
+ glcd_buffer[x+ (y/8)*GLCD_LCD_WIDTH] |= ( 1 << (y%8));
+ } else {
+ /* Set white */
+ glcd_buffer[x+ (y/8)*GLCD_LCD_WIDTH] &= ~ (1 << (y%8));
+ }
+
+ glcd_update_bbox(x,y,x,y);
+}
+
+/* Based on PCD8544 library by Limor Fried */
+uint8_t glcd_get_pixel(uint8_t x, uint8_t y) {
+ if ((x >= GLCD_LCD_WIDTH) || (y >= GLCD_LCD_HEIGHT)) {
+ return 0;
+ }
+
+ if ( glcd_buffer[x+ (y/8)*GLCD_LCD_WIDTH] & ( 1 << (y%8)) ) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+void glcd_invert_pixel(uint8_t x, uint8_t y) {
+ if ((x >= GLCD_LCD_WIDTH) || (y >= GLCD_LCD_HEIGHT)) {
+ return;
+ }
+ glcd_update_bbox(x,y,x,y);
+ glcd_buffer[x+ (y/8)*GLCD_LCD_WIDTH] ^= ( 1 << (y%8));
+}
+
+/* Bresenham's algorithm - based on PCD8544 library Limor Fried */
+void glcd_draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color) {
+ uint8_t steep = abs(y1 - y0) > abs(x1 - x0);
+ uint8_t dx, dy;
+ int8_t err;
+ int8_t ystep;
+
+ if (steep) {
+ swap(x0, y0);
+ swap(x1, y1);
+ }
+
+ if (x0 > x1) {
+ swap(x0, x1);
+ swap(y0, y1);
+ }
+
+ glcd_update_bbox( x0, y0, x1, y1 );
+
+ dx = x1 - x0;
+ dy = abs(y1 - y0);
+
+ err = dx / 2;
+
+ if (y0 < y1) {
+ ystep = 1;
+ } else {
+ ystep = -1;
+ }
+
+ for (; x0<=x1; x0++) {
+ if (steep) {
+ glcd_set_pixel(y0, x0, color);
+ } else {
+ glcd_set_pixel(x0, y0, color);
+ }
+ err -= dy;
+ if (err < 0) {
+ y0 += ystep;
+ err += dx;
+ }
+ }
+}
+
+void glcd_fill_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color)
+{
+ int16_t i;
+ for (i=x; i<x+w; i++) {
+ int16_t j;
+ for (j=y; j<y+h; j++) {
+ glcd_set_pixel(i, j, color);
+ }
+ }
+ glcd_update_bbox(x, y, x+w-1, y+h-1);
+}
+
+void glcd_draw_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color)
+{
+ int16_t i;
+ for (i=x; i<x+w; i++) {
+ glcd_set_pixel(i, y, color);
+ glcd_set_pixel(i, y+h-1, color);
+ }
+ for (i=y; i<y+h; i++) {
+ glcd_set_pixel(x, i, color);
+ glcd_set_pixel(x+w-1, i, color);
+ }
+ glcd_update_bbox(x, y, x+w-1, y+h-1);
+}
+
+void glcd_draw_rect_thick(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tx, uint8_t ty, uint8_t color)
+{
+ int16_t i, t;
+
+ if (tx == 0) {
+ tx = 1;
+ }
+
+ if (ty == 0) {
+ ty = 1;
+ }
+
+ for (i=x; i<x+w; i++) {
+ /* Top and bottom sides */
+ for (t=0; t<(ty); t++) {
+ glcd_set_pixel(i, y+t, color);
+ glcd_set_pixel(i, y+h-1-t, color);
+ }
+ }
+ for (i=y; i<y+h; i++) {
+ /* Left and right sides */
+ for (t=0; t<(tx); t++) {
+ glcd_set_pixel(x+t, i, color);
+ glcd_set_pixel(x+w-1-t, i, color);
+ }
+ }
+ glcd_update_bbox(x, y, x+w-1, y+h-1);
+}
+
+void glcd_draw_rect_shadow(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color)
+{
+ glcd_draw_rect(x, y, w, h, color);
+ glcd_draw_line(x+1, y+h, x+w, y+h, color);
+ glcd_draw_line(x+w, y+1, x+w, y+h, color);
+}
+
+void glcd_draw_circle(uint8_t x0, uint8_t y0, uint8_t r, uint8_t color)
+{
+
+ int8_t f = 1 - r;
+ int8_t ddF_x = 1;
+ int8_t ddF_y = -2 * r;
+ int8_t x = 0;
+ int8_t y = r;
+
+ glcd_update_bbox(x0-r, y0-r, x0+r, y0+r);
+
+ glcd_set_pixel(x0, y0+r, color);
+ glcd_set_pixel(x0, y0-r, color);
+ glcd_set_pixel(x0+r, y0, color);
+ glcd_set_pixel(x0-r, y0, color);
+
+ while (x<y) {
+ if (f >= 0) {
+ y--;
+ ddF_y += 2;
+ f += ddF_y;
+ }
+ x++;
+ ddF_x += 2;
+ f += ddF_x;
+
+ glcd_set_pixel(x0 + x, y0 + y, color);
+ glcd_set_pixel(x0 - x, y0 + y, color);
+ glcd_set_pixel(x0 + x, y0 - y, color);
+ glcd_set_pixel(x0 - x, y0 - y, color);
+
+ glcd_set_pixel(x0 + y, y0 + x, color);
+ glcd_set_pixel(x0 - y, y0 + x, color);
+ glcd_set_pixel(x0 + y, y0 - x, color);
+ glcd_set_pixel(x0 - y, y0 - x, color);
+
+ }
+}
+
+void glcd_fill_circle(uint8_t x0, uint8_t y0, uint8_t r, uint8_t color)
+{
+
+ int8_t f = 1 - r;
+ int8_t ddF_x = 1;
+ int8_t ddF_y = -2 * r;
+ int8_t x = 0;
+ int8_t y = r;
+
+ int16_t i;
+
+ glcd_update_bbox(x0-r, y0-r, x0+r, y0+r);
+
+ for (i=y0-r; i<=y0+r; i++) {
+ glcd_set_pixel(x0, i, color);
+ }
+
+ while (x < y) {
+ if (f >= 0) {
+ y--;
+ ddF_y += 2;
+ f += ddF_y;
+ }
+ x++;
+ ddF_x += 2;
+ f += ddF_x;
+
+ for (i=y0-y; i<=y0+y; i++) {
+ glcd_set_pixel(x0+x, i, color);
+ glcd_set_pixel(x0-x, i, color);
+ }
+ for (i=y0-x; i<=y0+x; i++) {
+ glcd_set_pixel(x0+y, i, color);
+ glcd_set_pixel(x0-y, i, color);
+ }
+ }
+}
+
+void glcd_invert_area(uint8_t x, uint8_t y, uint8_t w, uint8_t h)
+{
+ uint8_t xx, yy;
+ for (xx = x; xx < (x+w); xx++) {
+ /* Loop through each partial column */
+ for (yy = y; yy < (y+h); yy++) {
+ /* Go down and invert every pixel */
+ glcd_invert_pixel(xx,yy);
+ }
+ }
+}
+
+void glcd_draw_bitmap(const unsigned char *data)
+{
+
+#if 0
+ /* Testing purposes only: Writing to the LCD right away (not for AVR) */
+ /* Normally, we do not do this, we just write to the screen buffer */
+ uint8_t *original_buffer;
+
+ /* Save the location of original screen buffer */
+ original_buffer = glcd_buffer_selected;
+
+ /* Use bitmap location as screen buffer (this won't work when using AVR8 PGM_P) */
+ glcd_select_screen((uint8_t *)data, glcd_bbox_selected);
+
+ /* Make sure we write the entre display */
+ glcd_bbox_refresh();
+ glcd_write();
+
+ /* Restore the screen buffer back to original */
+ glcd_select_screen(original_buffer, glcd_bbox_selected);
+#endif
+
+ /* Copy bitmap data to the screen buffer */
+#if defined(GLCD_DEVICE_AVR8)
+ memcpy_P(glcd_buffer_selected, data, (GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8));
+#else
+ memcpy(glcd_buffer_selected, data, (GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8));
+#endif
+
+ glcd_bbox_refresh();
+}
diff --git a/lcd/graphs.c b/lcd/graphs.c
new file mode 100644
index 0000000..fb1f034
--- /dev/null
+++ b/lcd/graphs.c
@@ -0,0 +1,120 @@
+/**
+ \file graphs.c
+ \brief Functions relating to graphs. e.g bar graphs etc.
+ \author Andy Gock
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "glcd.h"
+
+static uint8_t glcd_map(uint8_t x1, uint8_t x2, uint8_t x);
+
+void glcd_bar_graph_horizontal(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val)
+{
+ if (height < 3) {
+ return;
+ }
+ glcd_draw_rect(x, y, width, height, BLACK);
+ glcd_fill_rect(x+1, y+1, glcd_map(0,width-2,val), height-2 , BLACK);
+}
+
+void glcd_bar_graph_horizontal_no_border(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val)
+{
+ if (height < 3) {
+ return;
+ }
+ glcd_fill_rect(x, y, glcd_map(0,width,val), height , BLACK);
+}
+
+void glcd_bar_graph_vertical(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val)
+{
+ glcd_draw_rect(x, y, width, height, BLACK);
+ glcd_fill_rect(x+1, y+1+glcd_map(0,height-2,255-val), width-2, height-2-glcd_map(0,height-2,255-val), BLACK);
+}
+
+void glcd_bar_graph_vertical_no_border(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val)
+{
+ glcd_fill_rect(x, y+glcd_map(0,height-2,255-val), width, height-2-glcd_map(0,height-2,255-val), BLACK);
+}
+
+void glcd_scrolling_bar_graph(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val)
+{
+ uint8_t nx, ny;
+ uint8_t color;
+
+ /* Draw border of graph */
+ glcd_draw_rect(x,y,width,height,BLACK);
+
+ /* Scroll inner contents left by one pixel width */
+ for (ny = 1; ny <= (height-2); ny++) {
+ /* Redraw each horizontal line */
+ for (nx = 1; nx <= (width-2); nx += 1) {
+ color = glcd_get_pixel(x+nx+1,y+ny);
+ glcd_set_pixel(x+nx,y+ny,color);
+ }
+ }
+
+ val = val * (height-3) / 255;
+
+ /* Make sure we're not exceeding the size of box interior */
+ if (val > (height-3)) {
+ val = height - 3;
+ }
+
+ /* Draw new bar - both black and white portions*/
+ glcd_draw_line(x+width-2,y+height-2,x+width-2,y+height-2-val,BLACK);
+ glcd_draw_line(x+width-2,y+height-3-val,x+width-2,y+1,WHITE);
+
+ /* Write to display */
+ glcd_write();
+}
+
+void glcd_scrolling_bar_graph_timing(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t val, uint8_t line_width, uint16_t delay)
+{
+ uint8_t n;
+ if (line_width == 0) {
+ line_width = 1;
+ }
+
+ /* Adjust graph line's width by just running glcd_scrolling_bar_graph() x number of times */
+ /* \todo This should be done differently! */
+ for (n=0; n<line_width; n++) {
+ glcd_scrolling_bar_graph(x,y,width,height,val);
+ }
+
+ if (delay) {
+ delay_ms(delay);
+ }
+}
+
+static uint8_t glcd_map(uint8_t x1, uint8_t x2, uint8_t x)
+{
+ return x1+(x2-x1)*x/255;
+}
diff --git a/lcd/spi.c b/lcd/spi.c
new file mode 100644
index 0000000..23bb27a
--- /dev/null
+++ b/lcd/spi.c
@@ -0,0 +1,79 @@
+#include "spi.h"
+
+static void spi_gpio_init(void)
+{
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO, ENABLE);
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15|GPIO_Pin_13;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
+ GPIO_Init(GPIOB, &GPIO_InitStructure);
+
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
+ GPIO_Init(GPIOB, &GPIO_InitStructure);
+}
+
+static void spi_cs_init(void)
+{
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOA, ENABLE);
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
+ GPIO_Init(GPIOB, &GPIO_InitStructure);
+
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
+ GPIO_Init(GPIOC, &GPIO_InitStructure);
+
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
+ GPIO_Init(GPIOA, &GPIO_InitStructure);
+
+ GPIO_SetBits(GPIOB, GPIO_Pin_12);
+ GPIO_SetBits(GPIOC, GPIO_Pin_7);
+ GPIO_SetBits(GPIOA, GPIO_Pin_8);
+}
+
+void spi_init(void)
+{
+ SPI_InitTypeDef SPI_InitStructure;
+
+ spi_cs_init();
+ spi_gpio_init();
+
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
+ SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
+ SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
+ SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
+ SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
+ SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
+ SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
+ SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16;
+ SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
+ SPI_InitStructure.SPI_CRCPolynomial = 7;
+ SPI_Init(SPI2, &SPI_InitStructure);
+
+ SPI_Cmd(SPI2, ENABLE);
+}
+
+//transmit/receive
+uint8_t spi_transive(uint8_t byte, uint32_t timeout)
+{
+ uint32_t timer;
+
+ timer = timeout;
+ while((SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET)&&timer)
+ {
+ timer --;
+ }
+ SPI_I2S_SendData(SPI2, byte);
+
+ timer = timeout;
+ while((SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET)&&timer)
+ {
+ timer --;
+ }
+ return SPI_I2S_ReceiveData(SPI2);
+}
diff --git a/lcd/spi.h b/lcd/spi.h
new file mode 100644
index 0000000..89a3c5b
--- /dev/null
+++ b/lcd/spi.h
@@ -0,0 +1,19 @@
+#ifndef __spi_h__
+#define __spi_h__
+
+#include "stm32f10x.h"
+
+#define SPI_SELECT_CH1() GPIO_ResetBits(GPIOB, GPIO_Pin_12)
+#define SPI_DESELECT_CH1() GPIO_SetBits(GPIOB, GPIO_Pin_12)
+
+#define SPI_SELECT_CH2() GPIO_ResetBits(GPIOA, GPIO_Pin_8)
+#define SPI_DESELECT_CH2() GPIO_SetBits(GPIOA, GPIO_Pin_8)
+
+
+#define SPI_SELECT_CH3() GPIO_ResetBits(GPIOC, GPIO_Pin_7)
+#define SPI_DESELECT_CH3() GPIO_SetBits(GPIOC, GPIO_Pin_7)
+
+extern void spi_init(void);
+extern uint8_t spi_transive(uint8_t byte, uint32_t timeout);
+
+#endif
diff --git a/lcd/text.c b/lcd/text.c
new file mode 100644
index 0000000..23bfa5d
--- /dev/null
+++ b/lcd/text.c
@@ -0,0 +1,321 @@
+
+/**
+ \file text.c
+ \brief Functions relating to using text fonts of all sizes.
+ \author Andy Gock
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "glcd.h"
+
+extern uint8_t *glcd_buffer_selected;
+extern glcd_BoundingBox_t *glcd_bbox_selected;
+
+glcd_FontConfig_t font_current;
+
+#if defined(GLCD_DEVICE_AVR8)
+void glcd_set_font(PGM_P font_table, uint8_t width, uint8_t height, char start_char, char end_char)
+#else
+void glcd_set_font(const char * font_table, uint8_t width, uint8_t height, char start_char, char end_char)
+#endif
+{
+ /* Supports variable width fonts */
+ font_current.font_table = font_table;
+ font_current.width = width;
+ font_current.height = height;
+ font_current.start_char = start_char;
+ font_current.end_char = end_char;
+ font_current.table_type = MIKRO; /* Only supports MikroElektronika generated format at the moment */
+}
+
+#if defined(GLCD_DEVICE_AVR8)
+void glcd_font(PGM_P font_table, uint8_t width, uint8_t height, char start_char, char end_char, font_table_type_t type)
+#else
+void glcd_font(const char * font_table, uint8_t width, uint8_t height, char start_char, char end_char, font_table_type_t type)
+#endif
+{
+ /* Supports variable width fonts */
+ font_current.font_table = font_table;
+ font_current.width = width;
+ font_current.height = height;
+ font_current.start_char = start_char;
+ font_current.end_char = end_char;
+ font_current.table_type = type; /* Only supports MikroElektronika generated format at the moment */
+}
+
+uint8_t glcd_draw_char_xy(uint8_t x, uint8_t y, char c)
+{
+ if (c < font_current.start_char || c > font_current.end_char) {
+ c = '.';
+ }
+
+ if (font_current.table_type == STANG) {
+ /* Font table in Pascal Stang format (single byte height with with no width specifier) */
+ /* Maximum height of 8 bits only */
+
+ uint8_t i;
+ for ( i = 0; i < font_current.width; i++ ) {
+#if defined(GLCD_DEVICE_AVR8)
+ uint8_t dat = pgm_read_byte( font_current.font_table + ((c - font_current.start_char) * (font_current.width)) + i );
+#else
+ uint8_t dat = *( font_current.font_table + ((c - font_current.start_char) * (font_current.width)) + i );
+#endif
+ uint8_t j;
+
+ if(glcd_get_reverse_sta())
+ dat = ~dat;
+ for (j = 0; j < 8; j++) {
+ /* Set pixel color for each bit of the column (8-bits) */
+ if (x+i >= GLCD_LCD_WIDTH || y+j >= GLCD_LCD_HEIGHT) {
+ /* Don't try and write past the dimensions of the LCD */
+ return 0;
+ }
+ if (dat & (1<<j)) {
+ glcd_set_pixel(x+i,y+j,BLACK);
+ } else {
+ glcd_set_pixel(x+i,y+j,WHITE);
+ }
+ }
+ }
+
+ /* always return how many pixels of width were written */
+ /* here for "stang" format fonts, it is always fixed */
+ return font_current.width;
+
+ } else if (font_current.table_type == MIKRO) {
+ /* Font table in MikroElecktronica format
+ - multi row fonts allowed (more than 8 pixels high)
+ - variable width fonts allowed
+ a complete column is written before moving to the next */
+
+ uint8_t i;
+ uint8_t var_width;
+ uint8_t bytes_high;
+ uint8_t bytes_per_char;
+ const char *p;
+
+ if ((font_current.height % 8) > 0){
+ bytes_high = (font_current.height / 8) + 1;
+ }
+ else{
+ bytes_high = (font_current.height / 8);
+ }
+ bytes_per_char = font_current.width * bytes_high + 1; /* The +1 is the width byte at the start */
+
+ p = font_current.font_table + (c - font_current.start_char) * bytes_per_char;
+
+ /* The first byte per character is always the width of the character */
+#if defined(GLCD_DEVICE_AVR8)
+ var_width = pgm_read_byte(p);
+#else
+ var_width = *p;
+#endif
+ p++; /* Step over the variable width field */
+
+ /*
+ if (x+var_width >= GLCD_LCD_WIDTH || y+font_current.height >= GLCD_LCD_HEIGHT) {
+ return;
+ }
+ */
+
+ for ( i = 0; i < var_width; i++ ) {
+ uint8_t j;
+ for ( j = 0; j < bytes_high; j++ ) {
+#if defined(GLCD_DEVICE_AVR8)
+ uint8_t dat = pgm_read_byte( p + i*bytes_high + j );
+#else
+ uint8_t dat = *( p + i*bytes_high + j );
+#endif
+ uint8_t bit;
+
+ if(glcd_get_reverse_sta())
+ dat = ~dat;
+ for (bit = 0; bit < 8; bit++) {
+
+ if (x+i >= GLCD_LCD_WIDTH || y+j*8+bit >= GLCD_LCD_HEIGHT) {
+ /* Don't write past the dimensions of the LCD, skip the entire char */
+ return 0;
+ }
+
+ /* We should not write if the y bit exceeds font height */
+ if ((j*8 + bit) >= font_current.height) {
+ /* Skip the bit */
+ continue;
+ }
+
+ if (dat & (1<<bit)) {
+ glcd_set_pixel(x+i,y+j*8+bit,BLACK);
+ } else {
+ glcd_set_pixel(x+i,y+j*8+bit,WHITE);
+ }
+ }
+ }
+ }
+ return var_width;
+
+ } else if (font_current.table_type == GLCD_UTILS) {
+ /* Font table format of glcd-utils
+ - A complete row is written first (not completed columns)
+ - Width not stored, but we can search and determine it
+ - Not yet supported */
+
+ uint8_t var_width, n;
+ uint8_t bytes_high, bytes_per_char;
+ const char *p;
+ uint8_t j;
+
+ bytes_high = font_current.height / 8 + 1;
+ bytes_per_char = font_current.width * bytes_high;
+
+ /* Point to chars first byte */
+ p = font_current.font_table + (c - font_current.start_char) * bytes_per_char;
+
+ /* Determine the width of the character */
+ var_width = font_current.width;
+
+ n = 0; /* How many columns back from the end */
+
+ while (1) {
+ uint8_t max_byte = 0;
+ uint8_t row = 0;
+
+ for (row = 0; row < bytes_high; row++) {
+ uint8_t offset;
+ offset = (font_current.width - 1 - n) * row;
+ max_byte = *(p + offset);
+ }
+ if (max_byte == 0) {
+ /* column is empty for all rows, go left and test again */
+ /* reduce variable width by 1 */
+ var_width--;
+ if (var_width == 0) {
+ break;
+ }
+ } else {
+ break; /* Part of a character was found */
+ }
+ n++;
+ }
+
+ /* Uncomment line below, to force fixed width, for debugging only */
+ //var_width = font_current.width; // bypass auto width detection, treat as fixed width
+
+ /* For glcd-utils format, we write one complete row at a time */
+ /* loop as rows, 1st row, j=0 */
+ for ( j = 0; j < bytes_high; j++ ) {
+ /* Loop one row at a time */
+
+ uint8_t i;
+ for ( i = 0; i < var_width; i++ ) {
+ /* Loop one column at a time */
+
+ uint8_t dat, bit;
+
+#if defined(GLCD_DEVICE_AVR8)
+ dat = pgm_read_byte( p + j*font_current.width + i );
+#else
+ dat = *( p + j*font_current.width + i );
+#endif
+
+ if(glcd_get_reverse_sta())
+ dat = ~dat;
+
+ for (bit = 0; bit < 8; bit++) {
+
+ if ((x+i) >= GLCD_LCD_WIDTH || (y+j*8+bit) >= GLCD_LCD_HEIGHT) {
+ /* Don't write past the dimensions of the LCD, skip the entire char */
+ return 0;
+ }
+
+ /* We should not write if the y bit exceeds font height */
+ if ((j*8 + bit) >= font_current.height) {
+ /* Skip the bit */
+ continue;
+ }
+
+ if (dat & (1<<bit)) {
+ glcd_set_pixel(x+i,y+j*8+bit,BLACK);
+ } else {
+ glcd_set_pixel(x+i,y+j*8+bit,WHITE);
+ }
+ }
+ } /* i */
+ } /* j */
+
+ return var_width; /* Number of columns written to display */
+
+ } else {
+ /* Don't recognise the font table */
+ return 0;
+
+ }
+
+}
+
+void glcd_draw_string_xy(uint8_t x, uint8_t y, char *c)
+{
+ uint8_t width;
+
+ if (y > (GLCD_LCD_HEIGHT - font_current.height - 1)) {
+ /* Character won't fit */
+ return;
+ }
+
+ while (*c) {
+ width = glcd_draw_char_xy(x,y,*c);
+ x += (width + 1);
+ c++;
+ }
+}
+
+void glcd_draw_string_xy_P(uint8_t x, uint8_t y, const char *str)
+{
+ uint8_t width;
+
+ if (y > (GLCD_LCD_HEIGHT - font_current.height - 1)) {
+ /* Character won't fit */
+ return;
+ }
+
+ while (1) {
+#if defined(GLCD_DEVICE_AVR8)
+ char c = pgm_read_byte(str++);
+#else
+ char c = *(str++);
+#endif
+ if (!c)
+ return;
+
+ width = glcd_draw_char_xy(x,y,c);
+ x += (width + 1);
+ c++;
+ }
+}
+
diff --git a/lcd/text_tiny.c b/lcd/text_tiny.c
new file mode 100644
index 0000000..ade6d4e
--- /dev/null
+++ b/lcd/text_tiny.c
@@ -0,0 +1,177 @@
+/**
+ \file text_tiny.c
+ \brief Functions relating to using tiny 5x7 text fonts.
+ \author Andy Gock
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "glcd.h"
+
+#if defined(GLCD_DEVICE_AVR8)
+void glcd_tiny_set_font(PGM_P font_table, uint8_t width, uint8_t height, char start_char, char end_char)
+#else
+void glcd_tiny_set_font(const char * font_table, uint8_t width, uint8_t height, char start_char, char end_char)
+#endif
+{
+ font_current.font_table = font_table;
+ font_current.width = width;
+ font_current.height = height;
+ font_current.start_char = start_char;
+ font_current.end_char = end_char;
+ font_current.table_type = STANG;
+}
+
+void glcd_tiny_draw_char(uint8_t x, uint8_t line, char c)
+{
+ uint8_t i;
+
+ /* Only works for fonts < 8 bits in height */
+ if (font_current.height >= 8) {
+ return;
+ }
+ if (c < font_current.start_char || c > font_current.end_char) {
+ c = '.';
+ }
+ if ( line >= GLCD_LCD_HEIGHT / (font_current.height + 1) ) {
+ return;
+ }
+ if ( (x+font_current.width) >= GLCD_LCD_WIDTH ) {
+ return;
+ }
+
+ glcd_update_bbox(x, line*(font_current.height + 1), x+font_current.width, line*(font_current.height + 1) + (font_current.height + 1));
+
+ for ( i = 0; i < font_current.width; i++ ) {
+#if defined(GLCD_DEVICE_AVR8)
+ glcd_buffer_selected[x + (line * GLCD_LCD_WIDTH)] = pgm_read_byte( font_current.font_table + ((c - font_current.start_char) * (font_current.width)) + i );
+#else
+ glcd_buffer_selected[x + (line * GLCD_LCD_WIDTH)] = *( font_current.font_table + ((c - font_current.start_char) * (font_current.width)) + i );
+#endif
+ x++;
+ }
+}
+
+void glcd_tiny_draw_string(uint8_t x, uint8_t line, char *str)
+{
+ if (font_current.height >= 8) {
+ return;
+ }
+ while (*str) {
+ glcd_tiny_draw_char(x, line, *str++);
+ x += (font_current.width + 1);
+ if ((x + font_current.width + 1) > GLCD_LCD_WIDTH) {
+ x = 0; /* Ran out of this line */
+ line++;
+ }
+ if (line >= (GLCD_LCD_HEIGHT/(font_current.height + 1)))
+ return; /* Ran out of space :( */
+ }
+}
+
+#if defined(GLCD_DEVICE_AVR8)
+void glcd_tiny_draw_string_P(uint8_t x, uint8_t line, PGM_P str)
+#else
+void glcd_tiny_draw_string_P(uint8_t x, uint8_t line, const char *str)
+#endif
+{
+ if (font_current.height >= 8) {
+ return;
+ }
+ while (1) {
+#if defined(GLCD_DEVICE_AVR8)
+ char c = pgm_read_byte(str++);
+#else
+ char c = *(str++);
+#endif
+ if (!c)
+ return;
+
+ glcd_tiny_draw_char(x, line, c);
+
+ x += (font_current.width + 1);
+ if ((x + font_current.width + 1) > GLCD_LCD_WIDTH) {
+ x = 0; /* Ran out of this line */
+ line++;
+ }
+ if (line >= (GLCD_LCD_HEIGHT/(font_current.height + 1)))
+ return; /* Ran out of space :( */
+ }
+}
+
+void glcd_tiny_draw_string_ammend(char *str) {
+ glcd_scroll_line();
+ glcd_tiny_draw_string(0, (GLCD_LCD_HEIGHT/8-1), str);
+ glcd_write();
+}
+
+void glcd_tiny_draw_string_ammend_P(const char *str) {
+ glcd_scroll_line();
+ glcd_tiny_draw_string_P(0, (GLCD_LCD_HEIGHT/8-1), str);
+ glcd_write();
+}
+
+void glcd_tiny_invert_line(uint8_t line)
+{
+ glcd_invert_area(0,line*8,GLCD_LCD_WIDTH-1,8);
+}
+
+void glcd_tiny_draw_char_xy(uint8_t x, uint8_t y, char c)
+{
+ uint8_t i;
+ uint8_t xvar, yvar;
+ uint8_t dat;
+
+ /* Only works for fonts < 8 bits in height */
+
+ /* Check all important bounds requirements are okay */
+ if ( (y >= GLCD_LCD_HEIGHT) || ((x+font_current.width) >= GLCD_LCD_WIDTH) || (font_current.height >= 8) || font_current.table_type != STANG) {
+ return;
+ }
+ if (c < font_current.start_char || c > font_current.end_char) {
+ c = '.';
+ }
+
+ xvar = x;
+
+ for ( i = 0; i < font_current.width; i++ ) {
+#if defined(GLCD_DEVICE_AVR8)
+ dat = pgm_read_byte( font_current.font_table + ((c - font_current.start_char) * (font_current.width)) + i );
+#else
+ dat = *( font_current.font_table + ((c - font_current.start_char) * (font_current.width)) + i );
+#endif
+ for (yvar = 0; yvar < font_current.height; yvar++) {
+ glcd_set_pixel(xvar,y+yvar, (dat & (1<<yvar) ? 1 : 0) );
+ }
+ xvar++;
+ }
+
+ glcd_update_bbox(x, y, x+font_current.width,y+font_current.height);
+
+}
diff --git a/lcd/unit_tests.c b/lcd/unit_tests.c
new file mode 100644
index 0000000..75f8bf1
--- /dev/null
+++ b/lcd/unit_tests.c
@@ -0,0 +1,334 @@
+/**
+ * \file unit_tests.c
+ * \brief Various test functions to demonstrate features of the library
+ * \author Andy Gock
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "glcd.h"
+#include "unit_tests.h"
+
+/** Fonts */
+#include "font5x7.h"
+#include "Liberation_Sans11x14_Numbers.h"
+#include "Liberation_Sans15x21_Numbers.h"
+#include "Liberation_Sans17x17_Alpha.h"
+#include "Liberation_Sans27x36_Numbers.h"
+#include "Bebas_Neue20x36_Bold_Numbers.h"
+
+volatile uint8_t unit_test_return = 0;
+
+/**
+ * Return from test procedure. Global var \p unit_test_return is set to 1 elsewhere,
+ * to signal function to return.
+ */
+#define DEMO_RETURN() if (unit_test_return) { unit_test_return = 0; return; }
+
+#if defined(GLCD_UNIT_TEST_BITMAP_ENABLE)
+ /* Open Source logo -- Size: 128x64 */
+ #if defined(GLCD_DEVICE_AVR8)
+ const unsigned char bmp_oslogo[] PROGMEM = {
+ #else
+ const unsigned char bmp_oslogo[] = {
+ #endif /* GLCD_DEVICE_AVR8 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf0, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xfe, 0xfc, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x07, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xf0, 0xe0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xc0, 0xf0, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1f, 0x7f,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00
+, 0x00 //
+ };
+#endif /* GLCD_UNIT_TEST_BITMAP_ENABLE */
+
+void glcd_test_circles(void)
+{
+ uint8_t x,y,radius;
+
+ unit_test_return = 0;
+ while (1) {
+ uint8_t i;
+
+ glcd_clear();
+
+ // generate random(ish) position on display
+ x = rand() % GLCD_LCD_WIDTH;
+ y = rand() % GLCD_LCD_HEIGHT;
+ radius = rand() % 50;
+
+ //x = 70; y=25; radius=50; // for debugging
+
+ // fill circle with black
+
+ for (i=0; i<=radius; i++) {
+ glcd_fill_circle(x,y,i,BLACK);
+ glcd_write();
+ delay_ms(2);
+ }
+
+ // fill the same circle above but with white
+ for (i=0; i<=radius; i++) {
+ glcd_fill_circle(x,y,i,WHITE);
+ glcd_write();
+ delay_ms(1);
+ }
+ DEMO_RETURN();
+ }
+}
+
+void glcd_test_counter_and_graph(void)
+{
+ uint8_t count = 0;
+ char string[8] = "";
+
+ unit_test_return = 0;
+ while(1) {
+ glcd_clear_buffer();
+
+ //glcd_tiny_set_font(Font5x7,5,7,32,127);
+ //glcd_draw_string_xy(0,40,(char *)utoa(count,string,10));
+
+ glcd_set_font(Liberation_Sans15x21_Numbers,15,21,46,57);
+ //glcd_set_font(Liberation_Sans27x36_Numbers,27,36,46,57);
+ //glcd_set_font(Bebas_Neue20x36_Bold_Numbers,20,36,46,57);
+ //glcd_set_font(Bebas_Neue18x36_Numbers,18,36,46,57);
+ //glcd_set_font(HelveticaNeueLT_Com_57_Cn23x35_Numbers,23,35,46,57); // commercial font - not for public distribution
+
+ sprintf(string,"%d",count);
+ glcd_draw_string_xy(0,0,string);
+ glcd_bar_graph_horizontal(10,38,30,6,count*4);
+ glcd_bar_graph_vertical(70,0,8,30,count*2);
+
+ glcd_write();
+ count += 1;
+
+ DEMO_RETURN();
+ }
+
+}
+
+/* Test glcd-utils font table type, increments and display a 16-bit number over and over */
+#include "Earthbound_12x19_48to57.h"
+void glcd_test_glcdutils(void)
+{
+ uint16_t count = 0;
+ char string[8] = "";
+
+ unit_test_return = 0;
+ while(1) {
+ glcd_clear_buffer();
+
+ /* Set the font */
+ glcd_font(font_Earthbound_12x19_48to57,12,19,48,57,GLCD_UTILS);
+
+ sprintf(string,"%d",count);
+ glcd_draw_string_xy(0,0,string);
+ glcd_write();
+
+ count += 1;
+
+ DEMO_RETURN();
+ }
+}
+
+void glcd_test_text_up_down(void)
+{
+ // moves some text up and down the display
+
+ uint8_t y;
+ uint8_t max_y;
+
+ //glcd_set_font(Liberation_Sans11x14_Numbers,11,14,46,57);
+ glcd_set_font(Liberation_Sans15x21_Numbers,15,21,46,57);
+ //glcd_set_font(Liberation_Sans27x36_Numbers,27,36,46,57);
+ //glcd_set_font(Liberation_Sans17x17_Alpha,17,17,46,90);
+
+ max_y = GLCD_LCD_HEIGHT - font_current.height - 2; // max y start position for draw_string
+
+ unit_test_return = 0;
+ while(1) {
+ // move top to bottom
+ for (y=0; y<max_y; y++) {
+ DEMO_RETURN();
+ glcd_clear_buffer();
+ glcd_draw_string_xy(0,y,"123");
+ glcd_write();
+ delay_ms(80);
+ }
+
+ // move bottom to top
+ for (y=(max_y); y>0; y--) {
+ DEMO_RETURN();
+ glcd_clear_buffer();
+ glcd_draw_string_xy(0,y,"456");
+ glcd_write();
+ delay_ms(80);
+ }
+
+ }
+
+}
+
+void glcd_test_tiny_text(void)
+{
+ /* Write tiny text on display, all chars, scrolling up every second */
+
+ char string[GLCD_LCD_WIDTH / 6 + 1];
+
+ uint8_t c = 32;
+ uint8_t len = GLCD_LCD_WIDTH / 6;
+
+ GLCD_TEXT_INIT();
+
+ unit_test_return = 0;
+ while(1) {
+ // write chars to string from 32 to 127 ASCII
+ uint8_t i;
+ for (i=0; i<len; i++) {
+ string[i] = c;
+ c++;
+ if (c > 127) {
+ c = 32;
+ }
+ }
+
+ // write null terminator
+ string[len] = '\0';
+
+ GLCD_WRITE(string);
+
+ DEMO_RETURN();
+
+ delay_ms(1000);
+ }
+
+}
+
+void glcd_test_hello_world(void)
+{
+ glcd_tiny_set_font(Font5x7,5,7,32,127);
+ glcd_clear_buffer();
+ glcd_tiny_draw_string(0,0,"Hello World!");
+ glcd_write();
+
+ unit_test_return = 0;
+ while(1) {
+ DEMO_RETURN();
+ }
+}
+
+void glcd_test_rectangles(void)
+{
+ glcd_tiny_set_font(Font5x7,5,7,32,127);
+ glcd_clear_buffer();
+ glcd_tiny_draw_string(0,0,"RECTANGLE DEMO");
+ glcd_write();
+ delay_ms(200);
+
+ unit_test_return = 0;
+ while(1) {
+
+ //glcd_clear();
+ glcd_draw_rect(0,0,100,50,BLACK);
+ glcd_tiny_draw_string(0,GLCD_NUMBER_OF_BANKS-1,"glcd_draw_rect");
+ glcd_write();
+ delay_ms(500);
+ DEMO_RETURN();
+
+ glcd_clear();
+ glcd_tiny_draw_string(0,GLCD_NUMBER_OF_BANKS-1,"glcd_draw_rect_thick");
+ glcd_write();
+
+ glcd_draw_rect_thick(5,5,80,30,3,6,BLACK);
+ glcd_write();
+ delay_ms(500);
+ DEMO_RETURN();
+
+ glcd_draw_rect_thick(0,0,20,20,2,2,BLACK);
+ glcd_write();
+ delay_ms(500);
+ DEMO_RETURN();
+
+ glcd_draw_rect_thick(100,10,20,20,5,5,BLACK);
+ glcd_write();
+ delay_ms(500);
+ DEMO_RETURN();
+
+ glcd_clear();
+ glcd_tiny_draw_string(0,GLCD_NUMBER_OF_BANKS-1,"glcd_draw_rect_shadow");
+ glcd_draw_rect_shadow(0,0,45,30,BLACK);
+ glcd_write();
+ delay_ms(500);
+ DEMO_RETURN();
+
+ glcd_draw_rect_shadow(95,5,30,30,BLACK);
+ glcd_write();
+ delay_ms(500);
+ DEMO_RETURN();
+
+ }
+
+}
+
+void glcd_test_scrolling_graph(void)
+{
+ glcd_clear();
+ glcd_write();
+
+ unit_test_return = 0;
+ while(1) {
+ uint16_t n;
+ for (n=0; n<=255; n += 20) {
+ glcd_scrolling_bar_graph(0,0,50,50,n);
+ glcd_scrolling_bar_graph(60,0,50,30,n);
+ glcd_scrolling_bar_graph(60,35,60,20,n);
+ DEMO_RETURN();
+ }
+ for (n=0; n<=255; n += 20) {
+ glcd_scrolling_bar_graph(0,0,50,50,255-n);
+ glcd_scrolling_bar_graph(60,0,50,30,n);
+ glcd_scrolling_bar_graph(60,35,60,20,n);
+ DEMO_RETURN();
+ }
+ }
+}
+
+#if defined (GLCD_UNIT_TEST_BITMAP_ENABLE)
+void glcd_test_bitmap_128x64(void)
+{
+ glcd_draw_bitmap(bmp_oslogo);
+
+ unit_test_return = 0;
+ glcd_write();
+ while (1) {
+ DEMO_RETURN();
+ }
+}
+#endif
diff --git a/lcd/unit_tests.h b/lcd/unit_tests.h
new file mode 100644
index 0000000..f3540ba
--- /dev/null
+++ b/lcd/unit_tests.h
@@ -0,0 +1,71 @@
+/**
+ * \file unit_tests.h
+ * \brief Various test functions to demonstrate features of the library
+ * \author Andy Gock
+ */
+
+/*
+ Copyright (c) 2012, Andy Gock
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Andy Gock nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef _UNIT_TESTS_H
+#define _UNIT_TESTS_H
+
+#include "stdint.h"
+
+#define GLCD_UNIT_TEST_BITMAP_ENABLE
+
+extern volatile uint8_t unit_test_return;
+
+/** Make random "exploding circles" */
+void glcd_test_circles(void);
+
+/* Shows a 8-bit counter incorementing, with a verticla and horizontal bar graph */
+void glcd_test_counter_and_graph(void);
+
+/* Shows a 16-bit counter incrementing, using glcdutils font format */
+void glcd_test_glcdutils(void);
+
+/** Scroll some text up and down the screen */
+void glcd_test_text_up_down(void);
+
+/** Display all chars of tiny 5x7 font, scrolling previous lines one by one every second */
+void glcd_test_tiny_text(void);
+
+/** Print hello world to display */
+void glcd_test_hello_world(void);
+
+/** Demonstrating rectangle drawing */
+void glcd_test_rectangles(void);
+
+/** Demonstrate scrolling bar graph */
+void glcd_test_scrolling_graph(void);
+
+/** Demonstrate bitmap display */
+void glcd_test_bitmap_128x64(void);
+
+#endif
diff --git a/libqr/qrencode.c b/libqr/qrencode.c
new file mode 100644
index 0000000..f083724
--- /dev/null
+++ b/libqr/qrencode.c
@@ -0,0 +1,1474 @@
+#include <string.h>
+
+#include "qrencode.h"
+
+typedef enum
+{
+ FALSE = 0,
+ TRUE = !FALSE
+} bool;
+
+typedef unsigned char BYTE;
+typedef unsigned int WORD;
+
+#define QR_LEVEL_L 0
+#define QR_LEVEL_M 1
+#define QR_LEVEL_Q 2
+#define QR_LEVEL_H 3
+
+#define QR_MODE_NUMERAL 0
+#define QR_MODE_ALPHABET 1
+#define QR_MODE_8BIT 2
+
+#define QR_VRESION_S 0
+#define QR_VRESION_M 1
+#define QR_VRESION_L 2
+
+#define MAX_ALLCODEWORD 172 //733Êǰ汾16ÐèÒªµÄ×î´ó¿Õ¼ä
+#define MAX_DATACODEWORD 136 //589Êǰ汾16ÐèÒªµÄ×î´ó¿Õ¼ä
+#define MAX_CODEBLOCK 153
+
+/////////////////////////////////////////////////////////////////////////////
+
+struct RS_BLOCKINFO
+{
+ int ncRSBlock;
+ int ncAllCodeWord;
+ int ncDataCodeWord;
+};
+
+struct QR_VERSIONINFO
+{
+ int nVersionNo;
+ int ncAllCodeWord;
+
+ int ncDataCodeWord[4];
+ int ncAlignPoint;
+ int nAlignPoint[6];
+
+ struct RS_BLOCKINFO RS_BlockInfo1[4];
+ struct RS_BLOCKINFO RS_BlockInfo2[4];
+};
+
+static const struct QR_VERSIONINFO QR_VersonInfo[] = {{0}, // Ver.0
+ {
+ 1, // Ver.1
+ 26, 19, 16, 13, 9,
+ 0, 0, 0, 0, 0, 0, 0,
+ 1, 26, 19,
+ 1, 26, 16,
+ 1, 26, 13,
+ 1, 26, 9,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0
+ },
+ {
+ 2, // Ver.2
+ 44, 34, 28, 22, 16,
+ 1, 18, 0, 0, 0, 0, 0,
+ 1, 44, 34,
+ 1, 44, 28,
+ 1, 44, 22,
+ 1, 44, 16,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0
+ },
+ {
+ 3, // Ver.3
+ 70, 55, 44, 34, 26,
+ 1, 22, 0, 0, 0, 0, 0,
+ 1, 70, 55,
+ 1, 70, 44,
+ 2, 35, 17,
+ 2, 35, 13,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0
+ },
+ {
+ 4, // Ver.4
+ 100, 80, 64, 48, 36,
+ 1, 26, 0, 0, 0, 0, 0,
+ 1, 100, 80,
+ 2, 50, 32,
+ 2, 50, 24,
+ 4, 25, 9,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0
+ },
+ {
+ 5, // Ver.5
+ 134, 108, 86, 62, 46,
+ 1, 30, 0, 0, 0, 0, 0,
+ 1, 134, 108,
+ 2, 67, 43,
+ 2, 33, 15,
+ 2, 33, 11,
+ 0, 0, 0,
+ 0, 0, 0,
+ 2, 34, 16,
+ 2, 34, 12
+ },
+ {
+ 6, // Ver.6
+ 172, 136, 108, 76, 60,
+ 1, 34, 0, 0, 0, 0, 0,
+ 2, 86, 68,
+ 4, 43, 27,
+ 4, 43, 19,
+ 4, 43, 15,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0
+ },
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+static const BYTE byExpToInt[] = { 1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38,
+ 76, 152, 45, 90, 180, 117, 234, 201, 143, 3, 6, 12, 24, 48, 96, 192,
+ 157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35,
+ 70, 140, 5, 10, 20, 40, 80, 160, 93, 186, 105, 210, 185, 111, 222, 161,
+ 95, 190, 97, 194, 153, 47, 94, 188, 101, 202, 137, 15, 30, 60, 120, 240,
+ 253, 231, 211, 187, 107, 214, 177, 127, 254, 225, 223, 163, 91, 182, 113, 226,
+ 217, 175, 67, 134, 17, 34, 68, 136, 13, 26, 52, 104, 208, 189, 103, 206,
+ 129, 31, 62, 124, 248, 237, 199, 147, 59, 118, 236, 197, 151, 51, 102, 204,
+ 133, 23, 46, 92, 184, 109, 218, 169, 79, 158, 33, 66, 132, 21, 42, 84,
+ 168, 77, 154, 41, 82, 164, 85, 170, 73, 146, 57, 114, 228, 213, 183, 115,
+ 230, 209, 191, 99, 198, 145, 63, 126, 252, 229, 215, 179, 123, 246, 241, 255,
+ 227, 219, 171, 75, 150, 49, 98, 196, 149, 55, 110, 220, 165, 87, 174, 65,
+ 130, 25, 50, 100, 200, 141, 7, 14, 28, 56, 112, 224, 221, 167, 83, 166,
+ 81, 162, 89, 178, 121, 242, 249, 239, 195, 155, 43, 86, 172, 69, 138, 9,
+ 18, 36, 72, 144, 61, 122, 244, 245, 247, 243, 251, 235, 203, 139, 11, 22,
+ 44, 88, 176, 125, 250, 233, 207, 131, 27, 54, 108, 216, 173, 71, 142, 1
+ };
+
+
+/////////////////////////////////////////////////////////////////////////////
+static const BYTE byIntToExp[] = { 0, 0, 1, 25, 2, 50, 26, 198, 3, 223, 51, 238, 27, 104, 199, 75,
+ 4, 100, 224, 14, 52, 141, 239, 129, 28, 193, 105, 248, 200, 8, 76, 113,
+ 5, 138, 101, 47, 225, 36, 15, 33, 53, 147, 142, 218, 240, 18, 130, 69,
+ 29, 181, 194, 125, 106, 39, 249, 185, 201, 154, 9, 120, 77, 228, 114, 166,
+ 6, 191, 139, 98, 102, 221, 48, 253, 226, 152, 37, 179, 16, 145, 34, 136,
+ 54, 208, 148, 206, 143, 150, 219, 189, 241, 210, 19, 92, 131, 56, 70, 64,
+ 30, 66, 182, 163, 195, 72, 126, 110, 107, 58, 40, 84, 250, 133, 186, 61,
+ 202, 94, 155, 159, 10, 21, 121, 43, 78, 212, 229, 172, 115, 243, 167, 87,
+ 7, 112, 192, 247, 140, 128, 99, 13, 103, 74, 222, 237, 49, 197, 254, 24,
+ 227, 165, 153, 119, 38, 184, 180, 124, 17, 68, 146, 217, 35, 32, 137, 46,
+ 55, 63, 209, 91, 149, 188, 207, 205, 144, 135, 151, 178, 220, 252, 190, 97,
+ 242, 86, 211, 171, 20, 42, 93, 158, 132, 60, 57, 83, 71, 109, 65, 162,
+ 31, 45, 67, 216, 183, 123, 164, 118, 196, 23, 73, 236, 127, 12, 111, 246,
+ 108, 161, 59, 82, 41, 157, 85, 170, 251, 96, 134, 177, 187, 204, 62, 90,
+ 203, 89, 95, 176, 156, 169, 160, 81, 11, 245, 22, 235, 122, 117, 44, 215,
+ 79, 174, 213, 233, 230, 231, 173, 232, 116, 214, 244, 234, 168, 80, 88, 175
+ };
+
+
+/////////////////////////////////////////////////////////////////////////////
+static const BYTE byRSExp7[] = {87, 229, 146, 149, 238, 102, 21};
+static const BYTE byRSExp10[] = {251, 67, 46, 61, 118, 70, 64, 94, 32, 45};
+static const BYTE byRSExp13[] = { 74, 152, 176, 100, 86, 100, 106, 104, 130, 218, 206, 140, 78};
+static const BYTE byRSExp15[] = { 8, 183, 61, 91, 202, 37, 51, 58, 58, 237, 140, 124, 5, 99, 105};
+static const BYTE byRSExp16[] = {120, 104, 107, 109, 102, 161, 76, 3, 91, 191, 147, 169, 182, 194, 225, 120};
+static const BYTE byRSExp17[] = { 43, 139, 206, 78, 43, 239, 123, 206, 214, 147, 24, 99, 150, 39, 243, 163, 136};
+static const BYTE byRSExp18[] = {215, 234, 158, 94, 184, 97, 118, 170, 79, 187, 152, 148, 252, 179, 5, 98, 96, 153};
+static const BYTE byRSExp20[] = { 17, 60, 79, 50, 61, 163, 26, 187, 202, 180, 221, 225, 83, 239, 156, 164, 212, 212, 188, 190};
+static const BYTE byRSExp22[] = {210, 171, 247, 242, 93, 230, 14, 109, 221, 53, 200, 74, 8, 172, 98, 80, 219, 134, 160, 105,
+ 165, 231
+ };
+static const BYTE byRSExp24[] = {229, 121, 135, 48, 211, 117, 251, 126, 159, 180, 169, 152, 192, 226, 228, 218, 111, 0, 117, 232,
+ 87, 96, 227, 21
+ };
+static const BYTE byRSExp26[] = {173, 125, 158, 2, 103, 182, 118, 17, 145, 201, 111, 28, 165, 53, 161, 21, 245, 142, 13, 102,
+ 48, 227, 153, 145, 218, 70
+ };
+static const BYTE byRSExp28[] = {168, 223, 200, 104, 224, 234, 108, 180, 110, 190, 195, 147, 205, 27, 232, 201, 21, 43, 245, 87,
+ 42, 195, 212, 119, 242, 37, 9, 123
+ };
+static const BYTE byRSExp30[] = { 41, 173, 145, 152, 216, 31, 179, 182, 50, 48, 110, 86, 239, 96, 222, 125, 42, 173, 226, 193,
+ 224, 130, 156, 37, 251, 216, 238, 40, 192, 180
+ };
+static const BYTE byRSExp32[] = { 10, 6, 106, 190, 249, 167, 4, 67, 209, 138, 138, 32, 242, 123, 89, 27, 120, 185, 80, 156,
+ 38, 69, 171, 60, 28, 222, 80, 52, 254, 185, 220, 241
+ };
+static const BYTE byRSExp34[] = {111, 77, 146, 94, 26, 21, 108, 19, 105, 94, 113, 193, 86, 140, 163, 125, 58, 158, 229, 239,
+ 218, 103, 56, 70, 114, 61, 183, 129, 167, 13, 98, 62, 129, 51
+ };
+static const BYTE byRSExp36[] = {200, 183, 98, 16, 172, 31, 246, 234, 60, 152, 115, 0, 167, 152, 113, 248, 238, 107, 18, 63,
+ 218, 37, 87, 210, 105, 177, 120, 74, 121, 196, 117, 251, 113, 233, 30, 120
+ };
+static const BYTE byRSExp38[] = {159, 34, 38, 228, 230, 59, 243, 95, 49, 218, 176, 164, 20, 65, 45, 111, 39, 81, 49, 118,
+ 113, 222, 193, 250, 242, 168, 217, 41, 164, 247, 177, 30, 238, 18, 120, 153, 60, 193
+ };
+static const BYTE byRSExp40[] = { 59, 116, 79, 161, 252, 98, 128, 205, 128, 161, 247, 57, 163, 56, 235, 106, 53, 26, 187, 174,
+ 226, 104, 170, 7, 175, 35, 181, 114, 88, 41, 47, 163, 125, 134, 72, 20, 232, 53, 35, 15
+ };
+static const BYTE byRSExp42[] = {250, 103, 221, 230, 25, 18, 137, 231, 0, 3, 58, 242, 221, 191, 110, 84, 230, 8, 188, 106,
+ 96, 147, 15, 131, 139, 34, 101, 223, 39, 101, 213, 199, 237, 254, 201, 123, 171, 162, 194, 117,
+ 50, 96
+ };
+static const BYTE byRSExp44[] = {190, 7, 61, 121, 71, 246, 69, 55, 168, 188, 89, 243, 191, 25, 72, 123, 9, 145, 14, 247,
+ 1, 238, 44, 78, 143, 62, 224, 126, 118, 114, 68, 163, 52, 194, 217, 147, 204, 169, 37, 130,
+ 113, 102, 73, 181
+ };
+static const BYTE byRSExp46[] = {112, 94, 88, 112, 253, 224, 202, 115, 187, 99, 89, 5, 54, 113, 129, 44, 58, 16, 135, 216,
+ 169, 211, 36, 1, 4, 96, 60, 241, 73, 104, 234, 8, 249, 245, 119, 174, 52, 25, 157, 224,
+ 43, 202, 223, 19, 82, 15
+ };
+static const BYTE byRSExp48[] = {228, 25, 196, 130, 211, 146, 60, 24, 251, 90, 39, 102, 240, 61, 178, 63, 46, 123, 115, 18,
+ 221, 111, 135, 160, 182, 205, 107, 206, 95, 150, 120, 184, 91, 21, 247, 156, 140, 238, 191, 11,
+ 94, 227, 84, 50, 163, 39, 34, 108
+ };
+static const BYTE byRSExp50[] = {232, 125, 157, 161, 164, 9, 118, 46, 209, 99, 203, 193, 35, 3, 209, 111, 195, 242, 203, 225,
+ 46, 13, 32, 160, 126, 209, 130, 160, 242, 215, 242, 75, 77, 42, 189, 32, 113, 65, 124, 69,
+ 228, 114, 235, 175, 124, 170, 215, 232, 133, 205
+ };
+static const BYTE byRSExp52[] = {116, 50, 86, 186, 50, 220, 251, 89, 192, 46, 86, 127, 124, 19, 184, 233, 151, 215, 22, 14,
+ 59, 145, 37, 242, 203, 134, 254, 89, 190, 94, 59, 65, 124, 113, 100, 233, 235, 121, 22, 76,
+ 86, 97, 39, 242, 200, 220, 101, 33, 239, 254, 116, 51
+ };
+static const BYTE byRSExp54[] = {183, 26, 201, 87, 210, 221, 113, 21, 46, 65, 45, 50, 238, 184, 249, 225, 102, 58, 209, 218,
+ 109, 165, 26, 95, 184, 192, 52, 245, 35, 254, 238, 175, 172, 79, 123, 25, 122, 43, 120, 108,
+ 215, 80, 128, 201, 235, 8, 153, 59, 101, 31, 198, 76, 31, 156
+ };
+static const BYTE byRSExp56[] = {106, 120, 107, 157, 164, 216, 112, 116, 2, 91, 248, 163, 36, 201, 202, 229, 6, 144, 254, 155,
+ 135, 208, 170, 209, 12, 139, 127, 142, 182, 249, 177, 174, 190, 28, 10, 85, 239, 184, 101, 124,
+ 152, 206, 96, 23, 163, 61, 27, 196, 247, 151, 154, 202, 207, 20, 61, 10
+ };
+static const BYTE byRSExp58[] = { 82, 116, 26, 247, 66, 27, 62, 107, 252, 182, 200, 185, 235, 55, 251, 242, 210, 144, 154, 237,
+ 176, 141, 192, 248, 152, 249, 206, 85, 253, 142, 65, 165, 125, 23, 24, 30, 122, 240, 214, 6,
+ 129, 218, 29, 145, 127, 134, 206, 245, 117, 29, 41, 63, 159, 142, 233, 125, 148, 123
+ };
+static const BYTE byRSExp60[] = {107, 140, 26, 12, 9, 141, 243, 197, 226, 197, 219, 45, 211, 101, 219, 120, 28, 181, 127, 6,
+ 100, 247, 2, 205, 198, 57, 115, 219, 101, 109, 160, 82, 37, 38, 238, 49, 160, 209, 121, 86,
+ 11, 124, 30, 181, 84, 25, 194, 87, 65, 102, 190, 220, 70, 27, 209, 16, 89, 7, 33, 240
+ };
+static const BYTE byRSExp62[] = { 65, 202, 113, 98, 71, 223, 248, 118, 214, 94, 0, 122, 37, 23, 2, 228, 58, 121, 7, 105,
+ 135, 78, 243, 118, 70, 76, 223, 89, 72, 50, 70, 111, 194, 17, 212, 126, 181, 35, 221, 117,
+ 235, 11, 229, 149, 147, 123, 213, 40, 115, 6, 200, 100, 26, 246, 182, 218, 127, 215, 36, 186,
+ 110, 106
+ };
+static const BYTE byRSExp64[] = { 45, 51, 175, 9, 7, 158, 159, 49, 68, 119, 92, 123, 177, 204, 187, 254, 200, 78, 141, 149,
+ 119, 26, 127, 53, 160, 93, 199, 212, 29, 24, 145, 156, 208, 150, 218, 209, 4, 216, 91, 47,
+ 184, 146, 47, 140, 195, 195, 125, 242, 238, 63, 99, 108, 140, 230, 242, 31, 204, 11, 178, 243,
+ 217, 156, 213, 231
+ };
+static const BYTE byRSExp66[] = { 5, 118, 222, 180, 136, 136, 162, 51, 46, 117, 13, 215, 81, 17, 139, 247, 197, 171, 95, 173,
+ 65, 137, 178, 68, 111, 95, 101, 41, 72, 214, 169, 197, 95, 7, 44, 154, 77, 111, 236, 40,
+ 121, 143, 63, 87, 80, 253, 240, 126, 217, 77, 34, 232, 106, 50, 168, 82, 76, 146, 67, 106,
+ 171, 25, 132, 93, 45, 105
+ };
+static const BYTE byRSExp68[] = {247, 159, 223, 33, 224, 93, 77, 70, 90, 160, 32, 254, 43, 150, 84, 101, 190, 205, 133, 52,
+ 60, 202, 165, 220, 203, 151, 93, 84, 15, 84, 253, 173, 160, 89, 227, 52, 199, 97, 95, 231,
+ 52, 177, 41, 125, 137, 241, 166, 225, 118, 2, 54, 32, 82, 215, 175, 198, 43, 238, 235, 27,
+ 101, 184, 127, 3, 5, 8, 163, 238
+ };
+
+static const BYTE* byRSExp[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, byRSExp7, NULL, NULL,
+ byRSExp10, NULL, NULL, byRSExp13, NULL, byRSExp15, byRSExp16, byRSExp17, byRSExp18, NULL,
+ byRSExp20, NULL, byRSExp22, NULL, byRSExp24, NULL, byRSExp26, NULL, byRSExp28, NULL,
+ byRSExp30, NULL, byRSExp32, NULL, byRSExp34, NULL, byRSExp36, NULL, byRSExp38, NULL,
+ byRSExp40, NULL, byRSExp42, NULL, byRSExp44, NULL, byRSExp46, NULL, byRSExp48, NULL,
+ byRSExp50, NULL, byRSExp52, NULL, byRSExp54, NULL, byRSExp56, NULL, byRSExp58, NULL,
+ byRSExp60, NULL, byRSExp62, NULL, byRSExp64, NULL, byRSExp66, NULL, byRSExp68
+ };
+
+static const int nIndicatorLenNumeral[] = {10, 12, 14};
+static const int nIndicatorLenAlphabet[] = { 9, 11, 13};
+static const int nIndicatorLen8Bit[] = { 8, 16, 16};
+
+static int m_ncDataCodeWordBit;
+static BYTE m_byDataCodeWord[MAX_DATACODEWORD];
+
+static int m_ncDataBlock;
+static BYTE m_byBlockMode[MAX_DATACODEWORD];
+static int m_nBlockLength[MAX_DATACODEWORD];
+
+static int m_ncAllCodeWord;
+static BYTE m_byAllCodeWord[MAX_ALLCODEWORD];
+static BYTE m_byRSWork[MAX_CODEBLOCK];
+
+static int m_nLevel;
+static int m_nVersion;
+static int m_nMaskingNo;
+
+int m_nSymbleSize;
+BYTE m_byModuleData[MAX_MODULESIZE][MAX_MODULESIZE];
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+
+static bool IsNumeralData(unsigned char c)
+{
+ if(c >= '0' && c <= '9')
+ return TRUE;
+
+ return FALSE;
+}
+
+static bool IsAlphabetData(unsigned char c)
+{
+ if(c >= '0' && c <= '9')
+ return TRUE;
+
+ if(c >= 'A' && c <= 'Z')
+ return TRUE;
+
+ if(c == ' ' || c == '$' || c == '%' || c == '*' || c == '+' || c == '-' || c == '.'
+ || c == '/' || c == ':')
+ return TRUE;
+
+ return FALSE;
+}
+
+static BYTE AlphabetToBinaly(BYTE c)
+{
+ if(c >= '0' && c <= '9') return (BYTE)(c - '0');
+
+ if(c >= 'A' && c <= 'Z') return (BYTE)(c - 'A' + 10);
+
+ if(c == ' ') return 36;
+
+ if(c == '$') return 37;
+
+ if(c == '%') return 38;
+
+ if(c == '*') return 39;
+
+ if(c == '+') return 40;
+
+ if(c == '-') return 41;
+
+ if(c == '.') return 42;
+
+ if(c == '/') return 43;
+
+ return 44;
+}
+static int GetBitLength(BYTE nMode, int ncData, int nVerGroup)
+{
+ int ncBits = 0;
+
+ switch(nMode)
+ {
+ case QR_MODE_NUMERAL:
+ ncBits = 4 + nIndicatorLenNumeral[nVerGroup] + (10 * (ncData / 3));
+ switch(ncData % 3)
+ {
+ case 1:
+ ncBits += 4;
+ break;
+ case 2:
+ ncBits += 7;
+ break;
+ default:
+ break;
+ }
+
+ break;
+
+ case QR_MODE_ALPHABET:
+ ncBits = 4 + nIndicatorLenAlphabet[nVerGroup] + (11 * (ncData / 2)) + (6 * (ncData % 2));
+ break;
+
+ case QR_MODE_8BIT:
+ ncBits = 4 + nIndicatorLen8Bit[nVerGroup] + (8 * ncData);
+ break;
+
+ default:
+ break;
+ }
+
+ return ncBits;
+}
+
+static int SetBitStream(int nIndex, WORD wData, int ncData)
+{
+ int i;
+
+ if(nIndex == -1 || nIndex + ncData > MAX_DATACODEWORD * 8)
+ return -1;
+
+ for(i = 0; i < ncData; ++i)
+ {
+ if(wData & (1 << (ncData - i - 1)))
+ {
+ m_byDataCodeWord[(nIndex + i) / 8] |= 1 << (7 - ((nIndex + i) % 8));
+ }
+ }
+
+ return nIndex + ncData;
+}
+
+static void GetRSCodeWord(BYTE* lpbyRSWork, int ncDataCodeWord, int ncRSCodeWord)
+{
+ int i, j;
+
+ for(i = 0; i < ncDataCodeWord ; ++i)
+ {
+ if(lpbyRSWork[0] != 0)
+ {
+ BYTE nExpFirst = byIntToExp[lpbyRSWork[0]];
+
+ for(j = 0; j < ncRSCodeWord; ++j)
+ {
+ BYTE nExpElement = (BYTE)(((int)(byRSExp[ncRSCodeWord][j] + nExpFirst)) % 255);
+
+ lpbyRSWork[j] = (BYTE)(lpbyRSWork[j + 1] ^ byExpToInt[nExpElement]);
+ }
+
+ for(j = ncRSCodeWord; j < ncDataCodeWord + ncRSCodeWord - 1; ++j)
+ lpbyRSWork[j] = lpbyRSWork[j + 1];
+ }
+ else
+ {
+ for(j = 0; j < ncDataCodeWord + ncRSCodeWord - 1; ++j)
+ lpbyRSWork[j] = lpbyRSWork[j + 1];
+ }
+ }
+}
+
+static void SetAlignmentPattern(int x, int y)
+{
+ static BYTE byPattern[] = {0x1f,
+ 0x11,
+ 0x15,
+ 0x11,
+ 0x1f
+ };
+ int i, j;
+
+ if(m_byModuleData[x][y] & 0x20)
+ return;
+
+ x -= 2; y -= 2;
+
+ for(i = 0; i < 5; ++i)
+ {
+ for(j = 0; j < 5; ++j)
+ {
+ m_byModuleData[x + j][y + i] = (byPattern[i] & (1 << (4 - j))) ? '\x30' : '\x20';
+ }
+ }
+}
+static void SetFinderPattern(int x, int y)
+{
+ static BYTE byPattern[] = {0x7f,
+ 0x41,
+ 0x5d,
+ 0x5d,
+ 0x5d,
+ 0x41,
+ 0x7f
+ };
+ int i, j;
+
+ for(i = 0; i < 7; ++i)
+ {
+ for(j = 0; j < 7; ++j)
+ {
+ m_byModuleData[x + j][y + i] = (byPattern[i] & (1 << (6 - j))) ? '\x30' : '\x20';
+ }
+ }
+}
+
+static void SetVersionPattern(void)
+{
+ int i, j;
+ int nVerData;
+
+ if(m_nVersion <= 6)
+ return;
+
+ nVerData = m_nVersion << 12;
+
+ for(i = 0; i < 6; ++i)
+ {
+ if(nVerData & (1 << (17 - i)))
+ {
+ nVerData ^= (0x1f25 << (5 - i));
+ }
+ }
+
+ nVerData += m_nVersion << 12;
+
+ for(i = 0; i < 6; ++i)
+ {
+ for(j = 0; j < 3; ++j)
+ {
+ m_byModuleData[m_nSymbleSize - 11 + j][i] = m_byModuleData[i][m_nSymbleSize - 11 + j] =
+ (nVerData & (1 << (i * 3 + j))) ? '\x30' : '\x20';
+ }
+ }
+}
+
+static void SetCodeWordPattern(void)
+{
+ int x = m_nSymbleSize;
+ int y = m_nSymbleSize - 1;
+
+ int nCoef_x = 1;
+ int nCoef_y = 1;
+
+ int i, j;
+
+ for(i = 0; i < m_ncAllCodeWord; ++i)
+ {
+ for(j = 0; j < 8; ++j)
+ {
+ do
+ {
+ x += nCoef_x;
+ nCoef_x *= -1;
+
+ if(nCoef_x < 0)
+ {
+ y += nCoef_y;
+
+ if(y < 0 || y == m_nSymbleSize)
+ {
+ y = (y < 0) ? 0 : m_nSymbleSize - 1;
+ nCoef_y *= -1;
+
+ x -= 2;
+
+ if(x == 6)
+ --x;
+ }
+ }
+ }
+ while(m_byModuleData[x][y] & 0x20);
+
+ m_byModuleData[x][y] = (m_byAllCodeWord[i] & (1 << (7 - j))) ? '\x02' : '\x00';
+ }
+ }
+}
+
+static void SetMaskingPattern(int nPatternNo)
+{
+ int i, j;
+
+ for(i = 0; i < m_nSymbleSize; ++i)
+ {
+ for(j = 0; j < m_nSymbleSize; ++j)
+ {
+ if(!(m_byModuleData[j][i] & 0x20))
+ {
+ bool bMask;
+
+ switch(nPatternNo)
+ {
+ case 0:
+ bMask = (bool)((i + j) % 2 == 0);
+ break;
+
+ case 1:
+ bMask = (bool)(i % 2 == 0);
+ break;
+
+ case 2:
+ bMask = (bool)(j % 3 == 0);
+ break;
+
+ case 3:
+ bMask = (bool)((i + j) % 3 == 0);
+ break;
+
+ case 4:
+ bMask = (bool)(((i / 2) + (j / 3)) % 2 == 0);
+ break;
+
+ case 5:
+ bMask = (bool)(((i * j) % 2) + ((i * j) % 3) == 0);
+ break;
+
+ case 6:
+ bMask = (bool)((((i * j) % 2) + ((i * j) % 3)) % 2 == 0);
+ break;
+
+ default:
+ bMask = (bool)((((i * j) % 3) + ((i + j) % 2)) % 2 == 0);
+ break;
+ }
+
+ m_byModuleData[j][i] = (BYTE)((m_byModuleData[j][i] & 0xfe) | (((
+ m_byModuleData[j][i] & 0x02) > 1) ^ bMask));
+ }
+ }
+ }
+}
+
+static void SetFormatInfoPattern(int nPatternNo)
+{
+ int nFormatInfo;
+ int i;
+ int nFormatData;
+
+ switch(m_nLevel)
+ {
+ case QR_LEVEL_M:
+ nFormatInfo = 0x00;
+ break;
+
+ case QR_LEVEL_L:
+ nFormatInfo = 0x08;
+ break;
+
+ case QR_LEVEL_Q:
+ nFormatInfo = 0x18;
+ break;
+
+ default:
+ nFormatInfo = 0x10;
+ break;
+ }
+
+ nFormatInfo += nPatternNo;
+
+ nFormatData = nFormatInfo << 10;
+
+ for(i = 0; i < 5; ++i)
+ {
+ if(nFormatData & (1 << (14 - i)))
+ {
+ nFormatData ^= (0x0537 << (4 - i));
+ }
+ }
+
+ nFormatData += nFormatInfo << 10;
+
+ nFormatData ^= 0x5412;
+
+ for(i = 0; i <= 5; ++i)
+ m_byModuleData[8][i] = (nFormatData & (1 << i)) ? '\x30' : '\x20';
+
+ m_byModuleData[8][7] = (nFormatData & (1 << 6)) ? '\x30' : '\x20';
+ m_byModuleData[8][8] = (nFormatData & (1 << 7)) ? '\x30' : '\x20';
+ m_byModuleData[7][8] = (nFormatData & (1 << 8)) ? '\x30' : '\x20';
+
+ for(i = 9; i <= 14; ++i)
+ m_byModuleData[14 - i][8] = (nFormatData & (1 << i)) ? '\x30' : '\x20';
+
+ for(i = 0; i <= 7; ++i)
+ m_byModuleData[m_nSymbleSize - 1 - i][8] = (nFormatData & (1 << i)) ? '\x30' : '\x20';
+
+ m_byModuleData[8][m_nSymbleSize - 8] = '\x30';
+
+ for(i = 8; i <= 14; ++i)
+ m_byModuleData[8][m_nSymbleSize - 15 + i] = (nFormatData & (1 << i)) ? '\x30' : '\x20';
+}
+
+static int CountPenalty(void)
+{
+ int nPenalty = 0;
+ int i, j, k;
+ int nCount = 0, s_nCount;
+
+ for(i = 0; i < m_nSymbleSize; ++i)
+ {
+ for(j = 0; j < m_nSymbleSize - 4; ++j)
+ {
+ int nCount = 1;
+
+ for(k = j + 1; k < m_nSymbleSize; k++)
+ {
+ if(((m_byModuleData[i][j] & 0x11) == 0) == ((m_byModuleData[i][k] & 0x11) == 0))
+ ++nCount;
+ else
+ break;
+ }
+
+ if(nCount >= 5)
+ {
+ nPenalty += 3 + (nCount - 5);
+ }
+
+ j = k - 1;
+ }
+ }
+
+ for(i = 0; i < m_nSymbleSize; ++i)
+ {
+ for(j = 0; j < m_nSymbleSize - 4; ++j)
+ {
+ int nCount = 1;
+
+ for(k = j + 1; k < m_nSymbleSize; k++)
+ {
+ if(((m_byModuleData[j][i] & 0x11) == 0) == ((m_byModuleData[k][i] & 0x11) == 0))
+ ++nCount;
+ else
+ break;
+ }
+
+ if(nCount >= 5)
+ {
+ nPenalty += 3 + (nCount - 5);
+ }
+
+ j = k - 1;
+ }
+ }
+
+ for(i = 0; i < m_nSymbleSize - 1; ++i)
+ {
+ for(j = 0; j < m_nSymbleSize - 1; ++j)
+ {
+ if((((m_byModuleData[i][j] & 0x11) == 0) == ((m_byModuleData[i + 1][j] & 0x11) == 0)) &&
+ (((m_byModuleData[i][j] & 0x11) == 0) == ((m_byModuleData[i] [j + 1] & 0x11) == 0)) &&
+ (((m_byModuleData[i][j] & 0x11) == 0) == ((m_byModuleData[i + 1][j + 1] & 0x11) == 0)))
+ {
+ nPenalty += 3;
+ }
+ }
+ }
+
+ for(i = 0; i < m_nSymbleSize; ++i)
+ {
+ for(j = 0; j < m_nSymbleSize - 6; ++j)
+ {
+ if(((j == 0) || (!(m_byModuleData[i][j - 1] & 0x11))) && // Ã÷»ò·ûºÅÍâ
+ (m_byModuleData[i][j] & 0x11) && // °µ - 1
+ (!(m_byModuleData[i][j + 1] & 0x11)) && // Ã÷ - 1
+ (m_byModuleData[i][j + 2] & 0x11) && // °µ ©´
+ (m_byModuleData[i][j + 3] & 0x11) && // °µ ©¦3
+ (m_byModuleData[i][j + 4] & 0x11) && // °µ ©¼
+ (!(m_byModuleData[i][j + 5] & 0x11)) && // Ã÷ - 1
+ (m_byModuleData[i][j + 6] & 0x11) && // °µ - 1
+ ((j == m_nSymbleSize - 7) || (!(m_byModuleData[i][j + 7] & 0x11)))) // Ã÷»ò·ûºÅÍâ
+ {
+ if(((j < 2 || !(m_byModuleData[i][j - 2] & 0x11)) &&
+ (j < 3 || !(m_byModuleData[i][j - 3] & 0x11)) &&
+ (j < 4 || !(m_byModuleData[i][j - 4] & 0x11))) ||
+ ((j >= m_nSymbleSize - 8 || !(m_byModuleData[i][j + 8] & 0x11)) &&
+ (j >= m_nSymbleSize - 9 || !(m_byModuleData[i][j + 9] & 0x11)) &&
+ (j >= m_nSymbleSize - 10 || !(m_byModuleData[i][j + 10] & 0x11))))
+ {
+ nPenalty += 40;
+ }
+ }
+ }
+ }
+
+ for(i = 0; i < m_nSymbleSize; ++i)
+ {
+ for(j = 0; j < m_nSymbleSize - 6; ++j)
+ {
+ if(((j == 0) || (!(m_byModuleData[j - 1][i] & 0x11))) && // Ã÷»ò·ûºÅÍâ
+ (m_byModuleData[j] [i] & 0x11) && // °µ - 1
+ (!(m_byModuleData[j + 1][i] & 0x11)) && // Ã÷ - 1
+ (m_byModuleData[j + 2][i] & 0x11) && // °µ ©´
+ (m_byModuleData[j + 3][i] & 0x11) && // °µ ©¦3
+ (m_byModuleData[j + 4][i] & 0x11) && // °µ ©¼
+ (!(m_byModuleData[j + 5][i] & 0x11)) && // Ã÷ - 1
+ (m_byModuleData[j + 6][i] & 0x11) && // °µ - 1
+ ((j == m_nSymbleSize - 7) || (!(m_byModuleData[j + 7][i] & 0x11)))) // Ã÷»ò·ûºÅÍâ
+ {
+ if(((j < 2 || !(m_byModuleData[j - 2][i] & 0x11)) &&
+ (j < 3 || !(m_byModuleData[j - 3][i] & 0x11)) &&
+ (j < 4 || !(m_byModuleData[j - 4][i] & 0x11))) ||
+ ((j >= m_nSymbleSize - 8 || !(m_byModuleData[j + 8][i] & 0x11)) &&
+ (j >= m_nSymbleSize - 9 || !(m_byModuleData[j + 9][i] & 0x11)) &&
+ (j >= m_nSymbleSize - 10 || !(m_byModuleData[j + 10][i] & 0x11))))
+ {
+ nPenalty += 40;
+ }
+ }
+ }
+ }
+
+ for(i = 0; i < m_nSymbleSize; ++i)
+ {
+ for(j = 0; j < m_nSymbleSize; ++j)
+ {
+ if(!(m_byModuleData[i][j] & 0x11))
+ {
+ ++nCount;
+ }
+ }
+ }
+
+ if((50 - ((nCount * 100) / (m_nSymbleSize * m_nSymbleSize))) > 0)
+ s_nCount = 50 - ((nCount * 100) / (m_nSymbleSize * m_nSymbleSize));
+ else
+ s_nCount = 0 - (50 - ((nCount * 100) / (m_nSymbleSize * m_nSymbleSize)));
+ nPenalty += (s_nCount / 5) * 10;
+
+ return nPenalty;
+}
+
+static bool EncodeSourceData(char* lpsSource, int ncLength, int nVerGroup)
+{
+ int i, j;
+ int ncSrcBits, ncDstBits;
+ int nBlock = 0;
+ int ncComplete = 0;
+ WORD wBinCode;
+
+ memset(m_nBlockLength, 0, sizeof(m_nBlockLength));
+
+ for(m_ncDataBlock = i = 0; i < ncLength; ++i)
+ {
+ BYTE byMode;
+
+ if(IsNumeralData(lpsSource[i]))
+ byMode = QR_MODE_NUMERAL;
+ else if(IsAlphabetData(lpsSource[i]))
+ byMode = QR_MODE_ALPHABET;
+ else
+ byMode = QR_MODE_8BIT;
+
+ if(i == 0)
+ m_byBlockMode[0] = byMode;
+
+ if(m_byBlockMode[m_ncDataBlock] != byMode)
+ m_byBlockMode[++m_ncDataBlock] = byMode;
+
+ ++m_nBlockLength[m_ncDataBlock];
+ }
+
+ ++m_ncDataBlock;
+
+ while(nBlock < m_ncDataBlock - 1)
+ {
+ int ncJoinFront, ncJoinBehind;
+ int nJoinPosition = 0;
+
+ if((m_byBlockMode[nBlock] == QR_MODE_NUMERAL
+ && m_byBlockMode[nBlock + 1] == QR_MODE_ALPHABET) ||
+ (m_byBlockMode[nBlock] == QR_MODE_ALPHABET
+ && m_byBlockMode[nBlock + 1] == QR_MODE_NUMERAL))
+ {
+ ncSrcBits = GetBitLength(m_byBlockMode[nBlock], m_nBlockLength[nBlock], nVerGroup) +
+ GetBitLength(m_byBlockMode[nBlock + 1], m_nBlockLength[nBlock + 1], nVerGroup);
+
+ ncDstBits = GetBitLength(QR_MODE_ALPHABET,
+ m_nBlockLength[nBlock] + m_nBlockLength[nBlock + 1], nVerGroup);
+
+ if(ncSrcBits > ncDstBits)
+ {
+ if(nBlock >= 1 && m_byBlockMode[nBlock - 1] == QR_MODE_8BIT)
+ {
+ ncJoinFront = GetBitLength(QR_MODE_8BIT,
+ m_nBlockLength[nBlock - 1] + m_nBlockLength[nBlock], nVerGroup) +
+ GetBitLength(m_byBlockMode[nBlock + 1], m_nBlockLength[nBlock + 1], nVerGroup);
+
+ if(ncJoinFront > ncDstBits + GetBitLength(QR_MODE_8BIT, m_nBlockLength[nBlock - 1],
+ nVerGroup))
+ ncJoinFront = 0;
+ }
+ else
+ ncJoinFront = 0;
+
+ if(nBlock < m_ncDataBlock - 2 && m_byBlockMode[nBlock + 2] == QR_MODE_8BIT)
+ {
+ ncJoinBehind = GetBitLength(m_byBlockMode[nBlock], m_nBlockLength[nBlock], nVerGroup) +
+ GetBitLength(QR_MODE_8BIT, m_nBlockLength[nBlock + 1] + m_nBlockLength[nBlock + 2],
+ nVerGroup);
+
+ if(ncJoinBehind > ncDstBits + GetBitLength(QR_MODE_8BIT, m_nBlockLength[nBlock + 2],
+ nVerGroup))
+ ncJoinBehind = 0;
+ }
+ else
+ ncJoinBehind = 0;
+
+ if(ncJoinFront != 0 && ncJoinBehind != 0)
+ {
+ nJoinPosition = (ncJoinFront < ncJoinBehind) ? -1 : 1;
+ }
+ else
+ {
+ nJoinPosition = (ncJoinFront != 0) ? -1 : ((ncJoinBehind != 0) ? 1 : 0);
+ }
+
+ if(nJoinPosition != 0)
+ {
+ if(nJoinPosition == -1)
+ {
+ m_nBlockLength[nBlock - 1] += m_nBlockLength[nBlock];
+
+ for(i = nBlock; i < m_ncDataBlock - 1; ++i)
+ {
+ m_byBlockMode[i] = m_byBlockMode[i + 1];
+ m_nBlockLength[i] = m_nBlockLength[i + 1];
+ }
+ }
+ else
+ {
+ m_byBlockMode[nBlock + 1] = QR_MODE_8BIT;
+ m_nBlockLength[nBlock + 1] += m_nBlockLength[nBlock + 2];
+
+ for(i = nBlock + 2; i < m_ncDataBlock - 1; ++i)
+ {
+ m_byBlockMode[i] = m_byBlockMode[i + 1];
+ m_nBlockLength[i] = m_nBlockLength[i + 1];
+ }
+ }
+
+ --m_ncDataBlock;
+ }
+ else
+ {
+ if(nBlock < m_ncDataBlock - 2 && m_byBlockMode[nBlock + 2] == QR_MODE_ALPHABET)
+ {
+ m_nBlockLength[nBlock + 1] += m_nBlockLength[nBlock + 2];
+
+ for(i = nBlock + 2; i < m_ncDataBlock - 1; ++i)
+ {
+ m_byBlockMode[i] = m_byBlockMode[i + 1];
+ m_nBlockLength[i] = m_nBlockLength[i + 1];
+ }
+
+ --m_ncDataBlock;
+ }
+
+ m_byBlockMode[nBlock] = QR_MODE_ALPHABET;
+ m_nBlockLength[nBlock] += m_nBlockLength[nBlock + 1];
+
+ for(i = nBlock + 1; i < m_ncDataBlock - 1; ++i)
+ {
+ m_byBlockMode[i] = m_byBlockMode[i + 1];
+ m_nBlockLength[i] = m_nBlockLength[i + 1];
+ }
+
+ --m_ncDataBlock;
+
+ if(nBlock >= 1 && m_byBlockMode[nBlock - 1] == QR_MODE_ALPHABET)
+ {
+ m_nBlockLength[nBlock - 1] += m_nBlockLength[nBlock];
+
+ for(i = nBlock; i < m_ncDataBlock - 1; ++i)
+ {
+ m_byBlockMode[i] = m_byBlockMode[i + 1];
+ m_nBlockLength[i] = m_nBlockLength[i + 1];
+ }
+
+ --m_ncDataBlock;
+ }
+ }
+
+ continue;
+ }
+ }
+
+ ++nBlock;
+ }
+
+ nBlock = 0;
+
+ while(nBlock < m_ncDataBlock - 1)
+ {
+ ncSrcBits = GetBitLength(m_byBlockMode[nBlock], m_nBlockLength[nBlock], nVerGroup)
+ + GetBitLength(m_byBlockMode[nBlock + 1], m_nBlockLength[nBlock + 1], nVerGroup);
+
+ ncDstBits = GetBitLength(QR_MODE_8BIT,
+ m_nBlockLength[nBlock] + m_nBlockLength[nBlock + 1], nVerGroup);
+
+ if(nBlock >= 1 && m_byBlockMode[nBlock - 1] == QR_MODE_8BIT)
+ ncDstBits -= (4 + nIndicatorLen8Bit[nVerGroup]);
+
+ if(nBlock < m_ncDataBlock - 2 && m_byBlockMode[nBlock + 2] == QR_MODE_8BIT)
+ ncDstBits -= (4 + nIndicatorLen8Bit[nVerGroup]);
+
+ if(ncSrcBits > ncDstBits)
+ {
+ if(nBlock >= 1 && m_byBlockMode[nBlock - 1] == QR_MODE_8BIT)
+ {
+ m_nBlockLength[nBlock - 1] += m_nBlockLength[nBlock];
+
+ for(i = nBlock; i < m_ncDataBlock - 1; ++i)
+ {
+ m_byBlockMode[i] = m_byBlockMode[i + 1];
+ m_nBlockLength[i] = m_nBlockLength[i + 1];
+ }
+
+ --m_ncDataBlock;
+ --nBlock;
+ }
+
+ if(nBlock < m_ncDataBlock - 2 && m_byBlockMode[nBlock + 2] == QR_MODE_8BIT)
+ {
+ m_nBlockLength[nBlock + 1] += m_nBlockLength[nBlock + 2];
+
+ for(i = nBlock + 2; i < m_ncDataBlock - 1; ++i)
+ {
+ m_byBlockMode[i] = m_byBlockMode[i + 1];
+ m_nBlockLength[i] = m_nBlockLength[i + 1];
+ }
+
+ --m_ncDataBlock;
+ }
+
+ m_byBlockMode[nBlock] = QR_MODE_8BIT;
+ m_nBlockLength[nBlock] += m_nBlockLength[nBlock + 1];
+
+ for(i = nBlock + 1; i < m_ncDataBlock - 1; ++i)
+ {
+ m_byBlockMode[i] = m_byBlockMode[i + 1];
+ m_nBlockLength[i] = m_nBlockLength[i + 1];
+ }
+
+ --m_ncDataBlock;
+
+ if(nBlock >= 1)
+ --nBlock;
+
+ continue;
+ }
+
+ ++nBlock;
+ }
+
+ m_ncDataCodeWordBit = 0;
+
+ memset(m_byDataCodeWord, 0, MAX_DATACODEWORD);
+
+ for(i = 0; i < m_ncDataBlock && m_ncDataCodeWordBit != -1; ++i)
+ {
+ if(m_byBlockMode[i] == QR_MODE_NUMERAL)
+ {
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, 1, 4);
+
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, (WORD)m_nBlockLength[i],
+ nIndicatorLenNumeral[nVerGroup]);
+
+ for(j = 0; j < m_nBlockLength[i]; j += 3)
+ {
+ if(j < m_nBlockLength[i] - 2)
+ {
+ wBinCode = (WORD)(((lpsSource[ncComplete + j] - '0') * 100) +
+ ((lpsSource[ncComplete + j + 1] - '0') * 10) +
+ (lpsSource[ncComplete + j + 2] - '0'));
+
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, wBinCode, 10);
+ }
+ else if(j == m_nBlockLength[i] - 2)
+ {
+ wBinCode = (WORD)(((lpsSource[ncComplete + j] - '0') * 10) +
+ (lpsSource[ncComplete + j + 1] - '0'));
+
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, wBinCode, 7);
+ }
+ else if(j == m_nBlockLength[i] - 1)
+ {
+ wBinCode = (WORD)(lpsSource[ncComplete + j] - '0');
+
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, wBinCode, 4);
+ }
+ }
+
+ ncComplete += m_nBlockLength[i];
+ }
+
+ else if(m_byBlockMode[i] == QR_MODE_ALPHABET)
+ {
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, 2, 4);
+
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, (WORD)m_nBlockLength[i],
+ nIndicatorLenAlphabet[nVerGroup]);
+
+ for(j = 0; j < m_nBlockLength[i]; j += 2)
+ {
+ if(j < m_nBlockLength[i] - 1)
+ {
+ wBinCode = (WORD)((AlphabetToBinaly(lpsSource[ncComplete + j]) * 45) +
+ AlphabetToBinaly(lpsSource[ncComplete + j + 1]));
+
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, wBinCode, 11);
+ }
+ else
+ {
+ wBinCode = (WORD)AlphabetToBinaly(lpsSource[ncComplete + j]);
+
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, wBinCode, 6);
+ }
+ }
+
+ ncComplete += m_nBlockLength[i];
+ }
+
+ else if(m_byBlockMode[i] == QR_MODE_8BIT)
+ {
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, 4, 4);
+
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, (WORD)m_nBlockLength[i],
+ nIndicatorLen8Bit[nVerGroup]);
+
+ for(j = 0; j < m_nBlockLength[i]; ++j)
+ {
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, (WORD)lpsSource[ncComplete + j],
+ 8);
+ }
+
+ ncComplete += m_nBlockLength[i];
+ }
+ }
+
+ return (bool)(m_ncDataCodeWordBit != -1);
+}
+
+static int GetEncodeVersion(int nVersion, char* lpsSource, int ncLength)
+{
+ int nVerGroup = nVersion >= 27 ? QR_VRESION_L : (nVersion >= 10 ? QR_VRESION_M :
+ QR_VRESION_S);
+ int i, j;
+
+ for(i = nVerGroup; i <= QR_VRESION_L; ++i)
+ {
+ if(EncodeSourceData(lpsSource, ncLength, i))
+ {
+ if(i == QR_VRESION_S)
+ {
+ for(j = 1; j <= 9; ++j)
+ {
+ if((m_ncDataCodeWordBit + 7) / 8 <= QR_VersonInfo[j].ncDataCodeWord[m_nLevel])
+ return j;
+ }
+ }
+ else if(i == QR_VRESION_M)
+ {
+ for(j = 10; j <= 26; ++j)
+ {
+ if((m_ncDataCodeWordBit + 7) / 8 <= QR_VersonInfo[j].ncDataCodeWord[m_nLevel])
+ return j;
+ }
+ }
+ else if(i == QR_VRESION_L)
+ {
+ for(j = 27; j <= 40; ++j)
+ {
+ if((m_ncDataCodeWordBit + 7) / 8 <= QR_VersonInfo[j].ncDataCodeWord[m_nLevel])
+ return j;
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+static void SetFunctionModule(void)
+{
+ int i, j;
+
+ SetFinderPattern(0, 0);
+ SetFinderPattern(m_nSymbleSize - 7, 0);
+ SetFinderPattern(0, m_nSymbleSize - 7);
+
+ for(i = 0; i < 8; ++i)
+ {
+ m_byModuleData[i][7] = m_byModuleData[7][i] = '\x20';
+ m_byModuleData[m_nSymbleSize - 8][i] = m_byModuleData[m_nSymbleSize - 8 + i][7] = '\x20';
+ m_byModuleData[i][m_nSymbleSize - 8] = m_byModuleData[7][m_nSymbleSize - 8 + i] = '\x20';
+ }
+
+ for(i = 0; i < 9; ++i)
+ {
+ m_byModuleData[i][8] = m_byModuleData[8][i] = '\x20';
+ }
+
+ for(i = 0; i < 8; ++i)
+ {
+ m_byModuleData[m_nSymbleSize - 8 + i][8] = m_byModuleData[8][m_nSymbleSize - 8 + i] =
+ '\x20';
+ }
+
+ SetVersionPattern();
+
+ for(i = 0; i < QR_VersonInfo[m_nVersion].ncAlignPoint; ++i)
+ {
+ SetAlignmentPattern(QR_VersonInfo[m_nVersion].nAlignPoint[i], 6);
+ SetAlignmentPattern(6, QR_VersonInfo[m_nVersion].nAlignPoint[i]);
+
+ for(j = 0; j < QR_VersonInfo[m_nVersion].ncAlignPoint; ++j)
+ {
+ SetAlignmentPattern(QR_VersonInfo[m_nVersion].nAlignPoint[i],
+ QR_VersonInfo[m_nVersion].nAlignPoint[j]);
+ }
+ }
+
+ for(i = 8; i <= m_nSymbleSize - 9; ++i)
+ {
+ m_byModuleData[i][6] = (i % 2) == 0 ? '\x30' : '\x20';
+ m_byModuleData[6][i] = (i % 2) == 0 ? '\x30' : '\x20';
+ }
+}
+
+static void FormatModule(void)
+{
+ int i, j;
+ int nMinPenalty, nPenalty;
+
+ memset(m_byModuleData, 0, sizeof(m_byModuleData));
+
+ SetFunctionModule();
+
+ SetCodeWordPattern();
+
+ if(m_nMaskingNo == -1)
+ {
+ m_nMaskingNo = 0;
+
+ SetMaskingPattern(m_nMaskingNo);
+ SetFormatInfoPattern(m_nMaskingNo);
+
+ nMinPenalty = CountPenalty();
+
+ for(i = 1; i <= 7; ++i)
+ {
+ SetMaskingPattern(i);
+ SetFormatInfoPattern(i);
+
+ nPenalty = CountPenalty();
+
+ if(nPenalty < nMinPenalty)
+ {
+ nMinPenalty = nPenalty;
+ m_nMaskingNo = i;
+ }
+ }
+ }
+
+ SetMaskingPattern(m_nMaskingNo);
+ SetFormatInfoPattern(m_nMaskingNo);
+
+ for(i = 0; i < m_nSymbleSize; ++i)
+ {
+ for(j = 0; j < m_nSymbleSize; ++j)
+ {
+ m_byModuleData[i][j] = (BYTE)((m_byModuleData[i][j] & 0x11) != 0);
+ }
+ }
+}
+
+int QRencode(char* lpsSource, char* qr)
+{
+ int i, j, nVersion=2, bAutoExtent=1;
+ int ncLength, nEncodeVersion, ncDataCodeWord, ncTerminater;
+ BYTE byPaddingCode = 0xec;
+ int nDataCwIndex = 0, ncBlock1, ncBlock2, ncBlockSum;
+ int nBlockNo = 0, ncDataCw1, ncDataCw2;
+ int ncRSCw1, ncRSCw2;
+
+ m_nLevel = QR_LEVEL_M;
+ m_nMaskingNo = 0;
+
+ ncLength = strlen(lpsSource);
+ if(ncLength == 0)
+ return -1;
+
+ nEncodeVersion = GetEncodeVersion(nVersion, lpsSource, ncLength);
+ if(nEncodeVersion == 0)
+ return -1;
+
+ if(nVersion == 0)
+ {
+ m_nVersion = nEncodeVersion;
+ }
+ else
+ {
+ if(nEncodeVersion <= nVersion)
+ {
+ m_nVersion = nVersion;
+ }
+ else
+ {
+ if(bAutoExtent)
+ m_nVersion = nEncodeVersion;
+ else
+ return -1;
+ }
+ }
+
+ ncDataCodeWord = QR_VersonInfo[m_nVersion].ncDataCodeWord[m_nLevel];
+
+ ncTerminater = min(4, (ncDataCodeWord * 8) - m_ncDataCodeWordBit);
+
+ if(ncTerminater > 0)
+ m_ncDataCodeWordBit = SetBitStream(m_ncDataCodeWordBit, 0, ncTerminater);
+
+ for(i = (m_ncDataCodeWordBit + 7) / 8; i < ncDataCodeWord; ++i)
+ {
+ m_byDataCodeWord[i] = byPaddingCode;
+
+ byPaddingCode = (BYTE)(byPaddingCode == 0xec ? 0x11 : 0xec);
+ }
+
+ m_ncAllCodeWord = QR_VersonInfo[m_nVersion].ncAllCodeWord;
+ memset(m_byAllCodeWord, 0, m_ncAllCodeWord);
+
+ ncBlock1 = QR_VersonInfo[m_nVersion].RS_BlockInfo1[m_nLevel].ncRSBlock;
+ ncBlock2 = QR_VersonInfo[m_nVersion].RS_BlockInfo2[m_nLevel].ncRSBlock;
+ ncBlockSum = ncBlock1 + ncBlock2;
+
+ ncDataCw1 = QR_VersonInfo[m_nVersion].RS_BlockInfo1[m_nLevel].ncDataCodeWord;
+ ncDataCw2 = QR_VersonInfo[m_nVersion].RS_BlockInfo2[m_nLevel].ncDataCodeWord;
+
+ for(i = 0; i < ncBlock1; ++i)
+ {
+ for(j = 0; j < ncDataCw1; ++j)
+ {
+ m_byAllCodeWord[(ncBlockSum * j) + nBlockNo] = m_byDataCodeWord[nDataCwIndex++];
+ }
+
+ ++nBlockNo;
+ }
+
+ for(i = 0; i < ncBlock2; ++i)
+ {
+ for(j = 0; j < ncDataCw2; ++j)
+ {
+ if(j < ncDataCw1)
+ {
+ m_byAllCodeWord[(ncBlockSum * j) + nBlockNo] = m_byDataCodeWord[nDataCwIndex++];
+ }
+ else
+ {
+ m_byAllCodeWord[(ncBlockSum * ncDataCw1) + i] = m_byDataCodeWord[nDataCwIndex++];
+ }
+ }
+
+ ++nBlockNo;
+ }
+
+ ncRSCw1 = QR_VersonInfo[m_nVersion].RS_BlockInfo1[m_nLevel].ncAllCodeWord - ncDataCw1;
+ ncRSCw2 = QR_VersonInfo[m_nVersion].RS_BlockInfo2[m_nLevel].ncAllCodeWord - ncDataCw2;
+
+ nDataCwIndex = 0;
+ nBlockNo = 0;
+
+ for(i = 0; i < ncBlock1; ++i)
+ {
+ memset(m_byRSWork, 0, sizeof(m_byRSWork));
+
+ memmove(m_byRSWork, m_byDataCodeWord + nDataCwIndex, ncDataCw1);
+
+ GetRSCodeWord(m_byRSWork, ncDataCw1, ncRSCw1);
+
+ for(j = 0; j < ncRSCw1; ++j)
+ {
+ m_byAllCodeWord[ncDataCodeWord + (ncBlockSum * j) + nBlockNo] = m_byRSWork[j];
+ }
+
+ nDataCwIndex += ncDataCw1;
+ ++nBlockNo;
+ }
+
+ for(i = 0; i < ncBlock2; ++i)
+ {
+ memset(m_byRSWork, 0, sizeof(m_byRSWork));
+
+ memmove(m_byRSWork, m_byDataCodeWord + nDataCwIndex, ncDataCw2);
+
+ GetRSCodeWord(m_byRSWork, ncDataCw2, ncRSCw2);
+
+ for(j = 0; j < ncRSCw2; ++j)
+ {
+ m_byAllCodeWord[ncDataCodeWord + (ncBlockSum * j) + nBlockNo] = m_byRSWork[j];
+ }
+
+ nDataCwIndex += ncDataCw2;
+ ++nBlockNo;
+ }
+
+ m_nSymbleSize = m_nVersion * 4 + 17;
+
+ FormatModule();
+
+ //64x64
+ // for (i = 0; i < MAX_MODULESIZE; i++) {
+ // for (j = 0; j < MAX_MODULESIZE; j++) {
+ // n_byModuleData[i*2][j*2] = m_byModuleData[i][j];
+ // n_byModuleData[i*2][j*2+1] = m_byModuleData[i][j];
+ // }
+ // memcpy(n_byModuleData[i*2+1], n_byModuleData[i*2], MAX_MODULESIZE*2);
+ // }
+ // for (i = 0; i < MAX_MODULESIZE2; i++) {
+ // for (j = 0; j < (MAX_MODULESIZE2/8); j++) {
+ // qr[i * (MAX_MODULESIZE2/8 + 1) + j] = n_byModuleData[i][j*8 + 0] << 7;
+ // qr[i * (MAX_MODULESIZE2/8 + 1) + j] |= n_byModuleData[i][j*8 + 1] << 6;
+ // qr[i * (MAX_MODULESIZE2/8 + 1) + j] |= n_byModuleData[i][j*8 + 2] << 5;
+ // qr[i * (MAX_MODULESIZE2/8 + 1) + j] |= n_byModuleData[i][j*8 + 3] << 4;
+ // qr[i * (MAX_MODULESIZE2/8 + 1) + j] |= n_byModuleData[i][j*8 + 4] << 3;
+ // qr[i * (MAX_MODULESIZE2/8 + 1) + j] |= n_byModuleData[i][j*8 + 5] << 2;
+ // qr[i * (MAX_MODULESIZE2/8 + 1) + j] |= n_byModuleData[i][j*8 + 6] << 1;
+ // qr[i * (MAX_MODULESIZE2/8 + 1) + j] |= n_byModuleData[i][j*8 + 7];
+ // }
+ // if (j == MAX_MODULESIZE2/8) {
+ // qr[i * (MAX_MODULESIZE2/8 + 1) + j] = n_byModuleData[i][j*8 + 0] << 7;
+ // qr[i * (MAX_MODULESIZE2/8 + 1) + j] |= n_byModuleData[i][j*8 + 1] << 6;
+ // }
+ // }
+
+ //48x48
+ // for (i = 0; i < MAX_MODULESIZE; i++) {
+ // qr[i * ((MAX_MODULESIZE-1)/8 + 1)] = m_byModuleData[i][0];
+ // for (j = 1; j < ((MAX_MODULESIZE-1)/8 + 1); j++) {
+ // qr[i * ((MAX_MODULESIZE-1)/8 + 1) + j] = m_byModuleData[i][(j-1)*8 + 1] << 7;
+ // qr[i * ((MAX_MODULESIZE-1)/8 + 1) + j] |= m_byModuleData[i][(j-1)*8 + 2] << 6;
+ // qr[i * ((MAX_MODULESIZE-1)/8 + 1) + j] |= m_byModuleData[i][(j-1)*8 + 3] << 5;
+ // qr[i * ((MAX_MODULESIZE-1)/8 + 1) + j] |= m_byModuleData[i][(j-1)*8 + 4] << 4;
+ // qr[i * ((MAX_MODULESIZE-1)/8 + 1) + j] |= m_byModuleData[i][(j-1)*8 + 5] << 3;
+ // qr[i * ((MAX_MODULESIZE-1)/8 + 1) + j] |= m_byModuleData[i][(j-1)*8 + 6] << 2;
+ // qr[i * ((MAX_MODULESIZE-1)/8 + 1) + j] |= m_byModuleData[i][(j-1)*8 + 7] << 1;
+ // qr[i * ((MAX_MODULESIZE-1)/8 + 1) + j] |= m_byModuleData[i][(j-1)*8 + 8];
+ // }
+ // }
+ // for (i = 0; i < 7; i++) {
+ // for (j = 0; j < (MAX_MODULESIZE-1)/8 + 1; j++) {
+ // qr[MAX_MODULESIZE * 6 + i + j] = 0;
+ // }
+ // }
+
+ //32x32
+ // for (i = 0; i < MAX_MODULESIZE; i++) {
+ // for (j = 0; j < (MAX_MODULESIZE/8); j++) {
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] = m_byModuleData[i][j*8 + 0] << 7;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 1] << 6;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 2] << 5;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 3] << 4;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 4] << 3;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 5] << 2;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 6] << 1;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 7];
+ // }
+ // if (j == MAX_MODULESIZE/8) {
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] = m_byModuleData[i][j*8 + 0] << 7;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 1] << 6;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 2] << 5;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 3] << 4;
+ // qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 4] << 3;
+ // }
+ // }
+ //40x40
+ if(qr)
+ {
+ for(i = 0; i < MAX_MODULESIZE; i++)
+ {
+ for(j = 0; j < (MAX_MODULESIZE/8); j++)
+ {
+ qr[i * (MAX_MODULESIZE/8 + 1) + j] = m_byModuleData[i][j*8 + 0] << 7;
+ qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 1] << 6;
+ qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 2] << 5;
+ qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 3] << 4;
+ qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 4] << 3;
+ qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 5] << 2;
+ qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 6] << 1;
+ qr[i * (MAX_MODULESIZE/8 + 1) + j] |= m_byModuleData[i][j*8 + 7];
+ }
+ if(j == MAX_MODULESIZE/8)
+ {
+ qr[i * (MAX_MODULESIZE/8 + 1) + j] = m_byModuleData[i][j*8 + 0] << 7;
+ }
+ }
+ }
+ return 1;
+}
+
diff --git a/libqr/qrencode.h b/libqr/qrencode.h
new file mode 100644
index 0000000..a3a1130
--- /dev/null
+++ b/libqr/qrencode.h
@@ -0,0 +1,48 @@
+#ifndef QRENCODE_H
+#define QRENCODE_H
+
+#define MAX_MODULESIZE 25 //41 //50 // 21:Version=1,×î´ó×Ö·û=17(8.5¸öºº×Ö)
+ // 25:Version=2,×î´ó×Ö·û=32(16¸öºº×Ö)
+ // 29:Version=3,×î´ó×Ö·û=53(26.5¸öºº×Ö)
+ // 33:Version=4,×î´ó×Ö·û=78(39¸öºº×Ö)
+ // 37:Version=5,×î´ó×Ö·û=106(53¸öºº×Ö)
+ // 41:Version=6,×î´ó×Ö·û=134(67¸öºº×Ö) the one
+ // 45:Version=7,×î´ó×Ö·û=154(77¸öºº×Ö)
+ // 49:Version=8,×î´ó×Ö·û=192(96¸öºº×Ö)
+ // 53: 9
+ // 57: 10
+ // 61: 11
+// #define QR_MARGIN 4
+
+int QRencode(char *lpsSource, char *qr);
+
+//int GetEncodeVersion(int nVersion, char *lpsSource, int ncLength);
+//bool EncodeSourceData(char *lpsSource, int ncLength, int nVerGroup);
+
+//int GetBitLength(BYTE nMode, int ncData, int nVerGroup);
+
+//int SetBitStream(int nIndex, WORD wData, int ncData);
+
+//bool IsNumeralData(unsigned char c);
+//bool IsAlphabetData(unsigned char c);
+
+//BYTE AlphabetToBinaly(unsigned char c);
+
+//void GetRSCodeWord(BYTE *lpbyRSWork, int ncDataCodeWord, int ncRSCodeWord);
+
+//void FormatModule(void);
+
+//void SetFunctionModule(void);
+//void SetFinderPattern(int x, int y);
+//void SetAlignmentPattern(int x, int y);
+//void SetVersionPattern(void);
+//void SetCodeWordPattern(void);
+//void SetMaskingPattern(int nPatternNo);
+//void SetFormatInfoPattern(int nPatternNo);
+//int CountPenalty(void);
+
+extern int m_nSymbleSize;
+extern unsigned char m_byModuleData[MAX_MODULESIZE][MAX_MODULESIZE];
+
+#endif
+
diff --git a/msgpack/cwpack.c b/msgpack/cwpack.c
new file mode 100644
index 0000000..496b4b3
--- /dev/null
+++ b/msgpack/cwpack.c
@@ -0,0 +1,672 @@
+/* CWPack - cwpack.c */
+/*
+ The MIT License (MIT)
+
+ Copyright (c) 2017 Claes Wihlborg
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ software and associated documentation files (the "Software"), to deal in the Software
+ without restriction, including without limitation the rights to use, copy, modify,
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <string.h>
+
+#include "cwpack.h"
+#include "cwpack_defines.h"
+
+
+
+/************************* C S Y S T E M L I B R A R Y ****************/
+
+#ifdef FORCE_NO_LIBRARY
+
+static void *memcpy(void *dst, const void *src, size_t n)
+{
+ unsigned int i;
+ uint8_t *d=(uint8_t*)dst, *s=(uint8_t*)src;
+ for (i=0; i<n; i++)
+ {
+ *d++ = *s++;
+ }
+ return dst;
+}
+
+#endif
+
+
+
+/************************* B Y T E O R D E R ****************************/
+
+
+static int test_byte_order(void)
+{
+#ifdef COMPILE_FOR_BIG_ENDIAN
+ const char *endianness = "1234";
+ if (*(uint32_t*)endianness != 0x31323334UL)
+ return CWP_RC_WRONG_BYTE_ORDER;
+#else
+
+#ifdef COMPILE_FOR_LITTLE_ENDIAN
+ const char *endianness = "1234";
+ if (*(uint32_t*)endianness != 0x34333231UL)
+ return CWP_RC_WRONG_BYTE_ORDER;
+#endif
+#endif
+ return CWP_RC_OK;
+}
+
+
+/******************************* P A C K **********************************/
+
+
+
+int cw_pack_context_init (cw_pack_context* pack_context, void* data, unsigned long length, pack_overflow_handler hpo)
+{
+ pack_context->start = pack_context->current = (uint8_t*)data;
+ pack_context->end = pack_context->start + length;
+ pack_context->be_compatible = false;
+ pack_context->err_no = 0;
+ pack_context->handle_pack_overflow = hpo;
+ pack_context->return_code = test_byte_order();
+ return pack_context->return_code;
+}
+
+void cw_pack_set_compatibility (cw_pack_context* pack_context, bool be_compatible)
+{
+ pack_context->be_compatible = be_compatible;
+}
+
+
+
+/* Packing routines -------------------------------------------------------------------------------- */
+
+
+void cw_pack_unsigned(cw_pack_context* pack_context, uint64_t i)
+{
+ if (pack_context->return_code)
+ return;
+
+ if (i < 128)
+ tryMove0(i);
+
+ if (i < 256)
+ tryMove1(0xcc, i);
+
+ if (i < 0x10000L)
+ {
+ tryMove2(0xcd, i);
+ }
+ if (i < 0x100000000LL)
+ tryMove4(0xce, i);
+
+ tryMove8(0xcf,i);
+}
+
+
+void cw_pack_signed(cw_pack_context* pack_context, int64_t i)
+{
+ if (pack_context->return_code)
+ return;
+
+ if (i >127)
+ {
+ if (i < 256)
+ tryMove1(0xcc, i);
+
+ if (i < 0x10000L)
+ tryMove2(0xcd, i);
+
+ if (i < 0x100000000LL)
+ tryMove4(0xce, i);
+
+ tryMove8(0xcf,i);
+ }
+
+ if (i >= -32)
+ tryMove0(i);
+
+ if (i >= -128)
+ tryMove1(0xd0, i);
+
+ if (i >= -32768)
+ tryMove2(0xd1,i);
+
+ if (i >= (int64_t)0xffffffff80000000LL)
+ tryMove4(0xd2,i);
+
+ tryMove8(0xd3,i);
+}
+
+
+void cw_pack_float(cw_pack_context* pack_context, float f)
+{
+ if (pack_context->return_code)
+ return;
+
+ uint32_t tmp = *((uint32_t*)&f);
+ tryMove4(0xca,tmp);
+}
+
+
+void cw_pack_double(cw_pack_context* pack_context, double d)
+{
+ if (pack_context->return_code)
+ return;
+
+ uint64_t tmp = *((uint64_t*)&d);
+ tryMove8(0xcb,tmp);
+}
+
+
+void cw_pack_real (cw_pack_context* pack_context, double d)
+{
+ float f = (float)d;
+ double df = f;
+ if (df == d)
+ cw_pack_float (pack_context, f);
+ else
+ cw_pack_double (pack_context, d);
+}
+
+
+void cw_pack_nil(cw_pack_context* pack_context)
+{
+ if (pack_context->return_code)
+ return;
+
+ tryMove0(0xc0);
+}
+
+
+void cw_pack_true (cw_pack_context* pack_context)
+{
+ if (pack_context->return_code)
+ return;
+
+ tryMove0(0xc3);
+}
+
+
+void cw_pack_false (cw_pack_context* pack_context)
+{
+ if (pack_context->return_code)
+ return;
+
+ tryMove0(0xc2);
+}
+
+
+void cw_pack_boolean(cw_pack_context* pack_context, bool b)
+{
+ if (pack_context->return_code)
+ return;
+
+ tryMove0(b? 0xc3: 0xc2);
+}
+
+
+void cw_pack_array_size(cw_pack_context* pack_context, uint32_t n)
+{
+ if (pack_context->return_code)
+ return;
+
+ if (n < 16)
+ tryMove0(0x90 | n);
+
+ if (n < 65536)
+ tryMove2(0xdc, n);
+
+ tryMove4(0xdd, n);
+}
+
+
+void cw_pack_map_size(cw_pack_context* pack_context, uint32_t n)
+{
+ if (pack_context->return_code)
+ return;
+
+ if (n < 16)
+ tryMove0(0x80 | n);
+
+ if (n < 65536)
+ tryMove2(0xde, n);
+
+ tryMove4(0xdf, n);
+}
+
+
+void cw_pack_str(cw_pack_context* pack_context, const char* v, uint32_t l)
+{
+ if (pack_context->return_code)
+ return;
+
+ uint8_t *p;
+
+ if (l < 32) // Fixstr
+ {
+ cw_pack_reserve_space(l+1);
+ *p = (uint8_t)(0xa0 + l);
+ memcpy(p+1,v,l);
+ return;
+ }
+ if (l < 256 && !pack_context->be_compatible) // Str 8
+ {
+ cw_pack_reserve_space(l+2);
+ *p++ = (uint8_t)(0xd9);
+ *p = (uint8_t)(l);
+ memcpy(p+1,v,l);
+ return;
+ }
+ if (l < 65536) // Str 16
+ {
+ cw_pack_reserve_space(l+3)
+ *p++ = (uint8_t)0xda;
+ cw_store16(l);
+ memcpy(p+2,v,l);
+ return;
+ }
+ // Str 32
+ cw_pack_reserve_space(l+5)
+ *p++ = (uint8_t)0xdb;
+ cw_store32(l);
+ memcpy(p+4,v,l);
+ return;
+}
+
+
+void cw_pack_bin(cw_pack_context* pack_context, const void* v, uint32_t l)
+{
+ if (pack_context->return_code)
+ return;
+
+ if (pack_context->be_compatible)
+ {
+ cw_pack_str( pack_context, v, l);
+ return;
+ }
+
+ uint8_t *p;
+
+ if (l < 256) // Bin 8
+ {
+ cw_pack_reserve_space(l+2);
+ *p++ = (uint8_t)(0xc4);
+ *p = (uint8_t)(l);
+ memcpy(p+1,v,l);
+ return;
+ }
+ if (l < 65536) // Bin 16
+ {
+ cw_pack_reserve_space(l+3)
+ *p++ = (uint8_t)0xc5;
+ cw_store16(l);
+ memcpy(p+2,v,l);
+ return;
+ }
+ // Bin 32
+ cw_pack_reserve_space(l+5)
+ *p++ = (uint8_t)0xc6;
+ cw_store32(l);
+ memcpy(p+4,v,l);
+ return;
+}
+
+
+void cw_pack_ext (cw_pack_context* pack_context, int8_t type, const void* v, uint32_t l)
+{
+ if (pack_context->return_code)
+ return;
+
+ if (pack_context->be_compatible)
+ PACK_ERROR(CWP_RC_ILLEGAL_CALL);
+
+ uint8_t *p;
+
+ switch (l)
+ {
+ case 1: // Fixext 1
+ cw_pack_reserve_space(3);
+ *p++ = (uint8_t)0xd4;
+ *p++ = (uint8_t)type;
+ *p++ = *(uint8_t*)v;
+ return;
+ case 2: // Fixext 2
+ cw_pack_reserve_space(4);
+ *p++ = (uint8_t)0xd5;
+ break;
+ case 4: // Fixext 4
+ cw_pack_reserve_space(6);
+ *p++ = (uint8_t)0xd6;
+ break;
+ case 8: // Fixext 8
+ cw_pack_reserve_space(10);
+ *p++ = (uint8_t)0xd7;
+ break;
+ case 16: // Fixext16
+ cw_pack_reserve_space(18);
+ *p++ = (uint8_t)0xd8;
+ break;
+ default:
+ if (l < 256) // Ext 8
+ {
+ cw_pack_reserve_space(l+3);
+ *p++ = (uint8_t)0xc7;
+ *p++ = (uint8_t)(l);
+ }
+ else if (l < 65536) // Ext 16
+ {
+ cw_pack_reserve_space(l+4)
+ *p++ = (uint8_t)0xc8;
+ cw_store16(l);
+ p += 2;
+ }
+ else // Ext 32
+ {
+ cw_pack_reserve_space(l+6)
+ *p++ = (uint8_t)0xc9;
+ cw_store32(l);
+ p += 4;
+ }
+ }
+ *p++ = (uint8_t)type;
+ memcpy(p,v,l);
+}
+
+
+void cw_pack_insert (cw_pack_context* pack_context, const void* v, uint32_t l)
+{
+ uint8_t *p;
+ cw_pack_reserve_space(l);
+ memcpy(p,v,l);
+}
+
+/******************************* U N P A C K **********************************/
+
+
+int cw_unpack_context_init (cw_unpack_context* unpack_context, void* data, unsigned long length, unpack_underflow_handler huu)
+{
+ unpack_context->start = unpack_context->current = (uint8_t*)data;
+ unpack_context->end = unpack_context->start + length;
+ unpack_context->return_code = test_byte_order();
+ unpack_context->err_no = 0;
+ unpack_context->handle_unpack_underflow = huu;
+ return unpack_context->return_code;
+}
+
+
+/* Unpacking routines ---------------------------------------------------------- */
+
+
+
+void cw_unpack_next (cw_unpack_context* unpack_context)
+{
+ if (unpack_context->return_code)
+ return;
+
+ uint64_t tmpu64;
+ uint32_t tmpu32;
+ uint16_t tmpu16;
+ uint8_t* p;
+
+#define buffer_end_return_code CWP_RC_END_OF_INPUT;
+ cw_unpack_assert_space(1);
+ uint8_t c = *p;
+#undef buffer_end_return_code
+#define buffer_end_return_code CWP_RC_BUFFER_UNDERFLOW;
+ switch (c)
+ {
+ case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
+ case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
+ case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
+ case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
+ case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
+ case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f:
+ case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
+ case 0x38: case 0x39: case 0x3a: case 0x3b: case 0x3c: case 0x3d: case 0x3e: case 0x3f:
+ case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47:
+ case 0x48: case 0x49: case 0x4a: case 0x4b: case 0x4c: case 0x4d: case 0x4e: case 0x4f:
+ case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57:
+ case 0x58: case 0x59: case 0x5a: case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f:
+ case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67:
+ case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f:
+ case 0x70: case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77:
+ case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f:
+ getDDItem(CWP_ITEM_POSITIVE_INTEGER, i64, c); return; // positive fixnum
+ case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: case 0x86: case 0x87:
+ case 0x88: case 0x89: case 0x8a: case 0x8b: case 0x8c: case 0x8d: case 0x8e: case 0x8f:
+ getDDItem(CWP_ITEM_MAP, map.size, c & 0x0f); return; // fixmap
+ case 0x90: case 0x91: case 0x92: case 0x93: case 0x94: case 0x95: case 0x96: case 0x97:
+ case 0x98: case 0x99: case 0x9a: case 0x9b: case 0x9c: case 0x9d: case 0x9e: case 0x9f:
+ getDDItem(CWP_ITEM_ARRAY, array.size, c & 0x0f); return; // fixarray
+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: case 0xa4: case 0xa5: case 0xa6: case 0xa7:
+ case 0xa8: case 0xa9: case 0xaa: case 0xab: case 0xac: case 0xad: case 0xae: case 0xaf:
+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7:
+ case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf:
+ getDDItem(CWP_ITEM_STR, str.length, c & 0x1f); // fixraw
+ cw_unpack_assert_blob(str);
+ case 0xc0: unpack_context->item.type = CWP_ITEM_NIL; return; // nil
+ case 0xc2: getDDItem(CWP_ITEM_BOOLEAN, boolean, false); return; // false
+ case 0xc3: getDDItem(CWP_ITEM_BOOLEAN, boolean, true); return; // true
+ case 0xc4: getDDItem1(CWP_ITEM_BIN, bin.length, uint8_t); // bin 8
+ cw_unpack_assert_blob(bin);
+ case 0xc5: getDDItem2(CWP_ITEM_BIN, bin.length, uint16_t); // bin 16
+ cw_unpack_assert_blob(bin);
+ case 0xc6: getDDItem4(CWP_ITEM_BIN, bin.length, uint32_t); // bin 32
+ cw_unpack_assert_blob(bin);
+ case 0xc7: getDDItem1(CWP_ITEM_EXT, ext.length, uint8_t); // ext 8
+ cw_unpack_assert_space(1);
+ unpack_context->item.type = *(int8_t*)p;
+ cw_unpack_assert_blob(ext);
+ case 0xc8: getDDItem2(CWP_ITEM_EXT, ext.length, uint16_t); // ext 16
+ cw_unpack_assert_space(1);
+ unpack_context->item.type = *(int8_t*)p;
+ cw_unpack_assert_blob(ext);
+ case 0xc9: getDDItem4(CWP_ITEM_EXT, ext.length, uint32_t); // ext 32
+ cw_unpack_assert_space(1);
+ unpack_context->item.type = *(int8_t*)p;
+ cw_unpack_assert_blob(ext);
+ case 0xca: unpack_context->item.type = CWP_ITEM_FLOAT; // float
+ cw_unpack_assert_space(4);
+ cw_load32(p);
+ unpack_context->item.as.real = *(float*)&tmpu32; return;
+ case 0xcb: getDDItem8(CWP_ITEM_DOUBLE); return; // double
+ case 0xcc: getDDItem1(CWP_ITEM_POSITIVE_INTEGER, u64, uint8_t); return; // unsigned int 8
+ case 0xcd: getDDItem2(CWP_ITEM_POSITIVE_INTEGER, u64, uint16_t); return; // unsigned int 16
+ case 0xce: getDDItem4(CWP_ITEM_POSITIVE_INTEGER, u64, uint32_t); return; // unsigned int 32
+ case 0xcf: getDDItem8(CWP_ITEM_POSITIVE_INTEGER); return; // unsigned int 64
+ case 0xd0: getDDItem1(CWP_ITEM_NEGATIVE_INTEGER, i64, int8_t); // signed int 8
+ if (unpack_context->item.as.i64 >= 0)
+ unpack_context->item.type = CWP_ITEM_POSITIVE_INTEGER;
+ return;
+ case 0xd1: getDDItem2(CWP_ITEM_NEGATIVE_INTEGER, i64, int16_t); // signed int 16
+ if (unpack_context->item.as.i64 >= 0)
+ unpack_context->item.type = CWP_ITEM_POSITIVE_INTEGER;
+ return;
+ case 0xd2: getDDItem4(CWP_ITEM_NEGATIVE_INTEGER, i64, int32_t); // signed int 32
+ if (unpack_context->item.as.i64 >= 0)
+ unpack_context->item.type = CWP_ITEM_POSITIVE_INTEGER;
+ return;
+ case 0xd3: getDDItem8(CWP_ITEM_NEGATIVE_INTEGER); // signed int 64
+ if (unpack_context->item.as.i64 >= 0)
+ unpack_context->item.type = CWP_ITEM_POSITIVE_INTEGER;
+ return;
+ case 0xd4: getDDItemFix(1); // fixext 1
+ case 0xd5: getDDItemFix(2); // fixext 2
+ case 0xd6: getDDItemFix(4); // fixext 4
+ case 0xd7: getDDItemFix(8); // fixext 8
+ case 0xd8: getDDItemFix(16); // fixext 16
+ case 0xd9: getDDItem1(CWP_ITEM_STR, str.length, uint8_t); // str 8
+ cw_unpack_assert_blob(str);
+ case 0xda: getDDItem2(CWP_ITEM_STR, str.length, uint16_t); // str 16
+ cw_unpack_assert_blob(str);
+ case 0xdb: getDDItem4(CWP_ITEM_STR, str.length, uint32_t); // str 32
+ cw_unpack_assert_blob(str);
+ case 0xdc: getDDItem2(CWP_ITEM_ARRAY, array.size, uint16_t); return; // array 16
+ case 0xdd: getDDItem4(CWP_ITEM_ARRAY, array.size, uint32_t); return; // array 32
+ case 0xde: getDDItem2(CWP_ITEM_MAP, map.size, uint16_t); return; // map 16
+ case 0xdf: getDDItem4(CWP_ITEM_MAP, map.size, uint32_t); return; // map 32
+ case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe4: case 0xe5: case 0xe6: case 0xe7:
+ case 0xe8: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xee: case 0xef:
+ case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: case 0xf7:
+ case 0xf8: case 0xf9: case 0xfa: case 0xfb: case 0xfc: case 0xfd: case 0xfe: case 0xff:
+ getDDItem(CWP_ITEM_NEGATIVE_INTEGER, i64, (int8_t)c); return; // negative fixnum
+ default:
+ UNPACK_ERROR(CWP_RC_MALFORMED_INPUT)
+ }
+}
+
+#define cw_skip_bytes(n) \
+ cw_unpack_assert_space((n)); \
+ break;
+
+void cw_skip_items (cw_unpack_context* unpack_context, long item_count)
+{
+ if (unpack_context->return_code)
+ return;
+
+ uint32_t tmpu32;
+ uint16_t tmpu16;
+ uint8_t* p;
+
+ while (item_count-- > 0)
+ {
+#undef buffer_end_return_code
+#define buffer_end_return_code CWP_RC_END_OF_INPUT;
+ cw_unpack_assert_space(1);
+ uint8_t c = *p;
+
+#undef buffer_end_return_code
+#define buffer_end_return_code CWP_RC_BUFFER_UNDERFLOW;
+ switch (c)
+ {
+ case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
+ case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
+ case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
+ case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
+ case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
+ case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f:
+ case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
+ case 0x38: case 0x39: case 0x3a: case 0x3b: case 0x3c: case 0x3d: case 0x3e: case 0x3f:
+ case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47:
+ case 0x48: case 0x49: case 0x4a: case 0x4b: case 0x4c: case 0x4d: case 0x4e: case 0x4f:
+ case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57:
+ case 0x58: case 0x59: case 0x5a: case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f:
+ case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67:
+ case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f:
+ case 0x70: case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77:
+ case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f:
+ // unsigned fixint
+ case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe4: case 0xe5: case 0xe6: case 0xe7:
+ case 0xe8: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xee: case 0xef:
+ case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: case 0xf7:
+ case 0xf8: case 0xf9: case 0xfa: case 0xfb: case 0xfc: case 0xfd: case 0xfe: case 0xff:
+ // signed fixint
+ case 0xc0: // nil
+ case 0xc2: // false
+ case 0xc3: break; // true
+ case 0xcc: // unsigned int 8
+ case 0xd0: cw_skip_bytes(1); // signed int 8
+ case 0xcd: // unsigned int 16
+ case 0xd1: // signed int 16
+ case 0xd4: cw_skip_bytes(2); // fixext 1
+ case 0xd5: cw_skip_bytes(3); // fixext 2
+ case 0xca: // float
+ case 0xce: // unsigned int 32
+ case 0xd2: cw_skip_bytes(4); // signed int 32
+ case 0xd6: cw_skip_bytes(5); // fixext 4
+ case 0xcb: // double
+ case 0xcf: // unsigned int 64
+ case 0xd3: cw_skip_bytes(8); // signed int 64
+ case 0xd7: cw_skip_bytes(9); // fixext 8
+ case 0xd8: cw_skip_bytes(17); // fixext 16
+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: case 0xa4: case 0xa5: case 0xa6: case 0xa7:
+ case 0xa8: case 0xa9: case 0xaa: case 0xab: case 0xac: case 0xad: case 0xae: case 0xaf:
+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7:
+ case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf:
+ cw_skip_bytes(c & 0x1f); // fixstr
+ case 0xd9: // str 8
+ case 0xc4: // bin 8
+ cw_unpack_assert_space(1);
+ tmpu32 = *p;
+ cw_skip_bytes(tmpu32);
+
+ case 0xda: // str 16
+ case 0xc5: // bin 16
+ cw_unpack_assert_space(2);
+ cw_load16(p);
+ cw_skip_bytes(tmpu16);
+
+ case 0xdb: // str 32
+ case 0xc6: // bin 32
+ cw_unpack_assert_space(4);
+ cw_load32(p);
+ cw_skip_bytes(tmpu32);
+
+ case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: case 0x86: case 0x87:
+ case 0x88: case 0x89: case 0x8a: case 0x8b: case 0x8c: case 0x8d: case 0x8e: case 0x8f:
+ item_count += 2*(c & 15); // FixMap
+ break;
+
+ case 0x90: case 0x91: case 0x92: case 0x93: case 0x94: case 0x95: case 0x96: case 0x97:
+ case 0x98: case 0x99: case 0x9a: case 0x9b: case 0x9c: case 0x9d: case 0x9e: case 0x9f:
+ item_count += c & 15; // FixArray
+ break;
+
+ case 0xdc: // array 16
+ cw_unpack_assert_space(2);
+ cw_load16(p);
+ item_count += tmpu16;
+ break;
+
+ case 0xde: // map 16
+ cw_unpack_assert_space(2);
+ cw_load16(p);
+ item_count += 2*tmpu16;
+ break;
+
+ case 0xdd: // array 32
+ cw_unpack_assert_space(4);
+ cw_load32(p);
+ item_count += tmpu32;
+ break;
+
+ case 0xdf: // map 32
+ cw_unpack_assert_space(4);
+ cw_load32(p);
+ item_count += 2*tmpu32;
+ break;
+
+ case 0xc7: // ext 8
+ cw_unpack_assert_space(1);
+ tmpu32 = *p;
+ cw_skip_bytes(tmpu32 +1);
+
+ case 0xc8: // ext 16
+ cw_unpack_assert_space(2);
+ cw_load16(p);
+ cw_skip_bytes(tmpu16 +1);
+
+ case 0xc9: // ext 32
+ cw_unpack_assert_space(4);
+ cw_load32(p);
+ cw_skip_bytes(tmpu32 +1);
+
+ default: // illegal
+ UNPACK_ERROR(CWP_RC_MALFORMED_INPUT)
+ }
+ }
+ return;
+}
+
+/* end cwpack.c */
diff --git a/msgpack/cwpack.h b/msgpack/cwpack.h
new file mode 100644
index 0000000..c297d56
--- /dev/null
+++ b/msgpack/cwpack.h
@@ -0,0 +1,166 @@
+/* CWPack - cwpack.h */
+/*
+ The MIT License (MIT)
+
+ Copyright (c) 2017 Claes Wihlborg
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ software and associated documentation files (the "Software"), to deal in the Software
+ without restriction, including without limitation the rights to use, copy, modify,
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef CWPack_H__
+#define CWPack_H__
+
+
+//#include <stdint.h>
+#include <stdbool.h>
+
+//zzq add
+#include "stdint.h"
+
+
+
+/******************************* Return Codes *****************************/
+
+#define CWP_RC_OK 0
+#define CWP_RC_END_OF_INPUT -1
+#define CWP_RC_BUFFER_OVERFLOW -2
+#define CWP_RC_BUFFER_UNDERFLOW -3
+#define CWP_RC_MALFORMED_INPUT -4
+#define CWP_RC_WRONG_BYTE_ORDER -5
+#define CWP_RC_ERROR_IN_HANDLER -6
+#define CWP_RC_ILLEGAL_CALL -7
+#define CWP_RC_MALLOC_ERROR -8
+#define CWP_RC_STOPPED -9
+
+
+
+/******************************* P A C K **********************************/
+
+
+struct cw_pack_context;
+
+typedef int (*pack_overflow_handler)(struct cw_pack_context*, unsigned long);
+
+typedef struct cw_pack_context {
+ uint8_t* start;
+ uint8_t* current;
+ uint8_t* end;
+ bool be_compatible;
+ int return_code;
+ int err_no; /* handlers can save error here */
+ pack_overflow_handler handle_pack_overflow;
+} cw_pack_context;
+
+
+int cw_pack_context_init (cw_pack_context* pack_context, void* data, unsigned long length, pack_overflow_handler hpo);
+void cw_pack_set_compatibility (cw_pack_context* pack_context, bool be_compatible);
+
+void cw_pack_nil (cw_pack_context* pack_context);
+void cw_pack_true (cw_pack_context* pack_context);
+void cw_pack_false (cw_pack_context* pack_context);
+void cw_pack_boolean (cw_pack_context* pack_context, bool b);
+
+void cw_pack_signed (cw_pack_context* pack_context, int64_t i);
+void cw_pack_unsigned (cw_pack_context* pack_context, uint64_t i);
+
+void cw_pack_float (cw_pack_context* pack_context, float f);
+void cw_pack_double (cw_pack_context* pack_context, double d);
+void cw_pack_real (cw_pack_context* pack_context, double d); /* Pack as float if precision isn't destroyed */
+
+void cw_pack_array_size (cw_pack_context* pack_context, uint32_t n);
+void cw_pack_map_size (cw_pack_context* pack_context, uint32_t n);
+void cw_pack_str (cw_pack_context* pack_context, const char* v, uint32_t l);
+void cw_pack_bin (cw_pack_context* pack_context, const void* v, uint32_t l);
+void cw_pack_ext (cw_pack_context* pack_context, int8_t type, const void* v, uint32_t l);
+
+void cw_pack_insert (cw_pack_context* pack_context, const void* v, uint32_t l);
+
+
+/***************************** U N P A C K ********************************/
+
+
+typedef enum
+{
+ CWP_ITEM_MIN_RESERVED_EXT = -128,
+ CWP_ITEM_MAX_RESERVED_EXT = -1,
+ CWP_ITEM_MIN_USER_EXT = 0,
+ CWP_ITEM_MAX_USER_EXT = 127,
+ CWP_ITEM_NIL = 300,
+ CWP_ITEM_BOOLEAN = 301,
+ CWP_ITEM_POSITIVE_INTEGER = 302,
+ CWP_ITEM_NEGATIVE_INTEGER = 303,
+ CWP_ITEM_FLOAT = 304,
+ CWP_ITEM_DOUBLE = 305,
+ CWP_ITEM_STR = 306,
+ CWP_ITEM_BIN = 307,
+ CWP_ITEM_ARRAY = 308,
+ CWP_ITEM_MAP = 309,
+ CWP_ITEM_EXT = 310,
+ CWP_NOT_AN_ITEM = 999,
+} cwpack_item_types;
+
+
+typedef struct {
+ const void* start;
+ uint32_t length;
+} cwpack_blob;
+
+
+typedef struct {
+ uint32_t size;
+} cwpack_container;
+
+
+typedef struct {
+ cwpack_item_types type;
+ union
+ {
+ bool boolean;
+ uint64_t u64;
+ int64_t i64;
+ float real;
+ double long_real;
+ cwpack_container array;
+ cwpack_container map;
+ cwpack_blob str;
+ cwpack_blob bin;
+ cwpack_blob ext;
+ } as;
+} cwpack_item;
+
+struct cw_unpack_context;
+
+typedef int (*unpack_underflow_handler)(struct cw_unpack_context*, unsigned long);
+
+typedef struct cw_unpack_context {
+ cwpack_item item;
+ uint8_t* start;
+ uint8_t* current;
+ uint8_t* end; /* logical end of buffer */
+ int return_code;
+ int err_no; /* handlers can save error here */
+ unpack_underflow_handler handle_unpack_underflow;
+} cw_unpack_context;
+
+
+
+int cw_unpack_context_init (cw_unpack_context* unpack_context, void* data, unsigned long length, unpack_underflow_handler huu);
+
+void cw_unpack_next (cw_unpack_context* unpack_context);
+void cw_skip_items (cw_unpack_context* unpack_context, long item_count);
+
+
+#endif /* CWPack_H__ */
diff --git a/msgpack/cwpack_defines.h b/msgpack/cwpack_defines.h
new file mode 100644
index 0000000..b2f29f6
--- /dev/null
+++ b/msgpack/cwpack_defines.h
@@ -0,0 +1,365 @@
+/* CWPack - cwpack_defines.h */
+/*
+ The MIT License (MIT)
+
+ Copyright (c) 2017 Claes Wihlborg
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ software and associated documentation files (the "Software"), to deal in the Software
+ without restriction, including without limitation the rights to use, copy, modify,
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef cwpack_defines_h
+#define cwpack_defines_h
+
+
+
+/************************* A L I G N M E N T ******************************/
+
+/*
+ * Sometime the processor demands that integer access is to an even memory address.
+ * In that case define FORCE_ALIGNMENT
+ */
+
+/* #define FORCE_ALIGNMENT */
+
+
+/************************* C S Y S T E M L I B R A R Y ****************/
+
+/*
+ * The packer uses "memcpy" to move blobs. If you dont want to load C system library
+ * for just that, define FORCE_NO_LIBRARY and CWPack will use an internal "memcpy"
+ */
+
+/* #define FORCE_NO_LIBRARY */
+
+
+
+/************************* B Y T E O R D E R ****************************/
+
+/*
+ * The pack/unpack routines are written in three versions: for big endian, for
+ * little endian and insensitive to byte order. As you can get some speed gain
+ * if the byte order is known, we try that when we can certainly detect it.
+ * Define COMPILE_FOR_BIG_ENDIAN or COMPILE_FOR_LITTLE_ENDIAN if you know.
+ */
+
+#ifndef FORCE_ALIGNMENT
+#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__)
+
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#define COMPILE_FOR_BIG_ENDIAN
+#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define COMPILE_FOR_LITTLE_ENDIAN
+#endif
+
+#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define COMPILE_FOR_BIG_ENDIAN
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define COMPILE_FOR_LITTLE_ENDIAN
+#endif
+
+#elif defined(__BIG_ENDIAN__)
+#define COMPILE_FOR_BIG_ENDIAN
+
+#elif defined(__LITTLE_ENDIAN__)
+#define COMPILE_FOR_LITTLE_ENDIAN
+
+#elif defined(__i386__) || defined(__x86_64__)
+#define COMPILE_FOR_LITTLE_ENDIAN
+
+#endif
+#endif
+
+//zzq add
+#include "stdint.h"
+
+//#undef COMPILE_FOR_LITTLE_ENDIAN
+
+
+/******************************* P A C K **********************************/
+
+
+
+#define PACK_ERROR(error_code) \
+{ \
+ pack_context->return_code = error_code; \
+ return; \
+}
+
+
+
+#ifdef COMPILE_FOR_BIG_ENDIAN
+
+#define cw_store16(x) *(uint16_t*)p = *(uint16_t*)&x;
+#define cw_store32(x) *(uint32_t*)p = *(uint32_t*)&x;
+#define cw_store64(x) *(uint64_t*)p = *(uint64_t*)&x;
+
+#else /* Byte order little endian or undetermined */
+
+#ifdef COMPILE_FOR_LITTLE_ENDIAN
+
+#define cw_store16(d) \
+ *(uint16_t*)p = (uint16_t)((((d) >> 8) & 0x0ff) | (d) << 8)
+
+#define cw_store32(x) \
+ *(uint32_t*)p = \
+ ((uint32_t)((((uint32_t)(x)) >> 24) | \
+ (((uint32_t)(x) & 0x00ff0000) >> 8) | \
+ (((uint32_t)(x) & 0x0000ff00) << 8) | \
+ (((uint32_t)(x)) << 24))); \
+
+#define cw_store64(x) \
+ *(uint64_t*)p = \
+ ((uint64_t)( \
+ (((((uint64_t)(x)) >> 40) | \
+ (((uint64_t)(x)) << 24)) & 0x0000ff000000ff00ULL) | \
+ (((((uint64_t)(x)) >> 24) | \
+ (((uint64_t)(x)) << 40)) & 0x00ff000000ff0000ULL) | \
+ (((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
+ (((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \
+ (((uint64_t)(x)) >> 56) | \
+ (((uint64_t)(x)) << 56))); \
+
+#else /* Byte order undetermined */
+
+#define cw_store16(d) \
+ *p = (uint8_t)(d >> 8); \
+ p[1] = (uint8_t)d;
+
+#define cw_store32(d) \
+ *p = (uint8_t)(d >> 24); \
+ p[1] = (uint8_t)(d >> 16); \
+ p[2] = (uint8_t)(d >> 8); \
+ p[3] = (uint8_t)d;
+
+#define cw_store64(z) \
+ *p = (uint8_t)(z >> 56); \
+ p[1] = (uint8_t)(z >> 48); \
+ p[2] = (uint8_t)(z >> 40); \
+ p[3] = (uint8_t)(z >> 32); \
+ p[4] = (uint8_t)(z >> 24); \
+ p[5] = (uint8_t)(z >> 16); \
+ p[6] = (uint8_t)(z >> 8); \
+ p[7] = (uint8_t)z;
+#endif
+#endif
+
+
+
+#define cw_pack_reserve_space(more) \
+{ \
+ p = pack_context->current; \
+ uint8_t* nyp = p + more; \
+ if (nyp > pack_context->end) \
+ { \
+ if (!pack_context->handle_pack_overflow) \
+ PACK_ERROR(CWP_RC_BUFFER_OVERFLOW) \
+ int rc = pack_context->handle_pack_overflow (pack_context, (unsigned long)(more)); \
+ if (rc) \
+ PACK_ERROR(rc) \
+ p = pack_context->current; \
+ nyp = p + more; \
+ } \
+ pack_context->current = nyp; \
+}
+
+
+#define tryMove0(t) \
+{ \
+ uint8_t *p; \
+ cw_pack_reserve_space(1) \
+ *p = (uint8_t)(t); \
+ return; \
+}
+
+#define tryMove1(t,d) \
+{ \
+ uint8_t *p; \
+ cw_pack_reserve_space(2) \
+ *p++ = (uint8_t)t; \
+ *p = (uint8_t)d; \
+ return; \
+}
+
+#define tryMove2(t,d) \
+{ \
+ uint8_t *p; \
+ cw_pack_reserve_space(3) \
+ *p++ = (uint8_t)t; \
+ cw_store16(d); \
+ return; \
+}
+
+#define tryMove4(t,d) \
+{ \
+ uint8_t *p; \
+ cw_pack_reserve_space(5) \
+ *p++ = (uint8_t)t; \
+ cw_store32(d); \
+ return; \
+}
+
+#define tryMove8(t,d) \
+{ \
+ uint8_t *p; \
+ cw_pack_reserve_space(9) \
+ *p++ = (uint8_t)t; \
+ cw_store64(d); \
+ return; \
+}
+
+
+
+
+/******************************* U N P A C K **********************************/
+
+
+
+#define UNPACK_ERROR(error_code) \
+{ \
+ unpack_context->item.type = CWP_NOT_AN_ITEM; \
+ unpack_context->return_code = error_code; \
+ return; \
+}
+
+
+
+#ifdef COMPILE_FOR_BIG_ENDIAN
+
+#define cw_load16(ptr) tmpu16 = *(uint16_t*)ptr;
+#define cw_load32(ptr) tmpu32 = *(uint32_t*)ptr;
+#define cw_load64(ptr) tmpu64 = *(uint64_t*)ptr;
+
+#else /* Byte order little endian or undetermined */
+
+#ifdef COMPILE_FOR_LITTLE_ENDIAN
+
+#define cw_load16(ptr) \
+ tmpu16 = *(uint16_t*)ptr; \
+ tmpu16 = (uint16_t)((tmpu16<<8) | (tmpu16>>8))
+
+#define cw_load32(ptr) \
+ tmpu32 = *(uint32_t*)ptr; \
+ tmpu32 = (tmpu32<<24) | ((tmpu32 & 0xff00)<<8) | \
+ ((tmpu32 & 0xff0000)>>8) | (tmpu32>>24)
+
+#define cw_load64(ptr) \
+ tmpu64 = *((uint64_t*)ptr); \
+ tmpu64 = ( \
+ (((tmpu64 >> 40) | \
+ (tmpu64 << 24)) & 0x0000ff000000ff00ULL) | \
+ (((tmpu64 >> 24) | \
+ (tmpu64 << 40)) & 0x00ff000000ff0000ULL) | \
+ ((tmpu64 & 0x000000ff00000000ULL) >> 8) | \
+ ((tmpu64 & 0x00000000ff000000ULL) << 8) | \
+ (tmpu64 >> 56) | \
+ (tmpu64 << 56) )
+
+#else /* Byte order undetermined */
+
+#define cw_load16(ptr) \
+ tmpu16 = (uint16_t)((*ptr++) << 8); \
+ tmpu16 |= (uint16_t)(*ptr++)
+
+#define cw_load32(ptr) \
+ tmpu32 = (uint32_t)(*ptr++ << 24); \
+ tmpu32 |= (uint32_t)(*ptr++ << 16); \
+ tmpu32 |= (uint32_t)(*ptr++ << 8); \
+ tmpu32 |= (uint32_t)(*ptr++)
+
+#define cw_load64(ptr) \
+ tmpu64 = ((uint64_t)*ptr++) << 56; \
+ tmpu64 |= ((uint64_t)*ptr++) << 48; \
+ tmpu64 |= ((uint64_t)*ptr++) << 40; \
+ tmpu64 |= ((uint64_t)*ptr++) << 32; \
+ tmpu64 |= ((uint64_t)*ptr++) << 24; \
+ tmpu64 |= ((uint64_t)*ptr++) << 16; \
+ tmpu64 |= ((uint64_t)*ptr++) << 8; \
+ tmpu64 |= (uint64_t)*ptr++
+
+#endif
+#endif
+
+
+
+#define cw_unpack_assert_space(more) \
+{ \
+ p = unpack_context->current; \
+ uint8_t* nyp = p + more; \
+ if (nyp > unpack_context->end) \
+ { \
+ if (!unpack_context->handle_unpack_underflow) \
+ UNPACK_ERROR(buffer_end_return_code) \
+ int rc = unpack_context->handle_unpack_underflow (unpack_context, (unsigned long)(more)); \
+ if (rc != CWP_RC_OK) \
+ { \
+ if (rc != CWP_RC_END_OF_INPUT) \
+ UNPACK_ERROR(rc) \
+ else \
+ UNPACK_ERROR(buffer_end_return_code) \
+ } \
+ p = unpack_context->current; \
+ nyp = p + more; \
+ } \
+ unpack_context->current = nyp; \
+}
+
+
+#define cw_unpack_assert_blob(blob) \
+ cw_unpack_assert_space(unpack_context->item.as.blob.length); \
+ unpack_context->item.as.blob.start = p; \
+ return;
+
+
+#define getDDItem(typ,var,val) \
+ unpack_context->item.type = typ; \
+ unpack_context->item.as.var = val;
+
+#define getDDItem1(typ,var,cast) \
+ unpack_context->item.type = typ; \
+ cw_unpack_assert_space(1); \
+ unpack_context->item.as.var = (cast)*p;
+
+#define getDDItem2(typ,var,cast) \
+ unpack_context->item.type = typ; \
+ cw_unpack_assert_space(2); \
+ cw_load16(p); \
+ unpack_context->item.as.var = (cast)tmpu16;
+
+#define getDDItem4(typ,var,cast) \
+ unpack_context->item.type = typ; \
+ cw_unpack_assert_space(4); \
+ cw_load32(p); \
+ unpack_context->item.as.var = (cast)tmpu32;
+
+#define getDDItem8(typ) \
+ unpack_context->item.type = typ; \
+ cw_unpack_assert_space(8); \
+ cw_load64(p); \
+ unpack_context->item.as.u64 = tmpu64;
+
+#define getDDItemFix(len) \
+ cw_unpack_assert_space(1); \
+ unpack_context->item.type = *(int8_t*)p; \
+ unpack_context->item.as.ext.length = len; \
+ cw_unpack_assert_blob(ext);
+
+
+
+
+#endif /* cwpack_defines_h */
diff --git a/nec_apdu.h b/nec_apdu.h
new file mode 100644
index 0000000..c1bf60a
--- /dev/null
+++ b/nec_apdu.h
@@ -0,0 +1,21 @@
+#ifndef _NEC_APDU_H_
+#define _NEC_APDU_H_
+
+#include "config.h"
+
+int8 psam_poweron(uint8 cid);
+void psam_powreoff(uint8 cid);
+int8 card_request(uint8* sak,uint8 snr[8]);
+int8 card_m1_mode(uint8 cardphyid[8]);
+int8 card_cpu_mode(void);
+int8 card_cpu_exist(void);
+int8 card_rf_reset(void);
+void card_radio_on(void);
+void card_radio_off(void);
+uint16 card_m1_auth(uint8* cardphyid,uint8 blockno, uint8 key[6]);
+uint16 card_m1_read(uint8 blockno,uint8 readbuf[16]);
+uint16 card_m1_write(uint8 blockno,uint8 writebuf[16]);
+uint16 card_cpu_exchange(uint8* cmd_buf,uint8 cmd_len,uint8 ExpectedResponseLength,
+ uint8** rec_buf,uint8* rec_buf_len);
+
+#endif
diff --git a/nec_hardware.h b/nec_hardware.h
new file mode 100644
index 0000000..a9a1e7c
--- /dev/null
+++ b/nec_hardware.h
@@ -0,0 +1,21 @@
+#ifndef _NEC_HARDWARE_H_
+#define _NEC_HARDWARE_H_
+
+#include "config.h"
+//#include "./g401301/src/G401_drv_hw_V01.h"
+//#include "./g401301/src/stm32f10x_it.h"
+//#define DEVICE_TYPE 'd';
+
+
+/*LED ÏÔʾ»º³åÇø*/
+//extern uint8 LEDSEG[7]; //ÏÔʾ»º³åÇø
+
+uint16 sp_init(void);
+void sp_feed_dog(void);
+void sp_valve_control(void);
+void sp_flowsensor_control(void);
+uint32 sp_flowsensor_get_count(void);
+void sp_flowsensor_count_clear(void);
+uint8 sp_flowsensor_check_valid(void);
+
+#endif
diff --git a/st_fw_lib/inc/core_cm3.h b/st_fw_lib/inc/core_cm3.h
new file mode 100644
index 0000000..7ab7b4b
--- /dev/null
+++ b/st_fw_lib/inc/core_cm3.h
@@ -0,0 +1,1818 @@
+/**************************************************************************//**
+ * @file core_cm3.h
+ * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File
+ * @version V1.30
+ * @date 30. October 2009
+ *
+ * @note
+ * Copyright (C) 2009 ARM Limited. All rights reserved.
+ *
+ * @par
+ * ARM Limited (ARM) is supplying this software for use with Cortex-M
+ * processor based microcontrollers. This file can be freely distributed
+ * within development tools that are supporting such ARM based processors.
+ *
+ * @par
+ * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
+ * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
+ * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
+ * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+ *
+ ******************************************************************************/
+
+#ifndef __CM3_CORE_H__
+#define __CM3_CORE_H__
+
+/** @addtogroup CMSIS_CM3_core_LintCinfiguration CMSIS CM3 Core Lint Configuration
+ *
+ * List of Lint messages which will be suppressed and not shown:
+ * - Error 10: \n
+ * register uint32_t __regBasePri __asm("basepri"); \n
+ * Error 10: Expecting ';'
+ * .
+ * - Error 530: \n
+ * return(__regBasePri); \n
+ * Warning 530: Symbol '__regBasePri' (line 264) not initialized
+ * .
+ * - Error 550: \n
+ * __regBasePri = (basePri & 0x1ff); \n
+ * Warning 550: Symbol '__regBasePri' (line 271) not accessed
+ * .
+ * - Error 754: \n
+ * uint32_t RESERVED0[24]; \n
+ * Info 754: local structure member '<some, not used in the HAL>' (line 109, file ./cm3_core.h) not referenced
+ * .
+ * - Error 750: \n
+ * #define __CM3_CORE_H__ \n
+ * Info 750: local macro '__CM3_CORE_H__' (line 43, file./cm3_core.h) not referenced
+ * .
+ * - Error 528: \n
+ * static __INLINE void NVIC_DisableIRQ(uint32_t IRQn) \n
+ * Warning 528: Symbol 'NVIC_DisableIRQ(unsigned int)' (line 419, file ./cm3_core.h) not referenced
+ * .
+ * - Error 751: \n
+ * } InterruptType_Type; \n
+ * Info 751: local typedef 'InterruptType_Type' (line 170, file ./cm3_core.h) not referenced
+ * .
+ * Note: To re-enable a Message, insert a space before 'lint' *
+ *
+ */
+
+/*lint -save */
+/*lint -e10 */
+/*lint -e530 */
+/*lint -e550 */
+/*lint -e754 */
+/*lint -e750 */
+/*lint -e528 */
+/*lint -e751 */
+
+
+/** @addtogroup CMSIS_CM3_core_definitions CM3 Core Definitions
+ This file defines all structures and symbols for CMSIS core:
+ - CMSIS version number
+ - Cortex-M core registers and bitfields
+ - Cortex-M core peripheral base address
+ @{
+ */
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define __CM3_CMSIS_VERSION_MAIN (0x01) /*!< [31:16] CMSIS HAL main version */
+#define __CM3_CMSIS_VERSION_SUB (0x30) /*!< [15:0] CMSIS HAL sub version */
+#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number */
+
+#define __CORTEX_M (0x03) /*!< Cortex core */
+
+#include <stdint.h> /* Include standard types */
+
+#if defined (__ICCARM__)
+ #include <intrinsics.h> /* IAR Intrinsics */
+#endif
+
+
+#ifndef __NVIC_PRIO_BITS
+ #define __NVIC_PRIO_BITS 4 /*!< standard definition for NVIC Priority Bits */
+#endif
+
+
+
+
+/**
+ * IO definitions
+ *
+ * define access restrictions to peripheral registers
+ */
+
+#ifdef __cplusplus
+ #define __I volatile /*!< defines 'read only' permissions */
+#else
+ #define __I volatile const /*!< defines 'read only' permissions */
+#endif
+#define __O volatile /*!< defines 'write only' permissions */
+#define __IO volatile /*!< defines 'read / write' permissions */
+
+
+
+/*******************************************************************************
+ * Register Abstraction
+ ******************************************************************************/
+/** @addtogroup CMSIS_CM3_core_register CMSIS CM3 Core Register
+ @{
+*/
+
+
+/** @addtogroup CMSIS_CM3_NVIC CMSIS CM3 NVIC
+ memory mapped structure for Nested Vectored Interrupt Controller (NVIC)
+ @{
+ */
+typedef struct
+{
+ __IO uint32_t ISER[8]; /*!< Offset: 0x000 Interrupt Set Enable Register */
+ uint32_t RESERVED0[24];
+ __IO uint32_t ICER[8]; /*!< Offset: 0x080 Interrupt Clear Enable Register */
+ uint32_t RSERVED1[24];
+ __IO uint32_t ISPR[8]; /*!< Offset: 0x100 Interrupt Set Pending Register */
+ uint32_t RESERVED2[24];
+ __IO uint32_t ICPR[8]; /*!< Offset: 0x180 Interrupt Clear Pending Register */
+ uint32_t RESERVED3[24];
+ __IO uint32_t IABR[8]; /*!< Offset: 0x200 Interrupt Active bit Register */
+ uint32_t RESERVED4[56];
+ __IO uint8_t IP[240]; /*!< Offset: 0x300 Interrupt Priority Register (8Bit wide) */
+ uint32_t RESERVED5[644];
+ __O uint32_t STIR; /*!< Offset: 0xE00 Software Trigger Interrupt Register */
+} NVIC_Type;
+/*@}*/ /* end of group CMSIS_CM3_NVIC */
+
+
+/** @addtogroup CMSIS_CM3_SCB CMSIS CM3 SCB
+ memory mapped structure for System Control Block (SCB)
+ @{
+ */
+typedef struct
+{
+ __I uint32_t CPUID; /*!< Offset: 0x00 CPU ID Base Register */
+ __IO uint32_t ICSR; /*!< Offset: 0x04 Interrupt Control State Register */
+ __IO uint32_t VTOR; /*!< Offset: 0x08 Vector Table Offset Register */
+ __IO uint32_t AIRCR; /*!< Offset: 0x0C Application Interrupt / Reset Control Register */
+ __IO uint32_t SCR; /*!< Offset: 0x10 System Control Register */
+ __IO uint32_t CCR; /*!< Offset: 0x14 Configuration Control Register */
+ __IO uint8_t SHP[12]; /*!< Offset: 0x18 System Handlers Priority Registers (4-7, 8-11, 12-15) */
+ __IO uint32_t SHCSR; /*!< Offset: 0x24 System Handler Control and State Register */
+ __IO uint32_t CFSR; /*!< Offset: 0x28 Configurable Fault Status Register */
+ __IO uint32_t HFSR; /*!< Offset: 0x2C Hard Fault Status Register */
+ __IO uint32_t DFSR; /*!< Offset: 0x30 Debug Fault Status Register */
+ __IO uint32_t MMFAR; /*!< Offset: 0x34 Mem Manage Address Register */
+ __IO uint32_t BFAR; /*!< Offset: 0x38 Bus Fault Address Register */
+ __IO uint32_t AFSR; /*!< Offset: 0x3C Auxiliary Fault Status Register */
+ __I uint32_t PFR[2]; /*!< Offset: 0x40 Processor Feature Register */
+ __I uint32_t DFR; /*!< Offset: 0x48 Debug Feature Register */
+ __I uint32_t ADR; /*!< Offset: 0x4C Auxiliary Feature Register */
+ __I uint32_t MMFR[4]; /*!< Offset: 0x50 Memory Model Feature Register */
+ __I uint32_t ISAR[5]; /*!< Offset: 0x60 ISA Feature Register */
+} SCB_Type;
+
+/* SCB CPUID Register Definitions */
+#define SCB_CPUID_IMPLEMENTER_Pos 24 /*!< SCB CPUID: IMPLEMENTER Position */
+#define SCB_CPUID_IMPLEMENTER_Msk (0xFFul << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
+
+#define SCB_CPUID_VARIANT_Pos 20 /*!< SCB CPUID: VARIANT Position */
+#define SCB_CPUID_VARIANT_Msk (0xFul << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
+
+#define SCB_CPUID_PARTNO_Pos 4 /*!< SCB CPUID: PARTNO Position */
+#define SCB_CPUID_PARTNO_Msk (0xFFFul << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
+
+#define SCB_CPUID_REVISION_Pos 0 /*!< SCB CPUID: REVISION Position */
+#define SCB_CPUID_REVISION_Msk (0xFul << SCB_CPUID_REVISION_Pos) /*!< SCB CPUID: REVISION Mask */
+
+/* SCB Interrupt Control State Register Definitions */
+#define SCB_ICSR_NMIPENDSET_Pos 31 /*!< SCB ICSR: NMIPENDSET Position */
+#define SCB_ICSR_NMIPENDSET_Msk (1ul << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
+
+#define SCB_ICSR_PENDSVSET_Pos 28 /*!< SCB ICSR: PENDSVSET Position */
+#define SCB_ICSR_PENDSVSET_Msk (1ul << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
+
+#define SCB_ICSR_PENDSVCLR_Pos 27 /*!< SCB ICSR: PENDSVCLR Position */
+#define SCB_ICSR_PENDSVCLR_Msk (1ul << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
+
+#define SCB_ICSR_PENDSTSET_Pos 26 /*!< SCB ICSR: PENDSTSET Position */
+#define SCB_ICSR_PENDSTSET_Msk (1ul << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
+
+#define SCB_ICSR_PENDSTCLR_Pos 25 /*!< SCB ICSR: PENDSTCLR Position */
+#define SCB_ICSR_PENDSTCLR_Msk (1ul << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
+
+#define SCB_ICSR_ISRPREEMPT_Pos 23 /*!< SCB ICSR: ISRPREEMPT Position */
+#define SCB_ICSR_ISRPREEMPT_Msk (1ul << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
+
+#define SCB_ICSR_ISRPENDING_Pos 22 /*!< SCB ICSR: ISRPENDING Position */
+#define SCB_ICSR_ISRPENDING_Msk (1ul << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
+
+#define SCB_ICSR_VECTPENDING_Pos 12 /*!< SCB ICSR: VECTPENDING Position */
+#define SCB_ICSR_VECTPENDING_Msk (0x1FFul << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
+
+#define SCB_ICSR_RETTOBASE_Pos 11 /*!< SCB ICSR: RETTOBASE Position */
+#define SCB_ICSR_RETTOBASE_Msk (1ul << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */
+
+#define SCB_ICSR_VECTACTIVE_Pos 0 /*!< SCB ICSR: VECTACTIVE Position */
+#define SCB_ICSR_VECTACTIVE_Msk (0x1FFul << SCB_ICSR_VECTACTIVE_Pos) /*!< SCB ICSR: VECTACTIVE Mask */
+
+/* SCB Interrupt Control State Register Definitions */
+#define SCB_VTOR_TBLBASE_Pos 29 /*!< SCB VTOR: TBLBASE Position */
+#define SCB_VTOR_TBLBASE_Msk (0x1FFul << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */
+
+#define SCB_VTOR_TBLOFF_Pos 7 /*!< SCB VTOR: TBLOFF Position */
+#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFul << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
+
+/* SCB Application Interrupt and Reset Control Register Definitions */
+#define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */
+#define SCB_AIRCR_VECTKEY_Msk (0xFFFFul << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
+
+#define SCB_AIRCR_VECTKEYSTAT_Pos 16 /*!< SCB AIRCR: VECTKEYSTAT Position */
+#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFul << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
+
+#define SCB_AIRCR_ENDIANESS_Pos 15 /*!< SCB AIRCR: ENDIANESS Position */
+#define SCB_AIRCR_ENDIANESS_Msk (1ul << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
+
+#define SCB_AIRCR_PRIGROUP_Pos 8 /*!< SCB AIRCR: PRIGROUP Position */
+#define SCB_AIRCR_PRIGROUP_Msk (7ul << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */
+
+#define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */
+#define SCB_AIRCR_SYSRESETREQ_Msk (1ul << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
+
+#define SCB_AIRCR_VECTCLRACTIVE_Pos 1 /*!< SCB AIRCR: VECTCLRACTIVE Position */
+#define SCB_AIRCR_VECTCLRACTIVE_Msk (1ul << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
+
+#define SCB_AIRCR_VECTRESET_Pos 0 /*!< SCB AIRCR: VECTRESET Position */
+#define SCB_AIRCR_VECTRESET_Msk (1ul << SCB_AIRCR_VECTRESET_Pos) /*!< SCB AIRCR: VECTRESET Mask */
+
+/* SCB System Control Register Definitions */
+#define SCB_SCR_SEVONPEND_Pos 4 /*!< SCB SCR: SEVONPEND Position */
+#define SCB_SCR_SEVONPEND_Msk (1ul << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
+
+#define SCB_SCR_SLEEPDEEP_Pos 2 /*!< SCB SCR: SLEEPDEEP Position */
+#define SCB_SCR_SLEEPDEEP_Msk (1ul << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
+
+#define SCB_SCR_SLEEPONEXIT_Pos 1 /*!< SCB SCR: SLEEPONEXIT Position */
+#define SCB_SCR_SLEEPONEXIT_Msk (1ul << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
+
+/* SCB Configuration Control Register Definitions */
+#define SCB_CCR_STKALIGN_Pos 9 /*!< SCB CCR: STKALIGN Position */
+#define SCB_CCR_STKALIGN_Msk (1ul << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
+
+#define SCB_CCR_BFHFNMIGN_Pos 8 /*!< SCB CCR: BFHFNMIGN Position */
+#define SCB_CCR_BFHFNMIGN_Msk (1ul << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */
+
+#define SCB_CCR_DIV_0_TRP_Pos 4 /*!< SCB CCR: DIV_0_TRP Position */
+#define SCB_CCR_DIV_0_TRP_Msk (1ul << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */
+
+#define SCB_CCR_UNALIGN_TRP_Pos 3 /*!< SCB CCR: UNALIGN_TRP Position */
+#define SCB_CCR_UNALIGN_TRP_Msk (1ul << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
+
+#define SCB_CCR_USERSETMPEND_Pos 1 /*!< SCB CCR: USERSETMPEND Position */
+#define SCB_CCR_USERSETMPEND_Msk (1ul << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */
+
+#define SCB_CCR_NONBASETHRDENA_Pos 0 /*!< SCB CCR: NONBASETHRDENA Position */
+#define SCB_CCR_NONBASETHRDENA_Msk (1ul << SCB_CCR_NONBASETHRDENA_Pos) /*!< SCB CCR: NONBASETHRDENA Mask */
+
+/* SCB System Handler Control and State Register Definitions */
+#define SCB_SHCSR_USGFAULTENA_Pos 18 /*!< SCB SHCSR: USGFAULTENA Position */
+#define SCB_SHCSR_USGFAULTENA_Msk (1ul << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */
+
+#define SCB_SHCSR_BUSFAULTENA_Pos 17 /*!< SCB SHCSR: BUSFAULTENA Position */
+#define SCB_SHCSR_BUSFAULTENA_Msk (1ul << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */
+
+#define SCB_SHCSR_MEMFAULTENA_Pos 16 /*!< SCB SHCSR: MEMFAULTENA Position */
+#define SCB_SHCSR_MEMFAULTENA_Msk (1ul << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */
+
+#define SCB_SHCSR_SVCALLPENDED_Pos 15 /*!< SCB SHCSR: SVCALLPENDED Position */
+#define SCB_SHCSR_SVCALLPENDED_Msk (1ul << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
+
+#define SCB_SHCSR_BUSFAULTPENDED_Pos 14 /*!< SCB SHCSR: BUSFAULTPENDED Position */
+#define SCB_SHCSR_BUSFAULTPENDED_Msk (1ul << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */
+
+#define SCB_SHCSR_MEMFAULTPENDED_Pos 13 /*!< SCB SHCSR: MEMFAULTPENDED Position */
+#define SCB_SHCSR_MEMFAULTPENDED_Msk (1ul << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */
+
+#define SCB_SHCSR_USGFAULTPENDED_Pos 12 /*!< SCB SHCSR: USGFAULTPENDED Position */
+#define SCB_SHCSR_USGFAULTPENDED_Msk (1ul << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */
+
+#define SCB_SHCSR_SYSTICKACT_Pos 11 /*!< SCB SHCSR: SYSTICKACT Position */
+#define SCB_SHCSR_SYSTICKACT_Msk (1ul << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */
+
+#define SCB_SHCSR_PENDSVACT_Pos 10 /*!< SCB SHCSR: PENDSVACT Position */
+#define SCB_SHCSR_PENDSVACT_Msk (1ul << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */
+
+#define SCB_SHCSR_MONITORACT_Pos 8 /*!< SCB SHCSR: MONITORACT Position */
+#define SCB_SHCSR_MONITORACT_Msk (1ul << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */
+
+#define SCB_SHCSR_SVCALLACT_Pos 7 /*!< SCB SHCSR: SVCALLACT Position */
+#define SCB_SHCSR_SVCALLACT_Msk (1ul << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */
+
+#define SCB_SHCSR_USGFAULTACT_Pos 3 /*!< SCB SHCSR: USGFAULTACT Position */
+#define SCB_SHCSR_USGFAULTACT_Msk (1ul << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */
+
+#define SCB_SHCSR_BUSFAULTACT_Pos 1 /*!< SCB SHCSR: BUSFAULTACT Position */
+#define SCB_SHCSR_BUSFAULTACT_Msk (1ul << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */
+
+#define SCB_SHCSR_MEMFAULTACT_Pos 0 /*!< SCB SHCSR: MEMFAULTACT Position */
+#define SCB_SHCSR_MEMFAULTACT_Msk (1ul << SCB_SHCSR_MEMFAULTACT_Pos) /*!< SCB SHCSR: MEMFAULTACT Mask */
+
+/* SCB Configurable Fault Status Registers Definitions */
+#define SCB_CFSR_USGFAULTSR_Pos 16 /*!< SCB CFSR: Usage Fault Status Register Position */
+#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFul << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */
+
+#define SCB_CFSR_BUSFAULTSR_Pos 8 /*!< SCB CFSR: Bus Fault Status Register Position */
+#define SCB_CFSR_BUSFAULTSR_Msk (0xFFul << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */
+
+#define SCB_CFSR_MEMFAULTSR_Pos 0 /*!< SCB CFSR: Memory Manage Fault Status Register Position */
+#define SCB_CFSR_MEMFAULTSR_Msk (0xFFul << SCB_CFSR_MEMFAULTSR_Pos) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */
+
+/* SCB Hard Fault Status Registers Definitions */
+#define SCB_HFSR_DEBUGEVT_Pos 31 /*!< SCB HFSR: DEBUGEVT Position */
+#define SCB_HFSR_DEBUGEVT_Msk (1ul << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */
+
+#define SCB_HFSR_FORCED_Pos 30 /*!< SCB HFSR: FORCED Position */
+#define SCB_HFSR_FORCED_Msk (1ul << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */
+
+#define SCB_HFSR_VECTTBL_Pos 1 /*!< SCB HFSR: VECTTBL Position */
+#define SCB_HFSR_VECTTBL_Msk (1ul << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */
+
+/* SCB Debug Fault Status Register Definitions */
+#define SCB_DFSR_EXTERNAL_Pos 4 /*!< SCB DFSR: EXTERNAL Position */
+#define SCB_DFSR_EXTERNAL_Msk (1ul << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */
+
+#define SCB_DFSR_VCATCH_Pos 3 /*!< SCB DFSR: VCATCH Position */
+#define SCB_DFSR_VCATCH_Msk (1ul << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */
+
+#define SCB_DFSR_DWTTRAP_Pos 2 /*!< SCB DFSR: DWTTRAP Position */
+#define SCB_DFSR_DWTTRAP_Msk (1ul << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */
+
+#define SCB_DFSR_BKPT_Pos 1 /*!< SCB DFSR: BKPT Position */
+#define SCB_DFSR_BKPT_Msk (1ul << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */
+
+#define SCB_DFSR_HALTED_Pos 0 /*!< SCB DFSR: HALTED Position */
+#define SCB_DFSR_HALTED_Msk (1ul << SCB_DFSR_HALTED_Pos) /*!< SCB DFSR: HALTED Mask */
+/*@}*/ /* end of group CMSIS_CM3_SCB */
+
+
+/** @addtogroup CMSIS_CM3_SysTick CMSIS CM3 SysTick
+ memory mapped structure for SysTick
+ @{
+ */
+typedef struct
+{
+ __IO uint32_t CTRL; /*!< Offset: 0x00 SysTick Control and Status Register */
+ __IO uint32_t LOAD; /*!< Offset: 0x04 SysTick Reload Value Register */
+ __IO uint32_t VAL; /*!< Offset: 0x08 SysTick Current Value Register */
+ __I uint32_t CALIB; /*!< Offset: 0x0C SysTick Calibration Register */
+} SysTick_Type;
+
+/* SysTick Control / Status Register Definitions */
+#define SysTick_CTRL_COUNTFLAG_Pos 16 /*!< SysTick CTRL: COUNTFLAG Position */
+#define SysTick_CTRL_COUNTFLAG_Msk (1ul << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
+
+#define SysTick_CTRL_CLKSOURCE_Pos 2 /*!< SysTick CTRL: CLKSOURCE Position */
+#define SysTick_CTRL_CLKSOURCE_Msk (1ul << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
+
+#define SysTick_CTRL_TICKINT_Pos 1 /*!< SysTick CTRL: TICKINT Position */
+#define SysTick_CTRL_TICKINT_Msk (1ul << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
+
+#define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */
+#define SysTick_CTRL_ENABLE_Msk (1ul << SysTick_CTRL_ENABLE_Pos) /*!< SysTick CTRL: ENABLE Mask */
+
+/* SysTick Reload Register Definitions */
+#define SysTick_LOAD_RELOAD_Pos 0 /*!< SysTick LOAD: RELOAD Position */
+#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFul << SysTick_LOAD_RELOAD_Pos) /*!< SysTick LOAD: RELOAD Mask */
+
+/* SysTick Current Register Definitions */
+#define SysTick_VAL_CURRENT_Pos 0 /*!< SysTick VAL: CURRENT Position */
+#define SysTick_VAL_CURRENT_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos) /*!< SysTick VAL: CURRENT Mask */
+
+/* SysTick Calibration Register Definitions */
+#define SysTick_CALIB_NOREF_Pos 31 /*!< SysTick CALIB: NOREF Position */
+#define SysTick_CALIB_NOREF_Msk (1ul << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
+
+#define SysTick_CALIB_SKEW_Pos 30 /*!< SysTick CALIB: SKEW Position */
+#define SysTick_CALIB_SKEW_Msk (1ul << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
+
+#define SysTick_CALIB_TENMS_Pos 0 /*!< SysTick CALIB: TENMS Position */
+#define SysTick_CALIB_TENMS_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos) /*!< SysTick CALIB: TENMS Mask */
+/*@}*/ /* end of group CMSIS_CM3_SysTick */
+
+
+/** @addtogroup CMSIS_CM3_ITM CMSIS CM3 ITM
+ memory mapped structure for Instrumentation Trace Macrocell (ITM)
+ @{
+ */
+typedef struct
+{
+ __O union
+ {
+ __O uint8_t u8; /*!< Offset: ITM Stimulus Port 8-bit */
+ __O uint16_t u16; /*!< Offset: ITM Stimulus Port 16-bit */
+ __O uint32_t u32; /*!< Offset: ITM Stimulus Port 32-bit */
+ } PORT [32]; /*!< Offset: 0x00 ITM Stimulus Port Registers */
+ uint32_t RESERVED0[864];
+ __IO uint32_t TER; /*!< Offset: ITM Trace Enable Register */
+ uint32_t RESERVED1[15];
+ __IO uint32_t TPR; /*!< Offset: ITM Trace Privilege Register */
+ uint32_t RESERVED2[15];
+ __IO uint32_t TCR; /*!< Offset: ITM Trace Control Register */
+ uint32_t RESERVED3[29];
+ __IO uint32_t IWR; /*!< Offset: ITM Integration Write Register */
+ __IO uint32_t IRR; /*!< Offset: ITM Integration Read Register */
+ __IO uint32_t IMCR; /*!< Offset: ITM Integration Mode Control Register */
+ uint32_t RESERVED4[43];
+ __IO uint32_t LAR; /*!< Offset: ITM Lock Access Register */
+ __IO uint32_t LSR; /*!< Offset: ITM Lock Status Register */
+ uint32_t RESERVED5[6];
+ __I uint32_t PID4; /*!< Offset: ITM Peripheral Identification Register #4 */
+ __I uint32_t PID5; /*!< Offset: ITM Peripheral Identification Register #5 */
+ __I uint32_t PID6; /*!< Offset: ITM Peripheral Identification Register #6 */
+ __I uint32_t PID7; /*!< Offset: ITM Peripheral Identification Register #7 */
+ __I uint32_t PID0; /*!< Offset: ITM Peripheral Identification Register #0 */
+ __I uint32_t PID1; /*!< Offset: ITM Peripheral Identification Register #1 */
+ __I uint32_t PID2; /*!< Offset: ITM Peripheral Identification Register #2 */
+ __I uint32_t PID3; /*!< Offset: ITM Peripheral Identification Register #3 */
+ __I uint32_t CID0; /*!< Offset: ITM Component Identification Register #0 */
+ __I uint32_t CID1; /*!< Offset: ITM Component Identification Register #1 */
+ __I uint32_t CID2; /*!< Offset: ITM Component Identification Register #2 */
+ __I uint32_t CID3; /*!< Offset: ITM Component Identification Register #3 */
+} ITM_Type;
+
+/* ITM Trace Privilege Register Definitions */
+#define ITM_TPR_PRIVMASK_Pos 0 /*!< ITM TPR: PRIVMASK Position */
+#define ITM_TPR_PRIVMASK_Msk (0xFul << ITM_TPR_PRIVMASK_Pos) /*!< ITM TPR: PRIVMASK Mask */
+
+/* ITM Trace Control Register Definitions */
+#define ITM_TCR_BUSY_Pos 23 /*!< ITM TCR: BUSY Position */
+#define ITM_TCR_BUSY_Msk (1ul << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */
+
+#define ITM_TCR_ATBID_Pos 16 /*!< ITM TCR: ATBID Position */
+#define ITM_TCR_ATBID_Msk (0x7Ful << ITM_TCR_ATBID_Pos) /*!< ITM TCR: ATBID Mask */
+
+#define ITM_TCR_TSPrescale_Pos 8 /*!< ITM TCR: TSPrescale Position */
+#define ITM_TCR_TSPrescale_Msk (3ul << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */
+
+#define ITM_TCR_SWOENA_Pos 4 /*!< ITM TCR: SWOENA Position */
+#define ITM_TCR_SWOENA_Msk (1ul << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */
+
+#define ITM_TCR_DWTENA_Pos 3 /*!< ITM TCR: DWTENA Position */
+#define ITM_TCR_DWTENA_Msk (1ul << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */
+
+#define ITM_TCR_SYNCENA_Pos 2 /*!< ITM TCR: SYNCENA Position */
+#define ITM_TCR_SYNCENA_Msk (1ul << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */
+
+#define ITM_TCR_TSENA_Pos 1 /*!< ITM TCR: TSENA Position */
+#define ITM_TCR_TSENA_Msk (1ul << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */
+
+#define ITM_TCR_ITMENA_Pos 0 /*!< ITM TCR: ITM Enable bit Position */
+#define ITM_TCR_ITMENA_Msk (1ul << ITM_TCR_ITMENA_Pos) /*!< ITM TCR: ITM Enable bit Mask */
+
+/* ITM Integration Write Register Definitions */
+#define ITM_IWR_ATVALIDM_Pos 0 /*!< ITM IWR: ATVALIDM Position */
+#define ITM_IWR_ATVALIDM_Msk (1ul << ITM_IWR_ATVALIDM_Pos) /*!< ITM IWR: ATVALIDM Mask */
+
+/* ITM Integration Read Register Definitions */
+#define ITM_IRR_ATREADYM_Pos 0 /*!< ITM IRR: ATREADYM Position */
+#define ITM_IRR_ATREADYM_Msk (1ul << ITM_IRR_ATREADYM_Pos) /*!< ITM IRR: ATREADYM Mask */
+
+/* ITM Integration Mode Control Register Definitions */
+#define ITM_IMCR_INTEGRATION_Pos 0 /*!< ITM IMCR: INTEGRATION Position */
+#define ITM_IMCR_INTEGRATION_Msk (1ul << ITM_IMCR_INTEGRATION_Pos) /*!< ITM IMCR: INTEGRATION Mask */
+
+/* ITM Lock Status Register Definitions */
+#define ITM_LSR_ByteAcc_Pos 2 /*!< ITM LSR: ByteAcc Position */
+#define ITM_LSR_ByteAcc_Msk (1ul << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */
+
+#define ITM_LSR_Access_Pos 1 /*!< ITM LSR: Access Position */
+#define ITM_LSR_Access_Msk (1ul << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */
+
+#define ITM_LSR_Present_Pos 0 /*!< ITM LSR: Present Position */
+#define ITM_LSR_Present_Msk (1ul << ITM_LSR_Present_Pos) /*!< ITM LSR: Present Mask */
+/*@}*/ /* end of group CMSIS_CM3_ITM */
+
+
+/** @addtogroup CMSIS_CM3_InterruptType CMSIS CM3 Interrupt Type
+ memory mapped structure for Interrupt Type
+ @{
+ */
+typedef struct
+{
+ uint32_t RESERVED0;
+ __I uint32_t ICTR; /*!< Offset: 0x04 Interrupt Control Type Register */
+#if ((defined __CM3_REV) && (__CM3_REV >= 0x200))
+ __IO uint32_t ACTLR; /*!< Offset: 0x08 Auxiliary Control Register */
+#else
+ uint32_t RESERVED1;
+#endif
+} InterruptType_Type;
+
+/* Interrupt Controller Type Register Definitions */
+#define InterruptType_ICTR_INTLINESNUM_Pos 0 /*!< InterruptType ICTR: INTLINESNUM Position */
+#define InterruptType_ICTR_INTLINESNUM_Msk (0x1Ful << InterruptType_ICTR_INTLINESNUM_Pos) /*!< InterruptType ICTR: INTLINESNUM Mask */
+
+/* Auxiliary Control Register Definitions */
+#define InterruptType_ACTLR_DISFOLD_Pos 2 /*!< InterruptType ACTLR: DISFOLD Position */
+#define InterruptType_ACTLR_DISFOLD_Msk (1ul << InterruptType_ACTLR_DISFOLD_Pos) /*!< InterruptType ACTLR: DISFOLD Mask */
+
+#define InterruptType_ACTLR_DISDEFWBUF_Pos 1 /*!< InterruptType ACTLR: DISDEFWBUF Position */
+#define InterruptType_ACTLR_DISDEFWBUF_Msk (1ul << InterruptType_ACTLR_DISDEFWBUF_Pos) /*!< InterruptType ACTLR: DISDEFWBUF Mask */
+
+#define InterruptType_ACTLR_DISMCYCINT_Pos 0 /*!< InterruptType ACTLR: DISMCYCINT Position */
+#define InterruptType_ACTLR_DISMCYCINT_Msk (1ul << InterruptType_ACTLR_DISMCYCINT_Pos) /*!< InterruptType ACTLR: DISMCYCINT Mask */
+/*@}*/ /* end of group CMSIS_CM3_InterruptType */
+
+
+#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
+/** @addtogroup CMSIS_CM3_MPU CMSIS CM3 MPU
+ memory mapped structure for Memory Protection Unit (MPU)
+ @{
+ */
+typedef struct
+{
+ __I uint32_t TYPE; /*!< Offset: 0x00 MPU Type Register */
+ __IO uint32_t CTRL; /*!< Offset: 0x04 MPU Control Register */
+ __IO uint32_t RNR; /*!< Offset: 0x08 MPU Region RNRber Register */
+ __IO uint32_t RBAR; /*!< Offset: 0x0C MPU Region Base Address Register */
+ __IO uint32_t RASR; /*!< Offset: 0x10 MPU Region Attribute and Size Register */
+ __IO uint32_t RBAR_A1; /*!< Offset: 0x14 MPU Alias 1 Region Base Address Register */
+ __IO uint32_t RASR_A1; /*!< Offset: 0x18 MPU Alias 1 Region Attribute and Size Register */
+ __IO uint32_t RBAR_A2; /*!< Offset: 0x1C MPU Alias 2 Region Base Address Register */
+ __IO uint32_t RASR_A2; /*!< Offset: 0x20 MPU Alias 2 Region Attribute and Size Register */
+ __IO uint32_t RBAR_A3; /*!< Offset: 0x24 MPU Alias 3 Region Base Address Register */
+ __IO uint32_t RASR_A3; /*!< Offset: 0x28 MPU Alias 3 Region Attribute and Size Register */
+} MPU_Type;
+
+/* MPU Type Register */
+#define MPU_TYPE_IREGION_Pos 16 /*!< MPU TYPE: IREGION Position */
+#define MPU_TYPE_IREGION_Msk (0xFFul << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */
+
+#define MPU_TYPE_DREGION_Pos 8 /*!< MPU TYPE: DREGION Position */
+#define MPU_TYPE_DREGION_Msk (0xFFul << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */
+
+#define MPU_TYPE_SEPARATE_Pos 0 /*!< MPU TYPE: SEPARATE Position */
+#define MPU_TYPE_SEPARATE_Msk (1ul << MPU_TYPE_SEPARATE_Pos) /*!< MPU TYPE: SEPARATE Mask */
+
+/* MPU Control Register */
+#define MPU_CTRL_PRIVDEFENA_Pos 2 /*!< MPU CTRL: PRIVDEFENA Position */
+#define MPU_CTRL_PRIVDEFENA_Msk (1ul << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */
+
+#define MPU_CTRL_HFNMIENA_Pos 1 /*!< MPU CTRL: HFNMIENA Position */
+#define MPU_CTRL_HFNMIENA_Msk (1ul << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */
+
+#define MPU_CTRL_ENABLE_Pos 0 /*!< MPU CTRL: ENABLE Position */
+#define MPU_CTRL_ENABLE_Msk (1ul << MPU_CTRL_ENABLE_Pos) /*!< MPU CTRL: ENABLE Mask */
+
+/* MPU Region Number Register */
+#define MPU_RNR_REGION_Pos 0 /*!< MPU RNR: REGION Position */
+#define MPU_RNR_REGION_Msk (0xFFul << MPU_RNR_REGION_Pos) /*!< MPU RNR: REGION Mask */
+
+/* MPU Region Base Address Register */
+#define MPU_RBAR_ADDR_Pos 5 /*!< MPU RBAR: ADDR Position */
+#define MPU_RBAR_ADDR_Msk (0x7FFFFFFul << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */
+
+#define MPU_RBAR_VALID_Pos 4 /*!< MPU RBAR: VALID Position */
+#define MPU_RBAR_VALID_Msk (1ul << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */
+
+#define MPU_RBAR_REGION_Pos 0 /*!< MPU RBAR: REGION Position */
+#define MPU_RBAR_REGION_Msk (0xFul << MPU_RBAR_REGION_Pos) /*!< MPU RBAR: REGION Mask */
+
+/* MPU Region Attribute and Size Register */
+#define MPU_RASR_XN_Pos 28 /*!< MPU RASR: XN Position */
+#define MPU_RASR_XN_Msk (1ul << MPU_RASR_XN_Pos) /*!< MPU RASR: XN Mask */
+
+#define MPU_RASR_AP_Pos 24 /*!< MPU RASR: AP Position */
+#define MPU_RASR_AP_Msk (7ul << MPU_RASR_AP_Pos) /*!< MPU RASR: AP Mask */
+
+#define MPU_RASR_TEX_Pos 19 /*!< MPU RASR: TEX Position */
+#define MPU_RASR_TEX_Msk (7ul << MPU_RASR_TEX_Pos) /*!< MPU RASR: TEX Mask */
+
+#define MPU_RASR_S_Pos 18 /*!< MPU RASR: Shareable bit Position */
+#define MPU_RASR_S_Msk (1ul << MPU_RASR_S_Pos) /*!< MPU RASR: Shareable bit Mask */
+
+#define MPU_RASR_C_Pos 17 /*!< MPU RASR: Cacheable bit Position */
+#define MPU_RASR_C_Msk (1ul << MPU_RASR_C_Pos) /*!< MPU RASR: Cacheable bit Mask */
+
+#define MPU_RASR_B_Pos 16 /*!< MPU RASR: Bufferable bit Position */
+#define MPU_RASR_B_Msk (1ul << MPU_RASR_B_Pos) /*!< MPU RASR: Bufferable bit Mask */
+
+#define MPU_RASR_SRD_Pos 8 /*!< MPU RASR: Sub-Region Disable Position */
+#define MPU_RASR_SRD_Msk (0xFFul << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */
+
+#define MPU_RASR_SIZE_Pos 1 /*!< MPU RASR: Region Size Field Position */
+#define MPU_RASR_SIZE_Msk (0x1Ful << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */
+
+#define MPU_RASR_ENA_Pos 0 /*!< MPU RASR: Region enable bit Position */
+#define MPU_RASR_ENA_Msk (0x1Ful << MPU_RASR_ENA_Pos) /*!< MPU RASR: Region enable bit Disable Mask */
+
+/*@}*/ /* end of group CMSIS_CM3_MPU */
+#endif
+
+
+/** @addtogroup CMSIS_CM3_CoreDebug CMSIS CM3 Core Debug
+ memory mapped structure for Core Debug Register
+ @{
+ */
+typedef struct
+{
+ __IO uint32_t DHCSR; /*!< Offset: 0x00 Debug Halting Control and Status Register */
+ __O uint32_t DCRSR; /*!< Offset: 0x04 Debug Core Register Selector Register */
+ __IO uint32_t DCRDR; /*!< Offset: 0x08 Debug Core Register Data Register */
+ __IO uint32_t DEMCR; /*!< Offset: 0x0C Debug Exception and Monitor Control Register */
+} CoreDebug_Type;
+
+/* Debug Halting Control and Status Register */
+#define CoreDebug_DHCSR_DBGKEY_Pos 16 /*!< CoreDebug DHCSR: DBGKEY Position */
+#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFul << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */
+
+#define CoreDebug_DHCSR_S_RESET_ST_Pos 25 /*!< CoreDebug DHCSR: S_RESET_ST Position */
+#define CoreDebug_DHCSR_S_RESET_ST_Msk (1ul << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */
+
+#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24 /*!< CoreDebug DHCSR: S_RETIRE_ST Position */
+#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1ul << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */
+
+#define CoreDebug_DHCSR_S_LOCKUP_Pos 19 /*!< CoreDebug DHCSR: S_LOCKUP Position */
+#define CoreDebug_DHCSR_S_LOCKUP_Msk (1ul << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */
+
+#define CoreDebug_DHCSR_S_SLEEP_Pos 18 /*!< CoreDebug DHCSR: S_SLEEP Position */
+#define CoreDebug_DHCSR_S_SLEEP_Msk (1ul << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */
+
+#define CoreDebug_DHCSR_S_HALT_Pos 17 /*!< CoreDebug DHCSR: S_HALT Position */
+#define CoreDebug_DHCSR_S_HALT_Msk (1ul << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */
+
+#define CoreDebug_DHCSR_S_REGRDY_Pos 16 /*!< CoreDebug DHCSR: S_REGRDY Position */
+#define CoreDebug_DHCSR_S_REGRDY_Msk (1ul << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */
+
+#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5 /*!< CoreDebug DHCSR: C_SNAPSTALL Position */
+#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1ul << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */
+
+#define CoreDebug_DHCSR_C_MASKINTS_Pos 3 /*!< CoreDebug DHCSR: C_MASKINTS Position */
+#define CoreDebug_DHCSR_C_MASKINTS_Msk (1ul << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */
+
+#define CoreDebug_DHCSR_C_STEP_Pos 2 /*!< CoreDebug DHCSR: C_STEP Position */
+#define CoreDebug_DHCSR_C_STEP_Msk (1ul << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */
+
+#define CoreDebug_DHCSR_C_HALT_Pos 1 /*!< CoreDebug DHCSR: C_HALT Position */
+#define CoreDebug_DHCSR_C_HALT_Msk (1ul << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */
+
+#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0 /*!< CoreDebug DHCSR: C_DEBUGEN Position */
+#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1ul << CoreDebug_DHCSR_C_DEBUGEN_Pos) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */
+
+/* Debug Core Register Selector Register */
+#define CoreDebug_DCRSR_REGWnR_Pos 16 /*!< CoreDebug DCRSR: REGWnR Position */
+#define CoreDebug_DCRSR_REGWnR_Msk (1ul << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */
+
+#define CoreDebug_DCRSR_REGSEL_Pos 0 /*!< CoreDebug DCRSR: REGSEL Position */
+#define CoreDebug_DCRSR_REGSEL_Msk (0x1Ful << CoreDebug_DCRSR_REGSEL_Pos) /*!< CoreDebug DCRSR: REGSEL Mask */
+
+/* Debug Exception and Monitor Control Register */
+#define CoreDebug_DEMCR_TRCENA_Pos 24 /*!< CoreDebug DEMCR: TRCENA Position */
+#define CoreDebug_DEMCR_TRCENA_Msk (1ul << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */
+
+#define CoreDebug_DEMCR_MON_REQ_Pos 19 /*!< CoreDebug DEMCR: MON_REQ Position */
+#define CoreDebug_DEMCR_MON_REQ_Msk (1ul << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */
+
+#define CoreDebug_DEMCR_MON_STEP_Pos 18 /*!< CoreDebug DEMCR: MON_STEP Position */
+#define CoreDebug_DEMCR_MON_STEP_Msk (1ul << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */
+
+#define CoreDebug_DEMCR_MON_PEND_Pos 17 /*!< CoreDebug DEMCR: MON_PEND Position */
+#define CoreDebug_DEMCR_MON_PEND_Msk (1ul << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */
+
+#define CoreDebug_DEMCR_MON_EN_Pos 16 /*!< CoreDebug DEMCR: MON_EN Position */
+#define CoreDebug_DEMCR_MON_EN_Msk (1ul << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */
+
+#define CoreDebug_DEMCR_VC_HARDERR_Pos 10 /*!< CoreDebug DEMCR: VC_HARDERR Position */
+#define CoreDebug_DEMCR_VC_HARDERR_Msk (1ul << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */
+
+#define CoreDebug_DEMCR_VC_INTERR_Pos 9 /*!< CoreDebug DEMCR: VC_INTERR Position */
+#define CoreDebug_DEMCR_VC_INTERR_Msk (1ul << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */
+
+#define CoreDebug_DEMCR_VC_BUSERR_Pos 8 /*!< CoreDebug DEMCR: VC_BUSERR Position */
+#define CoreDebug_DEMCR_VC_BUSERR_Msk (1ul << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */
+
+#define CoreDebug_DEMCR_VC_STATERR_Pos 7 /*!< CoreDebug DEMCR: VC_STATERR Position */
+#define CoreDebug_DEMCR_VC_STATERR_Msk (1ul << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */
+
+#define CoreDebug_DEMCR_VC_CHKERR_Pos 6 /*!< CoreDebug DEMCR: VC_CHKERR Position */
+#define CoreDebug_DEMCR_VC_CHKERR_Msk (1ul << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */
+
+#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5 /*!< CoreDebug DEMCR: VC_NOCPERR Position */
+#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1ul << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */
+
+#define CoreDebug_DEMCR_VC_MMERR_Pos 4 /*!< CoreDebug DEMCR: VC_MMERR Position */
+#define CoreDebug_DEMCR_VC_MMERR_Msk (1ul << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */
+
+#define CoreDebug_DEMCR_VC_CORERESET_Pos 0 /*!< CoreDebug DEMCR: VC_CORERESET Position */
+#define CoreDebug_DEMCR_VC_CORERESET_Msk (1ul << CoreDebug_DEMCR_VC_CORERESET_Pos) /*!< CoreDebug DEMCR: VC_CORERESET Mask */
+/*@}*/ /* end of group CMSIS_CM3_CoreDebug */
+
+
+/* Memory mapping of Cortex-M3 Hardware */
+#define SCS_BASE (0xE000E000) /*!< System Control Space Base Address */
+#define ITM_BASE (0xE0000000) /*!< ITM Base Address */
+#define CoreDebug_BASE (0xE000EDF0) /*!< Core Debug Base Address */
+#define SysTick_BASE (SCS_BASE + 0x0010) /*!< SysTick Base Address */
+#define NVIC_BASE (SCS_BASE + 0x0100) /*!< NVIC Base Address */
+#define SCB_BASE (SCS_BASE + 0x0D00) /*!< System Control Block Base Address */
+
+#define InterruptType ((InterruptType_Type *) SCS_BASE) /*!< Interrupt Type Register */
+#define SCB ((SCB_Type *) SCB_BASE) /*!< SCB configuration struct */
+#define SysTick ((SysTick_Type *) SysTick_BASE) /*!< SysTick configuration struct */
+#define NVIC ((NVIC_Type *) NVIC_BASE) /*!< NVIC configuration struct */
+#define ITM ((ITM_Type *) ITM_BASE) /*!< ITM configuration struct */
+#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */
+
+#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
+ #define MPU_BASE (SCS_BASE + 0x0D90) /*!< Memory Protection Unit */
+ #define MPU ((MPU_Type*) MPU_BASE) /*!< Memory Protection Unit */
+#endif
+
+/*@}*/ /* end of group CMSIS_CM3_core_register */
+
+
+/*******************************************************************************
+ * Hardware Abstraction Layer
+ ******************************************************************************/
+
+#if defined ( __CC_ARM )
+ #define __ASM __asm /*!< asm keyword for ARM Compiler */
+ #define __INLINE __inline /*!< inline keyword for ARM Compiler */
+
+#elif defined ( __ICCARM__ )
+ #define __ASM __asm /*!< asm keyword for IAR Compiler */
+ #define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */
+
+#elif defined ( __GNUC__ )
+ #define __ASM __asm /*!< asm keyword for GNU Compiler */
+ #define __INLINE inline /*!< inline keyword for GNU Compiler */
+
+#elif defined ( __TASKING__ )
+ #define __ASM __asm /*!< asm keyword for TASKING Compiler */
+ #define __INLINE inline /*!< inline keyword for TASKING Compiler */
+
+#endif
+
+
+/* ################### Compiler specific Intrinsics ########################### */
+
+#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
+/* ARM armcc specific functions */
+
+#define __enable_fault_irq __enable_fiq
+#define __disable_fault_irq __disable_fiq
+
+#define __NOP __nop
+#define __WFI __wfi
+#define __WFE __wfe
+#define __SEV __sev
+#define __ISB() __isb(0)
+#define __DSB() __dsb(0)
+#define __DMB() __dmb(0)
+#define __REV __rev
+#define __RBIT __rbit
+#define __LDREXB(ptr) ((unsigned char ) __ldrex(ptr))
+#define __LDREXH(ptr) ((unsigned short) __ldrex(ptr))
+#define __LDREXW(ptr) ((unsigned int ) __ldrex(ptr))
+#define __STREXB(value, ptr) __strex(value, ptr)
+#define __STREXH(value, ptr) __strex(value, ptr)
+#define __STREXW(value, ptr) __strex(value, ptr)
+
+
+/* intrinsic unsigned long long __ldrexd(volatile void *ptr) */
+/* intrinsic int __strexd(unsigned long long val, volatile void *ptr) */
+/* intrinsic void __enable_irq(); */
+/* intrinsic void __disable_irq(); */
+
+
+/**
+ * @brief Return the Process Stack Pointer
+ *
+ * @return ProcessStackPointer
+ *
+ * Return the actual process stack pointer
+ */
+extern uint32_t __get_PSP(void);
+
+/**
+ * @brief Set the Process Stack Pointer
+ *
+ * @param topOfProcStack Process Stack Pointer
+ *
+ * Assign the value ProcessStackPointer to the MSP
+ * (process stack pointer) Cortex processor register
+ */
+extern void __set_PSP(uint32_t topOfProcStack);
+
+/**
+ * @brief Return the Main Stack Pointer
+ *
+ * @return Main Stack Pointer
+ *
+ * Return the current value of the MSP (main stack pointer)
+ * Cortex processor register
+ */
+extern uint32_t __get_MSP(void);
+
+/**
+ * @brief Set the Main Stack Pointer
+ *
+ * @param topOfMainStack Main Stack Pointer
+ *
+ * Assign the value mainStackPointer to the MSP
+ * (main stack pointer) Cortex processor register
+ */
+extern void __set_MSP(uint32_t topOfMainStack);
+
+/**
+ * @brief Reverse byte order in unsigned short value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in unsigned short value
+ */
+extern uint32_t __REV16(uint16_t value);
+
+/**
+ * @brief Reverse byte order in signed short value with sign extension to integer
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in signed short value with sign extension to integer
+ */
+extern int32_t __REVSH(int16_t value);
+
+
+#if (__ARMCC_VERSION < 400000)
+
+/**
+ * @brief Remove the exclusive lock created by ldrex
+ *
+ * Removes the exclusive lock which is created by ldrex.
+ */
+extern void __CLREX(void);
+
+/**
+ * @brief Return the Base Priority value
+ *
+ * @return BasePriority
+ *
+ * Return the content of the base priority register
+ */
+extern uint32_t __get_BASEPRI(void);
+
+/**
+ * @brief Set the Base Priority value
+ *
+ * @param basePri BasePriority
+ *
+ * Set the base priority register
+ */
+extern void __set_BASEPRI(uint32_t basePri);
+
+/**
+ * @brief Return the Priority Mask value
+ *
+ * @return PriMask
+ *
+ * Return state of the priority mask bit from the priority mask register
+ */
+extern uint32_t __get_PRIMASK(void);
+
+/**
+ * @brief Set the Priority Mask value
+ *
+ * @param priMask PriMask
+ *
+ * Set the priority mask bit in the priority mask register
+ */
+extern void __set_PRIMASK(uint32_t priMask);
+
+/**
+ * @brief Return the Fault Mask value
+ *
+ * @return FaultMask
+ *
+ * Return the content of the fault mask register
+ */
+extern uint32_t __get_FAULTMASK(void);
+
+/**
+ * @brief Set the Fault Mask value
+ *
+ * @param faultMask faultMask value
+ *
+ * Set the fault mask register
+ */
+extern void __set_FAULTMASK(uint32_t faultMask);
+
+/**
+ * @brief Return the Control Register value
+ *
+ * @return Control value
+ *
+ * Return the content of the control register
+ */
+extern uint32_t __get_CONTROL(void);
+
+/**
+ * @brief Set the Control Register value
+ *
+ * @param control Control value
+ *
+ * Set the control register
+ */
+extern void __set_CONTROL(uint32_t control);
+
+#else /* (__ARMCC_VERSION >= 400000) */
+
+/**
+ * @brief Remove the exclusive lock created by ldrex
+ *
+ * Removes the exclusive lock which is created by ldrex.
+ */
+#define __CLREX __clrex
+
+/**
+ * @brief Return the Base Priority value
+ *
+ * @return BasePriority
+ *
+ * Return the content of the base priority register
+ */
+static __INLINE uint32_t __get_BASEPRI(void)
+{
+ register uint32_t __regBasePri __ASM("basepri");
+ return(__regBasePri);
+}
+
+/**
+ * @brief Set the Base Priority value
+ *
+ * @param basePri BasePriority
+ *
+ * Set the base priority register
+ */
+static __INLINE void __set_BASEPRI(uint32_t basePri)
+{
+ register uint32_t __regBasePri __ASM("basepri");
+ __regBasePri = (basePri & 0xff);
+}
+
+/**
+ * @brief Return the Priority Mask value
+ *
+ * @return PriMask
+ *
+ * Return state of the priority mask bit from the priority mask register
+ */
+static __INLINE uint32_t __get_PRIMASK(void)
+{
+ register uint32_t __regPriMask __ASM("primask");
+ return(__regPriMask);
+}
+
+/**
+ * @brief Set the Priority Mask value
+ *
+ * @param priMask PriMask
+ *
+ * Set the priority mask bit in the priority mask register
+ */
+static __INLINE void __set_PRIMASK(uint32_t priMask)
+{
+ register uint32_t __regPriMask __ASM("primask");
+ __regPriMask = (priMask);
+}
+
+/**
+ * @brief Return the Fault Mask value
+ *
+ * @return FaultMask
+ *
+ * Return the content of the fault mask register
+ */
+static __INLINE uint32_t __get_FAULTMASK(void)
+{
+ register uint32_t __regFaultMask __ASM("faultmask");
+ return(__regFaultMask);
+}
+
+/**
+ * @brief Set the Fault Mask value
+ *
+ * @param faultMask faultMask value
+ *
+ * Set the fault mask register
+ */
+static __INLINE void __set_FAULTMASK(uint32_t faultMask)
+{
+ register uint32_t __regFaultMask __ASM("faultmask");
+ __regFaultMask = (faultMask & 1);
+}
+
+/**
+ * @brief Return the Control Register value
+ *
+ * @return Control value
+ *
+ * Return the content of the control register
+ */
+static __INLINE uint32_t __get_CONTROL(void)
+{
+ register uint32_t __regControl __ASM("control");
+ return(__regControl);
+}
+
+/**
+ * @brief Set the Control Register value
+ *
+ * @param control Control value
+ *
+ * Set the control register
+ */
+static __INLINE void __set_CONTROL(uint32_t control)
+{
+ register uint32_t __regControl __ASM("control");
+ __regControl = control;
+}
+
+#endif /* __ARMCC_VERSION */
+
+
+
+#elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/
+/* IAR iccarm specific functions */
+
+#define __enable_irq __enable_interrupt /*!< global Interrupt enable */
+#define __disable_irq __disable_interrupt /*!< global Interrupt disable */
+
+static __INLINE void __enable_fault_irq() { __ASM ("cpsie f"); }
+static __INLINE void __disable_fault_irq() { __ASM ("cpsid f"); }
+
+#define __NOP __no_operation /*!< no operation intrinsic in IAR Compiler */
+static __INLINE void __WFI() { __ASM ("wfi"); }
+static __INLINE void __WFE() { __ASM ("wfe"); }
+static __INLINE void __SEV() { __ASM ("sev"); }
+static __INLINE void __CLREX() { __ASM ("clrex"); }
+
+/* intrinsic void __ISB(void) */
+/* intrinsic void __DSB(void) */
+/* intrinsic void __DMB(void) */
+/* intrinsic void __set_PRIMASK(); */
+/* intrinsic void __get_PRIMASK(); */
+/* intrinsic void __set_FAULTMASK(); */
+/* intrinsic void __get_FAULTMASK(); */
+/* intrinsic uint32_t __REV(uint32_t value); */
+/* intrinsic uint32_t __REVSH(uint32_t value); */
+/* intrinsic unsigned long __STREX(unsigned long, unsigned long); */
+/* intrinsic unsigned long __LDREX(unsigned long *); */
+
+
+/**
+ * @brief Return the Process Stack Pointer
+ *
+ * @return ProcessStackPointer
+ *
+ * Return the actual process stack pointer
+ */
+extern uint32_t __get_PSP(void);
+
+/**
+ * @brief Set the Process Stack Pointer
+ *
+ * @param topOfProcStack Process Stack Pointer
+ *
+ * Assign the value ProcessStackPointer to the MSP
+ * (process stack pointer) Cortex processor register
+ */
+extern void __set_PSP(uint32_t topOfProcStack);
+
+/**
+ * @brief Return the Main Stack Pointer
+ *
+ * @return Main Stack Pointer
+ *
+ * Return the current value of the MSP (main stack pointer)
+ * Cortex processor register
+ */
+extern uint32_t __get_MSP(void);
+
+/**
+ * @brief Set the Main Stack Pointer
+ *
+ * @param topOfMainStack Main Stack Pointer
+ *
+ * Assign the value mainStackPointer to the MSP
+ * (main stack pointer) Cortex processor register
+ */
+extern void __set_MSP(uint32_t topOfMainStack);
+
+/**
+ * @brief Reverse byte order in unsigned short value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in unsigned short value
+ */
+extern uint32_t __REV16(uint16_t value);
+
+/**
+ * @brief Reverse bit order of value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse bit order of value
+ */
+extern uint32_t __RBIT(uint32_t value);
+
+/**
+ * @brief LDR Exclusive (8 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 8 bit values)
+ */
+extern uint8_t __LDREXB(uint8_t *addr);
+
+/**
+ * @brief LDR Exclusive (16 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 16 bit values
+ */
+extern uint16_t __LDREXH(uint16_t *addr);
+
+/**
+ * @brief LDR Exclusive (32 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 32 bit values
+ */
+extern uint32_t __LDREXW(uint32_t *addr);
+
+/**
+ * @brief STR Exclusive (8 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 8 bit values
+ */
+extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
+
+/**
+ * @brief STR Exclusive (16 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 16 bit values
+ */
+extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
+
+/**
+ * @brief STR Exclusive (32 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 32 bit values
+ */
+extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
+
+
+
+#elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
+/* GNU gcc specific functions */
+
+static __INLINE void __enable_irq() { __ASM volatile ("cpsie i"); }
+static __INLINE void __disable_irq() { __ASM volatile ("cpsid i"); }
+
+static __INLINE void __enable_fault_irq() { __ASM volatile ("cpsie f"); }
+static __INLINE void __disable_fault_irq() { __ASM volatile ("cpsid f"); }
+
+static __INLINE void __NOP() { __ASM volatile ("nop"); }
+static __INLINE void __WFI() { __ASM volatile ("wfi"); }
+static __INLINE void __WFE() { __ASM volatile ("wfe"); }
+static __INLINE void __SEV() { __ASM volatile ("sev"); }
+static __INLINE void __ISB() { __ASM volatile ("isb"); }
+static __INLINE void __DSB() { __ASM volatile ("dsb"); }
+static __INLINE void __DMB() { __ASM volatile ("dmb"); }
+static __INLINE void __CLREX() { __ASM volatile ("clrex"); }
+
+
+/**
+ * @brief Return the Process Stack Pointer
+ *
+ * @return ProcessStackPointer
+ *
+ * Return the actual process stack pointer
+ */
+extern uint32_t __get_PSP(void);
+
+/**
+ * @brief Set the Process Stack Pointer
+ *
+ * @param topOfProcStack Process Stack Pointer
+ *
+ * Assign the value ProcessStackPointer to the MSP
+ * (process stack pointer) Cortex processor register
+ */
+extern void __set_PSP(uint32_t topOfProcStack);
+
+/**
+ * @brief Return the Main Stack Pointer
+ *
+ * @return Main Stack Pointer
+ *
+ * Return the current value of the MSP (main stack pointer)
+ * Cortex processor register
+ */
+extern uint32_t __get_MSP(void);
+
+/**
+ * @brief Set the Main Stack Pointer
+ *
+ * @param topOfMainStack Main Stack Pointer
+ *
+ * Assign the value mainStackPointer to the MSP
+ * (main stack pointer) Cortex processor register
+ */
+extern void __set_MSP(uint32_t topOfMainStack);
+
+/**
+ * @brief Return the Base Priority value
+ *
+ * @return BasePriority
+ *
+ * Return the content of the base priority register
+ */
+extern uint32_t __get_BASEPRI(void);
+
+/**
+ * @brief Set the Base Priority value
+ *
+ * @param basePri BasePriority
+ *
+ * Set the base priority register
+ */
+extern void __set_BASEPRI(uint32_t basePri);
+
+/**
+ * @brief Return the Priority Mask value
+ *
+ * @return PriMask
+ *
+ * Return state of the priority mask bit from the priority mask register
+ */
+extern uint32_t __get_PRIMASK(void);
+
+/**
+ * @brief Set the Priority Mask value
+ *
+ * @param priMask PriMask
+ *
+ * Set the priority mask bit in the priority mask register
+ */
+extern void __set_PRIMASK(uint32_t priMask);
+
+/**
+ * @brief Return the Fault Mask value
+ *
+ * @return FaultMask
+ *
+ * Return the content of the fault mask register
+ */
+extern uint32_t __get_FAULTMASK(void);
+
+/**
+ * @brief Set the Fault Mask value
+ *
+ * @param faultMask faultMask value
+ *
+ * Set the fault mask register
+ */
+extern void __set_FAULTMASK(uint32_t faultMask);
+
+/**
+ * @brief Return the Control Register value
+*
+* @return Control value
+ *
+ * Return the content of the control register
+ */
+extern uint32_t __get_CONTROL(void);
+
+/**
+ * @brief Set the Control Register value
+ *
+ * @param control Control value
+ *
+ * Set the control register
+ */
+extern void __set_CONTROL(uint32_t control);
+
+/**
+ * @brief Reverse byte order in integer value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in integer value
+ */
+extern uint32_t __REV(uint32_t value);
+
+/**
+ * @brief Reverse byte order in unsigned short value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in unsigned short value
+ */
+extern uint32_t __REV16(uint16_t value);
+
+/**
+ * @brief Reverse byte order in signed short value with sign extension to integer
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in signed short value with sign extension to integer
+ */
+extern int32_t __REVSH(int16_t value);
+
+/**
+ * @brief Reverse bit order of value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse bit order of value
+ */
+extern uint32_t __RBIT(uint32_t value);
+
+/**
+ * @brief LDR Exclusive (8 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 8 bit value
+ */
+extern uint8_t __LDREXB(uint8_t *addr);
+
+/**
+ * @brief LDR Exclusive (16 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 16 bit values
+ */
+extern uint16_t __LDREXH(uint16_t *addr);
+
+/**
+ * @brief LDR Exclusive (32 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 32 bit values
+ */
+extern uint32_t __LDREXW(uint32_t *addr);
+
+/**
+ * @brief STR Exclusive (8 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 8 bit values
+ */
+extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
+
+/**
+ * @brief STR Exclusive (16 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 16 bit values
+ */
+extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
+
+/**
+ * @brief STR Exclusive (32 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 32 bit values
+ */
+extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
+
+
+#elif (defined (__TASKING__)) /*------------------ TASKING Compiler ---------------------*/
+/* TASKING carm specific functions */
+
+/*
+ * The CMSIS functions have been implemented as intrinsics in the compiler.
+ * Please use "carm -?i" to get an up to date list of all instrinsics,
+ * Including the CMSIS ones.
+ */
+
+#endif
+
+
+/** @addtogroup CMSIS_CM3_Core_FunctionInterface CMSIS CM3 Core Function Interface
+ Core Function Interface containing:
+ - Core NVIC Functions
+ - Core SysTick Functions
+ - Core Reset Functions
+*/
+/*@{*/
+
+/* ########################## NVIC functions #################################### */
+
+/**
+ * @brief Set the Priority Grouping in NVIC Interrupt Controller
+ *
+ * @param PriorityGroup is priority grouping field
+ *
+ * Set the priority grouping field using the required unlock sequence.
+ * The parameter priority_grouping is assigned to the field
+ * SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used.
+ * In case of a conflict between priority grouping and available
+ * priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
+ */
+static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
+{
+ uint32_t reg_value;
+ uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
+
+ reg_value = SCB->AIRCR; /* read old register configuration */
+ reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */
+ reg_value = (reg_value |
+ (0x5FA << SCB_AIRCR_VECTKEY_Pos) |
+ (PriorityGroupTmp << 8)); /* Insert write key and priorty group */
+ SCB->AIRCR = reg_value;
+}
+
+/**
+ * @brief Get the Priority Grouping from NVIC Interrupt Controller
+ *
+ * @return priority grouping field
+ *
+ * Get the priority grouping from NVIC Interrupt Controller.
+ * priority grouping is SCB->AIRCR [10:8] PRIGROUP field.
+ */
+static __INLINE uint32_t NVIC_GetPriorityGrouping(void)
+{
+ return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos); /* read priority grouping field */
+}
+
+/**
+ * @brief Enable Interrupt in NVIC Interrupt Controller
+ *
+ * @param IRQn The positive number of the external interrupt to enable
+ *
+ * Enable a device specific interupt in the NVIC interrupt controller.
+ * The interrupt number cannot be a negative value.
+ */
+static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
+{
+ NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */
+}
+
+/**
+ * @brief Disable the interrupt line for external interrupt specified
+ *
+ * @param IRQn The positive number of the external interrupt to disable
+ *
+ * Disable a device specific interupt in the NVIC interrupt controller.
+ * The interrupt number cannot be a negative value.
+ */
+static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
+{
+ NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */
+}
+
+/**
+ * @brief Read the interrupt pending bit for a device specific interrupt source
+ *
+ * @param IRQn The number of the device specifc interrupt
+ * @return 1 = interrupt pending, 0 = interrupt not pending
+ *
+ * Read the pending register in NVIC and return 1 if its status is pending,
+ * otherwise it returns 0
+ */
+static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
+{
+ return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */
+}
+
+/**
+ * @brief Set the pending bit for an external interrupt
+ *
+ * @param IRQn The number of the interrupt for set pending
+ *
+ * Set the pending bit for the specified interrupt.
+ * The interrupt number cannot be a negative value.
+ */
+static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
+{
+ NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */
+}
+
+/**
+ * @brief Clear the pending bit for an external interrupt
+ *
+ * @param IRQn The number of the interrupt for clear pending
+ *
+ * Clear the pending bit for the specified interrupt.
+ * The interrupt number cannot be a negative value.
+ */
+static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
+{
+ NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
+}
+
+/**
+ * @brief Read the active bit for an external interrupt
+ *
+ * @param IRQn The number of the interrupt for read active bit
+ * @return 1 = interrupt active, 0 = interrupt not active
+ *
+ * Read the active register in NVIC and returns 1 if its status is active,
+ * otherwise it returns 0.
+ */
+static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
+{
+ return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */
+}
+
+/**
+ * @brief Set the priority for an interrupt
+ *
+ * @param IRQn The number of the interrupt for set priority
+ * @param priority The priority to set
+ *
+ * Set the priority for the specified interrupt. The interrupt
+ * number can be positive to specify an external (device specific)
+ * interrupt, or negative to specify an internal (core) interrupt.
+ *
+ * Note: The priority cannot be set for every core interrupt.
+ */
+static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
+{
+ if(IRQn < 0) {
+ SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M3 System Interrupts */
+ else {
+ NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */
+}
+
+/**
+ * @brief Read the priority for an interrupt
+ *
+ * @param IRQn The number of the interrupt for get priority
+ * @return The priority for the interrupt
+ *
+ * Read the priority for the specified interrupt. The interrupt
+ * number can be positive to specify an external (device specific)
+ * interrupt, or negative to specify an internal (core) interrupt.
+ *
+ * The returned priority value is automatically aligned to the implemented
+ * priority bits of the microcontroller.
+ *
+ * Note: The priority cannot be set for every core interrupt.
+ */
+static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
+{
+
+ if(IRQn < 0) {
+ return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M3 system interrupts */
+ else {
+ return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
+}
+
+
+/**
+ * @brief Encode the priority for an interrupt
+ *
+ * @param PriorityGroup The used priority group
+ * @param PreemptPriority The preemptive priority value (starting from 0)
+ * @param SubPriority The sub priority value (starting from 0)
+ * @return The encoded priority for the interrupt
+ *
+ * Encode the priority for an interrupt with the given priority group,
+ * preemptive priority value and sub priority value.
+ * In case of a conflict between priority grouping and available
+ * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.
+ *
+ * The returned priority value can be used for NVIC_SetPriority(...) function
+ */
+static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
+{
+ uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
+ uint32_t PreemptPriorityBits;
+ uint32_t SubPriorityBits;
+
+ PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
+ SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
+
+ return (
+ ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
+ ((SubPriority & ((1 << (SubPriorityBits )) - 1)))
+ );
+}
+
+
+/**
+ * @brief Decode the priority of an interrupt
+ *
+ * @param Priority The priority for the interrupt
+ * @param PriorityGroup The used priority group
+ * @param pPreemptPriority The preemptive priority value (starting from 0)
+ * @param pSubPriority The sub priority value (starting from 0)
+ *
+ * Decode an interrupt priority value with the given priority group to
+ * preemptive priority value and sub priority value.
+ * In case of a conflict between priority grouping and available
+ * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.
+ *
+ * The priority value can be retrieved with NVIC_GetPriority(...) function
+ */
+static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)
+{
+ uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
+ uint32_t PreemptPriorityBits;
+ uint32_t SubPriorityBits;
+
+ PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
+ SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
+
+ *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
+ *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1);
+}
+
+
+
+/* ################################## SysTick function ############################################ */
+
+#if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)
+
+/**
+ * @brief Initialize and start the SysTick counter and its interrupt.
+ *
+ * @param ticks number of ticks between two interrupts
+ * @return 1 = failed, 0 = successful
+ *
+ * Initialise the system tick timer and its interrupt and start the
+ * system tick timer / counter in free running mode to generate
+ * periodical interrupts.
+ */
+static __INLINE uint32_t SysTick_Config(uint32_t ticks)
+{
+ if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
+
+ SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
+ NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Cortex-M0 System Interrupts */
+ SysTick->VAL = 0; /* Load the SysTick Counter Value */
+ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
+ SysTick_CTRL_TICKINT_Msk |
+ SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
+ return (0); /* Function successful */
+}
+
+#endif
+
+
+
+
+/* ################################## Reset function ############################################ */
+
+/**
+ * @brief Initiate a system reset request.
+ *
+ * Initiate a system reset request to reset the MCU
+ */
+static __INLINE void NVIC_SystemReset(void)
+{
+ SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
+ (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
+ SCB_AIRCR_SYSRESETREQ_Msk); /* Keep priority group unchanged */
+ __DSB(); /* Ensure completion of memory access */
+ while(1); /* wait until reset */
+}
+
+/*@}*/ /* end of group CMSIS_CM3_Core_FunctionInterface */
+
+
+
+/* ##################################### Debug In/Output function ########################################### */
+
+/** @addtogroup CMSIS_CM3_CoreDebugInterface CMSIS CM3 Core Debug Interface
+ Core Debug Interface containing:
+ - Core Debug Receive / Transmit Functions
+ - Core Debug Defines
+ - Core Debug Variables
+*/
+/*@{*/
+
+extern volatile int ITM_RxBuffer; /*!< variable to receive characters */
+#define ITM_RXBUFFER_EMPTY 0x5AA55AA5 /*!< value identifying ITM_RxBuffer is ready for next character */
+
+
+/**
+ * @brief Outputs a character via the ITM channel 0
+ *
+ * @param ch character to output
+ * @return character to output
+ *
+ * The function outputs a character via the ITM channel 0.
+ * The function returns when no debugger is connected that has booked the output.
+ * It is blocking when a debugger is connected, but the previous character send is not transmitted.
+ */
+static __INLINE uint32_t ITM_SendChar (uint32_t ch)
+{
+ if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && /* Trace enabled */
+ (ITM->TCR & ITM_TCR_ITMENA_Msk) && /* ITM enabled */
+ (ITM->TER & (1ul << 0) ) ) /* ITM Port #0 enabled */
+ {
+ while (ITM->PORT[0].u32 == 0);
+ ITM->PORT[0].u8 = (uint8_t) ch;
+ }
+ return (ch);
+}
+
+
+/**
+ * @brief Inputs a character via variable ITM_RxBuffer
+ *
+ * @return received character, -1 = no character received
+ *
+ * The function inputs a character via variable ITM_RxBuffer.
+ * The function returns when no debugger is connected that has booked the output.
+ * It is blocking when a debugger is connected, but the previous character send is not transmitted.
+ */
+static __INLINE int ITM_ReceiveChar (void) {
+ int ch = -1; /* no character available */
+
+ if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
+ ch = ITM_RxBuffer;
+ ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */
+ }
+
+ return (ch);
+}
+
+
+/**
+ * @brief Check if a character via variable ITM_RxBuffer is available
+ *
+ * @return 1 = character available, 0 = no character available
+ *
+ * The function checks variable ITM_RxBuffer whether a character is available or not.
+ * The function returns '1' if a character is available and '0' if no character is available.
+ */
+static __INLINE int ITM_CheckChar (void) {
+
+ if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {
+ return (0); /* no character available */
+ } else {
+ return (1); /* character available */
+ }
+}
+
+/*@}*/ /* end of group CMSIS_CM3_core_DebugInterface */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*@}*/ /* end of group CMSIS_CM3_core_definitions */
+
+#endif /* __CM3_CORE_H__ */
+
+/*lint -restore */
diff --git a/st_fw_lib/inc/misc.h b/st_fw_lib/inc/misc.h
new file mode 100644
index 0000000..9a6bd07
--- /dev/null
+++ b/st_fw_lib/inc/misc.h
@@ -0,0 +1,220 @@
+/**
+ ******************************************************************************
+ * @file misc.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the miscellaneous
+ * firmware library functions (add-on to CMSIS functions).
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __MISC_H
+#define __MISC_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup MISC
+ * @{
+ */
+
+/** @defgroup MISC_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief NVIC Init Structure definition
+ */
+
+typedef struct
+{
+ uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled.
+ This parameter can be a value of @ref IRQn_Type
+ (For the complete STM32 Devices IRQ Channels list, please
+ refer to stm32f10x.h file) */
+
+ uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel
+ specified in NVIC_IRQChannel. This parameter can be a value
+ between 0 and 15 as described in the table @ref NVIC_Priority_Table */
+
+ uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified
+ in NVIC_IRQChannel. This parameter can be a value
+ between 0 and 15 as described in the table @ref NVIC_Priority_Table */
+
+ FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel
+ will be enabled or disabled.
+ This parameter can be set either to ENABLE or DISABLE */
+} NVIC_InitTypeDef;
+
+/**
+ * @}
+ */
+
+/** @defgroup NVIC_Priority_Table
+ * @{
+ */
+
+/**
+@code
+ The table below gives the allowed values of the pre-emption priority and subpriority according
+ to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function
+ ============================================================================================================================
+ NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description
+ ============================================================================================================================
+ NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority
+ | | | 4 bits for subpriority
+ ----------------------------------------------------------------------------------------------------------------------------
+ NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority
+ | | | 3 bits for subpriority
+ ----------------------------------------------------------------------------------------------------------------------------
+ NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority
+ | | | 2 bits for subpriority
+ ----------------------------------------------------------------------------------------------------------------------------
+ NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority
+ | | | 1 bits for subpriority
+ ----------------------------------------------------------------------------------------------------------------------------
+ NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority
+ | | | 0 bits for subpriority
+ ============================================================================================================================
+@endcode
+*/
+
+/**
+ * @}
+ */
+
+/** @defgroup MISC_Exported_Constants
+ * @{
+ */
+
+/** @defgroup Vector_Table_Base
+ * @{
+ */
+
+#define NVIC_VectTab_RAM ((uint32_t)0x20000000)
+#define NVIC_VectTab_FLASH ((uint32_t)0x08000000)
+#define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
+ ((VECTTAB) == NVIC_VectTab_FLASH))
+/**
+ * @}
+ */
+
+/** @defgroup System_Low_Power
+ * @{
+ */
+
+#define NVIC_LP_SEVONPEND ((uint8_t)0x10)
+#define NVIC_LP_SLEEPDEEP ((uint8_t)0x04)
+#define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02)
+#define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
+ ((LP) == NVIC_LP_SLEEPDEEP) || \
+ ((LP) == NVIC_LP_SLEEPONEXIT))
+/**
+ * @}
+ */
+
+/** @defgroup Preemption_Priority_Group
+ * @{
+ */
+
+#define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority
+ 4 bits for subpriority */
+#define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority
+ 3 bits for subpriority */
+#define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority
+ 2 bits for subpriority */
+#define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority
+ 1 bits for subpriority */
+#define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority
+ 0 bits for subpriority */
+
+#define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
+ ((GROUP) == NVIC_PriorityGroup_1) || \
+ ((GROUP) == NVIC_PriorityGroup_2) || \
+ ((GROUP) == NVIC_PriorityGroup_3) || \
+ ((GROUP) == NVIC_PriorityGroup_4))
+
+#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
+
+#define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
+
+#define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF)
+
+/**
+ * @}
+ */
+
+/** @defgroup SysTick_clock_source
+ * @{
+ */
+
+#define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB)
+#define SysTick_CLKSource_HCLK ((uint32_t)0x00000004)
+#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
+ ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup MISC_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup MISC_Exported_Functions
+ * @{
+ */
+
+void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup);
+void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
+void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset);
+void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState);
+void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MISC_H */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_adc.h b/st_fw_lib/inc/stm32f10x_adc.h
new file mode 100644
index 0000000..c465d33
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_adc.h
@@ -0,0 +1,483 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_adc.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the ADC firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_ADC_H
+#define __STM32F10x_ADC_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup ADC
+ * @{
+ */
+
+/** @defgroup ADC_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief ADC Init structure definition
+ */
+
+typedef struct
+{
+ uint32_t ADC_Mode; /*!< Configures the ADC to operate in independent or
+ dual mode.
+ This parameter can be a value of @ref ADC_mode */
+
+ FunctionalState ADC_ScanConvMode; /*!< Specifies whether the conversion is performed in
+ Scan (multichannels) or Single (one channel) mode.
+ This parameter can be set to ENABLE or DISABLE */
+
+ FunctionalState ADC_ContinuousConvMode; /*!< Specifies whether the conversion is performed in
+ Continuous or Single mode.
+ This parameter can be set to ENABLE or DISABLE. */
+
+ uint32_t ADC_ExternalTrigConv; /*!< Defines the external trigger used to start the analog
+ to digital conversion of regular channels. This parameter
+ can be a value of @ref ADC_external_trigger_sources_for_regular_channels_conversion */
+
+ uint32_t ADC_DataAlign; /*!< Specifies whether the ADC data alignment is left or right.
+ This parameter can be a value of @ref ADC_data_align */
+
+ uint8_t ADC_NbrOfChannel; /*!< Specifies the number of ADC channels that will be converted
+ using the sequencer for regular channel group.
+ This parameter must range from 1 to 16. */
+}ADC_InitTypeDef;
+/**
+ * @}
+ */
+
+/** @defgroup ADC_Exported_Constants
+ * @{
+ */
+
+#define IS_ADC_ALL_PERIPH(PERIPH) (((PERIPH) == ADC1) || \
+ ((PERIPH) == ADC2) || \
+ ((PERIPH) == ADC3))
+
+#define IS_ADC_DMA_PERIPH(PERIPH) (((PERIPH) == ADC1) || \
+ ((PERIPH) == ADC3))
+
+/** @defgroup ADC_mode
+ * @{
+ */
+
+#define ADC_Mode_Independent ((uint32_t)0x00000000)
+#define ADC_Mode_RegInjecSimult ((uint32_t)0x00010000)
+#define ADC_Mode_RegSimult_AlterTrig ((uint32_t)0x00020000)
+#define ADC_Mode_InjecSimult_FastInterl ((uint32_t)0x00030000)
+#define ADC_Mode_InjecSimult_SlowInterl ((uint32_t)0x00040000)
+#define ADC_Mode_InjecSimult ((uint32_t)0x00050000)
+#define ADC_Mode_RegSimult ((uint32_t)0x00060000)
+#define ADC_Mode_FastInterl ((uint32_t)0x00070000)
+#define ADC_Mode_SlowInterl ((uint32_t)0x00080000)
+#define ADC_Mode_AlterTrig ((uint32_t)0x00090000)
+
+#define IS_ADC_MODE(MODE) (((MODE) == ADC_Mode_Independent) || \
+ ((MODE) == ADC_Mode_RegInjecSimult) || \
+ ((MODE) == ADC_Mode_RegSimult_AlterTrig) || \
+ ((MODE) == ADC_Mode_InjecSimult_FastInterl) || \
+ ((MODE) == ADC_Mode_InjecSimult_SlowInterl) || \
+ ((MODE) == ADC_Mode_InjecSimult) || \
+ ((MODE) == ADC_Mode_RegSimult) || \
+ ((MODE) == ADC_Mode_FastInterl) || \
+ ((MODE) == ADC_Mode_SlowInterl) || \
+ ((MODE) == ADC_Mode_AlterTrig))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_external_trigger_sources_for_regular_channels_conversion
+ * @{
+ */
+
+#define ADC_ExternalTrigConv_T1_CC1 ((uint32_t)0x00000000) /*!< For ADC1 and ADC2 */
+#define ADC_ExternalTrigConv_T1_CC2 ((uint32_t)0x00020000) /*!< For ADC1 and ADC2 */
+#define ADC_ExternalTrigConv_T2_CC2 ((uint32_t)0x00060000) /*!< For ADC1 and ADC2 */
+#define ADC_ExternalTrigConv_T3_TRGO ((uint32_t)0x00080000) /*!< For ADC1 and ADC2 */
+#define ADC_ExternalTrigConv_T4_CC4 ((uint32_t)0x000A0000) /*!< For ADC1 and ADC2 */
+#define ADC_ExternalTrigConv_Ext_IT11_TIM8_TRGO ((uint32_t)0x000C0000) /*!< For ADC1 and ADC2 */
+
+#define ADC_ExternalTrigConv_T1_CC3 ((uint32_t)0x00040000) /*!< For ADC1, ADC2 and ADC3 */
+#define ADC_ExternalTrigConv_None ((uint32_t)0x000E0000) /*!< For ADC1, ADC2 and ADC3 */
+
+#define ADC_ExternalTrigConv_T3_CC1 ((uint32_t)0x00000000) /*!< For ADC3 only */
+#define ADC_ExternalTrigConv_T2_CC3 ((uint32_t)0x00020000) /*!< For ADC3 only */
+#define ADC_ExternalTrigConv_T8_CC1 ((uint32_t)0x00060000) /*!< For ADC3 only */
+#define ADC_ExternalTrigConv_T8_TRGO ((uint32_t)0x00080000) /*!< For ADC3 only */
+#define ADC_ExternalTrigConv_T5_CC1 ((uint32_t)0x000A0000) /*!< For ADC3 only */
+#define ADC_ExternalTrigConv_T5_CC3 ((uint32_t)0x000C0000) /*!< For ADC3 only */
+
+#define IS_ADC_EXT_TRIG(REGTRIG) (((REGTRIG) == ADC_ExternalTrigConv_T1_CC1) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T1_CC2) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T1_CC3) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T2_CC2) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T3_TRGO) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T4_CC4) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_Ext_IT11_TIM8_TRGO) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_None) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T3_CC1) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T2_CC3) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T8_CC1) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T8_TRGO) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T5_CC1) || \
+ ((REGTRIG) == ADC_ExternalTrigConv_T5_CC3))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_data_align
+ * @{
+ */
+
+#define ADC_DataAlign_Right ((uint32_t)0x00000000)
+#define ADC_DataAlign_Left ((uint32_t)0x00000800)
+#define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DataAlign_Right) || \
+ ((ALIGN) == ADC_DataAlign_Left))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_channels
+ * @{
+ */
+
+#define ADC_Channel_0 ((uint8_t)0x00)
+#define ADC_Channel_1 ((uint8_t)0x01)
+#define ADC_Channel_2 ((uint8_t)0x02)
+#define ADC_Channel_3 ((uint8_t)0x03)
+#define ADC_Channel_4 ((uint8_t)0x04)
+#define ADC_Channel_5 ((uint8_t)0x05)
+#define ADC_Channel_6 ((uint8_t)0x06)
+#define ADC_Channel_7 ((uint8_t)0x07)
+#define ADC_Channel_8 ((uint8_t)0x08)
+#define ADC_Channel_9 ((uint8_t)0x09)
+#define ADC_Channel_10 ((uint8_t)0x0A)
+#define ADC_Channel_11 ((uint8_t)0x0B)
+#define ADC_Channel_12 ((uint8_t)0x0C)
+#define ADC_Channel_13 ((uint8_t)0x0D)
+#define ADC_Channel_14 ((uint8_t)0x0E)
+#define ADC_Channel_15 ((uint8_t)0x0F)
+#define ADC_Channel_16 ((uint8_t)0x10)
+#define ADC_Channel_17 ((uint8_t)0x11)
+
+#define ADC_Channel_TempSensor ((uint8_t)ADC_Channel_16)
+#define ADC_Channel_Vrefint ((uint8_t)ADC_Channel_17)
+
+#define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_Channel_0) || ((CHANNEL) == ADC_Channel_1) || \
+ ((CHANNEL) == ADC_Channel_2) || ((CHANNEL) == ADC_Channel_3) || \
+ ((CHANNEL) == ADC_Channel_4) || ((CHANNEL) == ADC_Channel_5) || \
+ ((CHANNEL) == ADC_Channel_6) || ((CHANNEL) == ADC_Channel_7) || \
+ ((CHANNEL) == ADC_Channel_8) || ((CHANNEL) == ADC_Channel_9) || \
+ ((CHANNEL) == ADC_Channel_10) || ((CHANNEL) == ADC_Channel_11) || \
+ ((CHANNEL) == ADC_Channel_12) || ((CHANNEL) == ADC_Channel_13) || \
+ ((CHANNEL) == ADC_Channel_14) || ((CHANNEL) == ADC_Channel_15) || \
+ ((CHANNEL) == ADC_Channel_16) || ((CHANNEL) == ADC_Channel_17))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_sampling_time
+ * @{
+ */
+
+#define ADC_SampleTime_1Cycles5 ((uint8_t)0x00)
+#define ADC_SampleTime_7Cycles5 ((uint8_t)0x01)
+#define ADC_SampleTime_13Cycles5 ((uint8_t)0x02)
+#define ADC_SampleTime_28Cycles5 ((uint8_t)0x03)
+#define ADC_SampleTime_41Cycles5 ((uint8_t)0x04)
+#define ADC_SampleTime_55Cycles5 ((uint8_t)0x05)
+#define ADC_SampleTime_71Cycles5 ((uint8_t)0x06)
+#define ADC_SampleTime_239Cycles5 ((uint8_t)0x07)
+#define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SampleTime_1Cycles5) || \
+ ((TIME) == ADC_SampleTime_7Cycles5) || \
+ ((TIME) == ADC_SampleTime_13Cycles5) || \
+ ((TIME) == ADC_SampleTime_28Cycles5) || \
+ ((TIME) == ADC_SampleTime_41Cycles5) || \
+ ((TIME) == ADC_SampleTime_55Cycles5) || \
+ ((TIME) == ADC_SampleTime_71Cycles5) || \
+ ((TIME) == ADC_SampleTime_239Cycles5))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_external_trigger_sources_for_injected_channels_conversion
+ * @{
+ */
+
+#define ADC_ExternalTrigInjecConv_T2_TRGO ((uint32_t)0x00002000) /*!< For ADC1 and ADC2 */
+#define ADC_ExternalTrigInjecConv_T2_CC1 ((uint32_t)0x00003000) /*!< For ADC1 and ADC2 */
+#define ADC_ExternalTrigInjecConv_T3_CC4 ((uint32_t)0x00004000) /*!< For ADC1 and ADC2 */
+#define ADC_ExternalTrigInjecConv_T4_TRGO ((uint32_t)0x00005000) /*!< For ADC1 and ADC2 */
+#define ADC_ExternalTrigInjecConv_Ext_IT15_TIM8_CC4 ((uint32_t)0x00006000) /*!< For ADC1 and ADC2 */
+
+#define ADC_ExternalTrigInjecConv_T1_TRGO ((uint32_t)0x00000000) /*!< For ADC1, ADC2 and ADC3 */
+#define ADC_ExternalTrigInjecConv_T1_CC4 ((uint32_t)0x00001000) /*!< For ADC1, ADC2 and ADC3 */
+#define ADC_ExternalTrigInjecConv_None ((uint32_t)0x00007000) /*!< For ADC1, ADC2 and ADC3 */
+
+#define ADC_ExternalTrigInjecConv_T4_CC3 ((uint32_t)0x00002000) /*!< For ADC3 only */
+#define ADC_ExternalTrigInjecConv_T8_CC2 ((uint32_t)0x00003000) /*!< For ADC3 only */
+#define ADC_ExternalTrigInjecConv_T8_CC4 ((uint32_t)0x00004000) /*!< For ADC3 only */
+#define ADC_ExternalTrigInjecConv_T5_TRGO ((uint32_t)0x00005000) /*!< For ADC3 only */
+#define ADC_ExternalTrigInjecConv_T5_CC4 ((uint32_t)0x00006000) /*!< For ADC3 only */
+
+#define IS_ADC_EXT_INJEC_TRIG(INJTRIG) (((INJTRIG) == ADC_ExternalTrigInjecConv_T1_TRGO) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_T1_CC4) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_T2_TRGO) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_T2_CC1) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_T3_CC4) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_T4_TRGO) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_Ext_IT15_TIM8_CC4) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_None) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_T4_CC3) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_T8_CC2) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_T8_CC4) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_T5_TRGO) || \
+ ((INJTRIG) == ADC_ExternalTrigInjecConv_T5_CC4))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_injected_channel_selection
+ * @{
+ */
+
+#define ADC_InjectedChannel_1 ((uint8_t)0x14)
+#define ADC_InjectedChannel_2 ((uint8_t)0x18)
+#define ADC_InjectedChannel_3 ((uint8_t)0x1C)
+#define ADC_InjectedChannel_4 ((uint8_t)0x20)
+#define IS_ADC_INJECTED_CHANNEL(CHANNEL) (((CHANNEL) == ADC_InjectedChannel_1) || \
+ ((CHANNEL) == ADC_InjectedChannel_2) || \
+ ((CHANNEL) == ADC_InjectedChannel_3) || \
+ ((CHANNEL) == ADC_InjectedChannel_4))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_analog_watchdog_selection
+ * @{
+ */
+
+#define ADC_AnalogWatchdog_SingleRegEnable ((uint32_t)0x00800200)
+#define ADC_AnalogWatchdog_SingleInjecEnable ((uint32_t)0x00400200)
+#define ADC_AnalogWatchdog_SingleRegOrInjecEnable ((uint32_t)0x00C00200)
+#define ADC_AnalogWatchdog_AllRegEnable ((uint32_t)0x00800000)
+#define ADC_AnalogWatchdog_AllInjecEnable ((uint32_t)0x00400000)
+#define ADC_AnalogWatchdog_AllRegAllInjecEnable ((uint32_t)0x00C00000)
+#define ADC_AnalogWatchdog_None ((uint32_t)0x00000000)
+
+#define IS_ADC_ANALOG_WATCHDOG(WATCHDOG) (((WATCHDOG) == ADC_AnalogWatchdog_SingleRegEnable) || \
+ ((WATCHDOG) == ADC_AnalogWatchdog_SingleInjecEnable) || \
+ ((WATCHDOG) == ADC_AnalogWatchdog_SingleRegOrInjecEnable) || \
+ ((WATCHDOG) == ADC_AnalogWatchdog_AllRegEnable) || \
+ ((WATCHDOG) == ADC_AnalogWatchdog_AllInjecEnable) || \
+ ((WATCHDOG) == ADC_AnalogWatchdog_AllRegAllInjecEnable) || \
+ ((WATCHDOG) == ADC_AnalogWatchdog_None))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_interrupts_definition
+ * @{
+ */
+
+#define ADC_IT_EOC ((uint16_t)0x0220)
+#define ADC_IT_AWD ((uint16_t)0x0140)
+#define ADC_IT_JEOC ((uint16_t)0x0480)
+
+#define IS_ADC_IT(IT) ((((IT) & (uint16_t)0xF81F) == 0x00) && ((IT) != 0x00))
+
+#define IS_ADC_GET_IT(IT) (((IT) == ADC_IT_EOC) || ((IT) == ADC_IT_AWD) || \
+ ((IT) == ADC_IT_JEOC))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_flags_definition
+ * @{
+ */
+
+#define ADC_FLAG_AWD ((uint8_t)0x01)
+#define ADC_FLAG_EOC ((uint8_t)0x02)
+#define ADC_FLAG_JEOC ((uint8_t)0x04)
+#define ADC_FLAG_JSTRT ((uint8_t)0x08)
+#define ADC_FLAG_STRT ((uint8_t)0x10)
+#define IS_ADC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint8_t)0xE0) == 0x00) && ((FLAG) != 0x00))
+#define IS_ADC_GET_FLAG(FLAG) (((FLAG) == ADC_FLAG_AWD) || ((FLAG) == ADC_FLAG_EOC) || \
+ ((FLAG) == ADC_FLAG_JEOC) || ((FLAG)== ADC_FLAG_JSTRT) || \
+ ((FLAG) == ADC_FLAG_STRT))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_thresholds
+ * @{
+ */
+
+#define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= 0xFFF)
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_injected_offset
+ * @{
+ */
+
+#define IS_ADC_OFFSET(OFFSET) ((OFFSET) <= 0xFFF)
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_injected_length
+ * @{
+ */
+
+#define IS_ADC_INJECTED_LENGTH(LENGTH) (((LENGTH) >= 0x1) && ((LENGTH) <= 0x4))
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_injected_rank
+ * @{
+ */
+
+#define IS_ADC_INJECTED_RANK(RANK) (((RANK) >= 0x1) && ((RANK) <= 0x4))
+
+/**
+ * @}
+ */
+
+
+/** @defgroup ADC_regular_length
+ * @{
+ */
+
+#define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= 0x1) && ((LENGTH) <= 0x10))
+/**
+ * @}
+ */
+
+/** @defgroup ADC_regular_rank
+ * @{
+ */
+
+#define IS_ADC_REGULAR_RANK(RANK) (((RANK) >= 0x1) && ((RANK) <= 0x10))
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_regular_discontinuous_mode_number
+ * @{
+ */
+
+#define IS_ADC_REGULAR_DISC_NUMBER(NUMBER) (((NUMBER) >= 0x1) && ((NUMBER) <= 0x8))
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_Exported_Functions
+ * @{
+ */
+
+void ADC_DeInit(ADC_TypeDef* ADCx);
+void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct);
+void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct);
+void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState);
+void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState);
+void ADC_ITConfig(ADC_TypeDef* ADCx, uint16_t ADC_IT, FunctionalState NewState);
+void ADC_ResetCalibration(ADC_TypeDef* ADCx);
+FlagStatus ADC_GetResetCalibrationStatus(ADC_TypeDef* ADCx);
+void ADC_StartCalibration(ADC_TypeDef* ADCx);
+FlagStatus ADC_GetCalibrationStatus(ADC_TypeDef* ADCx);
+void ADC_SoftwareStartConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
+FlagStatus ADC_GetSoftwareStartConvStatus(ADC_TypeDef* ADCx);
+void ADC_DiscModeChannelCountConfig(ADC_TypeDef* ADCx, uint8_t Number);
+void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
+void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
+void ADC_ExternalTrigConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
+uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx);
+uint32_t ADC_GetDualModeConversionValue(void);
+void ADC_AutoInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
+void ADC_InjectedDiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
+void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef* ADCx, uint32_t ADC_ExternalTrigInjecConv);
+void ADC_ExternalTrigInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
+void ADC_SoftwareStartInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
+FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus(ADC_TypeDef* ADCx);
+void ADC_InjectedChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
+void ADC_InjectedSequencerLengthConfig(ADC_TypeDef* ADCx, uint8_t Length);
+void ADC_SetInjectedOffset(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel, uint16_t Offset);
+uint16_t ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel);
+void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog);
+void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold, uint16_t LowThreshold);
+void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel);
+void ADC_TempSensorVrefintCmd(FunctionalState NewState);
+FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint8_t ADC_FLAG);
+void ADC_ClearFlag(ADC_TypeDef* ADCx, uint8_t ADC_FLAG);
+ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint16_t ADC_IT);
+void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint16_t ADC_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__STM32F10x_ADC_H */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_bkp.h b/st_fw_lib/inc/stm32f10x_bkp.h
new file mode 100644
index 0000000..275c5e1
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_bkp.h
@@ -0,0 +1,195 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_bkp.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the BKP firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_BKP_H
+#define __STM32F10x_BKP_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup BKP
+ * @{
+ */
+
+/** @defgroup BKP_Exported_Types
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup BKP_Exported_Constants
+ * @{
+ */
+
+/** @defgroup Tamper_Pin_active_level
+ * @{
+ */
+
+#define BKP_TamperPinLevel_High ((uint16_t)0x0000)
+#define BKP_TamperPinLevel_Low ((uint16_t)0x0001)
+#define IS_BKP_TAMPER_PIN_LEVEL(LEVEL) (((LEVEL) == BKP_TamperPinLevel_High) || \
+ ((LEVEL) == BKP_TamperPinLevel_Low))
+/**
+ * @}
+ */
+
+/** @defgroup RTC_output_source_to_output_on_the_Tamper_pin
+ * @{
+ */
+
+#define BKP_RTCOutputSource_None ((uint16_t)0x0000)
+#define BKP_RTCOutputSource_CalibClock ((uint16_t)0x0080)
+#define BKP_RTCOutputSource_Alarm ((uint16_t)0x0100)
+#define BKP_RTCOutputSource_Second ((uint16_t)0x0300)
+#define IS_BKP_RTC_OUTPUT_SOURCE(SOURCE) (((SOURCE) == BKP_RTCOutputSource_None) || \
+ ((SOURCE) == BKP_RTCOutputSource_CalibClock) || \
+ ((SOURCE) == BKP_RTCOutputSource_Alarm) || \
+ ((SOURCE) == BKP_RTCOutputSource_Second))
+/**
+ * @}
+ */
+
+/** @defgroup Data_Backup_Register
+ * @{
+ */
+
+#define BKP_DR1 ((uint16_t)0x0004)
+#define BKP_DR2 ((uint16_t)0x0008)
+#define BKP_DR3 ((uint16_t)0x000C)
+#define BKP_DR4 ((uint16_t)0x0010)
+#define BKP_DR5 ((uint16_t)0x0014)
+#define BKP_DR6 ((uint16_t)0x0018)
+#define BKP_DR7 ((uint16_t)0x001C)
+#define BKP_DR8 ((uint16_t)0x0020)
+#define BKP_DR9 ((uint16_t)0x0024)
+#define BKP_DR10 ((uint16_t)0x0028)
+#define BKP_DR11 ((uint16_t)0x0040)
+#define BKP_DR12 ((uint16_t)0x0044)
+#define BKP_DR13 ((uint16_t)0x0048)
+#define BKP_DR14 ((uint16_t)0x004C)
+#define BKP_DR15 ((uint16_t)0x0050)
+#define BKP_DR16 ((uint16_t)0x0054)
+#define BKP_DR17 ((uint16_t)0x0058)
+#define BKP_DR18 ((uint16_t)0x005C)
+#define BKP_DR19 ((uint16_t)0x0060)
+#define BKP_DR20 ((uint16_t)0x0064)
+#define BKP_DR21 ((uint16_t)0x0068)
+#define BKP_DR22 ((uint16_t)0x006C)
+#define BKP_DR23 ((uint16_t)0x0070)
+#define BKP_DR24 ((uint16_t)0x0074)
+#define BKP_DR25 ((uint16_t)0x0078)
+#define BKP_DR26 ((uint16_t)0x007C)
+#define BKP_DR27 ((uint16_t)0x0080)
+#define BKP_DR28 ((uint16_t)0x0084)
+#define BKP_DR29 ((uint16_t)0x0088)
+#define BKP_DR30 ((uint16_t)0x008C)
+#define BKP_DR31 ((uint16_t)0x0090)
+#define BKP_DR32 ((uint16_t)0x0094)
+#define BKP_DR33 ((uint16_t)0x0098)
+#define BKP_DR34 ((uint16_t)0x009C)
+#define BKP_DR35 ((uint16_t)0x00A0)
+#define BKP_DR36 ((uint16_t)0x00A4)
+#define BKP_DR37 ((uint16_t)0x00A8)
+#define BKP_DR38 ((uint16_t)0x00AC)
+#define BKP_DR39 ((uint16_t)0x00B0)
+#define BKP_DR40 ((uint16_t)0x00B4)
+#define BKP_DR41 ((uint16_t)0x00B8)
+#define BKP_DR42 ((uint16_t)0x00BC)
+
+#define IS_BKP_DR(DR) (((DR) == BKP_DR1) || ((DR) == BKP_DR2) || ((DR) == BKP_DR3) || \
+ ((DR) == BKP_DR4) || ((DR) == BKP_DR5) || ((DR) == BKP_DR6) || \
+ ((DR) == BKP_DR7) || ((DR) == BKP_DR8) || ((DR) == BKP_DR9) || \
+ ((DR) == BKP_DR10) || ((DR) == BKP_DR11) || ((DR) == BKP_DR12) || \
+ ((DR) == BKP_DR13) || ((DR) == BKP_DR14) || ((DR) == BKP_DR15) || \
+ ((DR) == BKP_DR16) || ((DR) == BKP_DR17) || ((DR) == BKP_DR18) || \
+ ((DR) == BKP_DR19) || ((DR) == BKP_DR20) || ((DR) == BKP_DR21) || \
+ ((DR) == BKP_DR22) || ((DR) == BKP_DR23) || ((DR) == BKP_DR24) || \
+ ((DR) == BKP_DR25) || ((DR) == BKP_DR26) || ((DR) == BKP_DR27) || \
+ ((DR) == BKP_DR28) || ((DR) == BKP_DR29) || ((DR) == BKP_DR30) || \
+ ((DR) == BKP_DR31) || ((DR) == BKP_DR32) || ((DR) == BKP_DR33) || \
+ ((DR) == BKP_DR34) || ((DR) == BKP_DR35) || ((DR) == BKP_DR36) || \
+ ((DR) == BKP_DR37) || ((DR) == BKP_DR38) || ((DR) == BKP_DR39) || \
+ ((DR) == BKP_DR40) || ((DR) == BKP_DR41) || ((DR) == BKP_DR42))
+
+#define IS_BKP_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x7F)
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup BKP_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup BKP_Exported_Functions
+ * @{
+ */
+
+void BKP_DeInit(void);
+void BKP_TamperPinLevelConfig(uint16_t BKP_TamperPinLevel);
+void BKP_TamperPinCmd(FunctionalState NewState);
+void BKP_ITConfig(FunctionalState NewState);
+void BKP_RTCOutputConfig(uint16_t BKP_RTCOutputSource);
+void BKP_SetRTCCalibrationValue(uint8_t CalibrationValue);
+void BKP_WriteBackupRegister(uint16_t BKP_DR, uint16_t Data);
+uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR);
+FlagStatus BKP_GetFlagStatus(void);
+void BKP_ClearFlag(void);
+ITStatus BKP_GetITStatus(void);
+void BKP_ClearITPendingBit(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_BKP_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_can.h b/st_fw_lib/inc/stm32f10x_can.h
new file mode 100644
index 0000000..d185aa2
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_can.h
@@ -0,0 +1,697 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_can.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the CAN firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_CAN_H
+#define __STM32F10x_CAN_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup CAN
+ * @{
+ */
+
+/** @defgroup CAN_Exported_Types
+ * @{
+ */
+
+#define IS_CAN_ALL_PERIPH(PERIPH) (((PERIPH) == CAN1) || \
+ ((PERIPH) == CAN2))
+
+/**
+ * @brief CAN init structure definition
+ */
+
+typedef struct
+{
+ uint16_t CAN_Prescaler; /*!< Specifies the length of a time quantum.
+ It ranges from 1 to 1024. */
+
+ uint8_t CAN_Mode; /*!< Specifies the CAN operating mode.
+ This parameter can be a value of
+ @ref CAN_operating_mode */
+
+ uint8_t CAN_SJW; /*!< Specifies the maximum number of time quanta
+ the CAN hardware is allowed to lengthen or
+ shorten a bit to perform resynchronization.
+ This parameter can be a value of
+ @ref CAN_synchronisation_jump_width */
+
+ uint8_t CAN_BS1; /*!< Specifies the number of time quanta in Bit
+ Segment 1. This parameter can be a value of
+ @ref CAN_time_quantum_in_bit_segment_1 */
+
+ uint8_t CAN_BS2; /*!< Specifies the number of time quanta in Bit
+ Segment 2.
+ This parameter can be a value of
+ @ref CAN_time_quantum_in_bit_segment_2 */
+
+ FunctionalState CAN_TTCM; /*!< Enable or disable the time triggered
+ communication mode. This parameter can be set
+ either to ENABLE or DISABLE. */
+
+ FunctionalState CAN_ABOM; /*!< Enable or disable the automatic bus-off
+ management. This parameter can be set either
+ to ENABLE or DISABLE. */
+
+ FunctionalState CAN_AWUM; /*!< Enable or disable the automatic wake-up mode.
+ This parameter can be set either to ENABLE or
+ DISABLE. */
+
+ FunctionalState CAN_NART; /*!< Enable or disable the no-automatic
+ retransmission mode. This parameter can be
+ set either to ENABLE or DISABLE. */
+
+ FunctionalState CAN_RFLM; /*!< Enable or disable the Receive FIFO Locked mode.
+ This parameter can be set either to ENABLE
+ or DISABLE. */
+
+ FunctionalState CAN_TXFP; /*!< Enable or disable the transmit FIFO priority.
+ This parameter can be set either to ENABLE
+ or DISABLE. */
+} CAN_InitTypeDef;
+
+/**
+ * @brief CAN filter init structure definition
+ */
+
+typedef struct
+{
+ uint16_t CAN_FilterIdHigh; /*!< Specifies the filter identification number (MSBs for a 32-bit
+ configuration, first one for a 16-bit configuration).
+ This parameter can be a value between 0x0000 and 0xFFFF */
+
+ uint16_t CAN_FilterIdLow; /*!< Specifies the filter identification number (LSBs for a 32-bit
+ configuration, second one for a 16-bit configuration).
+ This parameter can be a value between 0x0000 and 0xFFFF */
+
+ uint16_t CAN_FilterMaskIdHigh; /*!< Specifies the filter mask number or identification number,
+ according to the mode (MSBs for a 32-bit configuration,
+ first one for a 16-bit configuration).
+ This parameter can be a value between 0x0000 and 0xFFFF */
+
+ uint16_t CAN_FilterMaskIdLow; /*!< Specifies the filter mask number or identification number,
+ according to the mode (LSBs for a 32-bit configuration,
+ second one for a 16-bit configuration).
+ This parameter can be a value between 0x0000 and 0xFFFF */
+
+ uint16_t CAN_FilterFIFOAssignment; /*!< Specifies the FIFO (0 or 1) which will be assigned to the filter.
+ This parameter can be a value of @ref CAN_filter_FIFO */
+
+ uint8_t CAN_FilterNumber; /*!< Specifies the filter which will be initialized. It ranges from 0 to 13. */
+
+ uint8_t CAN_FilterMode; /*!< Specifies the filter mode to be initialized.
+ This parameter can be a value of @ref CAN_filter_mode */
+
+ uint8_t CAN_FilterScale; /*!< Specifies the filter scale.
+ This parameter can be a value of @ref CAN_filter_scale */
+
+ FunctionalState CAN_FilterActivation; /*!< Enable or disable the filter.
+ This parameter can be set either to ENABLE or DISABLE. */
+} CAN_FilterInitTypeDef;
+
+/**
+ * @brief CAN Tx message structure definition
+ */
+
+typedef struct
+{
+ uint32_t StdId; /*!< Specifies the standard identifier.
+ This parameter can be a value between 0 to 0x7FF. */
+
+ uint32_t ExtId; /*!< Specifies the extended identifier.
+ This parameter can be a value between 0 to 0x1FFFFFFF. */
+
+ uint8_t IDE; /*!< Specifies the type of identifier for the message that
+ will be transmitted. This parameter can be a value
+ of @ref CAN_identifier_type */
+
+ uint8_t RTR; /*!< Specifies the type of frame for the message that will
+ be transmitted. This parameter can be a value of
+ @ref CAN_remote_transmission_request */
+
+ uint8_t DLC; /*!< Specifies the length of the frame that will be
+ transmitted. This parameter can be a value between
+ 0 to 8 */
+
+ uint8_t Data[8]; /*!< Contains the data to be transmitted. It ranges from 0
+ to 0xFF. */
+} CanTxMsg;
+
+/**
+ * @brief CAN Rx message structure definition
+ */
+
+typedef struct
+{
+ uint32_t StdId; /*!< Specifies the standard identifier.
+ This parameter can be a value between 0 to 0x7FF. */
+
+ uint32_t ExtId; /*!< Specifies the extended identifier.
+ This parameter can be a value between 0 to 0x1FFFFFFF. */
+
+ uint8_t IDE; /*!< Specifies the type of identifier for the message that
+ will be received. This parameter can be a value of
+ @ref CAN_identifier_type */
+
+ uint8_t RTR; /*!< Specifies the type of frame for the received message.
+ This parameter can be a value of
+ @ref CAN_remote_transmission_request */
+
+ uint8_t DLC; /*!< Specifies the length of the frame that will be received.
+ This parameter can be a value between 0 to 8 */
+
+ uint8_t Data[8]; /*!< Contains the data to be received. It ranges from 0 to
+ 0xFF. */
+
+ uint8_t FMI; /*!< Specifies the index of the filter the message stored in
+ the mailbox passes through. This parameter can be a
+ value between 0 to 0xFF */
+} CanRxMsg;
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Exported_Constants
+ * @{
+ */
+
+/** @defgroup CAN_sleep_constants
+ * @{
+ */
+
+#define CAN_InitStatus_Failed ((uint8_t)0x00) /*!< CAN initialization failed */
+#define CAN_InitStatus_Success ((uint8_t)0x01) /*!< CAN initialization OK */
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Mode
+ * @{
+ */
+
+#define CAN_Mode_Normal ((uint8_t)0x00) /*!< normal mode */
+#define CAN_Mode_LoopBack ((uint8_t)0x01) /*!< loopback mode */
+#define CAN_Mode_Silent ((uint8_t)0x02) /*!< silent mode */
+#define CAN_Mode_Silent_LoopBack ((uint8_t)0x03) /*!< loopback combined with silent mode */
+
+#define IS_CAN_MODE(MODE) (((MODE) == CAN_Mode_Normal) || \
+ ((MODE) == CAN_Mode_LoopBack)|| \
+ ((MODE) == CAN_Mode_Silent) || \
+ ((MODE) == CAN_Mode_Silent_LoopBack))
+/**
+ * @}
+ */
+
+
+/**
+ * @defgroup CAN_Operating_Mode
+ * @{
+ */
+#define CAN_OperatingMode_Initialization ((uint8_t)0x00) /*!< Initialization mode */
+#define CAN_OperatingMode_Normal ((uint8_t)0x01) /*!< Normal mode */
+#define CAN_OperatingMode_Sleep ((uint8_t)0x02) /*!< sleep mode */
+
+
+#define IS_CAN_OPERATING_MODE(MODE) (((MODE) == CAN_OperatingMode_Initialization) ||\
+ ((MODE) == CAN_OperatingMode_Normal)|| \
+ ((MODE) == CAN_OperatingMode_Sleep))
+/**
+ * @}
+ */
+
+/**
+ * @defgroup CAN_Mode_Status
+ * @{
+ */
+
+#define CAN_ModeStatus_Failed ((uint8_t)0x00) /*!< CAN entering the specific mode failed */
+#define CAN_ModeStatus_Success ((uint8_t)!CAN_ModeStatus_Failed) /*!< CAN entering the specific mode Succeed */
+
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_synchronisation_jump_width
+ * @{
+ */
+
+#define CAN_SJW_1tq ((uint8_t)0x00) /*!< 1 time quantum */
+#define CAN_SJW_2tq ((uint8_t)0x01) /*!< 2 time quantum */
+#define CAN_SJW_3tq ((uint8_t)0x02) /*!< 3 time quantum */
+#define CAN_SJW_4tq ((uint8_t)0x03) /*!< 4 time quantum */
+
+#define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1tq) || ((SJW) == CAN_SJW_2tq)|| \
+ ((SJW) == CAN_SJW_3tq) || ((SJW) == CAN_SJW_4tq))
+/**
+ * @}
+ */
+
+/** @defgroup CAN_time_quantum_in_bit_segment_1
+ * @{
+ */
+
+#define CAN_BS1_1tq ((uint8_t)0x00) /*!< 1 time quantum */
+#define CAN_BS1_2tq ((uint8_t)0x01) /*!< 2 time quantum */
+#define CAN_BS1_3tq ((uint8_t)0x02) /*!< 3 time quantum */
+#define CAN_BS1_4tq ((uint8_t)0x03) /*!< 4 time quantum */
+#define CAN_BS1_5tq ((uint8_t)0x04) /*!< 5 time quantum */
+#define CAN_BS1_6tq ((uint8_t)0x05) /*!< 6 time quantum */
+#define CAN_BS1_7tq ((uint8_t)0x06) /*!< 7 time quantum */
+#define CAN_BS1_8tq ((uint8_t)0x07) /*!< 8 time quantum */
+#define CAN_BS1_9tq ((uint8_t)0x08) /*!< 9 time quantum */
+#define CAN_BS1_10tq ((uint8_t)0x09) /*!< 10 time quantum */
+#define CAN_BS1_11tq ((uint8_t)0x0A) /*!< 11 time quantum */
+#define CAN_BS1_12tq ((uint8_t)0x0B) /*!< 12 time quantum */
+#define CAN_BS1_13tq ((uint8_t)0x0C) /*!< 13 time quantum */
+#define CAN_BS1_14tq ((uint8_t)0x0D) /*!< 14 time quantum */
+#define CAN_BS1_15tq ((uint8_t)0x0E) /*!< 15 time quantum */
+#define CAN_BS1_16tq ((uint8_t)0x0F) /*!< 16 time quantum */
+
+#define IS_CAN_BS1(BS1) ((BS1) <= CAN_BS1_16tq)
+/**
+ * @}
+ */
+
+/** @defgroup CAN_time_quantum_in_bit_segment_2
+ * @{
+ */
+
+#define CAN_BS2_1tq ((uint8_t)0x00) /*!< 1 time quantum */
+#define CAN_BS2_2tq ((uint8_t)0x01) /*!< 2 time quantum */
+#define CAN_BS2_3tq ((uint8_t)0x02) /*!< 3 time quantum */
+#define CAN_BS2_4tq ((uint8_t)0x03) /*!< 4 time quantum */
+#define CAN_BS2_5tq ((uint8_t)0x04) /*!< 5 time quantum */
+#define CAN_BS2_6tq ((uint8_t)0x05) /*!< 6 time quantum */
+#define CAN_BS2_7tq ((uint8_t)0x06) /*!< 7 time quantum */
+#define CAN_BS2_8tq ((uint8_t)0x07) /*!< 8 time quantum */
+
+#define IS_CAN_BS2(BS2) ((BS2) <= CAN_BS2_8tq)
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_clock_prescaler
+ * @{
+ */
+
+#define IS_CAN_PRESCALER(PRESCALER) (((PRESCALER) >= 1) && ((PRESCALER) <= 1024))
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_filter_number
+ * @{
+ */
+#ifndef STM32F10X_CL
+ #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 13)
+#else
+ #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 27)
+#endif /* STM32F10X_CL */
+/**
+ * @}
+ */
+
+/** @defgroup CAN_filter_mode
+ * @{
+ */
+
+#define CAN_FilterMode_IdMask ((uint8_t)0x00) /*!< identifier/mask mode */
+#define CAN_FilterMode_IdList ((uint8_t)0x01) /*!< identifier list mode */
+
+#define IS_CAN_FILTER_MODE(MODE) (((MODE) == CAN_FilterMode_IdMask) || \
+ ((MODE) == CAN_FilterMode_IdList))
+/**
+ * @}
+ */
+
+/** @defgroup CAN_filter_scale
+ * @{
+ */
+
+#define CAN_FilterScale_16bit ((uint8_t)0x00) /*!< Two 16-bit filters */
+#define CAN_FilterScale_32bit ((uint8_t)0x01) /*!< One 32-bit filter */
+
+#define IS_CAN_FILTER_SCALE(SCALE) (((SCALE) == CAN_FilterScale_16bit) || \
+ ((SCALE) == CAN_FilterScale_32bit))
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_filter_FIFO
+ * @{
+ */
+
+#define CAN_Filter_FIFO0 ((uint8_t)0x00) /*!< Filter FIFO 0 assignment for filter x */
+#define CAN_Filter_FIFO1 ((uint8_t)0x01) /*!< Filter FIFO 1 assignment for filter x */
+#define IS_CAN_FILTER_FIFO(FIFO) (((FIFO) == CAN_FilterFIFO0) || \
+ ((FIFO) == CAN_FilterFIFO1))
+/**
+ * @}
+ */
+
+/** @defgroup Start_bank_filter_for_slave_CAN
+ * @{
+ */
+#define IS_CAN_BANKNUMBER(BANKNUMBER) (((BANKNUMBER) >= 1) && ((BANKNUMBER) <= 27))
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Tx
+ * @{
+ */
+
+#define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX) ((TRANSMITMAILBOX) <= ((uint8_t)0x02))
+#define IS_CAN_STDID(STDID) ((STDID) <= ((uint32_t)0x7FF))
+#define IS_CAN_EXTID(EXTID) ((EXTID) <= ((uint32_t)0x1FFFFFFF))
+#define IS_CAN_DLC(DLC) ((DLC) <= ((uint8_t)0x08))
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_identifier_type
+ * @{
+ */
+
+#define CAN_Id_Standard ((uint32_t)0x00000000) /*!< Standard Id */
+#define CAN_Id_Extended ((uint32_t)0x00000004) /*!< Extended Id */
+#define IS_CAN_IDTYPE(IDTYPE) (((IDTYPE) == CAN_Id_Standard) || \
+ ((IDTYPE) == CAN_Id_Extended))
+/**
+ * @}
+ */
+
+/** @defgroup CAN_remote_transmission_request
+ * @{
+ */
+
+#define CAN_RTR_Data ((uint32_t)0x00000000) /*!< Data frame */
+#define CAN_RTR_Remote ((uint32_t)0x00000002) /*!< Remote frame */
+#define IS_CAN_RTR(RTR) (((RTR) == CAN_RTR_Data) || ((RTR) == CAN_RTR_Remote))
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_transmit_constants
+ * @{
+ */
+
+#define CAN_TxStatus_Failed ((uint8_t)0x00)/*!< CAN transmission failed */
+#define CAN_TxStatus_Ok ((uint8_t)0x01) /*!< CAN transmission succeeded */
+#define CAN_TxStatus_Pending ((uint8_t)0x02) /*!< CAN transmission pending */
+#define CAN_TxStatus_NoMailBox ((uint8_t)0x04) /*!< CAN cell did not provide an empty mailbox */
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_receive_FIFO_number_constants
+ * @{
+ */
+
+#define CAN_FIFO0 ((uint8_t)0x00) /*!< CAN FIFO 0 used to receive */
+#define CAN_FIFO1 ((uint8_t)0x01) /*!< CAN FIFO 1 used to receive */
+
+#define IS_CAN_FIFO(FIFO) (((FIFO) == CAN_FIFO0) || ((FIFO) == CAN_FIFO1))
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_sleep_constants
+ * @{
+ */
+
+#define CAN_Sleep_Failed ((uint8_t)0x00) /*!< CAN did not enter the sleep mode */
+#define CAN_Sleep_Ok ((uint8_t)0x01) /*!< CAN entered the sleep mode */
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_wake_up_constants
+ * @{
+ */
+
+#define CAN_WakeUp_Failed ((uint8_t)0x00) /*!< CAN did not leave the sleep mode */
+#define CAN_WakeUp_Ok ((uint8_t)0x01) /*!< CAN leaved the sleep mode */
+
+/**
+ * @}
+ */
+
+/**
+ * @defgroup CAN_Error_Code_constants
+ * @{
+ */
+
+#define CAN_ErrorCode_NoErr ((uint8_t)0x00) /*!< No Error */
+#define CAN_ErrorCode_StuffErr ((uint8_t)0x10) /*!< Stuff Error */
+#define CAN_ErrorCode_FormErr ((uint8_t)0x20) /*!< Form Error */
+#define CAN_ErrorCode_ACKErr ((uint8_t)0x30) /*!< Acknowledgment Error */
+#define CAN_ErrorCode_BitRecessiveErr ((uint8_t)0x40) /*!< Bit Recessive Error */
+#define CAN_ErrorCode_BitDominantErr ((uint8_t)0x50) /*!< Bit Dominant Error */
+#define CAN_ErrorCode_CRCErr ((uint8_t)0x60) /*!< CRC Error */
+#define CAN_ErrorCode_SoftwareSetErr ((uint8_t)0x70) /*!< Software Set Error */
+
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_flags
+ * @{
+ */
+/* If the flag is 0x3XXXXXXX, it means that it can be used with CAN_GetFlagStatus()
+ and CAN_ClearFlag() functions. */
+/* If the flag is 0x1XXXXXXX, it means that it can only be used with CAN_GetFlagStatus() function. */
+
+/* Transmit Flags */
+#define CAN_FLAG_RQCP0 ((uint32_t)0x38000001) /*!< Request MailBox0 Flag */
+#define CAN_FLAG_RQCP1 ((uint32_t)0x38000100) /*!< Request MailBox1 Flag */
+#define CAN_FLAG_RQCP2 ((uint32_t)0x38010000) /*!< Request MailBox2 Flag */
+
+/* Receive Flags */
+#define CAN_FLAG_FMP0 ((uint32_t)0x12000003) /*!< FIFO 0 Message Pending Flag */
+#define CAN_FLAG_FF0 ((uint32_t)0x32000008) /*!< FIFO 0 Full Flag */
+#define CAN_FLAG_FOV0 ((uint32_t)0x32000010) /*!< FIFO 0 Overrun Flag */
+#define CAN_FLAG_FMP1 ((uint32_t)0x14000003) /*!< FIFO 1 Message Pending Flag */
+#define CAN_FLAG_FF1 ((uint32_t)0x34000008) /*!< FIFO 1 Full Flag */
+#define CAN_FLAG_FOV1 ((uint32_t)0x34000010) /*!< FIFO 1 Overrun Flag */
+
+/* Operating Mode Flags */
+#define CAN_FLAG_WKU ((uint32_t)0x31000008) /*!< Wake up Flag */
+#define CAN_FLAG_SLAK ((uint32_t)0x31000012) /*!< Sleep acknowledge Flag */
+/* Note: When SLAK intterupt is disabled (SLKIE=0), no polling on SLAKI is possible.
+ In this case the SLAK bit can be polled.*/
+
+/* Error Flags */
+#define CAN_FLAG_EWG ((uint32_t)0x10F00001) /*!< Error Warning Flag */
+#define CAN_FLAG_EPV ((uint32_t)0x10F00002) /*!< Error Passive Flag */
+#define CAN_FLAG_BOF ((uint32_t)0x10F00004) /*!< Bus-Off Flag */
+#define CAN_FLAG_LEC ((uint32_t)0x30F00070) /*!< Last error code Flag */
+
+#define IS_CAN_GET_FLAG(FLAG) (((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_BOF) || \
+ ((FLAG) == CAN_FLAG_EPV) || ((FLAG) == CAN_FLAG_EWG) || \
+ ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_FOV0) || \
+ ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FMP0) || \
+ ((FLAG) == CAN_FLAG_FOV1) || ((FLAG) == CAN_FLAG_FF1) || \
+ ((FLAG) == CAN_FLAG_FMP1) || ((FLAG) == CAN_FLAG_RQCP2) || \
+ ((FLAG) == CAN_FLAG_RQCP1)|| ((FLAG) == CAN_FLAG_RQCP0) || \
+ ((FLAG) == CAN_FLAG_SLAK ))
+
+#define IS_CAN_CLEAR_FLAG(FLAG)(((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_RQCP2) || \
+ ((FLAG) == CAN_FLAG_RQCP1) || ((FLAG) == CAN_FLAG_RQCP0) || \
+ ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FOV0) ||\
+ ((FLAG) == CAN_FLAG_FF1) || ((FLAG) == CAN_FLAG_FOV1) || \
+ ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_SLAK))
+/**
+ * @}
+ */
+
+
+/** @defgroup CAN_interrupts
+ * @{
+ */
+
+
+
+#define CAN_IT_TME ((uint32_t)0x00000001) /*!< Transmit mailbox empty Interrupt*/
+
+/* Receive Interrupts */
+#define CAN_IT_FMP0 ((uint32_t)0x00000002) /*!< FIFO 0 message pending Interrupt*/
+#define CAN_IT_FF0 ((uint32_t)0x00000004) /*!< FIFO 0 full Interrupt*/
+#define CAN_IT_FOV0 ((uint32_t)0x00000008) /*!< FIFO 0 overrun Interrupt*/
+#define CAN_IT_FMP1 ((uint32_t)0x00000010) /*!< FIFO 1 message pending Interrupt*/
+#define CAN_IT_FF1 ((uint32_t)0x00000020) /*!< FIFO 1 full Interrupt*/
+#define CAN_IT_FOV1 ((uint32_t)0x00000040) /*!< FIFO 1 overrun Interrupt*/
+
+/* Operating Mode Interrupts */
+#define CAN_IT_WKU ((uint32_t)0x00010000) /*!< Wake-up Interrupt*/
+#define CAN_IT_SLK ((uint32_t)0x00020000) /*!< Sleep acknowledge Interrupt*/
+
+/* Error Interrupts */
+#define CAN_IT_EWG ((uint32_t)0x00000100) /*!< Error warning Interrupt*/
+#define CAN_IT_EPV ((uint32_t)0x00000200) /*!< Error passive Interrupt*/
+#define CAN_IT_BOF ((uint32_t)0x00000400) /*!< Bus-off Interrupt*/
+#define CAN_IT_LEC ((uint32_t)0x00000800) /*!< Last error code Interrupt*/
+#define CAN_IT_ERR ((uint32_t)0x00008000) /*!< Error Interrupt*/
+
+/* Flags named as Interrupts : kept only for FW compatibility */
+#define CAN_IT_RQCP0 CAN_IT_TME
+#define CAN_IT_RQCP1 CAN_IT_TME
+#define CAN_IT_RQCP2 CAN_IT_TME
+
+
+#define IS_CAN_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FMP0) ||\
+ ((IT) == CAN_IT_FF0) || ((IT) == CAN_IT_FOV0) ||\
+ ((IT) == CAN_IT_FMP1) || ((IT) == CAN_IT_FF1) ||\
+ ((IT) == CAN_IT_FOV1) || ((IT) == CAN_IT_EWG) ||\
+ ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\
+ ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\
+ ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK))
+
+#define IS_CAN_CLEAR_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FF0) ||\
+ ((IT) == CAN_IT_FOV0)|| ((IT) == CAN_IT_FF1) ||\
+ ((IT) == CAN_IT_FOV1)|| ((IT) == CAN_IT_EWG) ||\
+ ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\
+ ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\
+ ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK))
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Legacy
+ * @{
+ */
+#define CANINITFAILED CAN_InitStatus_Failed
+#define CANINITOK CAN_InitStatus_Success
+#define CAN_FilterFIFO0 CAN_Filter_FIFO0
+#define CAN_FilterFIFO1 CAN_Filter_FIFO1
+#define CAN_ID_STD CAN_Id_Standard
+#define CAN_ID_EXT CAN_Id_Extended
+#define CAN_RTR_DATA CAN_RTR_Data
+#define CAN_RTR_REMOTE CAN_RTR_Remote
+#define CANTXFAILE CAN_TxStatus_Failed
+#define CANTXOK CAN_TxStatus_Ok
+#define CANTXPENDING CAN_TxStatus_Pending
+#define CAN_NO_MB CAN_TxStatus_NoMailBox
+#define CANSLEEPFAILED CAN_Sleep_Failed
+#define CANSLEEPOK CAN_Sleep_Ok
+#define CANWAKEUPFAILED CAN_WakeUp_Failed
+#define CANWAKEUPOK CAN_WakeUp_Ok
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Exported_Functions
+ * @{
+ */
+/* Function used to set the CAN configuration to the default reset state *****/
+void CAN_DeInit(CAN_TypeDef* CANx);
+
+/* Initialization and Configuration functions *********************************/
+uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct);
+void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct);
+void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct);
+void CAN_SlaveStartBank(uint8_t CAN_BankNumber);
+void CAN_DBGFreeze(CAN_TypeDef* CANx, FunctionalState NewState);
+void CAN_TTComModeCmd(CAN_TypeDef* CANx, FunctionalState NewState);
+
+/* Transmit functions *********************************************************/
+uint8_t CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage);
+uint8_t CAN_TransmitStatus(CAN_TypeDef* CANx, uint8_t TransmitMailbox);
+void CAN_CancelTransmit(CAN_TypeDef* CANx, uint8_t Mailbox);
+
+/* Receive functions **********************************************************/
+void CAN_Receive(CAN_TypeDef* CANx, uint8_t FIFONumber, CanRxMsg* RxMessage);
+void CAN_FIFORelease(CAN_TypeDef* CANx, uint8_t FIFONumber);
+uint8_t CAN_MessagePending(CAN_TypeDef* CANx, uint8_t FIFONumber);
+
+
+/* Operation modes functions **************************************************/
+uint8_t CAN_OperatingModeRequest(CAN_TypeDef* CANx, uint8_t CAN_OperatingMode);
+uint8_t CAN_Sleep(CAN_TypeDef* CANx);
+uint8_t CAN_WakeUp(CAN_TypeDef* CANx);
+
+/* Error management functions *************************************************/
+uint8_t CAN_GetLastErrorCode(CAN_TypeDef* CANx);
+uint8_t CAN_GetReceiveErrorCounter(CAN_TypeDef* CANx);
+uint8_t CAN_GetLSBTransmitErrorCounter(CAN_TypeDef* CANx);
+
+/* Interrupts and flags management functions **********************************/
+void CAN_ITConfig(CAN_TypeDef* CANx, uint32_t CAN_IT, FunctionalState NewState);
+FlagStatus CAN_GetFlagStatus(CAN_TypeDef* CANx, uint32_t CAN_FLAG);
+void CAN_ClearFlag(CAN_TypeDef* CANx, uint32_t CAN_FLAG);
+ITStatus CAN_GetITStatus(CAN_TypeDef* CANx, uint32_t CAN_IT);
+void CAN_ClearITPendingBit(CAN_TypeDef* CANx, uint32_t CAN_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_CAN_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_cec.h b/st_fw_lib/inc/stm32f10x_cec.h
new file mode 100644
index 0000000..7ce6896
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_cec.h
@@ -0,0 +1,210 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_cec.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the CEC firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_CEC_H
+#define __STM32F10x_CEC_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup CEC
+ * @{
+ */
+
+
+/** @defgroup CEC_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief CEC Init structure definition
+ */
+typedef struct
+{
+ uint16_t CEC_BitTimingMode; /*!< Configures the CEC Bit Timing Error Mode.
+ This parameter can be a value of @ref CEC_BitTiming_Mode */
+ uint16_t CEC_BitPeriodMode; /*!< Configures the CEC Bit Period Error Mode.
+ This parameter can be a value of @ref CEC_BitPeriod_Mode */
+}CEC_InitTypeDef;
+
+/**
+ * @}
+ */
+
+/** @defgroup CEC_Exported_Constants
+ * @{
+ */
+
+/** @defgroup CEC_BitTiming_Mode
+ * @{
+ */
+#define CEC_BitTimingStdMode ((uint16_t)0x00) /*!< Bit timing error Standard Mode */
+#define CEC_BitTimingErrFreeMode CEC_CFGR_BTEM /*!< Bit timing error Free Mode */
+
+#define IS_CEC_BIT_TIMING_ERROR_MODE(MODE) (((MODE) == CEC_BitTimingStdMode) || \
+ ((MODE) == CEC_BitTimingErrFreeMode))
+/**
+ * @}
+ */
+
+/** @defgroup CEC_BitPeriod_Mode
+ * @{
+ */
+#define CEC_BitPeriodStdMode ((uint16_t)0x00) /*!< Bit period error Standard Mode */
+#define CEC_BitPeriodFlexibleMode CEC_CFGR_BPEM /*!< Bit period error Flexible Mode */
+
+#define IS_CEC_BIT_PERIOD_ERROR_MODE(MODE) (((MODE) == CEC_BitPeriodStdMode) || \
+ ((MODE) == CEC_BitPeriodFlexibleMode))
+/**
+ * @}
+ */
+
+
+/** @defgroup CEC_interrupts_definition
+ * @{
+ */
+#define CEC_IT_TERR CEC_CSR_TERR
+#define CEC_IT_TBTRF CEC_CSR_TBTRF
+#define CEC_IT_RERR CEC_CSR_RERR
+#define CEC_IT_RBTF CEC_CSR_RBTF
+#define IS_CEC_GET_IT(IT) (((IT) == CEC_IT_TERR) || ((IT) == CEC_IT_TBTRF) || \
+ ((IT) == CEC_IT_RERR) || ((IT) == CEC_IT_RBTF))
+/**
+ * @}
+ */
+
+
+/** @defgroup CEC_Own_Address
+ * @{
+ */
+#define IS_CEC_ADDRESS(ADDRESS) ((ADDRESS) < 0x10)
+/**
+ * @}
+ */
+
+/** @defgroup CEC_Prescaler
+ * @{
+ */
+#define IS_CEC_PRESCALER(PRESCALER) ((PRESCALER) <= 0x3FFF)
+
+/**
+ * @}
+ */
+
+/** @defgroup CEC_flags_definition
+ * @{
+ */
+
+/**
+ * @brief ESR register flags
+ */
+#define CEC_FLAG_BTE ((uint32_t)0x10010000)
+#define CEC_FLAG_BPE ((uint32_t)0x10020000)
+#define CEC_FLAG_RBTFE ((uint32_t)0x10040000)
+#define CEC_FLAG_SBE ((uint32_t)0x10080000)
+#define CEC_FLAG_ACKE ((uint32_t)0x10100000)
+#define CEC_FLAG_LINE ((uint32_t)0x10200000)
+#define CEC_FLAG_TBTFE ((uint32_t)0x10400000)
+
+/**
+ * @brief CSR register flags
+ */
+#define CEC_FLAG_TEOM ((uint32_t)0x00000002)
+#define CEC_FLAG_TERR ((uint32_t)0x00000004)
+#define CEC_FLAG_TBTRF ((uint32_t)0x00000008)
+#define CEC_FLAG_RSOM ((uint32_t)0x00000010)
+#define CEC_FLAG_REOM ((uint32_t)0x00000020)
+#define CEC_FLAG_RERR ((uint32_t)0x00000040)
+#define CEC_FLAG_RBTF ((uint32_t)0x00000080)
+
+#define IS_CEC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFF03) == 0x00) && ((FLAG) != 0x00))
+
+#define IS_CEC_GET_FLAG(FLAG) (((FLAG) == CEC_FLAG_BTE) || ((FLAG) == CEC_FLAG_BPE) || \
+ ((FLAG) == CEC_FLAG_RBTFE) || ((FLAG)== CEC_FLAG_SBE) || \
+ ((FLAG) == CEC_FLAG_ACKE) || ((FLAG) == CEC_FLAG_LINE) || \
+ ((FLAG) == CEC_FLAG_TBTFE) || ((FLAG) == CEC_FLAG_TEOM) || \
+ ((FLAG) == CEC_FLAG_TERR) || ((FLAG) == CEC_FLAG_TBTRF) || \
+ ((FLAG) == CEC_FLAG_RSOM) || ((FLAG) == CEC_FLAG_REOM) || \
+ ((FLAG) == CEC_FLAG_RERR) || ((FLAG) == CEC_FLAG_RBTF))
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CEC_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CEC_Exported_Functions
+ * @{
+ */
+void CEC_DeInit(void);
+void CEC_Init(CEC_InitTypeDef* CEC_InitStruct);
+void CEC_Cmd(FunctionalState NewState);
+void CEC_ITConfig(FunctionalState NewState);
+void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress);
+void CEC_SetPrescaler(uint16_t CEC_Prescaler);
+void CEC_SendDataByte(uint8_t Data);
+uint8_t CEC_ReceiveDataByte(void);
+void CEC_StartOfMessage(void);
+void CEC_EndOfMessageCmd(FunctionalState NewState);
+FlagStatus CEC_GetFlagStatus(uint32_t CEC_FLAG);
+void CEC_ClearFlag(uint32_t CEC_FLAG);
+ITStatus CEC_GetITStatus(uint8_t CEC_IT);
+void CEC_ClearITPendingBit(uint16_t CEC_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_CEC_H */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_crc.h b/st_fw_lib/inc/stm32f10x_crc.h
new file mode 100644
index 0000000..3362fca
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_crc.h
@@ -0,0 +1,94 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_crc.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the CRC firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_CRC_H
+#define __STM32F10x_CRC_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup CRC
+ * @{
+ */
+
+/** @defgroup CRC_Exported_Types
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CRC_Exported_Constants
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CRC_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CRC_Exported_Functions
+ * @{
+ */
+
+void CRC_ResetDR(void);
+uint32_t CRC_CalcCRC(uint32_t Data);
+uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength);
+uint32_t CRC_GetCRC(void);
+void CRC_SetIDRegister(uint8_t IDValue);
+uint8_t CRC_GetIDRegister(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_CRC_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_dac.h b/st_fw_lib/inc/stm32f10x_dac.h
new file mode 100644
index 0000000..174773c
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_dac.h
@@ -0,0 +1,317 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_dac.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the DAC firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_DAC_H
+#define __STM32F10x_DAC_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup DAC
+ * @{
+ */
+
+/** @defgroup DAC_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief DAC Init structure definition
+ */
+
+typedef struct
+{
+ uint32_t DAC_Trigger; /*!< Specifies the external trigger for the selected DAC channel.
+ This parameter can be a value of @ref DAC_trigger_selection */
+
+ uint32_t DAC_WaveGeneration; /*!< Specifies whether DAC channel noise waves or triangle waves
+ are generated, or whether no wave is generated.
+ This parameter can be a value of @ref DAC_wave_generation */
+
+ uint32_t DAC_LFSRUnmask_TriangleAmplitude; /*!< Specifies the LFSR mask for noise wave generation or
+ the maximum amplitude triangle generation for the DAC channel.
+ This parameter can be a value of @ref DAC_lfsrunmask_triangleamplitude */
+
+ uint32_t DAC_OutputBuffer; /*!< Specifies whether the DAC channel output buffer is enabled or disabled.
+ This parameter can be a value of @ref DAC_output_buffer */
+}DAC_InitTypeDef;
+
+/**
+ * @}
+ */
+
+/** @defgroup DAC_Exported_Constants
+ * @{
+ */
+
+/** @defgroup DAC_trigger_selection
+ * @{
+ */
+
+#define DAC_Trigger_None ((uint32_t)0x00000000) /*!< Conversion is automatic once the DAC1_DHRxxxx register
+ has been loaded, and not by external trigger */
+#define DAC_Trigger_T6_TRGO ((uint32_t)0x00000004) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */
+#define DAC_Trigger_T8_TRGO ((uint32_t)0x0000000C) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel
+ only in High-density devices*/
+#define DAC_Trigger_T3_TRGO ((uint32_t)0x0000000C) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel
+ only in Connectivity line, Medium-density and Low-density Value Line devices */
+#define DAC_Trigger_T7_TRGO ((uint32_t)0x00000014) /*!< TIM7 TRGO selected as external conversion trigger for DAC channel */
+#define DAC_Trigger_T5_TRGO ((uint32_t)0x0000001C) /*!< TIM5 TRGO selected as external conversion trigger for DAC channel */
+#define DAC_Trigger_T15_TRGO ((uint32_t)0x0000001C) /*!< TIM15 TRGO selected as external conversion trigger for DAC channel
+ only in Medium-density and Low-density Value Line devices*/
+#define DAC_Trigger_T2_TRGO ((uint32_t)0x00000024) /*!< TIM2 TRGO selected as external conversion trigger for DAC channel */
+#define DAC_Trigger_T4_TRGO ((uint32_t)0x0000002C) /*!< TIM4 TRGO selected as external conversion trigger for DAC channel */
+#define DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034) /*!< EXTI Line9 event selected as external conversion trigger for DAC channel */
+#define DAC_Trigger_Software ((uint32_t)0x0000003C) /*!< Conversion started by software trigger for DAC channel */
+
+#define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \
+ ((TRIGGER) == DAC_Trigger_T6_TRGO) || \
+ ((TRIGGER) == DAC_Trigger_T8_TRGO) || \
+ ((TRIGGER) == DAC_Trigger_T7_TRGO) || \
+ ((TRIGGER) == DAC_Trigger_T5_TRGO) || \
+ ((TRIGGER) == DAC_Trigger_T2_TRGO) || \
+ ((TRIGGER) == DAC_Trigger_T4_TRGO) || \
+ ((TRIGGER) == DAC_Trigger_Ext_IT9) || \
+ ((TRIGGER) == DAC_Trigger_Software))
+
+/**
+ * @}
+ */
+
+/** @defgroup DAC_wave_generation
+ * @{
+ */
+
+#define DAC_WaveGeneration_None ((uint32_t)0x00000000)
+#define DAC_WaveGeneration_Noise ((uint32_t)0x00000040)
+#define DAC_WaveGeneration_Triangle ((uint32_t)0x00000080)
+#define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WaveGeneration_None) || \
+ ((WAVE) == DAC_WaveGeneration_Noise) || \
+ ((WAVE) == DAC_WaveGeneration_Triangle))
+/**
+ * @}
+ */
+
+/** @defgroup DAC_lfsrunmask_triangleamplitude
+ * @{
+ */
+
+#define DAC_LFSRUnmask_Bit0 ((uint32_t)0x00000000) /*!< Unmask DAC channel LFSR bit0 for noise wave generation */
+#define DAC_LFSRUnmask_Bits1_0 ((uint32_t)0x00000100) /*!< Unmask DAC channel LFSR bit[1:0] for noise wave generation */
+#define DAC_LFSRUnmask_Bits2_0 ((uint32_t)0x00000200) /*!< Unmask DAC channel LFSR bit[2:0] for noise wave generation */
+#define DAC_LFSRUnmask_Bits3_0 ((uint32_t)0x00000300) /*!< Unmask DAC channel LFSR bit[3:0] for noise wave generation */
+#define DAC_LFSRUnmask_Bits4_0 ((uint32_t)0x00000400) /*!< Unmask DAC channel LFSR bit[4:0] for noise wave generation */
+#define DAC_LFSRUnmask_Bits5_0 ((uint32_t)0x00000500) /*!< Unmask DAC channel LFSR bit[5:0] for noise wave generation */
+#define DAC_LFSRUnmask_Bits6_0 ((uint32_t)0x00000600) /*!< Unmask DAC channel LFSR bit[6:0] for noise wave generation */
+#define DAC_LFSRUnmask_Bits7_0 ((uint32_t)0x00000700) /*!< Unmask DAC channel LFSR bit[7:0] for noise wave generation */
+#define DAC_LFSRUnmask_Bits8_0 ((uint32_t)0x00000800) /*!< Unmask DAC channel LFSR bit[8:0] for noise wave generation */
+#define DAC_LFSRUnmask_Bits9_0 ((uint32_t)0x00000900) /*!< Unmask DAC channel LFSR bit[9:0] for noise wave generation */
+#define DAC_LFSRUnmask_Bits10_0 ((uint32_t)0x00000A00) /*!< Unmask DAC channel LFSR bit[10:0] for noise wave generation */
+#define DAC_LFSRUnmask_Bits11_0 ((uint32_t)0x00000B00) /*!< Unmask DAC channel LFSR bit[11:0] for noise wave generation */
+#define DAC_TriangleAmplitude_1 ((uint32_t)0x00000000) /*!< Select max triangle amplitude of 1 */
+#define DAC_TriangleAmplitude_3 ((uint32_t)0x00000100) /*!< Select max triangle amplitude of 3 */
+#define DAC_TriangleAmplitude_7 ((uint32_t)0x00000200) /*!< Select max triangle amplitude of 7 */
+#define DAC_TriangleAmplitude_15 ((uint32_t)0x00000300) /*!< Select max triangle amplitude of 15 */
+#define DAC_TriangleAmplitude_31 ((uint32_t)0x00000400) /*!< Select max triangle amplitude of 31 */
+#define DAC_TriangleAmplitude_63 ((uint32_t)0x00000500) /*!< Select max triangle amplitude of 63 */
+#define DAC_TriangleAmplitude_127 ((uint32_t)0x00000600) /*!< Select max triangle amplitude of 127 */
+#define DAC_TriangleAmplitude_255 ((uint32_t)0x00000700) /*!< Select max triangle amplitude of 255 */
+#define DAC_TriangleAmplitude_511 ((uint32_t)0x00000800) /*!< Select max triangle amplitude of 511 */
+#define DAC_TriangleAmplitude_1023 ((uint32_t)0x00000900) /*!< Select max triangle amplitude of 1023 */
+#define DAC_TriangleAmplitude_2047 ((uint32_t)0x00000A00) /*!< Select max triangle amplitude of 2047 */
+#define DAC_TriangleAmplitude_4095 ((uint32_t)0x00000B00) /*!< Select max triangle amplitude of 4095 */
+
+#define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUnmask_Bit0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits1_0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits2_0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits3_0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits4_0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits5_0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits6_0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits7_0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits8_0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits9_0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits10_0) || \
+ ((VALUE) == DAC_LFSRUnmask_Bits11_0) || \
+ ((VALUE) == DAC_TriangleAmplitude_1) || \
+ ((VALUE) == DAC_TriangleAmplitude_3) || \
+ ((VALUE) == DAC_TriangleAmplitude_7) || \
+ ((VALUE) == DAC_TriangleAmplitude_15) || \
+ ((VALUE) == DAC_TriangleAmplitude_31) || \
+ ((VALUE) == DAC_TriangleAmplitude_63) || \
+ ((VALUE) == DAC_TriangleAmplitude_127) || \
+ ((VALUE) == DAC_TriangleAmplitude_255) || \
+ ((VALUE) == DAC_TriangleAmplitude_511) || \
+ ((VALUE) == DAC_TriangleAmplitude_1023) || \
+ ((VALUE) == DAC_TriangleAmplitude_2047) || \
+ ((VALUE) == DAC_TriangleAmplitude_4095))
+/**
+ * @}
+ */
+
+/** @defgroup DAC_output_buffer
+ * @{
+ */
+
+#define DAC_OutputBuffer_Enable ((uint32_t)0x00000000)
+#define DAC_OutputBuffer_Disable ((uint32_t)0x00000002)
+#define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OutputBuffer_Enable) || \
+ ((STATE) == DAC_OutputBuffer_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup DAC_Channel_selection
+ * @{
+ */
+
+#define DAC_Channel_1 ((uint32_t)0x00000000)
+#define DAC_Channel_2 ((uint32_t)0x00000010)
+#define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1) || \
+ ((CHANNEL) == DAC_Channel_2))
+/**
+ * @}
+ */
+
+/** @defgroup DAC_data_alignment
+ * @{
+ */
+
+#define DAC_Align_12b_R ((uint32_t)0x00000000)
+#define DAC_Align_12b_L ((uint32_t)0x00000004)
+#define DAC_Align_8b_R ((uint32_t)0x00000008)
+#define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \
+ ((ALIGN) == DAC_Align_12b_L) || \
+ ((ALIGN) == DAC_Align_8b_R))
+/**
+ * @}
+ */
+
+/** @defgroup DAC_wave_generation
+ * @{
+ */
+
+#define DAC_Wave_Noise ((uint32_t)0x00000040)
+#define DAC_Wave_Triangle ((uint32_t)0x00000080)
+#define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_Wave_Noise) || \
+ ((WAVE) == DAC_Wave_Triangle))
+/**
+ * @}
+ */
+
+/** @defgroup DAC_data
+ * @{
+ */
+
+#define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0)
+/**
+ * @}
+ */
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+/** @defgroup DAC_interrupts_definition
+ * @{
+ */
+
+#define DAC_IT_DMAUDR ((uint32_t)0x00002000)
+#define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR))
+
+/**
+ * @}
+ */
+
+/** @defgroup DAC_flags_definition
+ * @{
+ */
+
+#define DAC_FLAG_DMAUDR ((uint32_t)0x00002000)
+#define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR))
+
+/**
+ * @}
+ */
+#endif
+
+/**
+ * @}
+ */
+
+/** @defgroup DAC_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DAC_Exported_Functions
+ * @{
+ */
+
+void DAC_DeInit(void);
+void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct);
+void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct);
+void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState);
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState);
+#endif
+void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState);
+void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState);
+void DAC_DualSoftwareTriggerCmd(FunctionalState NewState);
+void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState);
+void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data);
+void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data);
+void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1);
+uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel);
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG);
+void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG);
+ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT);
+void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__STM32F10x_DAC_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_dbgmcu.h b/st_fw_lib/inc/stm32f10x_dbgmcu.h
new file mode 100644
index 0000000..89ceb9a
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_dbgmcu.h
@@ -0,0 +1,119 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_dbgmcu.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the DBGMCU
+ * firmware library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_DBGMCU_H
+#define __STM32F10x_DBGMCU_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup DBGMCU
+ * @{
+ */
+
+/** @defgroup DBGMCU_Exported_Types
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DBGMCU_Exported_Constants
+ * @{
+ */
+
+#define DBGMCU_SLEEP ((uint32_t)0x00000001)
+#define DBGMCU_STOP ((uint32_t)0x00000002)
+#define DBGMCU_STANDBY ((uint32_t)0x00000004)
+#define DBGMCU_IWDG_STOP ((uint32_t)0x00000100)
+#define DBGMCU_WWDG_STOP ((uint32_t)0x00000200)
+#define DBGMCU_TIM1_STOP ((uint32_t)0x00000400)
+#define DBGMCU_TIM2_STOP ((uint32_t)0x00000800)
+#define DBGMCU_TIM3_STOP ((uint32_t)0x00001000)
+#define DBGMCU_TIM4_STOP ((uint32_t)0x00002000)
+#define DBGMCU_CAN1_STOP ((uint32_t)0x00004000)
+#define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000)
+#define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000)
+#define DBGMCU_TIM8_STOP ((uint32_t)0x00020000)
+#define DBGMCU_TIM5_STOP ((uint32_t)0x00040000)
+#define DBGMCU_TIM6_STOP ((uint32_t)0x00080000)
+#define DBGMCU_TIM7_STOP ((uint32_t)0x00100000)
+#define DBGMCU_CAN2_STOP ((uint32_t)0x00200000)
+#define DBGMCU_TIM15_STOP ((uint32_t)0x00400000)
+#define DBGMCU_TIM16_STOP ((uint32_t)0x00800000)
+#define DBGMCU_TIM17_STOP ((uint32_t)0x01000000)
+#define DBGMCU_TIM12_STOP ((uint32_t)0x02000000)
+#define DBGMCU_TIM13_STOP ((uint32_t)0x04000000)
+#define DBGMCU_TIM14_STOP ((uint32_t)0x08000000)
+#define DBGMCU_TIM9_STOP ((uint32_t)0x10000000)
+#define DBGMCU_TIM10_STOP ((uint32_t)0x20000000)
+#define DBGMCU_TIM11_STOP ((uint32_t)0x40000000)
+
+#define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0x800000F8) == 0x00) && ((PERIPH) != 0x00))
+/**
+ * @}
+ */
+
+/** @defgroup DBGMCU_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DBGMCU_Exported_Functions
+ * @{
+ */
+
+uint32_t DBGMCU_GetREVID(void);
+uint32_t DBGMCU_GetDEVID(void);
+void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_DBGMCU_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_dma.h b/st_fw_lib/inc/stm32f10x_dma.h
new file mode 100644
index 0000000..14275fe
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_dma.h
@@ -0,0 +1,439 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_dma.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the DMA firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_DMA_H
+#define __STM32F10x_DMA_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup DMA
+ * @{
+ */
+
+/** @defgroup DMA_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief DMA Init structure definition
+ */
+
+typedef struct
+{
+ uint32_t DMA_PeripheralBaseAddr; /*!< Specifies the peripheral base address for DMAy Channelx. */
+
+ uint32_t DMA_MemoryBaseAddr; /*!< Specifies the memory base address for DMAy Channelx. */
+
+ uint32_t DMA_DIR; /*!< Specifies if the peripheral is the source or destination.
+ This parameter can be a value of @ref DMA_data_transfer_direction */
+
+ uint32_t DMA_BufferSize; /*!< Specifies the buffer size, in data unit, of the specified Channel.
+ The data unit is equal to the configuration set in DMA_PeripheralDataSize
+ or DMA_MemoryDataSize members depending in the transfer direction. */
+
+ uint32_t DMA_PeripheralInc; /*!< Specifies whether the Peripheral address register is incremented or not.
+ This parameter can be a value of @ref DMA_peripheral_incremented_mode */
+
+ uint32_t DMA_MemoryInc; /*!< Specifies whether the memory address register is incremented or not.
+ This parameter can be a value of @ref DMA_memory_incremented_mode */
+
+ uint32_t DMA_PeripheralDataSize; /*!< Specifies the Peripheral data width.
+ This parameter can be a value of @ref DMA_peripheral_data_size */
+
+ uint32_t DMA_MemoryDataSize; /*!< Specifies the Memory data width.
+ This parameter can be a value of @ref DMA_memory_data_size */
+
+ uint32_t DMA_Mode; /*!< Specifies the operation mode of the DMAy Channelx.
+ This parameter can be a value of @ref DMA_circular_normal_mode.
+ @note: The circular buffer mode cannot be used if the memory-to-memory
+ data transfer is configured on the selected Channel */
+
+ uint32_t DMA_Priority; /*!< Specifies the software priority for the DMAy Channelx.
+ This parameter can be a value of @ref DMA_priority_level */
+
+ uint32_t DMA_M2M; /*!< Specifies if the DMAy Channelx will be used in memory-to-memory transfer.
+ This parameter can be a value of @ref DMA_memory_to_memory */
+}DMA_InitTypeDef;
+
+/**
+ * @}
+ */
+
+/** @defgroup DMA_Exported_Constants
+ * @{
+ */
+
+#define IS_DMA_ALL_PERIPH(PERIPH) (((PERIPH) == DMA1_Channel1) || \
+ ((PERIPH) == DMA1_Channel2) || \
+ ((PERIPH) == DMA1_Channel3) || \
+ ((PERIPH) == DMA1_Channel4) || \
+ ((PERIPH) == DMA1_Channel5) || \
+ ((PERIPH) == DMA1_Channel6) || \
+ ((PERIPH) == DMA1_Channel7) || \
+ ((PERIPH) == DMA2_Channel1) || \
+ ((PERIPH) == DMA2_Channel2) || \
+ ((PERIPH) == DMA2_Channel3) || \
+ ((PERIPH) == DMA2_Channel4) || \
+ ((PERIPH) == DMA2_Channel5))
+
+/** @defgroup DMA_data_transfer_direction
+ * @{
+ */
+
+#define DMA_DIR_PeripheralDST ((uint32_t)0x00000010)
+#define DMA_DIR_PeripheralSRC ((uint32_t)0x00000000)
+#define IS_DMA_DIR(DIR) (((DIR) == DMA_DIR_PeripheralDST) || \
+ ((DIR) == DMA_DIR_PeripheralSRC))
+/**
+ * @}
+ */
+
+/** @defgroup DMA_peripheral_incremented_mode
+ * @{
+ */
+
+#define DMA_PeripheralInc_Enable ((uint32_t)0x00000040)
+#define DMA_PeripheralInc_Disable ((uint32_t)0x00000000)
+#define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PeripheralInc_Enable) || \
+ ((STATE) == DMA_PeripheralInc_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup DMA_memory_incremented_mode
+ * @{
+ */
+
+#define DMA_MemoryInc_Enable ((uint32_t)0x00000080)
+#define DMA_MemoryInc_Disable ((uint32_t)0x00000000)
+#define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MemoryInc_Enable) || \
+ ((STATE) == DMA_MemoryInc_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup DMA_peripheral_data_size
+ * @{
+ */
+
+#define DMA_PeripheralDataSize_Byte ((uint32_t)0x00000000)
+#define DMA_PeripheralDataSize_HalfWord ((uint32_t)0x00000100)
+#define DMA_PeripheralDataSize_Word ((uint32_t)0x00000200)
+#define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PeripheralDataSize_Byte) || \
+ ((SIZE) == DMA_PeripheralDataSize_HalfWord) || \
+ ((SIZE) == DMA_PeripheralDataSize_Word))
+/**
+ * @}
+ */
+
+/** @defgroup DMA_memory_data_size
+ * @{
+ */
+
+#define DMA_MemoryDataSize_Byte ((uint32_t)0x00000000)
+#define DMA_MemoryDataSize_HalfWord ((uint32_t)0x00000400)
+#define DMA_MemoryDataSize_Word ((uint32_t)0x00000800)
+#define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MemoryDataSize_Byte) || \
+ ((SIZE) == DMA_MemoryDataSize_HalfWord) || \
+ ((SIZE) == DMA_MemoryDataSize_Word))
+/**
+ * @}
+ */
+
+/** @defgroup DMA_circular_normal_mode
+ * @{
+ */
+
+#define DMA_Mode_Circular ((uint32_t)0x00000020)
+#define DMA_Mode_Normal ((uint32_t)0x00000000)
+#define IS_DMA_MODE(MODE) (((MODE) == DMA_Mode_Circular) || ((MODE) == DMA_Mode_Normal))
+/**
+ * @}
+ */
+
+/** @defgroup DMA_priority_level
+ * @{
+ */
+
+#define DMA_Priority_VeryHigh ((uint32_t)0x00003000)
+#define DMA_Priority_High ((uint32_t)0x00002000)
+#define DMA_Priority_Medium ((uint32_t)0x00001000)
+#define DMA_Priority_Low ((uint32_t)0x00000000)
+#define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_Priority_VeryHigh) || \
+ ((PRIORITY) == DMA_Priority_High) || \
+ ((PRIORITY) == DMA_Priority_Medium) || \
+ ((PRIORITY) == DMA_Priority_Low))
+/**
+ * @}
+ */
+
+/** @defgroup DMA_memory_to_memory
+ * @{
+ */
+
+#define DMA_M2M_Enable ((uint32_t)0x00004000)
+#define DMA_M2M_Disable ((uint32_t)0x00000000)
+#define IS_DMA_M2M_STATE(STATE) (((STATE) == DMA_M2M_Enable) || ((STATE) == DMA_M2M_Disable))
+
+/**
+ * @}
+ */
+
+/** @defgroup DMA_interrupts_definition
+ * @{
+ */
+
+#define DMA_IT_TC ((uint32_t)0x00000002)
+#define DMA_IT_HT ((uint32_t)0x00000004)
+#define DMA_IT_TE ((uint32_t)0x00000008)
+#define IS_DMA_CONFIG_IT(IT) ((((IT) & 0xFFFFFFF1) == 0x00) && ((IT) != 0x00))
+
+#define DMA1_IT_GL1 ((uint32_t)0x00000001)
+#define DMA1_IT_TC1 ((uint32_t)0x00000002)
+#define DMA1_IT_HT1 ((uint32_t)0x00000004)
+#define DMA1_IT_TE1 ((uint32_t)0x00000008)
+#define DMA1_IT_GL2 ((uint32_t)0x00000010)
+#define DMA1_IT_TC2 ((uint32_t)0x00000020)
+#define DMA1_IT_HT2 ((uint32_t)0x00000040)
+#define DMA1_IT_TE2 ((uint32_t)0x00000080)
+#define DMA1_IT_GL3 ((uint32_t)0x00000100)
+#define DMA1_IT_TC3 ((uint32_t)0x00000200)
+#define DMA1_IT_HT3 ((uint32_t)0x00000400)
+#define DMA1_IT_TE3 ((uint32_t)0x00000800)
+#define DMA1_IT_GL4 ((uint32_t)0x00001000)
+#define DMA1_IT_TC4 ((uint32_t)0x00002000)
+#define DMA1_IT_HT4 ((uint32_t)0x00004000)
+#define DMA1_IT_TE4 ((uint32_t)0x00008000)
+#define DMA1_IT_GL5 ((uint32_t)0x00010000)
+#define DMA1_IT_TC5 ((uint32_t)0x00020000)
+#define DMA1_IT_HT5 ((uint32_t)0x00040000)
+#define DMA1_IT_TE5 ((uint32_t)0x00080000)
+#define DMA1_IT_GL6 ((uint32_t)0x00100000)
+#define DMA1_IT_TC6 ((uint32_t)0x00200000)
+#define DMA1_IT_HT6 ((uint32_t)0x00400000)
+#define DMA1_IT_TE6 ((uint32_t)0x00800000)
+#define DMA1_IT_GL7 ((uint32_t)0x01000000)
+#define DMA1_IT_TC7 ((uint32_t)0x02000000)
+#define DMA1_IT_HT7 ((uint32_t)0x04000000)
+#define DMA1_IT_TE7 ((uint32_t)0x08000000)
+
+#define DMA2_IT_GL1 ((uint32_t)0x10000001)
+#define DMA2_IT_TC1 ((uint32_t)0x10000002)
+#define DMA2_IT_HT1 ((uint32_t)0x10000004)
+#define DMA2_IT_TE1 ((uint32_t)0x10000008)
+#define DMA2_IT_GL2 ((uint32_t)0x10000010)
+#define DMA2_IT_TC2 ((uint32_t)0x10000020)
+#define DMA2_IT_HT2 ((uint32_t)0x10000040)
+#define DMA2_IT_TE2 ((uint32_t)0x10000080)
+#define DMA2_IT_GL3 ((uint32_t)0x10000100)
+#define DMA2_IT_TC3 ((uint32_t)0x10000200)
+#define DMA2_IT_HT3 ((uint32_t)0x10000400)
+#define DMA2_IT_TE3 ((uint32_t)0x10000800)
+#define DMA2_IT_GL4 ((uint32_t)0x10001000)
+#define DMA2_IT_TC4 ((uint32_t)0x10002000)
+#define DMA2_IT_HT4 ((uint32_t)0x10004000)
+#define DMA2_IT_TE4 ((uint32_t)0x10008000)
+#define DMA2_IT_GL5 ((uint32_t)0x10010000)
+#define DMA2_IT_TC5 ((uint32_t)0x10020000)
+#define DMA2_IT_HT5 ((uint32_t)0x10040000)
+#define DMA2_IT_TE5 ((uint32_t)0x10080000)
+
+#define IS_DMA_CLEAR_IT(IT) (((((IT) & 0xF0000000) == 0x00) || (((IT) & 0xEFF00000) == 0x00)) && ((IT) != 0x00))
+
+#define IS_DMA_GET_IT(IT) (((IT) == DMA1_IT_GL1) || ((IT) == DMA1_IT_TC1) || \
+ ((IT) == DMA1_IT_HT1) || ((IT) == DMA1_IT_TE1) || \
+ ((IT) == DMA1_IT_GL2) || ((IT) == DMA1_IT_TC2) || \
+ ((IT) == DMA1_IT_HT2) || ((IT) == DMA1_IT_TE2) || \
+ ((IT) == DMA1_IT_GL3) || ((IT) == DMA1_IT_TC3) || \
+ ((IT) == DMA1_IT_HT3) || ((IT) == DMA1_IT_TE3) || \
+ ((IT) == DMA1_IT_GL4) || ((IT) == DMA1_IT_TC4) || \
+ ((IT) == DMA1_IT_HT4) || ((IT) == DMA1_IT_TE4) || \
+ ((IT) == DMA1_IT_GL5) || ((IT) == DMA1_IT_TC5) || \
+ ((IT) == DMA1_IT_HT5) || ((IT) == DMA1_IT_TE5) || \
+ ((IT) == DMA1_IT_GL6) || ((IT) == DMA1_IT_TC6) || \
+ ((IT) == DMA1_IT_HT6) || ((IT) == DMA1_IT_TE6) || \
+ ((IT) == DMA1_IT_GL7) || ((IT) == DMA1_IT_TC7) || \
+ ((IT) == DMA1_IT_HT7) || ((IT) == DMA1_IT_TE7) || \
+ ((IT) == DMA2_IT_GL1) || ((IT) == DMA2_IT_TC1) || \
+ ((IT) == DMA2_IT_HT1) || ((IT) == DMA2_IT_TE1) || \
+ ((IT) == DMA2_IT_GL2) || ((IT) == DMA2_IT_TC2) || \
+ ((IT) == DMA2_IT_HT2) || ((IT) == DMA2_IT_TE2) || \
+ ((IT) == DMA2_IT_GL3) || ((IT) == DMA2_IT_TC3) || \
+ ((IT) == DMA2_IT_HT3) || ((IT) == DMA2_IT_TE3) || \
+ ((IT) == DMA2_IT_GL4) || ((IT) == DMA2_IT_TC4) || \
+ ((IT) == DMA2_IT_HT4) || ((IT) == DMA2_IT_TE4) || \
+ ((IT) == DMA2_IT_GL5) || ((IT) == DMA2_IT_TC5) || \
+ ((IT) == DMA2_IT_HT5) || ((IT) == DMA2_IT_TE5))
+
+/**
+ * @}
+ */
+
+/** @defgroup DMA_flags_definition
+ * @{
+ */
+#define DMA1_FLAG_GL1 ((uint32_t)0x00000001)
+#define DMA1_FLAG_TC1 ((uint32_t)0x00000002)
+#define DMA1_FLAG_HT1 ((uint32_t)0x00000004)
+#define DMA1_FLAG_TE1 ((uint32_t)0x00000008)
+#define DMA1_FLAG_GL2 ((uint32_t)0x00000010)
+#define DMA1_FLAG_TC2 ((uint32_t)0x00000020)
+#define DMA1_FLAG_HT2 ((uint32_t)0x00000040)
+#define DMA1_FLAG_TE2 ((uint32_t)0x00000080)
+#define DMA1_FLAG_GL3 ((uint32_t)0x00000100)
+#define DMA1_FLAG_TC3 ((uint32_t)0x00000200)
+#define DMA1_FLAG_HT3 ((uint32_t)0x00000400)
+#define DMA1_FLAG_TE3 ((uint32_t)0x00000800)
+#define DMA1_FLAG_GL4 ((uint32_t)0x00001000)
+#define DMA1_FLAG_TC4 ((uint32_t)0x00002000)
+#define DMA1_FLAG_HT4 ((uint32_t)0x00004000)
+#define DMA1_FLAG_TE4 ((uint32_t)0x00008000)
+#define DMA1_FLAG_GL5 ((uint32_t)0x00010000)
+#define DMA1_FLAG_TC5 ((uint32_t)0x00020000)
+#define DMA1_FLAG_HT5 ((uint32_t)0x00040000)
+#define DMA1_FLAG_TE5 ((uint32_t)0x00080000)
+#define DMA1_FLAG_GL6 ((uint32_t)0x00100000)
+#define DMA1_FLAG_TC6 ((uint32_t)0x00200000)
+#define DMA1_FLAG_HT6 ((uint32_t)0x00400000)
+#define DMA1_FLAG_TE6 ((uint32_t)0x00800000)
+#define DMA1_FLAG_GL7 ((uint32_t)0x01000000)
+#define DMA1_FLAG_TC7 ((uint32_t)0x02000000)
+#define DMA1_FLAG_HT7 ((uint32_t)0x04000000)
+#define DMA1_FLAG_TE7 ((uint32_t)0x08000000)
+
+#define DMA2_FLAG_GL1 ((uint32_t)0x10000001)
+#define DMA2_FLAG_TC1 ((uint32_t)0x10000002)
+#define DMA2_FLAG_HT1 ((uint32_t)0x10000004)
+#define DMA2_FLAG_TE1 ((uint32_t)0x10000008)
+#define DMA2_FLAG_GL2 ((uint32_t)0x10000010)
+#define DMA2_FLAG_TC2 ((uint32_t)0x10000020)
+#define DMA2_FLAG_HT2 ((uint32_t)0x10000040)
+#define DMA2_FLAG_TE2 ((uint32_t)0x10000080)
+#define DMA2_FLAG_GL3 ((uint32_t)0x10000100)
+#define DMA2_FLAG_TC3 ((uint32_t)0x10000200)
+#define DMA2_FLAG_HT3 ((uint32_t)0x10000400)
+#define DMA2_FLAG_TE3 ((uint32_t)0x10000800)
+#define DMA2_FLAG_GL4 ((uint32_t)0x10001000)
+#define DMA2_FLAG_TC4 ((uint32_t)0x10002000)
+#define DMA2_FLAG_HT4 ((uint32_t)0x10004000)
+#define DMA2_FLAG_TE4 ((uint32_t)0x10008000)
+#define DMA2_FLAG_GL5 ((uint32_t)0x10010000)
+#define DMA2_FLAG_TC5 ((uint32_t)0x10020000)
+#define DMA2_FLAG_HT5 ((uint32_t)0x10040000)
+#define DMA2_FLAG_TE5 ((uint32_t)0x10080000)
+
+#define IS_DMA_CLEAR_FLAG(FLAG) (((((FLAG) & 0xF0000000) == 0x00) || (((FLAG) & 0xEFF00000) == 0x00)) && ((FLAG) != 0x00))
+
+#define IS_DMA_GET_FLAG(FLAG) (((FLAG) == DMA1_FLAG_GL1) || ((FLAG) == DMA1_FLAG_TC1) || \
+ ((FLAG) == DMA1_FLAG_HT1) || ((FLAG) == DMA1_FLAG_TE1) || \
+ ((FLAG) == DMA1_FLAG_GL2) || ((FLAG) == DMA1_FLAG_TC2) || \
+ ((FLAG) == DMA1_FLAG_HT2) || ((FLAG) == DMA1_FLAG_TE2) || \
+ ((FLAG) == DMA1_FLAG_GL3) || ((FLAG) == DMA1_FLAG_TC3) || \
+ ((FLAG) == DMA1_FLAG_HT3) || ((FLAG) == DMA1_FLAG_TE3) || \
+ ((FLAG) == DMA1_FLAG_GL4) || ((FLAG) == DMA1_FLAG_TC4) || \
+ ((FLAG) == DMA1_FLAG_HT4) || ((FLAG) == DMA1_FLAG_TE4) || \
+ ((FLAG) == DMA1_FLAG_GL5) || ((FLAG) == DMA1_FLAG_TC5) || \
+ ((FLAG) == DMA1_FLAG_HT5) || ((FLAG) == DMA1_FLAG_TE5) || \
+ ((FLAG) == DMA1_FLAG_GL6) || ((FLAG) == DMA1_FLAG_TC6) || \
+ ((FLAG) == DMA1_FLAG_HT6) || ((FLAG) == DMA1_FLAG_TE6) || \
+ ((FLAG) == DMA1_FLAG_GL7) || ((FLAG) == DMA1_FLAG_TC7) || \
+ ((FLAG) == DMA1_FLAG_HT7) || ((FLAG) == DMA1_FLAG_TE7) || \
+ ((FLAG) == DMA2_FLAG_GL1) || ((FLAG) == DMA2_FLAG_TC1) || \
+ ((FLAG) == DMA2_FLAG_HT1) || ((FLAG) == DMA2_FLAG_TE1) || \
+ ((FLAG) == DMA2_FLAG_GL2) || ((FLAG) == DMA2_FLAG_TC2) || \
+ ((FLAG) == DMA2_FLAG_HT2) || ((FLAG) == DMA2_FLAG_TE2) || \
+ ((FLAG) == DMA2_FLAG_GL3) || ((FLAG) == DMA2_FLAG_TC3) || \
+ ((FLAG) == DMA2_FLAG_HT3) || ((FLAG) == DMA2_FLAG_TE3) || \
+ ((FLAG) == DMA2_FLAG_GL4) || ((FLAG) == DMA2_FLAG_TC4) || \
+ ((FLAG) == DMA2_FLAG_HT4) || ((FLAG) == DMA2_FLAG_TE4) || \
+ ((FLAG) == DMA2_FLAG_GL5) || ((FLAG) == DMA2_FLAG_TC5) || \
+ ((FLAG) == DMA2_FLAG_HT5) || ((FLAG) == DMA2_FLAG_TE5))
+/**
+ * @}
+ */
+
+/** @defgroup DMA_Buffer_Size
+ * @{
+ */
+
+#define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1) && ((SIZE) < 0x10000))
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DMA_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DMA_Exported_Functions
+ * @{
+ */
+
+void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx);
+void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct);
+void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct);
+void DMA_Cmd(DMA_Channel_TypeDef* DMAy_Channelx, FunctionalState NewState);
+void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState);
+void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t DataNumber);
+uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx);
+FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG);
+void DMA_ClearFlag(uint32_t DMAy_FLAG);
+ITStatus DMA_GetITStatus(uint32_t DMAy_IT);
+void DMA_ClearITPendingBit(uint32_t DMAy_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__STM32F10x_DMA_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_exti.h b/st_fw_lib/inc/stm32f10x_exti.h
new file mode 100644
index 0000000..bb9d7f6
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_exti.h
@@ -0,0 +1,184 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_exti.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the EXTI firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_EXTI_H
+#define __STM32F10x_EXTI_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup EXTI
+ * @{
+ */
+
+/** @defgroup EXTI_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief EXTI mode enumeration
+ */
+
+typedef enum
+{
+ EXTI_Mode_Interrupt = 0x00,
+ EXTI_Mode_Event = 0x04
+}EXTIMode_TypeDef;
+
+#define IS_EXTI_MODE(MODE) (((MODE) == EXTI_Mode_Interrupt) || ((MODE) == EXTI_Mode_Event))
+
+/**
+ * @brief EXTI Trigger enumeration
+ */
+
+typedef enum
+{
+ EXTI_Trigger_Rising = 0x08,
+ EXTI_Trigger_Falling = 0x0C,
+ EXTI_Trigger_Rising_Falling = 0x10
+}EXTITrigger_TypeDef;
+
+#define IS_EXTI_TRIGGER(TRIGGER) (((TRIGGER) == EXTI_Trigger_Rising) || \
+ ((TRIGGER) == EXTI_Trigger_Falling) || \
+ ((TRIGGER) == EXTI_Trigger_Rising_Falling))
+/**
+ * @brief EXTI Init Structure definition
+ */
+
+typedef struct
+{
+ uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled.
+ This parameter can be any combination of @ref EXTI_Lines */
+
+ EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines.
+ This parameter can be a value of @ref EXTIMode_TypeDef */
+
+ EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines.
+ This parameter can be a value of @ref EXTIMode_TypeDef */
+
+ FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines.
+ This parameter can be set either to ENABLE or DISABLE */
+}EXTI_InitTypeDef;
+
+/**
+ * @}
+ */
+
+/** @defgroup EXTI_Exported_Constants
+ * @{
+ */
+
+/** @defgroup EXTI_Lines
+ * @{
+ */
+
+#define EXTI_Line0 ((uint32_t)0x00001) /*!< External interrupt line 0 */
+#define EXTI_Line1 ((uint32_t)0x00002) /*!< External interrupt line 1 */
+#define EXTI_Line2 ((uint32_t)0x00004) /*!< External interrupt line 2 */
+#define EXTI_Line3 ((uint32_t)0x00008) /*!< External interrupt line 3 */
+#define EXTI_Line4 ((uint32_t)0x00010) /*!< External interrupt line 4 */
+#define EXTI_Line5 ((uint32_t)0x00020) /*!< External interrupt line 5 */
+#define EXTI_Line6 ((uint32_t)0x00040) /*!< External interrupt line 6 */
+#define EXTI_Line7 ((uint32_t)0x00080) /*!< External interrupt line 7 */
+#define EXTI_Line8 ((uint32_t)0x00100) /*!< External interrupt line 8 */
+#define EXTI_Line9 ((uint32_t)0x00200) /*!< External interrupt line 9 */
+#define EXTI_Line10 ((uint32_t)0x00400) /*!< External interrupt line 10 */
+#define EXTI_Line11 ((uint32_t)0x00800) /*!< External interrupt line 11 */
+#define EXTI_Line12 ((uint32_t)0x01000) /*!< External interrupt line 12 */
+#define EXTI_Line13 ((uint32_t)0x02000) /*!< External interrupt line 13 */
+#define EXTI_Line14 ((uint32_t)0x04000) /*!< External interrupt line 14 */
+#define EXTI_Line15 ((uint32_t)0x08000) /*!< External interrupt line 15 */
+#define EXTI_Line16 ((uint32_t)0x10000) /*!< External interrupt line 16 Connected to the PVD Output */
+#define EXTI_Line17 ((uint32_t)0x20000) /*!< External interrupt line 17 Connected to the RTC Alarm event */
+#define EXTI_Line18 ((uint32_t)0x40000) /*!< External interrupt line 18 Connected to the USB Device/USB OTG FS
+ Wakeup from suspend event */
+#define EXTI_Line19 ((uint32_t)0x80000) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */
+
+#define IS_EXTI_LINE(LINE) ((((LINE) & (uint32_t)0xFFF00000) == 0x00) && ((LINE) != (uint16_t)0x00))
+#define IS_GET_EXTI_LINE(LINE) (((LINE) == EXTI_Line0) || ((LINE) == EXTI_Line1) || \
+ ((LINE) == EXTI_Line2) || ((LINE) == EXTI_Line3) || \
+ ((LINE) == EXTI_Line4) || ((LINE) == EXTI_Line5) || \
+ ((LINE) == EXTI_Line6) || ((LINE) == EXTI_Line7) || \
+ ((LINE) == EXTI_Line8) || ((LINE) == EXTI_Line9) || \
+ ((LINE) == EXTI_Line10) || ((LINE) == EXTI_Line11) || \
+ ((LINE) == EXTI_Line12) || ((LINE) == EXTI_Line13) || \
+ ((LINE) == EXTI_Line14) || ((LINE) == EXTI_Line15) || \
+ ((LINE) == EXTI_Line16) || ((LINE) == EXTI_Line17) || \
+ ((LINE) == EXTI_Line18) || ((LINE) == EXTI_Line19))
+
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup EXTI_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup EXTI_Exported_Functions
+ * @{
+ */
+
+void EXTI_DeInit(void);
+void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct);
+void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct);
+void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line);
+FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line);
+void EXTI_ClearFlag(uint32_t EXTI_Line);
+ITStatus EXTI_GetITStatus(uint32_t EXTI_Line);
+void EXTI_ClearITPendingBit(uint32_t EXTI_Line);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_EXTI_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_flash.h b/st_fw_lib/inc/stm32f10x_flash.h
new file mode 100644
index 0000000..63720de
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_flash.h
@@ -0,0 +1,426 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_flash.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the FLASH
+ * firmware library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_FLASH_H
+#define __STM32F10x_FLASH_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup FLASH
+ * @{
+ */
+
+/** @defgroup FLASH_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief FLASH Status
+ */
+
+typedef enum
+{
+ FLASH_BUSY = 1,
+ FLASH_ERROR_PG,
+ FLASH_ERROR_WRP,
+ FLASH_COMPLETE,
+ FLASH_TIMEOUT
+}FLASH_Status;
+
+/**
+ * @}
+ */
+
+/** @defgroup FLASH_Exported_Constants
+ * @{
+ */
+
+/** @defgroup Flash_Latency
+ * @{
+ */
+
+#define FLASH_Latency_0 ((uint32_t)0x00000000) /*!< FLASH Zero Latency cycle */
+#define FLASH_Latency_1 ((uint32_t)0x00000001) /*!< FLASH One Latency cycle */
+#define FLASH_Latency_2 ((uint32_t)0x00000002) /*!< FLASH Two Latency cycles */
+#define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \
+ ((LATENCY) == FLASH_Latency_1) || \
+ ((LATENCY) == FLASH_Latency_2))
+/**
+ * @}
+ */
+
+/** @defgroup Half_Cycle_Enable_Disable
+ * @{
+ */
+
+#define FLASH_HalfCycleAccess_Enable ((uint32_t)0x00000008) /*!< FLASH Half Cycle Enable */
+#define FLASH_HalfCycleAccess_Disable ((uint32_t)0x00000000) /*!< FLASH Half Cycle Disable */
+#define IS_FLASH_HALFCYCLEACCESS_STATE(STATE) (((STATE) == FLASH_HalfCycleAccess_Enable) || \
+ ((STATE) == FLASH_HalfCycleAccess_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup Prefetch_Buffer_Enable_Disable
+ * @{
+ */
+
+#define FLASH_PrefetchBuffer_Enable ((uint32_t)0x00000010) /*!< FLASH Prefetch Buffer Enable */
+#define FLASH_PrefetchBuffer_Disable ((uint32_t)0x00000000) /*!< FLASH Prefetch Buffer Disable */
+#define IS_FLASH_PREFETCHBUFFER_STATE(STATE) (((STATE) == FLASH_PrefetchBuffer_Enable) || \
+ ((STATE) == FLASH_PrefetchBuffer_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup Option_Bytes_Write_Protection
+ * @{
+ */
+
+/* Values to be used with STM32 Low and Medium density devices */
+#define FLASH_WRProt_Pages0to3 ((uint32_t)0x00000001) /*!< STM32 Low and Medium density devices: Write protection of page 0 to 3 */
+#define FLASH_WRProt_Pages4to7 ((uint32_t)0x00000002) /*!< STM32 Low and Medium density devices: Write protection of page 4 to 7 */
+#define FLASH_WRProt_Pages8to11 ((uint32_t)0x00000004) /*!< STM32 Low and Medium density devices: Write protection of page 8 to 11 */
+#define FLASH_WRProt_Pages12to15 ((uint32_t)0x00000008) /*!< STM32 Low and Medium density devices: Write protection of page 12 to 15 */
+#define FLASH_WRProt_Pages16to19 ((uint32_t)0x00000010) /*!< STM32 Low and Medium density devices: Write protection of page 16 to 19 */
+#define FLASH_WRProt_Pages20to23 ((uint32_t)0x00000020) /*!< STM32 Low and Medium density devices: Write protection of page 20 to 23 */
+#define FLASH_WRProt_Pages24to27 ((uint32_t)0x00000040) /*!< STM32 Low and Medium density devices: Write protection of page 24 to 27 */
+#define FLASH_WRProt_Pages28to31 ((uint32_t)0x00000080) /*!< STM32 Low and Medium density devices: Write protection of page 28 to 31 */
+
+/* Values to be used with STM32 Medium-density devices */
+#define FLASH_WRProt_Pages32to35 ((uint32_t)0x00000100) /*!< STM32 Medium-density devices: Write protection of page 32 to 35 */
+#define FLASH_WRProt_Pages36to39 ((uint32_t)0x00000200) /*!< STM32 Medium-density devices: Write protection of page 36 to 39 */
+#define FLASH_WRProt_Pages40to43 ((uint32_t)0x00000400) /*!< STM32 Medium-density devices: Write protection of page 40 to 43 */
+#define FLASH_WRProt_Pages44to47 ((uint32_t)0x00000800) /*!< STM32 Medium-density devices: Write protection of page 44 to 47 */
+#define FLASH_WRProt_Pages48to51 ((uint32_t)0x00001000) /*!< STM32 Medium-density devices: Write protection of page 48 to 51 */
+#define FLASH_WRProt_Pages52to55 ((uint32_t)0x00002000) /*!< STM32 Medium-density devices: Write protection of page 52 to 55 */
+#define FLASH_WRProt_Pages56to59 ((uint32_t)0x00004000) /*!< STM32 Medium-density devices: Write protection of page 56 to 59 */
+#define FLASH_WRProt_Pages60to63 ((uint32_t)0x00008000) /*!< STM32 Medium-density devices: Write protection of page 60 to 63 */
+#define FLASH_WRProt_Pages64to67 ((uint32_t)0x00010000) /*!< STM32 Medium-density devices: Write protection of page 64 to 67 */
+#define FLASH_WRProt_Pages68to71 ((uint32_t)0x00020000) /*!< STM32 Medium-density devices: Write protection of page 68 to 71 */
+#define FLASH_WRProt_Pages72to75 ((uint32_t)0x00040000) /*!< STM32 Medium-density devices: Write protection of page 72 to 75 */
+#define FLASH_WRProt_Pages76to79 ((uint32_t)0x00080000) /*!< STM32 Medium-density devices: Write protection of page 76 to 79 */
+#define FLASH_WRProt_Pages80to83 ((uint32_t)0x00100000) /*!< STM32 Medium-density devices: Write protection of page 80 to 83 */
+#define FLASH_WRProt_Pages84to87 ((uint32_t)0x00200000) /*!< STM32 Medium-density devices: Write protection of page 84 to 87 */
+#define FLASH_WRProt_Pages88to91 ((uint32_t)0x00400000) /*!< STM32 Medium-density devices: Write protection of page 88 to 91 */
+#define FLASH_WRProt_Pages92to95 ((uint32_t)0x00800000) /*!< STM32 Medium-density devices: Write protection of page 92 to 95 */
+#define FLASH_WRProt_Pages96to99 ((uint32_t)0x01000000) /*!< STM32 Medium-density devices: Write protection of page 96 to 99 */
+#define FLASH_WRProt_Pages100to103 ((uint32_t)0x02000000) /*!< STM32 Medium-density devices: Write protection of page 100 to 103 */
+#define FLASH_WRProt_Pages104to107 ((uint32_t)0x04000000) /*!< STM32 Medium-density devices: Write protection of page 104 to 107 */
+#define FLASH_WRProt_Pages108to111 ((uint32_t)0x08000000) /*!< STM32 Medium-density devices: Write protection of page 108 to 111 */
+#define FLASH_WRProt_Pages112to115 ((uint32_t)0x10000000) /*!< STM32 Medium-density devices: Write protection of page 112 to 115 */
+#define FLASH_WRProt_Pages116to119 ((uint32_t)0x20000000) /*!< STM32 Medium-density devices: Write protection of page 115 to 119 */
+#define FLASH_WRProt_Pages120to123 ((uint32_t)0x40000000) /*!< STM32 Medium-density devices: Write protection of page 120 to 123 */
+#define FLASH_WRProt_Pages124to127 ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 124 to 127 */
+
+/* Values to be used with STM32 High-density and STM32F10X Connectivity line devices */
+#define FLASH_WRProt_Pages0to1 ((uint32_t)0x00000001) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 0 to 1 */
+#define FLASH_WRProt_Pages2to3 ((uint32_t)0x00000002) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 2 to 3 */
+#define FLASH_WRProt_Pages4to5 ((uint32_t)0x00000004) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 4 to 5 */
+#define FLASH_WRProt_Pages6to7 ((uint32_t)0x00000008) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 6 to 7 */
+#define FLASH_WRProt_Pages8to9 ((uint32_t)0x00000010) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 8 to 9 */
+#define FLASH_WRProt_Pages10to11 ((uint32_t)0x00000020) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 10 to 11 */
+#define FLASH_WRProt_Pages12to13 ((uint32_t)0x00000040) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 12 to 13 */
+#define FLASH_WRProt_Pages14to15 ((uint32_t)0x00000080) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 14 to 15 */
+#define FLASH_WRProt_Pages16to17 ((uint32_t)0x00000100) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 16 to 17 */
+#define FLASH_WRProt_Pages18to19 ((uint32_t)0x00000200) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 18 to 19 */
+#define FLASH_WRProt_Pages20to21 ((uint32_t)0x00000400) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 20 to 21 */
+#define FLASH_WRProt_Pages22to23 ((uint32_t)0x00000800) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 22 to 23 */
+#define FLASH_WRProt_Pages24to25 ((uint32_t)0x00001000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 24 to 25 */
+#define FLASH_WRProt_Pages26to27 ((uint32_t)0x00002000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 26 to 27 */
+#define FLASH_WRProt_Pages28to29 ((uint32_t)0x00004000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 28 to 29 */
+#define FLASH_WRProt_Pages30to31 ((uint32_t)0x00008000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 30 to 31 */
+#define FLASH_WRProt_Pages32to33 ((uint32_t)0x00010000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 32 to 33 */
+#define FLASH_WRProt_Pages34to35 ((uint32_t)0x00020000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 34 to 35 */
+#define FLASH_WRProt_Pages36to37 ((uint32_t)0x00040000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 36 to 37 */
+#define FLASH_WRProt_Pages38to39 ((uint32_t)0x00080000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 38 to 39 */
+#define FLASH_WRProt_Pages40to41 ((uint32_t)0x00100000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 40 to 41 */
+#define FLASH_WRProt_Pages42to43 ((uint32_t)0x00200000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 42 to 43 */
+#define FLASH_WRProt_Pages44to45 ((uint32_t)0x00400000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 44 to 45 */
+#define FLASH_WRProt_Pages46to47 ((uint32_t)0x00800000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 46 to 47 */
+#define FLASH_WRProt_Pages48to49 ((uint32_t)0x01000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 48 to 49 */
+#define FLASH_WRProt_Pages50to51 ((uint32_t)0x02000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 50 to 51 */
+#define FLASH_WRProt_Pages52to53 ((uint32_t)0x04000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 52 to 53 */
+#define FLASH_WRProt_Pages54to55 ((uint32_t)0x08000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 54 to 55 */
+#define FLASH_WRProt_Pages56to57 ((uint32_t)0x10000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 56 to 57 */
+#define FLASH_WRProt_Pages58to59 ((uint32_t)0x20000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 58 to 59 */
+#define FLASH_WRProt_Pages60to61 ((uint32_t)0x40000000) /*!< STM32 High-density, XL-density and Connectivity line devices:
+ Write protection of page 60 to 61 */
+#define FLASH_WRProt_Pages62to127 ((uint32_t)0x80000000) /*!< STM32 Connectivity line devices: Write protection of page 62 to 127 */
+#define FLASH_WRProt_Pages62to255 ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 62 to 255 */
+#define FLASH_WRProt_Pages62to511 ((uint32_t)0x80000000) /*!< STM32 XL-density devices: Write protection of page 62 to 511 */
+
+#define FLASH_WRProt_AllPages ((uint32_t)0xFFFFFFFF) /*!< Write protection of all Pages */
+
+#define IS_FLASH_WRPROT_PAGE(PAGE) (((PAGE) != 0x00000000))
+
+#define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x080FFFFF))
+
+#define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806))
+
+/**
+ * @}
+ */
+
+/** @defgroup Option_Bytes_IWatchdog
+ * @{
+ */
+
+#define OB_IWDG_SW ((uint16_t)0x0001) /*!< Software IWDG selected */
+#define OB_IWDG_HW ((uint16_t)0x0000) /*!< Hardware IWDG selected */
+#define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
+
+/**
+ * @}
+ */
+
+/** @defgroup Option_Bytes_nRST_STOP
+ * @{
+ */
+
+#define OB_STOP_NoRST ((uint16_t)0x0002) /*!< No reset generated when entering in STOP */
+#define OB_STOP_RST ((uint16_t)0x0000) /*!< Reset generated when entering in STOP */
+#define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
+
+/**
+ * @}
+ */
+
+/** @defgroup Option_Bytes_nRST_STDBY
+ * @{
+ */
+
+#define OB_STDBY_NoRST ((uint16_t)0x0004) /*!< No reset generated when entering in STANDBY */
+#define OB_STDBY_RST ((uint16_t)0x0000) /*!< Reset generated when entering in STANDBY */
+#define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
+
+#ifdef STM32F10X_XL
+/**
+ * @}
+ */
+/** @defgroup FLASH_Boot
+ * @{
+ */
+#define FLASH_BOOT_Bank1 ((uint16_t)0x0000) /*!< At startup, if boot pins are set in boot from user Flash position
+ and this parameter is selected the device will boot from Bank1(Default) */
+#define FLASH_BOOT_Bank2 ((uint16_t)0x0001) /*!< At startup, if boot pins are set in boot from user Flash position
+ and this parameter is selected the device will boot from Bank 2 or Bank 1,
+ depending on the activation of the bank */
+#define IS_FLASH_BOOT(BOOT) (((BOOT) == FLASH_BOOT_Bank1) || ((BOOT) == FLASH_BOOT_Bank2))
+#endif
+/**
+ * @}
+ */
+/** @defgroup FLASH_Interrupts
+ * @{
+ */
+#ifdef STM32F10X_XL
+#define FLASH_IT_BANK2_ERROR ((uint32_t)0x80000400) /*!< FPEC BANK2 error interrupt source */
+#define FLASH_IT_BANK2_EOP ((uint32_t)0x80001000) /*!< End of FLASH BANK2 Operation Interrupt source */
+
+#define FLASH_IT_BANK1_ERROR FLASH_IT_ERROR /*!< FPEC BANK1 error interrupt source */
+#define FLASH_IT_BANK1_EOP FLASH_IT_EOP /*!< End of FLASH BANK1 Operation Interrupt source */
+
+#define FLASH_IT_ERROR ((uint32_t)0x00000400) /*!< FPEC BANK1 error interrupt source */
+#define FLASH_IT_EOP ((uint32_t)0x00001000) /*!< End of FLASH BANK1 Operation Interrupt source */
+#define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0x7FFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
+#else
+#define FLASH_IT_ERROR ((uint32_t)0x00000400) /*!< FPEC error interrupt source */
+#define FLASH_IT_EOP ((uint32_t)0x00001000) /*!< End of FLASH Operation Interrupt source */
+#define FLASH_IT_BANK1_ERROR FLASH_IT_ERROR /*!< FPEC BANK1 error interrupt source */
+#define FLASH_IT_BANK1_EOP FLASH_IT_EOP /*!< End of FLASH BANK1 Operation Interrupt source */
+
+#define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
+#endif
+
+/**
+ * @}
+ */
+
+/** @defgroup FLASH_Flags
+ * @{
+ */
+#ifdef STM32F10X_XL
+#define FLASH_FLAG_BANK2_BSY ((uint32_t)0x80000001) /*!< FLASH BANK2 Busy flag */
+#define FLASH_FLAG_BANK2_EOP ((uint32_t)0x80000020) /*!< FLASH BANK2 End of Operation flag */
+#define FLASH_FLAG_BANK2_PGERR ((uint32_t)0x80000004) /*!< FLASH BANK2 Program error flag */
+#define FLASH_FLAG_BANK2_WRPRTERR ((uint32_t)0x80000010) /*!< FLASH BANK2 Write protected error flag */
+
+#define FLASH_FLAG_BANK1_BSY FLASH_FLAG_BSY /*!< FLASH BANK1 Busy flag*/
+#define FLASH_FLAG_BANK1_EOP FLASH_FLAG_EOP /*!< FLASH BANK1 End of Operation flag */
+#define FLASH_FLAG_BANK1_PGERR FLASH_FLAG_PGERR /*!< FLASH BANK1 Program error flag */
+#define FLASH_FLAG_BANK1_WRPRTERR FLASH_FLAG_WRPRTERR /*!< FLASH BANK1 Write protected error flag */
+
+#define FLASH_FLAG_BSY ((uint32_t)0x00000001) /*!< FLASH Busy flag */
+#define FLASH_FLAG_EOP ((uint32_t)0x00000020) /*!< FLASH End of Operation flag */
+#define FLASH_FLAG_PGERR ((uint32_t)0x00000004) /*!< FLASH Program error flag */
+#define FLASH_FLAG_WRPRTERR ((uint32_t)0x00000010) /*!< FLASH Write protected error flag */
+#define FLASH_FLAG_OPTERR ((uint32_t)0x00000001) /*!< FLASH Option Byte error flag */
+
+#define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0x7FFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
+#define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
+ ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
+ ((FLAG) == FLASH_FLAG_OPTERR)|| \
+ ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \
+ ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \
+ ((FLAG) == FLASH_FLAG_BANK2_BSY) || ((FLAG) == FLASH_FLAG_BANK2_EOP) || \
+ ((FLAG) == FLASH_FLAG_BANK2_PGERR) || ((FLAG) == FLASH_FLAG_BANK2_WRPRTERR))
+#else
+#define FLASH_FLAG_BSY ((uint32_t)0x00000001) /*!< FLASH Busy flag */
+#define FLASH_FLAG_EOP ((uint32_t)0x00000020) /*!< FLASH End of Operation flag */
+#define FLASH_FLAG_PGERR ((uint32_t)0x00000004) /*!< FLASH Program error flag */
+#define FLASH_FLAG_WRPRTERR ((uint32_t)0x00000010) /*!< FLASH Write protected error flag */
+#define FLASH_FLAG_OPTERR ((uint32_t)0x00000001) /*!< FLASH Option Byte error flag */
+
+#define FLASH_FLAG_BANK1_BSY FLASH_FLAG_BSY /*!< FLASH BANK1 Busy flag*/
+#define FLASH_FLAG_BANK1_EOP FLASH_FLAG_EOP /*!< FLASH BANK1 End of Operation flag */
+#define FLASH_FLAG_BANK1_PGERR FLASH_FLAG_PGERR /*!< FLASH BANK1 Program error flag */
+#define FLASH_FLAG_BANK1_WRPRTERR FLASH_FLAG_WRPRTERR /*!< FLASH BANK1 Write protected error flag */
+
+#define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
+#define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
+ ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
+ ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \
+ ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \
+ ((FLAG) == FLASH_FLAG_OPTERR))
+#endif
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FLASH_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FLASH_Exported_Functions
+ * @{
+ */
+
+/*------------ Functions used for all STM32F10x devices -----*/
+void FLASH_SetLatency(uint32_t FLASH_Latency);
+void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess);
+void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer);
+void FLASH_Unlock(void);
+void FLASH_Lock(void);
+FLASH_Status FLASH_ErasePage(uint32_t Page_Address);
+FLASH_Status FLASH_EraseAllPages(void);
+FLASH_Status FLASH_EraseOptionBytes(void);
+FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
+FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
+FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data);
+FLASH_Status FLASH_EnableWriteProtection(uint32_t FLASH_Pages);
+FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState);
+FLASH_Status FLASH_UserOptionByteConfig(uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY);
+uint32_t FLASH_GetUserOptionByte(void);
+uint32_t FLASH_GetWriteProtectionOptionByte(void);
+FlagStatus FLASH_GetReadOutProtectionStatus(void);
+FlagStatus FLASH_GetPrefetchBufferStatus(void);
+void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);
+FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);
+void FLASH_ClearFlag(uint32_t FLASH_FLAG);
+FLASH_Status FLASH_GetStatus(void);
+FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout);
+
+/*------------ New function used for all STM32F10x devices -----*/
+void FLASH_UnlockBank1(void);
+void FLASH_LockBank1(void);
+FLASH_Status FLASH_EraseAllBank1Pages(void);
+FLASH_Status FLASH_GetBank1Status(void);
+FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout);
+
+#ifdef STM32F10X_XL
+/*---- New Functions used only with STM32F10x_XL density devices -----*/
+void FLASH_UnlockBank2(void);
+void FLASH_LockBank2(void);
+FLASH_Status FLASH_EraseAllBank2Pages(void);
+FLASH_Status FLASH_GetBank2Status(void);
+FLASH_Status FLASH_WaitForLastBank2Operation(uint32_t Timeout);
+FLASH_Status FLASH_BootConfig(uint16_t FLASH_BOOT);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_FLASH_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_fsmc.h b/st_fw_lib/inc/stm32f10x_fsmc.h
new file mode 100644
index 0000000..6e1769d
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_fsmc.h
@@ -0,0 +1,733 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_fsmc.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the FSMC firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_FSMC_H
+#define __STM32F10x_FSMC_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup FSMC
+ * @{
+ */
+
+/** @defgroup FSMC_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief Timing parameters For NOR/SRAM Banks
+ */
+
+typedef struct
+{
+ uint32_t FSMC_AddressSetupTime; /*!< Defines the number of HCLK cycles to configure
+ the duration of the address setup time.
+ This parameter can be a value between 0 and 0xF.
+ @note: It is not used with synchronous NOR Flash memories. */
+
+ uint32_t FSMC_AddressHoldTime; /*!< Defines the number of HCLK cycles to configure
+ the duration of the address hold time.
+ This parameter can be a value between 0 and 0xF.
+ @note: It is not used with synchronous NOR Flash memories.*/
+
+ uint32_t FSMC_DataSetupTime; /*!< Defines the number of HCLK cycles to configure
+ the duration of the data setup time.
+ This parameter can be a value between 0 and 0xFF.
+ @note: It is used for SRAMs, ROMs and asynchronous multiplexed NOR Flash memories. */
+
+ uint32_t FSMC_BusTurnAroundDuration; /*!< Defines the number of HCLK cycles to configure
+ the duration of the bus turnaround.
+ This parameter can be a value between 0 and 0xF.
+ @note: It is only used for multiplexed NOR Flash memories. */
+
+ uint32_t FSMC_CLKDivision; /*!< Defines the period of CLK clock output signal, expressed in number of HCLK cycles.
+ This parameter can be a value between 1 and 0xF.
+ @note: This parameter is not used for asynchronous NOR Flash, SRAM or ROM accesses. */
+
+ uint32_t FSMC_DataLatency; /*!< Defines the number of memory clock cycles to issue
+ to the memory before getting the first data.
+ The value of this parameter depends on the memory type as shown below:
+ - It must be set to 0 in case of a CRAM
+ - It is don't care in asynchronous NOR, SRAM or ROM accesses
+ - It may assume a value between 0 and 0xF in NOR Flash memories
+ with synchronous burst mode enable */
+
+ uint32_t FSMC_AccessMode; /*!< Specifies the asynchronous access mode.
+ This parameter can be a value of @ref FSMC_Access_Mode */
+}FSMC_NORSRAMTimingInitTypeDef;
+
+/**
+ * @brief FSMC NOR/SRAM Init structure definition
+ */
+
+typedef struct
+{
+ uint32_t FSMC_Bank; /*!< Specifies the NOR/SRAM memory bank that will be used.
+ This parameter can be a value of @ref FSMC_NORSRAM_Bank */
+
+ uint32_t FSMC_DataAddressMux; /*!< Specifies whether the address and data values are
+ multiplexed on the databus or not.
+ This parameter can be a value of @ref FSMC_Data_Address_Bus_Multiplexing */
+
+ uint32_t FSMC_MemoryType; /*!< Specifies the type of external memory attached to
+ the corresponding memory bank.
+ This parameter can be a value of @ref FSMC_Memory_Type */
+
+ uint32_t FSMC_MemoryDataWidth; /*!< Specifies the external memory device width.
+ This parameter can be a value of @ref FSMC_Data_Width */
+
+ uint32_t FSMC_BurstAccessMode; /*!< Enables or disables the burst access mode for Flash memory,
+ valid only with synchronous burst Flash memories.
+ This parameter can be a value of @ref FSMC_Burst_Access_Mode */
+
+ uint32_t FSMC_AsynchronousWait; /*!< Enables or disables wait signal during asynchronous transfers,
+ valid only with asynchronous Flash memories.
+ This parameter can be a value of @ref FSMC_AsynchronousWait */
+
+ uint32_t FSMC_WaitSignalPolarity; /*!< Specifies the wait signal polarity, valid only when accessing
+ the Flash memory in burst mode.
+ This parameter can be a value of @ref FSMC_Wait_Signal_Polarity */
+
+ uint32_t FSMC_WrapMode; /*!< Enables or disables the Wrapped burst access mode for Flash
+ memory, valid only when accessing Flash memories in burst mode.
+ This parameter can be a value of @ref FSMC_Wrap_Mode */
+
+ uint32_t FSMC_WaitSignalActive; /*!< Specifies if the wait signal is asserted by the memory one
+ clock cycle before the wait state or during the wait state,
+ valid only when accessing memories in burst mode.
+ This parameter can be a value of @ref FSMC_Wait_Timing */
+
+ uint32_t FSMC_WriteOperation; /*!< Enables or disables the write operation in the selected bank by the FSMC.
+ This parameter can be a value of @ref FSMC_Write_Operation */
+
+ uint32_t FSMC_WaitSignal; /*!< Enables or disables the wait-state insertion via wait
+ signal, valid for Flash memory access in burst mode.
+ This parameter can be a value of @ref FSMC_Wait_Signal */
+
+ uint32_t FSMC_ExtendedMode; /*!< Enables or disables the extended mode.
+ This parameter can be a value of @ref FSMC_Extended_Mode */
+
+ uint32_t FSMC_WriteBurst; /*!< Enables or disables the write burst operation.
+ This parameter can be a value of @ref FSMC_Write_Burst */
+
+ FSMC_NORSRAMTimingInitTypeDef* FSMC_ReadWriteTimingStruct; /*!< Timing Parameters for write and read access if the ExtendedMode is not used*/
+
+ FSMC_NORSRAMTimingInitTypeDef* FSMC_WriteTimingStruct; /*!< Timing Parameters for write access if the ExtendedMode is used*/
+}FSMC_NORSRAMInitTypeDef;
+
+/**
+ * @brief Timing parameters For FSMC NAND and PCCARD Banks
+ */
+
+typedef struct
+{
+ uint32_t FSMC_SetupTime; /*!< Defines the number of HCLK cycles to setup address before
+ the command assertion for NAND-Flash read or write access
+ to common/Attribute or I/O memory space (depending on
+ the memory space timing to be configured).
+ This parameter can be a value between 0 and 0xFF.*/
+
+ uint32_t FSMC_WaitSetupTime; /*!< Defines the minimum number of HCLK cycles to assert the
+ command for NAND-Flash read or write access to
+ common/Attribute or I/O memory space (depending on the
+ memory space timing to be configured).
+ This parameter can be a number between 0x00 and 0xFF */
+
+ uint32_t FSMC_HoldSetupTime; /*!< Defines the number of HCLK clock cycles to hold address
+ (and data for write access) after the command deassertion
+ for NAND-Flash read or write access to common/Attribute
+ or I/O memory space (depending on the memory space timing
+ to be configured).
+ This parameter can be a number between 0x00 and 0xFF */
+
+ uint32_t FSMC_HiZSetupTime; /*!< Defines the number of HCLK clock cycles during which the
+ databus is kept in HiZ after the start of a NAND-Flash
+ write access to common/Attribute or I/O memory space (depending
+ on the memory space timing to be configured).
+ This parameter can be a number between 0x00 and 0xFF */
+}FSMC_NAND_PCCARDTimingInitTypeDef;
+
+/**
+ * @brief FSMC NAND Init structure definition
+ */
+
+typedef struct
+{
+ uint32_t FSMC_Bank; /*!< Specifies the NAND memory bank that will be used.
+ This parameter can be a value of @ref FSMC_NAND_Bank */
+
+ uint32_t FSMC_Waitfeature; /*!< Enables or disables the Wait feature for the NAND Memory Bank.
+ This parameter can be any value of @ref FSMC_Wait_feature */
+
+ uint32_t FSMC_MemoryDataWidth; /*!< Specifies the external memory device width.
+ This parameter can be any value of @ref FSMC_Data_Width */
+
+ uint32_t FSMC_ECC; /*!< Enables or disables the ECC computation.
+ This parameter can be any value of @ref FSMC_ECC */
+
+ uint32_t FSMC_ECCPageSize; /*!< Defines the page size for the extended ECC.
+ This parameter can be any value of @ref FSMC_ECC_Page_Size */
+
+ uint32_t FSMC_TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the
+ delay between CLE low and RE low.
+ This parameter can be a value between 0 and 0xFF. */
+
+ uint32_t FSMC_TARSetupTime; /*!< Defines the number of HCLK cycles to configure the
+ delay between ALE low and RE low.
+ This parameter can be a number between 0x0 and 0xFF */
+
+ FSMC_NAND_PCCARDTimingInitTypeDef* FSMC_CommonSpaceTimingStruct; /*!< FSMC Common Space Timing */
+
+ FSMC_NAND_PCCARDTimingInitTypeDef* FSMC_AttributeSpaceTimingStruct; /*!< FSMC Attribute Space Timing */
+}FSMC_NANDInitTypeDef;
+
+/**
+ * @brief FSMC PCCARD Init structure definition
+ */
+
+typedef struct
+{
+ uint32_t FSMC_Waitfeature; /*!< Enables or disables the Wait feature for the Memory Bank.
+ This parameter can be any value of @ref FSMC_Wait_feature */
+
+ uint32_t FSMC_TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the
+ delay between CLE low and RE low.
+ This parameter can be a value between 0 and 0xFF. */
+
+ uint32_t FSMC_TARSetupTime; /*!< Defines the number of HCLK cycles to configure the
+ delay between ALE low and RE low.
+ This parameter can be a number between 0x0 and 0xFF */
+
+
+ FSMC_NAND_PCCARDTimingInitTypeDef* FSMC_CommonSpaceTimingStruct; /*!< FSMC Common Space Timing */
+
+ FSMC_NAND_PCCARDTimingInitTypeDef* FSMC_AttributeSpaceTimingStruct; /*!< FSMC Attribute Space Timing */
+
+ FSMC_NAND_PCCARDTimingInitTypeDef* FSMC_IOSpaceTimingStruct; /*!< FSMC IO Space Timing */
+}FSMC_PCCARDInitTypeDef;
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Exported_Constants
+ * @{
+ */
+
+/** @defgroup FSMC_NORSRAM_Bank
+ * @{
+ */
+#define FSMC_Bank1_NORSRAM1 ((uint32_t)0x00000000)
+#define FSMC_Bank1_NORSRAM2 ((uint32_t)0x00000002)
+#define FSMC_Bank1_NORSRAM3 ((uint32_t)0x00000004)
+#define FSMC_Bank1_NORSRAM4 ((uint32_t)0x00000006)
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_NAND_Bank
+ * @{
+ */
+#define FSMC_Bank2_NAND ((uint32_t)0x00000010)
+#define FSMC_Bank3_NAND ((uint32_t)0x00000100)
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_PCCARD_Bank
+ * @{
+ */
+#define FSMC_Bank4_PCCARD ((uint32_t)0x00001000)
+/**
+ * @}
+ */
+
+#define IS_FSMC_NORSRAM_BANK(BANK) (((BANK) == FSMC_Bank1_NORSRAM1) || \
+ ((BANK) == FSMC_Bank1_NORSRAM2) || \
+ ((BANK) == FSMC_Bank1_NORSRAM3) || \
+ ((BANK) == FSMC_Bank1_NORSRAM4))
+
+#define IS_FSMC_NAND_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || \
+ ((BANK) == FSMC_Bank3_NAND))
+
+#define IS_FSMC_GETFLAG_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || \
+ ((BANK) == FSMC_Bank3_NAND) || \
+ ((BANK) == FSMC_Bank4_PCCARD))
+
+#define IS_FSMC_IT_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || \
+ ((BANK) == FSMC_Bank3_NAND) || \
+ ((BANK) == FSMC_Bank4_PCCARD))
+
+/** @defgroup NOR_SRAM_Controller
+ * @{
+ */
+
+/** @defgroup FSMC_Data_Address_Bus_Multiplexing
+ * @{
+ */
+
+#define FSMC_DataAddressMux_Disable ((uint32_t)0x00000000)
+#define FSMC_DataAddressMux_Enable ((uint32_t)0x00000002)
+#define IS_FSMC_MUX(MUX) (((MUX) == FSMC_DataAddressMux_Disable) || \
+ ((MUX) == FSMC_DataAddressMux_Enable))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Memory_Type
+ * @{
+ */
+
+#define FSMC_MemoryType_SRAM ((uint32_t)0x00000000)
+#define FSMC_MemoryType_PSRAM ((uint32_t)0x00000004)
+#define FSMC_MemoryType_NOR ((uint32_t)0x00000008)
+#define IS_FSMC_MEMORY(MEMORY) (((MEMORY) == FSMC_MemoryType_SRAM) || \
+ ((MEMORY) == FSMC_MemoryType_PSRAM)|| \
+ ((MEMORY) == FSMC_MemoryType_NOR))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Data_Width
+ * @{
+ */
+
+#define FSMC_MemoryDataWidth_8b ((uint32_t)0x00000000)
+#define FSMC_MemoryDataWidth_16b ((uint32_t)0x00000010)
+#define IS_FSMC_MEMORY_WIDTH(WIDTH) (((WIDTH) == FSMC_MemoryDataWidth_8b) || \
+ ((WIDTH) == FSMC_MemoryDataWidth_16b))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Burst_Access_Mode
+ * @{
+ */
+
+#define FSMC_BurstAccessMode_Disable ((uint32_t)0x00000000)
+#define FSMC_BurstAccessMode_Enable ((uint32_t)0x00000100)
+#define IS_FSMC_BURSTMODE(STATE) (((STATE) == FSMC_BurstAccessMode_Disable) || \
+ ((STATE) == FSMC_BurstAccessMode_Enable))
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_AsynchronousWait
+ * @{
+ */
+#define FSMC_AsynchronousWait_Disable ((uint32_t)0x00000000)
+#define FSMC_AsynchronousWait_Enable ((uint32_t)0x00008000)
+#define IS_FSMC_ASYNWAIT(STATE) (((STATE) == FSMC_AsynchronousWait_Disable) || \
+ ((STATE) == FSMC_AsynchronousWait_Enable))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Wait_Signal_Polarity
+ * @{
+ */
+
+#define FSMC_WaitSignalPolarity_Low ((uint32_t)0x00000000)
+#define FSMC_WaitSignalPolarity_High ((uint32_t)0x00000200)
+#define IS_FSMC_WAIT_POLARITY(POLARITY) (((POLARITY) == FSMC_WaitSignalPolarity_Low) || \
+ ((POLARITY) == FSMC_WaitSignalPolarity_High))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Wrap_Mode
+ * @{
+ */
+
+#define FSMC_WrapMode_Disable ((uint32_t)0x00000000)
+#define FSMC_WrapMode_Enable ((uint32_t)0x00000400)
+#define IS_FSMC_WRAP_MODE(MODE) (((MODE) == FSMC_WrapMode_Disable) || \
+ ((MODE) == FSMC_WrapMode_Enable))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Wait_Timing
+ * @{
+ */
+
+#define FSMC_WaitSignalActive_BeforeWaitState ((uint32_t)0x00000000)
+#define FSMC_WaitSignalActive_DuringWaitState ((uint32_t)0x00000800)
+#define IS_FSMC_WAIT_SIGNAL_ACTIVE(ACTIVE) (((ACTIVE) == FSMC_WaitSignalActive_BeforeWaitState) || \
+ ((ACTIVE) == FSMC_WaitSignalActive_DuringWaitState))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Write_Operation
+ * @{
+ */
+
+#define FSMC_WriteOperation_Disable ((uint32_t)0x00000000)
+#define FSMC_WriteOperation_Enable ((uint32_t)0x00001000)
+#define IS_FSMC_WRITE_OPERATION(OPERATION) (((OPERATION) == FSMC_WriteOperation_Disable) || \
+ ((OPERATION) == FSMC_WriteOperation_Enable))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Wait_Signal
+ * @{
+ */
+
+#define FSMC_WaitSignal_Disable ((uint32_t)0x00000000)
+#define FSMC_WaitSignal_Enable ((uint32_t)0x00002000)
+#define IS_FSMC_WAITE_SIGNAL(SIGNAL) (((SIGNAL) == FSMC_WaitSignal_Disable) || \
+ ((SIGNAL) == FSMC_WaitSignal_Enable))
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Extended_Mode
+ * @{
+ */
+
+#define FSMC_ExtendedMode_Disable ((uint32_t)0x00000000)
+#define FSMC_ExtendedMode_Enable ((uint32_t)0x00004000)
+
+#define IS_FSMC_EXTENDED_MODE(MODE) (((MODE) == FSMC_ExtendedMode_Disable) || \
+ ((MODE) == FSMC_ExtendedMode_Enable))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Write_Burst
+ * @{
+ */
+
+#define FSMC_WriteBurst_Disable ((uint32_t)0x00000000)
+#define FSMC_WriteBurst_Enable ((uint32_t)0x00080000)
+#define IS_FSMC_WRITE_BURST(BURST) (((BURST) == FSMC_WriteBurst_Disable) || \
+ ((BURST) == FSMC_WriteBurst_Enable))
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Address_Setup_Time
+ * @{
+ */
+
+#define IS_FSMC_ADDRESS_SETUP_TIME(TIME) ((TIME) <= 0xF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Address_Hold_Time
+ * @{
+ */
+
+#define IS_FSMC_ADDRESS_HOLD_TIME(TIME) ((TIME) <= 0xF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Data_Setup_Time
+ * @{
+ */
+
+#define IS_FSMC_DATASETUP_TIME(TIME) (((TIME) > 0) && ((TIME) <= 0xFF))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Bus_Turn_around_Duration
+ * @{
+ */
+
+#define IS_FSMC_TURNAROUND_TIME(TIME) ((TIME) <= 0xF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_CLK_Division
+ * @{
+ */
+
+#define IS_FSMC_CLK_DIV(DIV) ((DIV) <= 0xF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Data_Latency
+ * @{
+ */
+
+#define IS_FSMC_DATA_LATENCY(LATENCY) ((LATENCY) <= 0xF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Access_Mode
+ * @{
+ */
+
+#define FSMC_AccessMode_A ((uint32_t)0x00000000)
+#define FSMC_AccessMode_B ((uint32_t)0x10000000)
+#define FSMC_AccessMode_C ((uint32_t)0x20000000)
+#define FSMC_AccessMode_D ((uint32_t)0x30000000)
+#define IS_FSMC_ACCESS_MODE(MODE) (((MODE) == FSMC_AccessMode_A) || \
+ ((MODE) == FSMC_AccessMode_B) || \
+ ((MODE) == FSMC_AccessMode_C) || \
+ ((MODE) == FSMC_AccessMode_D))
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup NAND_PCCARD_Controller
+ * @{
+ */
+
+/** @defgroup FSMC_Wait_feature
+ * @{
+ */
+
+#define FSMC_Waitfeature_Disable ((uint32_t)0x00000000)
+#define FSMC_Waitfeature_Enable ((uint32_t)0x00000002)
+#define IS_FSMC_WAIT_FEATURE(FEATURE) (((FEATURE) == FSMC_Waitfeature_Disable) || \
+ ((FEATURE) == FSMC_Waitfeature_Enable))
+
+/**
+ * @}
+ */
+
+
+/** @defgroup FSMC_ECC
+ * @{
+ */
+
+#define FSMC_ECC_Disable ((uint32_t)0x00000000)
+#define FSMC_ECC_Enable ((uint32_t)0x00000040)
+#define IS_FSMC_ECC_STATE(STATE) (((STATE) == FSMC_ECC_Disable) || \
+ ((STATE) == FSMC_ECC_Enable))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_ECC_Page_Size
+ * @{
+ */
+
+#define FSMC_ECCPageSize_256Bytes ((uint32_t)0x00000000)
+#define FSMC_ECCPageSize_512Bytes ((uint32_t)0x00020000)
+#define FSMC_ECCPageSize_1024Bytes ((uint32_t)0x00040000)
+#define FSMC_ECCPageSize_2048Bytes ((uint32_t)0x00060000)
+#define FSMC_ECCPageSize_4096Bytes ((uint32_t)0x00080000)
+#define FSMC_ECCPageSize_8192Bytes ((uint32_t)0x000A0000)
+#define IS_FSMC_ECCPAGE_SIZE(SIZE) (((SIZE) == FSMC_ECCPageSize_256Bytes) || \
+ ((SIZE) == FSMC_ECCPageSize_512Bytes) || \
+ ((SIZE) == FSMC_ECCPageSize_1024Bytes) || \
+ ((SIZE) == FSMC_ECCPageSize_2048Bytes) || \
+ ((SIZE) == FSMC_ECCPageSize_4096Bytes) || \
+ ((SIZE) == FSMC_ECCPageSize_8192Bytes))
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_TCLR_Setup_Time
+ * @{
+ */
+
+#define IS_FSMC_TCLR_TIME(TIME) ((TIME) <= 0xFF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_TAR_Setup_Time
+ * @{
+ */
+
+#define IS_FSMC_TAR_TIME(TIME) ((TIME) <= 0xFF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Setup_Time
+ * @{
+ */
+
+#define IS_FSMC_SETUP_TIME(TIME) ((TIME) <= 0xFF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Wait_Setup_Time
+ * @{
+ */
+
+#define IS_FSMC_WAIT_TIME(TIME) ((TIME) <= 0xFF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Hold_Setup_Time
+ * @{
+ */
+
+#define IS_FSMC_HOLD_TIME(TIME) ((TIME) <= 0xFF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_HiZ_Setup_Time
+ * @{
+ */
+
+#define IS_FSMC_HIZ_TIME(TIME) ((TIME) <= 0xFF)
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Interrupt_sources
+ * @{
+ */
+
+#define FSMC_IT_RisingEdge ((uint32_t)0x00000008)
+#define FSMC_IT_Level ((uint32_t)0x00000010)
+#define FSMC_IT_FallingEdge ((uint32_t)0x00000020)
+#define IS_FSMC_IT(IT) ((((IT) & (uint32_t)0xFFFFFFC7) == 0x00000000) && ((IT) != 0x00000000))
+#define IS_FSMC_GET_IT(IT) (((IT) == FSMC_IT_RisingEdge) || \
+ ((IT) == FSMC_IT_Level) || \
+ ((IT) == FSMC_IT_FallingEdge))
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Flags
+ * @{
+ */
+
+#define FSMC_FLAG_RisingEdge ((uint32_t)0x00000001)
+#define FSMC_FLAG_Level ((uint32_t)0x00000002)
+#define FSMC_FLAG_FallingEdge ((uint32_t)0x00000004)
+#define FSMC_FLAG_FEMPT ((uint32_t)0x00000040)
+#define IS_FSMC_GET_FLAG(FLAG) (((FLAG) == FSMC_FLAG_RisingEdge) || \
+ ((FLAG) == FSMC_FLAG_Level) || \
+ ((FLAG) == FSMC_FLAG_FallingEdge) || \
+ ((FLAG) == FSMC_FLAG_FEMPT))
+
+#define IS_FSMC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFF8) == 0x00000000) && ((FLAG) != 0x00000000))
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Exported_Functions
+ * @{
+ */
+
+void FSMC_NORSRAMDeInit(uint32_t FSMC_Bank);
+void FSMC_NANDDeInit(uint32_t FSMC_Bank);
+void FSMC_PCCARDDeInit(void);
+void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct);
+void FSMC_NANDInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct);
+void FSMC_PCCARDInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct);
+void FSMC_NORSRAMStructInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct);
+void FSMC_NANDStructInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct);
+void FSMC_PCCARDStructInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct);
+void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState);
+void FSMC_NANDCmd(uint32_t FSMC_Bank, FunctionalState NewState);
+void FSMC_PCCARDCmd(FunctionalState NewState);
+void FSMC_NANDECCCmd(uint32_t FSMC_Bank, FunctionalState NewState);
+uint32_t FSMC_GetECC(uint32_t FSMC_Bank);
+void FSMC_ITConfig(uint32_t FSMC_Bank, uint32_t FSMC_IT, FunctionalState NewState);
+FlagStatus FSMC_GetFlagStatus(uint32_t FSMC_Bank, uint32_t FSMC_FLAG);
+void FSMC_ClearFlag(uint32_t FSMC_Bank, uint32_t FSMC_FLAG);
+ITStatus FSMC_GetITStatus(uint32_t FSMC_Bank, uint32_t FSMC_IT);
+void FSMC_ClearITPendingBit(uint32_t FSMC_Bank, uint32_t FSMC_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__STM32F10x_FSMC_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_gpio.h b/st_fw_lib/inc/stm32f10x_gpio.h
new file mode 100644
index 0000000..dd28da8
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_gpio.h
@@ -0,0 +1,385 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_gpio.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the GPIO
+ * firmware library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_GPIO_H
+#define __STM32F10x_GPIO_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup GPIO
+ * @{
+ */
+
+/** @defgroup GPIO_Exported_Types
+ * @{
+ */
+
+#define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \
+ ((PERIPH) == GPIOB) || \
+ ((PERIPH) == GPIOC) || \
+ ((PERIPH) == GPIOD) || \
+ ((PERIPH) == GPIOE) || \
+ ((PERIPH) == GPIOF) || \
+ ((PERIPH) == GPIOG))
+
+/**
+ * @brief Output Maximum frequency selection
+ */
+
+typedef enum
+{
+ GPIO_Speed_10MHz = 1,
+ GPIO_Speed_2MHz,
+ GPIO_Speed_50MHz
+}GPIOSpeed_TypeDef;
+#define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_10MHz) || ((SPEED) == GPIO_Speed_2MHz) || \
+ ((SPEED) == GPIO_Speed_50MHz))
+
+/**
+ * @brief Configuration Mode enumeration
+ */
+
+typedef enum
+{ GPIO_Mode_AIN = 0x0,
+ GPIO_Mode_IN_FLOATING = 0x04,
+ GPIO_Mode_IPD = 0x28,
+ GPIO_Mode_IPU = 0x48,
+ GPIO_Mode_Out_OD = 0x14,
+ GPIO_Mode_Out_PP = 0x10,
+ GPIO_Mode_AF_OD = 0x1C,
+ GPIO_Mode_AF_PP = 0x18
+}GPIOMode_TypeDef;
+
+#define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_AIN) || ((MODE) == GPIO_Mode_IN_FLOATING) || \
+ ((MODE) == GPIO_Mode_IPD) || ((MODE) == GPIO_Mode_IPU) || \
+ ((MODE) == GPIO_Mode_Out_OD) || ((MODE) == GPIO_Mode_Out_PP) || \
+ ((MODE) == GPIO_Mode_AF_OD) || ((MODE) == GPIO_Mode_AF_PP))
+
+/**
+ * @brief GPIO Init structure definition
+ */
+
+typedef struct
+{
+ uint16_t GPIO_Pin; /*!< Specifies the GPIO pins to be configured.
+ This parameter can be any value of @ref GPIO_pins_define */
+
+ GPIOSpeed_TypeDef GPIO_Speed; /*!< Specifies the speed for the selected pins.
+ This parameter can be a value of @ref GPIOSpeed_TypeDef */
+
+ GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins.
+ This parameter can be a value of @ref GPIOMode_TypeDef */
+}GPIO_InitTypeDef;
+
+
+/**
+ * @brief Bit_SET and Bit_RESET enumeration
+ */
+
+typedef enum
+{ Bit_RESET = 0,
+ Bit_SET
+}BitAction;
+
+#define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET))
+
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Exported_Constants
+ * @{
+ */
+
+/** @defgroup GPIO_pins_define
+ * @{
+ */
+
+#define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */
+#define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */
+#define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */
+#define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */
+#define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */
+#define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */
+#define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */
+#define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */
+#define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */
+#define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */
+#define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */
+#define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */
+#define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */
+#define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */
+#define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */
+#define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */
+#define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */
+
+#define IS_GPIO_PIN(PIN) ((((PIN) & (uint16_t)0x00) == 0x00) && ((PIN) != (uint16_t)0x00))
+
+#define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \
+ ((PIN) == GPIO_Pin_1) || \
+ ((PIN) == GPIO_Pin_2) || \
+ ((PIN) == GPIO_Pin_3) || \
+ ((PIN) == GPIO_Pin_4) || \
+ ((PIN) == GPIO_Pin_5) || \
+ ((PIN) == GPIO_Pin_6) || \
+ ((PIN) == GPIO_Pin_7) || \
+ ((PIN) == GPIO_Pin_8) || \
+ ((PIN) == GPIO_Pin_9) || \
+ ((PIN) == GPIO_Pin_10) || \
+ ((PIN) == GPIO_Pin_11) || \
+ ((PIN) == GPIO_Pin_12) || \
+ ((PIN) == GPIO_Pin_13) || \
+ ((PIN) == GPIO_Pin_14) || \
+ ((PIN) == GPIO_Pin_15))
+
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Remap_define
+ * @{
+ */
+
+#define GPIO_Remap_SPI1 ((uint32_t)0x00000001) /*!< SPI1 Alternate Function mapping */
+#define GPIO_Remap_I2C1 ((uint32_t)0x00000002) /*!< I2C1 Alternate Function mapping */
+#define GPIO_Remap_USART1 ((uint32_t)0x00000004) /*!< USART1 Alternate Function mapping */
+#define GPIO_Remap_USART2 ((uint32_t)0x00000008) /*!< USART2 Alternate Function mapping */
+#define GPIO_PartialRemap_USART3 ((uint32_t)0x00140010) /*!< USART3 Partial Alternate Function mapping */
+#define GPIO_FullRemap_USART3 ((uint32_t)0x00140030) /*!< USART3 Full Alternate Function mapping */
+#define GPIO_PartialRemap_TIM1 ((uint32_t)0x00160040) /*!< TIM1 Partial Alternate Function mapping */
+#define GPIO_FullRemap_TIM1 ((uint32_t)0x001600C0) /*!< TIM1 Full Alternate Function mapping */
+#define GPIO_PartialRemap1_TIM2 ((uint32_t)0x00180100) /*!< TIM2 Partial1 Alternate Function mapping */
+#define GPIO_PartialRemap2_TIM2 ((uint32_t)0x00180200) /*!< TIM2 Partial2 Alternate Function mapping */
+#define GPIO_FullRemap_TIM2 ((uint32_t)0x00180300) /*!< TIM2 Full Alternate Function mapping */
+#define GPIO_PartialRemap_TIM3 ((uint32_t)0x001A0800) /*!< TIM3 Partial Alternate Function mapping */
+#define GPIO_FullRemap_TIM3 ((uint32_t)0x001A0C00) /*!< TIM3 Full Alternate Function mapping */
+#define GPIO_Remap_TIM4 ((uint32_t)0x00001000) /*!< TIM4 Alternate Function mapping */
+#define GPIO_Remap1_CAN1 ((uint32_t)0x001D4000) /*!< CAN1 Alternate Function mapping */
+#define GPIO_Remap2_CAN1 ((uint32_t)0x001D6000) /*!< CAN1 Alternate Function mapping */
+#define GPIO_Remap_PD01 ((uint32_t)0x00008000) /*!< PD01 Alternate Function mapping */
+#define GPIO_Remap_TIM5CH4_LSI ((uint32_t)0x00200001) /*!< LSI connected to TIM5 Channel4 input capture for calibration */
+#define GPIO_Remap_ADC1_ETRGINJ ((uint32_t)0x00200002) /*!< ADC1 External Trigger Injected Conversion remapping */
+#define GPIO_Remap_ADC1_ETRGREG ((uint32_t)0x00200004) /*!< ADC1 External Trigger Regular Conversion remapping */
+#define GPIO_Remap_ADC2_ETRGINJ ((uint32_t)0x00200008) /*!< ADC2 External Trigger Injected Conversion remapping */
+#define GPIO_Remap_ADC2_ETRGREG ((uint32_t)0x00200010) /*!< ADC2 External Trigger Regular Conversion remapping */
+#define GPIO_Remap_ETH ((uint32_t)0x00200020) /*!< Ethernet remapping (only for Connectivity line devices) */
+#define GPIO_Remap_CAN2 ((uint32_t)0x00200040) /*!< CAN2 remapping (only for Connectivity line devices) */
+#define GPIO_Remap_SWJ_NoJTRST ((uint32_t)0x00300100) /*!< Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST */
+#define GPIO_Remap_SWJ_JTAGDisable ((uint32_t)0x00300200) /*!< JTAG-DP Disabled and SW-DP Enabled */
+#define GPIO_Remap_SWJ_Disable ((uint32_t)0x00300400) /*!< Full SWJ Disabled (JTAG-DP + SW-DP) */
+#define GPIO_Remap_SPI3 ((uint32_t)0x00201100) /*!< SPI3/I2S3 Alternate Function mapping (only for Connectivity line devices) */
+#define GPIO_Remap_TIM2ITR1_PTP_SOF ((uint32_t)0x00202000) /*!< Ethernet PTP output or USB OTG SOF (Start of Frame) connected
+ to TIM2 Internal Trigger 1 for calibration
+ (only for Connectivity line devices) */
+#define GPIO_Remap_PTP_PPS ((uint32_t)0x00204000) /*!< Ethernet MAC PPS_PTS output on PB05 (only for Connectivity line devices) */
+
+#define GPIO_Remap_TIM15 ((uint32_t)0x80000001) /*!< TIM15 Alternate Function mapping (only for Value line devices) */
+#define GPIO_Remap_TIM16 ((uint32_t)0x80000002) /*!< TIM16 Alternate Function mapping (only for Value line devices) */
+#define GPIO_Remap_TIM17 ((uint32_t)0x80000004) /*!< TIM17 Alternate Function mapping (only for Value line devices) */
+#define GPIO_Remap_CEC ((uint32_t)0x80000008) /*!< CEC Alternate Function mapping (only for Value line devices) */
+#define GPIO_Remap_TIM1_DMA ((uint32_t)0x80000010) /*!< TIM1 DMA requests mapping (only for Value line devices) */
+
+#define GPIO_Remap_TIM9 ((uint32_t)0x80000020) /*!< TIM9 Alternate Function mapping (only for XL-density devices) */
+#define GPIO_Remap_TIM10 ((uint32_t)0x80000040) /*!< TIM10 Alternate Function mapping (only for XL-density devices) */
+#define GPIO_Remap_TIM11 ((uint32_t)0x80000080) /*!< TIM11 Alternate Function mapping (only for XL-density devices) */
+#define GPIO_Remap_TIM13 ((uint32_t)0x80000100) /*!< TIM13 Alternate Function mapping (only for High density Value line and XL-density devices) */
+#define GPIO_Remap_TIM14 ((uint32_t)0x80000200) /*!< TIM14 Alternate Function mapping (only for High density Value line and XL-density devices) */
+#define GPIO_Remap_FSMC_NADV ((uint32_t)0x80000400) /*!< FSMC_NADV Alternate Function mapping (only for High density Value line and XL-density devices) */
+
+#define GPIO_Remap_TIM67_DAC_DMA ((uint32_t)0x80000800) /*!< TIM6/TIM7 and DAC DMA requests remapping (only for High density Value line devices) */
+#define GPIO_Remap_TIM12 ((uint32_t)0x80001000) /*!< TIM12 Alternate Function mapping (only for High density Value line devices) */
+#define GPIO_Remap_MISC ((uint32_t)0x80002000) /*!< Miscellaneous Remap (DMA2 Channel5 Position and DAC Trigger remapping,
+ only for High density Value line devices) */
+
+#define IS_GPIO_REMAP(REMAP) (((REMAP) == GPIO_Remap_SPI1) || ((REMAP) == GPIO_Remap_I2C1) || \
+ ((REMAP) == GPIO_Remap_USART1) || ((REMAP) == GPIO_Remap_USART2) || \
+ ((REMAP) == GPIO_PartialRemap_USART3) || ((REMAP) == GPIO_FullRemap_USART3) || \
+ ((REMAP) == GPIO_PartialRemap_TIM1) || ((REMAP) == GPIO_FullRemap_TIM1) || \
+ ((REMAP) == GPIO_PartialRemap1_TIM2) || ((REMAP) == GPIO_PartialRemap2_TIM2) || \
+ ((REMAP) == GPIO_FullRemap_TIM2) || ((REMAP) == GPIO_PartialRemap_TIM3) || \
+ ((REMAP) == GPIO_FullRemap_TIM3) || ((REMAP) == GPIO_Remap_TIM4) || \
+ ((REMAP) == GPIO_Remap1_CAN1) || ((REMAP) == GPIO_Remap2_CAN1) || \
+ ((REMAP) == GPIO_Remap_PD01) || ((REMAP) == GPIO_Remap_TIM5CH4_LSI) || \
+ ((REMAP) == GPIO_Remap_ADC1_ETRGINJ) ||((REMAP) == GPIO_Remap_ADC1_ETRGREG) || \
+ ((REMAP) == GPIO_Remap_ADC2_ETRGINJ) ||((REMAP) == GPIO_Remap_ADC2_ETRGREG) || \
+ ((REMAP) == GPIO_Remap_ETH) ||((REMAP) == GPIO_Remap_CAN2) || \
+ ((REMAP) == GPIO_Remap_SWJ_NoJTRST) || ((REMAP) == GPIO_Remap_SWJ_JTAGDisable) || \
+ ((REMAP) == GPIO_Remap_SWJ_Disable)|| ((REMAP) == GPIO_Remap_SPI3) || \
+ ((REMAP) == GPIO_Remap_TIM2ITR1_PTP_SOF) || ((REMAP) == GPIO_Remap_PTP_PPS) || \
+ ((REMAP) == GPIO_Remap_TIM15) || ((REMAP) == GPIO_Remap_TIM16) || \
+ ((REMAP) == GPIO_Remap_TIM17) || ((REMAP) == GPIO_Remap_CEC) || \
+ ((REMAP) == GPIO_Remap_TIM1_DMA) || ((REMAP) == GPIO_Remap_TIM9) || \
+ ((REMAP) == GPIO_Remap_TIM10) || ((REMAP) == GPIO_Remap_TIM11) || \
+ ((REMAP) == GPIO_Remap_TIM13) || ((REMAP) == GPIO_Remap_TIM14) || \
+ ((REMAP) == GPIO_Remap_FSMC_NADV) || ((REMAP) == GPIO_Remap_TIM67_DAC_DMA) || \
+ ((REMAP) == GPIO_Remap_TIM12) || ((REMAP) == GPIO_Remap_MISC))
+
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Port_Sources
+ * @{
+ */
+
+#define GPIO_PortSourceGPIOA ((uint8_t)0x00)
+#define GPIO_PortSourceGPIOB ((uint8_t)0x01)
+#define GPIO_PortSourceGPIOC ((uint8_t)0x02)
+#define GPIO_PortSourceGPIOD ((uint8_t)0x03)
+#define GPIO_PortSourceGPIOE ((uint8_t)0x04)
+#define GPIO_PortSourceGPIOF ((uint8_t)0x05)
+#define GPIO_PortSourceGPIOG ((uint8_t)0x06)
+#define IS_GPIO_EVENTOUT_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == GPIO_PortSourceGPIOA) || \
+ ((PORTSOURCE) == GPIO_PortSourceGPIOB) || \
+ ((PORTSOURCE) == GPIO_PortSourceGPIOC) || \
+ ((PORTSOURCE) == GPIO_PortSourceGPIOD) || \
+ ((PORTSOURCE) == GPIO_PortSourceGPIOE))
+
+#define IS_GPIO_EXTI_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == GPIO_PortSourceGPIOA) || \
+ ((PORTSOURCE) == GPIO_PortSourceGPIOB) || \
+ ((PORTSOURCE) == GPIO_PortSourceGPIOC) || \
+ ((PORTSOURCE) == GPIO_PortSourceGPIOD) || \
+ ((PORTSOURCE) == GPIO_PortSourceGPIOE) || \
+ ((PORTSOURCE) == GPIO_PortSourceGPIOF) || \
+ ((PORTSOURCE) == GPIO_PortSourceGPIOG))
+
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Pin_sources
+ * @{
+ */
+
+#define GPIO_PinSource0 ((uint8_t)0x00)
+#define GPIO_PinSource1 ((uint8_t)0x01)
+#define GPIO_PinSource2 ((uint8_t)0x02)
+#define GPIO_PinSource3 ((uint8_t)0x03)
+#define GPIO_PinSource4 ((uint8_t)0x04)
+#define GPIO_PinSource5 ((uint8_t)0x05)
+#define GPIO_PinSource6 ((uint8_t)0x06)
+#define GPIO_PinSource7 ((uint8_t)0x07)
+#define GPIO_PinSource8 ((uint8_t)0x08)
+#define GPIO_PinSource9 ((uint8_t)0x09)
+#define GPIO_PinSource10 ((uint8_t)0x0A)
+#define GPIO_PinSource11 ((uint8_t)0x0B)
+#define GPIO_PinSource12 ((uint8_t)0x0C)
+#define GPIO_PinSource13 ((uint8_t)0x0D)
+#define GPIO_PinSource14 ((uint8_t)0x0E)
+#define GPIO_PinSource15 ((uint8_t)0x0F)
+
+#define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \
+ ((PINSOURCE) == GPIO_PinSource1) || \
+ ((PINSOURCE) == GPIO_PinSource2) || \
+ ((PINSOURCE) == GPIO_PinSource3) || \
+ ((PINSOURCE) == GPIO_PinSource4) || \
+ ((PINSOURCE) == GPIO_PinSource5) || \
+ ((PINSOURCE) == GPIO_PinSource6) || \
+ ((PINSOURCE) == GPIO_PinSource7) || \
+ ((PINSOURCE) == GPIO_PinSource8) || \
+ ((PINSOURCE) == GPIO_PinSource9) || \
+ ((PINSOURCE) == GPIO_PinSource10) || \
+ ((PINSOURCE) == GPIO_PinSource11) || \
+ ((PINSOURCE) == GPIO_PinSource12) || \
+ ((PINSOURCE) == GPIO_PinSource13) || \
+ ((PINSOURCE) == GPIO_PinSource14) || \
+ ((PINSOURCE) == GPIO_PinSource15))
+
+/**
+ * @}
+ */
+
+/** @defgroup Ethernet_Media_Interface
+ * @{
+ */
+#define GPIO_ETH_MediaInterface_MII ((u32)0x00000000)
+#define GPIO_ETH_MediaInterface_RMII ((u32)0x00000001)
+
+#define IS_GPIO_ETH_MEDIA_INTERFACE(INTERFACE) (((INTERFACE) == GPIO_ETH_MediaInterface_MII) || \
+ ((INTERFACE) == GPIO_ETH_MediaInterface_RMII))
+
+/**
+ * @}
+ */
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Exported_Functions
+ * @{
+ */
+
+void GPIO_DeInit(GPIO_TypeDef* GPIOx);
+void GPIO_AFIODeInit(void);
+void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
+void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
+uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
+uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
+uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
+uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
+void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
+void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
+void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);
+void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);
+void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
+void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource);
+void GPIO_EventOutputCmd(FunctionalState NewState);
+void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState);
+void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource);
+void GPIO_ETH_MediaInterfaceConfig(uint32_t GPIO_ETH_MediaInterface);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_GPIO_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_i2c.h b/st_fw_lib/inc/stm32f10x_i2c.h
new file mode 100644
index 0000000..60e4b14
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_i2c.h
@@ -0,0 +1,684 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_i2c.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the I2C firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_I2C_H
+#define __STM32F10x_I2C_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup I2C
+ * @{
+ */
+
+/** @defgroup I2C_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief I2C Init structure definition
+ */
+
+typedef struct
+{
+ uint32_t I2C_ClockSpeed; /*!< Specifies the clock frequency.
+ This parameter must be set to a value lower than 400kHz */
+
+ uint16_t I2C_Mode; /*!< Specifies the I2C mode.
+ This parameter can be a value of @ref I2C_mode */
+
+ uint16_t I2C_DutyCycle; /*!< Specifies the I2C fast mode duty cycle.
+ This parameter can be a value of @ref I2C_duty_cycle_in_fast_mode */
+
+ uint16_t I2C_OwnAddress1; /*!< Specifies the first device own address.
+ This parameter can be a 7-bit or 10-bit address. */
+
+ uint16_t I2C_Ack; /*!< Enables or disables the acknowledgement.
+ This parameter can be a value of @ref I2C_acknowledgement */
+
+ uint16_t I2C_AcknowledgedAddress; /*!< Specifies if 7-bit or 10-bit address is acknowledged.
+ This parameter can be a value of @ref I2C_acknowledged_address */
+}I2C_InitTypeDef;
+
+/**
+ * @}
+ */
+
+
+/** @defgroup I2C_Exported_Constants
+ * @{
+ */
+
+#define IS_I2C_ALL_PERIPH(PERIPH) (((PERIPH) == I2C1) || \
+ ((PERIPH) == I2C2))
+/** @defgroup I2C_mode
+ * @{
+ */
+
+#define I2C_Mode_I2C ((uint16_t)0x0000)
+#define I2C_Mode_SMBusDevice ((uint16_t)0x0002)
+#define I2C_Mode_SMBusHost ((uint16_t)0x000A)
+#define IS_I2C_MODE(MODE) (((MODE) == I2C_Mode_I2C) || \
+ ((MODE) == I2C_Mode_SMBusDevice) || \
+ ((MODE) == I2C_Mode_SMBusHost))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_duty_cycle_in_fast_mode
+ * @{
+ */
+
+#define I2C_DutyCycle_16_9 ((uint16_t)0x4000) /*!< I2C fast mode Tlow/Thigh = 16/9 */
+#define I2C_DutyCycle_2 ((uint16_t)0xBFFF) /*!< I2C fast mode Tlow/Thigh = 2 */
+#define IS_I2C_DUTY_CYCLE(CYCLE) (((CYCLE) == I2C_DutyCycle_16_9) || \
+ ((CYCLE) == I2C_DutyCycle_2))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_acknowledgement
+ * @{
+ */
+
+#define I2C_Ack_Enable ((uint16_t)0x0400)
+#define I2C_Ack_Disable ((uint16_t)0x0000)
+#define IS_I2C_ACK_STATE(STATE) (((STATE) == I2C_Ack_Enable) || \
+ ((STATE) == I2C_Ack_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_transfer_direction
+ * @{
+ */
+
+#define I2C_Direction_Transmitter ((uint8_t)0x00)
+#define I2C_Direction_Receiver ((uint8_t)0x01)
+#define IS_I2C_DIRECTION(DIRECTION) (((DIRECTION) == I2C_Direction_Transmitter) || \
+ ((DIRECTION) == I2C_Direction_Receiver))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_acknowledged_address
+ * @{
+ */
+
+#define I2C_AcknowledgedAddress_7bit ((uint16_t)0x4000)
+#define I2C_AcknowledgedAddress_10bit ((uint16_t)0xC000)
+#define IS_I2C_ACKNOWLEDGE_ADDRESS(ADDRESS) (((ADDRESS) == I2C_AcknowledgedAddress_7bit) || \
+ ((ADDRESS) == I2C_AcknowledgedAddress_10bit))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_registers
+ * @{
+ */
+
+#define I2C_Register_CR1 ((uint8_t)0x00)
+#define I2C_Register_CR2 ((uint8_t)0x04)
+#define I2C_Register_OAR1 ((uint8_t)0x08)
+#define I2C_Register_OAR2 ((uint8_t)0x0C)
+#define I2C_Register_DR ((uint8_t)0x10)
+#define I2C_Register_SR1 ((uint8_t)0x14)
+#define I2C_Register_SR2 ((uint8_t)0x18)
+#define I2C_Register_CCR ((uint8_t)0x1C)
+#define I2C_Register_TRISE ((uint8_t)0x20)
+#define IS_I2C_REGISTER(REGISTER) (((REGISTER) == I2C_Register_CR1) || \
+ ((REGISTER) == I2C_Register_CR2) || \
+ ((REGISTER) == I2C_Register_OAR1) || \
+ ((REGISTER) == I2C_Register_OAR2) || \
+ ((REGISTER) == I2C_Register_DR) || \
+ ((REGISTER) == I2C_Register_SR1) || \
+ ((REGISTER) == I2C_Register_SR2) || \
+ ((REGISTER) == I2C_Register_CCR) || \
+ ((REGISTER) == I2C_Register_TRISE))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_SMBus_alert_pin_level
+ * @{
+ */
+
+#define I2C_SMBusAlert_Low ((uint16_t)0x2000)
+#define I2C_SMBusAlert_High ((uint16_t)0xDFFF)
+#define IS_I2C_SMBUS_ALERT(ALERT) (((ALERT) == I2C_SMBusAlert_Low) || \
+ ((ALERT) == I2C_SMBusAlert_High))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_PEC_position
+ * @{
+ */
+
+#define I2C_PECPosition_Next ((uint16_t)0x0800)
+#define I2C_PECPosition_Current ((uint16_t)0xF7FF)
+#define IS_I2C_PEC_POSITION(POSITION) (((POSITION) == I2C_PECPosition_Next) || \
+ ((POSITION) == I2C_PECPosition_Current))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_NCAK_position
+ * @{
+ */
+
+#define I2C_NACKPosition_Next ((uint16_t)0x0800)
+#define I2C_NACKPosition_Current ((uint16_t)0xF7FF)
+#define IS_I2C_NACK_POSITION(POSITION) (((POSITION) == I2C_NACKPosition_Next) || \
+ ((POSITION) == I2C_NACKPosition_Current))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_interrupts_definition
+ * @{
+ */
+
+#define I2C_IT_BUF ((uint16_t)0x0400)
+#define I2C_IT_EVT ((uint16_t)0x0200)
+#define I2C_IT_ERR ((uint16_t)0x0100)
+#define IS_I2C_CONFIG_IT(IT) ((((IT) & (uint16_t)0xF8FF) == 0x00) && ((IT) != 0x00))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_interrupts_definition
+ * @{
+ */
+
+#define I2C_IT_SMBALERT ((uint32_t)0x01008000)
+#define I2C_IT_TIMEOUT ((uint32_t)0x01004000)
+#define I2C_IT_PECERR ((uint32_t)0x01001000)
+#define I2C_IT_OVR ((uint32_t)0x01000800)
+#define I2C_IT_AF ((uint32_t)0x01000400)
+#define I2C_IT_ARLO ((uint32_t)0x01000200)
+#define I2C_IT_BERR ((uint32_t)0x01000100)
+#define I2C_IT_TXE ((uint32_t)0x06000080)
+#define I2C_IT_RXNE ((uint32_t)0x06000040)
+#define I2C_IT_STOPF ((uint32_t)0x02000010)
+#define I2C_IT_ADD10 ((uint32_t)0x02000008)
+#define I2C_IT_BTF ((uint32_t)0x02000004)
+#define I2C_IT_ADDR ((uint32_t)0x02000002)
+#define I2C_IT_SB ((uint32_t)0x02000001)
+
+#define IS_I2C_CLEAR_IT(IT) ((((IT) & (uint16_t)0x20FF) == 0x00) && ((IT) != (uint16_t)0x00))
+
+#define IS_I2C_GET_IT(IT) (((IT) == I2C_IT_SMBALERT) || ((IT) == I2C_IT_TIMEOUT) || \
+ ((IT) == I2C_IT_PECERR) || ((IT) == I2C_IT_OVR) || \
+ ((IT) == I2C_IT_AF) || ((IT) == I2C_IT_ARLO) || \
+ ((IT) == I2C_IT_BERR) || ((IT) == I2C_IT_TXE) || \
+ ((IT) == I2C_IT_RXNE) || ((IT) == I2C_IT_STOPF) || \
+ ((IT) == I2C_IT_ADD10) || ((IT) == I2C_IT_BTF) || \
+ ((IT) == I2C_IT_ADDR) || ((IT) == I2C_IT_SB))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_flags_definition
+ * @{
+ */
+
+/**
+ * @brief SR2 register flags
+ */
+
+#define I2C_FLAG_DUALF ((uint32_t)0x00800000)
+#define I2C_FLAG_SMBHOST ((uint32_t)0x00400000)
+#define I2C_FLAG_SMBDEFAULT ((uint32_t)0x00200000)
+#define I2C_FLAG_GENCALL ((uint32_t)0x00100000)
+#define I2C_FLAG_TRA ((uint32_t)0x00040000)
+#define I2C_FLAG_BUSY ((uint32_t)0x00020000)
+#define I2C_FLAG_MSL ((uint32_t)0x00010000)
+
+/**
+ * @brief SR1 register flags
+ */
+
+#define I2C_FLAG_SMBALERT ((uint32_t)0x10008000)
+#define I2C_FLAG_TIMEOUT ((uint32_t)0x10004000)
+#define I2C_FLAG_PECERR ((uint32_t)0x10001000)
+#define I2C_FLAG_OVR ((uint32_t)0x10000800)
+#define I2C_FLAG_AF ((uint32_t)0x10000400)
+#define I2C_FLAG_ARLO ((uint32_t)0x10000200)
+#define I2C_FLAG_BERR ((uint32_t)0x10000100)
+#define I2C_FLAG_TXE ((uint32_t)0x10000080)
+#define I2C_FLAG_RXNE ((uint32_t)0x10000040)
+#define I2C_FLAG_STOPF ((uint32_t)0x10000010)
+#define I2C_FLAG_ADD10 ((uint32_t)0x10000008)
+#define I2C_FLAG_BTF ((uint32_t)0x10000004)
+#define I2C_FLAG_ADDR ((uint32_t)0x10000002)
+#define I2C_FLAG_SB ((uint32_t)0x10000001)
+
+#define IS_I2C_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0x20FF) == 0x00) && ((FLAG) != (uint16_t)0x00))
+
+#define IS_I2C_GET_FLAG(FLAG) (((FLAG) == I2C_FLAG_DUALF) || ((FLAG) == I2C_FLAG_SMBHOST) || \
+ ((FLAG) == I2C_FLAG_SMBDEFAULT) || ((FLAG) == I2C_FLAG_GENCALL) || \
+ ((FLAG) == I2C_FLAG_TRA) || ((FLAG) == I2C_FLAG_BUSY) || \
+ ((FLAG) == I2C_FLAG_MSL) || ((FLAG) == I2C_FLAG_SMBALERT) || \
+ ((FLAG) == I2C_FLAG_TIMEOUT) || ((FLAG) == I2C_FLAG_PECERR) || \
+ ((FLAG) == I2C_FLAG_OVR) || ((FLAG) == I2C_FLAG_AF) || \
+ ((FLAG) == I2C_FLAG_ARLO) || ((FLAG) == I2C_FLAG_BERR) || \
+ ((FLAG) == I2C_FLAG_TXE) || ((FLAG) == I2C_FLAG_RXNE) || \
+ ((FLAG) == I2C_FLAG_STOPF) || ((FLAG) == I2C_FLAG_ADD10) || \
+ ((FLAG) == I2C_FLAG_BTF) || ((FLAG) == I2C_FLAG_ADDR) || \
+ ((FLAG) == I2C_FLAG_SB))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_Events
+ * @{
+ */
+
+/*========================================
+
+ I2C Master Events (Events grouped in order of communication)
+ ==========================================*/
+/**
+ * @brief Communication start
+ *
+ * After sending the START condition (I2C_GenerateSTART() function) the master
+ * has to wait for this event. It means that the Start condition has been correctly
+ * released on the I2C bus (the bus is free, no other devices is communicating).
+ *
+ */
+/* --EV5 */
+#define I2C_EVENT_MASTER_MODE_SELECT ((uint32_t)0x00030001) /* BUSY, MSL and SB flag */
+
+/**
+ * @brief Address Acknowledge
+ *
+ * After checking on EV5 (start condition correctly released on the bus), the
+ * master sends the address of the slave(s) with which it will communicate
+ * (I2C_Send7bitAddress() function, it also determines the direction of the communication:
+ * Master transmitter or Receiver). Then the master has to wait that a slave acknowledges
+ * his address. If an acknowledge is sent on the bus, one of the following events will
+ * be set:
+ *
+ * 1) In case of Master Receiver (7-bit addressing): the I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED
+ * event is set.
+ *
+ * 2) In case of Master Transmitter (7-bit addressing): the I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED
+ * is set
+ *
+ * 3) In case of 10-Bit addressing mode, the master (just after generating the START
+ * and checking on EV5) has to send the header of 10-bit addressing mode (I2C_SendData()
+ * function). Then master should wait on EV9. It means that the 10-bit addressing
+ * header has been correctly sent on the bus. Then master should send the second part of
+ * the 10-bit address (LSB) using the function I2C_Send7bitAddress(). Then master
+ * should wait for event EV6.
+ *
+ */
+
+/* --EV6 */
+#define I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED ((uint32_t)0x00070082) /* BUSY, MSL, ADDR, TXE and TRA flags */
+#define I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED ((uint32_t)0x00030002) /* BUSY, MSL and ADDR flags */
+/* --EV9 */
+#define I2C_EVENT_MASTER_MODE_ADDRESS10 ((uint32_t)0x00030008) /* BUSY, MSL and ADD10 flags */
+
+/**
+ * @brief Communication events
+ *
+ * If a communication is established (START condition generated and slave address
+ * acknowledged) then the master has to check on one of the following events for
+ * communication procedures:
+ *
+ * 1) Master Receiver mode: The master has to wait on the event EV7 then to read
+ * the data received from the slave (I2C_ReceiveData() function).
+ *
+ * 2) Master Transmitter mode: The master has to send data (I2C_SendData()
+ * function) then to wait on event EV8 or EV8_2.
+ * These two events are similar:
+ * - EV8 means that the data has been written in the data register and is
+ * being shifted out.
+ * - EV8_2 means that the data has been physically shifted out and output
+ * on the bus.
+ * In most cases, using EV8 is sufficient for the application.
+ * Using EV8_2 leads to a slower communication but ensure more reliable test.
+ * EV8_2 is also more suitable than EV8 for testing on the last data transmission
+ * (before Stop condition generation).
+ *
+ * @note In case the user software does not guarantee that this event EV7 is
+ * managed before the current byte end of transfer, then user may check on EV7
+ * and BTF flag at the same time (ie. (I2C_EVENT_MASTER_BYTE_RECEIVED | I2C_FLAG_BTF)).
+ * In this case the communication may be slower.
+ *
+ */
+
+/* Master RECEIVER mode -----------------------------*/
+/* --EV7 */
+#define I2C_EVENT_MASTER_BYTE_RECEIVED ((uint32_t)0x00030040) /* BUSY, MSL and RXNE flags */
+
+/* Master TRANSMITTER mode --------------------------*/
+/* --EV8 */
+#define I2C_EVENT_MASTER_BYTE_TRANSMITTING ((uint32_t)0x00070080) /* TRA, BUSY, MSL, TXE flags */
+/* --EV8_2 */
+#define I2C_EVENT_MASTER_BYTE_TRANSMITTED ((uint32_t)0x00070084) /* TRA, BUSY, MSL, TXE and BTF flags */
+
+
+/*========================================
+
+ I2C Slave Events (Events grouped in order of communication)
+ ==========================================*/
+
+/**
+ * @brief Communication start events
+ *
+ * Wait on one of these events at the start of the communication. It means that
+ * the I2C peripheral detected a Start condition on the bus (generated by master
+ * device) followed by the peripheral address. The peripheral generates an ACK
+ * condition on the bus (if the acknowledge feature is enabled through function
+ * I2C_AcknowledgeConfig()) and the events listed above are set :
+ *
+ * 1) In normal case (only one address managed by the slave), when the address
+ * sent by the master matches the own address of the peripheral (configured by
+ * I2C_OwnAddress1 field) the I2C_EVENT_SLAVE_XXX_ADDRESS_MATCHED event is set
+ * (where XXX could be TRANSMITTER or RECEIVER).
+ *
+ * 2) In case the address sent by the master matches the second address of the
+ * peripheral (configured by the function I2C_OwnAddress2Config() and enabled
+ * by the function I2C_DualAddressCmd()) the events I2C_EVENT_SLAVE_XXX_SECONDADDRESS_MATCHED
+ * (where XXX could be TRANSMITTER or RECEIVER) are set.
+ *
+ * 3) In case the address sent by the master is General Call (address 0x00) and
+ * if the General Call is enabled for the peripheral (using function I2C_GeneralCallCmd())
+ * the following event is set I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED.
+ *
+ */
+
+/* --EV1 (all the events below are variants of EV1) */
+/* 1) Case of One Single Address managed by the slave */
+#define I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED ((uint32_t)0x00020002) /* BUSY and ADDR flags */
+#define I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED ((uint32_t)0x00060082) /* TRA, BUSY, TXE and ADDR flags */
+
+/* 2) Case of Dual address managed by the slave */
+#define I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED ((uint32_t)0x00820000) /* DUALF and BUSY flags */
+#define I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED ((uint32_t)0x00860080) /* DUALF, TRA, BUSY and TXE flags */
+
+/* 3) Case of General Call enabled for the slave */
+#define I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED ((uint32_t)0x00120000) /* GENCALL and BUSY flags */
+
+/**
+ * @brief Communication events
+ *
+ * Wait on one of these events when EV1 has already been checked and:
+ *
+ * - Slave RECEIVER mode:
+ * - EV2: When the application is expecting a data byte to be received.
+ * - EV4: When the application is expecting the end of the communication: master
+ * sends a stop condition and data transmission is stopped.
+ *
+ * - Slave Transmitter mode:
+ * - EV3: When a byte has been transmitted by the slave and the application is expecting
+ * the end of the byte transmission. The two events I2C_EVENT_SLAVE_BYTE_TRANSMITTED and
+ * I2C_EVENT_SLAVE_BYTE_TRANSMITTING are similar. The second one can optionally be
+ * used when the user software doesn't guarantee the EV3 is managed before the
+ * current byte end of transfer.
+ * - EV3_2: When the master sends a NACK in order to tell slave that data transmission
+ * shall end (before sending the STOP condition). In this case slave has to stop sending
+ * data bytes and expect a Stop condition on the bus.
+ *
+ * @note In case the user software does not guarantee that the event EV2 is
+ * managed before the current byte end of transfer, then user may check on EV2
+ * and BTF flag at the same time (ie. (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_BTF)).
+ * In this case the communication may be slower.
+ *
+ */
+
+/* Slave RECEIVER mode --------------------------*/
+/* --EV2 */
+#define I2C_EVENT_SLAVE_BYTE_RECEIVED ((uint32_t)0x00020040) /* BUSY and RXNE flags */
+/* --EV4 */
+#define I2C_EVENT_SLAVE_STOP_DETECTED ((uint32_t)0x00000010) /* STOPF flag */
+
+/* Slave TRANSMITTER mode -----------------------*/
+/* --EV3 */
+#define I2C_EVENT_SLAVE_BYTE_TRANSMITTED ((uint32_t)0x00060084) /* TRA, BUSY, TXE and BTF flags */
+#define I2C_EVENT_SLAVE_BYTE_TRANSMITTING ((uint32_t)0x00060080) /* TRA, BUSY and TXE flags */
+/* --EV3_2 */
+#define I2C_EVENT_SLAVE_ACK_FAILURE ((uint32_t)0x00000400) /* AF flag */
+
+/*=========================== End of Events Description ==========================================*/
+
+#define IS_I2C_EVENT(EVENT) (((EVENT) == I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED) || \
+ ((EVENT) == I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED) || \
+ ((EVENT) == I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED) || \
+ ((EVENT) == I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED) || \
+ ((EVENT) == I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED) || \
+ ((EVENT) == I2C_EVENT_SLAVE_BYTE_RECEIVED) || \
+ ((EVENT) == (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_DUALF)) || \
+ ((EVENT) == (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_GENCALL)) || \
+ ((EVENT) == I2C_EVENT_SLAVE_BYTE_TRANSMITTED) || \
+ ((EVENT) == (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_DUALF)) || \
+ ((EVENT) == (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_GENCALL)) || \
+ ((EVENT) == I2C_EVENT_SLAVE_STOP_DETECTED) || \
+ ((EVENT) == I2C_EVENT_MASTER_MODE_SELECT) || \
+ ((EVENT) == I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED) || \
+ ((EVENT) == I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED) || \
+ ((EVENT) == I2C_EVENT_MASTER_BYTE_RECEIVED) || \
+ ((EVENT) == I2C_EVENT_MASTER_BYTE_TRANSMITTED) || \
+ ((EVENT) == I2C_EVENT_MASTER_BYTE_TRANSMITTING) || \
+ ((EVENT) == I2C_EVENT_MASTER_MODE_ADDRESS10) || \
+ ((EVENT) == I2C_EVENT_SLAVE_ACK_FAILURE))
+/**
+ * @}
+ */
+
+/** @defgroup I2C_own_address1
+ * @{
+ */
+
+#define IS_I2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= 0x3FF)
+/**
+ * @}
+ */
+
+/** @defgroup I2C_clock_speed
+ * @{
+ */
+
+#define IS_I2C_CLOCK_SPEED(SPEED) (((SPEED) >= 0x1) && ((SPEED) <= 400000))
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup I2C_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup I2C_Exported_Functions
+ * @{
+ */
+
+void I2C_DeInit(I2C_TypeDef* I2Cx);
+void I2C_Init(I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct);
+void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct);
+void I2C_Cmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_DMACmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_DMALastTransferCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_GenerateSTART(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_GenerateSTOP(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_AcknowledgeConfig(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_OwnAddress2Config(I2C_TypeDef* I2Cx, uint8_t Address);
+void I2C_DualAddressCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_GeneralCallCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_ITConfig(I2C_TypeDef* I2Cx, uint16_t I2C_IT, FunctionalState NewState);
+void I2C_SendData(I2C_TypeDef* I2Cx, uint8_t Data);
+uint8_t I2C_ReceiveData(I2C_TypeDef* I2Cx);
+void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, uint8_t Address, uint8_t I2C_Direction);
+uint16_t I2C_ReadRegister(I2C_TypeDef* I2Cx, uint8_t I2C_Register);
+void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_NACKPositionConfig(I2C_TypeDef* I2Cx, uint16_t I2C_NACKPosition);
+void I2C_SMBusAlertConfig(I2C_TypeDef* I2Cx, uint16_t I2C_SMBusAlert);
+void I2C_TransmitPEC(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_PECPositionConfig(I2C_TypeDef* I2Cx, uint16_t I2C_PECPosition);
+void I2C_CalculatePEC(I2C_TypeDef* I2Cx, FunctionalState NewState);
+uint8_t I2C_GetPEC(I2C_TypeDef* I2Cx);
+void I2C_ARPCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
+void I2C_FastModeDutyCycleConfig(I2C_TypeDef* I2Cx, uint16_t I2C_DutyCycle);
+
+/**
+ * @brief
+ ****************************************************************************************
+ *
+ * I2C State Monitoring Functions
+ *
+ ****************************************************************************************
+ * This I2C driver provides three different ways for I2C state monitoring
+ * depending on the application requirements and constraints:
+ *
+ *
+ * 1) Basic state monitoring:
+ * Using I2C_CheckEvent() function:
+ * It compares the status registers (SR1 and SR2) content to a given event
+ * (can be the combination of one or more flags).
+ * It returns SUCCESS if the current status includes the given flags
+ * and returns ERROR if one or more flags are missing in the current status.
+ * - When to use:
+ * - This function is suitable for most applications as well as for startup
+ * activity since the events are fully described in the product reference manual
+ * (RM0008).
+ * - It is also suitable for users who need to define their own events.
+ * - Limitations:
+ * - If an error occurs (ie. error flags are set besides to the monitored flags),
+ * the I2C_CheckEvent() function may return SUCCESS despite the communication
+ * hold or corrupted real state.
+ * In this case, it is advised to use error interrupts to monitor the error
+ * events and handle them in the interrupt IRQ handler.
+ *
+ * @note
+ * For error management, it is advised to use the following functions:
+ * - I2C_ITConfig() to configure and enable the error interrupts (I2C_IT_ERR).
+ * - I2Cx_ER_IRQHandler() which is called when the error interrupt occurs.
+ * Where x is the peripheral instance (I2C1, I2C2 ...)
+ * - I2C_GetFlagStatus() or I2C_GetITStatus() to be called into I2Cx_ER_IRQHandler()
+ * in order to determine which error occurred.
+ * - I2C_ClearFlag() or I2C_ClearITPendingBit() and/or I2C_SoftwareResetCmd()
+ * and/or I2C_GenerateStop() in order to clear the error flag and source,
+ * and return to correct communication status.
+ *
+ *
+ * 2) Advanced state monitoring:
+ * Using the function I2C_GetLastEvent() which returns the image of both status
+ * registers in a single word (uint32_t) (Status Register 2 value is shifted left
+ * by 16 bits and concatenated to Status Register 1).
+ * - When to use:
+ * - This function is suitable for the same applications above but it allows to
+ * overcome the limitations of I2C_GetFlagStatus() function (see below).
+ * The returned value could be compared to events already defined in the
+ * library (stm32f10x_i2c.h) or to custom values defined by user.
+ * - This function is suitable when multiple flags are monitored at the same time.
+ * - At the opposite of I2C_CheckEvent() function, this function allows user to
+ * choose when an event is accepted (when all events flags are set and no
+ * other flags are set or just when the needed flags are set like
+ * I2C_CheckEvent() function).
+ * - Limitations:
+ * - User may need to define his own events.
+ * - Same remark concerning the error management is applicable for this
+ * function if user decides to check only regular communication flags (and
+ * ignores error flags).
+ *
+ *
+ * 3) Flag-based state monitoring:
+ * Using the function I2C_GetFlagStatus() which simply returns the status of
+ * one single flag (ie. I2C_FLAG_RXNE ...).
+ * - When to use:
+ * - This function could be used for specific applications or in debug phase.
+ * - It is suitable when only one flag checking is needed (most I2C events
+ * are monitored through multiple flags).
+ * - Limitations:
+ * - When calling this function, the Status register is accessed. Some flags are
+ * cleared when the status register is accessed. So checking the status
+ * of one Flag, may clear other ones.
+ * - Function may need to be called twice or more in order to monitor one
+ * single event.
+ *
+ */
+
+/**
+ *
+ * 1) Basic state monitoring
+ *******************************************************************************
+ */
+ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, uint32_t I2C_EVENT);
+/**
+ *
+ * 2) Advanced state monitoring
+ *******************************************************************************
+ */
+uint32_t I2C_GetLastEvent(I2C_TypeDef* I2Cx);
+/**
+ *
+ * 3) Flag-based state monitoring
+ *******************************************************************************
+ */
+FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG);
+/**
+ *
+ *******************************************************************************
+ */
+
+void I2C_ClearFlag(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG);
+ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, uint32_t I2C_IT);
+void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, uint32_t I2C_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__STM32F10x_I2C_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_iwdg.h b/st_fw_lib/inc/stm32f10x_iwdg.h
new file mode 100644
index 0000000..25b0bb5
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_iwdg.h
@@ -0,0 +1,140 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_iwdg.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the IWDG
+ * firmware library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_IWDG_H
+#define __STM32F10x_IWDG_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup IWDG
+ * @{
+ */
+
+/** @defgroup IWDG_Exported_Types
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup IWDG_Exported_Constants
+ * @{
+ */
+
+/** @defgroup IWDG_WriteAccess
+ * @{
+ */
+
+#define IWDG_WriteAccess_Enable ((uint16_t)0x5555)
+#define IWDG_WriteAccess_Disable ((uint16_t)0x0000)
+#define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \
+ ((ACCESS) == IWDG_WriteAccess_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup IWDG_prescaler
+ * @{
+ */
+
+#define IWDG_Prescaler_4 ((uint8_t)0x00)
+#define IWDG_Prescaler_8 ((uint8_t)0x01)
+#define IWDG_Prescaler_16 ((uint8_t)0x02)
+#define IWDG_Prescaler_32 ((uint8_t)0x03)
+#define IWDG_Prescaler_64 ((uint8_t)0x04)
+#define IWDG_Prescaler_128 ((uint8_t)0x05)
+#define IWDG_Prescaler_256 ((uint8_t)0x06)
+#define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \
+ ((PRESCALER) == IWDG_Prescaler_8) || \
+ ((PRESCALER) == IWDG_Prescaler_16) || \
+ ((PRESCALER) == IWDG_Prescaler_32) || \
+ ((PRESCALER) == IWDG_Prescaler_64) || \
+ ((PRESCALER) == IWDG_Prescaler_128)|| \
+ ((PRESCALER) == IWDG_Prescaler_256))
+/**
+ * @}
+ */
+
+/** @defgroup IWDG_Flag
+ * @{
+ */
+
+#define IWDG_FLAG_PVU ((uint16_t)0x0001)
+#define IWDG_FLAG_RVU ((uint16_t)0x0002)
+#define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU))
+#define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF)
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup IWDG_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup IWDG_Exported_Functions
+ * @{
+ */
+
+void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess);
+void IWDG_SetPrescaler(uint8_t IWDG_Prescaler);
+void IWDG_SetReload(uint16_t Reload);
+void IWDG_ReloadCounter(void);
+void IWDG_Enable(void);
+FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_IWDG_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_pwr.h b/st_fw_lib/inc/stm32f10x_pwr.h
new file mode 100644
index 0000000..1c025e2
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_pwr.h
@@ -0,0 +1,156 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_pwr.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the PWR firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_PWR_H
+#define __STM32F10x_PWR_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup PWR
+ * @{
+ */
+
+/** @defgroup PWR_Exported_Types
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup PWR_Exported_Constants
+ * @{
+ */
+
+/** @defgroup PVD_detection_level
+ * @{
+ */
+
+#define PWR_PVDLevel_2V2 ((uint32_t)0x00000000)
+#define PWR_PVDLevel_2V3 ((uint32_t)0x00000020)
+#define PWR_PVDLevel_2V4 ((uint32_t)0x00000040)
+#define PWR_PVDLevel_2V5 ((uint32_t)0x00000060)
+#define PWR_PVDLevel_2V6 ((uint32_t)0x00000080)
+#define PWR_PVDLevel_2V7 ((uint32_t)0x000000A0)
+#define PWR_PVDLevel_2V8 ((uint32_t)0x000000C0)
+#define PWR_PVDLevel_2V9 ((uint32_t)0x000000E0)
+#define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_2V2) || ((LEVEL) == PWR_PVDLevel_2V3)|| \
+ ((LEVEL) == PWR_PVDLevel_2V4) || ((LEVEL) == PWR_PVDLevel_2V5)|| \
+ ((LEVEL) == PWR_PVDLevel_2V6) || ((LEVEL) == PWR_PVDLevel_2V7)|| \
+ ((LEVEL) == PWR_PVDLevel_2V8) || ((LEVEL) == PWR_PVDLevel_2V9))
+/**
+ * @}
+ */
+
+/** @defgroup Regulator_state_is_STOP_mode
+ * @{
+ */
+
+#define PWR_Regulator_ON ((uint32_t)0x00000000)
+#define PWR_Regulator_LowPower ((uint32_t)0x00000001)
+#define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \
+ ((REGULATOR) == PWR_Regulator_LowPower))
+/**
+ * @}
+ */
+
+/** @defgroup STOP_mode_entry
+ * @{
+ */
+
+#define PWR_STOPEntry_WFI ((uint8_t)0x01)
+#define PWR_STOPEntry_WFE ((uint8_t)0x02)
+#define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE))
+
+/**
+ * @}
+ */
+
+/** @defgroup PWR_Flag
+ * @{
+ */
+
+#define PWR_FLAG_WU ((uint32_t)0x00000001)
+#define PWR_FLAG_SB ((uint32_t)0x00000002)
+#define PWR_FLAG_PVDO ((uint32_t)0x00000004)
+#define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \
+ ((FLAG) == PWR_FLAG_PVDO))
+
+#define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB))
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup PWR_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup PWR_Exported_Functions
+ * @{
+ */
+
+void PWR_DeInit(void);
+void PWR_BackupAccessCmd(FunctionalState NewState);
+void PWR_PVDCmd(FunctionalState NewState);
+void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel);
+void PWR_WakeUpPinCmd(FunctionalState NewState);
+void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);
+void PWR_EnterSTANDBYMode(void);
+FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG);
+void PWR_ClearFlag(uint32_t PWR_FLAG);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_PWR_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_rcc.h b/st_fw_lib/inc/stm32f10x_rcc.h
new file mode 100644
index 0000000..1149c34
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_rcc.h
@@ -0,0 +1,727 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_rcc.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the RCC firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_RCC_H
+#define __STM32F10x_RCC_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup RCC
+ * @{
+ */
+
+/** @defgroup RCC_Exported_Types
+ * @{
+ */
+
+typedef struct
+{
+ uint32_t SYSCLK_Frequency; /*!< returns SYSCLK clock frequency expressed in Hz */
+ uint32_t HCLK_Frequency; /*!< returns HCLK clock frequency expressed in Hz */
+ uint32_t PCLK1_Frequency; /*!< returns PCLK1 clock frequency expressed in Hz */
+ uint32_t PCLK2_Frequency; /*!< returns PCLK2 clock frequency expressed in Hz */
+ uint32_t ADCCLK_Frequency; /*!< returns ADCCLK clock frequency expressed in Hz */
+}RCC_ClocksTypeDef;
+
+/**
+ * @}
+ */
+
+/** @defgroup RCC_Exported_Constants
+ * @{
+ */
+
+/** @defgroup HSE_configuration
+ * @{
+ */
+
+#define RCC_HSE_OFF ((uint32_t)0x00000000)
+#define RCC_HSE_ON ((uint32_t)0x00010000)
+#define RCC_HSE_Bypass ((uint32_t)0x00040000)
+#define IS_RCC_HSE(HSE) (((HSE) == RCC_HSE_OFF) || ((HSE) == RCC_HSE_ON) || \
+ ((HSE) == RCC_HSE_Bypass))
+
+/**
+ * @}
+ */
+
+/** @defgroup PLL_entry_clock_source
+ * @{
+ */
+
+#define RCC_PLLSource_HSI_Div2 ((uint32_t)0x00000000)
+
+#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_CL)
+ #define RCC_PLLSource_HSE_Div1 ((uint32_t)0x00010000)
+ #define RCC_PLLSource_HSE_Div2 ((uint32_t)0x00030000)
+ #define IS_RCC_PLL_SOURCE(SOURCE) (((SOURCE) == RCC_PLLSource_HSI_Div2) || \
+ ((SOURCE) == RCC_PLLSource_HSE_Div1) || \
+ ((SOURCE) == RCC_PLLSource_HSE_Div2))
+#else
+ #define RCC_PLLSource_PREDIV1 ((uint32_t)0x00010000)
+ #define IS_RCC_PLL_SOURCE(SOURCE) (((SOURCE) == RCC_PLLSource_HSI_Div2) || \
+ ((SOURCE) == RCC_PLLSource_PREDIV1))
+#endif /* STM32F10X_CL */
+
+/**
+ * @}
+ */
+
+/** @defgroup PLL_multiplication_factor
+ * @{
+ */
+#ifndef STM32F10X_CL
+ #define RCC_PLLMul_2 ((uint32_t)0x00000000)
+ #define RCC_PLLMul_3 ((uint32_t)0x00040000)
+ #define RCC_PLLMul_4 ((uint32_t)0x00080000)
+ #define RCC_PLLMul_5 ((uint32_t)0x000C0000)
+ #define RCC_PLLMul_6 ((uint32_t)0x00100000)
+ #define RCC_PLLMul_7 ((uint32_t)0x00140000)
+ #define RCC_PLLMul_8 ((uint32_t)0x00180000)
+ #define RCC_PLLMul_9 ((uint32_t)0x001C0000)
+ #define RCC_PLLMul_10 ((uint32_t)0x00200000)
+ #define RCC_PLLMul_11 ((uint32_t)0x00240000)
+ #define RCC_PLLMul_12 ((uint32_t)0x00280000)
+ #define RCC_PLLMul_13 ((uint32_t)0x002C0000)
+ #define RCC_PLLMul_14 ((uint32_t)0x00300000)
+ #define RCC_PLLMul_15 ((uint32_t)0x00340000)
+ #define RCC_PLLMul_16 ((uint32_t)0x00380000)
+ #define IS_RCC_PLL_MUL(MUL) (((MUL) == RCC_PLLMul_2) || ((MUL) == RCC_PLLMul_3) || \
+ ((MUL) == RCC_PLLMul_4) || ((MUL) == RCC_PLLMul_5) || \
+ ((MUL) == RCC_PLLMul_6) || ((MUL) == RCC_PLLMul_7) || \
+ ((MUL) == RCC_PLLMul_8) || ((MUL) == RCC_PLLMul_9) || \
+ ((MUL) == RCC_PLLMul_10) || ((MUL) == RCC_PLLMul_11) || \
+ ((MUL) == RCC_PLLMul_12) || ((MUL) == RCC_PLLMul_13) || \
+ ((MUL) == RCC_PLLMul_14) || ((MUL) == RCC_PLLMul_15) || \
+ ((MUL) == RCC_PLLMul_16))
+
+#else
+ #define RCC_PLLMul_4 ((uint32_t)0x00080000)
+ #define RCC_PLLMul_5 ((uint32_t)0x000C0000)
+ #define RCC_PLLMul_6 ((uint32_t)0x00100000)
+ #define RCC_PLLMul_7 ((uint32_t)0x00140000)
+ #define RCC_PLLMul_8 ((uint32_t)0x00180000)
+ #define RCC_PLLMul_9 ((uint32_t)0x001C0000)
+ #define RCC_PLLMul_6_5 ((uint32_t)0x00340000)
+
+ #define IS_RCC_PLL_MUL(MUL) (((MUL) == RCC_PLLMul_4) || ((MUL) == RCC_PLLMul_5) || \
+ ((MUL) == RCC_PLLMul_6) || ((MUL) == RCC_PLLMul_7) || \
+ ((MUL) == RCC_PLLMul_8) || ((MUL) == RCC_PLLMul_9) || \
+ ((MUL) == RCC_PLLMul_6_5))
+#endif /* STM32F10X_CL */
+/**
+ * @}
+ */
+
+/** @defgroup PREDIV1_division_factor
+ * @{
+ */
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) || defined (STM32F10X_CL)
+ #define RCC_PREDIV1_Div1 ((uint32_t)0x00000000)
+ #define RCC_PREDIV1_Div2 ((uint32_t)0x00000001)
+ #define RCC_PREDIV1_Div3 ((uint32_t)0x00000002)
+ #define RCC_PREDIV1_Div4 ((uint32_t)0x00000003)
+ #define RCC_PREDIV1_Div5 ((uint32_t)0x00000004)
+ #define RCC_PREDIV1_Div6 ((uint32_t)0x00000005)
+ #define RCC_PREDIV1_Div7 ((uint32_t)0x00000006)
+ #define RCC_PREDIV1_Div8 ((uint32_t)0x00000007)
+ #define RCC_PREDIV1_Div9 ((uint32_t)0x00000008)
+ #define RCC_PREDIV1_Div10 ((uint32_t)0x00000009)
+ #define RCC_PREDIV1_Div11 ((uint32_t)0x0000000A)
+ #define RCC_PREDIV1_Div12 ((uint32_t)0x0000000B)
+ #define RCC_PREDIV1_Div13 ((uint32_t)0x0000000C)
+ #define RCC_PREDIV1_Div14 ((uint32_t)0x0000000D)
+ #define RCC_PREDIV1_Div15 ((uint32_t)0x0000000E)
+ #define RCC_PREDIV1_Div16 ((uint32_t)0x0000000F)
+
+ #define IS_RCC_PREDIV1(PREDIV1) (((PREDIV1) == RCC_PREDIV1_Div1) || ((PREDIV1) == RCC_PREDIV1_Div2) || \
+ ((PREDIV1) == RCC_PREDIV1_Div3) || ((PREDIV1) == RCC_PREDIV1_Div4) || \
+ ((PREDIV1) == RCC_PREDIV1_Div5) || ((PREDIV1) == RCC_PREDIV1_Div6) || \
+ ((PREDIV1) == RCC_PREDIV1_Div7) || ((PREDIV1) == RCC_PREDIV1_Div8) || \
+ ((PREDIV1) == RCC_PREDIV1_Div9) || ((PREDIV1) == RCC_PREDIV1_Div10) || \
+ ((PREDIV1) == RCC_PREDIV1_Div11) || ((PREDIV1) == RCC_PREDIV1_Div12) || \
+ ((PREDIV1) == RCC_PREDIV1_Div13) || ((PREDIV1) == RCC_PREDIV1_Div14) || \
+ ((PREDIV1) == RCC_PREDIV1_Div15) || ((PREDIV1) == RCC_PREDIV1_Div16))
+#endif
+/**
+ * @}
+ */
+
+
+/** @defgroup PREDIV1_clock_source
+ * @{
+ */
+#ifdef STM32F10X_CL
+/* PREDIV1 clock source (for STM32 connectivity line devices) */
+ #define RCC_PREDIV1_Source_HSE ((uint32_t)0x00000000)
+ #define RCC_PREDIV1_Source_PLL2 ((uint32_t)0x00010000)
+
+ #define IS_RCC_PREDIV1_SOURCE(SOURCE) (((SOURCE) == RCC_PREDIV1_Source_HSE) || \
+ ((SOURCE) == RCC_PREDIV1_Source_PLL2))
+#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+/* PREDIV1 clock source (for STM32 Value line devices) */
+ #define RCC_PREDIV1_Source_HSE ((uint32_t)0x00000000)
+
+ #define IS_RCC_PREDIV1_SOURCE(SOURCE) (((SOURCE) == RCC_PREDIV1_Source_HSE))
+#endif
+/**
+ * @}
+ */
+
+#ifdef STM32F10X_CL
+/** @defgroup PREDIV2_division_factor
+ * @{
+ */
+
+ #define RCC_PREDIV2_Div1 ((uint32_t)0x00000000)
+ #define RCC_PREDIV2_Div2 ((uint32_t)0x00000010)
+ #define RCC_PREDIV2_Div3 ((uint32_t)0x00000020)
+ #define RCC_PREDIV2_Div4 ((uint32_t)0x00000030)
+ #define RCC_PREDIV2_Div5 ((uint32_t)0x00000040)
+ #define RCC_PREDIV2_Div6 ((uint32_t)0x00000050)
+ #define RCC_PREDIV2_Div7 ((uint32_t)0x00000060)
+ #define RCC_PREDIV2_Div8 ((uint32_t)0x00000070)
+ #define RCC_PREDIV2_Div9 ((uint32_t)0x00000080)
+ #define RCC_PREDIV2_Div10 ((uint32_t)0x00000090)
+ #define RCC_PREDIV2_Div11 ((uint32_t)0x000000A0)
+ #define RCC_PREDIV2_Div12 ((uint32_t)0x000000B0)
+ #define RCC_PREDIV2_Div13 ((uint32_t)0x000000C0)
+ #define RCC_PREDIV2_Div14 ((uint32_t)0x000000D0)
+ #define RCC_PREDIV2_Div15 ((uint32_t)0x000000E0)
+ #define RCC_PREDIV2_Div16 ((uint32_t)0x000000F0)
+
+ #define IS_RCC_PREDIV2(PREDIV2) (((PREDIV2) == RCC_PREDIV2_Div1) || ((PREDIV2) == RCC_PREDIV2_Div2) || \
+ ((PREDIV2) == RCC_PREDIV2_Div3) || ((PREDIV2) == RCC_PREDIV2_Div4) || \
+ ((PREDIV2) == RCC_PREDIV2_Div5) || ((PREDIV2) == RCC_PREDIV2_Div6) || \
+ ((PREDIV2) == RCC_PREDIV2_Div7) || ((PREDIV2) == RCC_PREDIV2_Div8) || \
+ ((PREDIV2) == RCC_PREDIV2_Div9) || ((PREDIV2) == RCC_PREDIV2_Div10) || \
+ ((PREDIV2) == RCC_PREDIV2_Div11) || ((PREDIV2) == RCC_PREDIV2_Div12) || \
+ ((PREDIV2) == RCC_PREDIV2_Div13) || ((PREDIV2) == RCC_PREDIV2_Div14) || \
+ ((PREDIV2) == RCC_PREDIV2_Div15) || ((PREDIV2) == RCC_PREDIV2_Div16))
+/**
+ * @}
+ */
+
+
+/** @defgroup PLL2_multiplication_factor
+ * @{
+ */
+
+ #define RCC_PLL2Mul_8 ((uint32_t)0x00000600)
+ #define RCC_PLL2Mul_9 ((uint32_t)0x00000700)
+ #define RCC_PLL2Mul_10 ((uint32_t)0x00000800)
+ #define RCC_PLL2Mul_11 ((uint32_t)0x00000900)
+ #define RCC_PLL2Mul_12 ((uint32_t)0x00000A00)
+ #define RCC_PLL2Mul_13 ((uint32_t)0x00000B00)
+ #define RCC_PLL2Mul_14 ((uint32_t)0x00000C00)
+ #define RCC_PLL2Mul_16 ((uint32_t)0x00000E00)
+ #define RCC_PLL2Mul_20 ((uint32_t)0x00000F00)
+
+ #define IS_RCC_PLL2_MUL(MUL) (((MUL) == RCC_PLL2Mul_8) || ((MUL) == RCC_PLL2Mul_9) || \
+ ((MUL) == RCC_PLL2Mul_10) || ((MUL) == RCC_PLL2Mul_11) || \
+ ((MUL) == RCC_PLL2Mul_12) || ((MUL) == RCC_PLL2Mul_13) || \
+ ((MUL) == RCC_PLL2Mul_14) || ((MUL) == RCC_PLL2Mul_16) || \
+ ((MUL) == RCC_PLL2Mul_20))
+/**
+ * @}
+ */
+
+
+/** @defgroup PLL3_multiplication_factor
+ * @{
+ */
+
+ #define RCC_PLL3Mul_8 ((uint32_t)0x00006000)
+ #define RCC_PLL3Mul_9 ((uint32_t)0x00007000)
+ #define RCC_PLL3Mul_10 ((uint32_t)0x00008000)
+ #define RCC_PLL3Mul_11 ((uint32_t)0x00009000)
+ #define RCC_PLL3Mul_12 ((uint32_t)0x0000A000)
+ #define RCC_PLL3Mul_13 ((uint32_t)0x0000B000)
+ #define RCC_PLL3Mul_14 ((uint32_t)0x0000C000)
+ #define RCC_PLL3Mul_16 ((uint32_t)0x0000E000)
+ #define RCC_PLL3Mul_20 ((uint32_t)0x0000F000)
+
+ #define IS_RCC_PLL3_MUL(MUL) (((MUL) == RCC_PLL3Mul_8) || ((MUL) == RCC_PLL3Mul_9) || \
+ ((MUL) == RCC_PLL3Mul_10) || ((MUL) == RCC_PLL3Mul_11) || \
+ ((MUL) == RCC_PLL3Mul_12) || ((MUL) == RCC_PLL3Mul_13) || \
+ ((MUL) == RCC_PLL3Mul_14) || ((MUL) == RCC_PLL3Mul_16) || \
+ ((MUL) == RCC_PLL3Mul_20))
+/**
+ * @}
+ */
+
+#endif /* STM32F10X_CL */
+
+
+/** @defgroup System_clock_source
+ * @{
+ */
+
+#define RCC_SYSCLKSource_HSI ((uint32_t)0x00000000)
+#define RCC_SYSCLKSource_HSE ((uint32_t)0x00000001)
+#define RCC_SYSCLKSource_PLLCLK ((uint32_t)0x00000002)
+#define IS_RCC_SYSCLK_SOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSource_HSI) || \
+ ((SOURCE) == RCC_SYSCLKSource_HSE) || \
+ ((SOURCE) == RCC_SYSCLKSource_PLLCLK))
+/**
+ * @}
+ */
+
+/** @defgroup AHB_clock_source
+ * @{
+ */
+
+#define RCC_SYSCLK_Div1 ((uint32_t)0x00000000)
+#define RCC_SYSCLK_Div2 ((uint32_t)0x00000080)
+#define RCC_SYSCLK_Div4 ((uint32_t)0x00000090)
+#define RCC_SYSCLK_Div8 ((uint32_t)0x000000A0)
+#define RCC_SYSCLK_Div16 ((uint32_t)0x000000B0)
+#define RCC_SYSCLK_Div64 ((uint32_t)0x000000C0)
+#define RCC_SYSCLK_Div128 ((uint32_t)0x000000D0)
+#define RCC_SYSCLK_Div256 ((uint32_t)0x000000E0)
+#define RCC_SYSCLK_Div512 ((uint32_t)0x000000F0)
+#define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_Div1) || ((HCLK) == RCC_SYSCLK_Div2) || \
+ ((HCLK) == RCC_SYSCLK_Div4) || ((HCLK) == RCC_SYSCLK_Div8) || \
+ ((HCLK) == RCC_SYSCLK_Div16) || ((HCLK) == RCC_SYSCLK_Div64) || \
+ ((HCLK) == RCC_SYSCLK_Div128) || ((HCLK) == RCC_SYSCLK_Div256) || \
+ ((HCLK) == RCC_SYSCLK_Div512))
+/**
+ * @}
+ */
+
+/** @defgroup APB1_APB2_clock_source
+ * @{
+ */
+
+#define RCC_HCLK_Div1 ((uint32_t)0x00000000)
+#define RCC_HCLK_Div2 ((uint32_t)0x00000400)
+#define RCC_HCLK_Div4 ((uint32_t)0x00000500)
+#define RCC_HCLK_Div8 ((uint32_t)0x00000600)
+#define RCC_HCLK_Div16 ((uint32_t)0x00000700)
+#define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_Div1) || ((PCLK) == RCC_HCLK_Div2) || \
+ ((PCLK) == RCC_HCLK_Div4) || ((PCLK) == RCC_HCLK_Div8) || \
+ ((PCLK) == RCC_HCLK_Div16))
+/**
+ * @}
+ */
+
+/** @defgroup RCC_Interrupt_source
+ * @{
+ */
+
+#define RCC_IT_LSIRDY ((uint8_t)0x01)
+#define RCC_IT_LSERDY ((uint8_t)0x02)
+#define RCC_IT_HSIRDY ((uint8_t)0x04)
+#define RCC_IT_HSERDY ((uint8_t)0x08)
+#define RCC_IT_PLLRDY ((uint8_t)0x10)
+#define RCC_IT_CSS ((uint8_t)0x80)
+
+#ifndef STM32F10X_CL
+ #define IS_RCC_IT(IT) ((((IT) & (uint8_t)0xE0) == 0x00) && ((IT) != 0x00))
+ #define IS_RCC_GET_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \
+ ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \
+ ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_CSS))
+ #define IS_RCC_CLEAR_IT(IT) ((((IT) & (uint8_t)0x60) == 0x00) && ((IT) != 0x00))
+#else
+ #define RCC_IT_PLL2RDY ((uint8_t)0x20)
+ #define RCC_IT_PLL3RDY ((uint8_t)0x40)
+ #define IS_RCC_IT(IT) ((((IT) & (uint8_t)0x80) == 0x00) && ((IT) != 0x00))
+ #define IS_RCC_GET_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \
+ ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \
+ ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_CSS) || \
+ ((IT) == RCC_IT_PLL2RDY) || ((IT) == RCC_IT_PLL3RDY))
+ #define IS_RCC_CLEAR_IT(IT) ((IT) != 0x00)
+#endif /* STM32F10X_CL */
+
+
+/**
+ * @}
+ */
+
+#ifndef STM32F10X_CL
+/** @defgroup USB_Device_clock_source
+ * @{
+ */
+
+ #define RCC_USBCLKSource_PLLCLK_1Div5 ((uint8_t)0x00)
+ #define RCC_USBCLKSource_PLLCLK_Div1 ((uint8_t)0x01)
+
+ #define IS_RCC_USBCLK_SOURCE(SOURCE) (((SOURCE) == RCC_USBCLKSource_PLLCLK_1Div5) || \
+ ((SOURCE) == RCC_USBCLKSource_PLLCLK_Div1))
+/**
+ * @}
+ */
+#else
+/** @defgroup USB_OTG_FS_clock_source
+ * @{
+ */
+ #define RCC_OTGFSCLKSource_PLLVCO_Div3 ((uint8_t)0x00)
+ #define RCC_OTGFSCLKSource_PLLVCO_Div2 ((uint8_t)0x01)
+
+ #define IS_RCC_OTGFSCLK_SOURCE(SOURCE) (((SOURCE) == RCC_OTGFSCLKSource_PLLVCO_Div3) || \
+ ((SOURCE) == RCC_OTGFSCLKSource_PLLVCO_Div2))
+/**
+ * @}
+ */
+#endif /* STM32F10X_CL */
+
+
+#ifdef STM32F10X_CL
+/** @defgroup I2S2_clock_source
+ * @{
+ */
+ #define RCC_I2S2CLKSource_SYSCLK ((uint8_t)0x00)
+ #define RCC_I2S2CLKSource_PLL3_VCO ((uint8_t)0x01)
+
+ #define IS_RCC_I2S2CLK_SOURCE(SOURCE) (((SOURCE) == RCC_I2S2CLKSource_SYSCLK) || \
+ ((SOURCE) == RCC_I2S2CLKSource_PLL3_VCO))
+/**
+ * @}
+ */
+
+/** @defgroup I2S3_clock_source
+ * @{
+ */
+ #define RCC_I2S3CLKSource_SYSCLK ((uint8_t)0x00)
+ #define RCC_I2S3CLKSource_PLL3_VCO ((uint8_t)0x01)
+
+ #define IS_RCC_I2S3CLK_SOURCE(SOURCE) (((SOURCE) == RCC_I2S3CLKSource_SYSCLK) || \
+ ((SOURCE) == RCC_I2S3CLKSource_PLL3_VCO))
+/**
+ * @}
+ */
+#endif /* STM32F10X_CL */
+
+
+/** @defgroup ADC_clock_source
+ * @{
+ */
+
+#define RCC_PCLK2_Div2 ((uint32_t)0x00000000)
+#define RCC_PCLK2_Div4 ((uint32_t)0x00004000)
+#define RCC_PCLK2_Div6 ((uint32_t)0x00008000)
+#define RCC_PCLK2_Div8 ((uint32_t)0x0000C000)
+#define IS_RCC_ADCCLK(ADCCLK) (((ADCCLK) == RCC_PCLK2_Div2) || ((ADCCLK) == RCC_PCLK2_Div4) || \
+ ((ADCCLK) == RCC_PCLK2_Div6) || ((ADCCLK) == RCC_PCLK2_Div8))
+/**
+ * @}
+ */
+
+/** @defgroup LSE_configuration
+ * @{
+ */
+
+#define RCC_LSE_OFF ((uint8_t)0x00)
+#define RCC_LSE_ON ((uint8_t)0x01)
+#define RCC_LSE_Bypass ((uint8_t)0x04)
+#define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \
+ ((LSE) == RCC_LSE_Bypass))
+/**
+ * @}
+ */
+
+/** @defgroup RTC_clock_source
+ * @{
+ */
+
+#define RCC_RTCCLKSource_LSE ((uint32_t)0x00000100)
+#define RCC_RTCCLKSource_LSI ((uint32_t)0x00000200)
+#define RCC_RTCCLKSource_HSE_Div128 ((uint32_t)0x00000300)
+#define IS_RCC_RTCCLK_SOURCE(SOURCE) (((SOURCE) == RCC_RTCCLKSource_LSE) || \
+ ((SOURCE) == RCC_RTCCLKSource_LSI) || \
+ ((SOURCE) == RCC_RTCCLKSource_HSE_Div128))
+/**
+ * @}
+ */
+
+/** @defgroup AHB_peripheral
+ * @{
+ */
+
+#define RCC_AHBPeriph_DMA1 ((uint32_t)0x00000001)
+#define RCC_AHBPeriph_DMA2 ((uint32_t)0x00000002)
+#define RCC_AHBPeriph_SRAM ((uint32_t)0x00000004)
+#define RCC_AHBPeriph_FLITF ((uint32_t)0x00000010)
+#define RCC_AHBPeriph_CRC ((uint32_t)0x00000040)
+
+#ifndef STM32F10X_CL
+ #define RCC_AHBPeriph_FSMC ((uint32_t)0x00000100)
+ #define RCC_AHBPeriph_SDIO ((uint32_t)0x00000400)
+ #define IS_RCC_AHB_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFAA8) == 0x00) && ((PERIPH) != 0x00))
+#else
+ #define RCC_AHBPeriph_OTG_FS ((uint32_t)0x00001000)
+ #define RCC_AHBPeriph_ETH_MAC ((uint32_t)0x00004000)
+ #define RCC_AHBPeriph_ETH_MAC_Tx ((uint32_t)0x00008000)
+ #define RCC_AHBPeriph_ETH_MAC_Rx ((uint32_t)0x00010000)
+
+ #define IS_RCC_AHB_PERIPH(PERIPH) ((((PERIPH) & 0xFFFE2FA8) == 0x00) && ((PERIPH) != 0x00))
+ #define IS_RCC_AHB_PERIPH_RESET(PERIPH) ((((PERIPH) & 0xFFFFAFFF) == 0x00) && ((PERIPH) != 0x00))
+#endif /* STM32F10X_CL */
+/**
+ * @}
+ */
+
+/** @defgroup APB2_peripheral
+ * @{
+ */
+
+#define RCC_APB2Periph_AFIO ((uint32_t)0x00000001)
+#define RCC_APB2Periph_GPIOA ((uint32_t)0x00000004)
+#define RCC_APB2Periph_GPIOB ((uint32_t)0x00000008)
+#define RCC_APB2Periph_GPIOC ((uint32_t)0x00000010)
+#define RCC_APB2Periph_GPIOD ((uint32_t)0x00000020)
+#define RCC_APB2Periph_GPIOE ((uint32_t)0x00000040)
+#define RCC_APB2Periph_GPIOF ((uint32_t)0x00000080)
+#define RCC_APB2Periph_GPIOG ((uint32_t)0x00000100)
+#define RCC_APB2Periph_ADC1 ((uint32_t)0x00000200)
+#define RCC_APB2Periph_ADC2 ((uint32_t)0x00000400)
+#define RCC_APB2Periph_TIM1 ((uint32_t)0x00000800)
+#define RCC_APB2Periph_SPI1 ((uint32_t)0x00001000)
+#define RCC_APB2Periph_TIM8 ((uint32_t)0x00002000)
+#define RCC_APB2Periph_USART1 ((uint32_t)0x00004000)
+#define RCC_APB2Periph_ADC3 ((uint32_t)0x00008000)
+#define RCC_APB2Periph_TIM15 ((uint32_t)0x00010000)
+#define RCC_APB2Periph_TIM16 ((uint32_t)0x00020000)
+#define RCC_APB2Periph_TIM17 ((uint32_t)0x00040000)
+#define RCC_APB2Periph_TIM9 ((uint32_t)0x00080000)
+#define RCC_APB2Periph_TIM10 ((uint32_t)0x00100000)
+#define RCC_APB2Periph_TIM11 ((uint32_t)0x00200000)
+
+#define IS_RCC_APB2_PERIPH(PERIPH) ((((PERIPH) & 0xFFC00002) == 0x00) && ((PERIPH) != 0x00))
+/**
+ * @}
+ */
+
+/** @defgroup APB1_peripheral
+ * @{
+ */
+
+#define RCC_APB1Periph_TIM2 ((uint32_t)0x00000001)
+#define RCC_APB1Periph_TIM3 ((uint32_t)0x00000002)
+#define RCC_APB1Periph_TIM4 ((uint32_t)0x00000004)
+#define RCC_APB1Periph_TIM5 ((uint32_t)0x00000008)
+#define RCC_APB1Periph_TIM6 ((uint32_t)0x00000010)
+#define RCC_APB1Periph_TIM7 ((uint32_t)0x00000020)
+#define RCC_APB1Periph_TIM12 ((uint32_t)0x00000040)
+#define RCC_APB1Periph_TIM13 ((uint32_t)0x00000080)
+#define RCC_APB1Periph_TIM14 ((uint32_t)0x00000100)
+#define RCC_APB1Periph_WWDG ((uint32_t)0x00000800)
+#define RCC_APB1Periph_SPI2 ((uint32_t)0x00004000)
+#define RCC_APB1Periph_SPI3 ((uint32_t)0x00008000)
+#define RCC_APB1Periph_USART2 ((uint32_t)0x00020000)
+#define RCC_APB1Periph_USART3 ((uint32_t)0x00040000)
+#define RCC_APB1Periph_UART4 ((uint32_t)0x00080000)
+#define RCC_APB1Periph_UART5 ((uint32_t)0x00100000)
+#define RCC_APB1Periph_I2C1 ((uint32_t)0x00200000)
+#define RCC_APB1Periph_I2C2 ((uint32_t)0x00400000)
+#define RCC_APB1Periph_USB ((uint32_t)0x00800000)
+#define RCC_APB1Periph_CAN1 ((uint32_t)0x02000000)
+#define RCC_APB1Periph_CAN2 ((uint32_t)0x04000000)
+#define RCC_APB1Periph_BKP ((uint32_t)0x08000000)
+#define RCC_APB1Periph_PWR ((uint32_t)0x10000000)
+#define RCC_APB1Periph_DAC ((uint32_t)0x20000000)
+#define RCC_APB1Periph_CEC ((uint32_t)0x40000000)
+
+#define IS_RCC_APB1_PERIPH(PERIPH) ((((PERIPH) & 0x81013600) == 0x00) && ((PERIPH) != 0x00))
+
+/**
+ * @}
+ */
+
+/** @defgroup Clock_source_to_output_on_MCO_pin
+ * @{
+ */
+
+#define RCC_MCO_NoClock ((uint8_t)0x00)
+#define RCC_MCO_SYSCLK ((uint8_t)0x04)
+#define RCC_MCO_HSI ((uint8_t)0x05)
+#define RCC_MCO_HSE ((uint8_t)0x06)
+#define RCC_MCO_PLLCLK_Div2 ((uint8_t)0x07)
+
+#ifndef STM32F10X_CL
+ #define IS_RCC_MCO(MCO) (((MCO) == RCC_MCO_NoClock) || ((MCO) == RCC_MCO_HSI) || \
+ ((MCO) == RCC_MCO_SYSCLK) || ((MCO) == RCC_MCO_HSE) || \
+ ((MCO) == RCC_MCO_PLLCLK_Div2))
+#else
+ #define RCC_MCO_PLL2CLK ((uint8_t)0x08)
+ #define RCC_MCO_PLL3CLK_Div2 ((uint8_t)0x09)
+ #define RCC_MCO_XT1 ((uint8_t)0x0A)
+ #define RCC_MCO_PLL3CLK ((uint8_t)0x0B)
+
+ #define IS_RCC_MCO(MCO) (((MCO) == RCC_MCO_NoClock) || ((MCO) == RCC_MCO_HSI) || \
+ ((MCO) == RCC_MCO_SYSCLK) || ((MCO) == RCC_MCO_HSE) || \
+ ((MCO) == RCC_MCO_PLLCLK_Div2) || ((MCO) == RCC_MCO_PLL2CLK) || \
+ ((MCO) == RCC_MCO_PLL3CLK_Div2) || ((MCO) == RCC_MCO_XT1) || \
+ ((MCO) == RCC_MCO_PLL3CLK))
+#endif /* STM32F10X_CL */
+
+/**
+ * @}
+ */
+
+/** @defgroup RCC_Flag
+ * @{
+ */
+
+#define RCC_FLAG_HSIRDY ((uint8_t)0x21)
+#define RCC_FLAG_HSERDY ((uint8_t)0x31)
+#define RCC_FLAG_PLLRDY ((uint8_t)0x39)
+#define RCC_FLAG_LSERDY ((uint8_t)0x41)
+#define RCC_FLAG_LSIRDY ((uint8_t)0x61)
+#define RCC_FLAG_PINRST ((uint8_t)0x7A)
+#define RCC_FLAG_PORRST ((uint8_t)0x7B)
+#define RCC_FLAG_SFTRST ((uint8_t)0x7C)
+#define RCC_FLAG_IWDGRST ((uint8_t)0x7D)
+#define RCC_FLAG_WWDGRST ((uint8_t)0x7E)
+#define RCC_FLAG_LPWRRST ((uint8_t)0x7F)
+
+#ifndef STM32F10X_CL
+ #define IS_RCC_FLAG(FLAG) (((FLAG) == RCC_FLAG_HSIRDY) || ((FLAG) == RCC_FLAG_HSERDY) || \
+ ((FLAG) == RCC_FLAG_PLLRDY) || ((FLAG) == RCC_FLAG_LSERDY) || \
+ ((FLAG) == RCC_FLAG_LSIRDY) || ((FLAG) == RCC_FLAG_PINRST) || \
+ ((FLAG) == RCC_FLAG_PORRST) || ((FLAG) == RCC_FLAG_SFTRST) || \
+ ((FLAG) == RCC_FLAG_IWDGRST)|| ((FLAG) == RCC_FLAG_WWDGRST)|| \
+ ((FLAG) == RCC_FLAG_LPWRRST))
+#else
+ #define RCC_FLAG_PLL2RDY ((uint8_t)0x3B)
+ #define RCC_FLAG_PLL3RDY ((uint8_t)0x3D)
+ #define IS_RCC_FLAG(FLAG) (((FLAG) == RCC_FLAG_HSIRDY) || ((FLAG) == RCC_FLAG_HSERDY) || \
+ ((FLAG) == RCC_FLAG_PLLRDY) || ((FLAG) == RCC_FLAG_LSERDY) || \
+ ((FLAG) == RCC_FLAG_PLL2RDY) || ((FLAG) == RCC_FLAG_PLL3RDY) || \
+ ((FLAG) == RCC_FLAG_LSIRDY) || ((FLAG) == RCC_FLAG_PINRST) || \
+ ((FLAG) == RCC_FLAG_PORRST) || ((FLAG) == RCC_FLAG_SFTRST) || \
+ ((FLAG) == RCC_FLAG_IWDGRST)|| ((FLAG) == RCC_FLAG_WWDGRST)|| \
+ ((FLAG) == RCC_FLAG_LPWRRST))
+#endif /* STM32F10X_CL */
+
+#define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1F)
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RCC_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RCC_Exported_Functions
+ * @{
+ */
+
+void RCC_DeInit(void);
+void RCC_HSEConfig(uint32_t RCC_HSE);
+ErrorStatus RCC_WaitForHSEStartUp(void);
+void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue);
+void RCC_HSICmd(FunctionalState NewState);
+void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t RCC_PLLMul);
+void RCC_PLLCmd(FunctionalState NewState);
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) || defined (STM32F10X_CL)
+ void RCC_PREDIV1Config(uint32_t RCC_PREDIV1_Source, uint32_t RCC_PREDIV1_Div);
+#endif
+
+#ifdef STM32F10X_CL
+ void RCC_PREDIV2Config(uint32_t RCC_PREDIV2_Div);
+ void RCC_PLL2Config(uint32_t RCC_PLL2Mul);
+ void RCC_PLL2Cmd(FunctionalState NewState);
+ void RCC_PLL3Config(uint32_t RCC_PLL3Mul);
+ void RCC_PLL3Cmd(FunctionalState NewState);
+#endif /* STM32F10X_CL */
+
+void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource);
+uint8_t RCC_GetSYSCLKSource(void);
+void RCC_HCLKConfig(uint32_t RCC_SYSCLK);
+void RCC_PCLK1Config(uint32_t RCC_HCLK);
+void RCC_PCLK2Config(uint32_t RCC_HCLK);
+void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState);
+
+#ifndef STM32F10X_CL
+ void RCC_USBCLKConfig(uint32_t RCC_USBCLKSource);
+#else
+ void RCC_OTGFSCLKConfig(uint32_t RCC_OTGFSCLKSource);
+#endif /* STM32F10X_CL */
+
+void RCC_ADCCLKConfig(uint32_t RCC_PCLK2);
+
+#ifdef STM32F10X_CL
+ void RCC_I2S2CLKConfig(uint32_t RCC_I2S2CLKSource);
+ void RCC_I2S3CLKConfig(uint32_t RCC_I2S3CLKSource);
+#endif /* STM32F10X_CL */
+
+void RCC_LSEConfig(uint8_t RCC_LSE);
+void RCC_LSICmd(FunctionalState NewState);
+void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource);
+void RCC_RTCCLKCmd(FunctionalState NewState);
+void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks);
+void RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState);
+void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
+void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
+
+#ifdef STM32F10X_CL
+void RCC_AHBPeriphResetCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState);
+#endif /* STM32F10X_CL */
+
+void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
+void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
+void RCC_BackupResetCmd(FunctionalState NewState);
+void RCC_ClockSecuritySystemCmd(FunctionalState NewState);
+void RCC_MCOConfig(uint8_t RCC_MCO);
+FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG);
+void RCC_ClearFlag(void);
+ITStatus RCC_GetITStatus(uint8_t RCC_IT);
+void RCC_ClearITPendingBit(uint8_t RCC_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_RCC_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_rtc.h b/st_fw_lib/inc/stm32f10x_rtc.h
new file mode 100644
index 0000000..fd8beb5
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_rtc.h
@@ -0,0 +1,135 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_rtc.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the RTC firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_RTC_H
+#define __STM32F10x_RTC_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup RTC
+ * @{
+ */
+
+/** @defgroup RTC_Exported_Types
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RTC_Exported_Constants
+ * @{
+ */
+
+/** @defgroup RTC_interrupts_define
+ * @{
+ */
+
+#define RTC_IT_OW ((uint16_t)0x0004) /*!< Overflow interrupt */
+#define RTC_IT_ALR ((uint16_t)0x0002) /*!< Alarm interrupt */
+#define RTC_IT_SEC ((uint16_t)0x0001) /*!< Second interrupt */
+#define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00))
+#define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \
+ ((IT) == RTC_IT_SEC))
+/**
+ * @}
+ */
+
+/** @defgroup RTC_interrupts_flags
+ * @{
+ */
+
+#define RTC_FLAG_RTOFF ((uint16_t)0x0020) /*!< RTC Operation OFF flag */
+#define RTC_FLAG_RSF ((uint16_t)0x0008) /*!< Registers Synchronized flag */
+#define RTC_FLAG_OW ((uint16_t)0x0004) /*!< Overflow flag */
+#define RTC_FLAG_ALR ((uint16_t)0x0002) /*!< Alarm flag */
+#define RTC_FLAG_SEC ((uint16_t)0x0001) /*!< Second flag */
+#define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00))
+#define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \
+ ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \
+ ((FLAG) == RTC_FLAG_SEC))
+#define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF)
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RTC_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RTC_Exported_Functions
+ * @{
+ */
+
+void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState);
+void RTC_EnterConfigMode(void);
+void RTC_ExitConfigMode(void);
+uint32_t RTC_GetCounter(void);
+void RTC_SetCounter(uint32_t CounterValue);
+void RTC_SetPrescaler(uint32_t PrescalerValue);
+void RTC_SetAlarm(uint32_t AlarmValue);
+uint32_t RTC_GetDivider(void);
+void RTC_WaitForLastTask(void);
+void RTC_WaitForSynchro(void);
+FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG);
+void RTC_ClearFlag(uint16_t RTC_FLAG);
+ITStatus RTC_GetITStatus(uint16_t RTC_IT);
+void RTC_ClearITPendingBit(uint16_t RTC_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_RTC_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_sdio.h b/st_fw_lib/inc/stm32f10x_sdio.h
new file mode 100644
index 0000000..81c058a
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_sdio.h
@@ -0,0 +1,531 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_sdio.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the SDIO firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_SDIO_H
+#define __STM32F10x_SDIO_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup SDIO
+ * @{
+ */
+
+/** @defgroup SDIO_Exported_Types
+ * @{
+ */
+
+typedef struct
+{
+ uint32_t SDIO_ClockEdge; /*!< Specifies the clock transition on which the bit capture is made.
+ This parameter can be a value of @ref SDIO_Clock_Edge */
+
+ uint32_t SDIO_ClockBypass; /*!< Specifies whether the SDIO Clock divider bypass is
+ enabled or disabled.
+ This parameter can be a value of @ref SDIO_Clock_Bypass */
+
+ uint32_t SDIO_ClockPowerSave; /*!< Specifies whether SDIO Clock output is enabled or
+ disabled when the bus is idle.
+ This parameter can be a value of @ref SDIO_Clock_Power_Save */
+
+ uint32_t SDIO_BusWide; /*!< Specifies the SDIO bus width.
+ This parameter can be a value of @ref SDIO_Bus_Wide */
+
+ uint32_t SDIO_HardwareFlowControl; /*!< Specifies whether the SDIO hardware flow control is enabled or disabled.
+ This parameter can be a value of @ref SDIO_Hardware_Flow_Control */
+
+ uint8_t SDIO_ClockDiv; /*!< Specifies the clock frequency of the SDIO controller.
+ This parameter can be a value between 0x00 and 0xFF. */
+
+} SDIO_InitTypeDef;
+
+typedef struct
+{
+ uint32_t SDIO_Argument; /*!< Specifies the SDIO command argument which is sent
+ to a card as part of a command message. If a command
+ contains an argument, it must be loaded into this register
+ before writing the command to the command register */
+
+ uint32_t SDIO_CmdIndex; /*!< Specifies the SDIO command index. It must be lower than 0x40. */
+
+ uint32_t SDIO_Response; /*!< Specifies the SDIO response type.
+ This parameter can be a value of @ref SDIO_Response_Type */
+
+ uint32_t SDIO_Wait; /*!< Specifies whether SDIO wait-for-interrupt request is enabled or disabled.
+ This parameter can be a value of @ref SDIO_Wait_Interrupt_State */
+
+ uint32_t SDIO_CPSM; /*!< Specifies whether SDIO Command path state machine (CPSM)
+ is enabled or disabled.
+ This parameter can be a value of @ref SDIO_CPSM_State */
+} SDIO_CmdInitTypeDef;
+
+typedef struct
+{
+ uint32_t SDIO_DataTimeOut; /*!< Specifies the data timeout period in card bus clock periods. */
+
+ uint32_t SDIO_DataLength; /*!< Specifies the number of data bytes to be transferred. */
+
+ uint32_t SDIO_DataBlockSize; /*!< Specifies the data block size for block transfer.
+ This parameter can be a value of @ref SDIO_Data_Block_Size */
+
+ uint32_t SDIO_TransferDir; /*!< Specifies the data transfer direction, whether the transfer
+ is a read or write.
+ This parameter can be a value of @ref SDIO_Transfer_Direction */
+
+ uint32_t SDIO_TransferMode; /*!< Specifies whether data transfer is in stream or block mode.
+ This parameter can be a value of @ref SDIO_Transfer_Type */
+
+ uint32_t SDIO_DPSM; /*!< Specifies whether SDIO Data path state machine (DPSM)
+ is enabled or disabled.
+ This parameter can be a value of @ref SDIO_DPSM_State */
+} SDIO_DataInitTypeDef;
+
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Exported_Constants
+ * @{
+ */
+
+/** @defgroup SDIO_Clock_Edge
+ * @{
+ */
+
+#define SDIO_ClockEdge_Rising ((uint32_t)0x00000000)
+#define SDIO_ClockEdge_Falling ((uint32_t)0x00002000)
+#define IS_SDIO_CLOCK_EDGE(EDGE) (((EDGE) == SDIO_ClockEdge_Rising) || \
+ ((EDGE) == SDIO_ClockEdge_Falling))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Clock_Bypass
+ * @{
+ */
+
+#define SDIO_ClockBypass_Disable ((uint32_t)0x00000000)
+#define SDIO_ClockBypass_Enable ((uint32_t)0x00000400)
+#define IS_SDIO_CLOCK_BYPASS(BYPASS) (((BYPASS) == SDIO_ClockBypass_Disable) || \
+ ((BYPASS) == SDIO_ClockBypass_Enable))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Clock_Power_Save
+ * @{
+ */
+
+#define SDIO_ClockPowerSave_Disable ((uint32_t)0x00000000)
+#define SDIO_ClockPowerSave_Enable ((uint32_t)0x00000200)
+#define IS_SDIO_CLOCK_POWER_SAVE(SAVE) (((SAVE) == SDIO_ClockPowerSave_Disable) || \
+ ((SAVE) == SDIO_ClockPowerSave_Enable))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Bus_Wide
+ * @{
+ */
+
+#define SDIO_BusWide_1b ((uint32_t)0x00000000)
+#define SDIO_BusWide_4b ((uint32_t)0x00000800)
+#define SDIO_BusWide_8b ((uint32_t)0x00001000)
+#define IS_SDIO_BUS_WIDE(WIDE) (((WIDE) == SDIO_BusWide_1b) || ((WIDE) == SDIO_BusWide_4b) || \
+ ((WIDE) == SDIO_BusWide_8b))
+
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Hardware_Flow_Control
+ * @{
+ */
+
+#define SDIO_HardwareFlowControl_Disable ((uint32_t)0x00000000)
+#define SDIO_HardwareFlowControl_Enable ((uint32_t)0x00004000)
+#define IS_SDIO_HARDWARE_FLOW_CONTROL(CONTROL) (((CONTROL) == SDIO_HardwareFlowControl_Disable) || \
+ ((CONTROL) == SDIO_HardwareFlowControl_Enable))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Power_State
+ * @{
+ */
+
+#define SDIO_PowerState_OFF ((uint32_t)0x00000000)
+#define SDIO_PowerState_ON ((uint32_t)0x00000003)
+#define IS_SDIO_POWER_STATE(STATE) (((STATE) == SDIO_PowerState_OFF) || ((STATE) == SDIO_PowerState_ON))
+/**
+ * @}
+ */
+
+
+/** @defgroup SDIO_Interrupt_sources
+ * @{
+ */
+
+#define SDIO_IT_CCRCFAIL ((uint32_t)0x00000001)
+#define SDIO_IT_DCRCFAIL ((uint32_t)0x00000002)
+#define SDIO_IT_CTIMEOUT ((uint32_t)0x00000004)
+#define SDIO_IT_DTIMEOUT ((uint32_t)0x00000008)
+#define SDIO_IT_TXUNDERR ((uint32_t)0x00000010)
+#define SDIO_IT_RXOVERR ((uint32_t)0x00000020)
+#define SDIO_IT_CMDREND ((uint32_t)0x00000040)
+#define SDIO_IT_CMDSENT ((uint32_t)0x00000080)
+#define SDIO_IT_DATAEND ((uint32_t)0x00000100)
+#define SDIO_IT_STBITERR ((uint32_t)0x00000200)
+#define SDIO_IT_DBCKEND ((uint32_t)0x00000400)
+#define SDIO_IT_CMDACT ((uint32_t)0x00000800)
+#define SDIO_IT_TXACT ((uint32_t)0x00001000)
+#define SDIO_IT_RXACT ((uint32_t)0x00002000)
+#define SDIO_IT_TXFIFOHE ((uint32_t)0x00004000)
+#define SDIO_IT_RXFIFOHF ((uint32_t)0x00008000)
+#define SDIO_IT_TXFIFOF ((uint32_t)0x00010000)
+#define SDIO_IT_RXFIFOF ((uint32_t)0x00020000)
+#define SDIO_IT_TXFIFOE ((uint32_t)0x00040000)
+#define SDIO_IT_RXFIFOE ((uint32_t)0x00080000)
+#define SDIO_IT_TXDAVL ((uint32_t)0x00100000)
+#define SDIO_IT_RXDAVL ((uint32_t)0x00200000)
+#define SDIO_IT_SDIOIT ((uint32_t)0x00400000)
+#define SDIO_IT_CEATAEND ((uint32_t)0x00800000)
+#define IS_SDIO_IT(IT) ((((IT) & (uint32_t)0xFF000000) == 0x00) && ((IT) != (uint32_t)0x00))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Command_Index
+ * @{
+ */
+
+#define IS_SDIO_CMD_INDEX(INDEX) ((INDEX) < 0x40)
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Response_Type
+ * @{
+ */
+
+#define SDIO_Response_No ((uint32_t)0x00000000)
+#define SDIO_Response_Short ((uint32_t)0x00000040)
+#define SDIO_Response_Long ((uint32_t)0x000000C0)
+#define IS_SDIO_RESPONSE(RESPONSE) (((RESPONSE) == SDIO_Response_No) || \
+ ((RESPONSE) == SDIO_Response_Short) || \
+ ((RESPONSE) == SDIO_Response_Long))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Wait_Interrupt_State
+ * @{
+ */
+
+#define SDIO_Wait_No ((uint32_t)0x00000000) /*!< SDIO No Wait, TimeOut is enabled */
+#define SDIO_Wait_IT ((uint32_t)0x00000100) /*!< SDIO Wait Interrupt Request */
+#define SDIO_Wait_Pend ((uint32_t)0x00000200) /*!< SDIO Wait End of transfer */
+#define IS_SDIO_WAIT(WAIT) (((WAIT) == SDIO_Wait_No) || ((WAIT) == SDIO_Wait_IT) || \
+ ((WAIT) == SDIO_Wait_Pend))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_CPSM_State
+ * @{
+ */
+
+#define SDIO_CPSM_Disable ((uint32_t)0x00000000)
+#define SDIO_CPSM_Enable ((uint32_t)0x00000400)
+#define IS_SDIO_CPSM(CPSM) (((CPSM) == SDIO_CPSM_Enable) || ((CPSM) == SDIO_CPSM_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Response_Registers
+ * @{
+ */
+
+#define SDIO_RESP1 ((uint32_t)0x00000000)
+#define SDIO_RESP2 ((uint32_t)0x00000004)
+#define SDIO_RESP3 ((uint32_t)0x00000008)
+#define SDIO_RESP4 ((uint32_t)0x0000000C)
+#define IS_SDIO_RESP(RESP) (((RESP) == SDIO_RESP1) || ((RESP) == SDIO_RESP2) || \
+ ((RESP) == SDIO_RESP3) || ((RESP) == SDIO_RESP4))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Data_Length
+ * @{
+ */
+
+#define IS_SDIO_DATA_LENGTH(LENGTH) ((LENGTH) <= 0x01FFFFFF)
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Data_Block_Size
+ * @{
+ */
+
+#define SDIO_DataBlockSize_1b ((uint32_t)0x00000000)
+#define SDIO_DataBlockSize_2b ((uint32_t)0x00000010)
+#define SDIO_DataBlockSize_4b ((uint32_t)0x00000020)
+#define SDIO_DataBlockSize_8b ((uint32_t)0x00000030)
+#define SDIO_DataBlockSize_16b ((uint32_t)0x00000040)
+#define SDIO_DataBlockSize_32b ((uint32_t)0x00000050)
+#define SDIO_DataBlockSize_64b ((uint32_t)0x00000060)
+#define SDIO_DataBlockSize_128b ((uint32_t)0x00000070)
+#define SDIO_DataBlockSize_256b ((uint32_t)0x00000080)
+#define SDIO_DataBlockSize_512b ((uint32_t)0x00000090)
+#define SDIO_DataBlockSize_1024b ((uint32_t)0x000000A0)
+#define SDIO_DataBlockSize_2048b ((uint32_t)0x000000B0)
+#define SDIO_DataBlockSize_4096b ((uint32_t)0x000000C0)
+#define SDIO_DataBlockSize_8192b ((uint32_t)0x000000D0)
+#define SDIO_DataBlockSize_16384b ((uint32_t)0x000000E0)
+#define IS_SDIO_BLOCK_SIZE(SIZE) (((SIZE) == SDIO_DataBlockSize_1b) || \
+ ((SIZE) == SDIO_DataBlockSize_2b) || \
+ ((SIZE) == SDIO_DataBlockSize_4b) || \
+ ((SIZE) == SDIO_DataBlockSize_8b) || \
+ ((SIZE) == SDIO_DataBlockSize_16b) || \
+ ((SIZE) == SDIO_DataBlockSize_32b) || \
+ ((SIZE) == SDIO_DataBlockSize_64b) || \
+ ((SIZE) == SDIO_DataBlockSize_128b) || \
+ ((SIZE) == SDIO_DataBlockSize_256b) || \
+ ((SIZE) == SDIO_DataBlockSize_512b) || \
+ ((SIZE) == SDIO_DataBlockSize_1024b) || \
+ ((SIZE) == SDIO_DataBlockSize_2048b) || \
+ ((SIZE) == SDIO_DataBlockSize_4096b) || \
+ ((SIZE) == SDIO_DataBlockSize_8192b) || \
+ ((SIZE) == SDIO_DataBlockSize_16384b))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Transfer_Direction
+ * @{
+ */
+
+#define SDIO_TransferDir_ToCard ((uint32_t)0x00000000)
+#define SDIO_TransferDir_ToSDIO ((uint32_t)0x00000002)
+#define IS_SDIO_TRANSFER_DIR(DIR) (((DIR) == SDIO_TransferDir_ToCard) || \
+ ((DIR) == SDIO_TransferDir_ToSDIO))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Transfer_Type
+ * @{
+ */
+
+#define SDIO_TransferMode_Block ((uint32_t)0x00000000)
+#define SDIO_TransferMode_Stream ((uint32_t)0x00000004)
+#define IS_SDIO_TRANSFER_MODE(MODE) (((MODE) == SDIO_TransferMode_Stream) || \
+ ((MODE) == SDIO_TransferMode_Block))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_DPSM_State
+ * @{
+ */
+
+#define SDIO_DPSM_Disable ((uint32_t)0x00000000)
+#define SDIO_DPSM_Enable ((uint32_t)0x00000001)
+#define IS_SDIO_DPSM(DPSM) (((DPSM) == SDIO_DPSM_Enable) || ((DPSM) == SDIO_DPSM_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Flags
+ * @{
+ */
+
+#define SDIO_FLAG_CCRCFAIL ((uint32_t)0x00000001)
+#define SDIO_FLAG_DCRCFAIL ((uint32_t)0x00000002)
+#define SDIO_FLAG_CTIMEOUT ((uint32_t)0x00000004)
+#define SDIO_FLAG_DTIMEOUT ((uint32_t)0x00000008)
+#define SDIO_FLAG_TXUNDERR ((uint32_t)0x00000010)
+#define SDIO_FLAG_RXOVERR ((uint32_t)0x00000020)
+#define SDIO_FLAG_CMDREND ((uint32_t)0x00000040)
+#define SDIO_FLAG_CMDSENT ((uint32_t)0x00000080)
+#define SDIO_FLAG_DATAEND ((uint32_t)0x00000100)
+#define SDIO_FLAG_STBITERR ((uint32_t)0x00000200)
+#define SDIO_FLAG_DBCKEND ((uint32_t)0x00000400)
+#define SDIO_FLAG_CMDACT ((uint32_t)0x00000800)
+#define SDIO_FLAG_TXACT ((uint32_t)0x00001000)
+#define SDIO_FLAG_RXACT ((uint32_t)0x00002000)
+#define SDIO_FLAG_TXFIFOHE ((uint32_t)0x00004000)
+#define SDIO_FLAG_RXFIFOHF ((uint32_t)0x00008000)
+#define SDIO_FLAG_TXFIFOF ((uint32_t)0x00010000)
+#define SDIO_FLAG_RXFIFOF ((uint32_t)0x00020000)
+#define SDIO_FLAG_TXFIFOE ((uint32_t)0x00040000)
+#define SDIO_FLAG_RXFIFOE ((uint32_t)0x00080000)
+#define SDIO_FLAG_TXDAVL ((uint32_t)0x00100000)
+#define SDIO_FLAG_RXDAVL ((uint32_t)0x00200000)
+#define SDIO_FLAG_SDIOIT ((uint32_t)0x00400000)
+#define SDIO_FLAG_CEATAEND ((uint32_t)0x00800000)
+#define IS_SDIO_FLAG(FLAG) (((FLAG) == SDIO_FLAG_CCRCFAIL) || \
+ ((FLAG) == SDIO_FLAG_DCRCFAIL) || \
+ ((FLAG) == SDIO_FLAG_CTIMEOUT) || \
+ ((FLAG) == SDIO_FLAG_DTIMEOUT) || \
+ ((FLAG) == SDIO_FLAG_TXUNDERR) || \
+ ((FLAG) == SDIO_FLAG_RXOVERR) || \
+ ((FLAG) == SDIO_FLAG_CMDREND) || \
+ ((FLAG) == SDIO_FLAG_CMDSENT) || \
+ ((FLAG) == SDIO_FLAG_DATAEND) || \
+ ((FLAG) == SDIO_FLAG_STBITERR) || \
+ ((FLAG) == SDIO_FLAG_DBCKEND) || \
+ ((FLAG) == SDIO_FLAG_CMDACT) || \
+ ((FLAG) == SDIO_FLAG_TXACT) || \
+ ((FLAG) == SDIO_FLAG_RXACT) || \
+ ((FLAG) == SDIO_FLAG_TXFIFOHE) || \
+ ((FLAG) == SDIO_FLAG_RXFIFOHF) || \
+ ((FLAG) == SDIO_FLAG_TXFIFOF) || \
+ ((FLAG) == SDIO_FLAG_RXFIFOF) || \
+ ((FLAG) == SDIO_FLAG_TXFIFOE) || \
+ ((FLAG) == SDIO_FLAG_RXFIFOE) || \
+ ((FLAG) == SDIO_FLAG_TXDAVL) || \
+ ((FLAG) == SDIO_FLAG_RXDAVL) || \
+ ((FLAG) == SDIO_FLAG_SDIOIT) || \
+ ((FLAG) == SDIO_FLAG_CEATAEND))
+
+#define IS_SDIO_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFF3FF800) == 0x00) && ((FLAG) != (uint32_t)0x00))
+
+#define IS_SDIO_GET_IT(IT) (((IT) == SDIO_IT_CCRCFAIL) || \
+ ((IT) == SDIO_IT_DCRCFAIL) || \
+ ((IT) == SDIO_IT_CTIMEOUT) || \
+ ((IT) == SDIO_IT_DTIMEOUT) || \
+ ((IT) == SDIO_IT_TXUNDERR) || \
+ ((IT) == SDIO_IT_RXOVERR) || \
+ ((IT) == SDIO_IT_CMDREND) || \
+ ((IT) == SDIO_IT_CMDSENT) || \
+ ((IT) == SDIO_IT_DATAEND) || \
+ ((IT) == SDIO_IT_STBITERR) || \
+ ((IT) == SDIO_IT_DBCKEND) || \
+ ((IT) == SDIO_IT_CMDACT) || \
+ ((IT) == SDIO_IT_TXACT) || \
+ ((IT) == SDIO_IT_RXACT) || \
+ ((IT) == SDIO_IT_TXFIFOHE) || \
+ ((IT) == SDIO_IT_RXFIFOHF) || \
+ ((IT) == SDIO_IT_TXFIFOF) || \
+ ((IT) == SDIO_IT_RXFIFOF) || \
+ ((IT) == SDIO_IT_TXFIFOE) || \
+ ((IT) == SDIO_IT_RXFIFOE) || \
+ ((IT) == SDIO_IT_TXDAVL) || \
+ ((IT) == SDIO_IT_RXDAVL) || \
+ ((IT) == SDIO_IT_SDIOIT) || \
+ ((IT) == SDIO_IT_CEATAEND))
+
+#define IS_SDIO_CLEAR_IT(IT) ((((IT) & (uint32_t)0xFF3FF800) == 0x00) && ((IT) != (uint32_t)0x00))
+
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Read_Wait_Mode
+ * @{
+ */
+
+#define SDIO_ReadWaitMode_CLK ((uint32_t)0x00000001)
+#define SDIO_ReadWaitMode_DATA2 ((uint32_t)0x00000000)
+#define IS_SDIO_READWAIT_MODE(MODE) (((MODE) == SDIO_ReadWaitMode_CLK) || \
+ ((MODE) == SDIO_ReadWaitMode_DATA2))
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Exported_Functions
+ * @{
+ */
+
+void SDIO_DeInit(void);
+void SDIO_Init(SDIO_InitTypeDef* SDIO_InitStruct);
+void SDIO_StructInit(SDIO_InitTypeDef* SDIO_InitStruct);
+void SDIO_ClockCmd(FunctionalState NewState);
+void SDIO_SetPowerState(uint32_t SDIO_PowerState);
+uint32_t SDIO_GetPowerState(void);
+void SDIO_ITConfig(uint32_t SDIO_IT, FunctionalState NewState);
+void SDIO_DMACmd(FunctionalState NewState);
+void SDIO_SendCommand(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct);
+void SDIO_CmdStructInit(SDIO_CmdInitTypeDef* SDIO_CmdInitStruct);
+uint8_t SDIO_GetCommandResponse(void);
+uint32_t SDIO_GetResponse(uint32_t SDIO_RESP);
+void SDIO_DataConfig(SDIO_DataInitTypeDef* SDIO_DataInitStruct);
+void SDIO_DataStructInit(SDIO_DataInitTypeDef* SDIO_DataInitStruct);
+uint32_t SDIO_GetDataCounter(void);
+uint32_t SDIO_ReadData(void);
+void SDIO_WriteData(uint32_t Data);
+uint32_t SDIO_GetFIFOCount(void);
+void SDIO_StartSDIOReadWait(FunctionalState NewState);
+void SDIO_StopSDIOReadWait(FunctionalState NewState);
+void SDIO_SetSDIOReadWaitMode(uint32_t SDIO_ReadWaitMode);
+void SDIO_SetSDIOOperation(FunctionalState NewState);
+void SDIO_SendSDIOSuspendCmd(FunctionalState NewState);
+void SDIO_CommandCompletionCmd(FunctionalState NewState);
+void SDIO_CEATAITCmd(FunctionalState NewState);
+void SDIO_SendCEATACmd(FunctionalState NewState);
+FlagStatus SDIO_GetFlagStatus(uint32_t SDIO_FLAG);
+void SDIO_ClearFlag(uint32_t SDIO_FLAG);
+ITStatus SDIO_GetITStatus(uint32_t SDIO_IT);
+void SDIO_ClearITPendingBit(uint32_t SDIO_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_SDIO_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_spi.h b/st_fw_lib/inc/stm32f10x_spi.h
new file mode 100644
index 0000000..23cc26d
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_spi.h
@@ -0,0 +1,487 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_spi.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the SPI firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_SPI_H
+#define __STM32F10x_SPI_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup SPI
+ * @{
+ */
+
+/** @defgroup SPI_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief SPI Init structure definition
+ */
+
+typedef struct
+{
+ uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.
+ This parameter can be a value of @ref SPI_data_direction */
+
+ uint16_t SPI_Mode; /*!< Specifies the SPI operating mode.
+ This parameter can be a value of @ref SPI_mode */
+
+ uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
+ This parameter can be a value of @ref SPI_data_size */
+
+ uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
+ This parameter can be a value of @ref SPI_Clock_Polarity */
+
+ uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture.
+ This parameter can be a value of @ref SPI_Clock_Phase */
+
+ uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
+ hardware (NSS pin) or by software using the SSI bit.
+ This parameter can be a value of @ref SPI_Slave_Select_management */
+
+ uint16_t SPI_BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
+ used to configure the transmit and receive SCK clock.
+ This parameter can be a value of @ref SPI_BaudRate_Prescaler.
+ @note The communication clock is derived from the master
+ clock. The slave clock does not need to be set. */
+
+ uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
+ This parameter can be a value of @ref SPI_MSB_LSB_transmission */
+
+ uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
+}SPI_InitTypeDef;
+
+/**
+ * @brief I2S Init structure definition
+ */
+
+typedef struct
+{
+
+ uint16_t I2S_Mode; /*!< Specifies the I2S operating mode.
+ This parameter can be a value of @ref I2S_Mode */
+
+ uint16_t I2S_Standard; /*!< Specifies the standard used for the I2S communication.
+ This parameter can be a value of @ref I2S_Standard */
+
+ uint16_t I2S_DataFormat; /*!< Specifies the data format for the I2S communication.
+ This parameter can be a value of @ref I2S_Data_Format */
+
+ uint16_t I2S_MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not.
+ This parameter can be a value of @ref I2S_MCLK_Output */
+
+ uint32_t I2S_AudioFreq; /*!< Specifies the frequency selected for the I2S communication.
+ This parameter can be a value of @ref I2S_Audio_Frequency */
+
+ uint16_t I2S_CPOL; /*!< Specifies the idle state of the I2S clock.
+ This parameter can be a value of @ref I2S_Clock_Polarity */
+}I2S_InitTypeDef;
+
+/**
+ * @}
+ */
+
+/** @defgroup SPI_Exported_Constants
+ * @{
+ */
+
+#define IS_SPI_ALL_PERIPH(PERIPH) (((PERIPH) == SPI1) || \
+ ((PERIPH) == SPI2) || \
+ ((PERIPH) == SPI3))
+
+#define IS_SPI_23_PERIPH(PERIPH) (((PERIPH) == SPI2) || \
+ ((PERIPH) == SPI3))
+
+/** @defgroup SPI_data_direction
+ * @{
+ */
+
+#define SPI_Direction_2Lines_FullDuplex ((uint16_t)0x0000)
+#define SPI_Direction_2Lines_RxOnly ((uint16_t)0x0400)
+#define SPI_Direction_1Line_Rx ((uint16_t)0x8000)
+#define SPI_Direction_1Line_Tx ((uint16_t)0xC000)
+#define IS_SPI_DIRECTION_MODE(MODE) (((MODE) == SPI_Direction_2Lines_FullDuplex) || \
+ ((MODE) == SPI_Direction_2Lines_RxOnly) || \
+ ((MODE) == SPI_Direction_1Line_Rx) || \
+ ((MODE) == SPI_Direction_1Line_Tx))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_mode
+ * @{
+ */
+
+#define SPI_Mode_Master ((uint16_t)0x0104)
+#define SPI_Mode_Slave ((uint16_t)0x0000)
+#define IS_SPI_MODE(MODE) (((MODE) == SPI_Mode_Master) || \
+ ((MODE) == SPI_Mode_Slave))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_data_size
+ * @{
+ */
+
+#define SPI_DataSize_16b ((uint16_t)0x0800)
+#define SPI_DataSize_8b ((uint16_t)0x0000)
+#define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DataSize_16b) || \
+ ((DATASIZE) == SPI_DataSize_8b))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_Clock_Polarity
+ * @{
+ */
+
+#define SPI_CPOL_Low ((uint16_t)0x0000)
+#define SPI_CPOL_High ((uint16_t)0x0002)
+#define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_CPOL_Low) || \
+ ((CPOL) == SPI_CPOL_High))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_Clock_Phase
+ * @{
+ */
+
+#define SPI_CPHA_1Edge ((uint16_t)0x0000)
+#define SPI_CPHA_2Edge ((uint16_t)0x0001)
+#define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_CPHA_1Edge) || \
+ ((CPHA) == SPI_CPHA_2Edge))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_Slave_Select_management
+ * @{
+ */
+
+#define SPI_NSS_Soft ((uint16_t)0x0200)
+#define SPI_NSS_Hard ((uint16_t)0x0000)
+#define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_Soft) || \
+ ((NSS) == SPI_NSS_Hard))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_BaudRate_Prescaler
+ * @{
+ */
+
+#define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000)
+#define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008)
+#define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010)
+#define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018)
+#define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020)
+#define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028)
+#define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030)
+#define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038)
+#define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BaudRatePrescaler_2) || \
+ ((PRESCALER) == SPI_BaudRatePrescaler_4) || \
+ ((PRESCALER) == SPI_BaudRatePrescaler_8) || \
+ ((PRESCALER) == SPI_BaudRatePrescaler_16) || \
+ ((PRESCALER) == SPI_BaudRatePrescaler_32) || \
+ ((PRESCALER) == SPI_BaudRatePrescaler_64) || \
+ ((PRESCALER) == SPI_BaudRatePrescaler_128) || \
+ ((PRESCALER) == SPI_BaudRatePrescaler_256))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_MSB_LSB_transmission
+ * @{
+ */
+
+#define SPI_FirstBit_MSB ((uint16_t)0x0000)
+#define SPI_FirstBit_LSB ((uint16_t)0x0080)
+#define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FirstBit_MSB) || \
+ ((BIT) == SPI_FirstBit_LSB))
+/**
+ * @}
+ */
+
+/** @defgroup I2S_Mode
+ * @{
+ */
+
+#define I2S_Mode_SlaveTx ((uint16_t)0x0000)
+#define I2S_Mode_SlaveRx ((uint16_t)0x0100)
+#define I2S_Mode_MasterTx ((uint16_t)0x0200)
+#define I2S_Mode_MasterRx ((uint16_t)0x0300)
+#define IS_I2S_MODE(MODE) (((MODE) == I2S_Mode_SlaveTx) || \
+ ((MODE) == I2S_Mode_SlaveRx) || \
+ ((MODE) == I2S_Mode_MasterTx) || \
+ ((MODE) == I2S_Mode_MasterRx) )
+/**
+ * @}
+ */
+
+/** @defgroup I2S_Standard
+ * @{
+ */
+
+#define I2S_Standard_Phillips ((uint16_t)0x0000)
+#define I2S_Standard_MSB ((uint16_t)0x0010)
+#define I2S_Standard_LSB ((uint16_t)0x0020)
+#define I2S_Standard_PCMShort ((uint16_t)0x0030)
+#define I2S_Standard_PCMLong ((uint16_t)0x00B0)
+#define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_Standard_Phillips) || \
+ ((STANDARD) == I2S_Standard_MSB) || \
+ ((STANDARD) == I2S_Standard_LSB) || \
+ ((STANDARD) == I2S_Standard_PCMShort) || \
+ ((STANDARD) == I2S_Standard_PCMLong))
+/**
+ * @}
+ */
+
+/** @defgroup I2S_Data_Format
+ * @{
+ */
+
+#define I2S_DataFormat_16b ((uint16_t)0x0000)
+#define I2S_DataFormat_16bextended ((uint16_t)0x0001)
+#define I2S_DataFormat_24b ((uint16_t)0x0003)
+#define I2S_DataFormat_32b ((uint16_t)0x0005)
+#define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DataFormat_16b) || \
+ ((FORMAT) == I2S_DataFormat_16bextended) || \
+ ((FORMAT) == I2S_DataFormat_24b) || \
+ ((FORMAT) == I2S_DataFormat_32b))
+/**
+ * @}
+ */
+
+/** @defgroup I2S_MCLK_Output
+ * @{
+ */
+
+#define I2S_MCLKOutput_Enable ((uint16_t)0x0200)
+#define I2S_MCLKOutput_Disable ((uint16_t)0x0000)
+#define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOutput_Enable) || \
+ ((OUTPUT) == I2S_MCLKOutput_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup I2S_Audio_Frequency
+ * @{
+ */
+
+#define I2S_AudioFreq_192k ((uint32_t)192000)
+#define I2S_AudioFreq_96k ((uint32_t)96000)
+#define I2S_AudioFreq_48k ((uint32_t)48000)
+#define I2S_AudioFreq_44k ((uint32_t)44100)
+#define I2S_AudioFreq_32k ((uint32_t)32000)
+#define I2S_AudioFreq_22k ((uint32_t)22050)
+#define I2S_AudioFreq_16k ((uint32_t)16000)
+#define I2S_AudioFreq_11k ((uint32_t)11025)
+#define I2S_AudioFreq_8k ((uint32_t)8000)
+#define I2S_AudioFreq_Default ((uint32_t)2)
+
+#define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AudioFreq_8k) && \
+ ((FREQ) <= I2S_AudioFreq_192k)) || \
+ ((FREQ) == I2S_AudioFreq_Default))
+/**
+ * @}
+ */
+
+/** @defgroup I2S_Clock_Polarity
+ * @{
+ */
+
+#define I2S_CPOL_Low ((uint16_t)0x0000)
+#define I2S_CPOL_High ((uint16_t)0x0008)
+#define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_Low) || \
+ ((CPOL) == I2S_CPOL_High))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_I2S_DMA_transfer_requests
+ * @{
+ */
+
+#define SPI_I2S_DMAReq_Tx ((uint16_t)0x0002)
+#define SPI_I2S_DMAReq_Rx ((uint16_t)0x0001)
+#define IS_SPI_I2S_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFFFC) == 0x00) && ((DMAREQ) != 0x00))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_NSS_internal_software_management
+ * @{
+ */
+
+#define SPI_NSSInternalSoft_Set ((uint16_t)0x0100)
+#define SPI_NSSInternalSoft_Reset ((uint16_t)0xFEFF)
+#define IS_SPI_NSS_INTERNAL(INTERNAL) (((INTERNAL) == SPI_NSSInternalSoft_Set) || \
+ ((INTERNAL) == SPI_NSSInternalSoft_Reset))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_CRC_Transmit_Receive
+ * @{
+ */
+
+#define SPI_CRC_Tx ((uint8_t)0x00)
+#define SPI_CRC_Rx ((uint8_t)0x01)
+#define IS_SPI_CRC(CRC) (((CRC) == SPI_CRC_Tx) || ((CRC) == SPI_CRC_Rx))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_direction_transmit_receive
+ * @{
+ */
+
+#define SPI_Direction_Rx ((uint16_t)0xBFFF)
+#define SPI_Direction_Tx ((uint16_t)0x4000)
+#define IS_SPI_DIRECTION(DIRECTION) (((DIRECTION) == SPI_Direction_Rx) || \
+ ((DIRECTION) == SPI_Direction_Tx))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_I2S_interrupts_definition
+ * @{
+ */
+
+#define SPI_I2S_IT_TXE ((uint8_t)0x71)
+#define SPI_I2S_IT_RXNE ((uint8_t)0x60)
+#define SPI_I2S_IT_ERR ((uint8_t)0x50)
+#define IS_SPI_I2S_CONFIG_IT(IT) (((IT) == SPI_I2S_IT_TXE) || \
+ ((IT) == SPI_I2S_IT_RXNE) || \
+ ((IT) == SPI_I2S_IT_ERR))
+#define SPI_I2S_IT_OVR ((uint8_t)0x56)
+#define SPI_IT_MODF ((uint8_t)0x55)
+#define SPI_IT_CRCERR ((uint8_t)0x54)
+#define I2S_IT_UDR ((uint8_t)0x53)
+#define IS_SPI_I2S_CLEAR_IT(IT) (((IT) == SPI_IT_CRCERR))
+#define IS_SPI_I2S_GET_IT(IT) (((IT) == SPI_I2S_IT_RXNE) || ((IT) == SPI_I2S_IT_TXE) || \
+ ((IT) == I2S_IT_UDR) || ((IT) == SPI_IT_CRCERR) || \
+ ((IT) == SPI_IT_MODF) || ((IT) == SPI_I2S_IT_OVR))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_I2S_flags_definition
+ * @{
+ */
+
+#define SPI_I2S_FLAG_RXNE ((uint16_t)0x0001)
+#define SPI_I2S_FLAG_TXE ((uint16_t)0x0002)
+#define I2S_FLAG_CHSIDE ((uint16_t)0x0004)
+#define I2S_FLAG_UDR ((uint16_t)0x0008)
+#define SPI_FLAG_CRCERR ((uint16_t)0x0010)
+#define SPI_FLAG_MODF ((uint16_t)0x0020)
+#define SPI_I2S_FLAG_OVR ((uint16_t)0x0040)
+#define SPI_I2S_FLAG_BSY ((uint16_t)0x0080)
+#define IS_SPI_I2S_CLEAR_FLAG(FLAG) (((FLAG) == SPI_FLAG_CRCERR))
+#define IS_SPI_I2S_GET_FLAG(FLAG) (((FLAG) == SPI_I2S_FLAG_BSY) || ((FLAG) == SPI_I2S_FLAG_OVR) || \
+ ((FLAG) == SPI_FLAG_MODF) || ((FLAG) == SPI_FLAG_CRCERR) || \
+ ((FLAG) == I2S_FLAG_UDR) || ((FLAG) == I2S_FLAG_CHSIDE) || \
+ ((FLAG) == SPI_I2S_FLAG_TXE) || ((FLAG) == SPI_I2S_FLAG_RXNE))
+/**
+ * @}
+ */
+
+/** @defgroup SPI_CRC_polynomial
+ * @{
+ */
+
+#define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) ((POLYNOMIAL) >= 0x1)
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SPI_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SPI_Exported_Functions
+ * @{
+ */
+
+void SPI_I2S_DeInit(SPI_TypeDef* SPIx);
+void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct);
+void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct);
+void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct);
+void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct);
+void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
+void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
+void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState);
+void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState);
+void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data);
+uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx);
+void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft);
+void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
+void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize);
+void SPI_TransmitCRC(SPI_TypeDef* SPIx);
+void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState);
+uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC);
+uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx);
+void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction);
+FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
+void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
+ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
+void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__STM32F10x_SPI_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_tim.h b/st_fw_lib/inc/stm32f10x_tim.h
new file mode 100644
index 0000000..65bf76a
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_tim.h
@@ -0,0 +1,1164 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_tim.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the TIM firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_TIM_H
+#define __STM32F10x_TIM_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup TIM
+ * @{
+ */
+
+/** @defgroup TIM_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief TIM Time Base Init structure definition
+ * @note This structure is used with all TIMx except for TIM6 and TIM7.
+ */
+
+typedef struct
+{
+ uint16_t TIM_Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
+ This parameter can be a number between 0x0000 and 0xFFFF */
+
+ uint16_t TIM_CounterMode; /*!< Specifies the counter mode.
+ This parameter can be a value of @ref TIM_Counter_Mode */
+
+ uint16_t TIM_Period; /*!< Specifies the period value to be loaded into the active
+ Auto-Reload Register at the next update event.
+ This parameter must be a number between 0x0000 and 0xFFFF. */
+
+ uint16_t TIM_ClockDivision; /*!< Specifies the clock division.
+ This parameter can be a value of @ref TIM_Clock_Division_CKD */
+
+ uint8_t TIM_RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR downcounter
+ reaches zero, an update event is generated and counting restarts
+ from the RCR value (N).
+ This means in PWM mode that (N+1) corresponds to:
+ - the number of PWM periods in edge-aligned mode
+ - the number of half PWM period in center-aligned mode
+ This parameter must be a number between 0x00 and 0xFF.
+ @note This parameter is valid only for TIM1 and TIM8. */
+} TIM_TimeBaseInitTypeDef;
+
+/**
+ * @brief TIM Output Compare Init structure definition
+ */
+
+typedef struct
+{
+ uint16_t TIM_OCMode; /*!< Specifies the TIM mode.
+ This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */
+
+ uint16_t TIM_OutputState; /*!< Specifies the TIM Output Compare state.
+ This parameter can be a value of @ref TIM_Output_Compare_state */
+
+ uint16_t TIM_OutputNState; /*!< Specifies the TIM complementary Output Compare state.
+ This parameter can be a value of @ref TIM_Output_Compare_N_state
+ @note This parameter is valid only for TIM1 and TIM8. */
+
+ uint16_t TIM_Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
+ This parameter can be a number between 0x0000 and 0xFFFF */
+
+ uint16_t TIM_OCPolarity; /*!< Specifies the output polarity.
+ This parameter can be a value of @ref TIM_Output_Compare_Polarity */
+
+ uint16_t TIM_OCNPolarity; /*!< Specifies the complementary output polarity.
+ This parameter can be a value of @ref TIM_Output_Compare_N_Polarity
+ @note This parameter is valid only for TIM1 and TIM8. */
+
+ uint16_t TIM_OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
+ This parameter can be a value of @ref TIM_Output_Compare_Idle_State
+ @note This parameter is valid only for TIM1 and TIM8. */
+
+ uint16_t TIM_OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
+ This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State
+ @note This parameter is valid only for TIM1 and TIM8. */
+} TIM_OCInitTypeDef;
+
+/**
+ * @brief TIM Input Capture Init structure definition
+ */
+
+typedef struct
+{
+
+ uint16_t TIM_Channel; /*!< Specifies the TIM channel.
+ This parameter can be a value of @ref TIM_Channel */
+
+ uint16_t TIM_ICPolarity; /*!< Specifies the active edge of the input signal.
+ This parameter can be a value of @ref TIM_Input_Capture_Polarity */
+
+ uint16_t TIM_ICSelection; /*!< Specifies the input.
+ This parameter can be a value of @ref TIM_Input_Capture_Selection */
+
+ uint16_t TIM_ICPrescaler; /*!< Specifies the Input Capture Prescaler.
+ This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
+
+ uint16_t TIM_ICFilter; /*!< Specifies the input capture filter.
+ This parameter can be a number between 0x0 and 0xF */
+} TIM_ICInitTypeDef;
+
+/**
+ * @brief BDTR structure definition
+ * @note This structure is used only with TIM1 and TIM8.
+ */
+
+typedef struct
+{
+
+ uint16_t TIM_OSSRState; /*!< Specifies the Off-State selection used in Run mode.
+ This parameter can be a value of @ref OSSR_Off_State_Selection_for_Run_mode_state */
+
+ uint16_t TIM_OSSIState; /*!< Specifies the Off-State used in Idle state.
+ This parameter can be a value of @ref OSSI_Off_State_Selection_for_Idle_mode_state */
+
+ uint16_t TIM_LOCKLevel; /*!< Specifies the LOCK level parameters.
+ This parameter can be a value of @ref Lock_level */
+
+ uint16_t TIM_DeadTime; /*!< Specifies the delay time between the switching-off and the
+ switching-on of the outputs.
+ This parameter can be a number between 0x00 and 0xFF */
+
+ uint16_t TIM_Break; /*!< Specifies whether the TIM Break input is enabled or not.
+ This parameter can be a value of @ref Break_Input_enable_disable */
+
+ uint16_t TIM_BreakPolarity; /*!< Specifies the TIM Break Input pin polarity.
+ This parameter can be a value of @ref Break_Polarity */
+
+ uint16_t TIM_AutomaticOutput; /*!< Specifies whether the TIM Automatic Output feature is enabled or not.
+ This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */
+} TIM_BDTRInitTypeDef;
+
+/** @defgroup TIM_Exported_constants
+ * @{
+ */
+
+#define IS_TIM_ALL_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
+ ((PERIPH) == TIM2) || \
+ ((PERIPH) == TIM3) || \
+ ((PERIPH) == TIM4) || \
+ ((PERIPH) == TIM5) || \
+ ((PERIPH) == TIM6) || \
+ ((PERIPH) == TIM7) || \
+ ((PERIPH) == TIM8) || \
+ ((PERIPH) == TIM9) || \
+ ((PERIPH) == TIM10)|| \
+ ((PERIPH) == TIM11)|| \
+ ((PERIPH) == TIM12)|| \
+ ((PERIPH) == TIM13)|| \
+ ((PERIPH) == TIM14)|| \
+ ((PERIPH) == TIM15)|| \
+ ((PERIPH) == TIM16)|| \
+ ((PERIPH) == TIM17))
+
+/* LIST1: TIM 1 and 8 */
+#define IS_TIM_LIST1_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
+ ((PERIPH) == TIM8))
+
+/* LIST2: TIM 1, 8, 15 16 and 17 */
+#define IS_TIM_LIST2_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
+ ((PERIPH) == TIM8) || \
+ ((PERIPH) == TIM15)|| \
+ ((PERIPH) == TIM16)|| \
+ ((PERIPH) == TIM17))
+
+/* LIST3: TIM 1, 2, 3, 4, 5 and 8 */
+#define IS_TIM_LIST3_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
+ ((PERIPH) == TIM2) || \
+ ((PERIPH) == TIM3) || \
+ ((PERIPH) == TIM4) || \
+ ((PERIPH) == TIM5) || \
+ ((PERIPH) == TIM8))
+
+/* LIST4: TIM 1, 2, 3, 4, 5, 8, 15, 16 and 17 */
+#define IS_TIM_LIST4_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
+ ((PERIPH) == TIM2) || \
+ ((PERIPH) == TIM3) || \
+ ((PERIPH) == TIM4) || \
+ ((PERIPH) == TIM5) || \
+ ((PERIPH) == TIM8) || \
+ ((PERIPH) == TIM15)|| \
+ ((PERIPH) == TIM16)|| \
+ ((PERIPH) == TIM17))
+
+/* LIST5: TIM 1, 2, 3, 4, 5, 8 and 15 */
+#define IS_TIM_LIST5_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
+ ((PERIPH) == TIM2) || \
+ ((PERIPH) == TIM3) || \
+ ((PERIPH) == TIM4) || \
+ ((PERIPH) == TIM5) || \
+ ((PERIPH) == TIM8) || \
+ ((PERIPH) == TIM15))
+
+/* LIST6: TIM 1, 2, 3, 4, 5, 8, 9, 12 and 15 */
+#define IS_TIM_LIST6_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
+ ((PERIPH) == TIM2) || \
+ ((PERIPH) == TIM3) || \
+ ((PERIPH) == TIM4) || \
+ ((PERIPH) == TIM5) || \
+ ((PERIPH) == TIM8) || \
+ ((PERIPH) == TIM9) || \
+ ((PERIPH) == TIM12)|| \
+ ((PERIPH) == TIM15))
+
+/* LIST7: TIM 1, 2, 3, 4, 5, 6, 7, 8, 9, 12 and 15 */
+#define IS_TIM_LIST7_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
+ ((PERIPH) == TIM2) || \
+ ((PERIPH) == TIM3) || \
+ ((PERIPH) == TIM4) || \
+ ((PERIPH) == TIM5) || \
+ ((PERIPH) == TIM6) || \
+ ((PERIPH) == TIM7) || \
+ ((PERIPH) == TIM8) || \
+ ((PERIPH) == TIM9) || \
+ ((PERIPH) == TIM12)|| \
+ ((PERIPH) == TIM15))
+
+/* LIST8: TIM 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16 and 17 */
+#define IS_TIM_LIST8_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
+ ((PERIPH) == TIM2) || \
+ ((PERIPH) == TIM3) || \
+ ((PERIPH) == TIM4) || \
+ ((PERIPH) == TIM5) || \
+ ((PERIPH) == TIM8) || \
+ ((PERIPH) == TIM9) || \
+ ((PERIPH) == TIM10)|| \
+ ((PERIPH) == TIM11)|| \
+ ((PERIPH) == TIM12)|| \
+ ((PERIPH) == TIM13)|| \
+ ((PERIPH) == TIM14)|| \
+ ((PERIPH) == TIM15)|| \
+ ((PERIPH) == TIM16)|| \
+ ((PERIPH) == TIM17))
+
+/* LIST9: TIM 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, and 17 */
+#define IS_TIM_LIST9_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
+ ((PERIPH) == TIM2) || \
+ ((PERIPH) == TIM3) || \
+ ((PERIPH) == TIM4) || \
+ ((PERIPH) == TIM5) || \
+ ((PERIPH) == TIM6) || \
+ ((PERIPH) == TIM7) || \
+ ((PERIPH) == TIM8) || \
+ ((PERIPH) == TIM15)|| \
+ ((PERIPH) == TIM16)|| \
+ ((PERIPH) == TIM17))
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Output_Compare_and_PWM_modes
+ * @{
+ */
+
+#define TIM_OCMode_Timing ((uint16_t)0x0000)
+#define TIM_OCMode_Active ((uint16_t)0x0010)
+#define TIM_OCMode_Inactive ((uint16_t)0x0020)
+#define TIM_OCMode_Toggle ((uint16_t)0x0030)
+#define TIM_OCMode_PWM1 ((uint16_t)0x0060)
+#define TIM_OCMode_PWM2 ((uint16_t)0x0070)
+#define IS_TIM_OC_MODE(MODE) (((MODE) == TIM_OCMode_Timing) || \
+ ((MODE) == TIM_OCMode_Active) || \
+ ((MODE) == TIM_OCMode_Inactive) || \
+ ((MODE) == TIM_OCMode_Toggle)|| \
+ ((MODE) == TIM_OCMode_PWM1) || \
+ ((MODE) == TIM_OCMode_PWM2))
+#define IS_TIM_OCM(MODE) (((MODE) == TIM_OCMode_Timing) || \
+ ((MODE) == TIM_OCMode_Active) || \
+ ((MODE) == TIM_OCMode_Inactive) || \
+ ((MODE) == TIM_OCMode_Toggle)|| \
+ ((MODE) == TIM_OCMode_PWM1) || \
+ ((MODE) == TIM_OCMode_PWM2) || \
+ ((MODE) == TIM_ForcedAction_Active) || \
+ ((MODE) == TIM_ForcedAction_InActive))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_One_Pulse_Mode
+ * @{
+ */
+
+#define TIM_OPMode_Single ((uint16_t)0x0008)
+#define TIM_OPMode_Repetitive ((uint16_t)0x0000)
+#define IS_TIM_OPM_MODE(MODE) (((MODE) == TIM_OPMode_Single) || \
+ ((MODE) == TIM_OPMode_Repetitive))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Channel
+ * @{
+ */
+
+#define TIM_Channel_1 ((uint16_t)0x0000)
+#define TIM_Channel_2 ((uint16_t)0x0004)
+#define TIM_Channel_3 ((uint16_t)0x0008)
+#define TIM_Channel_4 ((uint16_t)0x000C)
+#define IS_TIM_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
+ ((CHANNEL) == TIM_Channel_2) || \
+ ((CHANNEL) == TIM_Channel_3) || \
+ ((CHANNEL) == TIM_Channel_4))
+#define IS_TIM_PWMI_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
+ ((CHANNEL) == TIM_Channel_2))
+#define IS_TIM_COMPLEMENTARY_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
+ ((CHANNEL) == TIM_Channel_2) || \
+ ((CHANNEL) == TIM_Channel_3))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Clock_Division_CKD
+ * @{
+ */
+
+#define TIM_CKD_DIV1 ((uint16_t)0x0000)
+#define TIM_CKD_DIV2 ((uint16_t)0x0100)
+#define TIM_CKD_DIV4 ((uint16_t)0x0200)
+#define IS_TIM_CKD_DIV(DIV) (((DIV) == TIM_CKD_DIV1) || \
+ ((DIV) == TIM_CKD_DIV2) || \
+ ((DIV) == TIM_CKD_DIV4))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Counter_Mode
+ * @{
+ */
+
+#define TIM_CounterMode_Up ((uint16_t)0x0000)
+#define TIM_CounterMode_Down ((uint16_t)0x0010)
+#define TIM_CounterMode_CenterAligned1 ((uint16_t)0x0020)
+#define TIM_CounterMode_CenterAligned2 ((uint16_t)0x0040)
+#define TIM_CounterMode_CenterAligned3 ((uint16_t)0x0060)
+#define IS_TIM_COUNTER_MODE(MODE) (((MODE) == TIM_CounterMode_Up) || \
+ ((MODE) == TIM_CounterMode_Down) || \
+ ((MODE) == TIM_CounterMode_CenterAligned1) || \
+ ((MODE) == TIM_CounterMode_CenterAligned2) || \
+ ((MODE) == TIM_CounterMode_CenterAligned3))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Output_Compare_Polarity
+ * @{
+ */
+
+#define TIM_OCPolarity_High ((uint16_t)0x0000)
+#define TIM_OCPolarity_Low ((uint16_t)0x0002)
+#define IS_TIM_OC_POLARITY(POLARITY) (((POLARITY) == TIM_OCPolarity_High) || \
+ ((POLARITY) == TIM_OCPolarity_Low))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Output_Compare_N_Polarity
+ * @{
+ */
+
+#define TIM_OCNPolarity_High ((uint16_t)0x0000)
+#define TIM_OCNPolarity_Low ((uint16_t)0x0008)
+#define IS_TIM_OCN_POLARITY(POLARITY) (((POLARITY) == TIM_OCNPolarity_High) || \
+ ((POLARITY) == TIM_OCNPolarity_Low))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Output_Compare_state
+ * @{
+ */
+
+#define TIM_OutputState_Disable ((uint16_t)0x0000)
+#define TIM_OutputState_Enable ((uint16_t)0x0001)
+#define IS_TIM_OUTPUT_STATE(STATE) (((STATE) == TIM_OutputState_Disable) || \
+ ((STATE) == TIM_OutputState_Enable))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Output_Compare_N_state
+ * @{
+ */
+
+#define TIM_OutputNState_Disable ((uint16_t)0x0000)
+#define TIM_OutputNState_Enable ((uint16_t)0x0004)
+#define IS_TIM_OUTPUTN_STATE(STATE) (((STATE) == TIM_OutputNState_Disable) || \
+ ((STATE) == TIM_OutputNState_Enable))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Capture_Compare_state
+ * @{
+ */
+
+#define TIM_CCx_Enable ((uint16_t)0x0001)
+#define TIM_CCx_Disable ((uint16_t)0x0000)
+#define IS_TIM_CCX(CCX) (((CCX) == TIM_CCx_Enable) || \
+ ((CCX) == TIM_CCx_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Capture_Compare_N_state
+ * @{
+ */
+
+#define TIM_CCxN_Enable ((uint16_t)0x0004)
+#define TIM_CCxN_Disable ((uint16_t)0x0000)
+#define IS_TIM_CCXN(CCXN) (((CCXN) == TIM_CCxN_Enable) || \
+ ((CCXN) == TIM_CCxN_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup Break_Input_enable_disable
+ * @{
+ */
+
+#define TIM_Break_Enable ((uint16_t)0x1000)
+#define TIM_Break_Disable ((uint16_t)0x0000)
+#define IS_TIM_BREAK_STATE(STATE) (((STATE) == TIM_Break_Enable) || \
+ ((STATE) == TIM_Break_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup Break_Polarity
+ * @{
+ */
+
+#define TIM_BreakPolarity_Low ((uint16_t)0x0000)
+#define TIM_BreakPolarity_High ((uint16_t)0x2000)
+#define IS_TIM_BREAK_POLARITY(POLARITY) (((POLARITY) == TIM_BreakPolarity_Low) || \
+ ((POLARITY) == TIM_BreakPolarity_High))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_AOE_Bit_Set_Reset
+ * @{
+ */
+
+#define TIM_AutomaticOutput_Enable ((uint16_t)0x4000)
+#define TIM_AutomaticOutput_Disable ((uint16_t)0x0000)
+#define IS_TIM_AUTOMATIC_OUTPUT_STATE(STATE) (((STATE) == TIM_AutomaticOutput_Enable) || \
+ ((STATE) == TIM_AutomaticOutput_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup Lock_level
+ * @{
+ */
+
+#define TIM_LOCKLevel_OFF ((uint16_t)0x0000)
+#define TIM_LOCKLevel_1 ((uint16_t)0x0100)
+#define TIM_LOCKLevel_2 ((uint16_t)0x0200)
+#define TIM_LOCKLevel_3 ((uint16_t)0x0300)
+#define IS_TIM_LOCK_LEVEL(LEVEL) (((LEVEL) == TIM_LOCKLevel_OFF) || \
+ ((LEVEL) == TIM_LOCKLevel_1) || \
+ ((LEVEL) == TIM_LOCKLevel_2) || \
+ ((LEVEL) == TIM_LOCKLevel_3))
+/**
+ * @}
+ */
+
+/** @defgroup OSSI_Off_State_Selection_for_Idle_mode_state
+ * @{
+ */
+
+#define TIM_OSSIState_Enable ((uint16_t)0x0400)
+#define TIM_OSSIState_Disable ((uint16_t)0x0000)
+#define IS_TIM_OSSI_STATE(STATE) (((STATE) == TIM_OSSIState_Enable) || \
+ ((STATE) == TIM_OSSIState_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup OSSR_Off_State_Selection_for_Run_mode_state
+ * @{
+ */
+
+#define TIM_OSSRState_Enable ((uint16_t)0x0800)
+#define TIM_OSSRState_Disable ((uint16_t)0x0000)
+#define IS_TIM_OSSR_STATE(STATE) (((STATE) == TIM_OSSRState_Enable) || \
+ ((STATE) == TIM_OSSRState_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Output_Compare_Idle_State
+ * @{
+ */
+
+#define TIM_OCIdleState_Set ((uint16_t)0x0100)
+#define TIM_OCIdleState_Reset ((uint16_t)0x0000)
+#define IS_TIM_OCIDLE_STATE(STATE) (((STATE) == TIM_OCIdleState_Set) || \
+ ((STATE) == TIM_OCIdleState_Reset))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Output_Compare_N_Idle_State
+ * @{
+ */
+
+#define TIM_OCNIdleState_Set ((uint16_t)0x0200)
+#define TIM_OCNIdleState_Reset ((uint16_t)0x0000)
+#define IS_TIM_OCNIDLE_STATE(STATE) (((STATE) == TIM_OCNIdleState_Set) || \
+ ((STATE) == TIM_OCNIdleState_Reset))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Input_Capture_Polarity
+ * @{
+ */
+
+#define TIM_ICPolarity_Rising ((uint16_t)0x0000)
+#define TIM_ICPolarity_Falling ((uint16_t)0x0002)
+#define TIM_ICPolarity_BothEdge ((uint16_t)0x000A)
+#define IS_TIM_IC_POLARITY(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || \
+ ((POLARITY) == TIM_ICPolarity_Falling))
+#define IS_TIM_IC_POLARITY_LITE(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || \
+ ((POLARITY) == TIM_ICPolarity_Falling)|| \
+ ((POLARITY) == TIM_ICPolarity_BothEdge))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Input_Capture_Selection
+ * @{
+ */
+
+#define TIM_ICSelection_DirectTI ((uint16_t)0x0001) /*!< TIM Input 1, 2, 3 or 4 is selected to be
+ connected to IC1, IC2, IC3 or IC4, respectively */
+#define TIM_ICSelection_IndirectTI ((uint16_t)0x0002) /*!< TIM Input 1, 2, 3 or 4 is selected to be
+ connected to IC2, IC1, IC4 or IC3, respectively. */
+#define TIM_ICSelection_TRC ((uint16_t)0x0003) /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to TRC. */
+#define IS_TIM_IC_SELECTION(SELECTION) (((SELECTION) == TIM_ICSelection_DirectTI) || \
+ ((SELECTION) == TIM_ICSelection_IndirectTI) || \
+ ((SELECTION) == TIM_ICSelection_TRC))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Input_Capture_Prescaler
+ * @{
+ */
+
+#define TIM_ICPSC_DIV1 ((uint16_t)0x0000) /*!< Capture performed each time an edge is detected on the capture input. */
+#define TIM_ICPSC_DIV2 ((uint16_t)0x0004) /*!< Capture performed once every 2 events. */
+#define TIM_ICPSC_DIV4 ((uint16_t)0x0008) /*!< Capture performed once every 4 events. */
+#define TIM_ICPSC_DIV8 ((uint16_t)0x000C) /*!< Capture performed once every 8 events. */
+#define IS_TIM_IC_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ICPSC_DIV1) || \
+ ((PRESCALER) == TIM_ICPSC_DIV2) || \
+ ((PRESCALER) == TIM_ICPSC_DIV4) || \
+ ((PRESCALER) == TIM_ICPSC_DIV8))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_interrupt_sources
+ * @{
+ */
+
+#define TIM_IT_Update ((uint16_t)0x0001)
+#define TIM_IT_CC1 ((uint16_t)0x0002)
+#define TIM_IT_CC2 ((uint16_t)0x0004)
+#define TIM_IT_CC3 ((uint16_t)0x0008)
+#define TIM_IT_CC4 ((uint16_t)0x0010)
+#define TIM_IT_COM ((uint16_t)0x0020)
+#define TIM_IT_Trigger ((uint16_t)0x0040)
+#define TIM_IT_Break ((uint16_t)0x0080)
+#define IS_TIM_IT(IT) ((((IT) & (uint16_t)0xFF00) == 0x0000) && ((IT) != 0x0000))
+
+#define IS_TIM_GET_IT(IT) (((IT) == TIM_IT_Update) || \
+ ((IT) == TIM_IT_CC1) || \
+ ((IT) == TIM_IT_CC2) || \
+ ((IT) == TIM_IT_CC3) || \
+ ((IT) == TIM_IT_CC4) || \
+ ((IT) == TIM_IT_COM) || \
+ ((IT) == TIM_IT_Trigger) || \
+ ((IT) == TIM_IT_Break))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_DMA_Base_address
+ * @{
+ */
+
+#define TIM_DMABase_CR1 ((uint16_t)0x0000)
+#define TIM_DMABase_CR2 ((uint16_t)0x0001)
+#define TIM_DMABase_SMCR ((uint16_t)0x0002)
+#define TIM_DMABase_DIER ((uint16_t)0x0003)
+#define TIM_DMABase_SR ((uint16_t)0x0004)
+#define TIM_DMABase_EGR ((uint16_t)0x0005)
+#define TIM_DMABase_CCMR1 ((uint16_t)0x0006)
+#define TIM_DMABase_CCMR2 ((uint16_t)0x0007)
+#define TIM_DMABase_CCER ((uint16_t)0x0008)
+#define TIM_DMABase_CNT ((uint16_t)0x0009)
+#define TIM_DMABase_PSC ((uint16_t)0x000A)
+#define TIM_DMABase_ARR ((uint16_t)0x000B)
+#define TIM_DMABase_RCR ((uint16_t)0x000C)
+#define TIM_DMABase_CCR1 ((uint16_t)0x000D)
+#define TIM_DMABase_CCR2 ((uint16_t)0x000E)
+#define TIM_DMABase_CCR3 ((uint16_t)0x000F)
+#define TIM_DMABase_CCR4 ((uint16_t)0x0010)
+#define TIM_DMABase_BDTR ((uint16_t)0x0011)
+#define TIM_DMABase_DCR ((uint16_t)0x0012)
+#define IS_TIM_DMA_BASE(BASE) (((BASE) == TIM_DMABase_CR1) || \
+ ((BASE) == TIM_DMABase_CR2) || \
+ ((BASE) == TIM_DMABase_SMCR) || \
+ ((BASE) == TIM_DMABase_DIER) || \
+ ((BASE) == TIM_DMABase_SR) || \
+ ((BASE) == TIM_DMABase_EGR) || \
+ ((BASE) == TIM_DMABase_CCMR1) || \
+ ((BASE) == TIM_DMABase_CCMR2) || \
+ ((BASE) == TIM_DMABase_CCER) || \
+ ((BASE) == TIM_DMABase_CNT) || \
+ ((BASE) == TIM_DMABase_PSC) || \
+ ((BASE) == TIM_DMABase_ARR) || \
+ ((BASE) == TIM_DMABase_RCR) || \
+ ((BASE) == TIM_DMABase_CCR1) || \
+ ((BASE) == TIM_DMABase_CCR2) || \
+ ((BASE) == TIM_DMABase_CCR3) || \
+ ((BASE) == TIM_DMABase_CCR4) || \
+ ((BASE) == TIM_DMABase_BDTR) || \
+ ((BASE) == TIM_DMABase_DCR))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_DMA_Burst_Length
+ * @{
+ */
+
+#define TIM_DMABurstLength_1Transfer ((uint16_t)0x0000)
+#define TIM_DMABurstLength_2Transfers ((uint16_t)0x0100)
+#define TIM_DMABurstLength_3Transfers ((uint16_t)0x0200)
+#define TIM_DMABurstLength_4Transfers ((uint16_t)0x0300)
+#define TIM_DMABurstLength_5Transfers ((uint16_t)0x0400)
+#define TIM_DMABurstLength_6Transfers ((uint16_t)0x0500)
+#define TIM_DMABurstLength_7Transfers ((uint16_t)0x0600)
+#define TIM_DMABurstLength_8Transfers ((uint16_t)0x0700)
+#define TIM_DMABurstLength_9Transfers ((uint16_t)0x0800)
+#define TIM_DMABurstLength_10Transfers ((uint16_t)0x0900)
+#define TIM_DMABurstLength_11Transfers ((uint16_t)0x0A00)
+#define TIM_DMABurstLength_12Transfers ((uint16_t)0x0B00)
+#define TIM_DMABurstLength_13Transfers ((uint16_t)0x0C00)
+#define TIM_DMABurstLength_14Transfers ((uint16_t)0x0D00)
+#define TIM_DMABurstLength_15Transfers ((uint16_t)0x0E00)
+#define TIM_DMABurstLength_16Transfers ((uint16_t)0x0F00)
+#define TIM_DMABurstLength_17Transfers ((uint16_t)0x1000)
+#define TIM_DMABurstLength_18Transfers ((uint16_t)0x1100)
+#define IS_TIM_DMA_LENGTH(LENGTH) (((LENGTH) == TIM_DMABurstLength_1Transfer) || \
+ ((LENGTH) == TIM_DMABurstLength_2Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_3Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_4Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_5Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_6Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_7Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_8Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_9Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_10Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_11Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_12Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_13Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_14Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_15Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_16Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_17Transfers) || \
+ ((LENGTH) == TIM_DMABurstLength_18Transfers))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_DMA_sources
+ * @{
+ */
+
+#define TIM_DMA_Update ((uint16_t)0x0100)
+#define TIM_DMA_CC1 ((uint16_t)0x0200)
+#define TIM_DMA_CC2 ((uint16_t)0x0400)
+#define TIM_DMA_CC3 ((uint16_t)0x0800)
+#define TIM_DMA_CC4 ((uint16_t)0x1000)
+#define TIM_DMA_COM ((uint16_t)0x2000)
+#define TIM_DMA_Trigger ((uint16_t)0x4000)
+#define IS_TIM_DMA_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0x80FF) == 0x0000) && ((SOURCE) != 0x0000))
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_External_Trigger_Prescaler
+ * @{
+ */
+
+#define TIM_ExtTRGPSC_OFF ((uint16_t)0x0000)
+#define TIM_ExtTRGPSC_DIV2 ((uint16_t)0x1000)
+#define TIM_ExtTRGPSC_DIV4 ((uint16_t)0x2000)
+#define TIM_ExtTRGPSC_DIV8 ((uint16_t)0x3000)
+#define IS_TIM_EXT_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ExtTRGPSC_OFF) || \
+ ((PRESCALER) == TIM_ExtTRGPSC_DIV2) || \
+ ((PRESCALER) == TIM_ExtTRGPSC_DIV4) || \
+ ((PRESCALER) == TIM_ExtTRGPSC_DIV8))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Internal_Trigger_Selection
+ * @{
+ */
+
+#define TIM_TS_ITR0 ((uint16_t)0x0000)
+#define TIM_TS_ITR1 ((uint16_t)0x0010)
+#define TIM_TS_ITR2 ((uint16_t)0x0020)
+#define TIM_TS_ITR3 ((uint16_t)0x0030)
+#define TIM_TS_TI1F_ED ((uint16_t)0x0040)
+#define TIM_TS_TI1FP1 ((uint16_t)0x0050)
+#define TIM_TS_TI2FP2 ((uint16_t)0x0060)
+#define TIM_TS_ETRF ((uint16_t)0x0070)
+#define IS_TIM_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
+ ((SELECTION) == TIM_TS_ITR1) || \
+ ((SELECTION) == TIM_TS_ITR2) || \
+ ((SELECTION) == TIM_TS_ITR3) || \
+ ((SELECTION) == TIM_TS_TI1F_ED) || \
+ ((SELECTION) == TIM_TS_TI1FP1) || \
+ ((SELECTION) == TIM_TS_TI2FP2) || \
+ ((SELECTION) == TIM_TS_ETRF))
+#define IS_TIM_INTERNAL_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
+ ((SELECTION) == TIM_TS_ITR1) || \
+ ((SELECTION) == TIM_TS_ITR2) || \
+ ((SELECTION) == TIM_TS_ITR3))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_TIx_External_Clock_Source
+ * @{
+ */
+
+#define TIM_TIxExternalCLK1Source_TI1 ((uint16_t)0x0050)
+#define TIM_TIxExternalCLK1Source_TI2 ((uint16_t)0x0060)
+#define TIM_TIxExternalCLK1Source_TI1ED ((uint16_t)0x0040)
+#define IS_TIM_TIXCLK_SOURCE(SOURCE) (((SOURCE) == TIM_TIxExternalCLK1Source_TI1) || \
+ ((SOURCE) == TIM_TIxExternalCLK1Source_TI2) || \
+ ((SOURCE) == TIM_TIxExternalCLK1Source_TI1ED))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_External_Trigger_Polarity
+ * @{
+ */
+#define TIM_ExtTRGPolarity_Inverted ((uint16_t)0x8000)
+#define TIM_ExtTRGPolarity_NonInverted ((uint16_t)0x0000)
+#define IS_TIM_EXT_POLARITY(POLARITY) (((POLARITY) == TIM_ExtTRGPolarity_Inverted) || \
+ ((POLARITY) == TIM_ExtTRGPolarity_NonInverted))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Prescaler_Reload_Mode
+ * @{
+ */
+
+#define TIM_PSCReloadMode_Update ((uint16_t)0x0000)
+#define TIM_PSCReloadMode_Immediate ((uint16_t)0x0001)
+#define IS_TIM_PRESCALER_RELOAD(RELOAD) (((RELOAD) == TIM_PSCReloadMode_Update) || \
+ ((RELOAD) == TIM_PSCReloadMode_Immediate))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Forced_Action
+ * @{
+ */
+
+#define TIM_ForcedAction_Active ((uint16_t)0x0050)
+#define TIM_ForcedAction_InActive ((uint16_t)0x0040)
+#define IS_TIM_FORCED_ACTION(ACTION) (((ACTION) == TIM_ForcedAction_Active) || \
+ ((ACTION) == TIM_ForcedAction_InActive))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Encoder_Mode
+ * @{
+ */
+
+#define TIM_EncoderMode_TI1 ((uint16_t)0x0001)
+#define TIM_EncoderMode_TI2 ((uint16_t)0x0002)
+#define TIM_EncoderMode_TI12 ((uint16_t)0x0003)
+#define IS_TIM_ENCODER_MODE(MODE) (((MODE) == TIM_EncoderMode_TI1) || \
+ ((MODE) == TIM_EncoderMode_TI2) || \
+ ((MODE) == TIM_EncoderMode_TI12))
+/**
+ * @}
+ */
+
+
+/** @defgroup TIM_Event_Source
+ * @{
+ */
+
+#define TIM_EventSource_Update ((uint16_t)0x0001)
+#define TIM_EventSource_CC1 ((uint16_t)0x0002)
+#define TIM_EventSource_CC2 ((uint16_t)0x0004)
+#define TIM_EventSource_CC3 ((uint16_t)0x0008)
+#define TIM_EventSource_CC4 ((uint16_t)0x0010)
+#define TIM_EventSource_COM ((uint16_t)0x0020)
+#define TIM_EventSource_Trigger ((uint16_t)0x0040)
+#define TIM_EventSource_Break ((uint16_t)0x0080)
+#define IS_TIM_EVENT_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0xFF00) == 0x0000) && ((SOURCE) != 0x0000))
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Update_Source
+ * @{
+ */
+
+#define TIM_UpdateSource_Global ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow
+ or the setting of UG bit, or an update generation
+ through the slave mode controller. */
+#define TIM_UpdateSource_Regular ((uint16_t)0x0001) /*!< Source of update is counter overflow/underflow. */
+#define IS_TIM_UPDATE_SOURCE(SOURCE) (((SOURCE) == TIM_UpdateSource_Global) || \
+ ((SOURCE) == TIM_UpdateSource_Regular))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Output_Compare_Preload_State
+ * @{
+ */
+
+#define TIM_OCPreload_Enable ((uint16_t)0x0008)
+#define TIM_OCPreload_Disable ((uint16_t)0x0000)
+#define IS_TIM_OCPRELOAD_STATE(STATE) (((STATE) == TIM_OCPreload_Enable) || \
+ ((STATE) == TIM_OCPreload_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Output_Compare_Fast_State
+ * @{
+ */
+
+#define TIM_OCFast_Enable ((uint16_t)0x0004)
+#define TIM_OCFast_Disable ((uint16_t)0x0000)
+#define IS_TIM_OCFAST_STATE(STATE) (((STATE) == TIM_OCFast_Enable) || \
+ ((STATE) == TIM_OCFast_Disable))
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Output_Compare_Clear_State
+ * @{
+ */
+
+#define TIM_OCClear_Enable ((uint16_t)0x0080)
+#define TIM_OCClear_Disable ((uint16_t)0x0000)
+#define IS_TIM_OCCLEAR_STATE(STATE) (((STATE) == TIM_OCClear_Enable) || \
+ ((STATE) == TIM_OCClear_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Trigger_Output_Source
+ * @{
+ */
+
+#define TIM_TRGOSource_Reset ((uint16_t)0x0000)
+#define TIM_TRGOSource_Enable ((uint16_t)0x0010)
+#define TIM_TRGOSource_Update ((uint16_t)0x0020)
+#define TIM_TRGOSource_OC1 ((uint16_t)0x0030)
+#define TIM_TRGOSource_OC1Ref ((uint16_t)0x0040)
+#define TIM_TRGOSource_OC2Ref ((uint16_t)0x0050)
+#define TIM_TRGOSource_OC3Ref ((uint16_t)0x0060)
+#define TIM_TRGOSource_OC4Ref ((uint16_t)0x0070)
+#define IS_TIM_TRGO_SOURCE(SOURCE) (((SOURCE) == TIM_TRGOSource_Reset) || \
+ ((SOURCE) == TIM_TRGOSource_Enable) || \
+ ((SOURCE) == TIM_TRGOSource_Update) || \
+ ((SOURCE) == TIM_TRGOSource_OC1) || \
+ ((SOURCE) == TIM_TRGOSource_OC1Ref) || \
+ ((SOURCE) == TIM_TRGOSource_OC2Ref) || \
+ ((SOURCE) == TIM_TRGOSource_OC3Ref) || \
+ ((SOURCE) == TIM_TRGOSource_OC4Ref))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Slave_Mode
+ * @{
+ */
+
+#define TIM_SlaveMode_Reset ((uint16_t)0x0004)
+#define TIM_SlaveMode_Gated ((uint16_t)0x0005)
+#define TIM_SlaveMode_Trigger ((uint16_t)0x0006)
+#define TIM_SlaveMode_External1 ((uint16_t)0x0007)
+#define IS_TIM_SLAVE_MODE(MODE) (((MODE) == TIM_SlaveMode_Reset) || \
+ ((MODE) == TIM_SlaveMode_Gated) || \
+ ((MODE) == TIM_SlaveMode_Trigger) || \
+ ((MODE) == TIM_SlaveMode_External1))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Master_Slave_Mode
+ * @{
+ */
+
+#define TIM_MasterSlaveMode_Enable ((uint16_t)0x0080)
+#define TIM_MasterSlaveMode_Disable ((uint16_t)0x0000)
+#define IS_TIM_MSM_STATE(STATE) (((STATE) == TIM_MasterSlaveMode_Enable) || \
+ ((STATE) == TIM_MasterSlaveMode_Disable))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Flags
+ * @{
+ */
+
+#define TIM_FLAG_Update ((uint16_t)0x0001)
+#define TIM_FLAG_CC1 ((uint16_t)0x0002)
+#define TIM_FLAG_CC2 ((uint16_t)0x0004)
+#define TIM_FLAG_CC3 ((uint16_t)0x0008)
+#define TIM_FLAG_CC4 ((uint16_t)0x0010)
+#define TIM_FLAG_COM ((uint16_t)0x0020)
+#define TIM_FLAG_Trigger ((uint16_t)0x0040)
+#define TIM_FLAG_Break ((uint16_t)0x0080)
+#define TIM_FLAG_CC1OF ((uint16_t)0x0200)
+#define TIM_FLAG_CC2OF ((uint16_t)0x0400)
+#define TIM_FLAG_CC3OF ((uint16_t)0x0800)
+#define TIM_FLAG_CC4OF ((uint16_t)0x1000)
+#define IS_TIM_GET_FLAG(FLAG) (((FLAG) == TIM_FLAG_Update) || \
+ ((FLAG) == TIM_FLAG_CC1) || \
+ ((FLAG) == TIM_FLAG_CC2) || \
+ ((FLAG) == TIM_FLAG_CC3) || \
+ ((FLAG) == TIM_FLAG_CC4) || \
+ ((FLAG) == TIM_FLAG_COM) || \
+ ((FLAG) == TIM_FLAG_Trigger) || \
+ ((FLAG) == TIM_FLAG_Break) || \
+ ((FLAG) == TIM_FLAG_CC1OF) || \
+ ((FLAG) == TIM_FLAG_CC2OF) || \
+ ((FLAG) == TIM_FLAG_CC3OF) || \
+ ((FLAG) == TIM_FLAG_CC4OF))
+
+
+#define IS_TIM_CLEAR_FLAG(TIM_FLAG) ((((TIM_FLAG) & (uint16_t)0xE100) == 0x0000) && ((TIM_FLAG) != 0x0000))
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Input_Capture_Filer_Value
+ * @{
+ */
+
+#define IS_TIM_IC_FILTER(ICFILTER) ((ICFILTER) <= 0xF)
+/**
+ * @}
+ */
+
+/** @defgroup TIM_External_Trigger_Filter
+ * @{
+ */
+
+#define IS_TIM_EXT_FILTER(EXTFILTER) ((EXTFILTER) <= 0xF)
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Legacy
+ * @{
+ */
+
+#define TIM_DMABurstLength_1Byte TIM_DMABurstLength_1Transfer
+#define TIM_DMABurstLength_2Bytes TIM_DMABurstLength_2Transfers
+#define TIM_DMABurstLength_3Bytes TIM_DMABurstLength_3Transfers
+#define TIM_DMABurstLength_4Bytes TIM_DMABurstLength_4Transfers
+#define TIM_DMABurstLength_5Bytes TIM_DMABurstLength_5Transfers
+#define TIM_DMABurstLength_6Bytes TIM_DMABurstLength_6Transfers
+#define TIM_DMABurstLength_7Bytes TIM_DMABurstLength_7Transfers
+#define TIM_DMABurstLength_8Bytes TIM_DMABurstLength_8Transfers
+#define TIM_DMABurstLength_9Bytes TIM_DMABurstLength_9Transfers
+#define TIM_DMABurstLength_10Bytes TIM_DMABurstLength_10Transfers
+#define TIM_DMABurstLength_11Bytes TIM_DMABurstLength_11Transfers
+#define TIM_DMABurstLength_12Bytes TIM_DMABurstLength_12Transfers
+#define TIM_DMABurstLength_13Bytes TIM_DMABurstLength_13Transfers
+#define TIM_DMABurstLength_14Bytes TIM_DMABurstLength_14Transfers
+#define TIM_DMABurstLength_15Bytes TIM_DMABurstLength_15Transfers
+#define TIM_DMABurstLength_16Bytes TIM_DMABurstLength_16Transfers
+#define TIM_DMABurstLength_17Bytes TIM_DMABurstLength_17Transfers
+#define TIM_DMABurstLength_18Bytes TIM_DMABurstLength_18Transfers
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Exported_Functions
+ * @{
+ */
+
+void TIM_DeInit(TIM_TypeDef* TIMx);
+void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct);
+void TIM_OC1Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
+void TIM_OC2Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
+void TIM_OC3Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
+void TIM_OC4Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
+void TIM_ICInit(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct);
+void TIM_PWMIConfig(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct);
+void TIM_BDTRConfig(TIM_TypeDef* TIMx, TIM_BDTRInitTypeDef *TIM_BDTRInitStruct);
+void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct);
+void TIM_OCStructInit(TIM_OCInitTypeDef* TIM_OCInitStruct);
+void TIM_ICStructInit(TIM_ICInitTypeDef* TIM_ICInitStruct);
+void TIM_BDTRStructInit(TIM_BDTRInitTypeDef* TIM_BDTRInitStruct);
+void TIM_Cmd(TIM_TypeDef* TIMx, FunctionalState NewState);
+void TIM_CtrlPWMOutputs(TIM_TypeDef* TIMx, FunctionalState NewState);
+void TIM_ITConfig(TIM_TypeDef* TIMx, uint16_t TIM_IT, FunctionalState NewState);
+void TIM_GenerateEvent(TIM_TypeDef* TIMx, uint16_t TIM_EventSource);
+void TIM_DMAConfig(TIM_TypeDef* TIMx, uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength);
+void TIM_DMACmd(TIM_TypeDef* TIMx, uint16_t TIM_DMASource, FunctionalState NewState);
+void TIM_InternalClockConfig(TIM_TypeDef* TIMx);
+void TIM_ITRxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource);
+void TIM_TIxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_TIxExternalCLKSource,
+ uint16_t TIM_ICPolarity, uint16_t ICFilter);
+void TIM_ETRClockMode1Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
+ uint16_t ExtTRGFilter);
+void TIM_ETRClockMode2Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler,
+ uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter);
+void TIM_ETRConfig(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
+ uint16_t ExtTRGFilter);
+void TIM_PrescalerConfig(TIM_TypeDef* TIMx, uint16_t Prescaler, uint16_t TIM_PSCReloadMode);
+void TIM_CounterModeConfig(TIM_TypeDef* TIMx, uint16_t TIM_CounterMode);
+void TIM_SelectInputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource);
+void TIM_EncoderInterfaceConfig(TIM_TypeDef* TIMx, uint16_t TIM_EncoderMode,
+ uint16_t TIM_IC1Polarity, uint16_t TIM_IC2Polarity);
+void TIM_ForcedOC1Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
+void TIM_ForcedOC2Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
+void TIM_ForcedOC3Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
+void TIM_ForcedOC4Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
+void TIM_ARRPreloadConfig(TIM_TypeDef* TIMx, FunctionalState NewState);
+void TIM_SelectCOM(TIM_TypeDef* TIMx, FunctionalState NewState);
+void TIM_SelectCCDMA(TIM_TypeDef* TIMx, FunctionalState NewState);
+void TIM_CCPreloadControl(TIM_TypeDef* TIMx, FunctionalState NewState);
+void TIM_OC1PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
+void TIM_OC2PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
+void TIM_OC3PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
+void TIM_OC4PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
+void TIM_OC1FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
+void TIM_OC2FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
+void TIM_OC3FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
+void TIM_OC4FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
+void TIM_ClearOC1Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
+void TIM_ClearOC2Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
+void TIM_ClearOC3Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
+void TIM_ClearOC4Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
+void TIM_OC1PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
+void TIM_OC1NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity);
+void TIM_OC2PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
+void TIM_OC2NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity);
+void TIM_OC3PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
+void TIM_OC3NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity);
+void TIM_OC4PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
+void TIM_CCxCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx);
+void TIM_CCxNCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN);
+void TIM_SelectOCxM(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_OCMode);
+void TIM_UpdateDisableConfig(TIM_TypeDef* TIMx, FunctionalState NewState);
+void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource);
+void TIM_SelectHallSensor(TIM_TypeDef* TIMx, FunctionalState NewState);
+void TIM_SelectOnePulseMode(TIM_TypeDef* TIMx, uint16_t TIM_OPMode);
+void TIM_SelectOutputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_TRGOSource);
+void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_SlaveMode);
+void TIM_SelectMasterSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_MasterSlaveMode);
+void TIM_SetCounter(TIM_TypeDef* TIMx, uint16_t Counter);
+void TIM_SetAutoreload(TIM_TypeDef* TIMx, uint16_t Autoreload);
+void TIM_SetCompare1(TIM_TypeDef* TIMx, uint16_t Compare1);
+void TIM_SetCompare2(TIM_TypeDef* TIMx, uint16_t Compare2);
+void TIM_SetCompare3(TIM_TypeDef* TIMx, uint16_t Compare3);
+void TIM_SetCompare4(TIM_TypeDef* TIMx, uint16_t Compare4);
+void TIM_SetIC1Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
+void TIM_SetIC2Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
+void TIM_SetIC3Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
+void TIM_SetIC4Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
+void TIM_SetClockDivision(TIM_TypeDef* TIMx, uint16_t TIM_CKD);
+uint16_t TIM_GetCapture1(TIM_TypeDef* TIMx);
+uint16_t TIM_GetCapture2(TIM_TypeDef* TIMx);
+uint16_t TIM_GetCapture3(TIM_TypeDef* TIMx);
+uint16_t TIM_GetCapture4(TIM_TypeDef* TIMx);
+uint16_t TIM_GetCounter(TIM_TypeDef* TIMx);
+uint16_t TIM_GetPrescaler(TIM_TypeDef* TIMx);
+FlagStatus TIM_GetFlagStatus(TIM_TypeDef* TIMx, uint16_t TIM_FLAG);
+void TIM_ClearFlag(TIM_TypeDef* TIMx, uint16_t TIM_FLAG);
+ITStatus TIM_GetITStatus(TIM_TypeDef* TIMx, uint16_t TIM_IT);
+void TIM_ClearITPendingBit(TIM_TypeDef* TIMx, uint16_t TIM_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__STM32F10x_TIM_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_usart.h b/st_fw_lib/inc/stm32f10x_usart.h
new file mode 100644
index 0000000..162fa87
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_usart.h
@@ -0,0 +1,412 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_usart.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the USART
+ * firmware library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_USART_H
+#define __STM32F10x_USART_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup USART
+ * @{
+ */
+
+/** @defgroup USART_Exported_Types
+ * @{
+ */
+
+/**
+ * @brief USART Init Structure definition
+ */
+
+typedef struct
+{
+ uint32_t USART_BaudRate; /*!< This member configures the USART communication baud rate.
+ The baud rate is computed using the following formula:
+ - IntegerDivider = ((PCLKx) / (16 * (USART_InitStruct->USART_BaudRate)))
+ - FractionalDivider = ((IntegerDivider - ((u32) IntegerDivider)) * 16) + 0.5 */
+
+ uint16_t USART_WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
+ This parameter can be a value of @ref USART_Word_Length */
+
+ uint16_t USART_StopBits; /*!< Specifies the number of stop bits transmitted.
+ This parameter can be a value of @ref USART_Stop_Bits */
+
+ uint16_t USART_Parity; /*!< Specifies the parity mode.
+ This parameter can be a value of @ref USART_Parity
+ @note When parity is enabled, the computed parity is inserted
+ at the MSB position of the transmitted data (9th bit when
+ the word length is set to 9 data bits; 8th bit when the
+ word length is set to 8 data bits). */
+
+ uint16_t USART_Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
+ This parameter can be a value of @ref USART_Mode */
+
+ uint16_t USART_HardwareFlowControl; /*!< Specifies wether the hardware flow control mode is enabled
+ or disabled.
+ This parameter can be a value of @ref USART_Hardware_Flow_Control */
+} USART_InitTypeDef;
+
+/**
+ * @brief USART Clock Init Structure definition
+ */
+
+typedef struct
+{
+
+ uint16_t USART_Clock; /*!< Specifies whether the USART clock is enabled or disabled.
+ This parameter can be a value of @ref USART_Clock */
+
+ uint16_t USART_CPOL; /*!< Specifies the steady state value of the serial clock.
+ This parameter can be a value of @ref USART_Clock_Polarity */
+
+ uint16_t USART_CPHA; /*!< Specifies the clock transition on which the bit capture is made.
+ This parameter can be a value of @ref USART_Clock_Phase */
+
+ uint16_t USART_LastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
+ data bit (MSB) has to be output on the SCLK pin in synchronous mode.
+ This parameter can be a value of @ref USART_Last_Bit */
+} USART_ClockInitTypeDef;
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_Exported_Constants
+ * @{
+ */
+
+#define IS_USART_ALL_PERIPH(PERIPH) (((PERIPH) == USART1) || \
+ ((PERIPH) == USART2) || \
+ ((PERIPH) == USART3) || \
+ ((PERIPH) == UART4) || \
+ ((PERIPH) == UART5))
+
+#define IS_USART_123_PERIPH(PERIPH) (((PERIPH) == USART1) || \
+ ((PERIPH) == USART2) || \
+ ((PERIPH) == USART3))
+
+#define IS_USART_1234_PERIPH(PERIPH) (((PERIPH) == USART1) || \
+ ((PERIPH) == USART2) || \
+ ((PERIPH) == USART3) || \
+ ((PERIPH) == UART4))
+/** @defgroup USART_Word_Length
+ * @{
+ */
+
+#define USART_WordLength_8b ((uint16_t)0x0000)
+#define USART_WordLength_9b ((uint16_t)0x1000)
+
+#define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WordLength_8b) || \
+ ((LENGTH) == USART_WordLength_9b))
+/**
+ * @}
+ */
+
+/** @defgroup USART_Stop_Bits
+ * @{
+ */
+
+#define USART_StopBits_1 ((uint16_t)0x0000)
+#define USART_StopBits_0_5 ((uint16_t)0x1000)
+#define USART_StopBits_2 ((uint16_t)0x2000)
+#define USART_StopBits_1_5 ((uint16_t)0x3000)
+#define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_StopBits_1) || \
+ ((STOPBITS) == USART_StopBits_0_5) || \
+ ((STOPBITS) == USART_StopBits_2) || \
+ ((STOPBITS) == USART_StopBits_1_5))
+/**
+ * @}
+ */
+
+/** @defgroup USART_Parity
+ * @{
+ */
+
+#define USART_Parity_No ((uint16_t)0x0000)
+#define USART_Parity_Even ((uint16_t)0x0400)
+#define USART_Parity_Odd ((uint16_t)0x0600)
+#define IS_USART_PARITY(PARITY) (((PARITY) == USART_Parity_No) || \
+ ((PARITY) == USART_Parity_Even) || \
+ ((PARITY) == USART_Parity_Odd))
+/**
+ * @}
+ */
+
+/** @defgroup USART_Mode
+ * @{
+ */
+
+#define USART_Mode_Rx ((uint16_t)0x0004)
+#define USART_Mode_Tx ((uint16_t)0x0008)
+#define IS_USART_MODE(MODE) ((((MODE) & (uint16_t)0xFFF3) == 0x00) && ((MODE) != (uint16_t)0x00))
+/**
+ * @}
+ */
+
+/** @defgroup USART_Hardware_Flow_Control
+ * @{
+ */
+#define USART_HardwareFlowControl_None ((uint16_t)0x0000)
+#define USART_HardwareFlowControl_RTS ((uint16_t)0x0100)
+#define USART_HardwareFlowControl_CTS ((uint16_t)0x0200)
+#define USART_HardwareFlowControl_RTS_CTS ((uint16_t)0x0300)
+#define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\
+ (((CONTROL) == USART_HardwareFlowControl_None) || \
+ ((CONTROL) == USART_HardwareFlowControl_RTS) || \
+ ((CONTROL) == USART_HardwareFlowControl_CTS) || \
+ ((CONTROL) == USART_HardwareFlowControl_RTS_CTS))
+/**
+ * @}
+ */
+
+/** @defgroup USART_Clock
+ * @{
+ */
+#define USART_Clock_Disable ((uint16_t)0x0000)
+#define USART_Clock_Enable ((uint16_t)0x0800)
+#define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_Clock_Disable) || \
+ ((CLOCK) == USART_Clock_Enable))
+/**
+ * @}
+ */
+
+/** @defgroup USART_Clock_Polarity
+ * @{
+ */
+
+#define USART_CPOL_Low ((uint16_t)0x0000)
+#define USART_CPOL_High ((uint16_t)0x0400)
+#define IS_USART_CPOL(CPOL) (((CPOL) == USART_CPOL_Low) || ((CPOL) == USART_CPOL_High))
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_Clock_Phase
+ * @{
+ */
+
+#define USART_CPHA_1Edge ((uint16_t)0x0000)
+#define USART_CPHA_2Edge ((uint16_t)0x0200)
+#define IS_USART_CPHA(CPHA) (((CPHA) == USART_CPHA_1Edge) || ((CPHA) == USART_CPHA_2Edge))
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_Last_Bit
+ * @{
+ */
+
+#define USART_LastBit_Disable ((uint16_t)0x0000)
+#define USART_LastBit_Enable ((uint16_t)0x0100)
+#define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LastBit_Disable) || \
+ ((LASTBIT) == USART_LastBit_Enable))
+/**
+ * @}
+ */
+
+/** @defgroup USART_Interrupt_definition
+ * @{
+ */
+
+#define USART_IT_PE ((uint16_t)0x0028)
+#define USART_IT_TXE ((uint16_t)0x0727)
+#define USART_IT_TC ((uint16_t)0x0626)
+#define USART_IT_RXNE ((uint16_t)0x0525)
+#define USART_IT_IDLE ((uint16_t)0x0424)
+#define USART_IT_LBD ((uint16_t)0x0846)
+#define USART_IT_CTS ((uint16_t)0x096A)
+#define USART_IT_ERR ((uint16_t)0x0060)
+#define USART_IT_ORE ((uint16_t)0x0360)
+#define USART_IT_NE ((uint16_t)0x0260)
+#define USART_IT_FE ((uint16_t)0x0160)
+#define IS_USART_CONFIG_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
+ ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
+ ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
+ ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ERR))
+#define IS_USART_GET_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
+ ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
+ ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
+ ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ORE) || \
+ ((IT) == USART_IT_NE) || ((IT) == USART_IT_FE))
+#define IS_USART_CLEAR_IT(IT) (((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
+ ((IT) == USART_IT_LBD) || ((IT) == USART_IT_CTS))
+/**
+ * @}
+ */
+
+/** @defgroup USART_DMA_Requests
+ * @{
+ */
+
+#define USART_DMAReq_Tx ((uint16_t)0x0080)
+#define USART_DMAReq_Rx ((uint16_t)0x0040)
+#define IS_USART_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFF3F) == 0x00) && ((DMAREQ) != (uint16_t)0x00))
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_WakeUp_methods
+ * @{
+ */
+
+#define USART_WakeUp_IdleLine ((uint16_t)0x0000)
+#define USART_WakeUp_AddressMark ((uint16_t)0x0800)
+#define IS_USART_WAKEUP(WAKEUP) (((WAKEUP) == USART_WakeUp_IdleLine) || \
+ ((WAKEUP) == USART_WakeUp_AddressMark))
+/**
+ * @}
+ */
+
+/** @defgroup USART_LIN_Break_Detection_Length
+ * @{
+ */
+
+#define USART_LINBreakDetectLength_10b ((uint16_t)0x0000)
+#define USART_LINBreakDetectLength_11b ((uint16_t)0x0020)
+#define IS_USART_LIN_BREAK_DETECT_LENGTH(LENGTH) \
+ (((LENGTH) == USART_LINBreakDetectLength_10b) || \
+ ((LENGTH) == USART_LINBreakDetectLength_11b))
+/**
+ * @}
+ */
+
+/** @defgroup USART_IrDA_Low_Power
+ * @{
+ */
+
+#define USART_IrDAMode_LowPower ((uint16_t)0x0004)
+#define USART_IrDAMode_Normal ((uint16_t)0x0000)
+#define IS_USART_IRDA_MODE(MODE) (((MODE) == USART_IrDAMode_LowPower) || \
+ ((MODE) == USART_IrDAMode_Normal))
+/**
+ * @}
+ */
+
+/** @defgroup USART_Flags
+ * @{
+ */
+
+#define USART_FLAG_CTS ((uint16_t)0x0200)
+#define USART_FLAG_LBD ((uint16_t)0x0100)
+#define USART_FLAG_TXE ((uint16_t)0x0080)
+#define USART_FLAG_TC ((uint16_t)0x0040)
+#define USART_FLAG_RXNE ((uint16_t)0x0020)
+#define USART_FLAG_IDLE ((uint16_t)0x0010)
+#define USART_FLAG_ORE ((uint16_t)0x0008)
+#define USART_FLAG_NE ((uint16_t)0x0004)
+#define USART_FLAG_FE ((uint16_t)0x0002)
+#define USART_FLAG_PE ((uint16_t)0x0001)
+#define IS_USART_FLAG(FLAG) (((FLAG) == USART_FLAG_PE) || ((FLAG) == USART_FLAG_TXE) || \
+ ((FLAG) == USART_FLAG_TC) || ((FLAG) == USART_FLAG_RXNE) || \
+ ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_LBD) || \
+ ((FLAG) == USART_FLAG_CTS) || ((FLAG) == USART_FLAG_ORE) || \
+ ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE))
+
+#define IS_USART_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFC9F) == 0x00) && ((FLAG) != (uint16_t)0x00))
+#define IS_USART_PERIPH_FLAG(PERIPH, USART_FLAG) ((((*(uint32_t*)&(PERIPH)) != UART4_BASE) &&\
+ ((*(uint32_t*)&(PERIPH)) != UART5_BASE)) \
+ || ((USART_FLAG) != USART_FLAG_CTS))
+#define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 0x0044AA21))
+#define IS_USART_ADDRESS(ADDRESS) ((ADDRESS) <= 0xF)
+#define IS_USART_DATA(DATA) ((DATA) <= 0x1FF)
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_Exported_Functions
+ * @{
+ */
+
+void USART_DeInit(USART_TypeDef* USARTx);
+void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct);
+void USART_StructInit(USART_InitTypeDef* USART_InitStruct);
+void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct);
+void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct);
+void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
+void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState);
+void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState);
+void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address);
+void USART_WakeUpConfig(USART_TypeDef* USARTx, uint16_t USART_WakeUp);
+void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState);
+void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint16_t USART_LINBreakDetectLength);
+void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState);
+void USART_SendData(USART_TypeDef* USARTx, uint16_t Data);
+uint16_t USART_ReceiveData(USART_TypeDef* USARTx);
+void USART_SendBreak(USART_TypeDef* USARTx);
+void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime);
+void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler);
+void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState);
+void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState);
+void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState);
+void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
+void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState);
+void USART_IrDAConfig(USART_TypeDef* USARTx, uint16_t USART_IrDAMode);
+void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState);
+FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG);
+void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG);
+ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT);
+void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_USART_H */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/inc/stm32f10x_wwdg.h b/st_fw_lib/inc/stm32f10x_wwdg.h
new file mode 100644
index 0000000..bdfa177
--- /dev/null
+++ b/st_fw_lib/inc/stm32f10x_wwdg.h
@@ -0,0 +1,115 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_wwdg.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file contains all the functions prototypes for the WWDG firmware
+ * library.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_WWDG_H
+#define __STM32F10x_WWDG_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @addtogroup WWDG
+ * @{
+ */
+
+/** @defgroup WWDG_Exported_Types
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup WWDG_Exported_Constants
+ * @{
+ */
+
+/** @defgroup WWDG_Prescaler
+ * @{
+ */
+
+#define WWDG_Prescaler_1 ((uint32_t)0x00000000)
+#define WWDG_Prescaler_2 ((uint32_t)0x00000080)
+#define WWDG_Prescaler_4 ((uint32_t)0x00000100)
+#define WWDG_Prescaler_8 ((uint32_t)0x00000180)
+#define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \
+ ((PRESCALER) == WWDG_Prescaler_2) || \
+ ((PRESCALER) == WWDG_Prescaler_4) || \
+ ((PRESCALER) == WWDG_Prescaler_8))
+#define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F)
+#define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F))
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup WWDG_Exported_Macros
+ * @{
+ */
+/**
+ * @}
+ */
+
+/** @defgroup WWDG_Exported_Functions
+ * @{
+ */
+
+void WWDG_DeInit(void);
+void WWDG_SetPrescaler(uint32_t WWDG_Prescaler);
+void WWDG_SetWindowValue(uint8_t WindowValue);
+void WWDG_EnableIT(void);
+void WWDG_SetCounter(uint8_t Counter);
+void WWDG_Enable(uint8_t Counter);
+FlagStatus WWDG_GetFlagStatus(void);
+void WWDG_ClearFlag(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_WWDG_H */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/core_cm3.c b/st_fw_lib/src/core_cm3.c
new file mode 100644
index 0000000..fcff0d1
--- /dev/null
+++ b/st_fw_lib/src/core_cm3.c
@@ -0,0 +1,784 @@
+/**************************************************************************//**
+ * @file core_cm3.c
+ * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Source File
+ * @version V1.30
+ * @date 30. October 2009
+ *
+ * @note
+ * Copyright (C) 2009 ARM Limited. All rights reserved.
+ *
+ * @par
+ * ARM Limited (ARM) is supplying this software for use with Cortex-M
+ * processor based microcontrollers. This file can be freely distributed
+ * within development tools that are supporting such ARM based processors.
+ *
+ * @par
+ * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
+ * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
+ * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
+ * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+ *
+ ******************************************************************************/
+
+#include <stdint.h>
+
+/* define compiler specific symbols */
+#if defined ( __CC_ARM )
+ #define __ASM __asm /*!< asm keyword for ARM Compiler */
+ #define __INLINE __inline /*!< inline keyword for ARM Compiler */
+
+#elif defined ( __ICCARM__ )
+ #define __ASM __asm /*!< asm keyword for IAR Compiler */
+ #define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */
+
+#elif defined ( __GNUC__ )
+ #define __ASM __asm /*!< asm keyword for GNU Compiler */
+ #define __INLINE inline /*!< inline keyword for GNU Compiler */
+
+#elif defined ( __TASKING__ )
+ #define __ASM __asm /*!< asm keyword for TASKING Compiler */
+ #define __INLINE inline /*!< inline keyword for TASKING Compiler */
+
+#endif
+
+
+/* ################### Compiler specific Intrinsics ########################### */
+
+#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
+/* ARM armcc specific functions */
+
+/**
+ * @brief Return the Process Stack Pointer
+ *
+ * @return ProcessStackPointer
+ *
+ * Return the actual process stack pointer
+ */
+__ASM uint32_t __get_PSP(void)
+{
+ mrs r0, psp
+ bx lr
+}
+
+/**
+ * @brief Set the Process Stack Pointer
+ *
+ * @param topOfProcStack Process Stack Pointer
+ *
+ * Assign the value ProcessStackPointer to the MSP
+ * (process stack pointer) Cortex processor register
+ */
+__ASM void __set_PSP(uint32_t topOfProcStack)
+{
+ msr psp, r0
+ bx lr
+}
+
+/**
+ * @brief Return the Main Stack Pointer
+ *
+ * @return Main Stack Pointer
+ *
+ * Return the current value of the MSP (main stack pointer)
+ * Cortex processor register
+ */
+__ASM uint32_t __get_MSP(void)
+{
+ mrs r0, msp
+ bx lr
+}
+
+/**
+ * @brief Set the Main Stack Pointer
+ *
+ * @param topOfMainStack Main Stack Pointer
+ *
+ * Assign the value mainStackPointer to the MSP
+ * (main stack pointer) Cortex processor register
+ */
+__ASM void __set_MSP(uint32_t mainStackPointer)
+{
+ msr msp, r0
+ bx lr
+}
+
+/**
+ * @brief Reverse byte order in unsigned short value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in unsigned short value
+ */
+__ASM uint32_t __REV16(uint16_t value)
+{
+ rev16 r0, r0
+ bx lr
+}
+
+/**
+ * @brief Reverse byte order in signed short value with sign extension to integer
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in signed short value with sign extension to integer
+ */
+__ASM int32_t __REVSH(int16_t value)
+{
+ revsh r0, r0
+ bx lr
+}
+
+
+#if (__ARMCC_VERSION < 400000)
+
+/**
+ * @brief Remove the exclusive lock created by ldrex
+ *
+ * Removes the exclusive lock which is created by ldrex.
+ */
+__ASM void __CLREX(void)
+{
+ clrex
+}
+
+/**
+ * @brief Return the Base Priority value
+ *
+ * @return BasePriority
+ *
+ * Return the content of the base priority register
+ */
+__ASM uint32_t __get_BASEPRI(void)
+{
+ mrs r0, basepri
+ bx lr
+}
+
+/**
+ * @brief Set the Base Priority value
+ *
+ * @param basePri BasePriority
+ *
+ * Set the base priority register
+ */
+__ASM void __set_BASEPRI(uint32_t basePri)
+{
+ msr basepri, r0
+ bx lr
+}
+
+/**
+ * @brief Return the Priority Mask value
+ *
+ * @return PriMask
+ *
+ * Return state of the priority mask bit from the priority mask register
+ */
+__ASM uint32_t __get_PRIMASK(void)
+{
+ mrs r0, primask
+ bx lr
+}
+
+/**
+ * @brief Set the Priority Mask value
+ *
+ * @param priMask PriMask
+ *
+ * Set the priority mask bit in the priority mask register
+ */
+__ASM void __set_PRIMASK(uint32_t priMask)
+{
+ msr primask, r0
+ bx lr
+}
+
+/**
+ * @brief Return the Fault Mask value
+ *
+ * @return FaultMask
+ *
+ * Return the content of the fault mask register
+ */
+__ASM uint32_t __get_FAULTMASK(void)
+{
+ mrs r0, faultmask
+ bx lr
+}
+
+/**
+ * @brief Set the Fault Mask value
+ *
+ * @param faultMask faultMask value
+ *
+ * Set the fault mask register
+ */
+__ASM void __set_FAULTMASK(uint32_t faultMask)
+{
+ msr faultmask, r0
+ bx lr
+}
+
+/**
+ * @brief Return the Control Register value
+ *
+ * @return Control value
+ *
+ * Return the content of the control register
+ */
+__ASM uint32_t __get_CONTROL(void)
+{
+ mrs r0, control
+ bx lr
+}
+
+/**
+ * @brief Set the Control Register value
+ *
+ * @param control Control value
+ *
+ * Set the control register
+ */
+__ASM void __set_CONTROL(uint32_t control)
+{
+ msr control, r0
+ bx lr
+}
+
+#endif /* __ARMCC_VERSION */
+
+
+
+#elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/
+/* IAR iccarm specific functions */
+#pragma diag_suppress=Pe940
+
+/**
+ * @brief Return the Process Stack Pointer
+ *
+ * @return ProcessStackPointer
+ *
+ * Return the actual process stack pointer
+ */
+uint32_t __get_PSP(void)
+{
+ __ASM("mrs r0, psp");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief Set the Process Stack Pointer
+ *
+ * @param topOfProcStack Process Stack Pointer
+ *
+ * Assign the value ProcessStackPointer to the MSP
+ * (process stack pointer) Cortex processor register
+ */
+void __set_PSP(uint32_t topOfProcStack)
+{
+ __ASM("msr psp, r0");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief Return the Main Stack Pointer
+ *
+ * @return Main Stack Pointer
+ *
+ * Return the current value of the MSP (main stack pointer)
+ * Cortex processor register
+ */
+uint32_t __get_MSP(void)
+{
+ __ASM("mrs r0, msp");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief Set the Main Stack Pointer
+ *
+ * @param topOfMainStack Main Stack Pointer
+ *
+ * Assign the value mainStackPointer to the MSP
+ * (main stack pointer) Cortex processor register
+ */
+void __set_MSP(uint32_t topOfMainStack)
+{
+ __ASM("msr msp, r0");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief Reverse byte order in unsigned short value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in unsigned short value
+ */
+uint32_t __REV16(uint16_t value)
+{
+ __ASM("rev16 r0, r0");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief Reverse bit order of value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse bit order of value
+ */
+uint32_t __RBIT(uint32_t value)
+{
+ __ASM("rbit r0, r0");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief LDR Exclusive (8 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 8 bit values)
+ */
+uint8_t __LDREXB(uint8_t *addr)
+{
+ __ASM("ldrexb r0, [r0]");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief LDR Exclusive (16 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 16 bit values
+ */
+uint16_t __LDREXH(uint16_t *addr)
+{
+ __ASM("ldrexh r0, [r0]");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief LDR Exclusive (32 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 32 bit values
+ */
+uint32_t __LDREXW(uint32_t *addr)
+{
+ __ASM("ldrex r0, [r0]");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief STR Exclusive (8 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 8 bit values
+ */
+uint32_t __STREXB(uint8_t value, uint8_t *addr)
+{
+ __ASM("strexb r0, r0, [r1]");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief STR Exclusive (16 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 16 bit values
+ */
+uint32_t __STREXH(uint16_t value, uint16_t *addr)
+{
+ __ASM("strexh r0, r0, [r1]");
+ __ASM("bx lr");
+}
+
+/**
+ * @brief STR Exclusive (32 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 32 bit values
+ */
+uint32_t __STREXW(uint32_t value, uint32_t *addr)
+{
+ __ASM("strex r0, r0, [r1]");
+ __ASM("bx lr");
+}
+
+#pragma diag_default=Pe940
+
+
+#elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
+/* GNU gcc specific functions */
+
+/**
+ * @brief Return the Process Stack Pointer
+ *
+ * @return ProcessStackPointer
+ *
+ * Return the actual process stack pointer
+ */
+uint32_t __get_PSP(void) __attribute__( ( naked ) );
+uint32_t __get_PSP(void)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("MRS %0, psp\n\t"
+ "MOV r0, %0 \n\t"
+ "BX lr \n\t" : "=r" (result) );
+ return(result);
+}
+
+/**
+ * @brief Set the Process Stack Pointer
+ *
+ * @param topOfProcStack Process Stack Pointer
+ *
+ * Assign the value ProcessStackPointer to the MSP
+ * (process stack pointer) Cortex processor register
+ */
+void __set_PSP(uint32_t topOfProcStack) __attribute__( ( naked ) );
+void __set_PSP(uint32_t topOfProcStack)
+{
+ __ASM volatile ("MSR psp, %0\n\t"
+ "BX lr \n\t" : : "r" (topOfProcStack) );
+}
+
+/**
+ * @brief Return the Main Stack Pointer
+ *
+ * @return Main Stack Pointer
+ *
+ * Return the current value of the MSP (main stack pointer)
+ * Cortex processor register
+ */
+uint32_t __get_MSP(void) __attribute__( ( naked ) );
+uint32_t __get_MSP(void)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("MRS %0, msp\n\t"
+ "MOV r0, %0 \n\t"
+ "BX lr \n\t" : "=r" (result) );
+ return(result);
+}
+
+/**
+ * @brief Set the Main Stack Pointer
+ *
+ * @param topOfMainStack Main Stack Pointer
+ *
+ * Assign the value mainStackPointer to the MSP
+ * (main stack pointer) Cortex processor register
+ */
+void __set_MSP(uint32_t topOfMainStack) __attribute__( ( naked ) );
+void __set_MSP(uint32_t topOfMainStack)
+{
+ __ASM volatile ("MSR msp, %0\n\t"
+ "BX lr \n\t" : : "r" (topOfMainStack) );
+}
+
+/**
+ * @brief Return the Base Priority value
+ *
+ * @return BasePriority
+ *
+ * Return the content of the base priority register
+ */
+uint32_t __get_BASEPRI(void)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
+ return(result);
+}
+
+/**
+ * @brief Set the Base Priority value
+ *
+ * @param basePri BasePriority
+ *
+ * Set the base priority register
+ */
+void __set_BASEPRI(uint32_t value)
+{
+ __ASM volatile ("MSR basepri, %0" : : "r" (value) );
+}
+
+/**
+ * @brief Return the Priority Mask value
+ *
+ * @return PriMask
+ *
+ * Return state of the priority mask bit from the priority mask register
+ */
+uint32_t __get_PRIMASK(void)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("MRS %0, primask" : "=r" (result) );
+ return(result);
+}
+
+/**
+ * @brief Set the Priority Mask value
+ *
+ * @param priMask PriMask
+ *
+ * Set the priority mask bit in the priority mask register
+ */
+void __set_PRIMASK(uint32_t priMask)
+{
+ __ASM volatile ("MSR primask, %0" : : "r" (priMask) );
+}
+
+/**
+ * @brief Return the Fault Mask value
+ *
+ * @return FaultMask
+ *
+ * Return the content of the fault mask register
+ */
+uint32_t __get_FAULTMASK(void)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
+ return(result);
+}
+
+/**
+ * @brief Set the Fault Mask value
+ *
+ * @param faultMask faultMask value
+ *
+ * Set the fault mask register
+ */
+void __set_FAULTMASK(uint32_t faultMask)
+{
+ __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) );
+}
+
+/**
+ * @brief Return the Control Register value
+*
+* @return Control value
+ *
+ * Return the content of the control register
+ */
+uint32_t __get_CONTROL(void)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("MRS %0, control" : "=r" (result) );
+ return(result);
+}
+
+/**
+ * @brief Set the Control Register value
+ *
+ * @param control Control value
+ *
+ * Set the control register
+ */
+void __set_CONTROL(uint32_t control)
+{
+ __ASM volatile ("MSR control, %0" : : "r" (control) );
+}
+
+
+/**
+ * @brief Reverse byte order in integer value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in integer value
+ */
+uint32_t __REV(uint32_t value)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) );
+ return(result);
+}
+
+/**
+ * @brief Reverse byte order in unsigned short value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in unsigned short value
+ */
+uint32_t __REV16(uint16_t value)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) );
+ return(result);
+}
+
+/**
+ * @brief Reverse byte order in signed short value with sign extension to integer
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse byte order in signed short value with sign extension to integer
+ */
+int32_t __REVSH(int16_t value)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) );
+ return(result);
+}
+
+/**
+ * @brief Reverse bit order of value
+ *
+ * @param value value to reverse
+ * @return reversed value
+ *
+ * Reverse bit order of value
+ */
+uint32_t __RBIT(uint32_t value)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
+ return(result);
+}
+
+/**
+ * @brief LDR Exclusive (8 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 8 bit value
+ */
+uint8_t __LDREXB(uint8_t *addr)
+{
+ uint8_t result=0;
+
+ __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) );
+ return(result);
+}
+
+/**
+ * @brief LDR Exclusive (16 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 16 bit values
+ */
+uint16_t __LDREXH(uint16_t *addr)
+{
+ uint16_t result=0;
+
+ __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) );
+ return(result);
+}
+
+/**
+ * @brief LDR Exclusive (32 bit)
+ *
+ * @param *addr address pointer
+ * @return value of (*address)
+ *
+ * Exclusive LDR command for 32 bit values
+ */
+uint32_t __LDREXW(uint32_t *addr)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) );
+ return(result);
+}
+
+/**
+ * @brief STR Exclusive (8 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 8 bit values
+ */
+uint32_t __STREXB(uint8_t value, uint8_t *addr)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("strexb %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );
+ return(result);
+}
+
+/**
+ * @brief STR Exclusive (16 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 16 bit values
+ */
+uint32_t __STREXH(uint16_t value, uint16_t *addr)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("strexh %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );
+ return(result);
+}
+
+/**
+ * @brief STR Exclusive (32 bit)
+ *
+ * @param value value to store
+ * @param *addr address pointer
+ * @return successful / failed
+ *
+ * Exclusive STR command for 32 bit values
+ */
+uint32_t __STREXW(uint32_t value, uint32_t *addr)
+{
+ uint32_t result=0;
+
+ __ASM volatile ("strex %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );
+ return(result);
+}
+
+
+#elif (defined (__TASKING__)) /*------------------ TASKING Compiler ---------------------*/
+/* TASKING carm specific functions */
+
+/*
+ * The CMSIS functions have been implemented as intrinsics in the compiler.
+ * Please use "carm -?i" to get an up to date list of all instrinsics,
+ * Including the CMSIS ones.
+ */
+
+#endif
diff --git a/st_fw_lib/src/misc.c b/st_fw_lib/src/misc.c
new file mode 100644
index 0000000..c0a5e11
--- /dev/null
+++ b/st_fw_lib/src/misc.c
@@ -0,0 +1,225 @@
+/**
+ ******************************************************************************
+ * @file misc.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the miscellaneous firmware functions (add-on
+ * to CMSIS functions).
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "misc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup MISC
+ * @brief MISC driver modules
+ * @{
+ */
+
+/** @defgroup MISC_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup MISC_Private_Defines
+ * @{
+ */
+
+#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
+/**
+ * @}
+ */
+
+/** @defgroup MISC_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup MISC_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup MISC_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup MISC_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Configures the priority grouping: pre-emption priority and subpriority.
+ * @param NVIC_PriorityGroup: specifies the priority grouping bits length.
+ * This parameter can be one of the following values:
+ * @arg NVIC_PriorityGroup_0: 0 bits for pre-emption priority
+ * 4 bits for subpriority
+ * @arg NVIC_PriorityGroup_1: 1 bits for pre-emption priority
+ * 3 bits for subpriority
+ * @arg NVIC_PriorityGroup_2: 2 bits for pre-emption priority
+ * 2 bits for subpriority
+ * @arg NVIC_PriorityGroup_3: 3 bits for pre-emption priority
+ * 1 bits for subpriority
+ * @arg NVIC_PriorityGroup_4: 4 bits for pre-emption priority
+ * 0 bits for subpriority
+ * @retval None
+ */
+void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
+{
+ /* Check the parameters */
+ assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup));
+
+ /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */
+ SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup;
+}
+
+/**
+ * @brief Initializes the NVIC peripheral according to the specified
+ * parameters in the NVIC_InitStruct.
+ * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains
+ * the configuration information for the specified NVIC peripheral.
+ * @retval None
+ */
+void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
+{
+ uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;
+
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd));
+ assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority));
+ assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority));
+
+ if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)
+ {
+ /* Compute the Corresponding IRQ Priority --------------------------------*/
+ tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08;
+ tmppre = (0x4 - tmppriority);
+ tmpsub = tmpsub >> tmppriority;
+
+ tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;
+ tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub;
+ tmppriority = tmppriority << 0x04;
+
+ NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;
+
+ /* Enable the Selected IRQ Channels --------------------------------------*/
+ NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
+ (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
+ }
+ else
+ {
+ /* Disable the Selected IRQ Channels -------------------------------------*/
+ NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
+ (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
+ }
+}
+
+/**
+ * @brief Sets the vector table location and Offset.
+ * @param NVIC_VectTab: specifies if the vector table is in RAM or FLASH memory.
+ * This parameter can be one of the following values:
+ * @arg NVIC_VectTab_RAM
+ * @arg NVIC_VectTab_FLASH
+ * @param Offset: Vector Table base offset field. This value must be a multiple
+ * of 0x200.
+ * @retval None
+ */
+void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
+{
+ /* Check the parameters */
+ assert_param(IS_NVIC_VECTTAB(NVIC_VectTab));
+ assert_param(IS_NVIC_OFFSET(Offset));
+
+ SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80);
+}
+
+/**
+ * @brief Selects the condition for the system to enter low power mode.
+ * @param LowPowerMode: Specifies the new mode for the system to enter low power mode.
+ * This parameter can be one of the following values:
+ * @arg NVIC_LP_SEVONPEND
+ * @arg NVIC_LP_SLEEPDEEP
+ * @arg NVIC_LP_SLEEPONEXIT
+ * @param NewState: new state of LP condition. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_NVIC_LP(LowPowerMode));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ SCB->SCR |= LowPowerMode;
+ }
+ else
+ {
+ SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
+ }
+}
+
+/**
+ * @brief Configures the SysTick clock source.
+ * @param SysTick_CLKSource: specifies the SysTick clock source.
+ * This parameter can be one of the following values:
+ * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source.
+ * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source.
+ * @retval None
+ */
+void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
+{
+ /* Check the parameters */
+ assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
+ if (SysTick_CLKSource == SysTick_CLKSource_HCLK)
+ {
+ SysTick->CTRL |= SysTick_CLKSource_HCLK;
+ }
+ else
+ {
+ SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8;
+ }
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_adc.c b/st_fw_lib/src/stm32f10x_adc.c
new file mode 100644
index 0000000..8155dc9
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_adc.c
@@ -0,0 +1,1307 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_adc.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the ADC firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_adc.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup ADC
+ * @brief ADC driver modules
+ * @{
+ */
+
+/** @defgroup ADC_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_Private_Defines
+ * @{
+ */
+
+/* ADC DISCNUM mask */
+#define CR1_DISCNUM_Reset ((uint32_t)0xFFFF1FFF)
+
+/* ADC DISCEN mask */
+#define CR1_DISCEN_Set ((uint32_t)0x00000800)
+#define CR1_DISCEN_Reset ((uint32_t)0xFFFFF7FF)
+
+/* ADC JAUTO mask */
+#define CR1_JAUTO_Set ((uint32_t)0x00000400)
+#define CR1_JAUTO_Reset ((uint32_t)0xFFFFFBFF)
+
+/* ADC JDISCEN mask */
+#define CR1_JDISCEN_Set ((uint32_t)0x00001000)
+#define CR1_JDISCEN_Reset ((uint32_t)0xFFFFEFFF)
+
+/* ADC AWDCH mask */
+#define CR1_AWDCH_Reset ((uint32_t)0xFFFFFFE0)
+
+/* ADC Analog watchdog enable mode mask */
+#define CR1_AWDMode_Reset ((uint32_t)0xFF3FFDFF)
+
+/* CR1 register Mask */
+#define CR1_CLEAR_Mask ((uint32_t)0xFFF0FEFF)
+
+/* ADC ADON mask */
+#define CR2_ADON_Set ((uint32_t)0x00000001)
+#define CR2_ADON_Reset ((uint32_t)0xFFFFFFFE)
+
+/* ADC DMA mask */
+#define CR2_DMA_Set ((uint32_t)0x00000100)
+#define CR2_DMA_Reset ((uint32_t)0xFFFFFEFF)
+
+/* ADC RSTCAL mask */
+#define CR2_RSTCAL_Set ((uint32_t)0x00000008)
+
+/* ADC CAL mask */
+#define CR2_CAL_Set ((uint32_t)0x00000004)
+
+/* ADC SWSTART mask */
+#define CR2_SWSTART_Set ((uint32_t)0x00400000)
+
+/* ADC EXTTRIG mask */
+#define CR2_EXTTRIG_Set ((uint32_t)0x00100000)
+#define CR2_EXTTRIG_Reset ((uint32_t)0xFFEFFFFF)
+
+/* ADC Software start mask */
+#define CR2_EXTTRIG_SWSTART_Set ((uint32_t)0x00500000)
+#define CR2_EXTTRIG_SWSTART_Reset ((uint32_t)0xFFAFFFFF)
+
+/* ADC JEXTSEL mask */
+#define CR2_JEXTSEL_Reset ((uint32_t)0xFFFF8FFF)
+
+/* ADC JEXTTRIG mask */
+#define CR2_JEXTTRIG_Set ((uint32_t)0x00008000)
+#define CR2_JEXTTRIG_Reset ((uint32_t)0xFFFF7FFF)
+
+/* ADC JSWSTART mask */
+#define CR2_JSWSTART_Set ((uint32_t)0x00200000)
+
+/* ADC injected software start mask */
+#define CR2_JEXTTRIG_JSWSTART_Set ((uint32_t)0x00208000)
+#define CR2_JEXTTRIG_JSWSTART_Reset ((uint32_t)0xFFDF7FFF)
+
+/* ADC TSPD mask */
+#define CR2_TSVREFE_Set ((uint32_t)0x00800000)
+#define CR2_TSVREFE_Reset ((uint32_t)0xFF7FFFFF)
+
+/* CR2 register Mask */
+#define CR2_CLEAR_Mask ((uint32_t)0xFFF1F7FD)
+
+/* ADC SQx mask */
+#define SQR3_SQ_Set ((uint32_t)0x0000001F)
+#define SQR2_SQ_Set ((uint32_t)0x0000001F)
+#define SQR1_SQ_Set ((uint32_t)0x0000001F)
+
+/* SQR1 register Mask */
+#define SQR1_CLEAR_Mask ((uint32_t)0xFF0FFFFF)
+
+/* ADC JSQx mask */
+#define JSQR_JSQ_Set ((uint32_t)0x0000001F)
+
+/* ADC JL mask */
+#define JSQR_JL_Set ((uint32_t)0x00300000)
+#define JSQR_JL_Reset ((uint32_t)0xFFCFFFFF)
+
+/* ADC SMPx mask */
+#define SMPR1_SMP_Set ((uint32_t)0x00000007)
+#define SMPR2_SMP_Set ((uint32_t)0x00000007)
+
+/* ADC JDRx registers offset */
+#define JDR_Offset ((uint8_t)0x28)
+
+/* ADC1 DR register base address */
+#define DR_ADDRESS ((uint32_t)0x4001244C)
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup ADC_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the ADCx peripheral registers to their default reset values.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @retval None
+ */
+void ADC_DeInit(ADC_TypeDef* ADCx)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+
+ if (ADCx == ADC1)
+ {
+ /* Enable ADC1 reset state */
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, ENABLE);
+ /* Release ADC1 from reset state */
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, DISABLE);
+ }
+ else if (ADCx == ADC2)
+ {
+ /* Enable ADC2 reset state */
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC2, ENABLE);
+ /* Release ADC2 from reset state */
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC2, DISABLE);
+ }
+ else
+ {
+ if (ADCx == ADC3)
+ {
+ /* Enable ADC3 reset state */
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC3, ENABLE);
+ /* Release ADC3 from reset state */
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC3, DISABLE);
+ }
+ }
+}
+
+/**
+ * @brief Initializes the ADCx peripheral according to the specified parameters
+ * in the ADC_InitStruct.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_InitStruct: pointer to an ADC_InitTypeDef structure that contains
+ * the configuration information for the specified ADC peripheral.
+ * @retval None
+ */
+void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct)
+{
+ uint32_t tmpreg1 = 0;
+ uint8_t tmpreg2 = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_MODE(ADC_InitStruct->ADC_Mode));
+ assert_param(IS_FUNCTIONAL_STATE(ADC_InitStruct->ADC_ScanConvMode));
+ assert_param(IS_FUNCTIONAL_STATE(ADC_InitStruct->ADC_ContinuousConvMode));
+ assert_param(IS_ADC_EXT_TRIG(ADC_InitStruct->ADC_ExternalTrigConv));
+ assert_param(IS_ADC_DATA_ALIGN(ADC_InitStruct->ADC_DataAlign));
+ assert_param(IS_ADC_REGULAR_LENGTH(ADC_InitStruct->ADC_NbrOfChannel));
+
+ /*---------------------------- ADCx CR1 Configuration -----------------*/
+ /* Get the ADCx CR1 value */
+ tmpreg1 = ADCx->CR1;
+ /* Clear DUALMOD and SCAN bits */
+ tmpreg1 &= CR1_CLEAR_Mask;
+ /* Configure ADCx: Dual mode and scan conversion mode */
+ /* Set DUALMOD bits according to ADC_Mode value */
+ /* Set SCAN bit according to ADC_ScanConvMode value */
+ tmpreg1 |= (uint32_t)(ADC_InitStruct->ADC_Mode | ((uint32_t)ADC_InitStruct->ADC_ScanConvMode << 8));
+ /* Write to ADCx CR1 */
+ ADCx->CR1 = tmpreg1;
+
+ /*---------------------------- ADCx CR2 Configuration -----------------*/
+ /* Get the ADCx CR2 value */
+ tmpreg1 = ADCx->CR2;
+ /* Clear CONT, ALIGN and EXTSEL bits */
+ tmpreg1 &= CR2_CLEAR_Mask;
+ /* Configure ADCx: external trigger event and continuous conversion mode */
+ /* Set ALIGN bit according to ADC_DataAlign value */
+ /* Set EXTSEL bits according to ADC_ExternalTrigConv value */
+ /* Set CONT bit according to ADC_ContinuousConvMode value */
+ tmpreg1 |= (uint32_t)(ADC_InitStruct->ADC_DataAlign | ADC_InitStruct->ADC_ExternalTrigConv |
+ ((uint32_t)ADC_InitStruct->ADC_ContinuousConvMode << 1));
+ /* Write to ADCx CR2 */
+ ADCx->CR2 = tmpreg1;
+
+ /*---------------------------- ADCx SQR1 Configuration -----------------*/
+ /* Get the ADCx SQR1 value */
+ tmpreg1 = ADCx->SQR1;
+ /* Clear L bits */
+ tmpreg1 &= SQR1_CLEAR_Mask;
+ /* Configure ADCx: regular channel sequence length */
+ /* Set L bits according to ADC_NbrOfChannel value */
+ tmpreg2 |= (uint8_t) (ADC_InitStruct->ADC_NbrOfChannel - (uint8_t)1);
+ tmpreg1 |= (uint32_t)tmpreg2 << 20;
+ /* Write to ADCx SQR1 */
+ ADCx->SQR1 = tmpreg1;
+}
+
+/**
+ * @brief Fills each ADC_InitStruct member with its default value.
+ * @param ADC_InitStruct : pointer to an ADC_InitTypeDef structure which will be initialized.
+ * @retval None
+ */
+void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct)
+{
+ /* Reset ADC init structure parameters values */
+ /* Initialize the ADC_Mode member */
+ ADC_InitStruct->ADC_Mode = ADC_Mode_Independent;
+ /* initialize the ADC_ScanConvMode member */
+ ADC_InitStruct->ADC_ScanConvMode = DISABLE;
+ /* Initialize the ADC_ContinuousConvMode member */
+ ADC_InitStruct->ADC_ContinuousConvMode = DISABLE;
+ /* Initialize the ADC_ExternalTrigConv member */
+ ADC_InitStruct->ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;
+ /* Initialize the ADC_DataAlign member */
+ ADC_InitStruct->ADC_DataAlign = ADC_DataAlign_Right;
+ /* Initialize the ADC_NbrOfChannel member */
+ ADC_InitStruct->ADC_NbrOfChannel = 1;
+}
+
+/**
+ * @brief Enables or disables the specified ADC peripheral.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param NewState: new state of the ADCx peripheral.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Set the ADON bit to wake up the ADC from power down mode */
+ ADCx->CR2 |= CR2_ADON_Set;
+ }
+ else
+ {
+ /* Disable the selected ADC peripheral */
+ ADCx->CR2 &= CR2_ADON_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified ADC DMA request.
+ * @param ADCx: where x can be 1 or 3 to select the ADC peripheral.
+ * Note: ADC2 hasn't a DMA capability.
+ * @param NewState: new state of the selected ADC DMA transfer.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_DMA_PERIPH(ADCx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected ADC DMA request */
+ ADCx->CR2 |= CR2_DMA_Set;
+ }
+ else
+ {
+ /* Disable the selected ADC DMA request */
+ ADCx->CR2 &= CR2_DMA_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified ADC interrupts.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_IT: specifies the ADC interrupt sources to be enabled or disabled.
+ * This parameter can be any combination of the following values:
+ * @arg ADC_IT_EOC: End of conversion interrupt mask
+ * @arg ADC_IT_AWD: Analog watchdog interrupt mask
+ * @arg ADC_IT_JEOC: End of injected conversion interrupt mask
+ * @param NewState: new state of the specified ADC interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_ITConfig(ADC_TypeDef* ADCx, uint16_t ADC_IT, FunctionalState NewState)
+{
+ uint8_t itmask = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ assert_param(IS_ADC_IT(ADC_IT));
+ /* Get the ADC IT index */
+ itmask = (uint8_t)ADC_IT;
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected ADC interrupts */
+ ADCx->CR1 |= itmask;
+ }
+ else
+ {
+ /* Disable the selected ADC interrupts */
+ ADCx->CR1 &= (~(uint32_t)itmask);
+ }
+}
+
+/**
+ * @brief Resets the selected ADC calibration registers.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @retval None
+ */
+void ADC_ResetCalibration(ADC_TypeDef* ADCx)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ /* Resets the selected ADC calibration registers */
+ ADCx->CR2 |= CR2_RSTCAL_Set;
+}
+
+/**
+ * @brief Gets the selected ADC reset calibration registers status.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @retval The new state of ADC reset calibration registers (SET or RESET).
+ */
+FlagStatus ADC_GetResetCalibrationStatus(ADC_TypeDef* ADCx)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ /* Check the status of RSTCAL bit */
+ if ((ADCx->CR2 & CR2_RSTCAL_Set) != (uint32_t)RESET)
+ {
+ /* RSTCAL bit is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* RSTCAL bit is reset */
+ bitstatus = RESET;
+ }
+ /* Return the RSTCAL bit status */
+ return bitstatus;
+}
+
+/**
+ * @brief Starts the selected ADC calibration process.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @retval None
+ */
+void ADC_StartCalibration(ADC_TypeDef* ADCx)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ /* Enable the selected ADC calibration process */
+ ADCx->CR2 |= CR2_CAL_Set;
+}
+
+/**
+ * @brief Gets the selected ADC calibration status.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @retval The new state of ADC calibration (SET or RESET).
+ */
+FlagStatus ADC_GetCalibrationStatus(ADC_TypeDef* ADCx)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ /* Check the status of CAL bit */
+ if ((ADCx->CR2 & CR2_CAL_Set) != (uint32_t)RESET)
+ {
+ /* CAL bit is set: calibration on going */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* CAL bit is reset: end of calibration */
+ bitstatus = RESET;
+ }
+ /* Return the CAL bit status */
+ return bitstatus;
+}
+
+/**
+ * @brief Enables or disables the selected ADC software start conversion .
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param NewState: new state of the selected ADC software start conversion.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_SoftwareStartConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected ADC conversion on external event and start the selected
+ ADC conversion */
+ ADCx->CR2 |= CR2_EXTTRIG_SWSTART_Set;
+ }
+ else
+ {
+ /* Disable the selected ADC conversion on external event and stop the selected
+ ADC conversion */
+ ADCx->CR2 &= CR2_EXTTRIG_SWSTART_Reset;
+ }
+}
+
+/**
+ * @brief Gets the selected ADC Software start conversion Status.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @retval The new state of ADC software start conversion (SET or RESET).
+ */
+FlagStatus ADC_GetSoftwareStartConvStatus(ADC_TypeDef* ADCx)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ /* Check the status of SWSTART bit */
+ if ((ADCx->CR2 & CR2_SWSTART_Set) != (uint32_t)RESET)
+ {
+ /* SWSTART bit is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* SWSTART bit is reset */
+ bitstatus = RESET;
+ }
+ /* Return the SWSTART bit status */
+ return bitstatus;
+}
+
+/**
+ * @brief Configures the discontinuous mode for the selected ADC regular
+ * group channel.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param Number: specifies the discontinuous mode regular channel
+ * count value. This number must be between 1 and 8.
+ * @retval None
+ */
+void ADC_DiscModeChannelCountConfig(ADC_TypeDef* ADCx, uint8_t Number)
+{
+ uint32_t tmpreg1 = 0;
+ uint32_t tmpreg2 = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_REGULAR_DISC_NUMBER(Number));
+ /* Get the old register value */
+ tmpreg1 = ADCx->CR1;
+ /* Clear the old discontinuous mode channel count */
+ tmpreg1 &= CR1_DISCNUM_Reset;
+ /* Set the discontinuous mode channel count */
+ tmpreg2 = Number - 1;
+ tmpreg1 |= tmpreg2 << 13;
+ /* Store the new register value */
+ ADCx->CR1 = tmpreg1;
+}
+
+/**
+ * @brief Enables or disables the discontinuous mode on regular group
+ * channel for the specified ADC
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param NewState: new state of the selected ADC discontinuous mode
+ * on regular group channel.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected ADC regular discontinuous mode */
+ ADCx->CR1 |= CR1_DISCEN_Set;
+ }
+ else
+ {
+ /* Disable the selected ADC regular discontinuous mode */
+ ADCx->CR1 &= CR1_DISCEN_Reset;
+ }
+}
+
+/**
+ * @brief Configures for the selected ADC regular channel its corresponding
+ * rank in the sequencer and its sample time.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_Channel: the ADC channel to configure.
+ * This parameter can be one of the following values:
+ * @arg ADC_Channel_0: ADC Channel0 selected
+ * @arg ADC_Channel_1: ADC Channel1 selected
+ * @arg ADC_Channel_2: ADC Channel2 selected
+ * @arg ADC_Channel_3: ADC Channel3 selected
+ * @arg ADC_Channel_4: ADC Channel4 selected
+ * @arg ADC_Channel_5: ADC Channel5 selected
+ * @arg ADC_Channel_6: ADC Channel6 selected
+ * @arg ADC_Channel_7: ADC Channel7 selected
+ * @arg ADC_Channel_8: ADC Channel8 selected
+ * @arg ADC_Channel_9: ADC Channel9 selected
+ * @arg ADC_Channel_10: ADC Channel10 selected
+ * @arg ADC_Channel_11: ADC Channel11 selected
+ * @arg ADC_Channel_12: ADC Channel12 selected
+ * @arg ADC_Channel_13: ADC Channel13 selected
+ * @arg ADC_Channel_14: ADC Channel14 selected
+ * @arg ADC_Channel_15: ADC Channel15 selected
+ * @arg ADC_Channel_16: ADC Channel16 selected
+ * @arg ADC_Channel_17: ADC Channel17 selected
+ * @param Rank: The rank in the regular group sequencer. This parameter must be between 1 to 16.
+ * @param ADC_SampleTime: The sample time value to be set for the selected channel.
+ * This parameter can be one of the following values:
+ * @arg ADC_SampleTime_1Cycles5: Sample time equal to 1.5 cycles
+ * @arg ADC_SampleTime_7Cycles5: Sample time equal to 7.5 cycles
+ * @arg ADC_SampleTime_13Cycles5: Sample time equal to 13.5 cycles
+ * @arg ADC_SampleTime_28Cycles5: Sample time equal to 28.5 cycles
+ * @arg ADC_SampleTime_41Cycles5: Sample time equal to 41.5 cycles
+ * @arg ADC_SampleTime_55Cycles5: Sample time equal to 55.5 cycles
+ * @arg ADC_SampleTime_71Cycles5: Sample time equal to 71.5 cycles
+ * @arg ADC_SampleTime_239Cycles5: Sample time equal to 239.5 cycles
+ * @retval None
+ */
+void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime)
+{
+ uint32_t tmpreg1 = 0, tmpreg2 = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_CHANNEL(ADC_Channel));
+ assert_param(IS_ADC_REGULAR_RANK(Rank));
+ assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));
+ /* if ADC_Channel_10 ... ADC_Channel_17 is selected */
+ if (ADC_Channel > ADC_Channel_9)
+ {
+ /* Get the old register value */
+ tmpreg1 = ADCx->SMPR1;
+ /* Calculate the mask to clear */
+ tmpreg2 = SMPR1_SMP_Set << (3 * (ADC_Channel - 10));
+ /* Clear the old channel sample time */
+ tmpreg1 &= ~tmpreg2;
+ /* Calculate the mask to set */
+ tmpreg2 = (uint32_t)ADC_SampleTime << (3 * (ADC_Channel - 10));
+ /* Set the new channel sample time */
+ tmpreg1 |= tmpreg2;
+ /* Store the new register value */
+ ADCx->SMPR1 = tmpreg1;
+ }
+ else /* ADC_Channel include in ADC_Channel_[0..9] */
+ {
+ /* Get the old register value */
+ tmpreg1 = ADCx->SMPR2;
+ /* Calculate the mask to clear */
+ tmpreg2 = SMPR2_SMP_Set << (3 * ADC_Channel);
+ /* Clear the old channel sample time */
+ tmpreg1 &= ~tmpreg2;
+ /* Calculate the mask to set */
+ tmpreg2 = (uint32_t)ADC_SampleTime << (3 * ADC_Channel);
+ /* Set the new channel sample time */
+ tmpreg1 |= tmpreg2;
+ /* Store the new register value */
+ ADCx->SMPR2 = tmpreg1;
+ }
+ /* For Rank 1 to 6 */
+ if (Rank < 7)
+ {
+ /* Get the old register value */
+ tmpreg1 = ADCx->SQR3;
+ /* Calculate the mask to clear */
+ tmpreg2 = SQR3_SQ_Set << (5 * (Rank - 1));
+ /* Clear the old SQx bits for the selected rank */
+ tmpreg1 &= ~tmpreg2;
+ /* Calculate the mask to set */
+ tmpreg2 = (uint32_t)ADC_Channel << (5 * (Rank - 1));
+ /* Set the SQx bits for the selected rank */
+ tmpreg1 |= tmpreg2;
+ /* Store the new register value */
+ ADCx->SQR3 = tmpreg1;
+ }
+ /* For Rank 7 to 12 */
+ else if (Rank < 13)
+ {
+ /* Get the old register value */
+ tmpreg1 = ADCx->SQR2;
+ /* Calculate the mask to clear */
+ tmpreg2 = SQR2_SQ_Set << (5 * (Rank - 7));
+ /* Clear the old SQx bits for the selected rank */
+ tmpreg1 &= ~tmpreg2;
+ /* Calculate the mask to set */
+ tmpreg2 = (uint32_t)ADC_Channel << (5 * (Rank - 7));
+ /* Set the SQx bits for the selected rank */
+ tmpreg1 |= tmpreg2;
+ /* Store the new register value */
+ ADCx->SQR2 = tmpreg1;
+ }
+ /* For Rank 13 to 16 */
+ else
+ {
+ /* Get the old register value */
+ tmpreg1 = ADCx->SQR1;
+ /* Calculate the mask to clear */
+ tmpreg2 = SQR1_SQ_Set << (5 * (Rank - 13));
+ /* Clear the old SQx bits for the selected rank */
+ tmpreg1 &= ~tmpreg2;
+ /* Calculate the mask to set */
+ tmpreg2 = (uint32_t)ADC_Channel << (5 * (Rank - 13));
+ /* Set the SQx bits for the selected rank */
+ tmpreg1 |= tmpreg2;
+ /* Store the new register value */
+ ADCx->SQR1 = tmpreg1;
+ }
+}
+
+/**
+ * @brief Enables or disables the ADCx conversion through external trigger.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param NewState: new state of the selected ADC external trigger start of conversion.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_ExternalTrigConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected ADC conversion on external event */
+ ADCx->CR2 |= CR2_EXTTRIG_Set;
+ }
+ else
+ {
+ /* Disable the selected ADC conversion on external event */
+ ADCx->CR2 &= CR2_EXTTRIG_Reset;
+ }
+}
+
+/**
+ * @brief Returns the last ADCx conversion result data for regular channel.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @retval The Data conversion value.
+ */
+uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ /* Return the selected ADC conversion value */
+ return (uint16_t) ADCx->DR;
+}
+
+/**
+ * @brief Returns the last ADC1 and ADC2 conversion result data in dual mode.
+ * @retval The Data conversion value.
+ */
+uint32_t ADC_GetDualModeConversionValue(void)
+{
+ /* Return the dual mode conversion value */
+ return (*(__IO uint32_t *) DR_ADDRESS);
+}
+
+/**
+ * @brief Enables or disables the selected ADC automatic injected group
+ * conversion after regular one.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param NewState: new state of the selected ADC auto injected conversion
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_AutoInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected ADC automatic injected group conversion */
+ ADCx->CR1 |= CR1_JAUTO_Set;
+ }
+ else
+ {
+ /* Disable the selected ADC automatic injected group conversion */
+ ADCx->CR1 &= CR1_JAUTO_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the discontinuous mode for injected group
+ * channel for the specified ADC
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param NewState: new state of the selected ADC discontinuous mode
+ * on injected group channel.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_InjectedDiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected ADC injected discontinuous mode */
+ ADCx->CR1 |= CR1_JDISCEN_Set;
+ }
+ else
+ {
+ /* Disable the selected ADC injected discontinuous mode */
+ ADCx->CR1 &= CR1_JDISCEN_Reset;
+ }
+}
+
+/**
+ * @brief Configures the ADCx external trigger for injected channels conversion.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_ExternalTrigInjecConv: specifies the ADC trigger to start injected conversion.
+ * This parameter can be one of the following values:
+ * @arg ADC_ExternalTrigInjecConv_T1_TRGO: Timer1 TRGO event selected (for ADC1, ADC2 and ADC3)
+ * @arg ADC_ExternalTrigInjecConv_T1_CC4: Timer1 capture compare4 selected (for ADC1, ADC2 and ADC3)
+ * @arg ADC_ExternalTrigInjecConv_T2_TRGO: Timer2 TRGO event selected (for ADC1 and ADC2)
+ * @arg ADC_ExternalTrigInjecConv_T2_CC1: Timer2 capture compare1 selected (for ADC1 and ADC2)
+ * @arg ADC_ExternalTrigInjecConv_T3_CC4: Timer3 capture compare4 selected (for ADC1 and ADC2)
+ * @arg ADC_ExternalTrigInjecConv_T4_TRGO: Timer4 TRGO event selected (for ADC1 and ADC2)
+ * @arg ADC_ExternalTrigInjecConv_Ext_IT15_TIM8_CC4: External interrupt line 15 or Timer8
+ * capture compare4 event selected (for ADC1 and ADC2)
+ * @arg ADC_ExternalTrigInjecConv_T4_CC3: Timer4 capture compare3 selected (for ADC3 only)
+ * @arg ADC_ExternalTrigInjecConv_T8_CC2: Timer8 capture compare2 selected (for ADC3 only)
+ * @arg ADC_ExternalTrigInjecConv_T8_CC4: Timer8 capture compare4 selected (for ADC3 only)
+ * @arg ADC_ExternalTrigInjecConv_T5_TRGO: Timer5 TRGO event selected (for ADC3 only)
+ * @arg ADC_ExternalTrigInjecConv_T5_CC4: Timer5 capture compare4 selected (for ADC3 only)
+ * @arg ADC_ExternalTrigInjecConv_None: Injected conversion started by software and not
+ * by external trigger (for ADC1, ADC2 and ADC3)
+ * @retval None
+ */
+void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef* ADCx, uint32_t ADC_ExternalTrigInjecConv)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_EXT_INJEC_TRIG(ADC_ExternalTrigInjecConv));
+ /* Get the old register value */
+ tmpreg = ADCx->CR2;
+ /* Clear the old external event selection for injected group */
+ tmpreg &= CR2_JEXTSEL_Reset;
+ /* Set the external event selection for injected group */
+ tmpreg |= ADC_ExternalTrigInjecConv;
+ /* Store the new register value */
+ ADCx->CR2 = tmpreg;
+}
+
+/**
+ * @brief Enables or disables the ADCx injected channels conversion through
+ * external trigger
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param NewState: new state of the selected ADC external trigger start of
+ * injected conversion.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_ExternalTrigInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected ADC external event selection for injected group */
+ ADCx->CR2 |= CR2_JEXTTRIG_Set;
+ }
+ else
+ {
+ /* Disable the selected ADC external event selection for injected group */
+ ADCx->CR2 &= CR2_JEXTTRIG_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the selected ADC start of the injected
+ * channels conversion.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param NewState: new state of the selected ADC software start injected conversion.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_SoftwareStartInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected ADC conversion for injected group on external event and start the selected
+ ADC injected conversion */
+ ADCx->CR2 |= CR2_JEXTTRIG_JSWSTART_Set;
+ }
+ else
+ {
+ /* Disable the selected ADC conversion on external event for injected group and stop the selected
+ ADC injected conversion */
+ ADCx->CR2 &= CR2_JEXTTRIG_JSWSTART_Reset;
+ }
+}
+
+/**
+ * @brief Gets the selected ADC Software start injected conversion Status.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @retval The new state of ADC software start injected conversion (SET or RESET).
+ */
+FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus(ADC_TypeDef* ADCx)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ /* Check the status of JSWSTART bit */
+ if ((ADCx->CR2 & CR2_JSWSTART_Set) != (uint32_t)RESET)
+ {
+ /* JSWSTART bit is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* JSWSTART bit is reset */
+ bitstatus = RESET;
+ }
+ /* Return the JSWSTART bit status */
+ return bitstatus;
+}
+
+/**
+ * @brief Configures for the selected ADC injected channel its corresponding
+ * rank in the sequencer and its sample time.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_Channel: the ADC channel to configure.
+ * This parameter can be one of the following values:
+ * @arg ADC_Channel_0: ADC Channel0 selected
+ * @arg ADC_Channel_1: ADC Channel1 selected
+ * @arg ADC_Channel_2: ADC Channel2 selected
+ * @arg ADC_Channel_3: ADC Channel3 selected
+ * @arg ADC_Channel_4: ADC Channel4 selected
+ * @arg ADC_Channel_5: ADC Channel5 selected
+ * @arg ADC_Channel_6: ADC Channel6 selected
+ * @arg ADC_Channel_7: ADC Channel7 selected
+ * @arg ADC_Channel_8: ADC Channel8 selected
+ * @arg ADC_Channel_9: ADC Channel9 selected
+ * @arg ADC_Channel_10: ADC Channel10 selected
+ * @arg ADC_Channel_11: ADC Channel11 selected
+ * @arg ADC_Channel_12: ADC Channel12 selected
+ * @arg ADC_Channel_13: ADC Channel13 selected
+ * @arg ADC_Channel_14: ADC Channel14 selected
+ * @arg ADC_Channel_15: ADC Channel15 selected
+ * @arg ADC_Channel_16: ADC Channel16 selected
+ * @arg ADC_Channel_17: ADC Channel17 selected
+ * @param Rank: The rank in the injected group sequencer. This parameter must be between 1 and 4.
+ * @param ADC_SampleTime: The sample time value to be set for the selected channel.
+ * This parameter can be one of the following values:
+ * @arg ADC_SampleTime_1Cycles5: Sample time equal to 1.5 cycles
+ * @arg ADC_SampleTime_7Cycles5: Sample time equal to 7.5 cycles
+ * @arg ADC_SampleTime_13Cycles5: Sample time equal to 13.5 cycles
+ * @arg ADC_SampleTime_28Cycles5: Sample time equal to 28.5 cycles
+ * @arg ADC_SampleTime_41Cycles5: Sample time equal to 41.5 cycles
+ * @arg ADC_SampleTime_55Cycles5: Sample time equal to 55.5 cycles
+ * @arg ADC_SampleTime_71Cycles5: Sample time equal to 71.5 cycles
+ * @arg ADC_SampleTime_239Cycles5: Sample time equal to 239.5 cycles
+ * @retval None
+ */
+void ADC_InjectedChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime)
+{
+ uint32_t tmpreg1 = 0, tmpreg2 = 0, tmpreg3 = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_CHANNEL(ADC_Channel));
+ assert_param(IS_ADC_INJECTED_RANK(Rank));
+ assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));
+ /* if ADC_Channel_10 ... ADC_Channel_17 is selected */
+ if (ADC_Channel > ADC_Channel_9)
+ {
+ /* Get the old register value */
+ tmpreg1 = ADCx->SMPR1;
+ /* Calculate the mask to clear */
+ tmpreg2 = SMPR1_SMP_Set << (3*(ADC_Channel - 10));
+ /* Clear the old channel sample time */
+ tmpreg1 &= ~tmpreg2;
+ /* Calculate the mask to set */
+ tmpreg2 = (uint32_t)ADC_SampleTime << (3*(ADC_Channel - 10));
+ /* Set the new channel sample time */
+ tmpreg1 |= tmpreg2;
+ /* Store the new register value */
+ ADCx->SMPR1 = tmpreg1;
+ }
+ else /* ADC_Channel include in ADC_Channel_[0..9] */
+ {
+ /* Get the old register value */
+ tmpreg1 = ADCx->SMPR2;
+ /* Calculate the mask to clear */
+ tmpreg2 = SMPR2_SMP_Set << (3 * ADC_Channel);
+ /* Clear the old channel sample time */
+ tmpreg1 &= ~tmpreg2;
+ /* Calculate the mask to set */
+ tmpreg2 = (uint32_t)ADC_SampleTime << (3 * ADC_Channel);
+ /* Set the new channel sample time */
+ tmpreg1 |= tmpreg2;
+ /* Store the new register value */
+ ADCx->SMPR2 = tmpreg1;
+ }
+ /* Rank configuration */
+ /* Get the old register value */
+ tmpreg1 = ADCx->JSQR;
+ /* Get JL value: Number = JL+1 */
+ tmpreg3 = (tmpreg1 & JSQR_JL_Set)>> 20;
+ /* Calculate the mask to clear: ((Rank-1)+(4-JL-1)) */
+ tmpreg2 = JSQR_JSQ_Set << (5 * (uint8_t)((Rank + 3) - (tmpreg3 + 1)));
+ /* Clear the old JSQx bits for the selected rank */
+ tmpreg1 &= ~tmpreg2;
+ /* Calculate the mask to set: ((Rank-1)+(4-JL-1)) */
+ tmpreg2 = (uint32_t)ADC_Channel << (5 * (uint8_t)((Rank + 3) - (tmpreg3 + 1)));
+ /* Set the JSQx bits for the selected rank */
+ tmpreg1 |= tmpreg2;
+ /* Store the new register value */
+ ADCx->JSQR = tmpreg1;
+}
+
+/**
+ * @brief Configures the sequencer length for injected channels
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param Length: The sequencer length.
+ * This parameter must be a number between 1 to 4.
+ * @retval None
+ */
+void ADC_InjectedSequencerLengthConfig(ADC_TypeDef* ADCx, uint8_t Length)
+{
+ uint32_t tmpreg1 = 0;
+ uint32_t tmpreg2 = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_INJECTED_LENGTH(Length));
+
+ /* Get the old register value */
+ tmpreg1 = ADCx->JSQR;
+ /* Clear the old injected sequnence lenght JL bits */
+ tmpreg1 &= JSQR_JL_Reset;
+ /* Set the injected sequnence lenght JL bits */
+ tmpreg2 = Length - 1;
+ tmpreg1 |= tmpreg2 << 20;
+ /* Store the new register value */
+ ADCx->JSQR = tmpreg1;
+}
+
+/**
+ * @brief Set the injected channels conversion value offset
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_InjectedChannel: the ADC injected channel to set its offset.
+ * This parameter can be one of the following values:
+ * @arg ADC_InjectedChannel_1: Injected Channel1 selected
+ * @arg ADC_InjectedChannel_2: Injected Channel2 selected
+ * @arg ADC_InjectedChannel_3: Injected Channel3 selected
+ * @arg ADC_InjectedChannel_4: Injected Channel4 selected
+ * @param Offset: the offset value for the selected ADC injected channel
+ * This parameter must be a 12bit value.
+ * @retval None
+ */
+void ADC_SetInjectedOffset(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel, uint16_t Offset)
+{
+ __IO uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel));
+ assert_param(IS_ADC_OFFSET(Offset));
+
+ tmp = (uint32_t)ADCx;
+ tmp += ADC_InjectedChannel;
+
+ /* Set the selected injected channel data offset */
+ *(__IO uint32_t *) tmp = (uint32_t)Offset;
+}
+
+/**
+ * @brief Returns the ADC injected channel conversion result
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_InjectedChannel: the converted ADC injected channel.
+ * This parameter can be one of the following values:
+ * @arg ADC_InjectedChannel_1: Injected Channel1 selected
+ * @arg ADC_InjectedChannel_2: Injected Channel2 selected
+ * @arg ADC_InjectedChannel_3: Injected Channel3 selected
+ * @arg ADC_InjectedChannel_4: Injected Channel4 selected
+ * @retval The Data conversion value.
+ */
+uint16_t ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel)
+{
+ __IO uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel));
+
+ tmp = (uint32_t)ADCx;
+ tmp += ADC_InjectedChannel + JDR_Offset;
+
+ /* Returns the selected injected channel conversion data value */
+ return (uint16_t) (*(__IO uint32_t*) tmp);
+}
+
+/**
+ * @brief Enables or disables the analog watchdog on single/all regular
+ * or injected channels
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_AnalogWatchdog: the ADC analog watchdog configuration.
+ * This parameter can be one of the following values:
+ * @arg ADC_AnalogWatchdog_SingleRegEnable: Analog watchdog on a single regular channel
+ * @arg ADC_AnalogWatchdog_SingleInjecEnable: Analog watchdog on a single injected channel
+ * @arg ADC_AnalogWatchdog_SingleRegOrInjecEnable: Analog watchdog on a single regular or injected channel
+ * @arg ADC_AnalogWatchdog_AllRegEnable: Analog watchdog on all regular channel
+ * @arg ADC_AnalogWatchdog_AllInjecEnable: Analog watchdog on all injected channel
+ * @arg ADC_AnalogWatchdog_AllRegAllInjecEnable: Analog watchdog on all regular and injected channels
+ * @arg ADC_AnalogWatchdog_None: No channel guarded by the analog watchdog
+ * @retval None
+ */
+void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_ANALOG_WATCHDOG(ADC_AnalogWatchdog));
+ /* Get the old register value */
+ tmpreg = ADCx->CR1;
+ /* Clear AWDEN, AWDENJ and AWDSGL bits */
+ tmpreg &= CR1_AWDMode_Reset;
+ /* Set the analog watchdog enable mode */
+ tmpreg |= ADC_AnalogWatchdog;
+ /* Store the new register value */
+ ADCx->CR1 = tmpreg;
+}
+
+/**
+ * @brief Configures the high and low thresholds of the analog watchdog.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param HighThreshold: the ADC analog watchdog High threshold value.
+ * This parameter must be a 12bit value.
+ * @param LowThreshold: the ADC analog watchdog Low threshold value.
+ * This parameter must be a 12bit value.
+ * @retval None
+ */
+void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold,
+ uint16_t LowThreshold)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_THRESHOLD(HighThreshold));
+ assert_param(IS_ADC_THRESHOLD(LowThreshold));
+ /* Set the ADCx high threshold */
+ ADCx->HTR = HighThreshold;
+ /* Set the ADCx low threshold */
+ ADCx->LTR = LowThreshold;
+}
+
+/**
+ * @brief Configures the analog watchdog guarded single channel
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_Channel: the ADC channel to configure for the analog watchdog.
+ * This parameter can be one of the following values:
+ * @arg ADC_Channel_0: ADC Channel0 selected
+ * @arg ADC_Channel_1: ADC Channel1 selected
+ * @arg ADC_Channel_2: ADC Channel2 selected
+ * @arg ADC_Channel_3: ADC Channel3 selected
+ * @arg ADC_Channel_4: ADC Channel4 selected
+ * @arg ADC_Channel_5: ADC Channel5 selected
+ * @arg ADC_Channel_6: ADC Channel6 selected
+ * @arg ADC_Channel_7: ADC Channel7 selected
+ * @arg ADC_Channel_8: ADC Channel8 selected
+ * @arg ADC_Channel_9: ADC Channel9 selected
+ * @arg ADC_Channel_10: ADC Channel10 selected
+ * @arg ADC_Channel_11: ADC Channel11 selected
+ * @arg ADC_Channel_12: ADC Channel12 selected
+ * @arg ADC_Channel_13: ADC Channel13 selected
+ * @arg ADC_Channel_14: ADC Channel14 selected
+ * @arg ADC_Channel_15: ADC Channel15 selected
+ * @arg ADC_Channel_16: ADC Channel16 selected
+ * @arg ADC_Channel_17: ADC Channel17 selected
+ * @retval None
+ */
+void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_CHANNEL(ADC_Channel));
+ /* Get the old register value */
+ tmpreg = ADCx->CR1;
+ /* Clear the Analog watchdog channel select bits */
+ tmpreg &= CR1_AWDCH_Reset;
+ /* Set the Analog watchdog channel */
+ tmpreg |= ADC_Channel;
+ /* Store the new register value */
+ ADCx->CR1 = tmpreg;
+}
+
+/**
+ * @brief Enables or disables the temperature sensor and Vrefint channel.
+ * @param NewState: new state of the temperature sensor.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void ADC_TempSensorVrefintCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the temperature sensor and Vrefint channel*/
+ ADC1->CR2 |= CR2_TSVREFE_Set;
+ }
+ else
+ {
+ /* Disable the temperature sensor and Vrefint channel*/
+ ADC1->CR2 &= CR2_TSVREFE_Reset;
+ }
+}
+
+/**
+ * @brief Checks whether the specified ADC flag is set or not.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_FLAG: specifies the flag to check.
+ * This parameter can be one of the following values:
+ * @arg ADC_FLAG_AWD: Analog watchdog flag
+ * @arg ADC_FLAG_EOC: End of conversion flag
+ * @arg ADC_FLAG_JEOC: End of injected group conversion flag
+ * @arg ADC_FLAG_JSTRT: Start of injected group conversion flag
+ * @arg ADC_FLAG_STRT: Start of regular group conversion flag
+ * @retval The new state of ADC_FLAG (SET or RESET).
+ */
+FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint8_t ADC_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_GET_FLAG(ADC_FLAG));
+ /* Check the status of the specified ADC flag */
+ if ((ADCx->SR & ADC_FLAG) != (uint8_t)RESET)
+ {
+ /* ADC_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* ADC_FLAG is reset */
+ bitstatus = RESET;
+ }
+ /* Return the ADC_FLAG status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the ADCx's pending flags.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_FLAG: specifies the flag to clear.
+ * This parameter can be any combination of the following values:
+ * @arg ADC_FLAG_AWD: Analog watchdog flag
+ * @arg ADC_FLAG_EOC: End of conversion flag
+ * @arg ADC_FLAG_JEOC: End of injected group conversion flag
+ * @arg ADC_FLAG_JSTRT: Start of injected group conversion flag
+ * @arg ADC_FLAG_STRT: Start of regular group conversion flag
+ * @retval None
+ */
+void ADC_ClearFlag(ADC_TypeDef* ADCx, uint8_t ADC_FLAG)
+{
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_CLEAR_FLAG(ADC_FLAG));
+ /* Clear the selected ADC flags */
+ ADCx->SR = ~(uint32_t)ADC_FLAG;
+}
+
+/**
+ * @brief Checks whether the specified ADC interrupt has occurred or not.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_IT: specifies the ADC interrupt source to check.
+ * This parameter can be one of the following values:
+ * @arg ADC_IT_EOC: End of conversion interrupt mask
+ * @arg ADC_IT_AWD: Analog watchdog interrupt mask
+ * @arg ADC_IT_JEOC: End of injected conversion interrupt mask
+ * @retval The new state of ADC_IT (SET or RESET).
+ */
+ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint16_t ADC_IT)
+{
+ ITStatus bitstatus = RESET;
+ uint32_t itmask = 0, enablestatus = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_GET_IT(ADC_IT));
+ /* Get the ADC IT index */
+ itmask = ADC_IT >> 8;
+ /* Get the ADC_IT enable bit status */
+ enablestatus = (ADCx->CR1 & (uint8_t)ADC_IT) ;
+ /* Check the status of the specified ADC interrupt */
+ if (((ADCx->SR & itmask) != (uint32_t)RESET) && enablestatus)
+ {
+ /* ADC_IT is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* ADC_IT is reset */
+ bitstatus = RESET;
+ }
+ /* Return the ADC_IT status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the ADCx's interrupt pending bits.
+ * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
+ * @param ADC_IT: specifies the ADC interrupt pending bit to clear.
+ * This parameter can be any combination of the following values:
+ * @arg ADC_IT_EOC: End of conversion interrupt mask
+ * @arg ADC_IT_AWD: Analog watchdog interrupt mask
+ * @arg ADC_IT_JEOC: End of injected conversion interrupt mask
+ * @retval None
+ */
+void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint16_t ADC_IT)
+{
+ uint8_t itmask = 0;
+ /* Check the parameters */
+ assert_param(IS_ADC_ALL_PERIPH(ADCx));
+ assert_param(IS_ADC_IT(ADC_IT));
+ /* Get the ADC IT index */
+ itmask = (uint8_t)(ADC_IT >> 8);
+ /* Clear the selected ADC interrupt pending bits */
+ ADCx->SR = ~(uint32_t)itmask;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_bkp.c b/st_fw_lib/src/stm32f10x_bkp.c
new file mode 100644
index 0000000..997eecc
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_bkp.c
@@ -0,0 +1,308 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_bkp.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the BKP firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_bkp.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup BKP
+ * @brief BKP driver modules
+ * @{
+ */
+
+/** @defgroup BKP_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup BKP_Private_Defines
+ * @{
+ */
+
+/* ------------ BKP registers bit address in the alias region --------------- */
+#define BKP_OFFSET (BKP_BASE - PERIPH_BASE)
+
+/* --- CR Register ----*/
+
+/* Alias word address of TPAL bit */
+#define CR_OFFSET (BKP_OFFSET + 0x30)
+#define TPAL_BitNumber 0x01
+#define CR_TPAL_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (TPAL_BitNumber * 4))
+
+/* Alias word address of TPE bit */
+#define TPE_BitNumber 0x00
+#define CR_TPE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (TPE_BitNumber * 4))
+
+/* --- CSR Register ---*/
+
+/* Alias word address of TPIE bit */
+#define CSR_OFFSET (BKP_OFFSET + 0x34)
+#define TPIE_BitNumber 0x02
+#define CSR_TPIE_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TPIE_BitNumber * 4))
+
+/* Alias word address of TIF bit */
+#define TIF_BitNumber 0x09
+#define CSR_TIF_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TIF_BitNumber * 4))
+
+/* Alias word address of TEF bit */
+#define TEF_BitNumber 0x08
+#define CSR_TEF_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TEF_BitNumber * 4))
+
+/* ---------------------- BKP registers bit mask ------------------------ */
+
+/* RTCCR register bit mask */
+#define RTCCR_CAL_MASK ((uint16_t)0xFF80)
+#define RTCCR_MASK ((uint16_t)0xFC7F)
+
+/**
+ * @}
+ */
+
+
+/** @defgroup BKP_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup BKP_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup BKP_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup BKP_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the BKP peripheral registers to their default reset values.
+ * @param None
+ * @retval None
+ */
+void BKP_DeInit(void)
+{
+ RCC_BackupResetCmd(ENABLE);
+ RCC_BackupResetCmd(DISABLE);
+}
+
+/**
+ * @brief Configures the Tamper Pin active level.
+ * @param BKP_TamperPinLevel: specifies the Tamper Pin active level.
+ * This parameter can be one of the following values:
+ * @arg BKP_TamperPinLevel_High: Tamper pin active on high level
+ * @arg BKP_TamperPinLevel_Low: Tamper pin active on low level
+ * @retval None
+ */
+void BKP_TamperPinLevelConfig(uint16_t BKP_TamperPinLevel)
+{
+ /* Check the parameters */
+ assert_param(IS_BKP_TAMPER_PIN_LEVEL(BKP_TamperPinLevel));
+ *(__IO uint32_t *) CR_TPAL_BB = BKP_TamperPinLevel;
+}
+
+/**
+ * @brief Enables or disables the Tamper Pin activation.
+ * @param NewState: new state of the Tamper Pin activation.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void BKP_TamperPinCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) CR_TPE_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Enables or disables the Tamper Pin Interrupt.
+ * @param NewState: new state of the Tamper Pin Interrupt.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void BKP_ITConfig(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) CSR_TPIE_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Select the RTC output source to output on the Tamper pin.
+ * @param BKP_RTCOutputSource: specifies the RTC output source.
+ * This parameter can be one of the following values:
+ * @arg BKP_RTCOutputSource_None: no RTC output on the Tamper pin.
+ * @arg BKP_RTCOutputSource_CalibClock: output the RTC clock with frequency
+ * divided by 64 on the Tamper pin.
+ * @arg BKP_RTCOutputSource_Alarm: output the RTC Alarm pulse signal on
+ * the Tamper pin.
+ * @arg BKP_RTCOutputSource_Second: output the RTC Second pulse signal on
+ * the Tamper pin.
+ * @retval None
+ */
+void BKP_RTCOutputConfig(uint16_t BKP_RTCOutputSource)
+{
+ uint16_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_BKP_RTC_OUTPUT_SOURCE(BKP_RTCOutputSource));
+ tmpreg = BKP->RTCCR;
+ /* Clear CCO, ASOE and ASOS bits */
+ tmpreg &= RTCCR_MASK;
+
+ /* Set CCO, ASOE and ASOS bits according to BKP_RTCOutputSource value */
+ tmpreg |= BKP_RTCOutputSource;
+ /* Store the new value */
+ BKP->RTCCR = tmpreg;
+}
+
+/**
+ * @brief Sets RTC Clock Calibration value.
+ * @param CalibrationValue: specifies the RTC Clock Calibration value.
+ * This parameter must be a number between 0 and 0x7F.
+ * @retval None
+ */
+void BKP_SetRTCCalibrationValue(uint8_t CalibrationValue)
+{
+ uint16_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_BKP_CALIBRATION_VALUE(CalibrationValue));
+ tmpreg = BKP->RTCCR;
+ /* Clear CAL[6:0] bits */
+ tmpreg &= RTCCR_CAL_MASK;
+ /* Set CAL[6:0] bits according to CalibrationValue value */
+ tmpreg |= CalibrationValue;
+ /* Store the new value */
+ BKP->RTCCR = tmpreg;
+}
+
+/**
+ * @brief Writes user data to the specified Data Backup Register.
+ * @param BKP_DR: specifies the Data Backup Register.
+ * This parameter can be BKP_DRx where x:[1, 42]
+ * @param Data: data to write
+ * @retval None
+ */
+void BKP_WriteBackupRegister(uint16_t BKP_DR, uint16_t Data)
+{
+ __IO uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_BKP_DR(BKP_DR));
+
+ tmp = (uint32_t)BKP_BASE;
+ tmp += BKP_DR;
+
+ *(__IO uint32_t *) tmp = Data;
+}
+
+/**
+ * @brief Reads data from the specified Data Backup Register.
+ * @param BKP_DR: specifies the Data Backup Register.
+ * This parameter can be BKP_DRx where x:[1, 42]
+ * @retval The content of the specified Data Backup Register
+ */
+uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR)
+{
+ __IO uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_BKP_DR(BKP_DR));
+
+ tmp = (uint32_t)BKP_BASE;
+ tmp += BKP_DR;
+
+ return (*(__IO uint16_t *) tmp);
+}
+
+/**
+ * @brief Checks whether the Tamper Pin Event flag is set or not.
+ * @param None
+ * @retval The new state of the Tamper Pin Event flag (SET or RESET).
+ */
+FlagStatus BKP_GetFlagStatus(void)
+{
+ return (FlagStatus)(*(__IO uint32_t *) CSR_TEF_BB);
+}
+
+/**
+ * @brief Clears Tamper Pin Event pending flag.
+ * @param None
+ * @retval None
+ */
+void BKP_ClearFlag(void)
+{
+ /* Set CTE bit to clear Tamper Pin Event flag */
+ BKP->CSR |= BKP_CSR_CTE;
+}
+
+/**
+ * @brief Checks whether the Tamper Pin Interrupt has occurred or not.
+ * @param None
+ * @retval The new state of the Tamper Pin Interrupt (SET or RESET).
+ */
+ITStatus BKP_GetITStatus(void)
+{
+ return (ITStatus)(*(__IO uint32_t *) CSR_TIF_BB);
+}
+
+/**
+ * @brief Clears Tamper Pin Interrupt pending bit.
+ * @param None
+ * @retval None
+ */
+void BKP_ClearITPendingBit(void)
+{
+ /* Set CTI bit to clear Tamper Pin Interrupt pending bit */
+ BKP->CSR |= BKP_CSR_CTI;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_can.c b/st_fw_lib/src/stm32f10x_can.c
new file mode 100644
index 0000000..ec8e049
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_can.c
@@ -0,0 +1,1415 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_can.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the CAN firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_can.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup CAN
+ * @brief CAN driver modules
+ * @{
+ */
+
+/** @defgroup CAN_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Private_Defines
+ * @{
+ */
+
+/* CAN Master Control Register bits */
+
+#define MCR_DBF ((uint32_t)0x00010000) /* software master reset */
+
+/* CAN Mailbox Transmit Request */
+#define TMIDxR_TXRQ ((uint32_t)0x00000001) /* Transmit mailbox request */
+
+/* CAN Filter Master Register bits */
+#define FMR_FINIT ((uint32_t)0x00000001) /* Filter init mode */
+
+/* Time out for INAK bit */
+#define INAK_TIMEOUT ((uint32_t)0x0000FFFF)
+/* Time out for SLAK bit */
+#define SLAK_TIMEOUT ((uint32_t)0x0000FFFF)
+
+
+
+/* Flags in TSR register */
+#define CAN_FLAGS_TSR ((uint32_t)0x08000000)
+/* Flags in RF1R register */
+#define CAN_FLAGS_RF1R ((uint32_t)0x04000000)
+/* Flags in RF0R register */
+#define CAN_FLAGS_RF0R ((uint32_t)0x02000000)
+/* Flags in MSR register */
+#define CAN_FLAGS_MSR ((uint32_t)0x01000000)
+/* Flags in ESR register */
+#define CAN_FLAGS_ESR ((uint32_t)0x00F00000)
+
+/* Mailboxes definition */
+#define CAN_TXMAILBOX_0 ((uint8_t)0x00)
+#define CAN_TXMAILBOX_1 ((uint8_t)0x01)
+#define CAN_TXMAILBOX_2 ((uint8_t)0x02)
+
+
+
+#define CAN_MODE_MASK ((uint32_t) 0x00000003)
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Private_FunctionPrototypes
+ * @{
+ */
+
+static ITStatus CheckITStatus(uint32_t CAN_Reg, uint32_t It_Bit);
+
+/**
+ * @}
+ */
+
+/** @defgroup CAN_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the CAN peripheral registers to their default reset values.
+ * @param CANx: where x can be 1 or 2 to select the CAN peripheral.
+ * @retval None.
+ */
+void CAN_DeInit(CAN_TypeDef* CANx)
+{
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+
+ if (CANx == CAN1)
+ {
+ /* Enable CAN1 reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_CAN1, ENABLE);
+ /* Release CAN1 from reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_CAN1, DISABLE);
+ }
+ else
+ {
+ /* Enable CAN2 reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_CAN2, ENABLE);
+ /* Release CAN2 from reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_CAN2, DISABLE);
+ }
+}
+
+/**
+ * @brief Initializes the CAN peripheral according to the specified
+ * parameters in the CAN_InitStruct.
+ * @param CANx: where x can be 1 or 2 to to select the CAN
+ * peripheral.
+ * @param CAN_InitStruct: pointer to a CAN_InitTypeDef structure that
+ * contains the configuration information for the
+ * CAN peripheral.
+ * @retval Constant indicates initialization succeed which will be
+ * CAN_InitStatus_Failed or CAN_InitStatus_Success.
+ */
+uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct)
+{
+ uint8_t InitStatus = CAN_InitStatus_Failed;
+ uint32_t wait_ack = 0x00000000;
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_TTCM));
+ assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_ABOM));
+ assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_AWUM));
+ assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_NART));
+ assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_RFLM));
+ assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_TXFP));
+ assert_param(IS_CAN_MODE(CAN_InitStruct->CAN_Mode));
+ assert_param(IS_CAN_SJW(CAN_InitStruct->CAN_SJW));
+ assert_param(IS_CAN_BS1(CAN_InitStruct->CAN_BS1));
+ assert_param(IS_CAN_BS2(CAN_InitStruct->CAN_BS2));
+ assert_param(IS_CAN_PRESCALER(CAN_InitStruct->CAN_Prescaler));
+
+ /* Exit from sleep mode */
+ CANx->MCR &= (~(uint32_t)CAN_MCR_SLEEP);
+
+ /* Request initialisation */
+ CANx->MCR |= CAN_MCR_INRQ ;
+
+ /* Wait the acknowledge */
+ while (((CANx->MSR & CAN_MSR_INAK) != CAN_MSR_INAK) && (wait_ack != INAK_TIMEOUT))
+ {
+ wait_ack++;
+ }
+
+ /* Check acknowledge */
+ if ((CANx->MSR & CAN_MSR_INAK) != CAN_MSR_INAK)
+ {
+ InitStatus = CAN_InitStatus_Failed;
+ }
+ else
+ {
+ /* Set the time triggered communication mode */
+ if (CAN_InitStruct->CAN_TTCM == ENABLE)
+ {
+ CANx->MCR |= CAN_MCR_TTCM;
+ }
+ else
+ {
+ CANx->MCR &= ~(uint32_t)CAN_MCR_TTCM;
+ }
+
+ /* Set the automatic bus-off management */
+ if (CAN_InitStruct->CAN_ABOM == ENABLE)
+ {
+ CANx->MCR |= CAN_MCR_ABOM;
+ }
+ else
+ {
+ CANx->MCR &= ~(uint32_t)CAN_MCR_ABOM;
+ }
+
+ /* Set the automatic wake-up mode */
+ if (CAN_InitStruct->CAN_AWUM == ENABLE)
+ {
+ CANx->MCR |= CAN_MCR_AWUM;
+ }
+ else
+ {
+ CANx->MCR &= ~(uint32_t)CAN_MCR_AWUM;
+ }
+
+ /* Set the no automatic retransmission */
+ if (CAN_InitStruct->CAN_NART == ENABLE)
+ {
+ CANx->MCR |= CAN_MCR_NART;
+ }
+ else
+ {
+ CANx->MCR &= ~(uint32_t)CAN_MCR_NART;
+ }
+
+ /* Set the receive FIFO locked mode */
+ if (CAN_InitStruct->CAN_RFLM == ENABLE)
+ {
+ CANx->MCR |= CAN_MCR_RFLM;
+ }
+ else
+ {
+ CANx->MCR &= ~(uint32_t)CAN_MCR_RFLM;
+ }
+
+ /* Set the transmit FIFO priority */
+ if (CAN_InitStruct->CAN_TXFP == ENABLE)
+ {
+ CANx->MCR |= CAN_MCR_TXFP;
+ }
+ else
+ {
+ CANx->MCR &= ~(uint32_t)CAN_MCR_TXFP;
+ }
+
+ /* Set the bit timing register */
+ CANx->BTR = (uint32_t)((uint32_t)CAN_InitStruct->CAN_Mode << 30) | \
+ ((uint32_t)CAN_InitStruct->CAN_SJW << 24) | \
+ ((uint32_t)CAN_InitStruct->CAN_BS1 << 16) | \
+ ((uint32_t)CAN_InitStruct->CAN_BS2 << 20) | \
+ ((uint32_t)CAN_InitStruct->CAN_Prescaler - 1);
+
+ /* Request leave initialisation */
+ CANx->MCR &= ~(uint32_t)CAN_MCR_INRQ;
+
+ /* Wait the acknowledge */
+ wait_ack = 0;
+
+ while (((CANx->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) && (wait_ack != INAK_TIMEOUT))
+ {
+ wait_ack++;
+ }
+
+ /* ...and check acknowledged */
+ if ((CANx->MSR & CAN_MSR_INAK) == CAN_MSR_INAK)
+ {
+ InitStatus = CAN_InitStatus_Failed;
+ }
+ else
+ {
+ InitStatus = CAN_InitStatus_Success ;
+ }
+ }
+
+ /* At this step, return the status of initialization */
+ return InitStatus;
+}
+
+/**
+ * @brief Initializes the CAN peripheral according to the specified
+ * parameters in the CAN_FilterInitStruct.
+ * @param CAN_FilterInitStruct: pointer to a CAN_FilterInitTypeDef
+ * structure that contains the configuration
+ * information.
+ * @retval None.
+ */
+void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct)
+{
+ uint32_t filter_number_bit_pos = 0;
+ /* Check the parameters */
+ assert_param(IS_CAN_FILTER_NUMBER(CAN_FilterInitStruct->CAN_FilterNumber));
+ assert_param(IS_CAN_FILTER_MODE(CAN_FilterInitStruct->CAN_FilterMode));
+ assert_param(IS_CAN_FILTER_SCALE(CAN_FilterInitStruct->CAN_FilterScale));
+ assert_param(IS_CAN_FILTER_FIFO(CAN_FilterInitStruct->CAN_FilterFIFOAssignment));
+ assert_param(IS_FUNCTIONAL_STATE(CAN_FilterInitStruct->CAN_FilterActivation));
+
+ filter_number_bit_pos = ((uint32_t)1) << CAN_FilterInitStruct->CAN_FilterNumber;
+
+ /* Initialisation mode for the filter */
+ CAN1->FMR |= FMR_FINIT;
+
+ /* Filter Deactivation */
+ CAN1->FA1R &= ~(uint32_t)filter_number_bit_pos;
+
+ /* Filter Scale */
+ if (CAN_FilterInitStruct->CAN_FilterScale == CAN_FilterScale_16bit)
+ {
+ /* 16-bit scale for the filter */
+ CAN1->FS1R &= ~(uint32_t)filter_number_bit_pos;
+
+ /* First 16-bit identifier and First 16-bit mask */
+ /* Or First 16-bit identifier and Second 16-bit identifier */
+ CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR1 =
+ ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdLow) << 16) |
+ (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdLow);
+
+ /* Second 16-bit identifier and Second 16-bit mask */
+ /* Or Third 16-bit identifier and Fourth 16-bit identifier */
+ CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR2 =
+ ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdHigh) << 16) |
+ (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdHigh);
+ }
+
+ if (CAN_FilterInitStruct->CAN_FilterScale == CAN_FilterScale_32bit)
+ {
+ /* 32-bit scale for the filter */
+ CAN1->FS1R |= filter_number_bit_pos;
+ /* 32-bit identifier or First 32-bit identifier */
+ CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR1 =
+ ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdHigh) << 16) |
+ (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdLow);
+ /* 32-bit mask or Second 32-bit identifier */
+ CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR2 =
+ ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdHigh) << 16) |
+ (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdLow);
+ }
+
+ /* Filter Mode */
+ if (CAN_FilterInitStruct->CAN_FilterMode == CAN_FilterMode_IdMask)
+ {
+ /*Id/Mask mode for the filter*/
+ CAN1->FM1R &= ~(uint32_t)filter_number_bit_pos;
+ }
+ else /* CAN_FilterInitStruct->CAN_FilterMode == CAN_FilterMode_IdList */
+ {
+ /*Identifier list mode for the filter*/
+ CAN1->FM1R |= (uint32_t)filter_number_bit_pos;
+ }
+
+ /* Filter FIFO assignment */
+ if (CAN_FilterInitStruct->CAN_FilterFIFOAssignment == CAN_Filter_FIFO0)
+ {
+ /* FIFO 0 assignation for the filter */
+ CAN1->FFA1R &= ~(uint32_t)filter_number_bit_pos;
+ }
+
+ if (CAN_FilterInitStruct->CAN_FilterFIFOAssignment == CAN_Filter_FIFO1)
+ {
+ /* FIFO 1 assignation for the filter */
+ CAN1->FFA1R |= (uint32_t)filter_number_bit_pos;
+ }
+
+ /* Filter activation */
+ if (CAN_FilterInitStruct->CAN_FilterActivation == ENABLE)
+ {
+ CAN1->FA1R |= filter_number_bit_pos;
+ }
+
+ /* Leave the initialisation mode for the filter */
+ CAN1->FMR &= ~FMR_FINIT;
+}
+
+/**
+ * @brief Fills each CAN_InitStruct member with its default value.
+ * @param CAN_InitStruct: pointer to a CAN_InitTypeDef structure which
+ * will be initialized.
+ * @retval None.
+ */
+void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct)
+{
+ /* Reset CAN init structure parameters values */
+
+ /* Initialize the time triggered communication mode */
+ CAN_InitStruct->CAN_TTCM = DISABLE;
+
+ /* Initialize the automatic bus-off management */
+ CAN_InitStruct->CAN_ABOM = DISABLE;
+
+ /* Initialize the automatic wake-up mode */
+ CAN_InitStruct->CAN_AWUM = DISABLE;
+
+ /* Initialize the no automatic retransmission */
+ CAN_InitStruct->CAN_NART = DISABLE;
+
+ /* Initialize the receive FIFO locked mode */
+ CAN_InitStruct->CAN_RFLM = DISABLE;
+
+ /* Initialize the transmit FIFO priority */
+ CAN_InitStruct->CAN_TXFP = DISABLE;
+
+ /* Initialize the CAN_Mode member */
+ CAN_InitStruct->CAN_Mode = CAN_Mode_Normal;
+
+ /* Initialize the CAN_SJW member */
+ CAN_InitStruct->CAN_SJW = CAN_SJW_1tq;
+
+ /* Initialize the CAN_BS1 member */
+ CAN_InitStruct->CAN_BS1 = CAN_BS1_4tq;
+
+ /* Initialize the CAN_BS2 member */
+ CAN_InitStruct->CAN_BS2 = CAN_BS2_3tq;
+
+ /* Initialize the CAN_Prescaler member */
+ CAN_InitStruct->CAN_Prescaler = 1;
+}
+
+/**
+ * @brief Select the start bank filter for slave CAN.
+ * @note This function applies only to STM32 Connectivity line devices.
+ * @param CAN_BankNumber: Select the start slave bank filter from 1..27.
+ * @retval None.
+ */
+void CAN_SlaveStartBank(uint8_t CAN_BankNumber)
+{
+ /* Check the parameters */
+ assert_param(IS_CAN_BANKNUMBER(CAN_BankNumber));
+
+ /* Enter Initialisation mode for the filter */
+ CAN1->FMR |= FMR_FINIT;
+
+ /* Select the start slave bank */
+ CAN1->FMR &= (uint32_t)0xFFFFC0F1 ;
+ CAN1->FMR |= (uint32_t)(CAN_BankNumber)<<8;
+
+ /* Leave Initialisation mode for the filter */
+ CAN1->FMR &= ~FMR_FINIT;
+}
+
+/**
+ * @brief Enables or disables the DBG Freeze for CAN.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param NewState: new state of the CAN peripheral. This parameter can
+ * be: ENABLE or DISABLE.
+ * @retval None.
+ */
+void CAN_DBGFreeze(CAN_TypeDef* CANx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable Debug Freeze */
+ CANx->MCR |= MCR_DBF;
+ }
+ else
+ {
+ /* Disable Debug Freeze */
+ CANx->MCR &= ~MCR_DBF;
+ }
+}
+
+
+/**
+ * @brief Enables or disabes the CAN Time TriggerOperation communication mode.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param NewState : Mode new state , can be one of @ref FunctionalState.
+ * @note when enabled, Time stamp (TIME[15:0]) value is sent in the last
+ * two data bytes of the 8-byte message: TIME[7:0] in data byte 6
+ * and TIME[15:8] in data byte 7
+ * @note DLC must be programmed as 8 in order Time Stamp (2 bytes) to be
+ * sent over the CAN bus.
+ * @retval None
+ */
+void CAN_TTComModeCmd(CAN_TypeDef* CANx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the TTCM mode */
+ CANx->MCR |= CAN_MCR_TTCM;
+
+ /* Set TGT bits */
+ CANx->sTxMailBox[0].TDTR |= ((uint32_t)CAN_TDT0R_TGT);
+ CANx->sTxMailBox[1].TDTR |= ((uint32_t)CAN_TDT1R_TGT);
+ CANx->sTxMailBox[2].TDTR |= ((uint32_t)CAN_TDT2R_TGT);
+ }
+ else
+ {
+ /* Disable the TTCM mode */
+ CANx->MCR &= (uint32_t)(~(uint32_t)CAN_MCR_TTCM);
+
+ /* Reset TGT bits */
+ CANx->sTxMailBox[0].TDTR &= ((uint32_t)~CAN_TDT0R_TGT);
+ CANx->sTxMailBox[1].TDTR &= ((uint32_t)~CAN_TDT1R_TGT);
+ CANx->sTxMailBox[2].TDTR &= ((uint32_t)~CAN_TDT2R_TGT);
+ }
+}
+/**
+ * @brief Initiates the transmission of a message.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param TxMessage: pointer to a structure which contains CAN Id, CAN
+ * DLC and CAN data.
+ * @retval The number of the mailbox that is used for transmission
+ * or CAN_TxStatus_NoMailBox if there is no empty mailbox.
+ */
+uint8_t CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage)
+{
+ uint8_t transmit_mailbox = 0;
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_IDTYPE(TxMessage->IDE));
+ assert_param(IS_CAN_RTR(TxMessage->RTR));
+ assert_param(IS_CAN_DLC(TxMessage->DLC));
+
+ /* Select one empty transmit mailbox */
+ if ((CANx->TSR&CAN_TSR_TME0) == CAN_TSR_TME0)
+ {
+ transmit_mailbox = 0;
+ }
+ else if ((CANx->TSR&CAN_TSR_TME1) == CAN_TSR_TME1)
+ {
+ transmit_mailbox = 1;
+ }
+ else if ((CANx->TSR&CAN_TSR_TME2) == CAN_TSR_TME2)
+ {
+ transmit_mailbox = 2;
+ }
+ else
+ {
+ transmit_mailbox = CAN_TxStatus_NoMailBox;
+ }
+
+ if (transmit_mailbox != CAN_TxStatus_NoMailBox)
+ {
+ /* Set up the Id */
+ CANx->sTxMailBox[transmit_mailbox].TIR &= TMIDxR_TXRQ;
+ if (TxMessage->IDE == CAN_Id_Standard)
+ {
+ assert_param(IS_CAN_STDID(TxMessage->StdId));
+ CANx->sTxMailBox[transmit_mailbox].TIR |= ((TxMessage->StdId << 21) | \
+ TxMessage->RTR);
+ }
+ else
+ {
+ assert_param(IS_CAN_EXTID(TxMessage->ExtId));
+ CANx->sTxMailBox[transmit_mailbox].TIR |= ((TxMessage->ExtId << 3) | \
+ TxMessage->IDE | \
+ TxMessage->RTR);
+ }
+
+ /* Set up the DLC */
+ TxMessage->DLC &= (uint8_t)0x0000000F;
+ CANx->sTxMailBox[transmit_mailbox].TDTR &= (uint32_t)0xFFFFFFF0;
+ CANx->sTxMailBox[transmit_mailbox].TDTR |= TxMessage->DLC;
+
+ /* Set up the data field */
+ CANx->sTxMailBox[transmit_mailbox].TDLR = (((uint32_t)TxMessage->Data[3] << 24) |
+ ((uint32_t)TxMessage->Data[2] << 16) |
+ ((uint32_t)TxMessage->Data[1] << 8) |
+ ((uint32_t)TxMessage->Data[0]));
+ CANx->sTxMailBox[transmit_mailbox].TDHR = (((uint32_t)TxMessage->Data[7] << 24) |
+ ((uint32_t)TxMessage->Data[6] << 16) |
+ ((uint32_t)TxMessage->Data[5] << 8) |
+ ((uint32_t)TxMessage->Data[4]));
+ /* Request transmission */
+ CANx->sTxMailBox[transmit_mailbox].TIR |= TMIDxR_TXRQ;
+ }
+ return transmit_mailbox;
+}
+
+/**
+ * @brief Checks the transmission of a message.
+ * @param CANx: where x can be 1 or 2 to to select the
+ * CAN peripheral.
+ * @param TransmitMailbox: the number of the mailbox that is used for
+ * transmission.
+ * @retval CAN_TxStatus_Ok if the CAN driver transmits the message, CAN_TxStatus_Failed
+ * in an other case.
+ */
+uint8_t CAN_TransmitStatus(CAN_TypeDef* CANx, uint8_t TransmitMailbox)
+{
+ uint32_t state = 0;
+
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_TRANSMITMAILBOX(TransmitMailbox));
+
+ switch (TransmitMailbox)
+ {
+ case (CAN_TXMAILBOX_0):
+ state = CANx->TSR & (CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0);
+ break;
+ case (CAN_TXMAILBOX_1):
+ state = CANx->TSR & (CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1);
+ break;
+ case (CAN_TXMAILBOX_2):
+ state = CANx->TSR & (CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2);
+ break;
+ default:
+ state = CAN_TxStatus_Failed;
+ break;
+ }
+ switch (state)
+ {
+ /* transmit pending */
+ case (0x0): state = CAN_TxStatus_Pending;
+ break;
+ /* transmit failed */
+ case (CAN_TSR_RQCP0 | CAN_TSR_TME0): state = CAN_TxStatus_Failed;
+ break;
+ case (CAN_TSR_RQCP1 | CAN_TSR_TME1): state = CAN_TxStatus_Failed;
+ break;
+ case (CAN_TSR_RQCP2 | CAN_TSR_TME2): state = CAN_TxStatus_Failed;
+ break;
+ /* transmit succeeded */
+ case (CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0):state = CAN_TxStatus_Ok;
+ break;
+ case (CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1):state = CAN_TxStatus_Ok;
+ break;
+ case (CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2):state = CAN_TxStatus_Ok;
+ break;
+ default: state = CAN_TxStatus_Failed;
+ break;
+ }
+ return (uint8_t) state;
+}
+
+/**
+ * @brief Cancels a transmit request.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param Mailbox: Mailbox number.
+ * @retval None.
+ */
+void CAN_CancelTransmit(CAN_TypeDef* CANx, uint8_t Mailbox)
+{
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_TRANSMITMAILBOX(Mailbox));
+ /* abort transmission */
+ switch (Mailbox)
+ {
+ case (CAN_TXMAILBOX_0): CANx->TSR |= CAN_TSR_ABRQ0;
+ break;
+ case (CAN_TXMAILBOX_1): CANx->TSR |= CAN_TSR_ABRQ1;
+ break;
+ case (CAN_TXMAILBOX_2): CANx->TSR |= CAN_TSR_ABRQ2;
+ break;
+ default:
+ break;
+ }
+}
+
+
+/**
+ * @brief Receives a message.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param FIFONumber: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1.
+ * @param RxMessage: pointer to a structure receive message which contains
+ * CAN Id, CAN DLC, CAN datas and FMI number.
+ * @retval None.
+ */
+void CAN_Receive(CAN_TypeDef* CANx, uint8_t FIFONumber, CanRxMsg* RxMessage)
+{
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_FIFO(FIFONumber));
+ /* Get the Id */
+ RxMessage->IDE = (uint8_t)0x04 & CANx->sFIFOMailBox[FIFONumber].RIR;
+ if (RxMessage->IDE == CAN_Id_Standard)
+ {
+ RxMessage->StdId = (uint32_t)0x000007FF & (CANx->sFIFOMailBox[FIFONumber].RIR >> 21);
+ }
+ else
+ {
+ RxMessage->ExtId = (uint32_t)0x1FFFFFFF & (CANx->sFIFOMailBox[FIFONumber].RIR >> 3);
+ }
+
+ RxMessage->RTR = (uint8_t)0x02 & CANx->sFIFOMailBox[FIFONumber].RIR;
+ /* Get the DLC */
+ RxMessage->DLC = (uint8_t)0x0F & CANx->sFIFOMailBox[FIFONumber].RDTR;
+ /* Get the FMI */
+ RxMessage->FMI = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDTR >> 8);
+ /* Get the data field */
+ RxMessage->Data[0] = (uint8_t)0xFF & CANx->sFIFOMailBox[FIFONumber].RDLR;
+ RxMessage->Data[1] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDLR >> 8);
+ RxMessage->Data[2] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDLR >> 16);
+ RxMessage->Data[3] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDLR >> 24);
+ RxMessage->Data[4] = (uint8_t)0xFF & CANx->sFIFOMailBox[FIFONumber].RDHR;
+ RxMessage->Data[5] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDHR >> 8);
+ RxMessage->Data[6] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDHR >> 16);
+ RxMessage->Data[7] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDHR >> 24);
+ /* Release the FIFO */
+ /* Release FIFO0 */
+ if (FIFONumber == CAN_FIFO0)
+ {
+ CANx->RF0R |= CAN_RF0R_RFOM0;
+ }
+ /* Release FIFO1 */
+ else /* FIFONumber == CAN_FIFO1 */
+ {
+ CANx->RF1R |= CAN_RF1R_RFOM1;
+ }
+}
+
+/**
+ * @brief Releases the specified FIFO.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param FIFONumber: FIFO to release, CAN_FIFO0 or CAN_FIFO1.
+ * @retval None.
+ */
+void CAN_FIFORelease(CAN_TypeDef* CANx, uint8_t FIFONumber)
+{
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_FIFO(FIFONumber));
+ /* Release FIFO0 */
+ if (FIFONumber == CAN_FIFO0)
+ {
+ CANx->RF0R |= CAN_RF0R_RFOM0;
+ }
+ /* Release FIFO1 */
+ else /* FIFONumber == CAN_FIFO1 */
+ {
+ CANx->RF1R |= CAN_RF1R_RFOM1;
+ }
+}
+
+/**
+ * @brief Returns the number of pending messages.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param FIFONumber: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1.
+ * @retval NbMessage : which is the number of pending message.
+ */
+uint8_t CAN_MessagePending(CAN_TypeDef* CANx, uint8_t FIFONumber)
+{
+ uint8_t message_pending=0;
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_FIFO(FIFONumber));
+ if (FIFONumber == CAN_FIFO0)
+ {
+ message_pending = (uint8_t)(CANx->RF0R&(uint32_t)0x03);
+ }
+ else if (FIFONumber == CAN_FIFO1)
+ {
+ message_pending = (uint8_t)(CANx->RF1R&(uint32_t)0x03);
+ }
+ else
+ {
+ message_pending = 0;
+ }
+ return message_pending;
+}
+
+
+/**
+ * @brief Select the CAN Operation mode.
+ * @param CAN_OperatingMode : CAN Operating Mode. This parameter can be one
+ * of @ref CAN_OperatingMode_TypeDef enumeration.
+ * @retval status of the requested mode which can be
+ * - CAN_ModeStatus_Failed CAN failed entering the specific mode
+ * - CAN_ModeStatus_Success CAN Succeed entering the specific mode
+
+ */
+uint8_t CAN_OperatingModeRequest(CAN_TypeDef* CANx, uint8_t CAN_OperatingMode)
+{
+ uint8_t status = CAN_ModeStatus_Failed;
+
+ /* Timeout for INAK or also for SLAK bits*/
+ uint32_t timeout = INAK_TIMEOUT;
+
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_OPERATING_MODE(CAN_OperatingMode));
+
+ if (CAN_OperatingMode == CAN_OperatingMode_Initialization)
+ {
+ /* Request initialisation */
+ CANx->MCR = (uint32_t)((CANx->MCR & (uint32_t)(~(uint32_t)CAN_MCR_SLEEP)) | CAN_MCR_INRQ);
+
+ /* Wait the acknowledge */
+ while (((CANx->MSR & CAN_MODE_MASK) != CAN_MSR_INAK) && (timeout != 0))
+ {
+ timeout--;
+ }
+ if ((CANx->MSR & CAN_MODE_MASK) != CAN_MSR_INAK)
+ {
+ status = CAN_ModeStatus_Failed;
+ }
+ else
+ {
+ status = CAN_ModeStatus_Success;
+ }
+ }
+ else if (CAN_OperatingMode == CAN_OperatingMode_Normal)
+ {
+ /* Request leave initialisation and sleep mode and enter Normal mode */
+ CANx->MCR &= (uint32_t)(~(CAN_MCR_SLEEP|CAN_MCR_INRQ));
+
+ /* Wait the acknowledge */
+ while (((CANx->MSR & CAN_MODE_MASK) != 0) && (timeout!=0))
+ {
+ timeout--;
+ }
+ if ((CANx->MSR & CAN_MODE_MASK) != 0)
+ {
+ status = CAN_ModeStatus_Failed;
+ }
+ else
+ {
+ status = CAN_ModeStatus_Success;
+ }
+ }
+ else if (CAN_OperatingMode == CAN_OperatingMode_Sleep)
+ {
+ /* Request Sleep mode */
+ CANx->MCR = (uint32_t)((CANx->MCR & (uint32_t)(~(uint32_t)CAN_MCR_INRQ)) | CAN_MCR_SLEEP);
+
+ /* Wait the acknowledge */
+ while (((CANx->MSR & CAN_MODE_MASK) != CAN_MSR_SLAK) && (timeout!=0))
+ {
+ timeout--;
+ }
+ if ((CANx->MSR & CAN_MODE_MASK) != CAN_MSR_SLAK)
+ {
+ status = CAN_ModeStatus_Failed;
+ }
+ else
+ {
+ status = CAN_ModeStatus_Success;
+ }
+ }
+ else
+ {
+ status = CAN_ModeStatus_Failed;
+ }
+
+ return (uint8_t) status;
+}
+
+/**
+ * @brief Enters the low power mode.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @retval status: CAN_Sleep_Ok if sleep entered, CAN_Sleep_Failed in an
+ * other case.
+ */
+uint8_t CAN_Sleep(CAN_TypeDef* CANx)
+{
+ uint8_t sleepstatus = CAN_Sleep_Failed;
+
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+
+ /* Request Sleep mode */
+ CANx->MCR = (((CANx->MCR) & (uint32_t)(~(uint32_t)CAN_MCR_INRQ)) | CAN_MCR_SLEEP);
+
+ /* Sleep mode status */
+ if ((CANx->MSR & (CAN_MSR_SLAK|CAN_MSR_INAK)) == CAN_MSR_SLAK)
+ {
+ /* Sleep mode not entered */
+ sleepstatus = CAN_Sleep_Ok;
+ }
+ /* return sleep mode status */
+ return (uint8_t)sleepstatus;
+}
+
+/**
+ * @brief Wakes the CAN up.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @retval status: CAN_WakeUp_Ok if sleep mode left, CAN_WakeUp_Failed in an
+ * other case.
+ */
+uint8_t CAN_WakeUp(CAN_TypeDef* CANx)
+{
+ uint32_t wait_slak = SLAK_TIMEOUT;
+ uint8_t wakeupstatus = CAN_WakeUp_Failed;
+
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+
+ /* Wake up request */
+ CANx->MCR &= ~(uint32_t)CAN_MCR_SLEEP;
+
+ /* Sleep mode status */
+ while(((CANx->MSR & CAN_MSR_SLAK) == CAN_MSR_SLAK)&&(wait_slak!=0x00))
+ {
+ wait_slak--;
+ }
+ if((CANx->MSR & CAN_MSR_SLAK) != CAN_MSR_SLAK)
+ {
+ /* wake up done : Sleep mode exited */
+ wakeupstatus = CAN_WakeUp_Ok;
+ }
+ /* return wakeup status */
+ return (uint8_t)wakeupstatus;
+}
+
+
+/**
+ * @brief Returns the CANx's last error code (LEC).
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @retval CAN_ErrorCode: specifies the Error code :
+ * - CAN_ERRORCODE_NoErr No Error
+ * - CAN_ERRORCODE_StuffErr Stuff Error
+ * - CAN_ERRORCODE_FormErr Form Error
+ * - CAN_ERRORCODE_ACKErr Acknowledgment Error
+ * - CAN_ERRORCODE_BitRecessiveErr Bit Recessive Error
+ * - CAN_ERRORCODE_BitDominantErr Bit Dominant Error
+ * - CAN_ERRORCODE_CRCErr CRC Error
+ * - CAN_ERRORCODE_SoftwareSetErr Software Set Error
+ */
+
+uint8_t CAN_GetLastErrorCode(CAN_TypeDef* CANx)
+{
+ uint8_t errorcode=0;
+
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+
+ /* Get the error code*/
+ errorcode = (((uint8_t)CANx->ESR) & (uint8_t)CAN_ESR_LEC);
+
+ /* Return the error code*/
+ return errorcode;
+}
+/**
+ * @brief Returns the CANx Receive Error Counter (REC).
+ * @note In case of an error during reception, this counter is incremented
+ * by 1 or by 8 depending on the error condition as defined by the CAN
+ * standard. After every successful reception, the counter is
+ * decremented by 1 or reset to 120 if its value was higher than 128.
+ * When the counter value exceeds 127, the CAN controller enters the
+ * error passive state.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @retval CAN Receive Error Counter.
+ */
+uint8_t CAN_GetReceiveErrorCounter(CAN_TypeDef* CANx)
+{
+ uint8_t counter=0;
+
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+
+ /* Get the Receive Error Counter*/
+ counter = (uint8_t)((CANx->ESR & CAN_ESR_REC)>> 24);
+
+ /* Return the Receive Error Counter*/
+ return counter;
+}
+
+
+/**
+ * @brief Returns the LSB of the 9-bit CANx Transmit Error Counter(TEC).
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @retval LSB of the 9-bit CAN Transmit Error Counter.
+ */
+uint8_t CAN_GetLSBTransmitErrorCounter(CAN_TypeDef* CANx)
+{
+ uint8_t counter=0;
+
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+
+ /* Get the LSB of the 9-bit CANx Transmit Error Counter(TEC) */
+ counter = (uint8_t)((CANx->ESR & CAN_ESR_TEC)>> 16);
+
+ /* Return the LSB of the 9-bit CANx Transmit Error Counter(TEC) */
+ return counter;
+}
+
+
+/**
+ * @brief Enables or disables the specified CANx interrupts.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param CAN_IT: specifies the CAN interrupt sources to be enabled or disabled.
+ * This parameter can be:
+ * - CAN_IT_TME,
+ * - CAN_IT_FMP0,
+ * - CAN_IT_FF0,
+ * - CAN_IT_FOV0,
+ * - CAN_IT_FMP1,
+ * - CAN_IT_FF1,
+ * - CAN_IT_FOV1,
+ * - CAN_IT_EWG,
+ * - CAN_IT_EPV,
+ * - CAN_IT_LEC,
+ * - CAN_IT_ERR,
+ * - CAN_IT_WKU or
+ * - CAN_IT_SLK.
+ * @param NewState: new state of the CAN interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None.
+ */
+void CAN_ITConfig(CAN_TypeDef* CANx, uint32_t CAN_IT, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_IT(CAN_IT));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected CANx interrupt */
+ CANx->IER |= CAN_IT;
+ }
+ else
+ {
+ /* Disable the selected CANx interrupt */
+ CANx->IER &= ~CAN_IT;
+ }
+}
+/**
+ * @brief Checks whether the specified CAN flag is set or not.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param CAN_FLAG: specifies the flag to check.
+ * This parameter can be one of the following flags:
+ * - CAN_FLAG_EWG
+ * - CAN_FLAG_EPV
+ * - CAN_FLAG_BOF
+ * - CAN_FLAG_RQCP0
+ * - CAN_FLAG_RQCP1
+ * - CAN_FLAG_RQCP2
+ * - CAN_FLAG_FMP1
+ * - CAN_FLAG_FF1
+ * - CAN_FLAG_FOV1
+ * - CAN_FLAG_FMP0
+ * - CAN_FLAG_FF0
+ * - CAN_FLAG_FOV0
+ * - CAN_FLAG_WKU
+ * - CAN_FLAG_SLAK
+ * - CAN_FLAG_LEC
+ * @retval The new state of CAN_FLAG (SET or RESET).
+ */
+FlagStatus CAN_GetFlagStatus(CAN_TypeDef* CANx, uint32_t CAN_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_GET_FLAG(CAN_FLAG));
+
+
+ if((CAN_FLAG & CAN_FLAGS_ESR) != (uint32_t)RESET)
+ {
+ /* Check the status of the specified CAN flag */
+ if ((CANx->ESR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
+ {
+ /* CAN_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* CAN_FLAG is reset */
+ bitstatus = RESET;
+ }
+ }
+ else if((CAN_FLAG & CAN_FLAGS_MSR) != (uint32_t)RESET)
+ {
+ /* Check the status of the specified CAN flag */
+ if ((CANx->MSR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
+ {
+ /* CAN_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* CAN_FLAG is reset */
+ bitstatus = RESET;
+ }
+ }
+ else if((CAN_FLAG & CAN_FLAGS_TSR) != (uint32_t)RESET)
+ {
+ /* Check the status of the specified CAN flag */
+ if ((CANx->TSR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
+ {
+ /* CAN_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* CAN_FLAG is reset */
+ bitstatus = RESET;
+ }
+ }
+ else if((CAN_FLAG & CAN_FLAGS_RF0R) != (uint32_t)RESET)
+ {
+ /* Check the status of the specified CAN flag */
+ if ((CANx->RF0R & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
+ {
+ /* CAN_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* CAN_FLAG is reset */
+ bitstatus = RESET;
+ }
+ }
+ else /* If(CAN_FLAG & CAN_FLAGS_RF1R != (uint32_t)RESET) */
+ {
+ /* Check the status of the specified CAN flag */
+ if ((uint32_t)(CANx->RF1R & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
+ {
+ /* CAN_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* CAN_FLAG is reset */
+ bitstatus = RESET;
+ }
+ }
+ /* Return the CAN_FLAG status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the CAN's pending flags.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param CAN_FLAG: specifies the flag to clear.
+ * This parameter can be one of the following flags:
+ * - CAN_FLAG_RQCP0
+ * - CAN_FLAG_RQCP1
+ * - CAN_FLAG_RQCP2
+ * - CAN_FLAG_FF1
+ * - CAN_FLAG_FOV1
+ * - CAN_FLAG_FF0
+ * - CAN_FLAG_FOV0
+ * - CAN_FLAG_WKU
+ * - CAN_FLAG_SLAK
+ * - CAN_FLAG_LEC
+ * @retval None.
+ */
+void CAN_ClearFlag(CAN_TypeDef* CANx, uint32_t CAN_FLAG)
+{
+ uint32_t flagtmp=0;
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_CLEAR_FLAG(CAN_FLAG));
+
+ if (CAN_FLAG == CAN_FLAG_LEC) /* ESR register */
+ {
+ /* Clear the selected CAN flags */
+ CANx->ESR = (uint32_t)RESET;
+ }
+ else /* MSR or TSR or RF0R or RF1R */
+ {
+ flagtmp = CAN_FLAG & 0x000FFFFF;
+
+ if ((CAN_FLAG & CAN_FLAGS_RF0R)!=(uint32_t)RESET)
+ {
+ /* Receive Flags */
+ CANx->RF0R = (uint32_t)(flagtmp);
+ }
+ else if ((CAN_FLAG & CAN_FLAGS_RF1R)!=(uint32_t)RESET)
+ {
+ /* Receive Flags */
+ CANx->RF1R = (uint32_t)(flagtmp);
+ }
+ else if ((CAN_FLAG & CAN_FLAGS_TSR)!=(uint32_t)RESET)
+ {
+ /* Transmit Flags */
+ CANx->TSR = (uint32_t)(flagtmp);
+ }
+ else /* If((CAN_FLAG & CAN_FLAGS_MSR)!=(uint32_t)RESET) */
+ {
+ /* Operating mode Flags */
+ CANx->MSR = (uint32_t)(flagtmp);
+ }
+ }
+}
+
+/**
+ * @brief Checks whether the specified CANx interrupt has occurred or not.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param CAN_IT: specifies the CAN interrupt source to check.
+ * This parameter can be one of the following flags:
+ * - CAN_IT_TME
+ * - CAN_IT_FMP0
+ * - CAN_IT_FF0
+ * - CAN_IT_FOV0
+ * - CAN_IT_FMP1
+ * - CAN_IT_FF1
+ * - CAN_IT_FOV1
+ * - CAN_IT_WKU
+ * - CAN_IT_SLK
+ * - CAN_IT_EWG
+ * - CAN_IT_EPV
+ * - CAN_IT_BOF
+ * - CAN_IT_LEC
+ * - CAN_IT_ERR
+ * @retval The current state of CAN_IT (SET or RESET).
+ */
+ITStatus CAN_GetITStatus(CAN_TypeDef* CANx, uint32_t CAN_IT)
+{
+ ITStatus itstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_IT(CAN_IT));
+
+ /* check the enable interrupt bit */
+ if((CANx->IER & CAN_IT) != RESET)
+ {
+ /* in case the Interrupt is enabled, .... */
+ switch (CAN_IT)
+ {
+ case CAN_IT_TME:
+ /* Check CAN_TSR_RQCPx bits */
+ itstatus = CheckITStatus(CANx->TSR, CAN_TSR_RQCP0|CAN_TSR_RQCP1|CAN_TSR_RQCP2);
+ break;
+ case CAN_IT_FMP0:
+ /* Check CAN_RF0R_FMP0 bit */
+ itstatus = CheckITStatus(CANx->RF0R, CAN_RF0R_FMP0);
+ break;
+ case CAN_IT_FF0:
+ /* Check CAN_RF0R_FULL0 bit */
+ itstatus = CheckITStatus(CANx->RF0R, CAN_RF0R_FULL0);
+ break;
+ case CAN_IT_FOV0:
+ /* Check CAN_RF0R_FOVR0 bit */
+ itstatus = CheckITStatus(CANx->RF0R, CAN_RF0R_FOVR0);
+ break;
+ case CAN_IT_FMP1:
+ /* Check CAN_RF1R_FMP1 bit */
+ itstatus = CheckITStatus(CANx->RF1R, CAN_RF1R_FMP1);
+ break;
+ case CAN_IT_FF1:
+ /* Check CAN_RF1R_FULL1 bit */
+ itstatus = CheckITStatus(CANx->RF1R, CAN_RF1R_FULL1);
+ break;
+ case CAN_IT_FOV1:
+ /* Check CAN_RF1R_FOVR1 bit */
+ itstatus = CheckITStatus(CANx->RF1R, CAN_RF1R_FOVR1);
+ break;
+ case CAN_IT_WKU:
+ /* Check CAN_MSR_WKUI bit */
+ itstatus = CheckITStatus(CANx->MSR, CAN_MSR_WKUI);
+ break;
+ case CAN_IT_SLK:
+ /* Check CAN_MSR_SLAKI bit */
+ itstatus = CheckITStatus(CANx->MSR, CAN_MSR_SLAKI);
+ break;
+ case CAN_IT_EWG:
+ /* Check CAN_ESR_EWGF bit */
+ itstatus = CheckITStatus(CANx->ESR, CAN_ESR_EWGF);
+ break;
+ case CAN_IT_EPV:
+ /* Check CAN_ESR_EPVF bit */
+ itstatus = CheckITStatus(CANx->ESR, CAN_ESR_EPVF);
+ break;
+ case CAN_IT_BOF:
+ /* Check CAN_ESR_BOFF bit */
+ itstatus = CheckITStatus(CANx->ESR, CAN_ESR_BOFF);
+ break;
+ case CAN_IT_LEC:
+ /* Check CAN_ESR_LEC bit */
+ itstatus = CheckITStatus(CANx->ESR, CAN_ESR_LEC);
+ break;
+ case CAN_IT_ERR:
+ /* Check CAN_MSR_ERRI bit */
+ itstatus = CheckITStatus(CANx->MSR, CAN_MSR_ERRI);
+ break;
+ default :
+ /* in case of error, return RESET */
+ itstatus = RESET;
+ break;
+ }
+ }
+ else
+ {
+ /* in case the Interrupt is not enabled, return RESET */
+ itstatus = RESET;
+ }
+
+ /* Return the CAN_IT status */
+ return itstatus;
+}
+
+/**
+ * @brief Clears the CANx's interrupt pending bits.
+ * @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
+ * @param CAN_IT: specifies the interrupt pending bit to clear.
+ * - CAN_IT_TME
+ * - CAN_IT_FF0
+ * - CAN_IT_FOV0
+ * - CAN_IT_FF1
+ * - CAN_IT_FOV1
+ * - CAN_IT_WKU
+ * - CAN_IT_SLK
+ * - CAN_IT_EWG
+ * - CAN_IT_EPV
+ * - CAN_IT_BOF
+ * - CAN_IT_LEC
+ * - CAN_IT_ERR
+ * @retval None.
+ */
+void CAN_ClearITPendingBit(CAN_TypeDef* CANx, uint32_t CAN_IT)
+{
+ /* Check the parameters */
+ assert_param(IS_CAN_ALL_PERIPH(CANx));
+ assert_param(IS_CAN_CLEAR_IT(CAN_IT));
+
+ switch (CAN_IT)
+ {
+ case CAN_IT_TME:
+ /* Clear CAN_TSR_RQCPx (rc_w1)*/
+ CANx->TSR = CAN_TSR_RQCP0|CAN_TSR_RQCP1|CAN_TSR_RQCP2;
+ break;
+ case CAN_IT_FF0:
+ /* Clear CAN_RF0R_FULL0 (rc_w1)*/
+ CANx->RF0R = CAN_RF0R_FULL0;
+ break;
+ case CAN_IT_FOV0:
+ /* Clear CAN_RF0R_FOVR0 (rc_w1)*/
+ CANx->RF0R = CAN_RF0R_FOVR0;
+ break;
+ case CAN_IT_FF1:
+ /* Clear CAN_RF1R_FULL1 (rc_w1)*/
+ CANx->RF1R = CAN_RF1R_FULL1;
+ break;
+ case CAN_IT_FOV1:
+ /* Clear CAN_RF1R_FOVR1 (rc_w1)*/
+ CANx->RF1R = CAN_RF1R_FOVR1;
+ break;
+ case CAN_IT_WKU:
+ /* Clear CAN_MSR_WKUI (rc_w1)*/
+ CANx->MSR = CAN_MSR_WKUI;
+ break;
+ case CAN_IT_SLK:
+ /* Clear CAN_MSR_SLAKI (rc_w1)*/
+ CANx->MSR = CAN_MSR_SLAKI;
+ break;
+ case CAN_IT_EWG:
+ /* Clear CAN_MSR_ERRI (rc_w1) */
+ CANx->MSR = CAN_MSR_ERRI;
+ /* Note : the corresponding Flag is cleared by hardware depending
+ of the CAN Bus status*/
+ break;
+ case CAN_IT_EPV:
+ /* Clear CAN_MSR_ERRI (rc_w1) */
+ CANx->MSR = CAN_MSR_ERRI;
+ /* Note : the corresponding Flag is cleared by hardware depending
+ of the CAN Bus status*/
+ break;
+ case CAN_IT_BOF:
+ /* Clear CAN_MSR_ERRI (rc_w1) */
+ CANx->MSR = CAN_MSR_ERRI;
+ /* Note : the corresponding Flag is cleared by hardware depending
+ of the CAN Bus status*/
+ break;
+ case CAN_IT_LEC:
+ /* Clear LEC bits */
+ CANx->ESR = RESET;
+ /* Clear CAN_MSR_ERRI (rc_w1) */
+ CANx->MSR = CAN_MSR_ERRI;
+ break;
+ case CAN_IT_ERR:
+ /*Clear LEC bits */
+ CANx->ESR = RESET;
+ /* Clear CAN_MSR_ERRI (rc_w1) */
+ CANx->MSR = CAN_MSR_ERRI;
+ /* Note : BOFF, EPVF and EWGF Flags are cleared by hardware depending
+ of the CAN Bus status*/
+ break;
+ default :
+ break;
+ }
+}
+
+/**
+ * @brief Checks whether the CAN interrupt has occurred or not.
+ * @param CAN_Reg: specifies the CAN interrupt register to check.
+ * @param It_Bit: specifies the interrupt source bit to check.
+ * @retval The new state of the CAN Interrupt (SET or RESET).
+ */
+static ITStatus CheckITStatus(uint32_t CAN_Reg, uint32_t It_Bit)
+{
+ ITStatus pendingbitstatus = RESET;
+
+ if ((CAN_Reg & It_Bit) != (uint32_t)RESET)
+ {
+ /* CAN_IT is set */
+ pendingbitstatus = SET;
+ }
+ else
+ {
+ /* CAN_IT is reset */
+ pendingbitstatus = RESET;
+ }
+ return pendingbitstatus;
+}
+
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_cec.c b/st_fw_lib/src/stm32f10x_cec.c
new file mode 100644
index 0000000..4dc615f
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_cec.c
@@ -0,0 +1,433 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_cec.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the CEC firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_cec.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup CEC
+ * @brief CEC driver modules
+ * @{
+ */
+
+/** @defgroup CEC_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup CEC_Private_Defines
+ * @{
+ */
+
+/* ------------ CEC registers bit address in the alias region ----------- */
+#define CEC_OFFSET (CEC_BASE - PERIPH_BASE)
+
+/* --- CFGR Register ---*/
+
+/* Alias word address of PE bit */
+#define CFGR_OFFSET (CEC_OFFSET + 0x00)
+#define PE_BitNumber 0x00
+#define CFGR_PE_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (PE_BitNumber * 4))
+
+/* Alias word address of IE bit */
+#define IE_BitNumber 0x01
+#define CFGR_IE_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (IE_BitNumber * 4))
+
+/* --- CSR Register ---*/
+
+/* Alias word address of TSOM bit */
+#define CSR_OFFSET (CEC_OFFSET + 0x10)
+#define TSOM_BitNumber 0x00
+#define CSR_TSOM_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TSOM_BitNumber * 4))
+
+/* Alias word address of TEOM bit */
+#define TEOM_BitNumber 0x01
+#define CSR_TEOM_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TEOM_BitNumber * 4))
+
+#define CFGR_CLEAR_Mask (uint8_t)(0xF3) /* CFGR register Mask */
+#define FLAG_Mask ((uint32_t)0x00FFFFFF) /* CEC FLAG mask */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup CEC_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup CEC_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup CEC_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup CEC_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the CEC peripheral registers to their default reset
+ * values.
+ * @param None
+ * @retval None
+ */
+void CEC_DeInit(void)
+{
+ /* Enable CEC reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_CEC, ENABLE);
+ /* Release CEC from reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_CEC, DISABLE);
+}
+
+
+/**
+ * @brief Initializes the CEC peripheral according to the specified
+ * parameters in the CEC_InitStruct.
+ * @param CEC_InitStruct: pointer to an CEC_InitTypeDef structure that
+ * contains the configuration information for the specified
+ * CEC peripheral.
+ * @retval None
+ */
+void CEC_Init(CEC_InitTypeDef* CEC_InitStruct)
+{
+ uint16_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_CEC_BIT_TIMING_ERROR_MODE(CEC_InitStruct->CEC_BitTimingMode));
+ assert_param(IS_CEC_BIT_PERIOD_ERROR_MODE(CEC_InitStruct->CEC_BitPeriodMode));
+
+ /*---------------------------- CEC CFGR Configuration -----------------*/
+ /* Get the CEC CFGR value */
+ tmpreg = CEC->CFGR;
+
+ /* Clear BTEM and BPEM bits */
+ tmpreg &= CFGR_CLEAR_Mask;
+
+ /* Configure CEC: Bit Timing Error and Bit Period Error */
+ tmpreg |= (uint16_t)(CEC_InitStruct->CEC_BitTimingMode | CEC_InitStruct->CEC_BitPeriodMode);
+
+ /* Write to CEC CFGR register*/
+ CEC->CFGR = tmpreg;
+
+}
+
+/**
+ * @brief Enables or disables the specified CEC peripheral.
+ * @param NewState: new state of the CEC peripheral.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void CEC_Cmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) CFGR_PE_BB = (uint32_t)NewState;
+
+ if(NewState == DISABLE)
+ {
+ /* Wait until the PE bit is cleared by hardware (Idle Line detected) */
+ while((CEC->CFGR & CEC_CFGR_PE) != (uint32_t)RESET)
+ {
+ }
+ }
+}
+
+/**
+ * @brief Enables or disables the CEC interrupt.
+ * @param NewState: new state of the CEC interrupt.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void CEC_ITConfig(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) CFGR_IE_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Defines the Own Address of the CEC device.
+ * @param CEC_OwnAddress: The CEC own address
+ * @retval None
+ */
+void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress)
+{
+ /* Check the parameters */
+ assert_param(IS_CEC_ADDRESS(CEC_OwnAddress));
+
+ /* Set the CEC own address */
+ CEC->OAR = CEC_OwnAddress;
+}
+
+/**
+ * @brief Sets the CEC prescaler value.
+ * @param CEC_Prescaler: CEC prescaler new value
+ * @retval None
+ */
+void CEC_SetPrescaler(uint16_t CEC_Prescaler)
+{
+ /* Check the parameters */
+ assert_param(IS_CEC_PRESCALER(CEC_Prescaler));
+
+ /* Set the Prescaler value*/
+ CEC->PRES = CEC_Prescaler;
+}
+
+/**
+ * @brief Transmits single data through the CEC peripheral.
+ * @param Data: the data to transmit.
+ * @retval None
+ */
+void CEC_SendDataByte(uint8_t Data)
+{
+ /* Transmit Data */
+ CEC->TXD = Data ;
+}
+
+
+/**
+ * @brief Returns the most recent received data by the CEC peripheral.
+ * @param None
+ * @retval The received data.
+ */
+uint8_t CEC_ReceiveDataByte(void)
+{
+ /* Receive Data */
+ return (uint8_t)(CEC->RXD);
+}
+
+/**
+ * @brief Starts a new message.
+ * @param None
+ * @retval None
+ */
+void CEC_StartOfMessage(void)
+{
+ /* Starts of new message */
+ *(__IO uint32_t *) CSR_TSOM_BB = (uint32_t)0x1;
+}
+
+/**
+ * @brief Transmits message with or without an EOM bit.
+ * @param NewState: new state of the CEC Tx End Of Message.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void CEC_EndOfMessageCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ /* The data byte will be transmitted with or without an EOM bit*/
+ *(__IO uint32_t *) CSR_TEOM_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Gets the CEC flag status
+ * @param CEC_FLAG: specifies the CEC flag to check.
+ * This parameter can be one of the following values:
+ * @arg CEC_FLAG_BTE: Bit Timing Error
+ * @arg CEC_FLAG_BPE: Bit Period Error
+ * @arg CEC_FLAG_RBTFE: Rx Block Transfer Finished Error
+ * @arg CEC_FLAG_SBE: Start Bit Error
+ * @arg CEC_FLAG_ACKE: Block Acknowledge Error
+ * @arg CEC_FLAG_LINE: Line Error
+ * @arg CEC_FLAG_TBTFE: Tx Block Transfer Finished Error
+ * @arg CEC_FLAG_TEOM: Tx End Of Message
+ * @arg CEC_FLAG_TERR: Tx Error
+ * @arg CEC_FLAG_TBTRF: Tx Byte Transfer Request or Block Transfer Finished
+ * @arg CEC_FLAG_RSOM: Rx Start Of Message
+ * @arg CEC_FLAG_REOM: Rx End Of Message
+ * @arg CEC_FLAG_RERR: Rx Error
+ * @arg CEC_FLAG_RBTF: Rx Byte/Block Transfer Finished
+ * @retval The new state of CEC_FLAG (SET or RESET)
+ */
+FlagStatus CEC_GetFlagStatus(uint32_t CEC_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+ uint32_t cecreg = 0, cecbase = 0;
+
+ /* Check the parameters */
+ assert_param(IS_CEC_GET_FLAG(CEC_FLAG));
+
+ /* Get the CEC peripheral base address */
+ cecbase = (uint32_t)(CEC_BASE);
+
+ /* Read flag register index */
+ cecreg = CEC_FLAG >> 28;
+
+ /* Get bit[23:0] of the flag */
+ CEC_FLAG &= FLAG_Mask;
+
+ if(cecreg != 0)
+ {
+ /* Flag in CEC ESR Register */
+ CEC_FLAG = (uint32_t)(CEC_FLAG >> 16);
+
+ /* Get the CEC ESR register address */
+ cecbase += 0xC;
+ }
+ else
+ {
+ /* Get the CEC CSR register address */
+ cecbase += 0x10;
+ }
+
+ if(((*(__IO uint32_t *)cecbase) & CEC_FLAG) != (uint32_t)RESET)
+ {
+ /* CEC_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* CEC_FLAG is reset */
+ bitstatus = RESET;
+ }
+
+ /* Return the CEC_FLAG status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the CEC's pending flags.
+ * @param CEC_FLAG: specifies the flag to clear.
+ * This parameter can be any combination of the following values:
+ * @arg CEC_FLAG_TERR: Tx Error
+ * @arg CEC_FLAG_TBTRF: Tx Byte Transfer Request or Block Transfer Finished
+ * @arg CEC_FLAG_RSOM: Rx Start Of Message
+ * @arg CEC_FLAG_REOM: Rx End Of Message
+ * @arg CEC_FLAG_RERR: Rx Error
+ * @arg CEC_FLAG_RBTF: Rx Byte/Block Transfer Finished
+ * @retval None
+ */
+void CEC_ClearFlag(uint32_t CEC_FLAG)
+{
+ uint32_t tmp = 0x0;
+
+ /* Check the parameters */
+ assert_param(IS_CEC_CLEAR_FLAG(CEC_FLAG));
+
+ tmp = CEC->CSR & 0x2;
+
+ /* Clear the selected CEC flags */
+ CEC->CSR &= (uint32_t)(((~(uint32_t)CEC_FLAG) & 0xFFFFFFFC) | tmp);
+}
+
+/**
+ * @brief Checks whether the specified CEC interrupt has occurred or not.
+ * @param CEC_IT: specifies the CEC interrupt source to check.
+ * This parameter can be one of the following values:
+ * @arg CEC_IT_TERR: Tx Error
+ * @arg CEC_IT_TBTF: Tx Block Transfer Finished
+ * @arg CEC_IT_RERR: Rx Error
+ * @arg CEC_IT_RBTF: Rx Block Transfer Finished
+ * @retval The new state of CEC_IT (SET or RESET).
+ */
+ITStatus CEC_GetITStatus(uint8_t CEC_IT)
+{
+ ITStatus bitstatus = RESET;
+ uint32_t enablestatus = 0;
+
+ /* Check the parameters */
+ assert_param(IS_CEC_GET_IT(CEC_IT));
+
+ /* Get the CEC IT enable bit status */
+ enablestatus = (CEC->CFGR & (uint8_t)CEC_CFGR_IE) ;
+
+ /* Check the status of the specified CEC interrupt */
+ if (((CEC->CSR & CEC_IT) != (uint32_t)RESET) && enablestatus)
+ {
+ /* CEC_IT is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* CEC_IT is reset */
+ bitstatus = RESET;
+ }
+ /* Return the CEC_IT status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the CEC's interrupt pending bits.
+ * @param CEC_IT: specifies the CEC interrupt pending bit to clear.
+ * This parameter can be any combination of the following values:
+ * @arg CEC_IT_TERR: Tx Error
+ * @arg CEC_IT_TBTF: Tx Block Transfer Finished
+ * @arg CEC_IT_RERR: Rx Error
+ * @arg CEC_IT_RBTF: Rx Block Transfer Finished
+ * @retval None
+ */
+void CEC_ClearITPendingBit(uint16_t CEC_IT)
+{
+ uint32_t tmp = 0x0;
+
+ /* Check the parameters */
+ assert_param(IS_CEC_GET_IT(CEC_IT));
+
+ tmp = CEC->CSR & 0x2;
+
+ /* Clear the selected CEC interrupt pending bits */
+ CEC->CSR &= (uint32_t)(((~(uint32_t)CEC_IT) & 0xFFFFFFFC) | tmp);
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_crc.c b/st_fw_lib/src/stm32f10x_crc.c
new file mode 100644
index 0000000..6501728
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_crc.c
@@ -0,0 +1,160 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_crc.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the CRC firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_crc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup CRC
+ * @brief CRC driver modules
+ * @{
+ */
+
+/** @defgroup CRC_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CRC_Private_Defines
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CRC_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CRC_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CRC_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup CRC_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Resets the CRC Data register (DR).
+ * @param None
+ * @retval None
+ */
+void CRC_ResetDR(void)
+{
+ /* Reset CRC generator */
+ CRC->CR = CRC_CR_RESET;
+}
+
+/**
+ * @brief Computes the 32-bit CRC of a given data word(32-bit).
+ * @param Data: data word(32-bit) to compute its CRC
+ * @retval 32-bit CRC
+ */
+uint32_t CRC_CalcCRC(uint32_t Data)
+{
+ CRC->DR = Data;
+
+ return (CRC->DR);
+}
+
+/**
+ * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit).
+ * @param pBuffer: pointer to the buffer containing the data to be computed
+ * @param BufferLength: length of the buffer to be computed
+ * @retval 32-bit CRC
+ */
+uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength)
+{
+ uint32_t index = 0;
+
+ for(index = 0; index < BufferLength; index++)
+ {
+ CRC->DR = pBuffer[index];
+ }
+ return (CRC->DR);
+}
+
+/**
+ * @brief Returns the current CRC value.
+ * @param None
+ * @retval 32-bit CRC
+ */
+uint32_t CRC_GetCRC(void)
+{
+ return (CRC->DR);
+}
+
+/**
+ * @brief Stores a 8-bit data in the Independent Data(ID) register.
+ * @param IDValue: 8-bit value to be stored in the ID register
+ * @retval None
+ */
+void CRC_SetIDRegister(uint8_t IDValue)
+{
+ CRC->IDR = IDValue;
+}
+
+/**
+ * @brief Returns the 8-bit data stored in the Independent Data(ID) register
+ * @param None
+ * @retval 8-bit value of the ID register
+ */
+uint8_t CRC_GetIDRegister(void)
+{
+ return (CRC->IDR);
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_dac.c b/st_fw_lib/src/stm32f10x_dac.c
new file mode 100644
index 0000000..1cfc71d
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_dac.c
@@ -0,0 +1,571 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_dac.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the DAC firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_dac.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup DAC
+ * @brief DAC driver modules
+ * @{
+ */
+
+/** @defgroup DAC_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DAC_Private_Defines
+ * @{
+ */
+
+/* CR register Mask */
+#define CR_CLEAR_MASK ((uint32_t)0x00000FFE)
+
+/* DAC Dual Channels SWTRIG masks */
+#define DUAL_SWTRIG_SET ((uint32_t)0x00000003)
+#define DUAL_SWTRIG_RESET ((uint32_t)0xFFFFFFFC)
+
+/* DHR registers offsets */
+#define DHR12R1_OFFSET ((uint32_t)0x00000008)
+#define DHR12R2_OFFSET ((uint32_t)0x00000014)
+#define DHR12RD_OFFSET ((uint32_t)0x00000020)
+
+/* DOR register offset */
+#define DOR_OFFSET ((uint32_t)0x0000002C)
+/**
+ * @}
+ */
+
+/** @defgroup DAC_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DAC_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DAC_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DAC_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the DAC peripheral registers to their default reset values.
+ * @param None
+ * @retval None
+ */
+void DAC_DeInit(void)
+{
+ /* Enable DAC reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, ENABLE);
+ /* Release DAC from reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, DISABLE);
+}
+
+/**
+ * @brief Initializes the DAC peripheral according to the specified
+ * parameters in the DAC_InitStruct.
+ * @param DAC_Channel: the selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @param DAC_InitStruct: pointer to a DAC_InitTypeDef structure that
+ * contains the configuration information for the specified DAC channel.
+ * @retval None
+ */
+void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct)
+{
+ uint32_t tmpreg1 = 0, tmpreg2 = 0;
+ /* Check the DAC parameters */
+ assert_param(IS_DAC_TRIGGER(DAC_InitStruct->DAC_Trigger));
+ assert_param(IS_DAC_GENERATE_WAVE(DAC_InitStruct->DAC_WaveGeneration));
+ assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude));
+ assert_param(IS_DAC_OUTPUT_BUFFER_STATE(DAC_InitStruct->DAC_OutputBuffer));
+/*---------------------------- DAC CR Configuration --------------------------*/
+ /* Get the DAC CR value */
+ tmpreg1 = DAC->CR;
+ /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */
+ tmpreg1 &= ~(CR_CLEAR_MASK << DAC_Channel);
+ /* Configure for the selected DAC channel: buffer output, trigger, wave generation,
+ mask/amplitude for wave generation */
+ /* Set TSELx and TENx bits according to DAC_Trigger value */
+ /* Set WAVEx bits according to DAC_WaveGeneration value */
+ /* Set MAMPx bits according to DAC_LFSRUnmask_TriangleAmplitude value */
+ /* Set BOFFx bit according to DAC_OutputBuffer value */
+ tmpreg2 = (DAC_InitStruct->DAC_Trigger | DAC_InitStruct->DAC_WaveGeneration |
+ DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude | DAC_InitStruct->DAC_OutputBuffer);
+ /* Calculate CR register value depending on DAC_Channel */
+ tmpreg1 |= tmpreg2 << DAC_Channel;
+ /* Write to DAC CR */
+ DAC->CR = tmpreg1;
+}
+
+/**
+ * @brief Fills each DAC_InitStruct member with its default value.
+ * @param DAC_InitStruct : pointer to a DAC_InitTypeDef structure which will
+ * be initialized.
+ * @retval None
+ */
+void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct)
+{
+/*--------------- Reset DAC init structure parameters values -----------------*/
+ /* Initialize the DAC_Trigger member */
+ DAC_InitStruct->DAC_Trigger = DAC_Trigger_None;
+ /* Initialize the DAC_WaveGeneration member */
+ DAC_InitStruct->DAC_WaveGeneration = DAC_WaveGeneration_None;
+ /* Initialize the DAC_LFSRUnmask_TriangleAmplitude member */
+ DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bit0;
+ /* Initialize the DAC_OutputBuffer member */
+ DAC_InitStruct->DAC_OutputBuffer = DAC_OutputBuffer_Enable;
+}
+
+/**
+ * @brief Enables or disables the specified DAC channel.
+ * @param DAC_Channel: the selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @param NewState: new state of the DAC channel.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_DAC_CHANNEL(DAC_Channel));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected DAC channel */
+ DAC->CR |= (DAC_CR_EN1 << DAC_Channel);
+ }
+ else
+ {
+ /* Disable the selected DAC channel */
+ DAC->CR &= ~(DAC_CR_EN1 << DAC_Channel);
+ }
+}
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+/**
+ * @brief Enables or disables the specified DAC interrupts.
+ * @param DAC_Channel: the selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @param DAC_IT: specifies the DAC interrupt sources to be enabled or disabled.
+ * This parameter can be the following values:
+ * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask
+ * @param NewState: new state of the specified DAC interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_DAC_CHANNEL(DAC_Channel));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ assert_param(IS_DAC_IT(DAC_IT));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected DAC interrupts */
+ DAC->CR |= (DAC_IT << DAC_Channel);
+ }
+ else
+ {
+ /* Disable the selected DAC interrupts */
+ DAC->CR &= (~(uint32_t)(DAC_IT << DAC_Channel));
+ }
+}
+#endif
+
+/**
+ * @brief Enables or disables the specified DAC channel DMA request.
+ * @param DAC_Channel: the selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @param NewState: new state of the selected DAC channel DMA request.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_DAC_CHANNEL(DAC_Channel));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected DAC channel DMA request */
+ DAC->CR |= (DAC_CR_DMAEN1 << DAC_Channel);
+ }
+ else
+ {
+ /* Disable the selected DAC channel DMA request */
+ DAC->CR &= ~(DAC_CR_DMAEN1 << DAC_Channel);
+ }
+}
+
+/**
+ * @brief Enables or disables the selected DAC channel software trigger.
+ * @param DAC_Channel: the selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @param NewState: new state of the selected DAC channel software trigger.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_DAC_CHANNEL(DAC_Channel));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable software trigger for the selected DAC channel */
+ DAC->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4);
+ }
+ else
+ {
+ /* Disable software trigger for the selected DAC channel */
+ DAC->SWTRIGR &= ~((uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4));
+ }
+}
+
+/**
+ * @brief Enables or disables simultaneously the two DAC channels software
+ * triggers.
+ * @param NewState: new state of the DAC channels software triggers.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void DAC_DualSoftwareTriggerCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable software trigger for both DAC channels */
+ DAC->SWTRIGR |= DUAL_SWTRIG_SET ;
+ }
+ else
+ {
+ /* Disable software trigger for both DAC channels */
+ DAC->SWTRIGR &= DUAL_SWTRIG_RESET;
+ }
+}
+
+/**
+ * @brief Enables or disables the selected DAC channel wave generation.
+ * @param DAC_Channel: the selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @param DAC_Wave: Specifies the wave type to enable or disable.
+ * This parameter can be one of the following values:
+ * @arg DAC_Wave_Noise: noise wave generation
+ * @arg DAC_Wave_Triangle: triangle wave generation
+ * @param NewState: new state of the selected DAC channel wave generation.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_DAC_CHANNEL(DAC_Channel));
+ assert_param(IS_DAC_WAVE(DAC_Wave));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected wave generation for the selected DAC channel */
+ DAC->CR |= DAC_Wave << DAC_Channel;
+ }
+ else
+ {
+ /* Disable the selected wave generation for the selected DAC channel */
+ DAC->CR &= ~(DAC_Wave << DAC_Channel);
+ }
+}
+
+/**
+ * @brief Set the specified data holding register value for DAC channel1.
+ * @param DAC_Align: Specifies the data alignment for DAC channel1.
+ * This parameter can be one of the following values:
+ * @arg DAC_Align_8b_R: 8bit right data alignment selected
+ * @arg DAC_Align_12b_L: 12bit left data alignment selected
+ * @arg DAC_Align_12b_R: 12bit right data alignment selected
+ * @param Data : Data to be loaded in the selected data holding register.
+ * @retval None
+ */
+void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data)
+{
+ __IO uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_DAC_ALIGN(DAC_Align));
+ assert_param(IS_DAC_DATA(Data));
+
+ tmp = (uint32_t)DAC_BASE;
+ tmp += DHR12R1_OFFSET + DAC_Align;
+
+ /* Set the DAC channel1 selected data holding register */
+ *(__IO uint32_t *) tmp = Data;
+}
+
+/**
+ * @brief Set the specified data holding register value for DAC channel2.
+ * @param DAC_Align: Specifies the data alignment for DAC channel2.
+ * This parameter can be one of the following values:
+ * @arg DAC_Align_8b_R: 8bit right data alignment selected
+ * @arg DAC_Align_12b_L: 12bit left data alignment selected
+ * @arg DAC_Align_12b_R: 12bit right data alignment selected
+ * @param Data : Data to be loaded in the selected data holding register.
+ * @retval None
+ */
+void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data)
+{
+ __IO uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_DAC_ALIGN(DAC_Align));
+ assert_param(IS_DAC_DATA(Data));
+
+ tmp = (uint32_t)DAC_BASE;
+ tmp += DHR12R2_OFFSET + DAC_Align;
+
+ /* Set the DAC channel2 selected data holding register */
+ *(__IO uint32_t *)tmp = Data;
+}
+
+/**
+ * @brief Set the specified data holding register value for dual channel
+ * DAC.
+ * @param DAC_Align: Specifies the data alignment for dual channel DAC.
+ * This parameter can be one of the following values:
+ * @arg DAC_Align_8b_R: 8bit right data alignment selected
+ * @arg DAC_Align_12b_L: 12bit left data alignment selected
+ * @arg DAC_Align_12b_R: 12bit right data alignment selected
+ * @param Data2: Data for DAC Channel2 to be loaded in the selected data
+ * holding register.
+ * @param Data1: Data for DAC Channel1 to be loaded in the selected data
+ * holding register.
+ * @retval None
+ */
+void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1)
+{
+ uint32_t data = 0, tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_DAC_ALIGN(DAC_Align));
+ assert_param(IS_DAC_DATA(Data1));
+ assert_param(IS_DAC_DATA(Data2));
+
+ /* Calculate and set dual DAC data holding register value */
+ if (DAC_Align == DAC_Align_8b_R)
+ {
+ data = ((uint32_t)Data2 << 8) | Data1;
+ }
+ else
+ {
+ data = ((uint32_t)Data2 << 16) | Data1;
+ }
+
+ tmp = (uint32_t)DAC_BASE;
+ tmp += DHR12RD_OFFSET + DAC_Align;
+
+ /* Set the dual DAC selected data holding register */
+ *(__IO uint32_t *)tmp = data;
+}
+
+/**
+ * @brief Returns the last data output value of the selected DAC channel.
+ * @param DAC_Channel: the selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @retval The selected DAC channel data output value.
+ */
+uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel)
+{
+ __IO uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_DAC_CHANNEL(DAC_Channel));
+
+ tmp = (uint32_t) DAC_BASE ;
+ tmp += DOR_OFFSET + ((uint32_t)DAC_Channel >> 2);
+
+ /* Returns the DAC channel data output register value */
+ return (uint16_t) (*(__IO uint32_t*) tmp);
+}
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+/**
+ * @brief Checks whether the specified DAC flag is set or not.
+ * @param DAC_Channel: thee selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @param DAC_FLAG: specifies the flag to check.
+ * This parameter can be only of the following value:
+ * @arg DAC_FLAG_DMAUDR: DMA underrun flag
+ * @retval The new state of DAC_FLAG (SET or RESET).
+ */
+FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_DAC_CHANNEL(DAC_Channel));
+ assert_param(IS_DAC_FLAG(DAC_FLAG));
+
+ /* Check the status of the specified DAC flag */
+ if ((DAC->SR & (DAC_FLAG << DAC_Channel)) != (uint8_t)RESET)
+ {
+ /* DAC_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* DAC_FLAG is reset */
+ bitstatus = RESET;
+ }
+ /* Return the DAC_FLAG status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the DAC channelx's pending flags.
+ * @param DAC_Channel: the selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @param DAC_FLAG: specifies the flag to clear.
+ * This parameter can be of the following value:
+ * @arg DAC_FLAG_DMAUDR: DMA underrun flag
+ * @retval None
+ */
+void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG)
+{
+ /* Check the parameters */
+ assert_param(IS_DAC_CHANNEL(DAC_Channel));
+ assert_param(IS_DAC_FLAG(DAC_FLAG));
+
+ /* Clear the selected DAC flags */
+ DAC->SR = (DAC_FLAG << DAC_Channel);
+}
+
+/**
+ * @brief Checks whether the specified DAC interrupt has occurred or not.
+ * @param DAC_Channel: the selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @param DAC_IT: specifies the DAC interrupt source to check.
+ * This parameter can be the following values:
+ * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask
+ * @retval The new state of DAC_IT (SET or RESET).
+ */
+ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT)
+{
+ ITStatus bitstatus = RESET;
+ uint32_t enablestatus = 0;
+
+ /* Check the parameters */
+ assert_param(IS_DAC_CHANNEL(DAC_Channel));
+ assert_param(IS_DAC_IT(DAC_IT));
+
+ /* Get the DAC_IT enable bit status */
+ enablestatus = (DAC->CR & (DAC_IT << DAC_Channel)) ;
+
+ /* Check the status of the specified DAC interrupt */
+ if (((DAC->SR & (DAC_IT << DAC_Channel)) != (uint32_t)RESET) && enablestatus)
+ {
+ /* DAC_IT is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* DAC_IT is reset */
+ bitstatus = RESET;
+ }
+ /* Return the DAC_IT status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the DAC channelx's interrupt pending bits.
+ * @param DAC_Channel: the selected DAC channel.
+ * This parameter can be one of the following values:
+ * @arg DAC_Channel_1: DAC Channel1 selected
+ * @arg DAC_Channel_2: DAC Channel2 selected
+ * @param DAC_IT: specifies the DAC interrupt pending bit to clear.
+ * This parameter can be the following values:
+ * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask
+ * @retval None
+ */
+void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT)
+{
+ /* Check the parameters */
+ assert_param(IS_DAC_CHANNEL(DAC_Channel));
+ assert_param(IS_DAC_IT(DAC_IT));
+
+ /* Clear the selected DAC interrupt pending bits */
+ DAC->SR = (DAC_IT << DAC_Channel);
+}
+#endif
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_dbgmcu.c b/st_fw_lib/src/stm32f10x_dbgmcu.c
new file mode 100644
index 0000000..96a8fde
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_dbgmcu.c
@@ -0,0 +1,162 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_dbgmcu.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the DBGMCU firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_dbgmcu.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup DBGMCU
+ * @brief DBGMCU driver modules
+ * @{
+ */
+
+/** @defgroup DBGMCU_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DBGMCU_Private_Defines
+ * @{
+ */
+
+#define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
+/**
+ * @}
+ */
+
+/** @defgroup DBGMCU_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DBGMCU_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DBGMCU_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DBGMCU_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Returns the device revision identifier.
+ * @param None
+ * @retval Device revision identifier
+ */
+uint32_t DBGMCU_GetREVID(void)
+{
+ return(DBGMCU->IDCODE >> 16);
+}
+
+/**
+ * @brief Returns the device identifier.
+ * @param None
+ * @retval Device identifier
+ */
+uint32_t DBGMCU_GetDEVID(void)
+{
+ return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);
+}
+
+/**
+ * @brief Configures the specified peripheral and low power mode behavior
+ * when the MCU under Debug mode.
+ * @param DBGMCU_Periph: specifies the peripheral and low power mode.
+ * This parameter can be any combination of the following values:
+ * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode
+ * @arg DBGMCU_STOP: Keep debugger connection during STOP mode
+ * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode
+ * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted
+ * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted
+ * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted
+ * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted
+ * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted
+ * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted
+ * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted
+ * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted
+ * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted
+ * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted
+ * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted
+ * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted
+ * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted
+ * @arg DBGMCU_CAN2_STOP: Debug CAN2 stopped when Core is halted
+ * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted
+ * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted
+ * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted
+ * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted
+ * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted
+ * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted
+ * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted
+ * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted
+ * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted
+ * @param NewState: new state of the specified peripheral in Debug mode.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ DBGMCU->CR |= DBGMCU_Periph;
+ }
+ else
+ {
+ DBGMCU->CR &= ~DBGMCU_Periph;
+ }
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_dma.c b/st_fw_lib/src/stm32f10x_dma.c
new file mode 100644
index 0000000..bf072df
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_dma.c
@@ -0,0 +1,714 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_dma.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the DMA firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_dma.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup DMA
+ * @brief DMA driver modules
+ * @{
+ */
+
+/** @defgroup DMA_Private_TypesDefinitions
+ * @{
+ */
+/**
+ * @}
+ */
+
+/** @defgroup DMA_Private_Defines
+ * @{
+ */
+
+
+/* DMA1 Channelx interrupt pending bit masks */
+#define DMA1_Channel1_IT_Mask ((uint32_t)(DMA_ISR_GIF1 | DMA_ISR_TCIF1 | DMA_ISR_HTIF1 | DMA_ISR_TEIF1))
+#define DMA1_Channel2_IT_Mask ((uint32_t)(DMA_ISR_GIF2 | DMA_ISR_TCIF2 | DMA_ISR_HTIF2 | DMA_ISR_TEIF2))
+#define DMA1_Channel3_IT_Mask ((uint32_t)(DMA_ISR_GIF3 | DMA_ISR_TCIF3 | DMA_ISR_HTIF3 | DMA_ISR_TEIF3))
+#define DMA1_Channel4_IT_Mask ((uint32_t)(DMA_ISR_GIF4 | DMA_ISR_TCIF4 | DMA_ISR_HTIF4 | DMA_ISR_TEIF4))
+#define DMA1_Channel5_IT_Mask ((uint32_t)(DMA_ISR_GIF5 | DMA_ISR_TCIF5 | DMA_ISR_HTIF5 | DMA_ISR_TEIF5))
+#define DMA1_Channel6_IT_Mask ((uint32_t)(DMA_ISR_GIF6 | DMA_ISR_TCIF6 | DMA_ISR_HTIF6 | DMA_ISR_TEIF6))
+#define DMA1_Channel7_IT_Mask ((uint32_t)(DMA_ISR_GIF7 | DMA_ISR_TCIF7 | DMA_ISR_HTIF7 | DMA_ISR_TEIF7))
+
+/* DMA2 Channelx interrupt pending bit masks */
+#define DMA2_Channel1_IT_Mask ((uint32_t)(DMA_ISR_GIF1 | DMA_ISR_TCIF1 | DMA_ISR_HTIF1 | DMA_ISR_TEIF1))
+#define DMA2_Channel2_IT_Mask ((uint32_t)(DMA_ISR_GIF2 | DMA_ISR_TCIF2 | DMA_ISR_HTIF2 | DMA_ISR_TEIF2))
+#define DMA2_Channel3_IT_Mask ((uint32_t)(DMA_ISR_GIF3 | DMA_ISR_TCIF3 | DMA_ISR_HTIF3 | DMA_ISR_TEIF3))
+#define DMA2_Channel4_IT_Mask ((uint32_t)(DMA_ISR_GIF4 | DMA_ISR_TCIF4 | DMA_ISR_HTIF4 | DMA_ISR_TEIF4))
+#define DMA2_Channel5_IT_Mask ((uint32_t)(DMA_ISR_GIF5 | DMA_ISR_TCIF5 | DMA_ISR_HTIF5 | DMA_ISR_TEIF5))
+
+/* DMA2 FLAG mask */
+#define FLAG_Mask ((uint32_t)0x10000000)
+
+/* DMA registers Masks */
+#define CCR_CLEAR_Mask ((uint32_t)0xFFFF800F)
+
+/**
+ * @}
+ */
+
+/** @defgroup DMA_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DMA_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DMA_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup DMA_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the DMAy Channelx registers to their default reset
+ * values.
+ * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
+ * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
+ * @retval None
+ */
+void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx)
+{
+ /* Check the parameters */
+ assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
+
+ /* Disable the selected DMAy Channelx */
+ DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR1_EN);
+
+ /* Reset DMAy Channelx control register */
+ DMAy_Channelx->CCR = 0;
+
+ /* Reset DMAy Channelx remaining bytes register */
+ DMAy_Channelx->CNDTR = 0;
+
+ /* Reset DMAy Channelx peripheral address register */
+ DMAy_Channelx->CPAR = 0;
+
+ /* Reset DMAy Channelx memory address register */
+ DMAy_Channelx->CMAR = 0;
+
+ if (DMAy_Channelx == DMA1_Channel1)
+ {
+ /* Reset interrupt pending bits for DMA1 Channel1 */
+ DMA1->IFCR |= DMA1_Channel1_IT_Mask;
+ }
+ else if (DMAy_Channelx == DMA1_Channel2)
+ {
+ /* Reset interrupt pending bits for DMA1 Channel2 */
+ DMA1->IFCR |= DMA1_Channel2_IT_Mask;
+ }
+ else if (DMAy_Channelx == DMA1_Channel3)
+ {
+ /* Reset interrupt pending bits for DMA1 Channel3 */
+ DMA1->IFCR |= DMA1_Channel3_IT_Mask;
+ }
+ else if (DMAy_Channelx == DMA1_Channel4)
+ {
+ /* Reset interrupt pending bits for DMA1 Channel4 */
+ DMA1->IFCR |= DMA1_Channel4_IT_Mask;
+ }
+ else if (DMAy_Channelx == DMA1_Channel5)
+ {
+ /* Reset interrupt pending bits for DMA1 Channel5 */
+ DMA1->IFCR |= DMA1_Channel5_IT_Mask;
+ }
+ else if (DMAy_Channelx == DMA1_Channel6)
+ {
+ /* Reset interrupt pending bits for DMA1 Channel6 */
+ DMA1->IFCR |= DMA1_Channel6_IT_Mask;
+ }
+ else if (DMAy_Channelx == DMA1_Channel7)
+ {
+ /* Reset interrupt pending bits for DMA1 Channel7 */
+ DMA1->IFCR |= DMA1_Channel7_IT_Mask;
+ }
+ else if (DMAy_Channelx == DMA2_Channel1)
+ {
+ /* Reset interrupt pending bits for DMA2 Channel1 */
+ DMA2->IFCR |= DMA2_Channel1_IT_Mask;
+ }
+ else if (DMAy_Channelx == DMA2_Channel2)
+ {
+ /* Reset interrupt pending bits for DMA2 Channel2 */
+ DMA2->IFCR |= DMA2_Channel2_IT_Mask;
+ }
+ else if (DMAy_Channelx == DMA2_Channel3)
+ {
+ /* Reset interrupt pending bits for DMA2 Channel3 */
+ DMA2->IFCR |= DMA2_Channel3_IT_Mask;
+ }
+ else if (DMAy_Channelx == DMA2_Channel4)
+ {
+ /* Reset interrupt pending bits for DMA2 Channel4 */
+ DMA2->IFCR |= DMA2_Channel4_IT_Mask;
+ }
+ else
+ {
+ if (DMAy_Channelx == DMA2_Channel5)
+ {
+ /* Reset interrupt pending bits for DMA2 Channel5 */
+ DMA2->IFCR |= DMA2_Channel5_IT_Mask;
+ }
+ }
+}
+
+/**
+ * @brief Initializes the DMAy Channelx according to the specified
+ * parameters in the DMA_InitStruct.
+ * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
+ * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
+ * @param DMA_InitStruct: pointer to a DMA_InitTypeDef structure that
+ * contains the configuration information for the specified DMA Channel.
+ * @retval None
+ */
+void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct)
+{
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
+ assert_param(IS_DMA_DIR(DMA_InitStruct->DMA_DIR));
+ assert_param(IS_DMA_BUFFER_SIZE(DMA_InitStruct->DMA_BufferSize));
+ assert_param(IS_DMA_PERIPHERAL_INC_STATE(DMA_InitStruct->DMA_PeripheralInc));
+ assert_param(IS_DMA_MEMORY_INC_STATE(DMA_InitStruct->DMA_MemoryInc));
+ assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(DMA_InitStruct->DMA_PeripheralDataSize));
+ assert_param(IS_DMA_MEMORY_DATA_SIZE(DMA_InitStruct->DMA_MemoryDataSize));
+ assert_param(IS_DMA_MODE(DMA_InitStruct->DMA_Mode));
+ assert_param(IS_DMA_PRIORITY(DMA_InitStruct->DMA_Priority));
+ assert_param(IS_DMA_M2M_STATE(DMA_InitStruct->DMA_M2M));
+
+/*--------------------------- DMAy Channelx CCR Configuration -----------------*/
+ /* Get the DMAy_Channelx CCR value */
+ tmpreg = DMAy_Channelx->CCR;
+ /* Clear MEM2MEM, PL, MSIZE, PSIZE, MINC, PINC, CIRC and DIR bits */
+ tmpreg &= CCR_CLEAR_Mask;
+ /* Configure DMAy Channelx: data transfer, data size, priority level and mode */
+ /* Set DIR bit according to DMA_DIR value */
+ /* Set CIRC bit according to DMA_Mode value */
+ /* Set PINC bit according to DMA_PeripheralInc value */
+ /* Set MINC bit according to DMA_MemoryInc value */
+ /* Set PSIZE bits according to DMA_PeripheralDataSize value */
+ /* Set MSIZE bits according to DMA_MemoryDataSize value */
+ /* Set PL bits according to DMA_Priority value */
+ /* Set the MEM2MEM bit according to DMA_M2M value */
+ tmpreg |= DMA_InitStruct->DMA_DIR | DMA_InitStruct->DMA_Mode |
+ DMA_InitStruct->DMA_PeripheralInc | DMA_InitStruct->DMA_MemoryInc |
+ DMA_InitStruct->DMA_PeripheralDataSize | DMA_InitStruct->DMA_MemoryDataSize |
+ DMA_InitStruct->DMA_Priority | DMA_InitStruct->DMA_M2M;
+
+ /* Write to DMAy Channelx CCR */
+ DMAy_Channelx->CCR = tmpreg;
+
+/*--------------------------- DMAy Channelx CNDTR Configuration ---------------*/
+ /* Write to DMAy Channelx CNDTR */
+ DMAy_Channelx->CNDTR = DMA_InitStruct->DMA_BufferSize;
+
+/*--------------------------- DMAy Channelx CPAR Configuration ----------------*/
+ /* Write to DMAy Channelx CPAR */
+ DMAy_Channelx->CPAR = DMA_InitStruct->DMA_PeripheralBaseAddr;
+
+/*--------------------------- DMAy Channelx CMAR Configuration ----------------*/
+ /* Write to DMAy Channelx CMAR */
+ DMAy_Channelx->CMAR = DMA_InitStruct->DMA_MemoryBaseAddr;
+}
+
+/**
+ * @brief Fills each DMA_InitStruct member with its default value.
+ * @param DMA_InitStruct : pointer to a DMA_InitTypeDef structure which will
+ * be initialized.
+ * @retval None
+ */
+void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct)
+{
+/*-------------- Reset DMA init structure parameters values ------------------*/
+ /* Initialize the DMA_PeripheralBaseAddr member */
+ DMA_InitStruct->DMA_PeripheralBaseAddr = 0;
+ /* Initialize the DMA_MemoryBaseAddr member */
+ DMA_InitStruct->DMA_MemoryBaseAddr = 0;
+ /* Initialize the DMA_DIR member */
+ DMA_InitStruct->DMA_DIR = DMA_DIR_PeripheralSRC;
+ /* Initialize the DMA_BufferSize member */
+ DMA_InitStruct->DMA_BufferSize = 0;
+ /* Initialize the DMA_PeripheralInc member */
+ DMA_InitStruct->DMA_PeripheralInc = DMA_PeripheralInc_Disable;
+ /* Initialize the DMA_MemoryInc member */
+ DMA_InitStruct->DMA_MemoryInc = DMA_MemoryInc_Disable;
+ /* Initialize the DMA_PeripheralDataSize member */
+ DMA_InitStruct->DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
+ /* Initialize the DMA_MemoryDataSize member */
+ DMA_InitStruct->DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
+ /* Initialize the DMA_Mode member */
+ DMA_InitStruct->DMA_Mode = DMA_Mode_Normal;
+ /* Initialize the DMA_Priority member */
+ DMA_InitStruct->DMA_Priority = DMA_Priority_Low;
+ /* Initialize the DMA_M2M member */
+ DMA_InitStruct->DMA_M2M = DMA_M2M_Disable;
+}
+
+/**
+ * @brief Enables or disables the specified DMAy Channelx.
+ * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
+ * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
+ * @param NewState: new state of the DMAy Channelx.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void DMA_Cmd(DMA_Channel_TypeDef* DMAy_Channelx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected DMAy Channelx */
+ DMAy_Channelx->CCR |= DMA_CCR1_EN;
+ }
+ else
+ {
+ /* Disable the selected DMAy Channelx */
+ DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR1_EN);
+ }
+}
+
+/**
+ * @brief Enables or disables the specified DMAy Channelx interrupts.
+ * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
+ * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
+ * @param DMA_IT: specifies the DMA interrupts sources to be enabled
+ * or disabled.
+ * This parameter can be any combination of the following values:
+ * @arg DMA_IT_TC: Transfer complete interrupt mask
+ * @arg DMA_IT_HT: Half transfer interrupt mask
+ * @arg DMA_IT_TE: Transfer error interrupt mask
+ * @param NewState: new state of the specified DMA interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
+ assert_param(IS_DMA_CONFIG_IT(DMA_IT));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected DMA interrupts */
+ DMAy_Channelx->CCR |= DMA_IT;
+ }
+ else
+ {
+ /* Disable the selected DMA interrupts */
+ DMAy_Channelx->CCR &= ~DMA_IT;
+ }
+}
+
+/**
+ * @brief Sets the number of data units in the current DMAy Channelx transfer.
+ * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
+ * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
+ * @param DataNumber: The number of data units in the current DMAy Channelx
+ * transfer.
+ * @note This function can only be used when the DMAy_Channelx is disabled.
+ * @retval None.
+ */
+void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t DataNumber)
+{
+ /* Check the parameters */
+ assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
+
+/*--------------------------- DMAy Channelx CNDTR Configuration ---------------*/
+ /* Write to DMAy Channelx CNDTR */
+ DMAy_Channelx->CNDTR = DataNumber;
+}
+
+/**
+ * @brief Returns the number of remaining data units in the current
+ * DMAy Channelx transfer.
+ * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and
+ * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel.
+ * @retval The number of remaining data units in the current DMAy Channelx
+ * transfer.
+ */
+uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx)
+{
+ /* Check the parameters */
+ assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
+ /* Return the number of remaining data units for DMAy Channelx */
+ return ((uint16_t)(DMAy_Channelx->CNDTR));
+}
+
+/**
+ * @brief Checks whether the specified DMAy Channelx flag is set or not.
+ * @param DMAy_FLAG: specifies the flag to check.
+ * This parameter can be one of the following values:
+ * @arg DMA1_FLAG_GL1: DMA1 Channel1 global flag.
+ * @arg DMA1_FLAG_TC1: DMA1 Channel1 transfer complete flag.
+ * @arg DMA1_FLAG_HT1: DMA1 Channel1 half transfer flag.
+ * @arg DMA1_FLAG_TE1: DMA1 Channel1 transfer error flag.
+ * @arg DMA1_FLAG_GL2: DMA1 Channel2 global flag.
+ * @arg DMA1_FLAG_TC2: DMA1 Channel2 transfer complete flag.
+ * @arg DMA1_FLAG_HT2: DMA1 Channel2 half transfer flag.
+ * @arg DMA1_FLAG_TE2: DMA1 Channel2 transfer error flag.
+ * @arg DMA1_FLAG_GL3: DMA1 Channel3 global flag.
+ * @arg DMA1_FLAG_TC3: DMA1 Channel3 transfer complete flag.
+ * @arg DMA1_FLAG_HT3: DMA1 Channel3 half transfer flag.
+ * @arg DMA1_FLAG_TE3: DMA1 Channel3 transfer error flag.
+ * @arg DMA1_FLAG_GL4: DMA1 Channel4 global flag.
+ * @arg DMA1_FLAG_TC4: DMA1 Channel4 transfer complete flag.
+ * @arg DMA1_FLAG_HT4: DMA1 Channel4 half transfer flag.
+ * @arg DMA1_FLAG_TE4: DMA1 Channel4 transfer error flag.
+ * @arg DMA1_FLAG_GL5: DMA1 Channel5 global flag.
+ * @arg DMA1_FLAG_TC5: DMA1 Channel5 transfer complete flag.
+ * @arg DMA1_FLAG_HT5: DMA1 Channel5 half transfer flag.
+ * @arg DMA1_FLAG_TE5: DMA1 Channel5 transfer error flag.
+ * @arg DMA1_FLAG_GL6: DMA1 Channel6 global flag.
+ * @arg DMA1_FLAG_TC6: DMA1 Channel6 transfer complete flag.
+ * @arg DMA1_FLAG_HT6: DMA1 Channel6 half transfer flag.
+ * @arg DMA1_FLAG_TE6: DMA1 Channel6 transfer error flag.
+ * @arg DMA1_FLAG_GL7: DMA1 Channel7 global flag.
+ * @arg DMA1_FLAG_TC7: DMA1 Channel7 transfer complete flag.
+ * @arg DMA1_FLAG_HT7: DMA1 Channel7 half transfer flag.
+ * @arg DMA1_FLAG_TE7: DMA1 Channel7 transfer error flag.
+ * @arg DMA2_FLAG_GL1: DMA2 Channel1 global flag.
+ * @arg DMA2_FLAG_TC1: DMA2 Channel1 transfer complete flag.
+ * @arg DMA2_FLAG_HT1: DMA2 Channel1 half transfer flag.
+ * @arg DMA2_FLAG_TE1: DMA2 Channel1 transfer error flag.
+ * @arg DMA2_FLAG_GL2: DMA2 Channel2 global flag.
+ * @arg DMA2_FLAG_TC2: DMA2 Channel2 transfer complete flag.
+ * @arg DMA2_FLAG_HT2: DMA2 Channel2 half transfer flag.
+ * @arg DMA2_FLAG_TE2: DMA2 Channel2 transfer error flag.
+ * @arg DMA2_FLAG_GL3: DMA2 Channel3 global flag.
+ * @arg DMA2_FLAG_TC3: DMA2 Channel3 transfer complete flag.
+ * @arg DMA2_FLAG_HT3: DMA2 Channel3 half transfer flag.
+ * @arg DMA2_FLAG_TE3: DMA2 Channel3 transfer error flag.
+ * @arg DMA2_FLAG_GL4: DMA2 Channel4 global flag.
+ * @arg DMA2_FLAG_TC4: DMA2 Channel4 transfer complete flag.
+ * @arg DMA2_FLAG_HT4: DMA2 Channel4 half transfer flag.
+ * @arg DMA2_FLAG_TE4: DMA2 Channel4 transfer error flag.
+ * @arg DMA2_FLAG_GL5: DMA2 Channel5 global flag.
+ * @arg DMA2_FLAG_TC5: DMA2 Channel5 transfer complete flag.
+ * @arg DMA2_FLAG_HT5: DMA2 Channel5 half transfer flag.
+ * @arg DMA2_FLAG_TE5: DMA2 Channel5 transfer error flag.
+ * @retval The new state of DMAy_FLAG (SET or RESET).
+ */
+FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_DMA_GET_FLAG(DMAy_FLAG));
+
+ /* Calculate the used DMAy */
+ if ((DMAy_FLAG & FLAG_Mask) != (uint32_t)RESET)
+ {
+ /* Get DMA2 ISR register value */
+ tmpreg = DMA2->ISR ;
+ }
+ else
+ {
+ /* Get DMA1 ISR register value */
+ tmpreg = DMA1->ISR ;
+ }
+
+ /* Check the status of the specified DMAy flag */
+ if ((tmpreg & DMAy_FLAG) != (uint32_t)RESET)
+ {
+ /* DMAy_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* DMAy_FLAG is reset */
+ bitstatus = RESET;
+ }
+
+ /* Return the DMAy_FLAG status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the DMAy Channelx's pending flags.
+ * @param DMAy_FLAG: specifies the flag to clear.
+ * This parameter can be any combination (for the same DMA) of the following values:
+ * @arg DMA1_FLAG_GL1: DMA1 Channel1 global flag.
+ * @arg DMA1_FLAG_TC1: DMA1 Channel1 transfer complete flag.
+ * @arg DMA1_FLAG_HT1: DMA1 Channel1 half transfer flag.
+ * @arg DMA1_FLAG_TE1: DMA1 Channel1 transfer error flag.
+ * @arg DMA1_FLAG_GL2: DMA1 Channel2 global flag.
+ * @arg DMA1_FLAG_TC2: DMA1 Channel2 transfer complete flag.
+ * @arg DMA1_FLAG_HT2: DMA1 Channel2 half transfer flag.
+ * @arg DMA1_FLAG_TE2: DMA1 Channel2 transfer error flag.
+ * @arg DMA1_FLAG_GL3: DMA1 Channel3 global flag.
+ * @arg DMA1_FLAG_TC3: DMA1 Channel3 transfer complete flag.
+ * @arg DMA1_FLAG_HT3: DMA1 Channel3 half transfer flag.
+ * @arg DMA1_FLAG_TE3: DMA1 Channel3 transfer error flag.
+ * @arg DMA1_FLAG_GL4: DMA1 Channel4 global flag.
+ * @arg DMA1_FLAG_TC4: DMA1 Channel4 transfer complete flag.
+ * @arg DMA1_FLAG_HT4: DMA1 Channel4 half transfer flag.
+ * @arg DMA1_FLAG_TE4: DMA1 Channel4 transfer error flag.
+ * @arg DMA1_FLAG_GL5: DMA1 Channel5 global flag.
+ * @arg DMA1_FLAG_TC5: DMA1 Channel5 transfer complete flag.
+ * @arg DMA1_FLAG_HT5: DMA1 Channel5 half transfer flag.
+ * @arg DMA1_FLAG_TE5: DMA1 Channel5 transfer error flag.
+ * @arg DMA1_FLAG_GL6: DMA1 Channel6 global flag.
+ * @arg DMA1_FLAG_TC6: DMA1 Channel6 transfer complete flag.
+ * @arg DMA1_FLAG_HT6: DMA1 Channel6 half transfer flag.
+ * @arg DMA1_FLAG_TE6: DMA1 Channel6 transfer error flag.
+ * @arg DMA1_FLAG_GL7: DMA1 Channel7 global flag.
+ * @arg DMA1_FLAG_TC7: DMA1 Channel7 transfer complete flag.
+ * @arg DMA1_FLAG_HT7: DMA1 Channel7 half transfer flag.
+ * @arg DMA1_FLAG_TE7: DMA1 Channel7 transfer error flag.
+ * @arg DMA2_FLAG_GL1: DMA2 Channel1 global flag.
+ * @arg DMA2_FLAG_TC1: DMA2 Channel1 transfer complete flag.
+ * @arg DMA2_FLAG_HT1: DMA2 Channel1 half transfer flag.
+ * @arg DMA2_FLAG_TE1: DMA2 Channel1 transfer error flag.
+ * @arg DMA2_FLAG_GL2: DMA2 Channel2 global flag.
+ * @arg DMA2_FLAG_TC2: DMA2 Channel2 transfer complete flag.
+ * @arg DMA2_FLAG_HT2: DMA2 Channel2 half transfer flag.
+ * @arg DMA2_FLAG_TE2: DMA2 Channel2 transfer error flag.
+ * @arg DMA2_FLAG_GL3: DMA2 Channel3 global flag.
+ * @arg DMA2_FLAG_TC3: DMA2 Channel3 transfer complete flag.
+ * @arg DMA2_FLAG_HT3: DMA2 Channel3 half transfer flag.
+ * @arg DMA2_FLAG_TE3: DMA2 Channel3 transfer error flag.
+ * @arg DMA2_FLAG_GL4: DMA2 Channel4 global flag.
+ * @arg DMA2_FLAG_TC4: DMA2 Channel4 transfer complete flag.
+ * @arg DMA2_FLAG_HT4: DMA2 Channel4 half transfer flag.
+ * @arg DMA2_FLAG_TE4: DMA2 Channel4 transfer error flag.
+ * @arg DMA2_FLAG_GL5: DMA2 Channel5 global flag.
+ * @arg DMA2_FLAG_TC5: DMA2 Channel5 transfer complete flag.
+ * @arg DMA2_FLAG_HT5: DMA2 Channel5 half transfer flag.
+ * @arg DMA2_FLAG_TE5: DMA2 Channel5 transfer error flag.
+ * @retval None
+ */
+void DMA_ClearFlag(uint32_t DMAy_FLAG)
+{
+ /* Check the parameters */
+ assert_param(IS_DMA_CLEAR_FLAG(DMAy_FLAG));
+
+ /* Calculate the used DMAy */
+ if ((DMAy_FLAG & FLAG_Mask) != (uint32_t)RESET)
+ {
+ /* Clear the selected DMAy flags */
+ DMA2->IFCR = DMAy_FLAG;
+ }
+ else
+ {
+ /* Clear the selected DMAy flags */
+ DMA1->IFCR = DMAy_FLAG;
+ }
+}
+
+/**
+ * @brief Checks whether the specified DMAy Channelx interrupt has occurred or not.
+ * @param DMAy_IT: specifies the DMAy interrupt source to check.
+ * This parameter can be one of the following values:
+ * @arg DMA1_IT_GL1: DMA1 Channel1 global interrupt.
+ * @arg DMA1_IT_TC1: DMA1 Channel1 transfer complete interrupt.
+ * @arg DMA1_IT_HT1: DMA1 Channel1 half transfer interrupt.
+ * @arg DMA1_IT_TE1: DMA1 Channel1 transfer error interrupt.
+ * @arg DMA1_IT_GL2: DMA1 Channel2 global interrupt.
+ * @arg DMA1_IT_TC2: DMA1 Channel2 transfer complete interrupt.
+ * @arg DMA1_IT_HT2: DMA1 Channel2 half transfer interrupt.
+ * @arg DMA1_IT_TE2: DMA1 Channel2 transfer error interrupt.
+ * @arg DMA1_IT_GL3: DMA1 Channel3 global interrupt.
+ * @arg DMA1_IT_TC3: DMA1 Channel3 transfer complete interrupt.
+ * @arg DMA1_IT_HT3: DMA1 Channel3 half transfer interrupt.
+ * @arg DMA1_IT_TE3: DMA1 Channel3 transfer error interrupt.
+ * @arg DMA1_IT_GL4: DMA1 Channel4 global interrupt.
+ * @arg DMA1_IT_TC4: DMA1 Channel4 transfer complete interrupt.
+ * @arg DMA1_IT_HT4: DMA1 Channel4 half transfer interrupt.
+ * @arg DMA1_IT_TE4: DMA1 Channel4 transfer error interrupt.
+ * @arg DMA1_IT_GL5: DMA1 Channel5 global interrupt.
+ * @arg DMA1_IT_TC5: DMA1 Channel5 transfer complete interrupt.
+ * @arg DMA1_IT_HT5: DMA1 Channel5 half transfer interrupt.
+ * @arg DMA1_IT_TE5: DMA1 Channel5 transfer error interrupt.
+ * @arg DMA1_IT_GL6: DMA1 Channel6 global interrupt.
+ * @arg DMA1_IT_TC6: DMA1 Channel6 transfer complete interrupt.
+ * @arg DMA1_IT_HT6: DMA1 Channel6 half transfer interrupt.
+ * @arg DMA1_IT_TE6: DMA1 Channel6 transfer error interrupt.
+ * @arg DMA1_IT_GL7: DMA1 Channel7 global interrupt.
+ * @arg DMA1_IT_TC7: DMA1 Channel7 transfer complete interrupt.
+ * @arg DMA1_IT_HT7: DMA1 Channel7 half transfer interrupt.
+ * @arg DMA1_IT_TE7: DMA1 Channel7 transfer error interrupt.
+ * @arg DMA2_IT_GL1: DMA2 Channel1 global interrupt.
+ * @arg DMA2_IT_TC1: DMA2 Channel1 transfer complete interrupt.
+ * @arg DMA2_IT_HT1: DMA2 Channel1 half transfer interrupt.
+ * @arg DMA2_IT_TE1: DMA2 Channel1 transfer error interrupt.
+ * @arg DMA2_IT_GL2: DMA2 Channel2 global interrupt.
+ * @arg DMA2_IT_TC2: DMA2 Channel2 transfer complete interrupt.
+ * @arg DMA2_IT_HT2: DMA2 Channel2 half transfer interrupt.
+ * @arg DMA2_IT_TE2: DMA2 Channel2 transfer error interrupt.
+ * @arg DMA2_IT_GL3: DMA2 Channel3 global interrupt.
+ * @arg DMA2_IT_TC3: DMA2 Channel3 transfer complete interrupt.
+ * @arg DMA2_IT_HT3: DMA2 Channel3 half transfer interrupt.
+ * @arg DMA2_IT_TE3: DMA2 Channel3 transfer error interrupt.
+ * @arg DMA2_IT_GL4: DMA2 Channel4 global interrupt.
+ * @arg DMA2_IT_TC4: DMA2 Channel4 transfer complete interrupt.
+ * @arg DMA2_IT_HT4: DMA2 Channel4 half transfer interrupt.
+ * @arg DMA2_IT_TE4: DMA2 Channel4 transfer error interrupt.
+ * @arg DMA2_IT_GL5: DMA2 Channel5 global interrupt.
+ * @arg DMA2_IT_TC5: DMA2 Channel5 transfer complete interrupt.
+ * @arg DMA2_IT_HT5: DMA2 Channel5 half transfer interrupt.
+ * @arg DMA2_IT_TE5: DMA2 Channel5 transfer error interrupt.
+ * @retval The new state of DMAy_IT (SET or RESET).
+ */
+ITStatus DMA_GetITStatus(uint32_t DMAy_IT)
+{
+ ITStatus bitstatus = RESET;
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_DMA_GET_IT(DMAy_IT));
+
+ /* Calculate the used DMA */
+ if ((DMAy_IT & FLAG_Mask) != (uint32_t)RESET)
+ {
+ /* Get DMA2 ISR register value */
+ tmpreg = DMA2->ISR;
+ }
+ else
+ {
+ /* Get DMA1 ISR register value */
+ tmpreg = DMA1->ISR;
+ }
+
+ /* Check the status of the specified DMAy interrupt */
+ if ((tmpreg & DMAy_IT) != (uint32_t)RESET)
+ {
+ /* DMAy_IT is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* DMAy_IT is reset */
+ bitstatus = RESET;
+ }
+ /* Return the DMA_IT status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the DMAy Channelx's interrupt pending bits.
+ * @param DMAy_IT: specifies the DMAy interrupt pending bit to clear.
+ * This parameter can be any combination (for the same DMA) of the following values:
+ * @arg DMA1_IT_GL1: DMA1 Channel1 global interrupt.
+ * @arg DMA1_IT_TC1: DMA1 Channel1 transfer complete interrupt.
+ * @arg DMA1_IT_HT1: DMA1 Channel1 half transfer interrupt.
+ * @arg DMA1_IT_TE1: DMA1 Channel1 transfer error interrupt.
+ * @arg DMA1_IT_GL2: DMA1 Channel2 global interrupt.
+ * @arg DMA1_IT_TC2: DMA1 Channel2 transfer complete interrupt.
+ * @arg DMA1_IT_HT2: DMA1 Channel2 half transfer interrupt.
+ * @arg DMA1_IT_TE2: DMA1 Channel2 transfer error interrupt.
+ * @arg DMA1_IT_GL3: DMA1 Channel3 global interrupt.
+ * @arg DMA1_IT_TC3: DMA1 Channel3 transfer complete interrupt.
+ * @arg DMA1_IT_HT3: DMA1 Channel3 half transfer interrupt.
+ * @arg DMA1_IT_TE3: DMA1 Channel3 transfer error interrupt.
+ * @arg DMA1_IT_GL4: DMA1 Channel4 global interrupt.
+ * @arg DMA1_IT_TC4: DMA1 Channel4 transfer complete interrupt.
+ * @arg DMA1_IT_HT4: DMA1 Channel4 half transfer interrupt.
+ * @arg DMA1_IT_TE4: DMA1 Channel4 transfer error interrupt.
+ * @arg DMA1_IT_GL5: DMA1 Channel5 global interrupt.
+ * @arg DMA1_IT_TC5: DMA1 Channel5 transfer complete interrupt.
+ * @arg DMA1_IT_HT5: DMA1 Channel5 half transfer interrupt.
+ * @arg DMA1_IT_TE5: DMA1 Channel5 transfer error interrupt.
+ * @arg DMA1_IT_GL6: DMA1 Channel6 global interrupt.
+ * @arg DMA1_IT_TC6: DMA1 Channel6 transfer complete interrupt.
+ * @arg DMA1_IT_HT6: DMA1 Channel6 half transfer interrupt.
+ * @arg DMA1_IT_TE6: DMA1 Channel6 transfer error interrupt.
+ * @arg DMA1_IT_GL7: DMA1 Channel7 global interrupt.
+ * @arg DMA1_IT_TC7: DMA1 Channel7 transfer complete interrupt.
+ * @arg DMA1_IT_HT7: DMA1 Channel7 half transfer interrupt.
+ * @arg DMA1_IT_TE7: DMA1 Channel7 transfer error interrupt.
+ * @arg DMA2_IT_GL1: DMA2 Channel1 global interrupt.
+ * @arg DMA2_IT_TC1: DMA2 Channel1 transfer complete interrupt.
+ * @arg DMA2_IT_HT1: DMA2 Channel1 half transfer interrupt.
+ * @arg DMA2_IT_TE1: DMA2 Channel1 transfer error interrupt.
+ * @arg DMA2_IT_GL2: DMA2 Channel2 global interrupt.
+ * @arg DMA2_IT_TC2: DMA2 Channel2 transfer complete interrupt.
+ * @arg DMA2_IT_HT2: DMA2 Channel2 half transfer interrupt.
+ * @arg DMA2_IT_TE2: DMA2 Channel2 transfer error interrupt.
+ * @arg DMA2_IT_GL3: DMA2 Channel3 global interrupt.
+ * @arg DMA2_IT_TC3: DMA2 Channel3 transfer complete interrupt.
+ * @arg DMA2_IT_HT3: DMA2 Channel3 half transfer interrupt.
+ * @arg DMA2_IT_TE3: DMA2 Channel3 transfer error interrupt.
+ * @arg DMA2_IT_GL4: DMA2 Channel4 global interrupt.
+ * @arg DMA2_IT_TC4: DMA2 Channel4 transfer complete interrupt.
+ * @arg DMA2_IT_HT4: DMA2 Channel4 half transfer interrupt.
+ * @arg DMA2_IT_TE4: DMA2 Channel4 transfer error interrupt.
+ * @arg DMA2_IT_GL5: DMA2 Channel5 global interrupt.
+ * @arg DMA2_IT_TC5: DMA2 Channel5 transfer complete interrupt.
+ * @arg DMA2_IT_HT5: DMA2 Channel5 half transfer interrupt.
+ * @arg DMA2_IT_TE5: DMA2 Channel5 transfer error interrupt.
+ * @retval None
+ */
+void DMA_ClearITPendingBit(uint32_t DMAy_IT)
+{
+ /* Check the parameters */
+ assert_param(IS_DMA_CLEAR_IT(DMAy_IT));
+
+ /* Calculate the used DMAy */
+ if ((DMAy_IT & FLAG_Mask) != (uint32_t)RESET)
+ {
+ /* Clear the selected DMAy interrupt pending bits */
+ DMA2->IFCR = DMAy_IT;
+ }
+ else
+ {
+ /* Clear the selected DMAy interrupt pending bits */
+ DMA1->IFCR = DMAy_IT;
+ }
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_exti.c b/st_fw_lib/src/stm32f10x_exti.c
new file mode 100644
index 0000000..b6290d5
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_exti.c
@@ -0,0 +1,269 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_exti.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the EXTI firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_exti.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup EXTI
+ * @brief EXTI driver modules
+ * @{
+ */
+
+/** @defgroup EXTI_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup EXTI_Private_Defines
+ * @{
+ */
+
+#define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */
+
+/**
+ * @}
+ */
+
+/** @defgroup EXTI_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup EXTI_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup EXTI_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup EXTI_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the EXTI peripheral registers to their default reset values.
+ * @param None
+ * @retval None
+ */
+void EXTI_DeInit(void)
+{
+ EXTI->IMR = 0x00000000;
+ EXTI->EMR = 0x00000000;
+ EXTI->RTSR = 0x00000000;
+ EXTI->FTSR = 0x00000000;
+ EXTI->PR = 0x000FFFFF;
+}
+
+/**
+ * @brief Initializes the EXTI peripheral according to the specified
+ * parameters in the EXTI_InitStruct.
+ * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure
+ * that contains the configuration information for the EXTI peripheral.
+ * @retval None
+ */
+void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct)
+{
+ uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode));
+ assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger));
+ assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line));
+ assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd));
+
+ tmp = (uint32_t)EXTI_BASE;
+
+ if (EXTI_InitStruct->EXTI_LineCmd != DISABLE)
+ {
+ /* Clear EXTI line configuration */
+ EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line;
+ EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line;
+
+ tmp += EXTI_InitStruct->EXTI_Mode;
+
+ *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
+
+ /* Clear Rising Falling edge configuration */
+ EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line;
+ EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line;
+
+ /* Select the trigger for the selected external interrupts */
+ if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling)
+ {
+ /* Rising Falling edge */
+ EXTI->RTSR |= EXTI_InitStruct->EXTI_Line;
+ EXTI->FTSR |= EXTI_InitStruct->EXTI_Line;
+ }
+ else
+ {
+ tmp = (uint32_t)EXTI_BASE;
+ tmp += EXTI_InitStruct->EXTI_Trigger;
+
+ *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line;
+ }
+ }
+ else
+ {
+ tmp += EXTI_InitStruct->EXTI_Mode;
+
+ /* Disable the selected external lines */
+ *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line;
+ }
+}
+
+/**
+ * @brief Fills each EXTI_InitStruct member with its reset value.
+ * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will
+ * be initialized.
+ * @retval None
+ */
+void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct)
+{
+ EXTI_InitStruct->EXTI_Line = EXTI_LINENONE;
+ EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
+ EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling;
+ EXTI_InitStruct->EXTI_LineCmd = DISABLE;
+}
+
+/**
+ * @brief Generates a Software interrupt.
+ * @param EXTI_Line: specifies the EXTI lines to be enabled or disabled.
+ * This parameter can be any combination of EXTI_Linex where x can be (0..19).
+ * @retval None
+ */
+void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
+{
+ /* Check the parameters */
+ assert_param(IS_EXTI_LINE(EXTI_Line));
+
+ EXTI->SWIER |= EXTI_Line;
+}
+
+/**
+ * @brief Checks whether the specified EXTI line flag is set or not.
+ * @param EXTI_Line: specifies the EXTI line flag to check.
+ * This parameter can be:
+ * @arg EXTI_Linex: External interrupt line x where x(0..19)
+ * @retval The new state of EXTI_Line (SET or RESET).
+ */
+FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_GET_EXTI_LINE(EXTI_Line));
+
+ if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the EXTI's line pending flags.
+ * @param EXTI_Line: specifies the EXTI lines flags to clear.
+ * This parameter can be any combination of EXTI_Linex where x can be (0..19).
+ * @retval None
+ */
+void EXTI_ClearFlag(uint32_t EXTI_Line)
+{
+ /* Check the parameters */
+ assert_param(IS_EXTI_LINE(EXTI_Line));
+
+ EXTI->PR = EXTI_Line;
+}
+
+/**
+ * @brief Checks whether the specified EXTI line is asserted or not.
+ * @param EXTI_Line: specifies the EXTI line to check.
+ * This parameter can be:
+ * @arg EXTI_Linex: External interrupt line x where x(0..19)
+ * @retval The new state of EXTI_Line (SET or RESET).
+ */
+ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
+{
+ ITStatus bitstatus = RESET;
+ uint32_t enablestatus = 0;
+ /* Check the parameters */
+ assert_param(IS_GET_EXTI_LINE(EXTI_Line));
+
+ enablestatus = EXTI->IMR & EXTI_Line;
+ if (((EXTI->PR & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET))
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the EXTI's line pending bits.
+ * @param EXTI_Line: specifies the EXTI lines to clear.
+ * This parameter can be any combination of EXTI_Linex where x can be (0..19).
+ * @retval None
+ */
+void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
+{
+ /* Check the parameters */
+ assert_param(IS_EXTI_LINE(EXTI_Line));
+
+ EXTI->PR = EXTI_Line;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_flash.c b/st_fw_lib/src/stm32f10x_flash.c
new file mode 100644
index 0000000..cdff9e9
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_flash.c
@@ -0,0 +1,1684 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_flash.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the FLASH firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_flash.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup FLASH
+ * @brief FLASH driver modules
+ * @{
+ */
+
+/** @defgroup FLASH_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FLASH_Private_Defines
+ * @{
+ */
+
+/* Flash Access Control Register bits */
+#define ACR_LATENCY_Mask ((uint32_t)0x00000038)
+#define ACR_HLFCYA_Mask ((uint32_t)0xFFFFFFF7)
+#define ACR_PRFTBE_Mask ((uint32_t)0xFFFFFFEF)
+
+/* Flash Access Control Register bits */
+#define ACR_PRFTBS_Mask ((uint32_t)0x00000020)
+
+/* Flash Control Register bits */
+#define CR_PG_Set ((uint32_t)0x00000001)
+#define CR_PG_Reset ((uint32_t)0x00001FFE)
+#define CR_PER_Set ((uint32_t)0x00000002)
+#define CR_PER_Reset ((uint32_t)0x00001FFD)
+#define CR_MER_Set ((uint32_t)0x00000004)
+#define CR_MER_Reset ((uint32_t)0x00001FFB)
+#define CR_OPTPG_Set ((uint32_t)0x00000010)
+#define CR_OPTPG_Reset ((uint32_t)0x00001FEF)
+#define CR_OPTER_Set ((uint32_t)0x00000020)
+#define CR_OPTER_Reset ((uint32_t)0x00001FDF)
+#define CR_STRT_Set ((uint32_t)0x00000040)
+#define CR_LOCK_Set ((uint32_t)0x00000080)
+
+/* FLASH Mask */
+#define RDPRT_Mask ((uint32_t)0x00000002)
+#define WRP0_Mask ((uint32_t)0x000000FF)
+#define WRP1_Mask ((uint32_t)0x0000FF00)
+#define WRP2_Mask ((uint32_t)0x00FF0000)
+#define WRP3_Mask ((uint32_t)0xFF000000)
+#define OB_USER_BFB2 ((uint16_t)0x0008)
+
+/* FLASH Keys */
+#define RDP_Key ((uint16_t)0x00A5)
+#define FLASH_KEY1 ((uint32_t)0x45670123)
+#define FLASH_KEY2 ((uint32_t)0xCDEF89AB)
+
+/* FLASH BANK address */
+#define FLASH_BANK1_END_ADDRESS ((uint32_t)0x807FFFF)
+
+/* Delay definition */
+#define EraseTimeout ((uint32_t)0x000B0000)
+#define ProgramTimeout ((uint32_t)0x00002000)
+/**
+ * @}
+ */
+
+/** @defgroup FLASH_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FLASH_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FLASH_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FLASH_Private_Functions
+ * @{
+ */
+
+/**
+@code
+
+ This driver provides functions to configure and program the Flash memory of all STM32F10x devices,
+ including the latest STM32F10x_XL density devices.
+
+ STM32F10x_XL devices feature up to 1 Mbyte with dual bank architecture for read-while-write (RWW) capability:
+ - bank1: fixed size of 512 Kbytes (256 pages of 2Kbytes each)
+ - bank2: up to 512 Kbytes (up to 256 pages of 2Kbytes each)
+ While other STM32F10x devices features only one bank with memory up to 512 Kbytes.
+
+ In version V3.3.0, some functions were updated and new ones were added to support
+ STM32F10x_XL devices. Thus some functions manages all devices, while other are
+ dedicated for XL devices only.
+
+ The table below presents the list of available functions depending on the used STM32F10x devices.
+
+ ***************************************************
+ * Legacy functions used for all STM32F10x devices *
+ ***************************************************
+ +----------------------------------------------------------------------------------------------------------------------------------+
+ | Functions prototypes |STM32F10x_XL|Other STM32F10x| Comments |
+ | | devices | devices | |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_SetLatency | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_HalfCycleAccessCmd | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_PrefetchBufferCmd | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_Unlock | Yes | Yes | - For STM32F10X_XL devices: unlock Bank1 and Bank2. |
+ | | | | - For other devices: unlock Bank1 and it is equivalent |
+ | | | | to FLASH_UnlockBank1 function. |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_Lock | Yes | Yes | - For STM32F10X_XL devices: lock Bank1 and Bank2. |
+ | | | | - For other devices: lock Bank1 and it is equivalent |
+ | | | | to FLASH_LockBank1 function. |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_ErasePage | Yes | Yes | - For STM32F10x_XL devices: erase a page in Bank1 and Bank2 |
+ | | | | - For other devices: erase a page in Bank1 |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_EraseAllPages | Yes | Yes | - For STM32F10x_XL devices: erase all pages in Bank1 and Bank2 |
+ | | | | - For other devices: erase all pages in Bank1 |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_EraseOptionBytes | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_ProgramWord | Yes | Yes | Updated to program up to 1MByte (depending on the used device) |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_ProgramHalfWord | Yes | Yes | Updated to program up to 1MByte (depending on the used device) |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_ProgramOptionByteData | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_EnableWriteProtection | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_ReadOutProtection | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_UserOptionByteConfig | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_GetUserOptionByte | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_GetWriteProtectionOptionByte | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_GetReadOutProtectionStatus | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_GetPrefetchBufferStatus | Yes | Yes | No change |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_ITConfig | Yes | Yes | - For STM32F10x_XL devices: enable Bank1 and Bank2's interrupts|
+ | | | | - For other devices: enable Bank1's interrupts |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_GetFlagStatus | Yes | Yes | - For STM32F10x_XL devices: return Bank1 and Bank2's flag status|
+ | | | | - For other devices: return Bank1's flag status |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_ClearFlag | Yes | Yes | - For STM32F10x_XL devices: clear Bank1 and Bank2's flag |
+ | | | | - For other devices: clear Bank1's flag |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_GetStatus | Yes | Yes | - Return the status of Bank1 (for all devices) |
+ | | | | equivalent to FLASH_GetBank1Status function |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_WaitForLastOperation | Yes | Yes | - Wait for Bank1 last operation (for all devices) |
+ | | | | equivalent to: FLASH_WaitForLastBank1Operation function |
+ +----------------------------------------------------------------------------------------------------------------------------------+
+
+ ************************************************************************************************************************
+ * New functions used for all STM32F10x devices to manage Bank1: *
+ * - These functions are mainly useful for STM32F10x_XL density devices, to have separate control for Bank1 and bank2 *
+ * - For other devices, these functions are optional (covered by functions listed above) *
+ ************************************************************************************************************************
+ +----------------------------------------------------------------------------------------------------------------------------------+
+ | Functions prototypes |STM32F10x_XL|Other STM32F10x| Comments |
+ | | devices | devices | |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ | FLASH_UnlockBank1 | Yes | Yes | - Unlock Bank1 |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_LockBank1 | Yes | Yes | - Lock Bank1 |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ | FLASH_EraseAllBank1Pages | Yes | Yes | - Erase all pages in Bank1 |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ | FLASH_GetBank1Status | Yes | Yes | - Return the status of Bank1 |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ | FLASH_WaitForLastBank1Operation | Yes | Yes | - Wait for Bank1 last operation |
+ +----------------------------------------------------------------------------------------------------------------------------------+
+
+ *****************************************************************************
+ * New Functions used only with STM32F10x_XL density devices to manage Bank2 *
+ *****************************************************************************
+ +----------------------------------------------------------------------------------------------------------------------------------+
+ | Functions prototypes |STM32F10x_XL|Other STM32F10x| Comments |
+ | | devices | devices | |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ | FLASH_UnlockBank2 | Yes | No | - Unlock Bank2 |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ |FLASH_LockBank2 | Yes | No | - Lock Bank2 |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ | FLASH_EraseAllBank2Pages | Yes | No | - Erase all pages in Bank2 |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ | FLASH_GetBank2Status | Yes | No | - Return the status of Bank2 |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ | FLASH_WaitForLastBank2Operation | Yes | No | - Wait for Bank2 last operation |
+ |----------------------------------------------------------------------------------------------------------------------------------|
+ | FLASH_BootConfig | Yes | No | - Configure to boot from Bank1 or Bank2 |
+ +----------------------------------------------------------------------------------------------------------------------------------+
+@endcode
+*/
+
+
+/**
+ * @brief Sets the code latency value.
+ * @note This function can be used for all STM32F10x devices.
+ * @param FLASH_Latency: specifies the FLASH Latency value.
+ * This parameter can be one of the following values:
+ * @arg FLASH_Latency_0: FLASH Zero Latency cycle
+ * @arg FLASH_Latency_1: FLASH One Latency cycle
+ * @arg FLASH_Latency_2: FLASH Two Latency cycles
+ * @retval None
+ */
+void FLASH_SetLatency(uint32_t FLASH_Latency)
+{
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_FLASH_LATENCY(FLASH_Latency));
+
+ /* Read the ACR register */
+ tmpreg = FLASH->ACR;
+
+ /* Sets the Latency value */
+ tmpreg &= ACR_LATENCY_Mask;
+ tmpreg |= FLASH_Latency;
+
+ /* Write the ACR register */
+ FLASH->ACR = tmpreg;
+}
+
+/**
+ * @brief Enables or disables the Half cycle flash access.
+ * @note This function can be used for all STM32F10x devices.
+ * @param FLASH_HalfCycleAccess: specifies the FLASH Half cycle Access mode.
+ * This parameter can be one of the following values:
+ * @arg FLASH_HalfCycleAccess_Enable: FLASH Half Cycle Enable
+ * @arg FLASH_HalfCycleAccess_Disable: FLASH Half Cycle Disable
+ * @retval None
+ */
+void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess)
+{
+ /* Check the parameters */
+ assert_param(IS_FLASH_HALFCYCLEACCESS_STATE(FLASH_HalfCycleAccess));
+
+ /* Enable or disable the Half cycle access */
+ FLASH->ACR &= ACR_HLFCYA_Mask;
+ FLASH->ACR |= FLASH_HalfCycleAccess;
+}
+
+/**
+ * @brief Enables or disables the Prefetch Buffer.
+ * @note This function can be used for all STM32F10x devices.
+ * @param FLASH_PrefetchBuffer: specifies the Prefetch buffer status.
+ * This parameter can be one of the following values:
+ * @arg FLASH_PrefetchBuffer_Enable: FLASH Prefetch Buffer Enable
+ * @arg FLASH_PrefetchBuffer_Disable: FLASH Prefetch Buffer Disable
+ * @retval None
+ */
+void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer)
+{
+ /* Check the parameters */
+ assert_param(IS_FLASH_PREFETCHBUFFER_STATE(FLASH_PrefetchBuffer));
+
+ /* Enable or disable the Prefetch Buffer */
+ FLASH->ACR &= ACR_PRFTBE_Mask;
+ FLASH->ACR |= FLASH_PrefetchBuffer;
+}
+
+/**
+ * @brief Unlocks the FLASH Program Erase Controller.
+ * @note This function can be used for all STM32F10x devices.
+ * - For STM32F10X_XL devices this function unlocks Bank1 and Bank2.
+ * - For all other devices it unlocks Bank1 and it is equivalent
+ * to FLASH_UnlockBank1 function..
+ * @param None
+ * @retval None
+ */
+void FLASH_Unlock(void)
+{
+ /* Authorize the FPEC of Bank1 Access */
+ FLASH->KEYR = FLASH_KEY1;
+ FLASH->KEYR = FLASH_KEY2;
+
+#ifdef STM32F10X_XL
+ /* Authorize the FPEC of Bank2 Access */
+ FLASH->KEYR2 = FLASH_KEY1;
+ FLASH->KEYR2 = FLASH_KEY2;
+#endif /* STM32F10X_XL */
+}
+/**
+ * @brief Unlocks the FLASH Bank1 Program Erase Controller.
+ * @note This function can be used for all STM32F10x devices.
+ * - For STM32F10X_XL devices this function unlocks Bank1.
+ * - For all other devices it unlocks Bank1 and it is
+ * equivalent to FLASH_Unlock function.
+ * @param None
+ * @retval None
+ */
+void FLASH_UnlockBank1(void)
+{
+ /* Authorize the FPEC of Bank1 Access */
+ FLASH->KEYR = FLASH_KEY1;
+ FLASH->KEYR = FLASH_KEY2;
+}
+
+#ifdef STM32F10X_XL
+/**
+ * @brief Unlocks the FLASH Bank2 Program Erase Controller.
+ * @note This function can be used only for STM32F10X_XL density devices.
+ * @param None
+ * @retval None
+ */
+void FLASH_UnlockBank2(void)
+{
+ /* Authorize the FPEC of Bank2 Access */
+ FLASH->KEYR2 = FLASH_KEY1;
+ FLASH->KEYR2 = FLASH_KEY2;
+
+}
+#endif /* STM32F10X_XL */
+
+/**
+ * @brief Locks the FLASH Program Erase Controller.
+ * @note This function can be used for all STM32F10x devices.
+ * - For STM32F10X_XL devices this function Locks Bank1 and Bank2.
+ * - For all other devices it Locks Bank1 and it is equivalent
+ * to FLASH_LockBank1 function.
+ * @param None
+ * @retval None
+ */
+void FLASH_Lock(void)
+{
+ /* Set the Lock Bit to lock the FPEC and the CR of Bank1 */
+ FLASH->CR |= CR_LOCK_Set;
+
+#ifdef STM32F10X_XL
+ /* Set the Lock Bit to lock the FPEC and the CR of Bank2 */
+ FLASH->CR2 |= CR_LOCK_Set;
+#endif /* STM32F10X_XL */
+}
+
+/**
+ * @brief Locks the FLASH Bank1 Program Erase Controller.
+ * @note this function can be used for all STM32F10x devices.
+ * - For STM32F10X_XL devices this function Locks Bank1.
+ * - For all other devices it Locks Bank1 and it is equivalent
+ * to FLASH_Lock function.
+ * @param None
+ * @retval None
+ */
+void FLASH_LockBank1(void)
+{
+ /* Set the Lock Bit to lock the FPEC and the CR of Bank1 */
+ FLASH->CR |= CR_LOCK_Set;
+}
+
+#ifdef STM32F10X_XL
+/**
+ * @brief Locks the FLASH Bank2 Program Erase Controller.
+ * @note This function can be used only for STM32F10X_XL density devices.
+ * @param None
+ * @retval None
+ */
+void FLASH_LockBank2(void)
+{
+ /* Set the Lock Bit to lock the FPEC and the CR of Bank2 */
+ FLASH->CR2 |= CR_LOCK_Set;
+}
+#endif /* STM32F10X_XL */
+
+/**
+ * @brief Erases a specified FLASH page.
+ * @note This function can be used for all STM32F10x devices.
+ * @param Page_Address: The page address to be erased.
+ * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_ErasePage(uint32_t Page_Address)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+ /* Check the parameters */
+ assert_param(IS_FLASH_ADDRESS(Page_Address));
+
+#ifdef STM32F10X_XL
+ if(Page_Address < FLASH_BANK1_END_ADDRESS)
+ {
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank1Operation(EraseTimeout);
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to erase the page */
+ FLASH->CR|= CR_PER_Set;
+ FLASH->AR = Page_Address;
+ FLASH->CR|= CR_STRT_Set;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank1Operation(EraseTimeout);
+
+ /* Disable the PER Bit */
+ FLASH->CR &= CR_PER_Reset;
+ }
+ }
+ else
+ {
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(EraseTimeout);
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to erase the page */
+ FLASH->CR2|= CR_PER_Set;
+ FLASH->AR2 = Page_Address;
+ FLASH->CR2|= CR_STRT_Set;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(EraseTimeout);
+
+ /* Disable the PER Bit */
+ FLASH->CR2 &= CR_PER_Reset;
+ }
+ }
+#else
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(EraseTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to erase the page */
+ FLASH->CR|= CR_PER_Set;
+ FLASH->AR = Page_Address;
+ FLASH->CR|= CR_STRT_Set;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(EraseTimeout);
+
+ /* Disable the PER Bit */
+ FLASH->CR &= CR_PER_Reset;
+ }
+#endif /* STM32F10X_XL */
+
+ /* Return the Erase Status */
+ return status;
+}
+
+/**
+ * @brief Erases all FLASH pages.
+ * @note This function can be used for all STM32F10x devices.
+ * @param None
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_EraseAllPages(void)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+
+#ifdef STM32F10X_XL
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank1Operation(EraseTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to erase all pages */
+ FLASH->CR |= CR_MER_Set;
+ FLASH->CR |= CR_STRT_Set;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank1Operation(EraseTimeout);
+
+ /* Disable the MER Bit */
+ FLASH->CR &= CR_MER_Reset;
+ }
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to erase all pages */
+ FLASH->CR2 |= CR_MER_Set;
+ FLASH->CR2 |= CR_STRT_Set;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(EraseTimeout);
+
+ /* Disable the MER Bit */
+ FLASH->CR2 &= CR_MER_Reset;
+ }
+#else
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(EraseTimeout);
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to erase all pages */
+ FLASH->CR |= CR_MER_Set;
+ FLASH->CR |= CR_STRT_Set;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(EraseTimeout);
+
+ /* Disable the MER Bit */
+ FLASH->CR &= CR_MER_Reset;
+ }
+#endif /* STM32F10X_XL */
+
+ /* Return the Erase Status */
+ return status;
+}
+
+/**
+ * @brief Erases all Bank1 FLASH pages.
+ * @note This function can be used for all STM32F10x devices.
+ * - For STM32F10X_XL devices this function erases all Bank1 pages.
+ * - For all other devices it erases all Bank1 pages and it is equivalent
+ * to FLASH_EraseAllPages function.
+ * @param None
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_EraseAllBank1Pages(void)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank1Operation(EraseTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to erase all pages */
+ FLASH->CR |= CR_MER_Set;
+ FLASH->CR |= CR_STRT_Set;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank1Operation(EraseTimeout);
+
+ /* Disable the MER Bit */
+ FLASH->CR &= CR_MER_Reset;
+ }
+ /* Return the Erase Status */
+ return status;
+}
+
+#ifdef STM32F10X_XL
+/**
+ * @brief Erases all Bank2 FLASH pages.
+ * @note This function can be used only for STM32F10x_XL density devices.
+ * @param None
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_EraseAllBank2Pages(void)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(EraseTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to erase all pages */
+ FLASH->CR2 |= CR_MER_Set;
+ FLASH->CR2 |= CR_STRT_Set;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(EraseTimeout);
+
+ /* Disable the MER Bit */
+ FLASH->CR2 &= CR_MER_Reset;
+ }
+ /* Return the Erase Status */
+ return status;
+}
+#endif /* STM32F10X_XL */
+
+/**
+ * @brief Erases the FLASH option bytes.
+ * @note This functions erases all option bytes except the Read protection (RDP).
+ * @note This function can be used for all STM32F10x devices.
+ * @param None
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_EraseOptionBytes(void)
+{
+ uint16_t rdptmp = RDP_Key;
+
+ FLASH_Status status = FLASH_COMPLETE;
+
+ /* Get the actual read protection Option Byte value */
+ if(FLASH_GetReadOutProtectionStatus() != RESET)
+ {
+ rdptmp = 0x00;
+ }
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(EraseTimeout);
+ if(status == FLASH_COMPLETE)
+ {
+ /* Authorize the small information block programming */
+ FLASH->OPTKEYR = FLASH_KEY1;
+ FLASH->OPTKEYR = FLASH_KEY2;
+
+ /* if the previous operation is completed, proceed to erase the option bytes */
+ FLASH->CR |= CR_OPTER_Set;
+ FLASH->CR |= CR_STRT_Set;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(EraseTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the erase operation is completed, disable the OPTER Bit */
+ FLASH->CR &= CR_OPTER_Reset;
+
+ /* Enable the Option Bytes Programming operation */
+ FLASH->CR |= CR_OPTPG_Set;
+ /* Restore the last read protection Option Byte value */
+ OB->RDP = (uint16_t)rdptmp;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ if(status != FLASH_TIMEOUT)
+ {
+ /* if the program operation is completed, disable the OPTPG Bit */
+ FLASH->CR &= CR_OPTPG_Reset;
+ }
+ }
+ else
+ {
+ if (status != FLASH_TIMEOUT)
+ {
+ /* Disable the OPTPG Bit */
+ FLASH->CR &= CR_OPTPG_Reset;
+ }
+ }
+ }
+ /* Return the erase status */
+ return status;
+}
+
+/**
+ * @brief Programs a word at a specified address.
+ * @note This function can be used for all STM32F10x devices.
+ * @param Address: specifies the address to be programmed.
+ * @param Data: specifies the data to be programmed.
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+ __IO uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_FLASH_ADDRESS(Address));
+
+#ifdef STM32F10X_XL
+ if(Address < FLASH_BANK1_END_ADDRESS - 2)
+ {
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank1Operation(ProgramTimeout);
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new first
+ half word */
+ FLASH->CR |= CR_PG_Set;
+
+ *(__IO uint16_t*)Address = (uint16_t)Data;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new second
+ half word */
+ tmp = Address + 2;
+
+ *(__IO uint16_t*) tmp = Data >> 16;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ /* Disable the PG Bit */
+ FLASH->CR &= CR_PG_Reset;
+ }
+ else
+ {
+ /* Disable the PG Bit */
+ FLASH->CR &= CR_PG_Reset;
+ }
+ }
+ }
+ else if(Address == (FLASH_BANK1_END_ADDRESS - 1))
+ {
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank1Operation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new first
+ half word */
+ FLASH->CR |= CR_PG_Set;
+
+ *(__IO uint16_t*)Address = (uint16_t)Data;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank1Operation(ProgramTimeout);
+
+ /* Disable the PG Bit */
+ FLASH->CR &= CR_PG_Reset;
+ }
+ else
+ {
+ /* Disable the PG Bit */
+ FLASH->CR &= CR_PG_Reset;
+ }
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new second
+ half word */
+ FLASH->CR2 |= CR_PG_Set;
+ tmp = Address + 2;
+
+ *(__IO uint16_t*) tmp = Data >> 16;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(ProgramTimeout);
+
+ /* Disable the PG Bit */
+ FLASH->CR2 &= CR_PG_Reset;
+ }
+ else
+ {
+ /* Disable the PG Bit */
+ FLASH->CR2 &= CR_PG_Reset;
+ }
+ }
+ else
+ {
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new first
+ half word */
+ FLASH->CR2 |= CR_PG_Set;
+
+ *(__IO uint16_t*)Address = (uint16_t)Data;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new second
+ half word */
+ tmp = Address + 2;
+
+ *(__IO uint16_t*) tmp = Data >> 16;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(ProgramTimeout);
+
+ /* Disable the PG Bit */
+ FLASH->CR2 &= CR_PG_Reset;
+ }
+ else
+ {
+ /* Disable the PG Bit */
+ FLASH->CR2 &= CR_PG_Reset;
+ }
+ }
+ }
+#else
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new first
+ half word */
+ FLASH->CR |= CR_PG_Set;
+
+ *(__IO uint16_t*)Address = (uint16_t)Data;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new second
+ half word */
+ tmp = Address + 2;
+
+ *(__IO uint16_t*) tmp = Data >> 16;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ /* Disable the PG Bit */
+ FLASH->CR &= CR_PG_Reset;
+ }
+ else
+ {
+ /* Disable the PG Bit */
+ FLASH->CR &= CR_PG_Reset;
+ }
+ }
+#endif /* STM32F10X_XL */
+
+ /* Return the Program Status */
+ return status;
+}
+
+/**
+ * @brief Programs a half word at a specified address.
+ * @note This function can be used for all STM32F10x devices.
+ * @param Address: specifies the address to be programmed.
+ * @param Data: specifies the data to be programmed.
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+ /* Check the parameters */
+ assert_param(IS_FLASH_ADDRESS(Address));
+
+#ifdef STM32F10X_XL
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ if(Address < FLASH_BANK1_END_ADDRESS)
+ {
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new data */
+ FLASH->CR |= CR_PG_Set;
+
+ *(__IO uint16_t*)Address = Data;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank1Operation(ProgramTimeout);
+
+ /* Disable the PG Bit */
+ FLASH->CR &= CR_PG_Reset;
+ }
+ }
+ else
+ {
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new data */
+ FLASH->CR2 |= CR_PG_Set;
+
+ *(__IO uint16_t*)Address = Data;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastBank2Operation(ProgramTimeout);
+
+ /* Disable the PG Bit */
+ FLASH->CR2 &= CR_PG_Reset;
+ }
+ }
+#else
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the previous operation is completed, proceed to program the new data */
+ FLASH->CR |= CR_PG_Set;
+
+ *(__IO uint16_t*)Address = Data;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ /* Disable the PG Bit */
+ FLASH->CR &= CR_PG_Reset;
+ }
+#endif /* STM32F10X_XL */
+
+ /* Return the Program Status */
+ return status;
+}
+
+/**
+ * @brief Programs a half word at a specified Option Byte Data address.
+ * @note This function can be used for all STM32F10x devices.
+ * @param Address: specifies the address to be programmed.
+ * This parameter can be 0x1FFFF804 or 0x1FFFF806.
+ * @param Data: specifies the data to be programmed.
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+ /* Check the parameters */
+ assert_param(IS_OB_DATA_ADDRESS(Address));
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* Authorize the small information block programming */
+ FLASH->OPTKEYR = FLASH_KEY1;
+ FLASH->OPTKEYR = FLASH_KEY2;
+ /* Enables the Option Bytes Programming operation */
+ FLASH->CR |= CR_OPTPG_Set;
+ *(__IO uint16_t*)Address = Data;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+ if(status != FLASH_TIMEOUT)
+ {
+ /* if the program operation is completed, disable the OPTPG Bit */
+ FLASH->CR &= CR_OPTPG_Reset;
+ }
+ }
+ /* Return the Option Byte Data Program Status */
+ return status;
+}
+
+/**
+ * @brief Write protects the desired pages
+ * @note This function can be used for all STM32F10x devices.
+ * @param FLASH_Pages: specifies the address of the pages to be write protected.
+ * This parameter can be:
+ * @arg For @b STM32_Low-density_devices: value between FLASH_WRProt_Pages0to3 and FLASH_WRProt_Pages28to31
+ * @arg For @b STM32_Medium-density_devices: value between FLASH_WRProt_Pages0to3
+ * and FLASH_WRProt_Pages124to127
+ * @arg For @b STM32_High-density_devices: value between FLASH_WRProt_Pages0to1 and
+ * FLASH_WRProt_Pages60to61 or FLASH_WRProt_Pages62to255
+ * @arg For @b STM32_Connectivity_line_devices: value between FLASH_WRProt_Pages0to1 and
+ * FLASH_WRProt_Pages60to61 or FLASH_WRProt_Pages62to127
+ * @arg For @b STM32_XL-density_devices: value between FLASH_WRProt_Pages0to1 and
+ * FLASH_WRProt_Pages60to61 or FLASH_WRProt_Pages62to511
+ * @arg FLASH_WRProt_AllPages
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_EnableWriteProtection(uint32_t FLASH_Pages)
+{
+ uint16_t WRP0_Data = 0xFFFF, WRP1_Data = 0xFFFF, WRP2_Data = 0xFFFF, WRP3_Data = 0xFFFF;
+
+ FLASH_Status status = FLASH_COMPLETE;
+
+ /* Check the parameters */
+ assert_param(IS_FLASH_WRPROT_PAGE(FLASH_Pages));
+
+ FLASH_Pages = (uint32_t)(~FLASH_Pages);
+ WRP0_Data = (uint16_t)(FLASH_Pages & WRP0_Mask);
+ WRP1_Data = (uint16_t)((FLASH_Pages & WRP1_Mask) >> 8);
+ WRP2_Data = (uint16_t)((FLASH_Pages & WRP2_Mask) >> 16);
+ WRP3_Data = (uint16_t)((FLASH_Pages & WRP3_Mask) >> 24);
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* Authorizes the small information block programming */
+ FLASH->OPTKEYR = FLASH_KEY1;
+ FLASH->OPTKEYR = FLASH_KEY2;
+ FLASH->CR |= CR_OPTPG_Set;
+ if(WRP0_Data != 0xFF)
+ {
+ OB->WRP0 = WRP0_Data;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+ }
+ if((status == FLASH_COMPLETE) && (WRP1_Data != 0xFF))
+ {
+ OB->WRP1 = WRP1_Data;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+ }
+ if((status == FLASH_COMPLETE) && (WRP2_Data != 0xFF))
+ {
+ OB->WRP2 = WRP2_Data;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+ }
+
+ if((status == FLASH_COMPLETE)&& (WRP3_Data != 0xFF))
+ {
+ OB->WRP3 = WRP3_Data;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+ }
+
+ if(status != FLASH_TIMEOUT)
+ {
+ /* if the program operation is completed, disable the OPTPG Bit */
+ FLASH->CR &= CR_OPTPG_Reset;
+ }
+ }
+ /* Return the write protection operation Status */
+ return status;
+}
+
+/**
+ * @brief Enables or disables the read out protection.
+ * @note If the user has already programmed the other option bytes before calling
+ * this function, he must re-program them since this function erases all option bytes.
+ * @note This function can be used for all STM32F10x devices.
+ * @param Newstate: new state of the ReadOut Protection.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ status = FLASH_WaitForLastOperation(EraseTimeout);
+ if(status == FLASH_COMPLETE)
+ {
+ /* Authorizes the small information block programming */
+ FLASH->OPTKEYR = FLASH_KEY1;
+ FLASH->OPTKEYR = FLASH_KEY2;
+ FLASH->CR |= CR_OPTER_Set;
+ FLASH->CR |= CR_STRT_Set;
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(EraseTimeout);
+ if(status == FLASH_COMPLETE)
+ {
+ /* if the erase operation is completed, disable the OPTER Bit */
+ FLASH->CR &= CR_OPTER_Reset;
+ /* Enable the Option Bytes Programming operation */
+ FLASH->CR |= CR_OPTPG_Set;
+ if(NewState != DISABLE)
+ {
+ OB->RDP = 0x00;
+ }
+ else
+ {
+ OB->RDP = RDP_Key;
+ }
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(EraseTimeout);
+
+ if(status != FLASH_TIMEOUT)
+ {
+ /* if the program operation is completed, disable the OPTPG Bit */
+ FLASH->CR &= CR_OPTPG_Reset;
+ }
+ }
+ else
+ {
+ if(status != FLASH_TIMEOUT)
+ {
+ /* Disable the OPTER Bit */
+ FLASH->CR &= CR_OPTER_Reset;
+ }
+ }
+ }
+ /* Return the protection operation Status */
+ return status;
+}
+
+/**
+ * @brief Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.
+ * @note This function can be used for all STM32F10x devices.
+ * @param OB_IWDG: Selects the IWDG mode
+ * This parameter can be one of the following values:
+ * @arg OB_IWDG_SW: Software IWDG selected
+ * @arg OB_IWDG_HW: Hardware IWDG selected
+ * @param OB_STOP: Reset event when entering STOP mode.
+ * This parameter can be one of the following values:
+ * @arg OB_STOP_NoRST: No reset generated when entering in STOP
+ * @arg OB_STOP_RST: Reset generated when entering in STOP
+ * @param OB_STDBY: Reset event when entering Standby mode.
+ * This parameter can be one of the following values:
+ * @arg OB_STDBY_NoRST: No reset generated when entering in STANDBY
+ * @arg OB_STDBY_RST: Reset generated when entering in STANDBY
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_UserOptionByteConfig(uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+
+ /* Check the parameters */
+ assert_param(IS_OB_IWDG_SOURCE(OB_IWDG));
+ assert_param(IS_OB_STOP_SOURCE(OB_STOP));
+ assert_param(IS_OB_STDBY_SOURCE(OB_STDBY));
+
+ /* Authorize the small information block programming */
+ FLASH->OPTKEYR = FLASH_KEY1;
+ FLASH->OPTKEYR = FLASH_KEY2;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* Enable the Option Bytes Programming operation */
+ FLASH->CR |= CR_OPTPG_Set;
+
+ OB->USER = OB_IWDG | (uint16_t)(OB_STOP | (uint16_t)(OB_STDBY | ((uint16_t)0xF8)));
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+ if(status != FLASH_TIMEOUT)
+ {
+ /* if the program operation is completed, disable the OPTPG Bit */
+ FLASH->CR &= CR_OPTPG_Reset;
+ }
+ }
+ /* Return the Option Byte program Status */
+ return status;
+}
+
+#ifdef STM32F10X_XL
+/**
+ * @brief Configures to boot from Bank1 or Bank2.
+ * @note This function can be used only for STM32F10x_XL density devices.
+ * @param FLASH_BOOT: select the FLASH Bank to boot from.
+ * This parameter can be one of the following values:
+ * @arg FLASH_BOOT_Bank1: At startup, if boot pins are set in boot from user Flash
+ * position and this parameter is selected the device will boot from Bank1(Default).
+ * @arg FLASH_BOOT_Bank2: At startup, if boot pins are set in boot from user Flash
+ * position and this parameter is selected the device will boot from Bank2 or Bank1,
+ * depending on the activation of the bank. The active banks are checked in
+ * the following order: Bank2, followed by Bank1.
+ * The active bank is recognized by the value programmed at the base address
+ * of the respective bank (corresponding to the initial stack pointer value
+ * in the interrupt vector table).
+ * For more information, please refer to AN2606 from www.st.com.
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_BootConfig(uint16_t FLASH_BOOT)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+ assert_param(IS_FLASH_BOOT(FLASH_BOOT));
+ /* Authorize the small information block programming */
+ FLASH->OPTKEYR = FLASH_KEY1;
+ FLASH->OPTKEYR = FLASH_KEY2;
+
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+
+ if(status == FLASH_COMPLETE)
+ {
+ /* Enable the Option Bytes Programming operation */
+ FLASH->CR |= CR_OPTPG_Set;
+
+ if(FLASH_BOOT == FLASH_BOOT_Bank1)
+ {
+ OB->USER |= OB_USER_BFB2;
+ }
+ else
+ {
+ OB->USER &= (uint16_t)(~(uint16_t)(OB_USER_BFB2));
+ }
+ /* Wait for last operation to be completed */
+ status = FLASH_WaitForLastOperation(ProgramTimeout);
+ if(status != FLASH_TIMEOUT)
+ {
+ /* if the program operation is completed, disable the OPTPG Bit */
+ FLASH->CR &= CR_OPTPG_Reset;
+ }
+ }
+ /* Return the Option Byte program Status */
+ return status;
+}
+#endif /* STM32F10X_XL */
+
+/**
+ * @brief Returns the FLASH User Option Bytes values.
+ * @note This function can be used for all STM32F10x devices.
+ * @param None
+ * @retval The FLASH User Option Bytes values:IWDG_SW(Bit0), RST_STOP(Bit1)
+ * and RST_STDBY(Bit2).
+ */
+uint32_t FLASH_GetUserOptionByte(void)
+{
+ /* Return the User Option Byte */
+ return (uint32_t)(FLASH->OBR >> 2);
+}
+
+/**
+ * @brief Returns the FLASH Write Protection Option Bytes Register value.
+ * @note This function can be used for all STM32F10x devices.
+ * @param None
+ * @retval The FLASH Write Protection Option Bytes Register value
+ */
+uint32_t FLASH_GetWriteProtectionOptionByte(void)
+{
+ /* Return the Flash write protection Register value */
+ return (uint32_t)(FLASH->WRPR);
+}
+
+/**
+ * @brief Checks whether the FLASH Read Out Protection Status is set or not.
+ * @note This function can be used for all STM32F10x devices.
+ * @param None
+ * @retval FLASH ReadOut Protection Status(SET or RESET)
+ */
+FlagStatus FLASH_GetReadOutProtectionStatus(void)
+{
+ FlagStatus readoutstatus = RESET;
+ if ((FLASH->OBR & RDPRT_Mask) != (uint32_t)RESET)
+ {
+ readoutstatus = SET;
+ }
+ else
+ {
+ readoutstatus = RESET;
+ }
+ return readoutstatus;
+}
+
+/**
+ * @brief Checks whether the FLASH Prefetch Buffer status is set or not.
+ * @note This function can be used for all STM32F10x devices.
+ * @param None
+ * @retval FLASH Prefetch Buffer Status (SET or RESET).
+ */
+FlagStatus FLASH_GetPrefetchBufferStatus(void)
+{
+ FlagStatus bitstatus = RESET;
+
+ if ((FLASH->ACR & ACR_PRFTBS_Mask) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ /* Return the new state of FLASH Prefetch Buffer Status (SET or RESET) */
+ return bitstatus;
+}
+
+/**
+ * @brief Enables or disables the specified FLASH interrupts.
+ * @note This function can be used for all STM32F10x devices.
+ * - For STM32F10X_XL devices, enables or disables the specified FLASH interrupts
+ for Bank1 and Bank2.
+ * - For other devices it enables or disables the specified FLASH interrupts for Bank1.
+ * @param FLASH_IT: specifies the FLASH interrupt sources to be enabled or disabled.
+ * This parameter can be any combination of the following values:
+ * @arg FLASH_IT_ERROR: FLASH Error Interrupt
+ * @arg FLASH_IT_EOP: FLASH end of operation Interrupt
+ * @param NewState: new state of the specified Flash interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState)
+{
+#ifdef STM32F10X_XL
+ /* Check the parameters */
+ assert_param(IS_FLASH_IT(FLASH_IT));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if((FLASH_IT & 0x80000000) != 0x0)
+ {
+ if(NewState != DISABLE)
+ {
+ /* Enable the interrupt sources */
+ FLASH->CR2 |= (FLASH_IT & 0x7FFFFFFF);
+ }
+ else
+ {
+ /* Disable the interrupt sources */
+ FLASH->CR2 &= ~(uint32_t)(FLASH_IT & 0x7FFFFFFF);
+ }
+ }
+ else
+ {
+ if(NewState != DISABLE)
+ {
+ /* Enable the interrupt sources */
+ FLASH->CR |= FLASH_IT;
+ }
+ else
+ {
+ /* Disable the interrupt sources */
+ FLASH->CR &= ~(uint32_t)FLASH_IT;
+ }
+ }
+#else
+ /* Check the parameters */
+ assert_param(IS_FLASH_IT(FLASH_IT));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if(NewState != DISABLE)
+ {
+ /* Enable the interrupt sources */
+ FLASH->CR |= FLASH_IT;
+ }
+ else
+ {
+ /* Disable the interrupt sources */
+ FLASH->CR &= ~(uint32_t)FLASH_IT;
+ }
+#endif /* STM32F10X_XL */
+}
+
+/**
+ * @brief Checks whether the specified FLASH flag is set or not.
+ * @note This function can be used for all STM32F10x devices.
+ * - For STM32F10X_XL devices, this function checks whether the specified
+ * Bank1 or Bank2 flag is set or not.
+ * - For other devices, it checks whether the specified Bank1 flag is
+ * set or not.
+ * @param FLASH_FLAG: specifies the FLASH flag to check.
+ * This parameter can be one of the following values:
+ * @arg FLASH_FLAG_BSY: FLASH Busy flag
+ * @arg FLASH_FLAG_PGERR: FLASH Program error flag
+ * @arg FLASH_FLAG_WRPRTERR: FLASH Write protected error flag
+ * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
+ * @arg FLASH_FLAG_OPTERR: FLASH Option Byte error flag
+ * @retval The new state of FLASH_FLAG (SET or RESET).
+ */
+FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+
+#ifdef STM32F10X_XL
+ /* Check the parameters */
+ assert_param(IS_FLASH_GET_FLAG(FLASH_FLAG)) ;
+ if(FLASH_FLAG == FLASH_FLAG_OPTERR)
+ {
+ if((FLASH->OBR & FLASH_FLAG_OPTERR) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ }
+ else
+ {
+ if((FLASH_FLAG & 0x80000000) != 0x0)
+ {
+ if((FLASH->SR2 & FLASH_FLAG) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ }
+ else
+ {
+ if((FLASH->SR & FLASH_FLAG) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ }
+ }
+#else
+ /* Check the parameters */
+ assert_param(IS_FLASH_GET_FLAG(FLASH_FLAG)) ;
+ if(FLASH_FLAG == FLASH_FLAG_OPTERR)
+ {
+ if((FLASH->OBR & FLASH_FLAG_OPTERR) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ }
+ else
+ {
+ if((FLASH->SR & FLASH_FLAG) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ }
+#endif /* STM32F10X_XL */
+
+ /* Return the new state of FLASH_FLAG (SET or RESET) */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the FLASH's pending flags.
+ * @note This function can be used for all STM32F10x devices.
+ * - For STM32F10X_XL devices, this function clears Bank1 or Bank2s pending flags
+ * - For other devices, it clears Bank1s pending flags.
+ * @param FLASH_FLAG: specifies the FLASH flags to clear.
+ * This parameter can be any combination of the following values:
+ * @arg FLASH_FLAG_PGERR: FLASH Program error flag
+ * @arg FLASH_FLAG_WRPRTERR: FLASH Write protected error flag
+ * @arg FLASH_FLAG_EOP: FLASH End of Operation flag
+ * @retval None
+ */
+void FLASH_ClearFlag(uint32_t FLASH_FLAG)
+{
+#ifdef STM32F10X_XL
+ /* Check the parameters */
+ assert_param(IS_FLASH_CLEAR_FLAG(FLASH_FLAG)) ;
+
+ if((FLASH_FLAG & 0x80000000) != 0x0)
+ {
+ /* Clear the flags */
+ FLASH->SR2 = FLASH_FLAG;
+ }
+ else
+ {
+ /* Clear the flags */
+ FLASH->SR = FLASH_FLAG;
+ }
+
+#else
+ /* Check the parameters */
+ assert_param(IS_FLASH_CLEAR_FLAG(FLASH_FLAG)) ;
+
+ /* Clear the flags */
+ FLASH->SR = FLASH_FLAG;
+#endif /* STM32F10X_XL */
+}
+
+/**
+ * @brief Returns the FLASH Status.
+ * @note This function can be used for all STM32F10x devices, it is equivalent
+ * to FLASH_GetBank1Status function.
+ * @param None
+ * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP or FLASH_COMPLETE
+ */
+FLASH_Status FLASH_GetStatus(void)
+{
+ FLASH_Status flashstatus = FLASH_COMPLETE;
+
+ if((FLASH->SR & FLASH_FLAG_BSY) == FLASH_FLAG_BSY)
+ {
+ flashstatus = FLASH_BUSY;
+ }
+ else
+ {
+ if((FLASH->SR & FLASH_FLAG_PGERR) != 0)
+ {
+ flashstatus = FLASH_ERROR_PG;
+ }
+ else
+ {
+ if((FLASH->SR & FLASH_FLAG_WRPRTERR) != 0 )
+ {
+ flashstatus = FLASH_ERROR_WRP;
+ }
+ else
+ {
+ flashstatus = FLASH_COMPLETE;
+ }
+ }
+ }
+ /* Return the Flash Status */
+ return flashstatus;
+}
+
+/**
+ * @brief Returns the FLASH Bank1 Status.
+ * @note This function can be used for all STM32F10x devices, it is equivalent
+ * to FLASH_GetStatus function.
+ * @param None
+ * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP or FLASH_COMPLETE
+ */
+FLASH_Status FLASH_GetBank1Status(void)
+{
+ FLASH_Status flashstatus = FLASH_COMPLETE;
+
+ if((FLASH->SR & FLASH_FLAG_BANK1_BSY) == FLASH_FLAG_BSY)
+ {
+ flashstatus = FLASH_BUSY;
+ }
+ else
+ {
+ if((FLASH->SR & FLASH_FLAG_BANK1_PGERR) != 0)
+ {
+ flashstatus = FLASH_ERROR_PG;
+ }
+ else
+ {
+ if((FLASH->SR & FLASH_FLAG_BANK1_WRPRTERR) != 0 )
+ {
+ flashstatus = FLASH_ERROR_WRP;
+ }
+ else
+ {
+ flashstatus = FLASH_COMPLETE;
+ }
+ }
+ }
+ /* Return the Flash Status */
+ return flashstatus;
+}
+
+#ifdef STM32F10X_XL
+/**
+ * @brief Returns the FLASH Bank2 Status.
+ * @note This function can be used for STM32F10x_XL density devices.
+ * @param None
+ * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP or FLASH_COMPLETE
+ */
+FLASH_Status FLASH_GetBank2Status(void)
+{
+ FLASH_Status flashstatus = FLASH_COMPLETE;
+
+ if((FLASH->SR2 & (FLASH_FLAG_BANK2_BSY & 0x7FFFFFFF)) == (FLASH_FLAG_BANK2_BSY & 0x7FFFFFFF))
+ {
+ flashstatus = FLASH_BUSY;
+ }
+ else
+ {
+ if((FLASH->SR2 & (FLASH_FLAG_BANK2_PGERR & 0x7FFFFFFF)) != 0)
+ {
+ flashstatus = FLASH_ERROR_PG;
+ }
+ else
+ {
+ if((FLASH->SR2 & (FLASH_FLAG_BANK2_WRPRTERR & 0x7FFFFFFF)) != 0 )
+ {
+ flashstatus = FLASH_ERROR_WRP;
+ }
+ else
+ {
+ flashstatus = FLASH_COMPLETE;
+ }
+ }
+ }
+ /* Return the Flash Status */
+ return flashstatus;
+}
+#endif /* STM32F10X_XL */
+/**
+ * @brief Waits for a Flash operation to complete or a TIMEOUT to occur.
+ * @note This function can be used for all STM32F10x devices,
+ * it is equivalent to FLASH_WaitForLastBank1Operation.
+ * - For STM32F10X_XL devices this function waits for a Bank1 Flash operation
+ * to complete or a TIMEOUT to occur.
+ * - For all other devices it waits for a Flash operation to complete
+ * or a TIMEOUT to occur.
+ * @param Timeout: FLASH programming Timeout
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+
+ /* Check for the Flash Status */
+ status = FLASH_GetBank1Status();
+ /* Wait for a Flash operation to complete or a TIMEOUT to occur */
+ while((status == FLASH_BUSY) && (Timeout != 0x00))
+ {
+ status = FLASH_GetBank1Status();
+ Timeout--;
+ }
+ if(Timeout == 0x00 )
+ {
+ status = FLASH_TIMEOUT;
+ }
+ /* Return the operation status */
+ return status;
+}
+
+/**
+ * @brief Waits for a Flash operation on Bank1 to complete or a TIMEOUT to occur.
+ * @note This function can be used for all STM32F10x devices,
+ * it is equivalent to FLASH_WaitForLastOperation.
+ * @param Timeout: FLASH programming Timeout
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+
+ /* Check for the Flash Status */
+ status = FLASH_GetBank1Status();
+ /* Wait for a Flash operation to complete or a TIMEOUT to occur */
+ while((status == FLASH_FLAG_BANK1_BSY) && (Timeout != 0x00))
+ {
+ status = FLASH_GetBank1Status();
+ Timeout--;
+ }
+ if(Timeout == 0x00 )
+ {
+ status = FLASH_TIMEOUT;
+ }
+ /* Return the operation status */
+ return status;
+}
+
+#ifdef STM32F10X_XL
+/**
+ * @brief Waits for a Flash operation on Bank2 to complete or a TIMEOUT to occur.
+ * @note This function can be used only for STM32F10x_XL density devices.
+ * @param Timeout: FLASH programming Timeout
+ * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
+ * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
+ */
+FLASH_Status FLASH_WaitForLastBank2Operation(uint32_t Timeout)
+{
+ FLASH_Status status = FLASH_COMPLETE;
+
+ /* Check for the Flash Status */
+ status = FLASH_GetBank2Status();
+ /* Wait for a Flash operation to complete or a TIMEOUT to occur */
+ while((status == (FLASH_FLAG_BANK2_BSY & 0x7FFFFFFF)) && (Timeout != 0x00))
+ {
+ status = FLASH_GetBank2Status();
+ Timeout--;
+ }
+ if(Timeout == 0x00 )
+ {
+ status = FLASH_TIMEOUT;
+ }
+ /* Return the operation status */
+ return status;
+}
+#endif /* STM32F10X_XL */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_fsmc.c b/st_fw_lib/src/stm32f10x_fsmc.c
new file mode 100644
index 0000000..51669ee
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_fsmc.c
@@ -0,0 +1,866 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_fsmc.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the FSMC firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_fsmc.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup FSMC
+ * @brief FSMC driver modules
+ * @{
+ */
+
+/** @defgroup FSMC_Private_TypesDefinitions
+ * @{
+ */
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Private_Defines
+ * @{
+ */
+
+/* --------------------- FSMC registers bit mask ---------------------------- */
+
+/* FSMC BCRx Mask */
+#define BCR_MBKEN_Set ((uint32_t)0x00000001)
+#define BCR_MBKEN_Reset ((uint32_t)0x000FFFFE)
+#define BCR_FACCEN_Set ((uint32_t)0x00000040)
+
+/* FSMC PCRx Mask */
+#define PCR_PBKEN_Set ((uint32_t)0x00000004)
+#define PCR_PBKEN_Reset ((uint32_t)0x000FFFFB)
+#define PCR_ECCEN_Set ((uint32_t)0x00000040)
+#define PCR_ECCEN_Reset ((uint32_t)0x000FFFBF)
+#define PCR_MemoryType_NAND ((uint32_t)0x00000008)
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup FSMC_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the FSMC NOR/SRAM Banks registers to their default
+ * reset values.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank1_NORSRAM1: FSMC Bank1 NOR/SRAM1
+ * @arg FSMC_Bank1_NORSRAM2: FSMC Bank1 NOR/SRAM2
+ * @arg FSMC_Bank1_NORSRAM3: FSMC Bank1 NOR/SRAM3
+ * @arg FSMC_Bank1_NORSRAM4: FSMC Bank1 NOR/SRAM4
+ * @retval None
+ */
+void FSMC_NORSRAMDeInit(uint32_t FSMC_Bank)
+{
+ /* Check the parameter */
+ assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank));
+
+ /* FSMC_Bank1_NORSRAM1 */
+ if(FSMC_Bank == FSMC_Bank1_NORSRAM1)
+ {
+ FSMC_Bank1->BTCR[FSMC_Bank] = 0x000030DB;
+ }
+ /* FSMC_Bank1_NORSRAM2, FSMC_Bank1_NORSRAM3 or FSMC_Bank1_NORSRAM4 */
+ else
+ {
+ FSMC_Bank1->BTCR[FSMC_Bank] = 0x000030D2;
+ }
+ FSMC_Bank1->BTCR[FSMC_Bank + 1] = 0x0FFFFFFF;
+ FSMC_Bank1E->BWTR[FSMC_Bank] = 0x0FFFFFFF;
+}
+
+/**
+ * @brief Deinitializes the FSMC NAND Banks registers to their default reset values.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
+ * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
+ * @retval None
+ */
+void FSMC_NANDDeInit(uint32_t FSMC_Bank)
+{
+ /* Check the parameter */
+ assert_param(IS_FSMC_NAND_BANK(FSMC_Bank));
+
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ /* Set the FSMC_Bank2 registers to their reset values */
+ FSMC_Bank2->PCR2 = 0x00000018;
+ FSMC_Bank2->SR2 = 0x00000040;
+ FSMC_Bank2->PMEM2 = 0xFCFCFCFC;
+ FSMC_Bank2->PATT2 = 0xFCFCFCFC;
+ }
+ /* FSMC_Bank3_NAND */
+ else
+ {
+ /* Set the FSMC_Bank3 registers to their reset values */
+ FSMC_Bank3->PCR3 = 0x00000018;
+ FSMC_Bank3->SR3 = 0x00000040;
+ FSMC_Bank3->PMEM3 = 0xFCFCFCFC;
+ FSMC_Bank3->PATT3 = 0xFCFCFCFC;
+ }
+}
+
+/**
+ * @brief Deinitializes the FSMC PCCARD Bank registers to their default reset values.
+ * @param None
+ * @retval None
+ */
+void FSMC_PCCARDDeInit(void)
+{
+ /* Set the FSMC_Bank4 registers to their reset values */
+ FSMC_Bank4->PCR4 = 0x00000018;
+ FSMC_Bank4->SR4 = 0x00000000;
+ FSMC_Bank4->PMEM4 = 0xFCFCFCFC;
+ FSMC_Bank4->PATT4 = 0xFCFCFCFC;
+ FSMC_Bank4->PIO4 = 0xFCFCFCFC;
+}
+
+/**
+ * @brief Initializes the FSMC NOR/SRAM Banks according to the specified
+ * parameters in the FSMC_NORSRAMInitStruct.
+ * @param FSMC_NORSRAMInitStruct : pointer to a FSMC_NORSRAMInitTypeDef
+ * structure that contains the configuration information for
+ * the FSMC NOR/SRAM specified Banks.
+ * @retval None
+ */
+void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct)
+{
+ /* Check the parameters */
+ assert_param(IS_FSMC_NORSRAM_BANK(FSMC_NORSRAMInitStruct->FSMC_Bank));
+ assert_param(IS_FSMC_MUX(FSMC_NORSRAMInitStruct->FSMC_DataAddressMux));
+ assert_param(IS_FSMC_MEMORY(FSMC_NORSRAMInitStruct->FSMC_MemoryType));
+ assert_param(IS_FSMC_MEMORY_WIDTH(FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth));
+ assert_param(IS_FSMC_BURSTMODE(FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode));
+ assert_param(IS_FSMC_ASYNWAIT(FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait));
+ assert_param(IS_FSMC_WAIT_POLARITY(FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity));
+ assert_param(IS_FSMC_WRAP_MODE(FSMC_NORSRAMInitStruct->FSMC_WrapMode));
+ assert_param(IS_FSMC_WAIT_SIGNAL_ACTIVE(FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive));
+ assert_param(IS_FSMC_WRITE_OPERATION(FSMC_NORSRAMInitStruct->FSMC_WriteOperation));
+ assert_param(IS_FSMC_WAITE_SIGNAL(FSMC_NORSRAMInitStruct->FSMC_WaitSignal));
+ assert_param(IS_FSMC_EXTENDED_MODE(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode));
+ assert_param(IS_FSMC_WRITE_BURST(FSMC_NORSRAMInitStruct->FSMC_WriteBurst));
+ assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime));
+ assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime));
+ assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime));
+ assert_param(IS_FSMC_TURNAROUND_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration));
+ assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision));
+ assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency));
+ assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode));
+
+ /* Bank1 NOR/SRAM control register configuration */
+ FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] =
+ (uint32_t)FSMC_NORSRAMInitStruct->FSMC_DataAddressMux |
+ FSMC_NORSRAMInitStruct->FSMC_MemoryType |
+ FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth |
+ FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode |
+ FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait |
+ FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity |
+ FSMC_NORSRAMInitStruct->FSMC_WrapMode |
+ FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive |
+ FSMC_NORSRAMInitStruct->FSMC_WriteOperation |
+ FSMC_NORSRAMInitStruct->FSMC_WaitSignal |
+ FSMC_NORSRAMInitStruct->FSMC_ExtendedMode |
+ FSMC_NORSRAMInitStruct->FSMC_WriteBurst;
+
+ if(FSMC_NORSRAMInitStruct->FSMC_MemoryType == FSMC_MemoryType_NOR)
+ {
+ FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] |= (uint32_t)BCR_FACCEN_Set;
+ }
+
+ /* Bank1 NOR/SRAM timing register configuration */
+ FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank+1] =
+ (uint32_t)FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime |
+ (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime << 4) |
+ (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime << 8) |
+ (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration << 16) |
+ (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision << 20) |
+ (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency << 24) |
+ FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode;
+
+
+ /* Bank1 NOR/SRAM timing register for write configuration, if extended mode is used */
+ if(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode == FSMC_ExtendedMode_Enable)
+ {
+ assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime));
+ assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime));
+ assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime));
+ assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision));
+ assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency));
+ assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode));
+ FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] =
+ (uint32_t)FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime |
+ (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime << 4 )|
+ (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime << 8) |
+ (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision << 20) |
+ (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency << 24) |
+ FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode;
+ }
+ else
+ {
+ FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] = 0x0FFFFFFF;
+ }
+}
+
+/**
+ * @brief Initializes the FSMC NAND Banks according to the specified
+ * parameters in the FSMC_NANDInitStruct.
+ * @param FSMC_NANDInitStruct : pointer to a FSMC_NANDInitTypeDef
+ * structure that contains the configuration information for the FSMC
+ * NAND specified Banks.
+ * @retval None
+ */
+void FSMC_NANDInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct)
+{
+ uint32_t tmppcr = 0x00000000, tmppmem = 0x00000000, tmppatt = 0x00000000;
+
+ /* Check the parameters */
+ assert_param( IS_FSMC_NAND_BANK(FSMC_NANDInitStruct->FSMC_Bank));
+ assert_param( IS_FSMC_WAIT_FEATURE(FSMC_NANDInitStruct->FSMC_Waitfeature));
+ assert_param( IS_FSMC_MEMORY_WIDTH(FSMC_NANDInitStruct->FSMC_MemoryDataWidth));
+ assert_param( IS_FSMC_ECC_STATE(FSMC_NANDInitStruct->FSMC_ECC));
+ assert_param( IS_FSMC_ECCPAGE_SIZE(FSMC_NANDInitStruct->FSMC_ECCPageSize));
+ assert_param( IS_FSMC_TCLR_TIME(FSMC_NANDInitStruct->FSMC_TCLRSetupTime));
+ assert_param( IS_FSMC_TAR_TIME(FSMC_NANDInitStruct->FSMC_TARSetupTime));
+ assert_param(IS_FSMC_SETUP_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime));
+ assert_param(IS_FSMC_WAIT_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime));
+ assert_param(IS_FSMC_HOLD_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime));
+ assert_param(IS_FSMC_HIZ_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime));
+ assert_param(IS_FSMC_SETUP_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime));
+ assert_param(IS_FSMC_WAIT_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime));
+ assert_param(IS_FSMC_HOLD_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime));
+ assert_param(IS_FSMC_HIZ_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime));
+
+ /* Set the tmppcr value according to FSMC_NANDInitStruct parameters */
+ tmppcr = (uint32_t)FSMC_NANDInitStruct->FSMC_Waitfeature |
+ PCR_MemoryType_NAND |
+ FSMC_NANDInitStruct->FSMC_MemoryDataWidth |
+ FSMC_NANDInitStruct->FSMC_ECC |
+ FSMC_NANDInitStruct->FSMC_ECCPageSize |
+ (FSMC_NANDInitStruct->FSMC_TCLRSetupTime << 9 )|
+ (FSMC_NANDInitStruct->FSMC_TARSetupTime << 13);
+
+ /* Set tmppmem value according to FSMC_CommonSpaceTimingStructure parameters */
+ tmppmem = (uint32_t)FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime |
+ (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
+ (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
+ (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime << 24);
+
+ /* Set tmppatt value according to FSMC_AttributeSpaceTimingStructure parameters */
+ tmppatt = (uint32_t)FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime |
+ (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
+ (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
+ (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime << 24);
+
+ if(FSMC_NANDInitStruct->FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ /* FSMC_Bank2_NAND registers configuration */
+ FSMC_Bank2->PCR2 = tmppcr;
+ FSMC_Bank2->PMEM2 = tmppmem;
+ FSMC_Bank2->PATT2 = tmppatt;
+ }
+ else
+ {
+ /* FSMC_Bank3_NAND registers configuration */
+ FSMC_Bank3->PCR3 = tmppcr;
+ FSMC_Bank3->PMEM3 = tmppmem;
+ FSMC_Bank3->PATT3 = tmppatt;
+ }
+}
+
+/**
+ * @brief Initializes the FSMC PCCARD Bank according to the specified
+ * parameters in the FSMC_PCCARDInitStruct.
+ * @param FSMC_PCCARDInitStruct : pointer to a FSMC_PCCARDInitTypeDef
+ * structure that contains the configuration information for the FSMC
+ * PCCARD Bank.
+ * @retval None
+ */
+void FSMC_PCCARDInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct)
+{
+ /* Check the parameters */
+ assert_param(IS_FSMC_WAIT_FEATURE(FSMC_PCCARDInitStruct->FSMC_Waitfeature));
+ assert_param(IS_FSMC_TCLR_TIME(FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime));
+ assert_param(IS_FSMC_TAR_TIME(FSMC_PCCARDInitStruct->FSMC_TARSetupTime));
+
+ assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime));
+ assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime));
+ assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime));
+ assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime));
+
+ assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime));
+ assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime));
+ assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime));
+ assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime));
+ assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime));
+ assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime));
+ assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime));
+ assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime));
+
+ /* Set the PCR4 register value according to FSMC_PCCARDInitStruct parameters */
+ FSMC_Bank4->PCR4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_Waitfeature |
+ FSMC_MemoryDataWidth_16b |
+ (FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime << 9) |
+ (FSMC_PCCARDInitStruct->FSMC_TARSetupTime << 13);
+
+ /* Set PMEM4 register value according to FSMC_CommonSpaceTimingStructure parameters */
+ FSMC_Bank4->PMEM4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime |
+ (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
+ (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
+ (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime << 24);
+
+ /* Set PATT4 register value according to FSMC_AttributeSpaceTimingStructure parameters */
+ FSMC_Bank4->PATT4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime |
+ (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
+ (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
+ (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime << 24);
+
+ /* Set PIO4 register value according to FSMC_IOSpaceTimingStructure parameters */
+ FSMC_Bank4->PIO4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime |
+ (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
+ (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
+ (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime << 24);
+}
+
+/**
+ * @brief Fills each FSMC_NORSRAMInitStruct member with its default value.
+ * @param FSMC_NORSRAMInitStruct: pointer to a FSMC_NORSRAMInitTypeDef
+ * structure which will be initialized.
+ * @retval None
+ */
+void FSMC_NORSRAMStructInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct)
+{
+ /* Reset NOR/SRAM Init structure parameters values */
+ FSMC_NORSRAMInitStruct->FSMC_Bank = FSMC_Bank1_NORSRAM1;
+ FSMC_NORSRAMInitStruct->FSMC_DataAddressMux = FSMC_DataAddressMux_Enable;
+ FSMC_NORSRAMInitStruct->FSMC_MemoryType = FSMC_MemoryType_SRAM;
+ FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
+ FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
+ FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
+ FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
+ FSMC_NORSRAMInitStruct->FSMC_WrapMode = FSMC_WrapMode_Disable;
+ FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
+ FSMC_NORSRAMInitStruct->FSMC_WriteOperation = FSMC_WriteOperation_Enable;
+ FSMC_NORSRAMInitStruct->FSMC_WaitSignal = FSMC_WaitSignal_Enable;
+ FSMC_NORSRAMInitStruct->FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
+ FSMC_NORSRAMInitStruct->FSMC_WriteBurst = FSMC_WriteBurst_Disable;
+ FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime = 0xF;
+ FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime = 0xF;
+ FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime = 0xFF;
+ FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration = 0xF;
+ FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision = 0xF;
+ FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency = 0xF;
+ FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode = FSMC_AccessMode_A;
+ FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime = 0xF;
+ FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime = 0xF;
+ FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime = 0xFF;
+ FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_BusTurnAroundDuration = 0xF;
+ FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision = 0xF;
+ FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency = 0xF;
+ FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode = FSMC_AccessMode_A;
+}
+
+/**
+ * @brief Fills each FSMC_NANDInitStruct member with its default value.
+ * @param FSMC_NANDInitStruct: pointer to a FSMC_NANDInitTypeDef
+ * structure which will be initialized.
+ * @retval None
+ */
+void FSMC_NANDStructInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct)
+{
+ /* Reset NAND Init structure parameters values */
+ FSMC_NANDInitStruct->FSMC_Bank = FSMC_Bank2_NAND;
+ FSMC_NANDInitStruct->FSMC_Waitfeature = FSMC_Waitfeature_Disable;
+ FSMC_NANDInitStruct->FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
+ FSMC_NANDInitStruct->FSMC_ECC = FSMC_ECC_Disable;
+ FSMC_NANDInitStruct->FSMC_ECCPageSize = FSMC_ECCPageSize_256Bytes;
+ FSMC_NANDInitStruct->FSMC_TCLRSetupTime = 0x0;
+ FSMC_NANDInitStruct->FSMC_TARSetupTime = 0x0;
+ FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime = 0xFC;
+ FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
+ FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
+ FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
+ FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime = 0xFC;
+ FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
+ FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
+ FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
+}
+
+/**
+ * @brief Fills each FSMC_PCCARDInitStruct member with its default value.
+ * @param FSMC_PCCARDInitStruct: pointer to a FSMC_PCCARDInitTypeDef
+ * structure which will be initialized.
+ * @retval None
+ */
+void FSMC_PCCARDStructInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct)
+{
+ /* Reset PCCARD Init structure parameters values */
+ FSMC_PCCARDInitStruct->FSMC_Waitfeature = FSMC_Waitfeature_Disable;
+ FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime = 0x0;
+ FSMC_PCCARDInitStruct->FSMC_TARSetupTime = 0x0;
+ FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
+ FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
+}
+
+/**
+ * @brief Enables or disables the specified NOR/SRAM Memory Bank.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank1_NORSRAM1: FSMC Bank1 NOR/SRAM1
+ * @arg FSMC_Bank1_NORSRAM2: FSMC Bank1 NOR/SRAM2
+ * @arg FSMC_Bank1_NORSRAM3: FSMC Bank1 NOR/SRAM3
+ * @arg FSMC_Bank1_NORSRAM4: FSMC Bank1 NOR/SRAM4
+ * @param NewState: new state of the FSMC_Bank. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState)
+{
+ assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected NOR/SRAM Bank by setting the PBKEN bit in the BCRx register */
+ FSMC_Bank1->BTCR[FSMC_Bank] |= BCR_MBKEN_Set;
+ }
+ else
+ {
+ /* Disable the selected NOR/SRAM Bank by clearing the PBKEN bit in the BCRx register */
+ FSMC_Bank1->BTCR[FSMC_Bank] &= BCR_MBKEN_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified NAND Memory Bank.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
+ * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
+ * @param NewState: new state of the FSMC_Bank. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void FSMC_NANDCmd(uint32_t FSMC_Bank, FunctionalState NewState)
+{
+ assert_param(IS_FSMC_NAND_BANK(FSMC_Bank));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected NAND Bank by setting the PBKEN bit in the PCRx register */
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ FSMC_Bank2->PCR2 |= PCR_PBKEN_Set;
+ }
+ else
+ {
+ FSMC_Bank3->PCR3 |= PCR_PBKEN_Set;
+ }
+ }
+ else
+ {
+ /* Disable the selected NAND Bank by clearing the PBKEN bit in the PCRx register */
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ FSMC_Bank2->PCR2 &= PCR_PBKEN_Reset;
+ }
+ else
+ {
+ FSMC_Bank3->PCR3 &= PCR_PBKEN_Reset;
+ }
+ }
+}
+
+/**
+ * @brief Enables or disables the PCCARD Memory Bank.
+ * @param NewState: new state of the PCCARD Memory Bank.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void FSMC_PCCARDCmd(FunctionalState NewState)
+{
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the PCCARD Bank by setting the PBKEN bit in the PCR4 register */
+ FSMC_Bank4->PCR4 |= PCR_PBKEN_Set;
+ }
+ else
+ {
+ /* Disable the PCCARD Bank by clearing the PBKEN bit in the PCR4 register */
+ FSMC_Bank4->PCR4 &= PCR_PBKEN_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the FSMC NAND ECC feature.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
+ * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
+ * @param NewState: new state of the FSMC NAND ECC feature.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void FSMC_NANDECCCmd(uint32_t FSMC_Bank, FunctionalState NewState)
+{
+ assert_param(IS_FSMC_NAND_BANK(FSMC_Bank));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected NAND Bank ECC function by setting the ECCEN bit in the PCRx register */
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ FSMC_Bank2->PCR2 |= PCR_ECCEN_Set;
+ }
+ else
+ {
+ FSMC_Bank3->PCR3 |= PCR_ECCEN_Set;
+ }
+ }
+ else
+ {
+ /* Disable the selected NAND Bank ECC function by clearing the ECCEN bit in the PCRx register */
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ FSMC_Bank2->PCR2 &= PCR_ECCEN_Reset;
+ }
+ else
+ {
+ FSMC_Bank3->PCR3 &= PCR_ECCEN_Reset;
+ }
+ }
+}
+
+/**
+ * @brief Returns the error correction code register value.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
+ * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
+ * @retval The Error Correction Code (ECC) value.
+ */
+uint32_t FSMC_GetECC(uint32_t FSMC_Bank)
+{
+ uint32_t eccval = 0x00000000;
+
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ /* Get the ECCR2 register value */
+ eccval = FSMC_Bank2->ECCR2;
+ }
+ else
+ {
+ /* Get the ECCR3 register value */
+ eccval = FSMC_Bank3->ECCR3;
+ }
+ /* Return the error correction code value */
+ return(eccval);
+}
+
+/**
+ * @brief Enables or disables the specified FSMC interrupts.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
+ * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
+ * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
+ * @param FSMC_IT: specifies the FSMC interrupt sources to be enabled or disabled.
+ * This parameter can be any combination of the following values:
+ * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt.
+ * @arg FSMC_IT_Level: Level edge detection interrupt.
+ * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt.
+ * @param NewState: new state of the specified FSMC interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void FSMC_ITConfig(uint32_t FSMC_Bank, uint32_t FSMC_IT, FunctionalState NewState)
+{
+ assert_param(IS_FSMC_IT_BANK(FSMC_Bank));
+ assert_param(IS_FSMC_IT(FSMC_IT));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected FSMC_Bank2 interrupts */
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ FSMC_Bank2->SR2 |= FSMC_IT;
+ }
+ /* Enable the selected FSMC_Bank3 interrupts */
+ else if (FSMC_Bank == FSMC_Bank3_NAND)
+ {
+ FSMC_Bank3->SR3 |= FSMC_IT;
+ }
+ /* Enable the selected FSMC_Bank4 interrupts */
+ else
+ {
+ FSMC_Bank4->SR4 |= FSMC_IT;
+ }
+ }
+ else
+ {
+ /* Disable the selected FSMC_Bank2 interrupts */
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+
+ FSMC_Bank2->SR2 &= (uint32_t)~FSMC_IT;
+ }
+ /* Disable the selected FSMC_Bank3 interrupts */
+ else if (FSMC_Bank == FSMC_Bank3_NAND)
+ {
+ FSMC_Bank3->SR3 &= (uint32_t)~FSMC_IT;
+ }
+ /* Disable the selected FSMC_Bank4 interrupts */
+ else
+ {
+ FSMC_Bank4->SR4 &= (uint32_t)~FSMC_IT;
+ }
+ }
+}
+
+/**
+ * @brief Checks whether the specified FSMC flag is set or not.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
+ * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
+ * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
+ * @param FSMC_FLAG: specifies the flag to check.
+ * This parameter can be one of the following values:
+ * @arg FSMC_FLAG_RisingEdge: Rising egde detection Flag.
+ * @arg FSMC_FLAG_Level: Level detection Flag.
+ * @arg FSMC_FLAG_FallingEdge: Falling egde detection Flag.
+ * @arg FSMC_FLAG_FEMPT: Fifo empty Flag.
+ * @retval The new state of FSMC_FLAG (SET or RESET).
+ */
+FlagStatus FSMC_GetFlagStatus(uint32_t FSMC_Bank, uint32_t FSMC_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+ uint32_t tmpsr = 0x00000000;
+
+ /* Check the parameters */
+ assert_param(IS_FSMC_GETFLAG_BANK(FSMC_Bank));
+ assert_param(IS_FSMC_GET_FLAG(FSMC_FLAG));
+
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ tmpsr = FSMC_Bank2->SR2;
+ }
+ else if(FSMC_Bank == FSMC_Bank3_NAND)
+ {
+ tmpsr = FSMC_Bank3->SR3;
+ }
+ /* FSMC_Bank4_PCCARD*/
+ else
+ {
+ tmpsr = FSMC_Bank4->SR4;
+ }
+
+ /* Get the flag status */
+ if ((tmpsr & FSMC_FLAG) != (uint16_t)RESET )
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ /* Return the flag status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the FSMC's pending flags.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
+ * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
+ * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
+ * @param FSMC_FLAG: specifies the flag to clear.
+ * This parameter can be any combination of the following values:
+ * @arg FSMC_FLAG_RisingEdge: Rising egde detection Flag.
+ * @arg FSMC_FLAG_Level: Level detection Flag.
+ * @arg FSMC_FLAG_FallingEdge: Falling egde detection Flag.
+ * @retval None
+ */
+void FSMC_ClearFlag(uint32_t FSMC_Bank, uint32_t FSMC_FLAG)
+{
+ /* Check the parameters */
+ assert_param(IS_FSMC_GETFLAG_BANK(FSMC_Bank));
+ assert_param(IS_FSMC_CLEAR_FLAG(FSMC_FLAG)) ;
+
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ FSMC_Bank2->SR2 &= ~FSMC_FLAG;
+ }
+ else if(FSMC_Bank == FSMC_Bank3_NAND)
+ {
+ FSMC_Bank3->SR3 &= ~FSMC_FLAG;
+ }
+ /* FSMC_Bank4_PCCARD*/
+ else
+ {
+ FSMC_Bank4->SR4 &= ~FSMC_FLAG;
+ }
+}
+
+/**
+ * @brief Checks whether the specified FSMC interrupt has occurred or not.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
+ * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
+ * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
+ * @param FSMC_IT: specifies the FSMC interrupt source to check.
+ * This parameter can be one of the following values:
+ * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt.
+ * @arg FSMC_IT_Level: Level edge detection interrupt.
+ * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt.
+ * @retval The new state of FSMC_IT (SET or RESET).
+ */
+ITStatus FSMC_GetITStatus(uint32_t FSMC_Bank, uint32_t FSMC_IT)
+{
+ ITStatus bitstatus = RESET;
+ uint32_t tmpsr = 0x0, itstatus = 0x0, itenable = 0x0;
+
+ /* Check the parameters */
+ assert_param(IS_FSMC_IT_BANK(FSMC_Bank));
+ assert_param(IS_FSMC_GET_IT(FSMC_IT));
+
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ tmpsr = FSMC_Bank2->SR2;
+ }
+ else if(FSMC_Bank == FSMC_Bank3_NAND)
+ {
+ tmpsr = FSMC_Bank3->SR3;
+ }
+ /* FSMC_Bank4_PCCARD*/
+ else
+ {
+ tmpsr = FSMC_Bank4->SR4;
+ }
+
+ itstatus = tmpsr & FSMC_IT;
+
+ itenable = tmpsr & (FSMC_IT >> 3);
+ if ((itstatus != (uint32_t)RESET) && (itenable != (uint32_t)RESET))
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the FSMC's interrupt pending bits.
+ * @param FSMC_Bank: specifies the FSMC Bank to be used
+ * This parameter can be one of the following values:
+ * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
+ * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
+ * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
+ * @param FSMC_IT: specifies the interrupt pending bit to clear.
+ * This parameter can be any combination of the following values:
+ * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt.
+ * @arg FSMC_IT_Level: Level edge detection interrupt.
+ * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt.
+ * @retval None
+ */
+void FSMC_ClearITPendingBit(uint32_t FSMC_Bank, uint32_t FSMC_IT)
+{
+ /* Check the parameters */
+ assert_param(IS_FSMC_IT_BANK(FSMC_Bank));
+ assert_param(IS_FSMC_IT(FSMC_IT));
+
+ if(FSMC_Bank == FSMC_Bank2_NAND)
+ {
+ FSMC_Bank2->SR2 &= ~(FSMC_IT >> 3);
+ }
+ else if(FSMC_Bank == FSMC_Bank3_NAND)
+ {
+ FSMC_Bank3->SR3 &= ~(FSMC_IT >> 3);
+ }
+ /* FSMC_Bank4_PCCARD*/
+ else
+ {
+ FSMC_Bank4->SR4 &= ~(FSMC_IT >> 3);
+ }
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_gpio.c b/st_fw_lib/src/stm32f10x_gpio.c
new file mode 100644
index 0000000..457ff11
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_gpio.c
@@ -0,0 +1,650 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_gpio.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the GPIO firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_gpio.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup GPIO
+ * @brief GPIO driver modules
+ * @{
+ */
+
+/** @defgroup GPIO_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Private_Defines
+ * @{
+ */
+
+/* ------------ RCC registers bit address in the alias region ----------------*/
+#define AFIO_OFFSET (AFIO_BASE - PERIPH_BASE)
+
+/* --- EVENTCR Register -----*/
+
+/* Alias word address of EVOE bit */
+#define EVCR_OFFSET (AFIO_OFFSET + 0x00)
+#define EVOE_BitNumber ((uint8_t)0x07)
+#define EVCR_EVOE_BB (PERIPH_BB_BASE + (EVCR_OFFSET * 32) + (EVOE_BitNumber * 4))
+
+
+/* --- MAPR Register ---*/
+/* Alias word address of MII_RMII_SEL bit */
+#define MAPR_OFFSET (AFIO_OFFSET + 0x04)
+#define MII_RMII_SEL_BitNumber ((u8)0x17)
+#define MAPR_MII_RMII_SEL_BB (PERIPH_BB_BASE + (MAPR_OFFSET * 32) + (MII_RMII_SEL_BitNumber * 4))
+
+
+#define EVCR_PORTPINCONFIG_MASK ((uint16_t)0xFF80)
+#define LSB_MASK ((uint16_t)0xFFFF)
+#define DBGAFR_POSITION_MASK ((uint32_t)0x000F0000)
+#define DBGAFR_SWJCFG_MASK ((uint32_t)0xF0FFFFFF)
+#define DBGAFR_LOCATION_MASK ((uint32_t)0x00200000)
+#define DBGAFR_NUMBITS_MASK ((uint32_t)0x00100000)
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup GPIO_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the GPIOx peripheral registers to their default reset values.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @retval None
+ */
+void GPIO_DeInit(GPIO_TypeDef* GPIOx)
+{
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+
+ if (GPIOx == GPIOA)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOA, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOA, DISABLE);
+ }
+ else if (GPIOx == GPIOB)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOB, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOB, DISABLE);
+ }
+ else if (GPIOx == GPIOC)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, DISABLE);
+ }
+ else if (GPIOx == GPIOD)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD, DISABLE);
+ }
+ else if (GPIOx == GPIOE)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, DISABLE);
+ }
+ else if (GPIOx == GPIOF)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOF, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOF, DISABLE);
+ }
+ else
+ {
+ if (GPIOx == GPIOG)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOG, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOG, DISABLE);
+ }
+ }
+}
+
+/**
+ * @brief Deinitializes the Alternate Functions (remap, event control
+ * and EXTI configuration) registers to their default reset values.
+ * @param None
+ * @retval None
+ */
+void GPIO_AFIODeInit(void)
+{
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO, DISABLE);
+}
+
+/**
+ * @brief Initializes the GPIOx peripheral according to the specified
+ * parameters in the GPIO_InitStruct.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @param GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure that
+ * contains the configuration information for the specified GPIO peripheral.
+ * @retval None
+ */
+void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
+{
+ uint32_t currentmode = 0x00, currentpin = 0x00, pinpos = 0x00, pos = 0x00;
+ uint32_t tmpreg = 0x00, pinmask = 0x00;
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+ assert_param(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode));
+ assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));
+
+/*---------------------------- GPIO Mode Configuration -----------------------*/
+ currentmode = ((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x0F);
+ if ((((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x10)) != 0x00)
+ {
+ /* Check the parameters */
+ assert_param(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed));
+ /* Output mode */
+ currentmode |= (uint32_t)GPIO_InitStruct->GPIO_Speed;
+ }
+/*---------------------------- GPIO CRL Configuration ------------------------*/
+ /* Configure the eight low port pins */
+ if (((uint32_t)GPIO_InitStruct->GPIO_Pin & ((uint32_t)0x00FF)) != 0x00)
+ {
+ tmpreg = GPIOx->CRL;
+ for (pinpos = 0x00; pinpos < 0x08; pinpos++)
+ {
+ pos = ((uint32_t)0x01) << pinpos;
+ /* Get the port pins position */
+ currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;
+ if (currentpin == pos)
+ {
+ pos = pinpos << 2;
+ /* Clear the corresponding low control register bits */
+ pinmask = ((uint32_t)0x0F) << pos;
+ tmpreg &= ~pinmask;
+ /* Write the mode configuration in the corresponding bits */
+ tmpreg |= (currentmode << pos);
+ /* Reset the corresponding ODR bit */
+ if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD)
+ {
+ GPIOx->BRR = (((uint32_t)0x01) << pinpos);
+ }
+ else
+ {
+ /* Set the corresponding ODR bit */
+ if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU)
+ {
+ GPIOx->BSRR = (((uint32_t)0x01) << pinpos);
+ }
+ }
+ }
+ }
+ GPIOx->CRL = tmpreg;
+ }
+/*---------------------------- GPIO CRH Configuration ------------------------*/
+ /* Configure the eight high port pins */
+ if (GPIO_InitStruct->GPIO_Pin > 0x00FF)
+ {
+ tmpreg = GPIOx->CRH;
+ for (pinpos = 0x00; pinpos < 0x08; pinpos++)
+ {
+ pos = (((uint32_t)0x01) << (pinpos + 0x08));
+ /* Get the port pins position */
+ currentpin = ((GPIO_InitStruct->GPIO_Pin) & pos);
+ if (currentpin == pos)
+ {
+ pos = pinpos << 2;
+ /* Clear the corresponding high control register bits */
+ pinmask = ((uint32_t)0x0F) << pos;
+ tmpreg &= ~pinmask;
+ /* Write the mode configuration in the corresponding bits */
+ tmpreg |= (currentmode << pos);
+ /* Reset the corresponding ODR bit */
+ if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD)
+ {
+ GPIOx->BRR = (((uint32_t)0x01) << (pinpos + 0x08));
+ }
+ /* Set the corresponding ODR bit */
+ if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU)
+ {
+ GPIOx->BSRR = (((uint32_t)0x01) << (pinpos + 0x08));
+ }
+ }
+ }
+ GPIOx->CRH = tmpreg;
+ }
+}
+
+/**
+ * @brief Fills each GPIO_InitStruct member with its default value.
+ * @param GPIO_InitStruct : pointer to a GPIO_InitTypeDef structure which will
+ * be initialized.
+ * @retval None
+ */
+void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)
+{
+ /* Reset GPIO init structure parameters values */
+ GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All;
+ GPIO_InitStruct->GPIO_Speed = GPIO_Speed_2MHz;
+ GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN_FLOATING;
+}
+
+/**
+ * @brief Reads the specified input port pin.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @param GPIO_Pin: specifies the port bit to read.
+ * This parameter can be GPIO_Pin_x where x can be (0..15).
+ * @retval The input port pin value.
+ */
+uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
+{
+ uint8_t bitstatus = 0x00;
+
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+ assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
+
+ if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)Bit_RESET)
+ {
+ bitstatus = (uint8_t)Bit_SET;
+ }
+ else
+ {
+ bitstatus = (uint8_t)Bit_RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Reads the specified GPIO input data port.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @retval GPIO input data port value.
+ */
+uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx)
+{
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+
+ return ((uint16_t)GPIOx->IDR);
+}
+
+/**
+ * @brief Reads the specified output data port bit.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @param GPIO_Pin: specifies the port bit to read.
+ * This parameter can be GPIO_Pin_x where x can be (0..15).
+ * @retval The output port pin value.
+ */
+uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
+{
+ uint8_t bitstatus = 0x00;
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+ assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
+
+ if ((GPIOx->ODR & GPIO_Pin) != (uint32_t)Bit_RESET)
+ {
+ bitstatus = (uint8_t)Bit_SET;
+ }
+ else
+ {
+ bitstatus = (uint8_t)Bit_RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Reads the specified GPIO output data port.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @retval GPIO output data port value.
+ */
+uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)
+{
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+
+ return ((uint16_t)GPIOx->ODR);
+}
+
+/**
+ * @brief Sets the selected data port bits.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @param GPIO_Pin: specifies the port bits to be written.
+ * This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
+ * @retval None
+ */
+void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
+{
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+ assert_param(IS_GPIO_PIN(GPIO_Pin));
+
+ GPIOx->BSRR = GPIO_Pin;
+}
+
+/**
+ * @brief Clears the selected data port bits.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @param GPIO_Pin: specifies the port bits to be written.
+ * This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
+ * @retval None
+ */
+void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
+{
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+ assert_param(IS_GPIO_PIN(GPIO_Pin));
+
+ GPIOx->BRR = GPIO_Pin;
+}
+
+/**
+ * @brief Sets or clears the selected data port bit.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @param GPIO_Pin: specifies the port bit to be written.
+ * This parameter can be one of GPIO_Pin_x where x can be (0..15).
+ * @param BitVal: specifies the value to be written to the selected bit.
+ * This parameter can be one of the BitAction enum values:
+ * @arg Bit_RESET: to clear the port pin
+ * @arg Bit_SET: to set the port pin
+ * @retval None
+ */
+void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
+{
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+ assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
+ assert_param(IS_GPIO_BIT_ACTION(BitVal));
+
+ if (BitVal != Bit_RESET)
+ {
+ GPIOx->BSRR = GPIO_Pin;
+ }
+ else
+ {
+ GPIOx->BRR = GPIO_Pin;
+ }
+}
+
+/**
+ * @brief Writes data to the specified GPIO data port.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @param PortVal: specifies the value to be written to the port output data register.
+ * @retval None
+ */
+void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal)
+{
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+
+ GPIOx->ODR = PortVal;
+}
+
+/**
+ * @brief Locks GPIO Pins configuration registers.
+ * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.
+ * @param GPIO_Pin: specifies the port bit to be written.
+ * This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
+ * @retval None
+ */
+void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
+{
+ uint32_t tmp = 0x00010000;
+
+ /* Check the parameters */
+ assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
+ assert_param(IS_GPIO_PIN(GPIO_Pin));
+
+ tmp |= GPIO_Pin;
+ /* Set LCKK bit */
+ GPIOx->LCKR = tmp;
+ /* Reset LCKK bit */
+ GPIOx->LCKR = GPIO_Pin;
+ /* Set LCKK bit */
+ GPIOx->LCKR = tmp;
+ /* Read LCKK bit*/
+ tmp = GPIOx->LCKR;
+ /* Read LCKK bit*/
+ tmp = GPIOx->LCKR;
+}
+
+/**
+ * @brief Selects the GPIO pin used as Event output.
+ * @param GPIO_PortSource: selects the GPIO port to be used as source
+ * for Event output.
+ * This parameter can be GPIO_PortSourceGPIOx where x can be (A..E).
+ * @param GPIO_PinSource: specifies the pin for the Event output.
+ * This parameter can be GPIO_PinSourcex where x can be (0..15).
+ * @retval None
+ */
+void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource)
+{
+ uint32_t tmpreg = 0x00;
+ /* Check the parameters */
+ assert_param(IS_GPIO_EVENTOUT_PORT_SOURCE(GPIO_PortSource));
+ assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
+
+ tmpreg = AFIO->EVCR;
+ /* Clear the PORT[6:4] and PIN[3:0] bits */
+ tmpreg &= EVCR_PORTPINCONFIG_MASK;
+ tmpreg |= (uint32_t)GPIO_PortSource << 0x04;
+ tmpreg |= GPIO_PinSource;
+ AFIO->EVCR = tmpreg;
+}
+
+/**
+ * @brief Enables or disables the Event Output.
+ * @param NewState: new state of the Event output.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void GPIO_EventOutputCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) EVCR_EVOE_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Changes the mapping of the specified pin.
+ * @param GPIO_Remap: selects the pin to remap.
+ * This parameter can be one of the following values:
+ * @arg GPIO_Remap_SPI1 : SPI1 Alternate Function mapping
+ * @arg GPIO_Remap_I2C1 : I2C1 Alternate Function mapping
+ * @arg GPIO_Remap_USART1 : USART1 Alternate Function mapping
+ * @arg GPIO_Remap_USART2 : USART2 Alternate Function mapping
+ * @arg GPIO_PartialRemap_USART3 : USART3 Partial Alternate Function mapping
+ * @arg GPIO_FullRemap_USART3 : USART3 Full Alternate Function mapping
+ * @arg GPIO_PartialRemap_TIM1 : TIM1 Partial Alternate Function mapping
+ * @arg GPIO_FullRemap_TIM1 : TIM1 Full Alternate Function mapping
+ * @arg GPIO_PartialRemap1_TIM2 : TIM2 Partial1 Alternate Function mapping
+ * @arg GPIO_PartialRemap2_TIM2 : TIM2 Partial2 Alternate Function mapping
+ * @arg GPIO_FullRemap_TIM2 : TIM2 Full Alternate Function mapping
+ * @arg GPIO_PartialRemap_TIM3 : TIM3 Partial Alternate Function mapping
+ * @arg GPIO_FullRemap_TIM3 : TIM3 Full Alternate Function mapping
+ * @arg GPIO_Remap_TIM4 : TIM4 Alternate Function mapping
+ * @arg GPIO_Remap1_CAN1 : CAN1 Alternate Function mapping
+ * @arg GPIO_Remap2_CAN1 : CAN1 Alternate Function mapping
+ * @arg GPIO_Remap_PD01 : PD01 Alternate Function mapping
+ * @arg GPIO_Remap_TIM5CH4_LSI : LSI connected to TIM5 Channel4 input capture for calibration
+ * @arg GPIO_Remap_ADC1_ETRGINJ : ADC1 External Trigger Injected Conversion remapping
+ * @arg GPIO_Remap_ADC1_ETRGREG : ADC1 External Trigger Regular Conversion remapping
+ * @arg GPIO_Remap_ADC2_ETRGINJ : ADC2 External Trigger Injected Conversion remapping
+ * @arg GPIO_Remap_ADC2_ETRGREG : ADC2 External Trigger Regular Conversion remapping
+ * @arg GPIO_Remap_ETH : Ethernet remapping (only for Connectivity line devices)
+ * @arg GPIO_Remap_CAN2 : CAN2 remapping (only for Connectivity line devices)
+ * @arg GPIO_Remap_SWJ_NoJTRST : Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST
+ * @arg GPIO_Remap_SWJ_JTAGDisable : JTAG-DP Disabled and SW-DP Enabled
+ * @arg GPIO_Remap_SWJ_Disable : Full SWJ Disabled (JTAG-DP + SW-DP)
+ * @arg GPIO_Remap_SPI3 : SPI3/I2S3 Alternate Function mapping (only for Connectivity line devices)
+ * When the SPI3/I2S3 is remapped using this function, the SWJ is configured
+ * to Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST.
+ * @arg GPIO_Remap_TIM2ITR1_PTP_SOF : Ethernet PTP output or USB OTG SOF (Start of Frame) connected
+ * to TIM2 Internal Trigger 1 for calibration (only for Connectivity line devices)
+ * If the GPIO_Remap_TIM2ITR1_PTP_SOF is enabled the TIM2 ITR1 is connected to
+ * Ethernet PTP output. When Reset TIM2 ITR1 is connected to USB OTG SOF output.
+ * @arg GPIO_Remap_PTP_PPS : Ethernet MAC PPS_PTS output on PB05 (only for Connectivity line devices)
+ * @arg GPIO_Remap_TIM15 : TIM15 Alternate Function mapping (only for Value line devices)
+ * @arg GPIO_Remap_TIM16 : TIM16 Alternate Function mapping (only for Value line devices)
+ * @arg GPIO_Remap_TIM17 : TIM17 Alternate Function mapping (only for Value line devices)
+ * @arg GPIO_Remap_CEC : CEC Alternate Function mapping (only for Value line devices)
+ * @arg GPIO_Remap_TIM1_DMA : TIM1 DMA requests mapping (only for Value line devices)
+ * @arg GPIO_Remap_TIM9 : TIM9 Alternate Function mapping (only for XL-density devices)
+ * @arg GPIO_Remap_TIM10 : TIM10 Alternate Function mapping (only for XL-density devices)
+ * @arg GPIO_Remap_TIM11 : TIM11 Alternate Function mapping (only for XL-density devices)
+ * @arg GPIO_Remap_TIM13 : TIM13 Alternate Function mapping (only for High density Value line and XL-density devices)
+ * @arg GPIO_Remap_TIM14 : TIM14 Alternate Function mapping (only for High density Value line and XL-density devices)
+ * @arg GPIO_Remap_FSMC_NADV : FSMC_NADV Alternate Function mapping (only for High density Value line and XL-density devices)
+ * @arg GPIO_Remap_TIM67_DAC_DMA : TIM6/TIM7 and DAC DMA requests remapping (only for High density Value line devices)
+ * @arg GPIO_Remap_TIM12 : TIM12 Alternate Function mapping (only for High density Value line devices)
+ * @arg GPIO_Remap_MISC : Miscellaneous Remap (DMA2 Channel5 Position and DAC Trigger remapping,
+ * only for High density Value line devices)
+ * @param NewState: new state of the port pin remapping.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState)
+{
+ uint32_t tmp = 0x00, tmp1 = 0x00, tmpreg = 0x00, tmpmask = 0x00;
+
+ /* Check the parameters */
+ assert_param(IS_GPIO_REMAP(GPIO_Remap));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if((GPIO_Remap & 0x80000000) == 0x80000000)
+ {
+ tmpreg = AFIO->MAPR2;
+ }
+ else
+ {
+ tmpreg = AFIO->MAPR;
+ }
+
+ tmpmask = (GPIO_Remap & DBGAFR_POSITION_MASK) >> 0x10;
+ tmp = GPIO_Remap & LSB_MASK;
+
+ if ((GPIO_Remap & (DBGAFR_LOCATION_MASK | DBGAFR_NUMBITS_MASK)) == (DBGAFR_LOCATION_MASK | DBGAFR_NUMBITS_MASK))
+ {
+ tmpreg &= DBGAFR_SWJCFG_MASK;
+ AFIO->MAPR &= DBGAFR_SWJCFG_MASK;
+ }
+ else if ((GPIO_Remap & DBGAFR_NUMBITS_MASK) == DBGAFR_NUMBITS_MASK)
+ {
+ tmp1 = ((uint32_t)0x03) << tmpmask;
+ tmpreg &= ~tmp1;
+ tmpreg |= ~DBGAFR_SWJCFG_MASK;
+ }
+ else
+ {
+ tmpreg &= ~(tmp << ((GPIO_Remap >> 0x15)*0x10));
+ tmpreg |= ~DBGAFR_SWJCFG_MASK;
+ }
+
+ if (NewState != DISABLE)
+ {
+ tmpreg |= (tmp << ((GPIO_Remap >> 0x15)*0x10));
+ }
+
+ if((GPIO_Remap & 0x80000000) == 0x80000000)
+ {
+ AFIO->MAPR2 = tmpreg;
+ }
+ else
+ {
+ AFIO->MAPR = tmpreg;
+ }
+}
+
+/**
+ * @brief Selects the GPIO pin used as EXTI Line.
+ * @param GPIO_PortSource: selects the GPIO port to be used as source for EXTI lines.
+ * This parameter can be GPIO_PortSourceGPIOx where x can be (A..G).
+ * @param GPIO_PinSource: specifies the EXTI line to be configured.
+ * This parameter can be GPIO_PinSourcex where x can be (0..15).
+ * @retval None
+ */
+void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource)
+{
+ uint32_t tmp = 0x00;
+ /* Check the parameters */
+ assert_param(IS_GPIO_EXTI_PORT_SOURCE(GPIO_PortSource));
+ assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
+
+ tmp = ((uint32_t)0x0F) << (0x04 * (GPIO_PinSource & (uint8_t)0x03));
+ AFIO->EXTICR[GPIO_PinSource >> 0x02] &= ~tmp;
+ AFIO->EXTICR[GPIO_PinSource >> 0x02] |= (((uint32_t)GPIO_PortSource) << (0x04 * (GPIO_PinSource & (uint8_t)0x03)));
+}
+
+/**
+ * @brief Selects the Ethernet media interface.
+ * @note This function applies only to STM32 Connectivity line devices.
+ * @param GPIO_ETH_MediaInterface: specifies the Media Interface mode.
+ * This parameter can be one of the following values:
+ * @arg GPIO_ETH_MediaInterface_MII: MII mode
+ * @arg GPIO_ETH_MediaInterface_RMII: RMII mode
+ * @retval None
+ */
+void GPIO_ETH_MediaInterfaceConfig(uint32_t GPIO_ETH_MediaInterface)
+{
+ assert_param(IS_GPIO_ETH_MEDIA_INTERFACE(GPIO_ETH_MediaInterface));
+
+ /* Configure MII_RMII selection bit */
+ *(__IO uint32_t *) MAPR_MII_RMII_SEL_BB = GPIO_ETH_MediaInterface;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_i2c.c b/st_fw_lib/src/stm32f10x_i2c.c
new file mode 100644
index 0000000..4ea321c
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_i2c.c
@@ -0,0 +1,1331 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_i2c.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the I2C firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_i2c.h"
+#include "stm32f10x_rcc.h"
+
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup I2C
+ * @brief I2C driver modules
+ * @{
+ */
+
+/** @defgroup I2C_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup I2C_Private_Defines
+ * @{
+ */
+
+/* I2C SPE mask */
+#define CR1_PE_Set ((uint16_t)0x0001)
+#define CR1_PE_Reset ((uint16_t)0xFFFE)
+
+/* I2C START mask */
+#define CR1_START_Set ((uint16_t)0x0100)
+#define CR1_START_Reset ((uint16_t)0xFEFF)
+
+/* I2C STOP mask */
+#define CR1_STOP_Set ((uint16_t)0x0200)
+#define CR1_STOP_Reset ((uint16_t)0xFDFF)
+
+/* I2C ACK mask */
+#define CR1_ACK_Set ((uint16_t)0x0400)
+#define CR1_ACK_Reset ((uint16_t)0xFBFF)
+
+/* I2C ENGC mask */
+#define CR1_ENGC_Set ((uint16_t)0x0040)
+#define CR1_ENGC_Reset ((uint16_t)0xFFBF)
+
+/* I2C SWRST mask */
+#define CR1_SWRST_Set ((uint16_t)0x8000)
+#define CR1_SWRST_Reset ((uint16_t)0x7FFF)
+
+/* I2C PEC mask */
+#define CR1_PEC_Set ((uint16_t)0x1000)
+#define CR1_PEC_Reset ((uint16_t)0xEFFF)
+
+/* I2C ENPEC mask */
+#define CR1_ENPEC_Set ((uint16_t)0x0020)
+#define CR1_ENPEC_Reset ((uint16_t)0xFFDF)
+
+/* I2C ENARP mask */
+#define CR1_ENARP_Set ((uint16_t)0x0010)
+#define CR1_ENARP_Reset ((uint16_t)0xFFEF)
+
+/* I2C NOSTRETCH mask */
+#define CR1_NOSTRETCH_Set ((uint16_t)0x0080)
+#define CR1_NOSTRETCH_Reset ((uint16_t)0xFF7F)
+
+/* I2C registers Masks */
+#define CR1_CLEAR_Mask ((uint16_t)0xFBF5)
+
+/* I2C DMAEN mask */
+#define CR2_DMAEN_Set ((uint16_t)0x0800)
+#define CR2_DMAEN_Reset ((uint16_t)0xF7FF)
+
+/* I2C LAST mask */
+#define CR2_LAST_Set ((uint16_t)0x1000)
+#define CR2_LAST_Reset ((uint16_t)0xEFFF)
+
+/* I2C FREQ mask */
+#define CR2_FREQ_Reset ((uint16_t)0xFFC0)
+
+/* I2C ADD0 mask */
+#define OAR1_ADD0_Set ((uint16_t)0x0001)
+#define OAR1_ADD0_Reset ((uint16_t)0xFFFE)
+
+/* I2C ENDUAL mask */
+#define OAR2_ENDUAL_Set ((uint16_t)0x0001)
+#define OAR2_ENDUAL_Reset ((uint16_t)0xFFFE)
+
+/* I2C ADD2 mask */
+#define OAR2_ADD2_Reset ((uint16_t)0xFF01)
+
+/* I2C F/S mask */
+#define CCR_FS_Set ((uint16_t)0x8000)
+
+/* I2C CCR mask */
+#define CCR_CCR_Set ((uint16_t)0x0FFF)
+
+/* I2C FLAG mask */
+#define FLAG_Mask ((uint32_t)0x00FFFFFF)
+
+/* I2C Interrupt Enable mask */
+#define ITEN_Mask ((uint32_t)0x07000000)
+
+/**
+ * @}
+ */
+
+/** @defgroup I2C_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup I2C_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup I2C_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup I2C_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the I2Cx peripheral registers to their default reset values.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @retval None
+ */
+void I2C_DeInit(I2C_TypeDef* I2Cx)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+
+ if (I2Cx == I2C1)
+ {
+ /* Enable I2C1 reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE);
+ /* Release I2C1 from reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE);
+ }
+ else
+ {
+ /* Enable I2C2 reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, ENABLE);
+ /* Release I2C2 from reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, DISABLE);
+ }
+}
+
+/**
+ * @brief Initializes the I2Cx peripheral according to the specified
+ * parameters in the I2C_InitStruct.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_InitStruct: pointer to a I2C_InitTypeDef structure that
+ * contains the configuration information for the specified I2C peripheral.
+ * @retval None
+ */
+void I2C_Init(I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct)
+{
+ uint16_t tmpreg = 0, freqrange = 0;
+ uint16_t result = 0x04;
+ uint32_t pclk1 = 8000000;
+ RCC_ClocksTypeDef rcc_clocks;
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_CLOCK_SPEED(I2C_InitStruct->I2C_ClockSpeed));
+ assert_param(IS_I2C_MODE(I2C_InitStruct->I2C_Mode));
+ assert_param(IS_I2C_DUTY_CYCLE(I2C_InitStruct->I2C_DutyCycle));
+ assert_param(IS_I2C_OWN_ADDRESS1(I2C_InitStruct->I2C_OwnAddress1));
+ assert_param(IS_I2C_ACK_STATE(I2C_InitStruct->I2C_Ack));
+ assert_param(IS_I2C_ACKNOWLEDGE_ADDRESS(I2C_InitStruct->I2C_AcknowledgedAddress));
+
+/*---------------------------- I2Cx CR2 Configuration ------------------------*/
+ /* Get the I2Cx CR2 value */
+ tmpreg = I2Cx->CR2;
+ /* Clear frequency FREQ[5:0] bits */
+ tmpreg &= CR2_FREQ_Reset;
+ /* Get pclk1 frequency value */
+ RCC_GetClocksFreq(&rcc_clocks);
+ pclk1 = rcc_clocks.PCLK1_Frequency;
+ /* Set frequency bits depending on pclk1 value */
+ freqrange = (uint16_t)(pclk1 / 1000000);
+ tmpreg |= freqrange;
+ /* Write to I2Cx CR2 */
+ I2Cx->CR2 = tmpreg;
+
+/*---------------------------- I2Cx CCR Configuration ------------------------*/
+ /* Disable the selected I2C peripheral to configure TRISE */
+ I2Cx->CR1 &= CR1_PE_Reset;
+ /* Reset tmpreg value */
+ /* Clear F/S, DUTY and CCR[11:0] bits */
+ tmpreg = 0;
+
+ /* Configure speed in standard mode */
+ if (I2C_InitStruct->I2C_ClockSpeed <= 100000)
+ {
+ /* Standard mode speed calculate */
+ result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed << 1));
+ /* Test if CCR value is under 0x4*/
+ if (result < 0x04)
+ {
+ /* Set minimum allowed value */
+ result = 0x04;
+ }
+ /* Set speed value for standard mode */
+ tmpreg |= result;
+ /* Set Maximum Rise Time for standard mode */
+ I2Cx->TRISE = freqrange + 1;
+ }
+ /* Configure speed in fast mode */
+ else /*(I2C_InitStruct->I2C_ClockSpeed <= 400000)*/
+ {
+ if (I2C_InitStruct->I2C_DutyCycle == I2C_DutyCycle_2)
+ {
+ /* Fast mode speed calculate: Tlow/Thigh = 2 */
+ result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed * 3));
+ }
+ else /*I2C_InitStruct->I2C_DutyCycle == I2C_DutyCycle_16_9*/
+ {
+ /* Fast mode speed calculate: Tlow/Thigh = 16/9 */
+ result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed * 25));
+ /* Set DUTY bit */
+ result |= I2C_DutyCycle_16_9;
+ }
+
+ /* Test if CCR value is under 0x1*/
+ if ((result & CCR_CCR_Set) == 0)
+ {
+ /* Set minimum allowed value */
+ result |= (uint16_t)0x0001;
+ }
+ /* Set speed value and set F/S bit for fast mode */
+ tmpreg |= (uint16_t)(result | CCR_FS_Set);
+ /* Set Maximum Rise Time for fast mode */
+ I2Cx->TRISE = (uint16_t)(((freqrange * (uint16_t)300) / (uint16_t)1000) + (uint16_t)1);
+ }
+
+ /* Write to I2Cx CCR */
+ I2Cx->CCR = tmpreg;
+ /* Enable the selected I2C peripheral */
+ I2Cx->CR1 |= CR1_PE_Set;
+
+/*---------------------------- I2Cx CR1 Configuration ------------------------*/
+ /* Get the I2Cx CR1 value */
+ tmpreg = I2Cx->CR1;
+ /* Clear ACK, SMBTYPE and SMBUS bits */
+ tmpreg &= CR1_CLEAR_Mask;
+ /* Configure I2Cx: mode and acknowledgement */
+ /* Set SMBTYPE and SMBUS bits according to I2C_Mode value */
+ /* Set ACK bit according to I2C_Ack value */
+ tmpreg |= (uint16_t)((uint32_t)I2C_InitStruct->I2C_Mode | I2C_InitStruct->I2C_Ack);
+ /* Write to I2Cx CR1 */
+ I2Cx->CR1 = tmpreg;
+
+/*---------------------------- I2Cx OAR1 Configuration -----------------------*/
+ /* Set I2Cx Own Address1 and acknowledged address */
+ I2Cx->OAR1 = (I2C_InitStruct->I2C_AcknowledgedAddress | I2C_InitStruct->I2C_OwnAddress1);
+}
+
+/**
+ * @brief Fills each I2C_InitStruct member with its default value.
+ * @param I2C_InitStruct: pointer to an I2C_InitTypeDef structure which will be initialized.
+ * @retval None
+ */
+void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct)
+{
+/*---------------- Reset I2C init structure parameters values ----------------*/
+ /* initialize the I2C_ClockSpeed member */
+ I2C_InitStruct->I2C_ClockSpeed = 5000;
+ /* Initialize the I2C_Mode member */
+ I2C_InitStruct->I2C_Mode = I2C_Mode_I2C;
+ /* Initialize the I2C_DutyCycle member */
+ I2C_InitStruct->I2C_DutyCycle = I2C_DutyCycle_2;
+ /* Initialize the I2C_OwnAddress1 member */
+ I2C_InitStruct->I2C_OwnAddress1 = 0;
+ /* Initialize the I2C_Ack member */
+ I2C_InitStruct->I2C_Ack = I2C_Ack_Disable;
+ /* Initialize the I2C_AcknowledgedAddress member */
+ I2C_InitStruct->I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
+}
+
+/**
+ * @brief Enables or disables the specified I2C peripheral.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2Cx peripheral.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_Cmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected I2C peripheral */
+ I2Cx->CR1 |= CR1_PE_Set;
+ }
+ else
+ {
+ /* Disable the selected I2C peripheral */
+ I2Cx->CR1 &= CR1_PE_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified I2C DMA requests.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2C DMA transfer.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_DMACmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected I2C DMA requests */
+ I2Cx->CR2 |= CR2_DMAEN_Set;
+ }
+ else
+ {
+ /* Disable the selected I2C DMA requests */
+ I2Cx->CR2 &= CR2_DMAEN_Reset;
+ }
+}
+
+/**
+ * @brief Specifies if the next DMA transfer will be the last one.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2C DMA last transfer.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_DMALastTransferCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Next DMA transfer is the last transfer */
+ I2Cx->CR2 |= CR2_LAST_Set;
+ }
+ else
+ {
+ /* Next DMA transfer is not the last transfer */
+ I2Cx->CR2 &= CR2_LAST_Reset;
+ }
+}
+
+/**
+ * @brief Generates I2Cx communication START condition.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2C START condition generation.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None.
+ */
+void I2C_GenerateSTART(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Generate a START condition */
+ I2Cx->CR1 |= CR1_START_Set;
+ }
+ else
+ {
+ /* Disable the START condition generation */
+ I2Cx->CR1 &= CR1_START_Reset;
+ }
+}
+
+/**
+ * @brief Generates I2Cx communication STOP condition.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2C STOP condition generation.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None.
+ */
+void I2C_GenerateSTOP(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Generate a STOP condition */
+ I2Cx->CR1 |= CR1_STOP_Set;
+ }
+ else
+ {
+ /* Disable the STOP condition generation */
+ I2Cx->CR1 &= CR1_STOP_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified I2C acknowledge feature.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2C Acknowledgement.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None.
+ */
+void I2C_AcknowledgeConfig(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the acknowledgement */
+ I2Cx->CR1 |= CR1_ACK_Set;
+ }
+ else
+ {
+ /* Disable the acknowledgement */
+ I2Cx->CR1 &= CR1_ACK_Reset;
+ }
+}
+
+/**
+ * @brief Configures the specified I2C own address2.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param Address: specifies the 7bit I2C own address2.
+ * @retval None.
+ */
+void I2C_OwnAddress2Config(I2C_TypeDef* I2Cx, uint8_t Address)
+{
+ uint16_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+
+ /* Get the old register value */
+ tmpreg = I2Cx->OAR2;
+
+ /* Reset I2Cx Own address2 bit [7:1] */
+ tmpreg &= OAR2_ADD2_Reset;
+
+ /* Set I2Cx Own address2 */
+ tmpreg |= (uint16_t)((uint16_t)Address & (uint16_t)0x00FE);
+
+ /* Store the new register value */
+ I2Cx->OAR2 = tmpreg;
+}
+
+/**
+ * @brief Enables or disables the specified I2C dual addressing mode.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2C dual addressing mode.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_DualAddressCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable dual addressing mode */
+ I2Cx->OAR2 |= OAR2_ENDUAL_Set;
+ }
+ else
+ {
+ /* Disable dual addressing mode */
+ I2Cx->OAR2 &= OAR2_ENDUAL_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified I2C general call feature.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2C General call.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_GeneralCallCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable generall call */
+ I2Cx->CR1 |= CR1_ENGC_Set;
+ }
+ else
+ {
+ /* Disable generall call */
+ I2Cx->CR1 &= CR1_ENGC_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified I2C interrupts.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_IT: specifies the I2C interrupts sources to be enabled or disabled.
+ * This parameter can be any combination of the following values:
+ * @arg I2C_IT_BUF: Buffer interrupt mask
+ * @arg I2C_IT_EVT: Event interrupt mask
+ * @arg I2C_IT_ERR: Error interrupt mask
+ * @param NewState: new state of the specified I2C interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_ITConfig(I2C_TypeDef* I2Cx, uint16_t I2C_IT, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ assert_param(IS_I2C_CONFIG_IT(I2C_IT));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected I2C interrupts */
+ I2Cx->CR2 |= I2C_IT;
+ }
+ else
+ {
+ /* Disable the selected I2C interrupts */
+ I2Cx->CR2 &= (uint16_t)~I2C_IT;
+ }
+}
+
+/**
+ * @brief Sends a data byte through the I2Cx peripheral.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param Data: Byte to be transmitted..
+ * @retval None
+ */
+void I2C_SendData(I2C_TypeDef* I2Cx, uint8_t Data)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ /* Write in the DR register the data to be sent */
+ I2Cx->DR = Data;
+}
+
+/**
+ * @brief Returns the most recent received data by the I2Cx peripheral.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @retval The value of the received data.
+ */
+uint8_t I2C_ReceiveData(I2C_TypeDef* I2Cx)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ /* Return the data in the DR register */
+ return (uint8_t)I2Cx->DR;
+}
+
+/**
+ * @brief Transmits the address byte to select the slave device.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param Address: specifies the slave address which will be transmitted
+ * @param I2C_Direction: specifies whether the I2C device will be a
+ * Transmitter or a Receiver. This parameter can be one of the following values
+ * @arg I2C_Direction_Transmitter: Transmitter mode
+ * @arg I2C_Direction_Receiver: Receiver mode
+ * @retval None.
+ */
+void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, uint8_t Address, uint8_t I2C_Direction)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_DIRECTION(I2C_Direction));
+ /* Test on the direction to set/reset the read/write bit */
+ if (I2C_Direction != I2C_Direction_Transmitter)
+ {
+ /* Set the address bit0 for read */
+ Address |= OAR1_ADD0_Set;
+ }
+ else
+ {
+ /* Reset the address bit0 for write */
+ Address &= OAR1_ADD0_Reset;
+ }
+ /* Send the address */
+ I2Cx->DR = Address;
+}
+
+/**
+ * @brief Reads the specified I2C register and returns its value.
+ * @param I2C_Register: specifies the register to read.
+ * This parameter can be one of the following values:
+ * @arg I2C_Register_CR1: CR1 register.
+ * @arg I2C_Register_CR2: CR2 register.
+ * @arg I2C_Register_OAR1: OAR1 register.
+ * @arg I2C_Register_OAR2: OAR2 register.
+ * @arg I2C_Register_DR: DR register.
+ * @arg I2C_Register_SR1: SR1 register.
+ * @arg I2C_Register_SR2: SR2 register.
+ * @arg I2C_Register_CCR: CCR register.
+ * @arg I2C_Register_TRISE: TRISE register.
+ * @retval The value of the read register.
+ */
+uint16_t I2C_ReadRegister(I2C_TypeDef* I2Cx, uint8_t I2C_Register)
+{
+ __IO uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_REGISTER(I2C_Register));
+
+ tmp = (uint32_t) I2Cx;
+ tmp += I2C_Register;
+
+ /* Return the selected register value */
+ return (*(__IO uint16_t *) tmp);
+}
+
+/**
+ * @brief Enables or disables the specified I2C software reset.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2C software reset.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Peripheral under reset */
+ I2Cx->CR1 |= CR1_SWRST_Set;
+ }
+ else
+ {
+ /* Peripheral not under reset */
+ I2Cx->CR1 &= CR1_SWRST_Reset;
+ }
+}
+
+/**
+ * @brief Selects the specified I2C NACK position in master receiver mode.
+ * This function is useful in I2C Master Receiver mode when the number
+ * of data to be received is equal to 2. In this case, this function
+ * should be called (with parameter I2C_NACKPosition_Next) before data
+ * reception starts,as described in the 2-byte reception procedure
+ * recommended in Reference Manual in Section: Master receiver.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_NACKPosition: specifies the NACK position.
+ * This parameter can be one of the following values:
+ * @arg I2C_NACKPosition_Next: indicates that the next byte will be the last
+ * received byte.
+ * @arg I2C_NACKPosition_Current: indicates that current byte is the last
+ * received byte.
+ *
+ * @note This function configures the same bit (POS) as I2C_PECPositionConfig()
+ * but is intended to be used in I2C mode while I2C_PECPositionConfig()
+ * is intended to used in SMBUS mode.
+ *
+ * @retval None
+ */
+void I2C_NACKPositionConfig(I2C_TypeDef* I2Cx, uint16_t I2C_NACKPosition)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_NACK_POSITION(I2C_NACKPosition));
+
+ /* Check the input parameter */
+ if (I2C_NACKPosition == I2C_NACKPosition_Next)
+ {
+ /* Next byte in shift register is the last received byte */
+ I2Cx->CR1 |= I2C_NACKPosition_Next;
+ }
+ else
+ {
+ /* Current byte in shift register is the last received byte */
+ I2Cx->CR1 &= I2C_NACKPosition_Current;
+ }
+}
+
+/**
+ * @brief Drives the SMBusAlert pin high or low for the specified I2C.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_SMBusAlert: specifies SMBAlert pin level.
+ * This parameter can be one of the following values:
+ * @arg I2C_SMBusAlert_Low: SMBAlert pin driven low
+ * @arg I2C_SMBusAlert_High: SMBAlert pin driven high
+ * @retval None
+ */
+void I2C_SMBusAlertConfig(I2C_TypeDef* I2Cx, uint16_t I2C_SMBusAlert)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_SMBUS_ALERT(I2C_SMBusAlert));
+ if (I2C_SMBusAlert == I2C_SMBusAlert_Low)
+ {
+ /* Drive the SMBusAlert pin Low */
+ I2Cx->CR1 |= I2C_SMBusAlert_Low;
+ }
+ else
+ {
+ /* Drive the SMBusAlert pin High */
+ I2Cx->CR1 &= I2C_SMBusAlert_High;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified I2C PEC transfer.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2C PEC transmission.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_TransmitPEC(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected I2C PEC transmission */
+ I2Cx->CR1 |= CR1_PEC_Set;
+ }
+ else
+ {
+ /* Disable the selected I2C PEC transmission */
+ I2Cx->CR1 &= CR1_PEC_Reset;
+ }
+}
+
+/**
+ * @brief Selects the specified I2C PEC position.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_PECPosition: specifies the PEC position.
+ * This parameter can be one of the following values:
+ * @arg I2C_PECPosition_Next: indicates that the next byte is PEC
+ * @arg I2C_PECPosition_Current: indicates that current byte is PEC
+ *
+ * @note This function configures the same bit (POS) as I2C_NACKPositionConfig()
+ * but is intended to be used in SMBUS mode while I2C_NACKPositionConfig()
+ * is intended to used in I2C mode.
+ *
+ * @retval None
+ */
+void I2C_PECPositionConfig(I2C_TypeDef* I2Cx, uint16_t I2C_PECPosition)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_PEC_POSITION(I2C_PECPosition));
+ if (I2C_PECPosition == I2C_PECPosition_Next)
+ {
+ /* Next byte in shift register is PEC */
+ I2Cx->CR1 |= I2C_PECPosition_Next;
+ }
+ else
+ {
+ /* Current byte in shift register is PEC */
+ I2Cx->CR1 &= I2C_PECPosition_Current;
+ }
+}
+
+/**
+ * @brief Enables or disables the PEC value calculation of the transferred bytes.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2Cx PEC value calculation.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_CalculatePEC(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected I2C PEC calculation */
+ I2Cx->CR1 |= CR1_ENPEC_Set;
+ }
+ else
+ {
+ /* Disable the selected I2C PEC calculation */
+ I2Cx->CR1 &= CR1_ENPEC_Reset;
+ }
+}
+
+/**
+ * @brief Returns the PEC value for the specified I2C.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @retval The PEC value.
+ */
+uint8_t I2C_GetPEC(I2C_TypeDef* I2Cx)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ /* Return the selected I2C PEC value */
+ return ((I2Cx->SR2) >> 8);
+}
+
+/**
+ * @brief Enables or disables the specified I2C ARP.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2Cx ARP.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_ARPCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected I2C ARP */
+ I2Cx->CR1 |= CR1_ENARP_Set;
+ }
+ else
+ {
+ /* Disable the selected I2C ARP */
+ I2Cx->CR1 &= CR1_ENARP_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified I2C Clock stretching.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param NewState: new state of the I2Cx Clock stretching.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState == DISABLE)
+ {
+ /* Enable the selected I2C Clock stretching */
+ I2Cx->CR1 |= CR1_NOSTRETCH_Set;
+ }
+ else
+ {
+ /* Disable the selected I2C Clock stretching */
+ I2Cx->CR1 &= CR1_NOSTRETCH_Reset;
+ }
+}
+
+/**
+ * @brief Selects the specified I2C fast mode duty cycle.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_DutyCycle: specifies the fast mode duty cycle.
+ * This parameter can be one of the following values:
+ * @arg I2C_DutyCycle_2: I2C fast mode Tlow/Thigh = 2
+ * @arg I2C_DutyCycle_16_9: I2C fast mode Tlow/Thigh = 16/9
+ * @retval None
+ */
+void I2C_FastModeDutyCycleConfig(I2C_TypeDef* I2Cx, uint16_t I2C_DutyCycle)
+{
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_DUTY_CYCLE(I2C_DutyCycle));
+ if (I2C_DutyCycle != I2C_DutyCycle_16_9)
+ {
+ /* I2C fast mode Tlow/Thigh=2 */
+ I2Cx->CCR &= I2C_DutyCycle_2;
+ }
+ else
+ {
+ /* I2C fast mode Tlow/Thigh=16/9 */
+ I2Cx->CCR |= I2C_DutyCycle_16_9;
+ }
+}
+
+
+
+/**
+ * @brief
+ ****************************************************************************************
+ *
+ * I2C State Monitoring Functions
+ *
+ ****************************************************************************************
+ * This I2C driver provides three different ways for I2C state monitoring
+ * depending on the application requirements and constraints:
+ *
+ *
+ * 1) Basic state monitoring:
+ * Using I2C_CheckEvent() function:
+ * It compares the status registers (SR1 and SR2) content to a given event
+ * (can be the combination of one or more flags).
+ * It returns SUCCESS if the current status includes the given flags
+ * and returns ERROR if one or more flags are missing in the current status.
+ * - When to use:
+ * - This function is suitable for most applications as well as for startup
+ * activity since the events are fully described in the product reference manual
+ * (RM0008).
+ * - It is also suitable for users who need to define their own events.
+ * - Limitations:
+ * - If an error occurs (ie. error flags are set besides to the monitored flags),
+ * the I2C_CheckEvent() function may return SUCCESS despite the communication
+ * hold or corrupted real state.
+ * In this case, it is advised to use error interrupts to monitor the error
+ * events and handle them in the interrupt IRQ handler.
+ *
+ * @note
+ * For error management, it is advised to use the following functions:
+ * - I2C_ITConfig() to configure and enable the error interrupts (I2C_IT_ERR).
+ * - I2Cx_ER_IRQHandler() which is called when the error interrupt occurs.
+ * Where x is the peripheral instance (I2C1, I2C2 ...)
+ * - I2C_GetFlagStatus() or I2C_GetITStatus() to be called into I2Cx_ER_IRQHandler()
+ * in order to determine which error occured.
+ * - I2C_ClearFlag() or I2C_ClearITPendingBit() and/or I2C_SoftwareResetCmd()
+ * and/or I2C_GenerateStop() in order to clear the error flag and source,
+ * and return to correct communication status.
+ *
+ *
+ * 2) Advanced state monitoring:
+ * Using the function I2C_GetLastEvent() which returns the image of both status
+ * registers in a single word (uint32_t) (Status Register 2 value is shifted left
+ * by 16 bits and concatenated to Status Register 1).
+ * - When to use:
+ * - This function is suitable for the same applications above but it allows to
+ * overcome the mentioned limitation of I2C_GetFlagStatus() function.
+ * The returned value could be compared to events already defined in the
+ * library (stm32f10x_i2c.h) or to custom values defined by user.
+ * - This function is suitable when multiple flags are monitored at the same time.
+ * - At the opposite of I2C_CheckEvent() function, this function allows user to
+ * choose when an event is accepted (when all events flags are set and no
+ * other flags are set or just when the needed flags are set like
+ * I2C_CheckEvent() function).
+ * - Limitations:
+ * - User may need to define his own events.
+ * - Same remark concerning the error management is applicable for this
+ * function if user decides to check only regular communication flags (and
+ * ignores error flags).
+ *
+ *
+ * 3) Flag-based state monitoring:
+ * Using the function I2C_GetFlagStatus() which simply returns the status of
+ * one single flag (ie. I2C_FLAG_RXNE ...).
+ * - When to use:
+ * - This function could be used for specific applications or in debug phase.
+ * - It is suitable when only one flag checking is needed (most I2C events
+ * are monitored through multiple flags).
+ * - Limitations:
+ * - When calling this function, the Status register is accessed. Some flags are
+ * cleared when the status register is accessed. So checking the status
+ * of one Flag, may clear other ones.
+ * - Function may need to be called twice or more in order to monitor one
+ * single event.
+ *
+ * For detailed description of Events, please refer to section I2C_Events in
+ * stm32f10x_i2c.h file.
+ *
+ */
+
+/**
+ *
+ * 1) Basic state monitoring
+ *******************************************************************************
+ */
+
+/**
+ * @brief Checks whether the last I2Cx Event is equal to the one passed
+ * as parameter.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_EVENT: specifies the event to be checked.
+ * This parameter can be one of the following values:
+ * @arg I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED : EV1
+ * @arg I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED : EV1
+ * @arg I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED : EV1
+ * @arg I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED : EV1
+ * @arg I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED : EV1
+ * @arg I2C_EVENT_SLAVE_BYTE_RECEIVED : EV2
+ * @arg (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_DUALF) : EV2
+ * @arg (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_GENCALL) : EV2
+ * @arg I2C_EVENT_SLAVE_BYTE_TRANSMITTED : EV3
+ * @arg (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_DUALF) : EV3
+ * @arg (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_GENCALL) : EV3
+ * @arg I2C_EVENT_SLAVE_ACK_FAILURE : EV3_2
+ * @arg I2C_EVENT_SLAVE_STOP_DETECTED : EV4
+ * @arg I2C_EVENT_MASTER_MODE_SELECT : EV5
+ * @arg I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED : EV6
+ * @arg I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED : EV6
+ * @arg I2C_EVENT_MASTER_BYTE_RECEIVED : EV7
+ * @arg I2C_EVENT_MASTER_BYTE_TRANSMITTING : EV8
+ * @arg I2C_EVENT_MASTER_BYTE_TRANSMITTED : EV8_2
+ * @arg I2C_EVENT_MASTER_MODE_ADDRESS10 : EV9
+ *
+ * @note: For detailed description of Events, please refer to section
+ * I2C_Events in stm32f10x_i2c.h file.
+ *
+ * @retval An ErrorStatus enumeration value:
+ * - SUCCESS: Last event is equal to the I2C_EVENT
+ * - ERROR: Last event is different from the I2C_EVENT
+ */
+ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, uint32_t I2C_EVENT)
+{
+ uint32_t lastevent = 0;
+ uint32_t flag1 = 0, flag2 = 0;
+ ErrorStatus status = ERROR;
+
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_EVENT(I2C_EVENT));
+
+ /* Read the I2Cx status register */
+ flag1 = I2Cx->SR1;
+ flag2 = I2Cx->SR2;
+ flag2 = flag2 << 16;
+
+ /* Get the last event value from I2C status register */
+ lastevent = (flag1 | flag2) & FLAG_Mask;
+
+ /* Check whether the last event contains the I2C_EVENT */
+ if ((lastevent & I2C_EVENT) == I2C_EVENT)
+ {
+ /* SUCCESS: last event is equal to I2C_EVENT */
+ status = SUCCESS;
+ }
+ else
+ {
+ /* ERROR: last event is different from I2C_EVENT */
+ status = ERROR;
+ }
+ /* Return status */
+ return status;
+}
+
+/**
+ *
+ * 2) Advanced state monitoring
+ *******************************************************************************
+ */
+
+/**
+ * @brief Returns the last I2Cx Event.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ *
+ * @note: For detailed description of Events, please refer to section
+ * I2C_Events in stm32f10x_i2c.h file.
+ *
+ * @retval The last event
+ */
+uint32_t I2C_GetLastEvent(I2C_TypeDef* I2Cx)
+{
+ uint32_t lastevent = 0;
+ uint32_t flag1 = 0, flag2 = 0;
+
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+
+ /* Read the I2Cx status register */
+ flag1 = I2Cx->SR1;
+ flag2 = I2Cx->SR2;
+ flag2 = flag2 << 16;
+
+ /* Get the last event value from I2C status register */
+ lastevent = (flag1 | flag2) & FLAG_Mask;
+
+ /* Return status */
+ return lastevent;
+}
+
+/**
+ *
+ * 3) Flag-based state monitoring
+ *******************************************************************************
+ */
+
+/**
+ * @brief Checks whether the specified I2C flag is set or not.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_FLAG: specifies the flag to check.
+ * This parameter can be one of the following values:
+ * @arg I2C_FLAG_DUALF: Dual flag (Slave mode)
+ * @arg I2C_FLAG_SMBHOST: SMBus host header (Slave mode)
+ * @arg I2C_FLAG_SMBDEFAULT: SMBus default header (Slave mode)
+ * @arg I2C_FLAG_GENCALL: General call header flag (Slave mode)
+ * @arg I2C_FLAG_TRA: Transmitter/Receiver flag
+ * @arg I2C_FLAG_BUSY: Bus busy flag
+ * @arg I2C_FLAG_MSL: Master/Slave flag
+ * @arg I2C_FLAG_SMBALERT: SMBus Alert flag
+ * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag
+ * @arg I2C_FLAG_PECERR: PEC error in reception flag
+ * @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode)
+ * @arg I2C_FLAG_AF: Acknowledge failure flag
+ * @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode)
+ * @arg I2C_FLAG_BERR: Bus error flag
+ * @arg I2C_FLAG_TXE: Data register empty flag (Transmitter)
+ * @arg I2C_FLAG_RXNE: Data register not empty (Receiver) flag
+ * @arg I2C_FLAG_STOPF: Stop detection flag (Slave mode)
+ * @arg I2C_FLAG_ADD10: 10-bit header sent flag (Master mode)
+ * @arg I2C_FLAG_BTF: Byte transfer finished flag
+ * @arg I2C_FLAG_ADDR: Address sent flag (Master mode) "ADSL"
+ * Address matched flag (Slave mode)"ENDA"
+ * @arg I2C_FLAG_SB: Start bit flag (Master mode)
+ * @retval The new state of I2C_FLAG (SET or RESET).
+ */
+FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+ __IO uint32_t i2creg = 0, i2cxbase = 0;
+
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_GET_FLAG(I2C_FLAG));
+
+ /* Get the I2Cx peripheral base address */
+ i2cxbase = (uint32_t)I2Cx;
+
+ /* Read flag register index */
+ i2creg = I2C_FLAG >> 28;
+
+ /* Get bit[23:0] of the flag */
+ I2C_FLAG &= FLAG_Mask;
+
+ if(i2creg != 0)
+ {
+ /* Get the I2Cx SR1 register address */
+ i2cxbase += 0x14;
+ }
+ else
+ {
+ /* Flag in I2Cx SR2 Register */
+ I2C_FLAG = (uint32_t)(I2C_FLAG >> 16);
+ /* Get the I2Cx SR2 register address */
+ i2cxbase += 0x18;
+ }
+
+ if(((*(__IO uint32_t *)i2cxbase) & I2C_FLAG) != (uint32_t)RESET)
+ {
+ /* I2C_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* I2C_FLAG is reset */
+ bitstatus = RESET;
+ }
+
+ /* Return the I2C_FLAG status */
+ return bitstatus;
+}
+
+
+
+/**
+ * @brief Clears the I2Cx's pending flags.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_FLAG: specifies the flag to clear.
+ * This parameter can be any combination of the following values:
+ * @arg I2C_FLAG_SMBALERT: SMBus Alert flag
+ * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag
+ * @arg I2C_FLAG_PECERR: PEC error in reception flag
+ * @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode)
+ * @arg I2C_FLAG_AF: Acknowledge failure flag
+ * @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode)
+ * @arg I2C_FLAG_BERR: Bus error flag
+ *
+ * @note
+ * - STOPF (STOP detection) is cleared by software sequence: a read operation
+ * to I2C_SR1 register (I2C_GetFlagStatus()) followed by a write operation
+ * to I2C_CR1 register (I2C_Cmd() to re-enable the I2C peripheral).
+ * - ADD10 (10-bit header sent) is cleared by software sequence: a read
+ * operation to I2C_SR1 (I2C_GetFlagStatus()) followed by writing the
+ * second byte of the address in DR register.
+ * - BTF (Byte Transfer Finished) is cleared by software sequence: a read
+ * operation to I2C_SR1 register (I2C_GetFlagStatus()) followed by a
+ * read/write to I2C_DR register (I2C_SendData()).
+ * - ADDR (Address sent) is cleared by software sequence: a read operation to
+ * I2C_SR1 register (I2C_GetFlagStatus()) followed by a read operation to
+ * I2C_SR2 register ((void)(I2Cx->SR2)).
+ * - SB (Start Bit) is cleared software sequence: a read operation to I2C_SR1
+ * register (I2C_GetFlagStatus()) followed by a write operation to I2C_DR
+ * register (I2C_SendData()).
+ * @retval None
+ */
+void I2C_ClearFlag(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG)
+{
+ uint32_t flagpos = 0;
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_CLEAR_FLAG(I2C_FLAG));
+ /* Get the I2C flag position */
+ flagpos = I2C_FLAG & FLAG_Mask;
+ /* Clear the selected I2C flag */
+ I2Cx->SR1 = (uint16_t)~flagpos;
+}
+
+/**
+ * @brief Checks whether the specified I2C interrupt has occurred or not.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_IT: specifies the interrupt source to check.
+ * This parameter can be one of the following values:
+ * @arg I2C_IT_SMBALERT: SMBus Alert flag
+ * @arg I2C_IT_TIMEOUT: Timeout or Tlow error flag
+ * @arg I2C_IT_PECERR: PEC error in reception flag
+ * @arg I2C_IT_OVR: Overrun/Underrun flag (Slave mode)
+ * @arg I2C_IT_AF: Acknowledge failure flag
+ * @arg I2C_IT_ARLO: Arbitration lost flag (Master mode)
+ * @arg I2C_IT_BERR: Bus error flag
+ * @arg I2C_IT_TXE: Data register empty flag (Transmitter)
+ * @arg I2C_IT_RXNE: Data register not empty (Receiver) flag
+ * @arg I2C_IT_STOPF: Stop detection flag (Slave mode)
+ * @arg I2C_IT_ADD10: 10-bit header sent flag (Master mode)
+ * @arg I2C_IT_BTF: Byte transfer finished flag
+ * @arg I2C_IT_ADDR: Address sent flag (Master mode) "ADSL"
+ * Address matched flag (Slave mode)"ENDAD"
+ * @arg I2C_IT_SB: Start bit flag (Master mode)
+ * @retval The new state of I2C_IT (SET or RESET).
+ */
+ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, uint32_t I2C_IT)
+{
+ ITStatus bitstatus = RESET;
+ uint32_t enablestatus = 0;
+
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_GET_IT(I2C_IT));
+
+ /* Check if the interrupt source is enabled or not */
+ enablestatus = (uint32_t)(((I2C_IT & ITEN_Mask) >> 16) & (I2Cx->CR2)) ;
+
+ /* Get bit[23:0] of the flag */
+ I2C_IT &= FLAG_Mask;
+
+ /* Check the status of the specified I2C flag */
+ if (((I2Cx->SR1 & I2C_IT) != (uint32_t)RESET) && enablestatus)
+ {
+ /* I2C_IT is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* I2C_IT is reset */
+ bitstatus = RESET;
+ }
+ /* Return the I2C_IT status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the I2Cxs interrupt pending bits.
+ * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
+ * @param I2C_IT: specifies the interrupt pending bit to clear.
+ * This parameter can be any combination of the following values:
+ * @arg I2C_IT_SMBALERT: SMBus Alert interrupt
+ * @arg I2C_IT_TIMEOUT: Timeout or Tlow error interrupt
+ * @arg I2C_IT_PECERR: PEC error in reception interrupt
+ * @arg I2C_IT_OVR: Overrun/Underrun interrupt (Slave mode)
+ * @arg I2C_IT_AF: Acknowledge failure interrupt
+ * @arg I2C_IT_ARLO: Arbitration lost interrupt (Master mode)
+ * @arg I2C_IT_BERR: Bus error interrupt
+ *
+ * @note
+ * - STOPF (STOP detection) is cleared by software sequence: a read operation
+ * to I2C_SR1 register (I2C_GetITStatus()) followed by a write operation to
+ * I2C_CR1 register (I2C_Cmd() to re-enable the I2C peripheral).
+ * - ADD10 (10-bit header sent) is cleared by software sequence: a read
+ * operation to I2C_SR1 (I2C_GetITStatus()) followed by writing the second
+ * byte of the address in I2C_DR register.
+ * - BTF (Byte Transfer Finished) is cleared by software sequence: a read
+ * operation to I2C_SR1 register (I2C_GetITStatus()) followed by a
+ * read/write to I2C_DR register (I2C_SendData()).
+ * - ADDR (Address sent) is cleared by software sequence: a read operation to
+ * I2C_SR1 register (I2C_GetITStatus()) followed by a read operation to
+ * I2C_SR2 register ((void)(I2Cx->SR2)).
+ * - SB (Start Bit) is cleared by software sequence: a read operation to
+ * I2C_SR1 register (I2C_GetITStatus()) followed by a write operation to
+ * I2C_DR register (I2C_SendData()).
+ * @retval None
+ */
+void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, uint32_t I2C_IT)
+{
+ uint32_t flagpos = 0;
+ /* Check the parameters */
+ assert_param(IS_I2C_ALL_PERIPH(I2Cx));
+ assert_param(IS_I2C_CLEAR_IT(I2C_IT));
+ /* Get the I2C flag position */
+ flagpos = I2C_IT & FLAG_Mask;
+ /* Clear the selected I2C flag */
+ I2Cx->SR1 = (uint16_t)~flagpos;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_iwdg.c b/st_fw_lib/src/stm32f10x_iwdg.c
new file mode 100644
index 0000000..c7cbf7e
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_iwdg.c
@@ -0,0 +1,190 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_iwdg.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the IWDG firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_iwdg.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup IWDG
+ * @brief IWDG driver modules
+ * @{
+ */
+
+/** @defgroup IWDG_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup IWDG_Private_Defines
+ * @{
+ */
+
+/* ---------------------- IWDG registers bit mask ----------------------------*/
+
+/* KR register bit mask */
+#define KR_KEY_Reload ((uint16_t)0xAAAA)
+#define KR_KEY_Enable ((uint16_t)0xCCCC)
+
+/**
+ * @}
+ */
+
+/** @defgroup IWDG_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup IWDG_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup IWDG_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup IWDG_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers.
+ * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers.
+ * This parameter can be one of the following values:
+ * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers
+ * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers
+ * @retval None
+ */
+void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess)
+{
+ /* Check the parameters */
+ assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess));
+ IWDG->KR = IWDG_WriteAccess;
+}
+
+/**
+ * @brief Sets IWDG Prescaler value.
+ * @param IWDG_Prescaler: specifies the IWDG Prescaler value.
+ * This parameter can be one of the following values:
+ * @arg IWDG_Prescaler_4: IWDG prescaler set to 4
+ * @arg IWDG_Prescaler_8: IWDG prescaler set to 8
+ * @arg IWDG_Prescaler_16: IWDG prescaler set to 16
+ * @arg IWDG_Prescaler_32: IWDG prescaler set to 32
+ * @arg IWDG_Prescaler_64: IWDG prescaler set to 64
+ * @arg IWDG_Prescaler_128: IWDG prescaler set to 128
+ * @arg IWDG_Prescaler_256: IWDG prescaler set to 256
+ * @retval None
+ */
+void IWDG_SetPrescaler(uint8_t IWDG_Prescaler)
+{
+ /* Check the parameters */
+ assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler));
+ IWDG->PR = IWDG_Prescaler;
+}
+
+/**
+ * @brief Sets IWDG Reload value.
+ * @param Reload: specifies the IWDG Reload value.
+ * This parameter must be a number between 0 and 0x0FFF.
+ * @retval None
+ */
+void IWDG_SetReload(uint16_t Reload)
+{
+ /* Check the parameters */
+ assert_param(IS_IWDG_RELOAD(Reload));
+ IWDG->RLR = Reload;
+}
+
+/**
+ * @brief Reloads IWDG counter with value defined in the reload register
+ * (write access to IWDG_PR and IWDG_RLR registers disabled).
+ * @param None
+ * @retval None
+ */
+void IWDG_ReloadCounter(void)
+{
+ IWDG->KR = KR_KEY_Reload;
+}
+
+/**
+ * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled).
+ * @param None
+ * @retval None
+ */
+void IWDG_Enable(void)
+{
+ IWDG->KR = KR_KEY_Enable;
+}
+
+/**
+ * @brief Checks whether the specified IWDG flag is set or not.
+ * @param IWDG_FLAG: specifies the flag to check.
+ * This parameter can be one of the following values:
+ * @arg IWDG_FLAG_PVU: Prescaler Value Update on going
+ * @arg IWDG_FLAG_RVU: Reload Value Update on going
+ * @retval The new state of IWDG_FLAG (SET or RESET).
+ */
+FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_IWDG_FLAG(IWDG_FLAG));
+ if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ /* Return the flag status */
+ return bitstatus;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_pwr.c b/st_fw_lib/src/stm32f10x_pwr.c
new file mode 100644
index 0000000..a5a5c57
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_pwr.c
@@ -0,0 +1,307 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_pwr.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the PWR firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_pwr.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup PWR
+ * @brief PWR driver modules
+ * @{
+ */
+
+/** @defgroup PWR_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup PWR_Private_Defines
+ * @{
+ */
+
+/* --------- PWR registers bit address in the alias region ---------- */
+#define PWR_OFFSET (PWR_BASE - PERIPH_BASE)
+
+/* --- CR Register ---*/
+
+/* Alias word address of DBP bit */
+#define CR_OFFSET (PWR_OFFSET + 0x00)
+#define DBP_BitNumber 0x08
+#define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4))
+
+/* Alias word address of PVDE bit */
+#define PVDE_BitNumber 0x04
+#define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4))
+
+/* --- CSR Register ---*/
+
+/* Alias word address of EWUP bit */
+#define CSR_OFFSET (PWR_OFFSET + 0x04)
+#define EWUP_BitNumber 0x08
+#define CSR_EWUP_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP_BitNumber * 4))
+
+/* ------------------ PWR registers bit mask ------------------------ */
+
+/* CR register bit mask */
+#define CR_DS_MASK ((uint32_t)0xFFFFFFFC)
+#define CR_PLS_MASK ((uint32_t)0xFFFFFF1F)
+
+
+/**
+ * @}
+ */
+
+/** @defgroup PWR_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup PWR_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup PWR_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup PWR_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the PWR peripheral registers to their default reset values.
+ * @param None
+ * @retval None
+ */
+void PWR_DeInit(void)
+{
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE);
+}
+
+/**
+ * @brief Enables or disables access to the RTC and backup registers.
+ * @param NewState: new state of the access to the RTC and backup registers.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void PWR_BackupAccessCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) CR_DBP_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Enables or disables the Power Voltage Detector(PVD).
+ * @param NewState: new state of the PVD.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void PWR_PVDCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD).
+ * @param PWR_PVDLevel: specifies the PVD detection level
+ * This parameter can be one of the following values:
+ * @arg PWR_PVDLevel_2V2: PVD detection level set to 2.2V
+ * @arg PWR_PVDLevel_2V3: PVD detection level set to 2.3V
+ * @arg PWR_PVDLevel_2V4: PVD detection level set to 2.4V
+ * @arg PWR_PVDLevel_2V5: PVD detection level set to 2.5V
+ * @arg PWR_PVDLevel_2V6: PVD detection level set to 2.6V
+ * @arg PWR_PVDLevel_2V7: PVD detection level set to 2.7V
+ * @arg PWR_PVDLevel_2V8: PVD detection level set to 2.8V
+ * @arg PWR_PVDLevel_2V9: PVD detection level set to 2.9V
+ * @retval None
+ */
+void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel));
+ tmpreg = PWR->CR;
+ /* Clear PLS[7:5] bits */
+ tmpreg &= CR_PLS_MASK;
+ /* Set PLS[7:5] bits according to PWR_PVDLevel value */
+ tmpreg |= PWR_PVDLevel;
+ /* Store the new value */
+ PWR->CR = tmpreg;
+}
+
+/**
+ * @brief Enables or disables the WakeUp Pin functionality.
+ * @param NewState: new state of the WakeUp Pin functionality.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void PWR_WakeUpPinCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) CSR_EWUP_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Enters STOP mode.
+ * @param PWR_Regulator: specifies the regulator state in STOP mode.
+ * This parameter can be one of the following values:
+ * @arg PWR_Regulator_ON: STOP mode with regulator ON
+ * @arg PWR_Regulator_LowPower: STOP mode with regulator in low power mode
+ * @param PWR_STOPEntry: specifies if STOP mode in entered with WFI or WFE instruction.
+ * This parameter can be one of the following values:
+ * @arg PWR_STOPEntry_WFI: enter STOP mode with WFI instruction
+ * @arg PWR_STOPEntry_WFE: enter STOP mode with WFE instruction
+ * @retval None
+ */
+void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_PWR_REGULATOR(PWR_Regulator));
+ assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry));
+
+ /* Select the regulator state in STOP mode ---------------------------------*/
+ tmpreg = PWR->CR;
+ /* Clear PDDS and LPDS bits */
+ tmpreg &= CR_DS_MASK;
+ /* Set LPDS bit according to PWR_Regulator value */
+ tmpreg |= PWR_Regulator;
+ /* Store the new value */
+ PWR->CR = tmpreg;
+ /* Set SLEEPDEEP bit of Cortex System Control Register */
+ SCB->SCR |= SCB_SCR_SLEEPDEEP;
+
+ /* Select STOP mode entry --------------------------------------------------*/
+ if(PWR_STOPEntry == PWR_STOPEntry_WFI)
+ {
+ /* Request Wait For Interrupt */
+ __WFI();
+ }
+ else
+ {
+ /* Request Wait For Event */
+ __WFE();
+ }
+
+ /* Reset SLEEPDEEP bit of Cortex System Control Register */
+ SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP);
+}
+
+/**
+ * @brief Enters STANDBY mode.
+ * @param None
+ * @retval None
+ */
+void PWR_EnterSTANDBYMode(void)
+{
+ /* Clear Wake-up flag */
+ PWR->CR |= PWR_CR_CWUF;
+ /* Select STANDBY mode */
+ PWR->CR |= PWR_CR_PDDS;
+ /* Set SLEEPDEEP bit of Cortex System Control Register */
+ SCB->SCR |= SCB_SCR_SLEEPDEEP;
+/* This option is used to ensure that store operations are completed */
+#if defined ( __CC_ARM )
+ __force_stores();
+#endif
+ /* Request Wait For Interrupt */
+ __WFI();
+}
+
+/**
+ * @brief Checks whether the specified PWR flag is set or not.
+ * @param PWR_FLAG: specifies the flag to check.
+ * This parameter can be one of the following values:
+ * @arg PWR_FLAG_WU: Wake Up flag
+ * @arg PWR_FLAG_SB: StandBy flag
+ * @arg PWR_FLAG_PVDO: PVD Output
+ * @retval The new state of PWR_FLAG (SET or RESET).
+ */
+FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_PWR_GET_FLAG(PWR_FLAG));
+
+ if ((PWR->CSR & PWR_FLAG) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ /* Return the flag status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the PWR's pending flags.
+ * @param PWR_FLAG: specifies the flag to clear.
+ * This parameter can be one of the following values:
+ * @arg PWR_FLAG_WU: Wake Up flag
+ * @arg PWR_FLAG_SB: StandBy flag
+ * @retval None
+ */
+void PWR_ClearFlag(uint32_t PWR_FLAG)
+{
+ /* Check the parameters */
+ assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG));
+
+ PWR->CR |= PWR_FLAG << 2;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_rcc.c b/st_fw_lib/src/stm32f10x_rcc.c
new file mode 100644
index 0000000..a29034b
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_rcc.c
@@ -0,0 +1,1470 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_rcc.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the RCC firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup RCC
+ * @brief RCC driver modules
+ * @{
+ */
+
+/** @defgroup RCC_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RCC_Private_Defines
+ * @{
+ */
+
+/* ------------ RCC registers bit address in the alias region ----------- */
+#define RCC_OFFSET (RCC_BASE - PERIPH_BASE)
+
+/* --- CR Register ---*/
+
+/* Alias word address of HSION bit */
+#define CR_OFFSET (RCC_OFFSET + 0x00)
+#define HSION_BitNumber 0x00
+#define CR_HSION_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (HSION_BitNumber * 4))
+
+/* Alias word address of PLLON bit */
+#define PLLON_BitNumber 0x18
+#define CR_PLLON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLLON_BitNumber * 4))
+
+#ifdef STM32F10X_CL
+ /* Alias word address of PLL2ON bit */
+ #define PLL2ON_BitNumber 0x1A
+ #define CR_PLL2ON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLL2ON_BitNumber * 4))
+
+ /* Alias word address of PLL3ON bit */
+ #define PLL3ON_BitNumber 0x1C
+ #define CR_PLL3ON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLL3ON_BitNumber * 4))
+#endif /* STM32F10X_CL */
+
+/* Alias word address of CSSON bit */
+#define CSSON_BitNumber 0x13
+#define CR_CSSON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (CSSON_BitNumber * 4))
+
+/* --- CFGR Register ---*/
+
+/* Alias word address of USBPRE bit */
+#define CFGR_OFFSET (RCC_OFFSET + 0x04)
+
+#ifndef STM32F10X_CL
+ #define USBPRE_BitNumber 0x16
+ #define CFGR_USBPRE_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (USBPRE_BitNumber * 4))
+#else
+ #define OTGFSPRE_BitNumber 0x16
+ #define CFGR_OTGFSPRE_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (OTGFSPRE_BitNumber * 4))
+#endif /* STM32F10X_CL */
+
+/* --- BDCR Register ---*/
+
+/* Alias word address of RTCEN bit */
+#define BDCR_OFFSET (RCC_OFFSET + 0x20)
+#define RTCEN_BitNumber 0x0F
+#define BDCR_RTCEN_BB (PERIPH_BB_BASE + (BDCR_OFFSET * 32) + (RTCEN_BitNumber * 4))
+
+/* Alias word address of BDRST bit */
+#define BDRST_BitNumber 0x10
+#define BDCR_BDRST_BB (PERIPH_BB_BASE + (BDCR_OFFSET * 32) + (BDRST_BitNumber * 4))
+
+/* --- CSR Register ---*/
+
+/* Alias word address of LSION bit */
+#define CSR_OFFSET (RCC_OFFSET + 0x24)
+#define LSION_BitNumber 0x00
+#define CSR_LSION_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (LSION_BitNumber * 4))
+
+#ifdef STM32F10X_CL
+/* --- CFGR2 Register ---*/
+
+ /* Alias word address of I2S2SRC bit */
+ #define CFGR2_OFFSET (RCC_OFFSET + 0x2C)
+ #define I2S2SRC_BitNumber 0x11
+ #define CFGR2_I2S2SRC_BB (PERIPH_BB_BASE + (CFGR2_OFFSET * 32) + (I2S2SRC_BitNumber * 4))
+
+ /* Alias word address of I2S3SRC bit */
+ #define I2S3SRC_BitNumber 0x12
+ #define CFGR2_I2S3SRC_BB (PERIPH_BB_BASE + (CFGR2_OFFSET * 32) + (I2S3SRC_BitNumber * 4))
+#endif /* STM32F10X_CL */
+
+/* ---------------------- RCC registers bit mask ------------------------ */
+
+/* CR register bit mask */
+#define CR_HSEBYP_Reset ((uint32_t)0xFFFBFFFF)
+#define CR_HSEBYP_Set ((uint32_t)0x00040000)
+#define CR_HSEON_Reset ((uint32_t)0xFFFEFFFF)
+#define CR_HSEON_Set ((uint32_t)0x00010000)
+#define CR_HSITRIM_Mask ((uint32_t)0xFFFFFF07)
+
+/* CFGR register bit mask */
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) || defined (STM32F10X_CL)
+ #define CFGR_PLL_Mask ((uint32_t)0xFFC2FFFF)
+#else
+ #define CFGR_PLL_Mask ((uint32_t)0xFFC0FFFF)
+#endif /* STM32F10X_CL */
+
+#define CFGR_PLLMull_Mask ((uint32_t)0x003C0000)
+#define CFGR_PLLSRC_Mask ((uint32_t)0x00010000)
+#define CFGR_PLLXTPRE_Mask ((uint32_t)0x00020000)
+#define CFGR_SWS_Mask ((uint32_t)0x0000000C)
+#define CFGR_SW_Mask ((uint32_t)0xFFFFFFFC)
+#define CFGR_HPRE_Reset_Mask ((uint32_t)0xFFFFFF0F)
+#define CFGR_HPRE_Set_Mask ((uint32_t)0x000000F0)
+#define CFGR_PPRE1_Reset_Mask ((uint32_t)0xFFFFF8FF)
+#define CFGR_PPRE1_Set_Mask ((uint32_t)0x00000700)
+#define CFGR_PPRE2_Reset_Mask ((uint32_t)0xFFFFC7FF)
+#define CFGR_PPRE2_Set_Mask ((uint32_t)0x00003800)
+#define CFGR_ADCPRE_Reset_Mask ((uint32_t)0xFFFF3FFF)
+#define CFGR_ADCPRE_Set_Mask ((uint32_t)0x0000C000)
+
+/* CSR register bit mask */
+#define CSR_RMVF_Set ((uint32_t)0x01000000)
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) || defined (STM32F10X_CL)
+/* CFGR2 register bit mask */
+ #define CFGR2_PREDIV1SRC ((uint32_t)0x00010000)
+ #define CFGR2_PREDIV1 ((uint32_t)0x0000000F)
+#endif
+#ifdef STM32F10X_CL
+ #define CFGR2_PREDIV2 ((uint32_t)0x000000F0)
+ #define CFGR2_PLL2MUL ((uint32_t)0x00000F00)
+ #define CFGR2_PLL3MUL ((uint32_t)0x0000F000)
+#endif /* STM32F10X_CL */
+
+/* RCC Flag Mask */
+#define FLAG_Mask ((uint8_t)0x1F)
+
+/* CIR register byte 2 (Bits[15:8]) base address */
+#define CIR_BYTE2_ADDRESS ((uint32_t)0x40021009)
+
+/* CIR register byte 3 (Bits[23:16]) base address */
+#define CIR_BYTE3_ADDRESS ((uint32_t)0x4002100A)
+
+/* CFGR register byte 4 (Bits[31:24]) base address */
+#define CFGR_BYTE4_ADDRESS ((uint32_t)0x40021007)
+
+/* BDCR register base address */
+#define BDCR_ADDRESS (PERIPH_BASE + BDCR_OFFSET)
+
+/**
+ * @}
+ */
+
+/** @defgroup RCC_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RCC_Private_Variables
+ * @{
+ */
+
+static __I uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
+static __I uint8_t ADCPrescTable[4] = {2, 4, 6, 8};
+
+/**
+ * @}
+ */
+
+/** @defgroup RCC_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RCC_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Resets the RCC clock configuration to the default reset state.
+ * @param None
+ * @retval None
+ */
+void RCC_DeInit(void)
+{
+ /* Set HSION bit */
+ RCC->CR |= (uint32_t)0x00000001;
+
+ /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */
+#ifndef STM32F10X_CL
+ RCC->CFGR &= (uint32_t)0xF8FF0000;
+#else
+ RCC->CFGR &= (uint32_t)0xF0FF0000;
+#endif /* STM32F10X_CL */
+
+ /* Reset HSEON, CSSON and PLLON bits */
+ RCC->CR &= (uint32_t)0xFEF6FFFF;
+
+ /* Reset HSEBYP bit */
+ RCC->CR &= (uint32_t)0xFFFBFFFF;
+
+ /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */
+ RCC->CFGR &= (uint32_t)0xFF80FFFF;
+
+#ifdef STM32F10X_CL
+ /* Reset PLL2ON and PLL3ON bits */
+ RCC->CR &= (uint32_t)0xEBFFFFFF;
+
+ /* Disable all interrupts and clear pending bits */
+ RCC->CIR = 0x00FF0000;
+
+ /* Reset CFGR2 register */
+ RCC->CFGR2 = 0x00000000;
+#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+ /* Disable all interrupts and clear pending bits */
+ RCC->CIR = 0x009F0000;
+
+ /* Reset CFGR2 register */
+ RCC->CFGR2 = 0x00000000;
+#else
+ /* Disable all interrupts and clear pending bits */
+ RCC->CIR = 0x009F0000;
+#endif /* STM32F10X_CL */
+
+}
+
+/**
+ * @brief Configures the External High Speed oscillator (HSE).
+ * @note HSE can not be stopped if it is used directly or through the PLL as system clock.
+ * @param RCC_HSE: specifies the new state of the HSE.
+ * This parameter can be one of the following values:
+ * @arg RCC_HSE_OFF: HSE oscillator OFF
+ * @arg RCC_HSE_ON: HSE oscillator ON
+ * @arg RCC_HSE_Bypass: HSE oscillator bypassed with external clock
+ * @retval None
+ */
+void RCC_HSEConfig(uint32_t RCC_HSE)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_HSE(RCC_HSE));
+ /* Reset HSEON and HSEBYP bits before configuring the HSE ------------------*/
+ /* Reset HSEON bit */
+ RCC->CR &= CR_HSEON_Reset;
+ /* Reset HSEBYP bit */
+ RCC->CR &= CR_HSEBYP_Reset;
+ /* Configure HSE (RCC_HSE_OFF is already covered by the code section above) */
+ switch(RCC_HSE)
+ {
+ case RCC_HSE_ON:
+ /* Set HSEON bit */
+ RCC->CR |= CR_HSEON_Set;
+ break;
+
+ case RCC_HSE_Bypass:
+ /* Set HSEBYP and HSEON bits */
+ RCC->CR |= CR_HSEBYP_Set | CR_HSEON_Set;
+ break;
+
+ default:
+ break;
+ }
+}
+
+/**
+ * @brief Waits for HSE start-up.
+ * @param None
+ * @retval An ErrorStatus enumuration value:
+ * - SUCCESS: HSE oscillator is stable and ready to use
+ * - ERROR: HSE oscillator not yet ready
+ */
+ErrorStatus RCC_WaitForHSEStartUp(void)
+{
+ __IO uint32_t StartUpCounter = 0;
+ ErrorStatus status = ERROR;
+ FlagStatus HSEStatus = RESET;
+
+ /* Wait till HSE is ready and if Time out is reached exit */
+ do
+ {
+ HSEStatus = RCC_GetFlagStatus(RCC_FLAG_HSERDY);
+ StartUpCounter++;
+ } while((StartUpCounter != HSE_STARTUP_TIMEOUT) && (HSEStatus == RESET));
+
+ if (RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET)
+ {
+ status = SUCCESS;
+ }
+ else
+ {
+ status = ERROR;
+ }
+ return (status);
+}
+
+/**
+ * @brief Adjusts the Internal High Speed oscillator (HSI) calibration value.
+ * @param HSICalibrationValue: specifies the calibration trimming value.
+ * This parameter must be a number between 0 and 0x1F.
+ * @retval None
+ */
+void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_RCC_CALIBRATION_VALUE(HSICalibrationValue));
+ tmpreg = RCC->CR;
+ /* Clear HSITRIM[4:0] bits */
+ tmpreg &= CR_HSITRIM_Mask;
+ /* Set the HSITRIM[4:0] bits according to HSICalibrationValue value */
+ tmpreg |= (uint32_t)HSICalibrationValue << 3;
+ /* Store the new value */
+ RCC->CR = tmpreg;
+}
+
+/**
+ * @brief Enables or disables the Internal High Speed oscillator (HSI).
+ * @note HSI can not be stopped if it is used directly or through the PLL as system clock.
+ * @param NewState: new state of the HSI. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_HSICmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) CR_HSION_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Configures the PLL clock source and multiplication factor.
+ * @note This function must be used only when the PLL is disabled.
+ * @param RCC_PLLSource: specifies the PLL entry clock source.
+ * For @b STM32_Connectivity_line_devices or @b STM32_Value_line_devices,
+ * this parameter can be one of the following values:
+ * @arg RCC_PLLSource_HSI_Div2: HSI oscillator clock divided by 2 selected as PLL clock entry
+ * @arg RCC_PLLSource_PREDIV1: PREDIV1 clock selected as PLL clock entry
+ * For @b other_STM32_devices, this parameter can be one of the following values:
+ * @arg RCC_PLLSource_HSI_Div2: HSI oscillator clock divided by 2 selected as PLL clock entry
+ * @arg RCC_PLLSource_HSE_Div1: HSE oscillator clock selected as PLL clock entry
+ * @arg RCC_PLLSource_HSE_Div2: HSE oscillator clock divided by 2 selected as PLL clock entry
+ * @param RCC_PLLMul: specifies the PLL multiplication factor.
+ * For @b STM32_Connectivity_line_devices, this parameter can be RCC_PLLMul_x where x:{[4,9], 6_5}
+ * For @b other_STM32_devices, this parameter can be RCC_PLLMul_x where x:[2,16]
+ * @retval None
+ */
+void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t RCC_PLLMul)
+{
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource));
+ assert_param(IS_RCC_PLL_MUL(RCC_PLLMul));
+
+ tmpreg = RCC->CFGR;
+ /* Clear PLLSRC, PLLXTPRE and PLLMUL[3:0] bits */
+ tmpreg &= CFGR_PLL_Mask;
+ /* Set the PLL configuration bits */
+ tmpreg |= RCC_PLLSource | RCC_PLLMul;
+ /* Store the new value */
+ RCC->CFGR = tmpreg;
+}
+
+/**
+ * @brief Enables or disables the PLL.
+ * @note The PLL can not be disabled if it is used as system clock.
+ * @param NewState: new state of the PLL. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_PLLCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) CR_PLLON_BB = (uint32_t)NewState;
+}
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) || defined (STM32F10X_CL)
+/**
+ * @brief Configures the PREDIV1 division factor.
+ * @note
+ * - This function must be used only when the PLL is disabled.
+ * - This function applies only to STM32 Connectivity line and Value line
+ * devices.
+ * @param RCC_PREDIV1_Source: specifies the PREDIV1 clock source.
+ * This parameter can be one of the following values:
+ * @arg RCC_PREDIV1_Source_HSE: HSE selected as PREDIV1 clock
+ * @arg RCC_PREDIV1_Source_PLL2: PLL2 selected as PREDIV1 clock
+ * @note
+ * For @b STM32_Value_line_devices this parameter is always RCC_PREDIV1_Source_HSE
+ * @param RCC_PREDIV1_Div: specifies the PREDIV1 clock division factor.
+ * This parameter can be RCC_PREDIV1_Divx where x:[1,16]
+ * @retval None
+ */
+void RCC_PREDIV1Config(uint32_t RCC_PREDIV1_Source, uint32_t RCC_PREDIV1_Div)
+{
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_RCC_PREDIV1_SOURCE(RCC_PREDIV1_Source));
+ assert_param(IS_RCC_PREDIV1(RCC_PREDIV1_Div));
+
+ tmpreg = RCC->CFGR2;
+ /* Clear PREDIV1[3:0] and PREDIV1SRC bits */
+ tmpreg &= ~(CFGR2_PREDIV1 | CFGR2_PREDIV1SRC);
+ /* Set the PREDIV1 clock source and division factor */
+ tmpreg |= RCC_PREDIV1_Source | RCC_PREDIV1_Div ;
+ /* Store the new value */
+ RCC->CFGR2 = tmpreg;
+}
+#endif
+
+#ifdef STM32F10X_CL
+/**
+ * @brief Configures the PREDIV2 division factor.
+ * @note
+ * - This function must be used only when both PLL2 and PLL3 are disabled.
+ * - This function applies only to STM32 Connectivity line devices.
+ * @param RCC_PREDIV2_Div: specifies the PREDIV2 clock division factor.
+ * This parameter can be RCC_PREDIV2_Divx where x:[1,16]
+ * @retval None
+ */
+void RCC_PREDIV2Config(uint32_t RCC_PREDIV2_Div)
+{
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_RCC_PREDIV2(RCC_PREDIV2_Div));
+
+ tmpreg = RCC->CFGR2;
+ /* Clear PREDIV2[3:0] bits */
+ tmpreg &= ~CFGR2_PREDIV2;
+ /* Set the PREDIV2 division factor */
+ tmpreg |= RCC_PREDIV2_Div;
+ /* Store the new value */
+ RCC->CFGR2 = tmpreg;
+}
+
+/**
+ * @brief Configures the PLL2 multiplication factor.
+ * @note
+ * - This function must be used only when the PLL2 is disabled.
+ * - This function applies only to STM32 Connectivity line devices.
+ * @param RCC_PLL2Mul: specifies the PLL2 multiplication factor.
+ * This parameter can be RCC_PLL2Mul_x where x:{[8,14], 16, 20}
+ * @retval None
+ */
+void RCC_PLL2Config(uint32_t RCC_PLL2Mul)
+{
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_RCC_PLL2_MUL(RCC_PLL2Mul));
+
+ tmpreg = RCC->CFGR2;
+ /* Clear PLL2Mul[3:0] bits */
+ tmpreg &= ~CFGR2_PLL2MUL;
+ /* Set the PLL2 configuration bits */
+ tmpreg |= RCC_PLL2Mul;
+ /* Store the new value */
+ RCC->CFGR2 = tmpreg;
+}
+
+
+/**
+ * @brief Enables or disables the PLL2.
+ * @note
+ * - The PLL2 can not be disabled if it is used indirectly as system clock
+ * (i.e. it is used as PLL clock entry that is used as System clock).
+ * - This function applies only to STM32 Connectivity line devices.
+ * @param NewState: new state of the PLL2. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_PLL2Cmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) CR_PLL2ON_BB = (uint32_t)NewState;
+}
+
+
+/**
+ * @brief Configures the PLL3 multiplication factor.
+ * @note
+ * - This function must be used only when the PLL3 is disabled.
+ * - This function applies only to STM32 Connectivity line devices.
+ * @param RCC_PLL3Mul: specifies the PLL3 multiplication factor.
+ * This parameter can be RCC_PLL3Mul_x where x:{[8,14], 16, 20}
+ * @retval None
+ */
+void RCC_PLL3Config(uint32_t RCC_PLL3Mul)
+{
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_RCC_PLL3_MUL(RCC_PLL3Mul));
+
+ tmpreg = RCC->CFGR2;
+ /* Clear PLL3Mul[3:0] bits */
+ tmpreg &= ~CFGR2_PLL3MUL;
+ /* Set the PLL3 configuration bits */
+ tmpreg |= RCC_PLL3Mul;
+ /* Store the new value */
+ RCC->CFGR2 = tmpreg;
+}
+
+
+/**
+ * @brief Enables or disables the PLL3.
+ * @note This function applies only to STM32 Connectivity line devices.
+ * @param NewState: new state of the PLL3. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_PLL3Cmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) CR_PLL3ON_BB = (uint32_t)NewState;
+}
+#endif /* STM32F10X_CL */
+
+/**
+ * @brief Configures the system clock (SYSCLK).
+ * @param RCC_SYSCLKSource: specifies the clock source used as system clock.
+ * This parameter can be one of the following values:
+ * @arg RCC_SYSCLKSource_HSI: HSI selected as system clock
+ * @arg RCC_SYSCLKSource_HSE: HSE selected as system clock
+ * @arg RCC_SYSCLKSource_PLLCLK: PLL selected as system clock
+ * @retval None
+ */
+void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_RCC_SYSCLK_SOURCE(RCC_SYSCLKSource));
+ tmpreg = RCC->CFGR;
+ /* Clear SW[1:0] bits */
+ tmpreg &= CFGR_SW_Mask;
+ /* Set SW[1:0] bits according to RCC_SYSCLKSource value */
+ tmpreg |= RCC_SYSCLKSource;
+ /* Store the new value */
+ RCC->CFGR = tmpreg;
+}
+
+/**
+ * @brief Returns the clock source used as system clock.
+ * @param None
+ * @retval The clock source used as system clock. The returned value can
+ * be one of the following:
+ * - 0x00: HSI used as system clock
+ * - 0x04: HSE used as system clock
+ * - 0x08: PLL used as system clock
+ */
+uint8_t RCC_GetSYSCLKSource(void)
+{
+ return ((uint8_t)(RCC->CFGR & CFGR_SWS_Mask));
+}
+
+/**
+ * @brief Configures the AHB clock (HCLK).
+ * @param RCC_SYSCLK: defines the AHB clock divider. This clock is derived from
+ * the system clock (SYSCLK).
+ * This parameter can be one of the following values:
+ * @arg RCC_SYSCLK_Div1: AHB clock = SYSCLK
+ * @arg RCC_SYSCLK_Div2: AHB clock = SYSCLK/2
+ * @arg RCC_SYSCLK_Div4: AHB clock = SYSCLK/4
+ * @arg RCC_SYSCLK_Div8: AHB clock = SYSCLK/8
+ * @arg RCC_SYSCLK_Div16: AHB clock = SYSCLK/16
+ * @arg RCC_SYSCLK_Div64: AHB clock = SYSCLK/64
+ * @arg RCC_SYSCLK_Div128: AHB clock = SYSCLK/128
+ * @arg RCC_SYSCLK_Div256: AHB clock = SYSCLK/256
+ * @arg RCC_SYSCLK_Div512: AHB clock = SYSCLK/512
+ * @retval None
+ */
+void RCC_HCLKConfig(uint32_t RCC_SYSCLK)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_RCC_HCLK(RCC_SYSCLK));
+ tmpreg = RCC->CFGR;
+ /* Clear HPRE[3:0] bits */
+ tmpreg &= CFGR_HPRE_Reset_Mask;
+ /* Set HPRE[3:0] bits according to RCC_SYSCLK value */
+ tmpreg |= RCC_SYSCLK;
+ /* Store the new value */
+ RCC->CFGR = tmpreg;
+}
+
+/**
+ * @brief Configures the Low Speed APB clock (PCLK1).
+ * @param RCC_HCLK: defines the APB1 clock divider. This clock is derived from
+ * the AHB clock (HCLK).
+ * This parameter can be one of the following values:
+ * @arg RCC_HCLK_Div1: APB1 clock = HCLK
+ * @arg RCC_HCLK_Div2: APB1 clock = HCLK/2
+ * @arg RCC_HCLK_Div4: APB1 clock = HCLK/4
+ * @arg RCC_HCLK_Div8: APB1 clock = HCLK/8
+ * @arg RCC_HCLK_Div16: APB1 clock = HCLK/16
+ * @retval None
+ */
+void RCC_PCLK1Config(uint32_t RCC_HCLK)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_RCC_PCLK(RCC_HCLK));
+ tmpreg = RCC->CFGR;
+ /* Clear PPRE1[2:0] bits */
+ tmpreg &= CFGR_PPRE1_Reset_Mask;
+ /* Set PPRE1[2:0] bits according to RCC_HCLK value */
+ tmpreg |= RCC_HCLK;
+ /* Store the new value */
+ RCC->CFGR = tmpreg;
+}
+
+/**
+ * @brief Configures the High Speed APB clock (PCLK2).
+ * @param RCC_HCLK: defines the APB2 clock divider. This clock is derived from
+ * the AHB clock (HCLK).
+ * This parameter can be one of the following values:
+ * @arg RCC_HCLK_Div1: APB2 clock = HCLK
+ * @arg RCC_HCLK_Div2: APB2 clock = HCLK/2
+ * @arg RCC_HCLK_Div4: APB2 clock = HCLK/4
+ * @arg RCC_HCLK_Div8: APB2 clock = HCLK/8
+ * @arg RCC_HCLK_Div16: APB2 clock = HCLK/16
+ * @retval None
+ */
+void RCC_PCLK2Config(uint32_t RCC_HCLK)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_RCC_PCLK(RCC_HCLK));
+ tmpreg = RCC->CFGR;
+ /* Clear PPRE2[2:0] bits */
+ tmpreg &= CFGR_PPRE2_Reset_Mask;
+ /* Set PPRE2[2:0] bits according to RCC_HCLK value */
+ tmpreg |= RCC_HCLK << 3;
+ /* Store the new value */
+ RCC->CFGR = tmpreg;
+}
+
+/**
+ * @brief Enables or disables the specified RCC interrupts.
+ * @param RCC_IT: specifies the RCC interrupt sources to be enabled or disabled.
+ *
+ * For @b STM32_Connectivity_line_devices, this parameter can be any combination
+ * of the following values
+ * @arg RCC_IT_LSIRDY: LSI ready interrupt
+ * @arg RCC_IT_LSERDY: LSE ready interrupt
+ * @arg RCC_IT_HSIRDY: HSI ready interrupt
+ * @arg RCC_IT_HSERDY: HSE ready interrupt
+ * @arg RCC_IT_PLLRDY: PLL ready interrupt
+ * @arg RCC_IT_PLL2RDY: PLL2 ready interrupt
+ * @arg RCC_IT_PLL3RDY: PLL3 ready interrupt
+ *
+ * For @b other_STM32_devices, this parameter can be any combination of the
+ * following values
+ * @arg RCC_IT_LSIRDY: LSI ready interrupt
+ * @arg RCC_IT_LSERDY: LSE ready interrupt
+ * @arg RCC_IT_HSIRDY: HSI ready interrupt
+ * @arg RCC_IT_HSERDY: HSE ready interrupt
+ * @arg RCC_IT_PLLRDY: PLL ready interrupt
+ *
+ * @param NewState: new state of the specified RCC interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_IT(RCC_IT));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Perform Byte access to RCC_CIR bits to enable the selected interrupts */
+ *(__IO uint8_t *) CIR_BYTE2_ADDRESS |= RCC_IT;
+ }
+ else
+ {
+ /* Perform Byte access to RCC_CIR bits to disable the selected interrupts */
+ *(__IO uint8_t *) CIR_BYTE2_ADDRESS &= (uint8_t)~RCC_IT;
+ }
+}
+
+#ifndef STM32F10X_CL
+/**
+ * @brief Configures the USB clock (USBCLK).
+ * @param RCC_USBCLKSource: specifies the USB clock source. This clock is
+ * derived from the PLL output.
+ * This parameter can be one of the following values:
+ * @arg RCC_USBCLKSource_PLLCLK_1Div5: PLL clock divided by 1,5 selected as USB
+ * clock source
+ * @arg RCC_USBCLKSource_PLLCLK_Div1: PLL clock selected as USB clock source
+ * @retval None
+ */
+void RCC_USBCLKConfig(uint32_t RCC_USBCLKSource)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_USBCLK_SOURCE(RCC_USBCLKSource));
+
+ *(__IO uint32_t *) CFGR_USBPRE_BB = RCC_USBCLKSource;
+}
+#else
+/**
+ * @brief Configures the USB OTG FS clock (OTGFSCLK).
+ * This function applies only to STM32 Connectivity line devices.
+ * @param RCC_OTGFSCLKSource: specifies the USB OTG FS clock source.
+ * This clock is derived from the PLL output.
+ * This parameter can be one of the following values:
+ * @arg RCC_OTGFSCLKSource_PLLVCO_Div3: PLL VCO clock divided by 2 selected as USB OTG FS clock source
+ * @arg RCC_OTGFSCLKSource_PLLVCO_Div2: PLL VCO clock divided by 2 selected as USB OTG FS clock source
+ * @retval None
+ */
+void RCC_OTGFSCLKConfig(uint32_t RCC_OTGFSCLKSource)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_OTGFSCLK_SOURCE(RCC_OTGFSCLKSource));
+
+ *(__IO uint32_t *) CFGR_OTGFSPRE_BB = RCC_OTGFSCLKSource;
+}
+#endif /* STM32F10X_CL */
+
+/**
+ * @brief Configures the ADC clock (ADCCLK).
+ * @param RCC_PCLK2: defines the ADC clock divider. This clock is derived from
+ * the APB2 clock (PCLK2).
+ * This parameter can be one of the following values:
+ * @arg RCC_PCLK2_Div2: ADC clock = PCLK2/2
+ * @arg RCC_PCLK2_Div4: ADC clock = PCLK2/4
+ * @arg RCC_PCLK2_Div6: ADC clock = PCLK2/6
+ * @arg RCC_PCLK2_Div8: ADC clock = PCLK2/8
+ * @retval None
+ */
+void RCC_ADCCLKConfig(uint32_t RCC_PCLK2)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_RCC_ADCCLK(RCC_PCLK2));
+ tmpreg = RCC->CFGR;
+ /* Clear ADCPRE[1:0] bits */
+ tmpreg &= CFGR_ADCPRE_Reset_Mask;
+ /* Set ADCPRE[1:0] bits according to RCC_PCLK2 value */
+ tmpreg |= RCC_PCLK2;
+ /* Store the new value */
+ RCC->CFGR = tmpreg;
+}
+
+#ifdef STM32F10X_CL
+/**
+ * @brief Configures the I2S2 clock source(I2S2CLK).
+ * @note
+ * - This function must be called before enabling I2S2 APB clock.
+ * - This function applies only to STM32 Connectivity line devices.
+ * @param RCC_I2S2CLKSource: specifies the I2S2 clock source.
+ * This parameter can be one of the following values:
+ * @arg RCC_I2S2CLKSource_SYSCLK: system clock selected as I2S2 clock entry
+ * @arg RCC_I2S2CLKSource_PLL3_VCO: PLL3 VCO clock selected as I2S2 clock entry
+ * @retval None
+ */
+void RCC_I2S2CLKConfig(uint32_t RCC_I2S2CLKSource)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_I2S2CLK_SOURCE(RCC_I2S2CLKSource));
+
+ *(__IO uint32_t *) CFGR2_I2S2SRC_BB = RCC_I2S2CLKSource;
+}
+
+/**
+ * @brief Configures the I2S3 clock source(I2S2CLK).
+ * @note
+ * - This function must be called before enabling I2S3 APB clock.
+ * - This function applies only to STM32 Connectivity line devices.
+ * @param RCC_I2S3CLKSource: specifies the I2S3 clock source.
+ * This parameter can be one of the following values:
+ * @arg RCC_I2S3CLKSource_SYSCLK: system clock selected as I2S3 clock entry
+ * @arg RCC_I2S3CLKSource_PLL3_VCO: PLL3 VCO clock selected as I2S3 clock entry
+ * @retval None
+ */
+void RCC_I2S3CLKConfig(uint32_t RCC_I2S3CLKSource)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_I2S3CLK_SOURCE(RCC_I2S3CLKSource));
+
+ *(__IO uint32_t *) CFGR2_I2S3SRC_BB = RCC_I2S3CLKSource;
+}
+#endif /* STM32F10X_CL */
+
+/**
+ * @brief Configures the External Low Speed oscillator (LSE).
+ * @param RCC_LSE: specifies the new state of the LSE.
+ * This parameter can be one of the following values:
+ * @arg RCC_LSE_OFF: LSE oscillator OFF
+ * @arg RCC_LSE_ON: LSE oscillator ON
+ * @arg RCC_LSE_Bypass: LSE oscillator bypassed with external clock
+ * @retval None
+ */
+void RCC_LSEConfig(uint8_t RCC_LSE)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_LSE(RCC_LSE));
+ /* Reset LSEON and LSEBYP bits before configuring the LSE ------------------*/
+ /* Reset LSEON bit */
+ *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_OFF;
+ /* Reset LSEBYP bit */
+ *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_OFF;
+ /* Configure LSE (RCC_LSE_OFF is already covered by the code section above) */
+ switch(RCC_LSE)
+ {
+ case RCC_LSE_ON:
+ /* Set LSEON bit */
+ *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_ON;
+ break;
+
+ case RCC_LSE_Bypass:
+ /* Set LSEBYP and LSEON bits */
+ *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_Bypass | RCC_LSE_ON;
+ break;
+
+ default:
+ break;
+ }
+}
+
+/**
+ * @brief Enables or disables the Internal Low Speed oscillator (LSI).
+ * @note LSI can not be disabled if the IWDG is running.
+ * @param NewState: new state of the LSI. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_LSICmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) CSR_LSION_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Configures the RTC clock (RTCCLK).
+ * @note Once the RTC clock is selected it can't be changed unless the Backup domain is reset.
+ * @param RCC_RTCCLKSource: specifies the RTC clock source.
+ * This parameter can be one of the following values:
+ * @arg RCC_RTCCLKSource_LSE: LSE selected as RTC clock
+ * @arg RCC_RTCCLKSource_LSI: LSI selected as RTC clock
+ * @arg RCC_RTCCLKSource_HSE_Div128: HSE clock divided by 128 selected as RTC clock
+ * @retval None
+ */
+void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource));
+ /* Select the RTC clock source */
+ RCC->BDCR |= RCC_RTCCLKSource;
+}
+
+/**
+ * @brief Enables or disables the RTC clock.
+ * @note This function must be used only after the RTC clock was selected using the RCC_RTCCLKConfig function.
+ * @param NewState: new state of the RTC clock. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_RTCCLKCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) BDCR_RTCEN_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Returns the frequencies of different on chip clocks.
+ * @param RCC_Clocks: pointer to a RCC_ClocksTypeDef structure which will hold
+ * the clocks frequencies.
+ * @note The result of this function could be not correct when using
+ * fractional value for HSE crystal.
+ * @retval None
+ */
+void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks)
+{
+ uint32_t tmp = 0, pllmull = 0, pllsource = 0, presc = 0;
+
+#ifdef STM32F10X_CL
+ uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0;
+#endif /* STM32F10X_CL */
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+ uint32_t prediv1factor = 0;
+#endif
+
+ /* Get SYSCLK source -------------------------------------------------------*/
+ tmp = RCC->CFGR & CFGR_SWS_Mask;
+
+ switch (tmp)
+ {
+ case 0x00: /* HSI used as system clock */
+ RCC_Clocks->SYSCLK_Frequency = HSI_VALUE;
+ break;
+ case 0x04: /* HSE used as system clock */
+ RCC_Clocks->SYSCLK_Frequency = HSE_VALUE;
+ break;
+ case 0x08: /* PLL used as system clock */
+
+ /* Get PLL clock source and multiplication factor ----------------------*/
+ pllmull = RCC->CFGR & CFGR_PLLMull_Mask;
+ pllsource = RCC->CFGR & CFGR_PLLSRC_Mask;
+
+#ifndef STM32F10X_CL
+ pllmull = ( pllmull >> 18) + 2;
+
+ if (pllsource == 0x00)
+ {/* HSI oscillator clock divided by 2 selected as PLL clock entry */
+ RCC_Clocks->SYSCLK_Frequency = (HSI_VALUE >> 1) * pllmull;
+ }
+ else
+ {
+ #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+ prediv1factor = (RCC->CFGR2 & CFGR2_PREDIV1) + 1;
+ /* HSE oscillator clock selected as PREDIV1 clock entry */
+ RCC_Clocks->SYSCLK_Frequency = (HSE_VALUE / prediv1factor) * pllmull;
+ #else
+ /* HSE selected as PLL clock entry */
+ if ((RCC->CFGR & CFGR_PLLXTPRE_Mask) != (uint32_t)RESET)
+ {/* HSE oscillator clock divided by 2 */
+ RCC_Clocks->SYSCLK_Frequency = (HSE_VALUE >> 1) * pllmull;
+ }
+ else
+ {
+ RCC_Clocks->SYSCLK_Frequency = HSE_VALUE * pllmull;
+ }
+ #endif
+ }
+#else
+ pllmull = pllmull >> 18;
+
+ if (pllmull != 0x0D)
+ {
+ pllmull += 2;
+ }
+ else
+ { /* PLL multiplication factor = PLL input clock * 6.5 */
+ pllmull = 13 / 2;
+ }
+
+ if (pllsource == 0x00)
+ {/* HSI oscillator clock divided by 2 selected as PLL clock entry */
+ RCC_Clocks->SYSCLK_Frequency = (HSI_VALUE >> 1) * pllmull;
+ }
+ else
+ {/* PREDIV1 selected as PLL clock entry */
+
+ /* Get PREDIV1 clock source and division factor */
+ prediv1source = RCC->CFGR2 & CFGR2_PREDIV1SRC;
+ prediv1factor = (RCC->CFGR2 & CFGR2_PREDIV1) + 1;
+
+ if (prediv1source == 0)
+ { /* HSE oscillator clock selected as PREDIV1 clock entry */
+ RCC_Clocks->SYSCLK_Frequency = (HSE_VALUE / prediv1factor) * pllmull;
+ }
+ else
+ {/* PLL2 clock selected as PREDIV1 clock entry */
+
+ /* Get PREDIV2 division factor and PLL2 multiplication factor */
+ prediv2factor = ((RCC->CFGR2 & CFGR2_PREDIV2) >> 4) + 1;
+ pll2mull = ((RCC->CFGR2 & CFGR2_PLL2MUL) >> 8 ) + 2;
+ RCC_Clocks->SYSCLK_Frequency = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull;
+ }
+ }
+#endif /* STM32F10X_CL */
+ break;
+
+ default:
+ RCC_Clocks->SYSCLK_Frequency = HSI_VALUE;
+ break;
+ }
+
+ /* Compute HCLK, PCLK1, PCLK2 and ADCCLK clocks frequencies ----------------*/
+ /* Get HCLK prescaler */
+ tmp = RCC->CFGR & CFGR_HPRE_Set_Mask;
+ tmp = tmp >> 4;
+ presc = APBAHBPrescTable[tmp];
+ /* HCLK clock frequency */
+ RCC_Clocks->HCLK_Frequency = RCC_Clocks->SYSCLK_Frequency >> presc;
+ /* Get PCLK1 prescaler */
+ tmp = RCC->CFGR & CFGR_PPRE1_Set_Mask;
+ tmp = tmp >> 8;
+ presc = APBAHBPrescTable[tmp];
+ /* PCLK1 clock frequency */
+ RCC_Clocks->PCLK1_Frequency = RCC_Clocks->HCLK_Frequency >> presc;
+ /* Get PCLK2 prescaler */
+ tmp = RCC->CFGR & CFGR_PPRE2_Set_Mask;
+ tmp = tmp >> 11;
+ presc = APBAHBPrescTable[tmp];
+ /* PCLK2 clock frequency */
+ RCC_Clocks->PCLK2_Frequency = RCC_Clocks->HCLK_Frequency >> presc;
+ /* Get ADCCLK prescaler */
+ tmp = RCC->CFGR & CFGR_ADCPRE_Set_Mask;
+ tmp = tmp >> 14;
+ presc = ADCPrescTable[tmp];
+ /* ADCCLK clock frequency */
+ RCC_Clocks->ADCCLK_Frequency = RCC_Clocks->PCLK2_Frequency / presc;
+}
+
+/**
+ * @brief Enables or disables the AHB peripheral clock.
+ * @param RCC_AHBPeriph: specifies the AHB peripheral to gates its clock.
+ *
+ * For @b STM32_Connectivity_line_devices, this parameter can be any combination
+ * of the following values:
+ * @arg RCC_AHBPeriph_DMA1
+ * @arg RCC_AHBPeriph_DMA2
+ * @arg RCC_AHBPeriph_SRAM
+ * @arg RCC_AHBPeriph_FLITF
+ * @arg RCC_AHBPeriph_CRC
+ * @arg RCC_AHBPeriph_OTG_FS
+ * @arg RCC_AHBPeriph_ETH_MAC
+ * @arg RCC_AHBPeriph_ETH_MAC_Tx
+ * @arg RCC_AHBPeriph_ETH_MAC_Rx
+ *
+ * For @b other_STM32_devices, this parameter can be any combination of the
+ * following values:
+ * @arg RCC_AHBPeriph_DMA1
+ * @arg RCC_AHBPeriph_DMA2
+ * @arg RCC_AHBPeriph_SRAM
+ * @arg RCC_AHBPeriph_FLITF
+ * @arg RCC_AHBPeriph_CRC
+ * @arg RCC_AHBPeriph_FSMC
+ * @arg RCC_AHBPeriph_SDIO
+ *
+ * @note SRAM and FLITF clock can be disabled only during sleep mode.
+ * @param NewState: new state of the specified peripheral clock.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_AHB_PERIPH(RCC_AHBPeriph));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ RCC->AHBENR |= RCC_AHBPeriph;
+ }
+ else
+ {
+ RCC->AHBENR &= ~RCC_AHBPeriph;
+ }
+}
+
+/**
+ * @brief Enables or disables the High Speed APB (APB2) peripheral clock.
+ * @param RCC_APB2Periph: specifies the APB2 peripheral to gates its clock.
+ * This parameter can be any combination of the following values:
+ * @arg RCC_APB2Periph_AFIO, RCC_APB2Periph_GPIOA, RCC_APB2Periph_GPIOB,
+ * RCC_APB2Periph_GPIOC, RCC_APB2Periph_GPIOD, RCC_APB2Periph_GPIOE,
+ * RCC_APB2Periph_GPIOF, RCC_APB2Periph_GPIOG, RCC_APB2Periph_ADC1,
+ * RCC_APB2Periph_ADC2, RCC_APB2Periph_TIM1, RCC_APB2Periph_SPI1,
+ * RCC_APB2Periph_TIM8, RCC_APB2Periph_USART1, RCC_APB2Periph_ADC3,
+ * RCC_APB2Periph_TIM15, RCC_APB2Periph_TIM16, RCC_APB2Periph_TIM17,
+ * RCC_APB2Periph_TIM9, RCC_APB2Periph_TIM10, RCC_APB2Periph_TIM11
+ * @param NewState: new state of the specified peripheral clock.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ RCC->APB2ENR |= RCC_APB2Periph;
+ }
+ else
+ {
+ RCC->APB2ENR &= ~RCC_APB2Periph;
+ }
+}
+
+/**
+ * @brief Enables or disables the Low Speed APB (APB1) peripheral clock.
+ * @param RCC_APB1Periph: specifies the APB1 peripheral to gates its clock.
+ * This parameter can be any combination of the following values:
+ * @arg RCC_APB1Periph_TIM2, RCC_APB1Periph_TIM3, RCC_APB1Periph_TIM4,
+ * RCC_APB1Periph_TIM5, RCC_APB1Periph_TIM6, RCC_APB1Periph_TIM7,
+ * RCC_APB1Periph_WWDG, RCC_APB1Periph_SPI2, RCC_APB1Periph_SPI3,
+ * RCC_APB1Periph_USART2, RCC_APB1Periph_USART3, RCC_APB1Periph_USART4,
+ * RCC_APB1Periph_USART5, RCC_APB1Periph_I2C1, RCC_APB1Periph_I2C2,
+ * RCC_APB1Periph_USB, RCC_APB1Periph_CAN1, RCC_APB1Periph_BKP,
+ * RCC_APB1Periph_PWR, RCC_APB1Periph_DAC, RCC_APB1Periph_CEC,
+ * RCC_APB1Periph_TIM12, RCC_APB1Periph_TIM13, RCC_APB1Periph_TIM14
+ * @param NewState: new state of the specified peripheral clock.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ RCC->APB1ENR |= RCC_APB1Periph;
+ }
+ else
+ {
+ RCC->APB1ENR &= ~RCC_APB1Periph;
+ }
+}
+
+#ifdef STM32F10X_CL
+/**
+ * @brief Forces or releases AHB peripheral reset.
+ * @note This function applies only to STM32 Connectivity line devices.
+ * @param RCC_AHBPeriph: specifies the AHB peripheral to reset.
+ * This parameter can be any combination of the following values:
+ * @arg RCC_AHBPeriph_OTG_FS
+ * @arg RCC_AHBPeriph_ETH_MAC
+ * @param NewState: new state of the specified peripheral reset.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_AHBPeriphResetCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_AHB_PERIPH_RESET(RCC_AHBPeriph));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ RCC->AHBRSTR |= RCC_AHBPeriph;
+ }
+ else
+ {
+ RCC->AHBRSTR &= ~RCC_AHBPeriph;
+ }
+}
+#endif /* STM32F10X_CL */
+
+/**
+ * @brief Forces or releases High Speed APB (APB2) peripheral reset.
+ * @param RCC_APB2Periph: specifies the APB2 peripheral to reset.
+ * This parameter can be any combination of the following values:
+ * @arg RCC_APB2Periph_AFIO, RCC_APB2Periph_GPIOA, RCC_APB2Periph_GPIOB,
+ * RCC_APB2Periph_GPIOC, RCC_APB2Periph_GPIOD, RCC_APB2Periph_GPIOE,
+ * RCC_APB2Periph_GPIOF, RCC_APB2Periph_GPIOG, RCC_APB2Periph_ADC1,
+ * RCC_APB2Periph_ADC2, RCC_APB2Periph_TIM1, RCC_APB2Periph_SPI1,
+ * RCC_APB2Periph_TIM8, RCC_APB2Periph_USART1, RCC_APB2Periph_ADC3,
+ * RCC_APB2Periph_TIM15, RCC_APB2Periph_TIM16, RCC_APB2Periph_TIM17,
+ * RCC_APB2Periph_TIM9, RCC_APB2Periph_TIM10, RCC_APB2Periph_TIM11
+ * @param NewState: new state of the specified peripheral reset.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ RCC->APB2RSTR |= RCC_APB2Periph;
+ }
+ else
+ {
+ RCC->APB2RSTR &= ~RCC_APB2Periph;
+ }
+}
+
+/**
+ * @brief Forces or releases Low Speed APB (APB1) peripheral reset.
+ * @param RCC_APB1Periph: specifies the APB1 peripheral to reset.
+ * This parameter can be any combination of the following values:
+ * @arg RCC_APB1Periph_TIM2, RCC_APB1Periph_TIM3, RCC_APB1Periph_TIM4,
+ * RCC_APB1Periph_TIM5, RCC_APB1Periph_TIM6, RCC_APB1Periph_TIM7,
+ * RCC_APB1Periph_WWDG, RCC_APB1Periph_SPI2, RCC_APB1Periph_SPI3,
+ * RCC_APB1Periph_USART2, RCC_APB1Periph_USART3, RCC_APB1Periph_USART4,
+ * RCC_APB1Periph_USART5, RCC_APB1Periph_I2C1, RCC_APB1Periph_I2C2,
+ * RCC_APB1Periph_USB, RCC_APB1Periph_CAN1, RCC_APB1Periph_BKP,
+ * RCC_APB1Periph_PWR, RCC_APB1Periph_DAC, RCC_APB1Periph_CEC,
+ * RCC_APB1Periph_TIM12, RCC_APB1Periph_TIM13, RCC_APB1Periph_TIM14
+ * @param NewState: new state of the specified peripheral clock.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ RCC->APB1RSTR |= RCC_APB1Periph;
+ }
+ else
+ {
+ RCC->APB1RSTR &= ~RCC_APB1Periph;
+ }
+}
+
+/**
+ * @brief Forces or releases the Backup domain reset.
+ * @param NewState: new state of the Backup domain reset.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_BackupResetCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) BDCR_BDRST_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Enables or disables the Clock Security System.
+ * @param NewState: new state of the Clock Security System..
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RCC_ClockSecuritySystemCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ *(__IO uint32_t *) CR_CSSON_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Selects the clock source to output on MCO pin.
+ * @param RCC_MCO: specifies the clock source to output.
+ *
+ * For @b STM32_Connectivity_line_devices, this parameter can be one of the
+ * following values:
+ * @arg RCC_MCO_NoClock: No clock selected
+ * @arg RCC_MCO_SYSCLK: System clock selected
+ * @arg RCC_MCO_HSI: HSI oscillator clock selected
+ * @arg RCC_MCO_HSE: HSE oscillator clock selected
+ * @arg RCC_MCO_PLLCLK_Div2: PLL clock divided by 2 selected
+ * @arg RCC_MCO_PLL2CLK: PLL2 clock selected
+ * @arg RCC_MCO_PLL3CLK_Div2: PLL3 clock divided by 2 selected
+ * @arg RCC_MCO_XT1: External 3-25 MHz oscillator clock selected
+ * @arg RCC_MCO_PLL3CLK: PLL3 clock selected
+ *
+ * For @b other_STM32_devices, this parameter can be one of the following values:
+ * @arg RCC_MCO_NoClock: No clock selected
+ * @arg RCC_MCO_SYSCLK: System clock selected
+ * @arg RCC_MCO_HSI: HSI oscillator clock selected
+ * @arg RCC_MCO_HSE: HSE oscillator clock selected
+ * @arg RCC_MCO_PLLCLK_Div2: PLL clock divided by 2 selected
+ *
+ * @retval None
+ */
+void RCC_MCOConfig(uint8_t RCC_MCO)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_MCO(RCC_MCO));
+
+ /* Perform Byte access to MCO bits to select the MCO source */
+ *(__IO uint8_t *) CFGR_BYTE4_ADDRESS = RCC_MCO;
+}
+
+/**
+ * @brief Checks whether the specified RCC flag is set or not.
+ * @param RCC_FLAG: specifies the flag to check.
+ *
+ * For @b STM32_Connectivity_line_devices, this parameter can be one of the
+ * following values:
+ * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready
+ * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready
+ * @arg RCC_FLAG_PLLRDY: PLL clock ready
+ * @arg RCC_FLAG_PLL2RDY: PLL2 clock ready
+ * @arg RCC_FLAG_PLL3RDY: PLL3 clock ready
+ * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready
+ * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready
+ * @arg RCC_FLAG_PINRST: Pin reset
+ * @arg RCC_FLAG_PORRST: POR/PDR reset
+ * @arg RCC_FLAG_SFTRST: Software reset
+ * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset
+ * @arg RCC_FLAG_WWDGRST: Window Watchdog reset
+ * @arg RCC_FLAG_LPWRRST: Low Power reset
+ *
+ * For @b other_STM32_devices, this parameter can be one of the following values:
+ * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready
+ * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready
+ * @arg RCC_FLAG_PLLRDY: PLL clock ready
+ * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready
+ * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready
+ * @arg RCC_FLAG_PINRST: Pin reset
+ * @arg RCC_FLAG_PORRST: POR/PDR reset
+ * @arg RCC_FLAG_SFTRST: Software reset
+ * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset
+ * @arg RCC_FLAG_WWDGRST: Window Watchdog reset
+ * @arg RCC_FLAG_LPWRRST: Low Power reset
+ *
+ * @retval The new state of RCC_FLAG (SET or RESET).
+ */
+FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
+{
+ uint32_t tmp = 0;
+ uint32_t statusreg = 0;
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_RCC_FLAG(RCC_FLAG));
+
+ /* Get the RCC register index */
+ tmp = RCC_FLAG >> 5;
+ if (tmp == 1) /* The flag to check is in CR register */
+ {
+ statusreg = RCC->CR;
+ }
+ else if (tmp == 2) /* The flag to check is in BDCR register */
+ {
+ statusreg = RCC->BDCR;
+ }
+ else /* The flag to check is in CSR register */
+ {
+ statusreg = RCC->CSR;
+ }
+
+ /* Get the flag position */
+ tmp = RCC_FLAG & FLAG_Mask;
+ if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+
+ /* Return the flag status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the RCC reset flags.
+ * @note The reset flags are: RCC_FLAG_PINRST, RCC_FLAG_PORRST, RCC_FLAG_SFTRST,
+ * RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST
+ * @param None
+ * @retval None
+ */
+void RCC_ClearFlag(void)
+{
+ /* Set RMVF bit to clear the reset flags */
+ RCC->CSR |= CSR_RMVF_Set;
+}
+
+/**
+ * @brief Checks whether the specified RCC interrupt has occurred or not.
+ * @param RCC_IT: specifies the RCC interrupt source to check.
+ *
+ * For @b STM32_Connectivity_line_devices, this parameter can be one of the
+ * following values:
+ * @arg RCC_IT_LSIRDY: LSI ready interrupt
+ * @arg RCC_IT_LSERDY: LSE ready interrupt
+ * @arg RCC_IT_HSIRDY: HSI ready interrupt
+ * @arg RCC_IT_HSERDY: HSE ready interrupt
+ * @arg RCC_IT_PLLRDY: PLL ready interrupt
+ * @arg RCC_IT_PLL2RDY: PLL2 ready interrupt
+ * @arg RCC_IT_PLL3RDY: PLL3 ready interrupt
+ * @arg RCC_IT_CSS: Clock Security System interrupt
+ *
+ * For @b other_STM32_devices, this parameter can be one of the following values:
+ * @arg RCC_IT_LSIRDY: LSI ready interrupt
+ * @arg RCC_IT_LSERDY: LSE ready interrupt
+ * @arg RCC_IT_HSIRDY: HSI ready interrupt
+ * @arg RCC_IT_HSERDY: HSE ready interrupt
+ * @arg RCC_IT_PLLRDY: PLL ready interrupt
+ * @arg RCC_IT_CSS: Clock Security System interrupt
+ *
+ * @retval The new state of RCC_IT (SET or RESET).
+ */
+ITStatus RCC_GetITStatus(uint8_t RCC_IT)
+{
+ ITStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_RCC_GET_IT(RCC_IT));
+
+ /* Check the status of the specified RCC interrupt */
+ if ((RCC->CIR & RCC_IT) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+
+ /* Return the RCC_IT status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the RCC's interrupt pending bits.
+ * @param RCC_IT: specifies the interrupt pending bit to clear.
+ *
+ * For @b STM32_Connectivity_line_devices, this parameter can be any combination
+ * of the following values:
+ * @arg RCC_IT_LSIRDY: LSI ready interrupt
+ * @arg RCC_IT_LSERDY: LSE ready interrupt
+ * @arg RCC_IT_HSIRDY: HSI ready interrupt
+ * @arg RCC_IT_HSERDY: HSE ready interrupt
+ * @arg RCC_IT_PLLRDY: PLL ready interrupt
+ * @arg RCC_IT_PLL2RDY: PLL2 ready interrupt
+ * @arg RCC_IT_PLL3RDY: PLL3 ready interrupt
+ * @arg RCC_IT_CSS: Clock Security System interrupt
+ *
+ * For @b other_STM32_devices, this parameter can be any combination of the
+ * following values:
+ * @arg RCC_IT_LSIRDY: LSI ready interrupt
+ * @arg RCC_IT_LSERDY: LSE ready interrupt
+ * @arg RCC_IT_HSIRDY: HSI ready interrupt
+ * @arg RCC_IT_HSERDY: HSE ready interrupt
+ * @arg RCC_IT_PLLRDY: PLL ready interrupt
+ *
+ * @arg RCC_IT_CSS: Clock Security System interrupt
+ * @retval None
+ */
+void RCC_ClearITPendingBit(uint8_t RCC_IT)
+{
+ /* Check the parameters */
+ assert_param(IS_RCC_CLEAR_IT(RCC_IT));
+
+ /* Perform Byte access to RCC_CIR[23:16] bits to clear the selected interrupt
+ pending bits */
+ *(__IO uint8_t *) CIR_BYTE3_ADDRESS = RCC_IT;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_rtc.c b/st_fw_lib/src/stm32f10x_rtc.c
new file mode 100644
index 0000000..f05aef5
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_rtc.c
@@ -0,0 +1,339 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_rtc.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the RTC firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_rtc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup RTC
+ * @brief RTC driver modules
+ * @{
+ */
+
+/** @defgroup RTC_Private_TypesDefinitions
+ * @{
+ */
+/**
+ * @}
+ */
+
+/** @defgroup RTC_Private_Defines
+ * @{
+ */
+#define RTC_LSB_MASK ((uint32_t)0x0000FFFF) /*!< RTC LSB Mask */
+#define PRLH_MSB_MASK ((uint32_t)0x000F0000) /*!< RTC Prescaler MSB Mask */
+
+/**
+ * @}
+ */
+
+/** @defgroup RTC_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RTC_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RTC_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup RTC_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Enables or disables the specified RTC interrupts.
+ * @param RTC_IT: specifies the RTC interrupts sources to be enabled or disabled.
+ * This parameter can be any combination of the following values:
+ * @arg RTC_IT_OW: Overflow interrupt
+ * @arg RTC_IT_ALR: Alarm interrupt
+ * @arg RTC_IT_SEC: Second interrupt
+ * @param NewState: new state of the specified RTC interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_RTC_IT(RTC_IT));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ RTC->CRH |= RTC_IT;
+ }
+ else
+ {
+ RTC->CRH &= (uint16_t)~RTC_IT;
+ }
+}
+
+/**
+ * @brief Enters the RTC configuration mode.
+ * @param None
+ * @retval None
+ */
+void RTC_EnterConfigMode(void)
+{
+ /* Set the CNF flag to enter in the Configuration Mode */
+ RTC->CRL |= RTC_CRL_CNF;
+}
+
+/**
+ * @brief Exits from the RTC configuration mode.
+ * @param None
+ * @retval None
+ */
+void RTC_ExitConfigMode(void)
+{
+ /* Reset the CNF flag to exit from the Configuration Mode */
+ RTC->CRL &= (uint16_t)~((uint16_t)RTC_CRL_CNF);
+}
+
+/**
+ * @brief Gets the RTC counter value.
+ * @param None
+ * @retval RTC counter value.
+ */
+uint32_t RTC_GetCounter(void)
+{
+ uint16_t tmp = 0;
+ tmp = RTC->CNTL;
+ return (((uint32_t)RTC->CNTH << 16 ) | tmp) ;
+}
+
+/**
+ * @brief Sets the RTC counter value.
+ * @param CounterValue: RTC counter new value.
+ * @retval None
+ */
+void RTC_SetCounter(uint32_t CounterValue)
+{
+ RTC_EnterConfigMode();
+ /* Set RTC COUNTER MSB word */
+ RTC->CNTH = CounterValue >> 16;
+ /* Set RTC COUNTER LSB word */
+ RTC->CNTL = (CounterValue & RTC_LSB_MASK);
+ RTC_ExitConfigMode();
+}
+
+/**
+ * @brief Sets the RTC prescaler value.
+ * @param PrescalerValue: RTC prescaler new value.
+ * @retval None
+ */
+void RTC_SetPrescaler(uint32_t PrescalerValue)
+{
+ /* Check the parameters */
+ assert_param(IS_RTC_PRESCALER(PrescalerValue));
+
+ RTC_EnterConfigMode();
+ /* Set RTC PRESCALER MSB word */
+ RTC->PRLH = (PrescalerValue & PRLH_MSB_MASK) >> 16;
+ /* Set RTC PRESCALER LSB word */
+ RTC->PRLL = (PrescalerValue & RTC_LSB_MASK);
+ RTC_ExitConfigMode();
+}
+
+/**
+ * @brief Sets the RTC alarm value.
+ * @param AlarmValue: RTC alarm new value.
+ * @retval None
+ */
+void RTC_SetAlarm(uint32_t AlarmValue)
+{
+ RTC_EnterConfigMode();
+ /* Set the ALARM MSB word */
+ RTC->ALRH = AlarmValue >> 16;
+ /* Set the ALARM LSB word */
+ RTC->ALRL = (AlarmValue & RTC_LSB_MASK);
+ RTC_ExitConfigMode();
+}
+
+/**
+ * @brief Gets the RTC divider value.
+ * @param None
+ * @retval RTC Divider value.
+ */
+uint32_t RTC_GetDivider(void)
+{
+ uint32_t tmp = 0x00;
+ tmp = ((uint32_t)RTC->DIVH & (uint32_t)0x000F) << 16;
+ tmp |= RTC->DIVL;
+ return tmp;
+}
+
+/**
+ * @brief Waits until last write operation on RTC registers has finished.
+ * @note This function must be called before any write to RTC registers.
+ * @param None
+ * @retval None
+ */
+void RTC_WaitForLastTask(void)
+{
+ /* Loop until RTOFF flag is set */
+ while ((RTC->CRL & RTC_FLAG_RTOFF) == (uint16_t)RESET)
+ {
+ }
+}
+
+/**
+ * @brief Waits until the RTC registers (RTC_CNT, RTC_ALR and RTC_PRL)
+ * are synchronized with RTC APB clock.
+ * @note This function must be called before any read operation after an APB reset
+ * or an APB clock stop.
+ * @param None
+ * @retval None
+ */
+void RTC_WaitForSynchro(void)
+{
+ /* Clear RSF flag */
+ RTC->CRL &= (uint16_t)~RTC_FLAG_RSF;
+ /* Loop until RSF flag is set */
+ while ((RTC->CRL & RTC_FLAG_RSF) == (uint16_t)RESET)
+ {
+ }
+}
+
+/**
+ * @brief Checks whether the specified RTC flag is set or not.
+ * @param RTC_FLAG: specifies the flag to check.
+ * This parameter can be one the following values:
+ * @arg RTC_FLAG_RTOFF: RTC Operation OFF flag
+ * @arg RTC_FLAG_RSF: Registers Synchronized flag
+ * @arg RTC_FLAG_OW: Overflow flag
+ * @arg RTC_FLAG_ALR: Alarm flag
+ * @arg RTC_FLAG_SEC: Second flag
+ * @retval The new state of RTC_FLAG (SET or RESET).
+ */
+FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+
+ /* Check the parameters */
+ assert_param(IS_RTC_GET_FLAG(RTC_FLAG));
+
+ if ((RTC->CRL & RTC_FLAG) != (uint16_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the RTC's pending flags.
+ * @param RTC_FLAG: specifies the flag to clear.
+ * This parameter can be any combination of the following values:
+ * @arg RTC_FLAG_RSF: Registers Synchronized flag. This flag is cleared only after
+ * an APB reset or an APB Clock stop.
+ * @arg RTC_FLAG_OW: Overflow flag
+ * @arg RTC_FLAG_ALR: Alarm flag
+ * @arg RTC_FLAG_SEC: Second flag
+ * @retval None
+ */
+void RTC_ClearFlag(uint16_t RTC_FLAG)
+{
+ /* Check the parameters */
+ assert_param(IS_RTC_CLEAR_FLAG(RTC_FLAG));
+
+ /* Clear the corresponding RTC flag */
+ RTC->CRL &= (uint16_t)~RTC_FLAG;
+}
+
+/**
+ * @brief Checks whether the specified RTC interrupt has occurred or not.
+ * @param RTC_IT: specifies the RTC interrupts sources to check.
+ * This parameter can be one of the following values:
+ * @arg RTC_IT_OW: Overflow interrupt
+ * @arg RTC_IT_ALR: Alarm interrupt
+ * @arg RTC_IT_SEC: Second interrupt
+ * @retval The new state of the RTC_IT (SET or RESET).
+ */
+ITStatus RTC_GetITStatus(uint16_t RTC_IT)
+{
+ ITStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_RTC_GET_IT(RTC_IT));
+
+ bitstatus = (ITStatus)(RTC->CRL & RTC_IT);
+ if (((RTC->CRH & RTC_IT) != (uint16_t)RESET) && (bitstatus != (uint16_t)RESET))
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the RTC's interrupt pending bits.
+ * @param RTC_IT: specifies the interrupt pending bit to clear.
+ * This parameter can be any combination of the following values:
+ * @arg RTC_IT_OW: Overflow interrupt
+ * @arg RTC_IT_ALR: Alarm interrupt
+ * @arg RTC_IT_SEC: Second interrupt
+ * @retval None
+ */
+void RTC_ClearITPendingBit(uint16_t RTC_IT)
+{
+ /* Check the parameters */
+ assert_param(IS_RTC_IT(RTC_IT));
+
+ /* Clear the corresponding RTC pending bit */
+ RTC->CRL &= (uint16_t)~RTC_IT;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_sdio.c b/st_fw_lib/src/stm32f10x_sdio.c
new file mode 100644
index 0000000..bc1719d
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_sdio.c
@@ -0,0 +1,799 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_sdio.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the SDIO firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_sdio.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup SDIO
+ * @brief SDIO driver modules
+ * @{
+ */
+
+/** @defgroup SDIO_Private_TypesDefinitions
+ * @{
+ */
+
+/* ------------ SDIO registers bit address in the alias region ----------- */
+#define SDIO_OFFSET (SDIO_BASE - PERIPH_BASE)
+
+/* --- CLKCR Register ---*/
+
+/* Alias word address of CLKEN bit */
+#define CLKCR_OFFSET (SDIO_OFFSET + 0x04)
+#define CLKEN_BitNumber 0x08
+#define CLKCR_CLKEN_BB (PERIPH_BB_BASE + (CLKCR_OFFSET * 32) + (CLKEN_BitNumber * 4))
+
+/* --- CMD Register ---*/
+
+/* Alias word address of SDIOSUSPEND bit */
+#define CMD_OFFSET (SDIO_OFFSET + 0x0C)
+#define SDIOSUSPEND_BitNumber 0x0B
+#define CMD_SDIOSUSPEND_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (SDIOSUSPEND_BitNumber * 4))
+
+/* Alias word address of ENCMDCOMPL bit */
+#define ENCMDCOMPL_BitNumber 0x0C
+#define CMD_ENCMDCOMPL_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ENCMDCOMPL_BitNumber * 4))
+
+/* Alias word address of NIEN bit */
+#define NIEN_BitNumber 0x0D
+#define CMD_NIEN_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (NIEN_BitNumber * 4))
+
+/* Alias word address of ATACMD bit */
+#define ATACMD_BitNumber 0x0E
+#define CMD_ATACMD_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ATACMD_BitNumber * 4))
+
+/* --- DCTRL Register ---*/
+
+/* Alias word address of DMAEN bit */
+#define DCTRL_OFFSET (SDIO_OFFSET + 0x2C)
+#define DMAEN_BitNumber 0x03
+#define DCTRL_DMAEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (DMAEN_BitNumber * 4))
+
+/* Alias word address of RWSTART bit */
+#define RWSTART_BitNumber 0x08
+#define DCTRL_RWSTART_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTART_BitNumber * 4))
+
+/* Alias word address of RWSTOP bit */
+#define RWSTOP_BitNumber 0x09
+#define DCTRL_RWSTOP_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTOP_BitNumber * 4))
+
+/* Alias word address of RWMOD bit */
+#define RWMOD_BitNumber 0x0A
+#define DCTRL_RWMOD_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWMOD_BitNumber * 4))
+
+/* Alias word address of SDIOEN bit */
+#define SDIOEN_BitNumber 0x0B
+#define DCTRL_SDIOEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (SDIOEN_BitNumber * 4))
+
+/* ---------------------- SDIO registers bit mask ------------------------ */
+
+/* --- CLKCR Register ---*/
+
+/* CLKCR register clear mask */
+#define CLKCR_CLEAR_MASK ((uint32_t)0xFFFF8100)
+
+/* --- PWRCTRL Register ---*/
+
+/* SDIO PWRCTRL Mask */
+#define PWR_PWRCTRL_MASK ((uint32_t)0xFFFFFFFC)
+
+/* --- DCTRL Register ---*/
+
+/* SDIO DCTRL Clear Mask */
+#define DCTRL_CLEAR_MASK ((uint32_t)0xFFFFFF08)
+
+/* --- CMD Register ---*/
+
+/* CMD Register clear mask */
+#define CMD_CLEAR_MASK ((uint32_t)0xFFFFF800)
+
+/* SDIO RESP Registers Address */
+#define SDIO_RESP_ADDR ((uint32_t)(SDIO_BASE + 0x14))
+
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Private_Defines
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SDIO_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the SDIO peripheral registers to their default reset values.
+ * @param None
+ * @retval None
+ */
+void SDIO_DeInit(void)
+{
+ SDIO->POWER = 0x00000000;
+ SDIO->CLKCR = 0x00000000;
+ SDIO->ARG = 0x00000000;
+ SDIO->CMD = 0x00000000;
+ SDIO->DTIMER = 0x00000000;
+ SDIO->DLEN = 0x00000000;
+ SDIO->DCTRL = 0x00000000;
+ SDIO->ICR = 0x00C007FF;
+ SDIO->MASK = 0x00000000;
+}
+
+/**
+ * @brief Initializes the SDIO peripheral according to the specified
+ * parameters in the SDIO_InitStruct.
+ * @param SDIO_InitStruct : pointer to a SDIO_InitTypeDef structure
+ * that contains the configuration information for the SDIO peripheral.
+ * @retval None
+ */
+void SDIO_Init(SDIO_InitTypeDef* SDIO_InitStruct)
+{
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_SDIO_CLOCK_EDGE(SDIO_InitStruct->SDIO_ClockEdge));
+ assert_param(IS_SDIO_CLOCK_BYPASS(SDIO_InitStruct->SDIO_ClockBypass));
+ assert_param(IS_SDIO_CLOCK_POWER_SAVE(SDIO_InitStruct->SDIO_ClockPowerSave));
+ assert_param(IS_SDIO_BUS_WIDE(SDIO_InitStruct->SDIO_BusWide));
+ assert_param(IS_SDIO_HARDWARE_FLOW_CONTROL(SDIO_InitStruct->SDIO_HardwareFlowControl));
+
+/*---------------------------- SDIO CLKCR Configuration ------------------------*/
+ /* Get the SDIO CLKCR value */
+ tmpreg = SDIO->CLKCR;
+
+ /* Clear CLKDIV, PWRSAV, BYPASS, WIDBUS, NEGEDGE, HWFC_EN bits */
+ tmpreg &= CLKCR_CLEAR_MASK;
+
+ /* Set CLKDIV bits according to SDIO_ClockDiv value */
+ /* Set PWRSAV bit according to SDIO_ClockPowerSave value */
+ /* Set BYPASS bit according to SDIO_ClockBypass value */
+ /* Set WIDBUS bits according to SDIO_BusWide value */
+ /* Set NEGEDGE bits according to SDIO_ClockEdge value */
+ /* Set HWFC_EN bits according to SDIO_HardwareFlowControl value */
+ tmpreg |= (SDIO_InitStruct->SDIO_ClockDiv | SDIO_InitStruct->SDIO_ClockPowerSave |
+ SDIO_InitStruct->SDIO_ClockBypass | SDIO_InitStruct->SDIO_BusWide |
+ SDIO_InitStruct->SDIO_ClockEdge | SDIO_InitStruct->SDIO_HardwareFlowControl);
+
+ /* Write to SDIO CLKCR */
+ SDIO->CLKCR = tmpreg;
+}
+
+/**
+ * @brief Fills each SDIO_InitStruct member with its default value.
+ * @param SDIO_InitStruct: pointer to an SDIO_InitTypeDef structure which
+ * will be initialized.
+ * @retval None
+ */
+void SDIO_StructInit(SDIO_InitTypeDef* SDIO_InitStruct)
+{
+ /* SDIO_InitStruct members default value */
+ SDIO_InitStruct->SDIO_ClockDiv = 0x00;
+ SDIO_InitStruct->SDIO_ClockEdge = SDIO_ClockEdge_Rising;
+ SDIO_InitStruct->SDIO_ClockBypass = SDIO_ClockBypass_Disable;
+ SDIO_InitStruct->SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable;
+ SDIO_InitStruct->SDIO_BusWide = SDIO_BusWide_1b;
+ SDIO_InitStruct->SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;
+}
+
+/**
+ * @brief Enables or disables the SDIO Clock.
+ * @param NewState: new state of the SDIO Clock. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SDIO_ClockCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) CLKCR_CLKEN_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Sets the power status of the controller.
+ * @param SDIO_PowerState: new state of the Power state.
+ * This parameter can be one of the following values:
+ * @arg SDIO_PowerState_OFF
+ * @arg SDIO_PowerState_ON
+ * @retval None
+ */
+void SDIO_SetPowerState(uint32_t SDIO_PowerState)
+{
+ /* Check the parameters */
+ assert_param(IS_SDIO_POWER_STATE(SDIO_PowerState));
+
+ SDIO->POWER &= PWR_PWRCTRL_MASK;
+ SDIO->POWER |= SDIO_PowerState;
+}
+
+/**
+ * @brief Gets the power status of the controller.
+ * @param None
+ * @retval Power status of the controller. The returned value can
+ * be one of the following:
+ * - 0x00: Power OFF
+ * - 0x02: Power UP
+ * - 0x03: Power ON
+ */
+uint32_t SDIO_GetPowerState(void)
+{
+ return (SDIO->POWER & (~PWR_PWRCTRL_MASK));
+}
+
+/**
+ * @brief Enables or disables the SDIO interrupts.
+ * @param SDIO_IT: specifies the SDIO interrupt sources to be enabled or disabled.
+ * This parameter can be one or a combination of the following values:
+ * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
+ * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
+ * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
+ * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
+ * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
+ * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
+ * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt
+ * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt
+ * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt
+ * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide
+ * bus mode interrupt
+ * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
+ * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt
+ * @arg SDIO_IT_TXACT: Data transmit in progress interrupt
+ * @arg SDIO_IT_RXACT: Data receive in progress interrupt
+ * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
+ * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
+ * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt
+ * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt
+ * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt
+ * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt
+ * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt
+ * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt
+ * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
+ * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt
+ * @param NewState: new state of the specified SDIO interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SDIO_ITConfig(uint32_t SDIO_IT, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_SDIO_IT(SDIO_IT));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the SDIO interrupts */
+ SDIO->MASK |= SDIO_IT;
+ }
+ else
+ {
+ /* Disable the SDIO interrupts */
+ SDIO->MASK &= ~SDIO_IT;
+ }
+}
+
+/**
+ * @brief Enables or disables the SDIO DMA request.
+ * @param NewState: new state of the selected SDIO DMA request.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SDIO_DMACmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) DCTRL_DMAEN_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Initializes the SDIO Command according to the specified
+ * parameters in the SDIO_CmdInitStruct and send the command.
+ * @param SDIO_CmdInitStruct : pointer to a SDIO_CmdInitTypeDef
+ * structure that contains the configuration information for the SDIO command.
+ * @retval None
+ */
+void SDIO_SendCommand(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct)
+{
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_SDIO_CMD_INDEX(SDIO_CmdInitStruct->SDIO_CmdIndex));
+ assert_param(IS_SDIO_RESPONSE(SDIO_CmdInitStruct->SDIO_Response));
+ assert_param(IS_SDIO_WAIT(SDIO_CmdInitStruct->SDIO_Wait));
+ assert_param(IS_SDIO_CPSM(SDIO_CmdInitStruct->SDIO_CPSM));
+
+/*---------------------------- SDIO ARG Configuration ------------------------*/
+ /* Set the SDIO Argument value */
+ SDIO->ARG = SDIO_CmdInitStruct->SDIO_Argument;
+
+/*---------------------------- SDIO CMD Configuration ------------------------*/
+ /* Get the SDIO CMD value */
+ tmpreg = SDIO->CMD;
+ /* Clear CMDINDEX, WAITRESP, WAITINT, WAITPEND, CPSMEN bits */
+ tmpreg &= CMD_CLEAR_MASK;
+ /* Set CMDINDEX bits according to SDIO_CmdIndex value */
+ /* Set WAITRESP bits according to SDIO_Response value */
+ /* Set WAITINT and WAITPEND bits according to SDIO_Wait value */
+ /* Set CPSMEN bits according to SDIO_CPSM value */
+ tmpreg |= (uint32_t)SDIO_CmdInitStruct->SDIO_CmdIndex | SDIO_CmdInitStruct->SDIO_Response
+ | SDIO_CmdInitStruct->SDIO_Wait | SDIO_CmdInitStruct->SDIO_CPSM;
+
+ /* Write to SDIO CMD */
+ SDIO->CMD = tmpreg;
+}
+
+/**
+ * @brief Fills each SDIO_CmdInitStruct member with its default value.
+ * @param SDIO_CmdInitStruct: pointer to an SDIO_CmdInitTypeDef
+ * structure which will be initialized.
+ * @retval None
+ */
+void SDIO_CmdStructInit(SDIO_CmdInitTypeDef* SDIO_CmdInitStruct)
+{
+ /* SDIO_CmdInitStruct members default value */
+ SDIO_CmdInitStruct->SDIO_Argument = 0x00;
+ SDIO_CmdInitStruct->SDIO_CmdIndex = 0x00;
+ SDIO_CmdInitStruct->SDIO_Response = SDIO_Response_No;
+ SDIO_CmdInitStruct->SDIO_Wait = SDIO_Wait_No;
+ SDIO_CmdInitStruct->SDIO_CPSM = SDIO_CPSM_Disable;
+}
+
+/**
+ * @brief Returns command index of last command for which response received.
+ * @param None
+ * @retval Returns the command index of the last command response received.
+ */
+uint8_t SDIO_GetCommandResponse(void)
+{
+ return (uint8_t)(SDIO->RESPCMD);
+}
+
+/**
+ * @brief Returns response received from the card for the last command.
+ * @param SDIO_RESP: Specifies the SDIO response register.
+ * This parameter can be one of the following values:
+ * @arg SDIO_RESP1: Response Register 1
+ * @arg SDIO_RESP2: Response Register 2
+ * @arg SDIO_RESP3: Response Register 3
+ * @arg SDIO_RESP4: Response Register 4
+ * @retval The Corresponding response register value.
+ */
+uint32_t SDIO_GetResponse(uint32_t SDIO_RESP)
+{
+ __IO uint32_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_SDIO_RESP(SDIO_RESP));
+
+ tmp = SDIO_RESP_ADDR + SDIO_RESP;
+
+ return (*(__IO uint32_t *) tmp);
+}
+
+/**
+ * @brief Initializes the SDIO data path according to the specified
+ * parameters in the SDIO_DataInitStruct.
+ * @param SDIO_DataInitStruct : pointer to a SDIO_DataInitTypeDef structure that
+ * contains the configuration information for the SDIO command.
+ * @retval None
+ */
+void SDIO_DataConfig(SDIO_DataInitTypeDef* SDIO_DataInitStruct)
+{
+ uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_SDIO_DATA_LENGTH(SDIO_DataInitStruct->SDIO_DataLength));
+ assert_param(IS_SDIO_BLOCK_SIZE(SDIO_DataInitStruct->SDIO_DataBlockSize));
+ assert_param(IS_SDIO_TRANSFER_DIR(SDIO_DataInitStruct->SDIO_TransferDir));
+ assert_param(IS_SDIO_TRANSFER_MODE(SDIO_DataInitStruct->SDIO_TransferMode));
+ assert_param(IS_SDIO_DPSM(SDIO_DataInitStruct->SDIO_DPSM));
+
+/*---------------------------- SDIO DTIMER Configuration ---------------------*/
+ /* Set the SDIO Data TimeOut value */
+ SDIO->DTIMER = SDIO_DataInitStruct->SDIO_DataTimeOut;
+
+/*---------------------------- SDIO DLEN Configuration -----------------------*/
+ /* Set the SDIO DataLength value */
+ SDIO->DLEN = SDIO_DataInitStruct->SDIO_DataLength;
+
+/*---------------------------- SDIO DCTRL Configuration ----------------------*/
+ /* Get the SDIO DCTRL value */
+ tmpreg = SDIO->DCTRL;
+ /* Clear DEN, DTMODE, DTDIR and DBCKSIZE bits */
+ tmpreg &= DCTRL_CLEAR_MASK;
+ /* Set DEN bit according to SDIO_DPSM value */
+ /* Set DTMODE bit according to SDIO_TransferMode value */
+ /* Set DTDIR bit according to SDIO_TransferDir value */
+ /* Set DBCKSIZE bits according to SDIO_DataBlockSize value */
+ tmpreg |= (uint32_t)SDIO_DataInitStruct->SDIO_DataBlockSize | SDIO_DataInitStruct->SDIO_TransferDir
+ | SDIO_DataInitStruct->SDIO_TransferMode | SDIO_DataInitStruct->SDIO_DPSM;
+
+ /* Write to SDIO DCTRL */
+ SDIO->DCTRL = tmpreg;
+}
+
+/**
+ * @brief Fills each SDIO_DataInitStruct member with its default value.
+ * @param SDIO_DataInitStruct: pointer to an SDIO_DataInitTypeDef structure which
+ * will be initialized.
+ * @retval None
+ */
+void SDIO_DataStructInit(SDIO_DataInitTypeDef* SDIO_DataInitStruct)
+{
+ /* SDIO_DataInitStruct members default value */
+ SDIO_DataInitStruct->SDIO_DataTimeOut = 0xFFFFFFFF;
+ SDIO_DataInitStruct->SDIO_DataLength = 0x00;
+ SDIO_DataInitStruct->SDIO_DataBlockSize = SDIO_DataBlockSize_1b;
+ SDIO_DataInitStruct->SDIO_TransferDir = SDIO_TransferDir_ToCard;
+ SDIO_DataInitStruct->SDIO_TransferMode = SDIO_TransferMode_Block;
+ SDIO_DataInitStruct->SDIO_DPSM = SDIO_DPSM_Disable;
+}
+
+/**
+ * @brief Returns number of remaining data bytes to be transferred.
+ * @param None
+ * @retval Number of remaining data bytes to be transferred
+ */
+uint32_t SDIO_GetDataCounter(void)
+{
+ return SDIO->DCOUNT;
+}
+
+/**
+ * @brief Read one data word from Rx FIFO.
+ * @param None
+ * @retval Data received
+ */
+uint32_t SDIO_ReadData(void)
+{
+ return SDIO->FIFO;
+}
+
+/**
+ * @brief Write one data word to Tx FIFO.
+ * @param Data: 32-bit data word to write.
+ * @retval None
+ */
+void SDIO_WriteData(uint32_t Data)
+{
+ SDIO->FIFO = Data;
+}
+
+/**
+ * @brief Returns the number of words left to be written to or read from FIFO.
+ * @param None
+ * @retval Remaining number of words.
+ */
+uint32_t SDIO_GetFIFOCount(void)
+{
+ return SDIO->FIFOCNT;
+}
+
+/**
+ * @brief Starts the SD I/O Read Wait operation.
+ * @param NewState: new state of the Start SDIO Read Wait operation.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SDIO_StartSDIOReadWait(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) DCTRL_RWSTART_BB = (uint32_t) NewState;
+}
+
+/**
+ * @brief Stops the SD I/O Read Wait operation.
+ * @param NewState: new state of the Stop SDIO Read Wait operation.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SDIO_StopSDIOReadWait(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) DCTRL_RWSTOP_BB = (uint32_t) NewState;
+}
+
+/**
+ * @brief Sets one of the two options of inserting read wait interval.
+ * @param SDIO_ReadWaitMode: SD I/O Read Wait operation mode.
+ * This parameter can be:
+ * @arg SDIO_ReadWaitMode_CLK: Read Wait control by stopping SDIOCLK
+ * @arg SDIO_ReadWaitMode_DATA2: Read Wait control using SDIO_DATA2
+ * @retval None
+ */
+void SDIO_SetSDIOReadWaitMode(uint32_t SDIO_ReadWaitMode)
+{
+ /* Check the parameters */
+ assert_param(IS_SDIO_READWAIT_MODE(SDIO_ReadWaitMode));
+
+ *(__IO uint32_t *) DCTRL_RWMOD_BB = SDIO_ReadWaitMode;
+}
+
+/**
+ * @brief Enables or disables the SD I/O Mode Operation.
+ * @param NewState: new state of SDIO specific operation.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SDIO_SetSDIOOperation(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) DCTRL_SDIOEN_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Enables or disables the SD I/O Mode suspend command sending.
+ * @param NewState: new state of the SD I/O Mode suspend command.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SDIO_SendSDIOSuspendCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) CMD_SDIOSUSPEND_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Enables or disables the command completion signal.
+ * @param NewState: new state of command completion signal.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SDIO_CommandCompletionCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) CMD_ENCMDCOMPL_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Enables or disables the CE-ATA interrupt.
+ * @param NewState: new state of CE-ATA interrupt. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SDIO_CEATAITCmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) CMD_NIEN_BB = (uint32_t)((~((uint32_t)NewState)) & ((uint32_t)0x1));
+}
+
+/**
+ * @brief Sends CE-ATA command (CMD61).
+ * @param NewState: new state of CE-ATA command. This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SDIO_SendCEATACmd(FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ *(__IO uint32_t *) CMD_ATACMD_BB = (uint32_t)NewState;
+}
+
+/**
+ * @brief Checks whether the specified SDIO flag is set or not.
+ * @param SDIO_FLAG: specifies the flag to check.
+ * This parameter can be one of the following values:
+ * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed)
+ * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
+ * @arg SDIO_FLAG_CTIMEOUT: Command response timeout
+ * @arg SDIO_FLAG_DTIMEOUT: Data timeout
+ * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
+ * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error
+ * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed)
+ * @arg SDIO_FLAG_CMDSENT: Command sent (no response required)
+ * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero)
+ * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide
+ * bus mode.
+ * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed)
+ * @arg SDIO_FLAG_CMDACT: Command transfer in progress
+ * @arg SDIO_FLAG_TXACT: Data transmit in progress
+ * @arg SDIO_FLAG_RXACT: Data receive in progress
+ * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty
+ * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full
+ * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full
+ * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full
+ * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty
+ * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty
+ * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO
+ * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO
+ * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received
+ * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61
+ * @retval The new state of SDIO_FLAG (SET or RESET).
+ */
+FlagStatus SDIO_GetFlagStatus(uint32_t SDIO_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+
+ /* Check the parameters */
+ assert_param(IS_SDIO_FLAG(SDIO_FLAG));
+
+ if ((SDIO->STA & SDIO_FLAG) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the SDIO's pending flags.
+ * @param SDIO_FLAG: specifies the flag to clear.
+ * This parameter can be one or a combination of the following values:
+ * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed)
+ * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
+ * @arg SDIO_FLAG_CTIMEOUT: Command response timeout
+ * @arg SDIO_FLAG_DTIMEOUT: Data timeout
+ * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
+ * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error
+ * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed)
+ * @arg SDIO_FLAG_CMDSENT: Command sent (no response required)
+ * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero)
+ * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide
+ * bus mode
+ * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed)
+ * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received
+ * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61
+ * @retval None
+ */
+void SDIO_ClearFlag(uint32_t SDIO_FLAG)
+{
+ /* Check the parameters */
+ assert_param(IS_SDIO_CLEAR_FLAG(SDIO_FLAG));
+
+ SDIO->ICR = SDIO_FLAG;
+}
+
+/**
+ * @brief Checks whether the specified SDIO interrupt has occurred or not.
+ * @param SDIO_IT: specifies the SDIO interrupt source to check.
+ * This parameter can be one of the following values:
+ * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
+ * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
+ * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
+ * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
+ * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
+ * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
+ * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt
+ * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt
+ * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt
+ * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide
+ * bus mode interrupt
+ * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
+ * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt
+ * @arg SDIO_IT_TXACT: Data transmit in progress interrupt
+ * @arg SDIO_IT_RXACT: Data receive in progress interrupt
+ * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
+ * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
+ * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt
+ * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt
+ * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt
+ * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt
+ * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt
+ * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt
+ * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
+ * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt
+ * @retval The new state of SDIO_IT (SET or RESET).
+ */
+ITStatus SDIO_GetITStatus(uint32_t SDIO_IT)
+{
+ ITStatus bitstatus = RESET;
+
+ /* Check the parameters */
+ assert_param(IS_SDIO_GET_IT(SDIO_IT));
+ if ((SDIO->STA & SDIO_IT) != (uint32_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the SDIO's interrupt pending bits.
+ * @param SDIO_IT: specifies the interrupt pending bit to clear.
+ * This parameter can be one or a combination of the following values:
+ * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
+ * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
+ * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
+ * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
+ * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
+ * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
+ * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt
+ * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt
+ * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt
+ * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide
+ * bus mode interrupt
+ * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
+ * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61
+ * @retval None
+ */
+void SDIO_ClearITPendingBit(uint32_t SDIO_IT)
+{
+ /* Check the parameters */
+ assert_param(IS_SDIO_CLEAR_IT(SDIO_IT));
+
+ SDIO->ICR = SDIO_IT;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_spi.c b/st_fw_lib/src/stm32f10x_spi.c
new file mode 100644
index 0000000..4ec65b2
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_spi.c
@@ -0,0 +1,908 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_spi.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the SPI firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_spi.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup SPI
+ * @brief SPI driver modules
+ * @{
+ */
+
+/** @defgroup SPI_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @defgroup SPI_Private_Defines
+ * @{
+ */
+
+/* SPI SPE mask */
+#define CR1_SPE_Set ((uint16_t)0x0040)
+#define CR1_SPE_Reset ((uint16_t)0xFFBF)
+
+/* I2S I2SE mask */
+#define I2SCFGR_I2SE_Set ((uint16_t)0x0400)
+#define I2SCFGR_I2SE_Reset ((uint16_t)0xFBFF)
+
+/* SPI CRCNext mask */
+#define CR1_CRCNext_Set ((uint16_t)0x1000)
+
+/* SPI CRCEN mask */
+#define CR1_CRCEN_Set ((uint16_t)0x2000)
+#define CR1_CRCEN_Reset ((uint16_t)0xDFFF)
+
+/* SPI SSOE mask */
+#define CR2_SSOE_Set ((uint16_t)0x0004)
+#define CR2_SSOE_Reset ((uint16_t)0xFFFB)
+
+/* SPI registers Masks */
+#define CR1_CLEAR_Mask ((uint16_t)0x3040)
+#define I2SCFGR_CLEAR_Mask ((uint16_t)0xF040)
+
+/* SPI or I2S mode selection masks */
+#define SPI_Mode_Select ((uint16_t)0xF7FF)
+#define I2S_Mode_Select ((uint16_t)0x0800)
+
+/* I2S clock source selection masks */
+#define I2S2_CLOCK_SRC ((uint32_t)(0x00020000))
+#define I2S3_CLOCK_SRC ((uint32_t)(0x00040000))
+#define I2S_MUL_MASK ((uint32_t)(0x0000F000))
+#define I2S_DIV_MASK ((uint32_t)(0x000000F0))
+
+/**
+ * @}
+ */
+
+/** @defgroup SPI_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SPI_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SPI_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup SPI_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the SPIx peripheral registers to their default
+ * reset values (Affects also the I2Ss).
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @retval None
+ */
+void SPI_I2S_DeInit(SPI_TypeDef* SPIx)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+
+ if (SPIx == SPI1)
+ {
+ /* Enable SPI1 reset state */
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE);
+ /* Release SPI1 from reset state */
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);
+ }
+ else if (SPIx == SPI2)
+ {
+ /* Enable SPI2 reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE);
+ /* Release SPI2 from reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE);
+ }
+ else
+ {
+ if (SPIx == SPI3)
+ {
+ /* Enable SPI3 reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE);
+ /* Release SPI3 from reset state */
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, DISABLE);
+ }
+ }
+}
+
+/**
+ * @brief Initializes the SPIx peripheral according to the specified
+ * parameters in the SPI_InitStruct.
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @param SPI_InitStruct: pointer to a SPI_InitTypeDef structure that
+ * contains the configuration information for the specified SPI peripheral.
+ * @retval None
+ */
+void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct)
+{
+ uint16_t tmpreg = 0;
+
+ /* check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+
+ /* Check the SPI parameters */
+ assert_param(IS_SPI_DIRECTION_MODE(SPI_InitStruct->SPI_Direction));
+ assert_param(IS_SPI_MODE(SPI_InitStruct->SPI_Mode));
+ assert_param(IS_SPI_DATASIZE(SPI_InitStruct->SPI_DataSize));
+ assert_param(IS_SPI_CPOL(SPI_InitStruct->SPI_CPOL));
+ assert_param(IS_SPI_CPHA(SPI_InitStruct->SPI_CPHA));
+ assert_param(IS_SPI_NSS(SPI_InitStruct->SPI_NSS));
+ assert_param(IS_SPI_BAUDRATE_PRESCALER(SPI_InitStruct->SPI_BaudRatePrescaler));
+ assert_param(IS_SPI_FIRST_BIT(SPI_InitStruct->SPI_FirstBit));
+ assert_param(IS_SPI_CRC_POLYNOMIAL(SPI_InitStruct->SPI_CRCPolynomial));
+
+/*---------------------------- SPIx CR1 Configuration ------------------------*/
+ /* Get the SPIx CR1 value */
+ tmpreg = SPIx->CR1;
+ /* Clear BIDIMode, BIDIOE, RxONLY, SSM, SSI, LSBFirst, BR, MSTR, CPOL and CPHA bits */
+ tmpreg &= CR1_CLEAR_Mask;
+ /* Configure SPIx: direction, NSS management, first transmitted bit, BaudRate prescaler
+ master/salve mode, CPOL and CPHA */
+ /* Set BIDImode, BIDIOE and RxONLY bits according to SPI_Direction value */
+ /* Set SSM, SSI and MSTR bits according to SPI_Mode and SPI_NSS values */
+ /* Set LSBFirst bit according to SPI_FirstBit value */
+ /* Set BR bits according to SPI_BaudRatePrescaler value */
+ /* Set CPOL bit according to SPI_CPOL value */
+ /* Set CPHA bit according to SPI_CPHA value */
+ tmpreg |= (uint16_t)((uint32_t)SPI_InitStruct->SPI_Direction | SPI_InitStruct->SPI_Mode |
+ SPI_InitStruct->SPI_DataSize | SPI_InitStruct->SPI_CPOL |
+ SPI_InitStruct->SPI_CPHA | SPI_InitStruct->SPI_NSS |
+ SPI_InitStruct->SPI_BaudRatePrescaler | SPI_InitStruct->SPI_FirstBit);
+ /* Write to SPIx CR1 */
+ SPIx->CR1 = tmpreg;
+
+ /* Activate the SPI mode (Reset I2SMOD bit in I2SCFGR register) */
+ SPIx->I2SCFGR &= SPI_Mode_Select;
+
+/*---------------------------- SPIx CRCPOLY Configuration --------------------*/
+ /* Write to SPIx CRCPOLY */
+ SPIx->CRCPR = SPI_InitStruct->SPI_CRCPolynomial;
+}
+
+/**
+ * @brief Initializes the SPIx peripheral according to the specified
+ * parameters in the I2S_InitStruct.
+ * @param SPIx: where x can be 2 or 3 to select the SPI peripheral
+ * (configured in I2S mode).
+ * @param I2S_InitStruct: pointer to an I2S_InitTypeDef structure that
+ * contains the configuration information for the specified SPI peripheral
+ * configured in I2S mode.
+ * @note
+ * The function calculates the optimal prescaler needed to obtain the most
+ * accurate audio frequency (depending on the I2S clock source, the PLL values
+ * and the product configuration). But in case the prescaler value is greater
+ * than 511, the default value (0x02) will be configured instead. *
+ * @retval None
+ */
+void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct)
+{
+ uint16_t tmpreg = 0, i2sdiv = 2, i2sodd = 0, packetlength = 1;
+ uint32_t tmp = 0;
+ RCC_ClocksTypeDef RCC_Clocks;
+ uint32_t sourceclock = 0;
+
+ /* Check the I2S parameters */
+ assert_param(IS_SPI_23_PERIPH(SPIx));
+ assert_param(IS_I2S_MODE(I2S_InitStruct->I2S_Mode));
+ assert_param(IS_I2S_STANDARD(I2S_InitStruct->I2S_Standard));
+ assert_param(IS_I2S_DATA_FORMAT(I2S_InitStruct->I2S_DataFormat));
+ assert_param(IS_I2S_MCLK_OUTPUT(I2S_InitStruct->I2S_MCLKOutput));
+ assert_param(IS_I2S_AUDIO_FREQ(I2S_InitStruct->I2S_AudioFreq));
+ assert_param(IS_I2S_CPOL(I2S_InitStruct->I2S_CPOL));
+
+/*----------------------- SPIx I2SCFGR & I2SPR Configuration -----------------*/
+ /* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */
+ SPIx->I2SCFGR &= I2SCFGR_CLEAR_Mask;
+ SPIx->I2SPR = 0x0002;
+
+ /* Get the I2SCFGR register value */
+ tmpreg = SPIx->I2SCFGR;
+
+ /* If the default value has to be written, reinitialize i2sdiv and i2sodd*/
+ if(I2S_InitStruct->I2S_AudioFreq == I2S_AudioFreq_Default)
+ {
+ i2sodd = (uint16_t)0;
+ i2sdiv = (uint16_t)2;
+ }
+ /* If the requested audio frequency is not the default, compute the prescaler */
+ else
+ {
+ /* Check the frame length (For the Prescaler computing) */
+ if(I2S_InitStruct->I2S_DataFormat == I2S_DataFormat_16b)
+ {
+ /* Packet length is 16 bits */
+ packetlength = 1;
+ }
+ else
+ {
+ /* Packet length is 32 bits */
+ packetlength = 2;
+ }
+
+ /* Get the I2S clock source mask depending on the peripheral number */
+ if(((uint32_t)SPIx) == SPI2_BASE)
+ {
+ /* The mask is relative to I2S2 */
+ tmp = I2S2_CLOCK_SRC;
+ }
+ else
+ {
+ /* The mask is relative to I2S3 */
+ tmp = I2S3_CLOCK_SRC;
+ }
+
+ /* Check the I2S clock source configuration depending on the Device:
+ Only Connectivity line devices have the PLL3 VCO clock */
+#ifdef STM32F10X_CL
+ if((RCC->CFGR2 & tmp) != 0)
+ {
+ /* Get the configuration bits of RCC PLL3 multiplier */
+ tmp = (uint32_t)((RCC->CFGR2 & I2S_MUL_MASK) >> 12);
+
+ /* Get the value of the PLL3 multiplier */
+ if((tmp > 5) && (tmp < 15))
+ {
+ /* Multiplier is between 8 and 14 (value 15 is forbidden) */
+ tmp += 2;
+ }
+ else
+ {
+ if (tmp == 15)
+ {
+ /* Multiplier is 20 */
+ tmp = 20;
+ }
+ }
+ /* Get the PREDIV2 value */
+ sourceclock = (uint32_t)(((RCC->CFGR2 & I2S_DIV_MASK) >> 4) + 1);
+
+ /* Calculate the Source Clock frequency based on PLL3 and PREDIV2 values */
+ sourceclock = (uint32_t) ((HSE_Value / sourceclock) * tmp * 2);
+ }
+ else
+ {
+ /* I2S Clock source is System clock: Get System Clock frequency */
+ RCC_GetClocksFreq(&RCC_Clocks);
+
+ /* Get the source clock value: based on System Clock value */
+ sourceclock = RCC_Clocks.SYSCLK_Frequency;
+ }
+#else /* STM32F10X_HD */
+ /* I2S Clock source is System clock: Get System Clock frequency */
+ RCC_GetClocksFreq(&RCC_Clocks);
+
+ /* Get the source clock value: based on System Clock value */
+ sourceclock = RCC_Clocks.SYSCLK_Frequency;
+#endif /* STM32F10X_CL */
+
+ /* Compute the Real divider depending on the MCLK output state with a floating point */
+ if(I2S_InitStruct->I2S_MCLKOutput == I2S_MCLKOutput_Enable)
+ {
+ /* MCLK output is enabled */
+ tmp = (uint16_t)(((((sourceclock / 256) * 10) / I2S_InitStruct->I2S_AudioFreq)) + 5);
+ }
+ else
+ {
+ /* MCLK output is disabled */
+ tmp = (uint16_t)(((((sourceclock / (32 * packetlength)) *10 ) / I2S_InitStruct->I2S_AudioFreq)) + 5);
+ }
+
+ /* Remove the floating point */
+ tmp = tmp / 10;
+
+ /* Check the parity of the divider */
+ i2sodd = (uint16_t)(tmp & (uint16_t)0x0001);
+
+ /* Compute the i2sdiv prescaler */
+ i2sdiv = (uint16_t)((tmp - i2sodd) / 2);
+
+ /* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */
+ i2sodd = (uint16_t) (i2sodd << 8);
+ }
+
+ /* Test if the divider is 1 or 0 or greater than 0xFF */
+ if ((i2sdiv < 2) || (i2sdiv > 0xFF))
+ {
+ /* Set the default values */
+ i2sdiv = 2;
+ i2sodd = 0;
+ }
+
+ /* Write to SPIx I2SPR register the computed value */
+ SPIx->I2SPR = (uint16_t)(i2sdiv | (uint16_t)(i2sodd | (uint16_t)I2S_InitStruct->I2S_MCLKOutput));
+
+ /* Configure the I2S with the SPI_InitStruct values */
+ tmpreg |= (uint16_t)(I2S_Mode_Select | (uint16_t)(I2S_InitStruct->I2S_Mode | \
+ (uint16_t)(I2S_InitStruct->I2S_Standard | (uint16_t)(I2S_InitStruct->I2S_DataFormat | \
+ (uint16_t)I2S_InitStruct->I2S_CPOL))));
+
+ /* Write to SPIx I2SCFGR */
+ SPIx->I2SCFGR = tmpreg;
+}
+
+/**
+ * @brief Fills each SPI_InitStruct member with its default value.
+ * @param SPI_InitStruct : pointer to a SPI_InitTypeDef structure which will be initialized.
+ * @retval None
+ */
+void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct)
+{
+/*--------------- Reset SPI init structure parameters values -----------------*/
+ /* Initialize the SPI_Direction member */
+ SPI_InitStruct->SPI_Direction = SPI_Direction_2Lines_FullDuplex;
+ /* initialize the SPI_Mode member */
+ SPI_InitStruct->SPI_Mode = SPI_Mode_Slave;
+ /* initialize the SPI_DataSize member */
+ SPI_InitStruct->SPI_DataSize = SPI_DataSize_8b;
+ /* Initialize the SPI_CPOL member */
+ SPI_InitStruct->SPI_CPOL = SPI_CPOL_Low;
+ /* Initialize the SPI_CPHA member */
+ SPI_InitStruct->SPI_CPHA = SPI_CPHA_1Edge;
+ /* Initialize the SPI_NSS member */
+ SPI_InitStruct->SPI_NSS = SPI_NSS_Hard;
+ /* Initialize the SPI_BaudRatePrescaler member */
+ SPI_InitStruct->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
+ /* Initialize the SPI_FirstBit member */
+ SPI_InitStruct->SPI_FirstBit = SPI_FirstBit_MSB;
+ /* Initialize the SPI_CRCPolynomial member */
+ SPI_InitStruct->SPI_CRCPolynomial = 7;
+}
+
+/**
+ * @brief Fills each I2S_InitStruct member with its default value.
+ * @param I2S_InitStruct : pointer to a I2S_InitTypeDef structure which will be initialized.
+ * @retval None
+ */
+void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct)
+{
+/*--------------- Reset I2S init structure parameters values -----------------*/
+ /* Initialize the I2S_Mode member */
+ I2S_InitStruct->I2S_Mode = I2S_Mode_SlaveTx;
+
+ /* Initialize the I2S_Standard member */
+ I2S_InitStruct->I2S_Standard = I2S_Standard_Phillips;
+
+ /* Initialize the I2S_DataFormat member */
+ I2S_InitStruct->I2S_DataFormat = I2S_DataFormat_16b;
+
+ /* Initialize the I2S_MCLKOutput member */
+ I2S_InitStruct->I2S_MCLKOutput = I2S_MCLKOutput_Disable;
+
+ /* Initialize the I2S_AudioFreq member */
+ I2S_InitStruct->I2S_AudioFreq = I2S_AudioFreq_Default;
+
+ /* Initialize the I2S_CPOL member */
+ I2S_InitStruct->I2S_CPOL = I2S_CPOL_Low;
+}
+
+/**
+ * @brief Enables or disables the specified SPI peripheral.
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @param NewState: new state of the SPIx peripheral.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected SPI peripheral */
+ SPIx->CR1 |= CR1_SPE_Set;
+ }
+ else
+ {
+ /* Disable the selected SPI peripheral */
+ SPIx->CR1 &= CR1_SPE_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified SPI peripheral (in I2S mode).
+ * @param SPIx: where x can be 2 or 3 to select the SPI peripheral.
+ * @param NewState: new state of the SPIx peripheral.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_23_PERIPH(SPIx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected SPI peripheral (in I2S mode) */
+ SPIx->I2SCFGR |= I2SCFGR_I2SE_Set;
+ }
+ else
+ {
+ /* Disable the selected SPI peripheral (in I2S mode) */
+ SPIx->I2SCFGR &= I2SCFGR_I2SE_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified SPI/I2S interrupts.
+ * @param SPIx: where x can be
+ * - 1, 2 or 3 in SPI mode
+ * - 2 or 3 in I2S mode
+ * @param SPI_I2S_IT: specifies the SPI/I2S interrupt source to be enabled or disabled.
+ * This parameter can be one of the following values:
+ * @arg SPI_I2S_IT_TXE: Tx buffer empty interrupt mask
+ * @arg SPI_I2S_IT_RXNE: Rx buffer not empty interrupt mask
+ * @arg SPI_I2S_IT_ERR: Error interrupt mask
+ * @param NewState: new state of the specified SPI/I2S interrupt.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState)
+{
+ uint16_t itpos = 0, itmask = 0 ;
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ assert_param(IS_SPI_I2S_CONFIG_IT(SPI_I2S_IT));
+
+ /* Get the SPI/I2S IT index */
+ itpos = SPI_I2S_IT >> 4;
+
+ /* Set the IT mask */
+ itmask = (uint16_t)1 << (uint16_t)itpos;
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected SPI/I2S interrupt */
+ SPIx->CR2 |= itmask;
+ }
+ else
+ {
+ /* Disable the selected SPI/I2S interrupt */
+ SPIx->CR2 &= (uint16_t)~itmask;
+ }
+}
+
+/**
+ * @brief Enables or disables the SPIx/I2Sx DMA interface.
+ * @param SPIx: where x can be
+ * - 1, 2 or 3 in SPI mode
+ * - 2 or 3 in I2S mode
+ * @param SPI_I2S_DMAReq: specifies the SPI/I2S DMA transfer request to be enabled or disabled.
+ * This parameter can be any combination of the following values:
+ * @arg SPI_I2S_DMAReq_Tx: Tx buffer DMA transfer request
+ * @arg SPI_I2S_DMAReq_Rx: Rx buffer DMA transfer request
+ * @param NewState: new state of the selected SPI/I2S DMA transfer request.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ assert_param(IS_SPI_I2S_DMAREQ(SPI_I2S_DMAReq));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected SPI/I2S DMA requests */
+ SPIx->CR2 |= SPI_I2S_DMAReq;
+ }
+ else
+ {
+ /* Disable the selected SPI/I2S DMA requests */
+ SPIx->CR2 &= (uint16_t)~SPI_I2S_DMAReq;
+ }
+}
+
+/**
+ * @brief Transmits a Data through the SPIx/I2Sx peripheral.
+ * @param SPIx: where x can be
+ * - 1, 2 or 3 in SPI mode
+ * - 2 or 3 in I2S mode
+ * @param Data : Data to be transmitted.
+ * @retval None
+ */
+void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+
+ /* Write in the DR register the data to be sent */
+ SPIx->DR = Data;
+}
+
+/**
+ * @brief Returns the most recent received data by the SPIx/I2Sx peripheral.
+ * @param SPIx: where x can be
+ * - 1, 2 or 3 in SPI mode
+ * - 2 or 3 in I2S mode
+ * @retval The value of the received data.
+ */
+uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+
+ /* Return the data in the DR register */
+ return SPIx->DR;
+}
+
+/**
+ * @brief Configures internally by software the NSS pin for the selected SPI.
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @param SPI_NSSInternalSoft: specifies the SPI NSS internal state.
+ * This parameter can be one of the following values:
+ * @arg SPI_NSSInternalSoft_Set: Set NSS pin internally
+ * @arg SPI_NSSInternalSoft_Reset: Reset NSS pin internally
+ * @retval None
+ */
+void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_SPI_NSS_INTERNAL(SPI_NSSInternalSoft));
+ if (SPI_NSSInternalSoft != SPI_NSSInternalSoft_Reset)
+ {
+ /* Set NSS pin internally by software */
+ SPIx->CR1 |= SPI_NSSInternalSoft_Set;
+ }
+ else
+ {
+ /* Reset NSS pin internally by software */
+ SPIx->CR1 &= SPI_NSSInternalSoft_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the SS output for the selected SPI.
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @param NewState: new state of the SPIx SS output.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected SPI SS output */
+ SPIx->CR2 |= CR2_SSOE_Set;
+ }
+ else
+ {
+ /* Disable the selected SPI SS output */
+ SPIx->CR2 &= CR2_SSOE_Reset;
+ }
+}
+
+/**
+ * @brief Configures the data size for the selected SPI.
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @param SPI_DataSize: specifies the SPI data size.
+ * This parameter can be one of the following values:
+ * @arg SPI_DataSize_16b: Set data frame format to 16bit
+ * @arg SPI_DataSize_8b: Set data frame format to 8bit
+ * @retval None
+ */
+void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_SPI_DATASIZE(SPI_DataSize));
+ /* Clear DFF bit */
+ SPIx->CR1 &= (uint16_t)~SPI_DataSize_16b;
+ /* Set new DFF bit value */
+ SPIx->CR1 |= SPI_DataSize;
+}
+
+/**
+ * @brief Transmit the SPIx CRC value.
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @retval None
+ */
+void SPI_TransmitCRC(SPI_TypeDef* SPIx)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+
+ /* Enable the selected SPI CRC transmission */
+ SPIx->CR1 |= CR1_CRCNext_Set;
+}
+
+/**
+ * @brief Enables or disables the CRC value calculation of the transferred bytes.
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @param NewState: new state of the SPIx CRC value calculation.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected SPI CRC calculation */
+ SPIx->CR1 |= CR1_CRCEN_Set;
+ }
+ else
+ {
+ /* Disable the selected SPI CRC calculation */
+ SPIx->CR1 &= CR1_CRCEN_Reset;
+ }
+}
+
+/**
+ * @brief Returns the transmit or the receive CRC register value for the specified SPI.
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @param SPI_CRC: specifies the CRC register to be read.
+ * This parameter can be one of the following values:
+ * @arg SPI_CRC_Tx: Selects Tx CRC register
+ * @arg SPI_CRC_Rx: Selects Rx CRC register
+ * @retval The selected CRC register value..
+ */
+uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC)
+{
+ uint16_t crcreg = 0;
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_SPI_CRC(SPI_CRC));
+ if (SPI_CRC != SPI_CRC_Rx)
+ {
+ /* Get the Tx CRC register */
+ crcreg = SPIx->TXCRCR;
+ }
+ else
+ {
+ /* Get the Rx CRC register */
+ crcreg = SPIx->RXCRCR;
+ }
+ /* Return the selected CRC register */
+ return crcreg;
+}
+
+/**
+ * @brief Returns the CRC Polynomial register value for the specified SPI.
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @retval The CRC Polynomial register value.
+ */
+uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+
+ /* Return the CRC polynomial register */
+ return SPIx->CRCPR;
+}
+
+/**
+ * @brief Selects the data transfer direction in bi-directional mode for the specified SPI.
+ * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral.
+ * @param SPI_Direction: specifies the data transfer direction in bi-directional mode.
+ * This parameter can be one of the following values:
+ * @arg SPI_Direction_Tx: Selects Tx transmission direction
+ * @arg SPI_Direction_Rx: Selects Rx receive direction
+ * @retval None
+ */
+void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_SPI_DIRECTION(SPI_Direction));
+ if (SPI_Direction == SPI_Direction_Tx)
+ {
+ /* Set the Tx only mode */
+ SPIx->CR1 |= SPI_Direction_Tx;
+ }
+ else
+ {
+ /* Set the Rx only mode */
+ SPIx->CR1 &= SPI_Direction_Rx;
+ }
+}
+
+/**
+ * @brief Checks whether the specified SPI/I2S flag is set or not.
+ * @param SPIx: where x can be
+ * - 1, 2 or 3 in SPI mode
+ * - 2 or 3 in I2S mode
+ * @param SPI_I2S_FLAG: specifies the SPI/I2S flag to check.
+ * This parameter can be one of the following values:
+ * @arg SPI_I2S_FLAG_TXE: Transmit buffer empty flag.
+ * @arg SPI_I2S_FLAG_RXNE: Receive buffer not empty flag.
+ * @arg SPI_I2S_FLAG_BSY: Busy flag.
+ * @arg SPI_I2S_FLAG_OVR: Overrun flag.
+ * @arg SPI_FLAG_MODF: Mode Fault flag.
+ * @arg SPI_FLAG_CRCERR: CRC Error flag.
+ * @arg I2S_FLAG_UDR: Underrun Error flag.
+ * @arg I2S_FLAG_CHSIDE: Channel Side flag.
+ * @retval The new state of SPI_I2S_FLAG (SET or RESET).
+ */
+FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_SPI_I2S_GET_FLAG(SPI_I2S_FLAG));
+ /* Check the status of the specified SPI/I2S flag */
+ if ((SPIx->SR & SPI_I2S_FLAG) != (uint16_t)RESET)
+ {
+ /* SPI_I2S_FLAG is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* SPI_I2S_FLAG is reset */
+ bitstatus = RESET;
+ }
+ /* Return the SPI_I2S_FLAG status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the SPIx CRC Error (CRCERR) flag.
+ * @param SPIx: where x can be
+ * - 1, 2 or 3 in SPI mode
+ * @param SPI_I2S_FLAG: specifies the SPI flag to clear.
+ * This function clears only CRCERR flag.
+ * @note
+ * - OVR (OverRun error) flag is cleared by software sequence: a read
+ * operation to SPI_DR register (SPI_I2S_ReceiveData()) followed by a read
+ * operation to SPI_SR register (SPI_I2S_GetFlagStatus()).
+ * - UDR (UnderRun error) flag is cleared by a read operation to
+ * SPI_SR register (SPI_I2S_GetFlagStatus()).
+ * - MODF (Mode Fault) flag is cleared by software sequence: a read/write
+ * operation to SPI_SR register (SPI_I2S_GetFlagStatus()) followed by a
+ * write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
+ * @retval None
+ */
+void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG)
+{
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_SPI_I2S_CLEAR_FLAG(SPI_I2S_FLAG));
+
+ /* Clear the selected SPI CRC Error (CRCERR) flag */
+ SPIx->SR = (uint16_t)~SPI_I2S_FLAG;
+}
+
+/**
+ * @brief Checks whether the specified SPI/I2S interrupt has occurred or not.
+ * @param SPIx: where x can be
+ * - 1, 2 or 3 in SPI mode
+ * - 2 or 3 in I2S mode
+ * @param SPI_I2S_IT: specifies the SPI/I2S interrupt source to check.
+ * This parameter can be one of the following values:
+ * @arg SPI_I2S_IT_TXE: Transmit buffer empty interrupt.
+ * @arg SPI_I2S_IT_RXNE: Receive buffer not empty interrupt.
+ * @arg SPI_I2S_IT_OVR: Overrun interrupt.
+ * @arg SPI_IT_MODF: Mode Fault interrupt.
+ * @arg SPI_IT_CRCERR: CRC Error interrupt.
+ * @arg I2S_IT_UDR: Underrun Error interrupt.
+ * @retval The new state of SPI_I2S_IT (SET or RESET).
+ */
+ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT)
+{
+ ITStatus bitstatus = RESET;
+ uint16_t itpos = 0, itmask = 0, enablestatus = 0;
+
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_SPI_I2S_GET_IT(SPI_I2S_IT));
+
+ /* Get the SPI/I2S IT index */
+ itpos = 0x01 << (SPI_I2S_IT & 0x0F);
+
+ /* Get the SPI/I2S IT mask */
+ itmask = SPI_I2S_IT >> 4;
+
+ /* Set the IT mask */
+ itmask = 0x01 << itmask;
+
+ /* Get the SPI_I2S_IT enable bit status */
+ enablestatus = (SPIx->CR2 & itmask) ;
+
+ /* Check the status of the specified SPI/I2S interrupt */
+ if (((SPIx->SR & itpos) != (uint16_t)RESET) && enablestatus)
+ {
+ /* SPI_I2S_IT is set */
+ bitstatus = SET;
+ }
+ else
+ {
+ /* SPI_I2S_IT is reset */
+ bitstatus = RESET;
+ }
+ /* Return the SPI_I2S_IT status */
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the SPIx CRC Error (CRCERR) interrupt pending bit.
+ * @param SPIx: where x can be
+ * - 1, 2 or 3 in SPI mode
+ * @param SPI_I2S_IT: specifies the SPI interrupt pending bit to clear.
+ * This function clears only CRCERR interrupt pending bit.
+ * @note
+ * - OVR (OverRun Error) interrupt pending bit is cleared by software
+ * sequence: a read operation to SPI_DR register (SPI_I2S_ReceiveData())
+ * followed by a read operation to SPI_SR register (SPI_I2S_GetITStatus()).
+ * - UDR (UnderRun Error) interrupt pending bit is cleared by a read
+ * operation to SPI_SR register (SPI_I2S_GetITStatus()).
+ * - MODF (Mode Fault) interrupt pending bit is cleared by software sequence:
+ * a read/write operation to SPI_SR register (SPI_I2S_GetITStatus())
+ * followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable
+ * the SPI).
+ * @retval None
+ */
+void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT)
+{
+ uint16_t itpos = 0;
+ /* Check the parameters */
+ assert_param(IS_SPI_ALL_PERIPH(SPIx));
+ assert_param(IS_SPI_I2S_CLEAR_IT(SPI_I2S_IT));
+
+ /* Get the SPI IT index */
+ itpos = 0x01 << (SPI_I2S_IT & 0x0F);
+
+ /* Clear the selected SPI CRC Error (CRCERR) interrupt pending bit */
+ SPIx->SR = (uint16_t)~itpos;
+}
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_tim.c b/st_fw_lib/src/stm32f10x_tim.c
new file mode 100644
index 0000000..bfb4dd1
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_tim.c
@@ -0,0 +1,2890 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_tim.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the TIM firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_tim.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup TIM
+ * @brief TIM driver modules
+ * @{
+ */
+
+/** @defgroup TIM_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Private_Defines
+ * @{
+ */
+
+/* ---------------------- TIM registers bit mask ------------------------ */
+#define SMCR_ETR_Mask ((uint16_t)0x00FF)
+#define CCMR_Offset ((uint16_t)0x0018)
+#define CCER_CCE_Set ((uint16_t)0x0001)
+#define CCER_CCNE_Set ((uint16_t)0x0004)
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Private_FunctionPrototypes
+ * @{
+ */
+
+static void TI1_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
+ uint16_t TIM_ICFilter);
+static void TI2_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
+ uint16_t TIM_ICFilter);
+static void TI3_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
+ uint16_t TIM_ICFilter);
+static void TI4_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
+ uint16_t TIM_ICFilter);
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup TIM_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the TIMx peripheral registers to their default reset values.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @retval None
+ */
+void TIM_DeInit(TIM_TypeDef* TIMx)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+
+ if (TIMx == TIM1)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM1, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM1, DISABLE);
+ }
+ else if (TIMx == TIM2)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, DISABLE);
+ }
+ else if (TIMx == TIM3)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3, DISABLE);
+ }
+ else if (TIMx == TIM4)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM4, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM4, DISABLE);
+ }
+ else if (TIMx == TIM5)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM5, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM5, DISABLE);
+ }
+ else if (TIMx == TIM6)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM6, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM6, DISABLE);
+ }
+ else if (TIMx == TIM7)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM7, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM7, DISABLE);
+ }
+ else if (TIMx == TIM8)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, DISABLE);
+ }
+ else if (TIMx == TIM9)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM9, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM9, DISABLE);
+ }
+ else if (TIMx == TIM10)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM10, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM10, DISABLE);
+ }
+ else if (TIMx == TIM11)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM11, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM11, DISABLE);
+ }
+ else if (TIMx == TIM12)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM12, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM12, DISABLE);
+ }
+ else if (TIMx == TIM13)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM13, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM13, DISABLE);
+ }
+ else if (TIMx == TIM14)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM14, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM14, DISABLE);
+ }
+ else if (TIMx == TIM15)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM15, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM15, DISABLE);
+ }
+ else if (TIMx == TIM16)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, DISABLE);
+ }
+ else
+ {
+ if (TIMx == TIM17)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM17, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM17, DISABLE);
+ }
+ }
+}
+
+/**
+ * @brief Initializes the TIMx Time Base Unit peripheral according to
+ * the specified parameters in the TIM_TimeBaseInitStruct.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param TIM_TimeBaseInitStruct: pointer to a TIM_TimeBaseInitTypeDef
+ * structure that contains the configuration information for the
+ * specified TIM peripheral.
+ * @retval None
+ */
+void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct)
+{
+ uint16_t tmpcr1 = 0;
+
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_TIM_COUNTER_MODE(TIM_TimeBaseInitStruct->TIM_CounterMode));
+ assert_param(IS_TIM_CKD_DIV(TIM_TimeBaseInitStruct->TIM_ClockDivision));
+
+ tmpcr1 = TIMx->CR1;
+
+ if((TIMx == TIM1) || (TIMx == TIM8)|| (TIMx == TIM2) || (TIMx == TIM3)||
+ (TIMx == TIM4) || (TIMx == TIM5))
+ {
+ /* Select the Counter Mode */
+ tmpcr1 &= (uint16_t)(~((uint16_t)(TIM_CR1_DIR | TIM_CR1_CMS)));
+ tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_CounterMode;
+ }
+
+ if((TIMx != TIM6) && (TIMx != TIM7))
+ {
+ /* Set the clock division */
+ tmpcr1 &= (uint16_t)(~((uint16_t)TIM_CR1_CKD));
+ tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_ClockDivision;
+ }
+
+ TIMx->CR1 = tmpcr1;
+
+ /* Set the Autoreload value */
+ TIMx->ARR = TIM_TimeBaseInitStruct->TIM_Period ;
+
+ /* Set the Prescaler value */
+ TIMx->PSC = TIM_TimeBaseInitStruct->TIM_Prescaler;
+
+ if ((TIMx == TIM1) || (TIMx == TIM8)|| (TIMx == TIM15)|| (TIMx == TIM16) || (TIMx == TIM17))
+ {
+ /* Set the Repetition Counter value */
+ TIMx->RCR = TIM_TimeBaseInitStruct->TIM_RepetitionCounter;
+ }
+
+ /* Generate an update event to reload the Prescaler and the Repetition counter
+ values immediately */
+ TIMx->EGR = TIM_PSCReloadMode_Immediate;
+}
+
+/**
+ * @brief Initializes the TIMx Channel1 according to the specified
+ * parameters in the TIM_OCInitStruct.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure
+ * that contains the configuration information for the specified TIM peripheral.
+ * @retval None
+ */
+void TIM_OC1Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct)
+{
+ uint16_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0;
+
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode));
+ assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState));
+ assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity));
+ /* Disable the Channel 1: Reset the CC1E Bit */
+ TIMx->CCER &= (uint16_t)(~(uint16_t)TIM_CCER_CC1E);
+ /* Get the TIMx CCER register value */
+ tmpccer = TIMx->CCER;
+ /* Get the TIMx CR2 register value */
+ tmpcr2 = TIMx->CR2;
+
+ /* Get the TIMx CCMR1 register value */
+ tmpccmrx = TIMx->CCMR1;
+
+ /* Reset the Output Compare Mode Bits */
+ tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR1_OC1M));
+ tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR1_CC1S));
+
+ /* Select the Output Compare Mode */
+ tmpccmrx |= TIM_OCInitStruct->TIM_OCMode;
+
+ /* Reset the Output Polarity level */
+ tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC1P));
+ /* Set the Output Compare Polarity */
+ tmpccer |= TIM_OCInitStruct->TIM_OCPolarity;
+
+ /* Set the Output State */
+ tmpccer |= TIM_OCInitStruct->TIM_OutputState;
+
+ if((TIMx == TIM1) || (TIMx == TIM8)|| (TIMx == TIM15)||
+ (TIMx == TIM16)|| (TIMx == TIM17))
+ {
+ assert_param(IS_TIM_OUTPUTN_STATE(TIM_OCInitStruct->TIM_OutputNState));
+ assert_param(IS_TIM_OCN_POLARITY(TIM_OCInitStruct->TIM_OCNPolarity));
+ assert_param(IS_TIM_OCNIDLE_STATE(TIM_OCInitStruct->TIM_OCNIdleState));
+ assert_param(IS_TIM_OCIDLE_STATE(TIM_OCInitStruct->TIM_OCIdleState));
+
+ /* Reset the Output N Polarity level */
+ tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC1NP));
+ /* Set the Output N Polarity */
+ tmpccer |= TIM_OCInitStruct->TIM_OCNPolarity;
+
+ /* Reset the Output N State */
+ tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC1NE));
+ /* Set the Output N State */
+ tmpccer |= TIM_OCInitStruct->TIM_OutputNState;
+
+ /* Reset the Output Compare and Output Compare N IDLE State */
+ tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS1));
+ tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS1N));
+
+ /* Set the Output Idle state */
+ tmpcr2 |= TIM_OCInitStruct->TIM_OCIdleState;
+ /* Set the Output N Idle state */
+ tmpcr2 |= TIM_OCInitStruct->TIM_OCNIdleState;
+ }
+ /* Write to TIMx CR2 */
+ TIMx->CR2 = tmpcr2;
+
+ /* Write to TIMx CCMR1 */
+ TIMx->CCMR1 = tmpccmrx;
+
+ /* Set the Capture Compare Register value */
+ TIMx->CCR1 = TIM_OCInitStruct->TIM_Pulse;
+
+ /* Write to TIMx CCER */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Initializes the TIMx Channel2 according to the specified
+ * parameters in the TIM_OCInitStruct.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select
+ * the TIM peripheral.
+ * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure
+ * that contains the configuration information for the specified TIM peripheral.
+ * @retval None
+ */
+void TIM_OC2Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct)
+{
+ uint16_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0;
+
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode));
+ assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState));
+ assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity));
+ /* Disable the Channel 2: Reset the CC2E Bit */
+ TIMx->CCER &= (uint16_t)(~((uint16_t)TIM_CCER_CC2E));
+
+ /* Get the TIMx CCER register value */
+ tmpccer = TIMx->CCER;
+ /* Get the TIMx CR2 register value */
+ tmpcr2 = TIMx->CR2;
+
+ /* Get the TIMx CCMR1 register value */
+ tmpccmrx = TIMx->CCMR1;
+
+ /* Reset the Output Compare mode and Capture/Compare selection Bits */
+ tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR1_OC2M));
+ tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR1_CC2S));
+
+ /* Select the Output Compare Mode */
+ tmpccmrx |= (uint16_t)(TIM_OCInitStruct->TIM_OCMode << 8);
+
+ /* Reset the Output Polarity level */
+ tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC2P));
+ /* Set the Output Compare Polarity */
+ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OCPolarity << 4);
+
+ /* Set the Output State */
+ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputState << 4);
+
+ if((TIMx == TIM1) || (TIMx == TIM8))
+ {
+ assert_param(IS_TIM_OUTPUTN_STATE(TIM_OCInitStruct->TIM_OutputNState));
+ assert_param(IS_TIM_OCN_POLARITY(TIM_OCInitStruct->TIM_OCNPolarity));
+ assert_param(IS_TIM_OCNIDLE_STATE(TIM_OCInitStruct->TIM_OCNIdleState));
+ assert_param(IS_TIM_OCIDLE_STATE(TIM_OCInitStruct->TIM_OCIdleState));
+
+ /* Reset the Output N Polarity level */
+ tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC2NP));
+ /* Set the Output N Polarity */
+ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OCNPolarity << 4);
+
+ /* Reset the Output N State */
+ tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC2NE));
+ /* Set the Output N State */
+ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputNState << 4);
+
+ /* Reset the Output Compare and Output Compare N IDLE State */
+ tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS2));
+ tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS2N));
+
+ /* Set the Output Idle state */
+ tmpcr2 |= (uint16_t)(TIM_OCInitStruct->TIM_OCIdleState << 2);
+ /* Set the Output N Idle state */
+ tmpcr2 |= (uint16_t)(TIM_OCInitStruct->TIM_OCNIdleState << 2);
+ }
+ /* Write to TIMx CR2 */
+ TIMx->CR2 = tmpcr2;
+
+ /* Write to TIMx CCMR1 */
+ TIMx->CCMR1 = tmpccmrx;
+
+ /* Set the Capture Compare Register value */
+ TIMx->CCR2 = TIM_OCInitStruct->TIM_Pulse;
+
+ /* Write to TIMx CCER */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Initializes the TIMx Channel3 according to the specified
+ * parameters in the TIM_OCInitStruct.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure
+ * that contains the configuration information for the specified TIM peripheral.
+ * @retval None
+ */
+void TIM_OC3Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct)
+{
+ uint16_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0;
+
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode));
+ assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState));
+ assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity));
+ /* Disable the Channel 2: Reset the CC2E Bit */
+ TIMx->CCER &= (uint16_t)(~((uint16_t)TIM_CCER_CC3E));
+
+ /* Get the TIMx CCER register value */
+ tmpccer = TIMx->CCER;
+ /* Get the TIMx CR2 register value */
+ tmpcr2 = TIMx->CR2;
+
+ /* Get the TIMx CCMR2 register value */
+ tmpccmrx = TIMx->CCMR2;
+
+ /* Reset the Output Compare mode and Capture/Compare selection Bits */
+ tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR2_OC3M));
+ tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR2_CC3S));
+ /* Select the Output Compare Mode */
+ tmpccmrx |= TIM_OCInitStruct->TIM_OCMode;
+
+ /* Reset the Output Polarity level */
+ tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC3P));
+ /* Set the Output Compare Polarity */
+ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OCPolarity << 8);
+
+ /* Set the Output State */
+ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputState << 8);
+
+ if((TIMx == TIM1) || (TIMx == TIM8))
+ {
+ assert_param(IS_TIM_OUTPUTN_STATE(TIM_OCInitStruct->TIM_OutputNState));
+ assert_param(IS_TIM_OCN_POLARITY(TIM_OCInitStruct->TIM_OCNPolarity));
+ assert_param(IS_TIM_OCNIDLE_STATE(TIM_OCInitStruct->TIM_OCNIdleState));
+ assert_param(IS_TIM_OCIDLE_STATE(TIM_OCInitStruct->TIM_OCIdleState));
+
+ /* Reset the Output N Polarity level */
+ tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC3NP));
+ /* Set the Output N Polarity */
+ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OCNPolarity << 8);
+ /* Reset the Output N State */
+ tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC3NE));
+
+ /* Set the Output N State */
+ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputNState << 8);
+ /* Reset the Output Compare and Output Compare N IDLE State */
+ tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS3));
+ tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS3N));
+ /* Set the Output Idle state */
+ tmpcr2 |= (uint16_t)(TIM_OCInitStruct->TIM_OCIdleState << 4);
+ /* Set the Output N Idle state */
+ tmpcr2 |= (uint16_t)(TIM_OCInitStruct->TIM_OCNIdleState << 4);
+ }
+ /* Write to TIMx CR2 */
+ TIMx->CR2 = tmpcr2;
+
+ /* Write to TIMx CCMR2 */
+ TIMx->CCMR2 = tmpccmrx;
+
+ /* Set the Capture Compare Register value */
+ TIMx->CCR3 = TIM_OCInitStruct->TIM_Pulse;
+
+ /* Write to TIMx CCER */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Initializes the TIMx Channel4 according to the specified
+ * parameters in the TIM_OCInitStruct.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure
+ * that contains the configuration information for the specified TIM peripheral.
+ * @retval None
+ */
+void TIM_OC4Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct)
+{
+ uint16_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0;
+
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode));
+ assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState));
+ assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity));
+ /* Disable the Channel 2: Reset the CC4E Bit */
+ TIMx->CCER &= (uint16_t)(~((uint16_t)TIM_CCER_CC4E));
+
+ /* Get the TIMx CCER register value */
+ tmpccer = TIMx->CCER;
+ /* Get the TIMx CR2 register value */
+ tmpcr2 = TIMx->CR2;
+
+ /* Get the TIMx CCMR2 register value */
+ tmpccmrx = TIMx->CCMR2;
+
+ /* Reset the Output Compare mode and Capture/Compare selection Bits */
+ tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR2_OC4M));
+ tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR2_CC4S));
+
+ /* Select the Output Compare Mode */
+ tmpccmrx |= (uint16_t)(TIM_OCInitStruct->TIM_OCMode << 8);
+
+ /* Reset the Output Polarity level */
+ tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC4P));
+ /* Set the Output Compare Polarity */
+ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OCPolarity << 12);
+
+ /* Set the Output State */
+ tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputState << 12);
+
+ if((TIMx == TIM1) || (TIMx == TIM8))
+ {
+ assert_param(IS_TIM_OCIDLE_STATE(TIM_OCInitStruct->TIM_OCIdleState));
+ /* Reset the Output Compare IDLE State */
+ tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS4));
+ /* Set the Output Idle state */
+ tmpcr2 |= (uint16_t)(TIM_OCInitStruct->TIM_OCIdleState << 6);
+ }
+ /* Write to TIMx CR2 */
+ TIMx->CR2 = tmpcr2;
+
+ /* Write to TIMx CCMR2 */
+ TIMx->CCMR2 = tmpccmrx;
+
+ /* Set the Capture Compare Register value */
+ TIMx->CCR4 = TIM_OCInitStruct->TIM_Pulse;
+
+ /* Write to TIMx CCER */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Initializes the TIM peripheral according to the specified
+ * parameters in the TIM_ICInitStruct.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param TIM_ICInitStruct: pointer to a TIM_ICInitTypeDef structure
+ * that contains the configuration information for the specified TIM peripheral.
+ * @retval None
+ */
+void TIM_ICInit(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_CHANNEL(TIM_ICInitStruct->TIM_Channel));
+ assert_param(IS_TIM_IC_SELECTION(TIM_ICInitStruct->TIM_ICSelection));
+ assert_param(IS_TIM_IC_PRESCALER(TIM_ICInitStruct->TIM_ICPrescaler));
+ assert_param(IS_TIM_IC_FILTER(TIM_ICInitStruct->TIM_ICFilter));
+
+ if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) ||
+ (TIMx == TIM4) ||(TIMx == TIM5))
+ {
+ assert_param(IS_TIM_IC_POLARITY(TIM_ICInitStruct->TIM_ICPolarity));
+ }
+ else
+ {
+ assert_param(IS_TIM_IC_POLARITY_LITE(TIM_ICInitStruct->TIM_ICPolarity));
+ }
+ if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_1)
+ {
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ /* TI1 Configuration */
+ TI1_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
+ TIM_ICInitStruct->TIM_ICSelection,
+ TIM_ICInitStruct->TIM_ICFilter);
+ /* Set the Input Capture Prescaler value */
+ TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
+ }
+ else if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_2)
+ {
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ /* TI2 Configuration */
+ TI2_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
+ TIM_ICInitStruct->TIM_ICSelection,
+ TIM_ICInitStruct->TIM_ICFilter);
+ /* Set the Input Capture Prescaler value */
+ TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
+ }
+ else if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_3)
+ {
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ /* TI3 Configuration */
+ TI3_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
+ TIM_ICInitStruct->TIM_ICSelection,
+ TIM_ICInitStruct->TIM_ICFilter);
+ /* Set the Input Capture Prescaler value */
+ TIM_SetIC3Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
+ }
+ else
+ {
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ /* TI4 Configuration */
+ TI4_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity,
+ TIM_ICInitStruct->TIM_ICSelection,
+ TIM_ICInitStruct->TIM_ICFilter);
+ /* Set the Input Capture Prescaler value */
+ TIM_SetIC4Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
+ }
+}
+
+/**
+ * @brief Configures the TIM peripheral according to the specified
+ * parameters in the TIM_ICInitStruct to measure an external PWM signal.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_ICInitStruct: pointer to a TIM_ICInitTypeDef structure
+ * that contains the configuration information for the specified TIM peripheral.
+ * @retval None
+ */
+void TIM_PWMIConfig(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct)
+{
+ uint16_t icoppositepolarity = TIM_ICPolarity_Rising;
+ uint16_t icoppositeselection = TIM_ICSelection_DirectTI;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ /* Select the Opposite Input Polarity */
+ if (TIM_ICInitStruct->TIM_ICPolarity == TIM_ICPolarity_Rising)
+ {
+ icoppositepolarity = TIM_ICPolarity_Falling;
+ }
+ else
+ {
+ icoppositepolarity = TIM_ICPolarity_Rising;
+ }
+ /* Select the Opposite Input */
+ if (TIM_ICInitStruct->TIM_ICSelection == TIM_ICSelection_DirectTI)
+ {
+ icoppositeselection = TIM_ICSelection_IndirectTI;
+ }
+ else
+ {
+ icoppositeselection = TIM_ICSelection_DirectTI;
+ }
+ if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_1)
+ {
+ /* TI1 Configuration */
+ TI1_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, TIM_ICInitStruct->TIM_ICSelection,
+ TIM_ICInitStruct->TIM_ICFilter);
+ /* Set the Input Capture Prescaler value */
+ TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
+ /* TI2 Configuration */
+ TI2_Config(TIMx, icoppositepolarity, icoppositeselection, TIM_ICInitStruct->TIM_ICFilter);
+ /* Set the Input Capture Prescaler value */
+ TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
+ }
+ else
+ {
+ /* TI2 Configuration */
+ TI2_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, TIM_ICInitStruct->TIM_ICSelection,
+ TIM_ICInitStruct->TIM_ICFilter);
+ /* Set the Input Capture Prescaler value */
+ TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
+ /* TI1 Configuration */
+ TI1_Config(TIMx, icoppositepolarity, icoppositeselection, TIM_ICInitStruct->TIM_ICFilter);
+ /* Set the Input Capture Prescaler value */
+ TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler);
+ }
+}
+
+/**
+ * @brief Configures the: Break feature, dead time, Lock level, the OSSI,
+ * the OSSR State and the AOE(automatic output enable).
+ * @param TIMx: where x can be 1 or 8 to select the TIM
+ * @param TIM_BDTRInitStruct: pointer to a TIM_BDTRInitTypeDef structure that
+ * contains the BDTR Register configuration information for the TIM peripheral.
+ * @retval None
+ */
+void TIM_BDTRConfig(TIM_TypeDef* TIMx, TIM_BDTRInitTypeDef *TIM_BDTRInitStruct)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST2_PERIPH(TIMx));
+ assert_param(IS_TIM_OSSR_STATE(TIM_BDTRInitStruct->TIM_OSSRState));
+ assert_param(IS_TIM_OSSI_STATE(TIM_BDTRInitStruct->TIM_OSSIState));
+ assert_param(IS_TIM_LOCK_LEVEL(TIM_BDTRInitStruct->TIM_LOCKLevel));
+ assert_param(IS_TIM_BREAK_STATE(TIM_BDTRInitStruct->TIM_Break));
+ assert_param(IS_TIM_BREAK_POLARITY(TIM_BDTRInitStruct->TIM_BreakPolarity));
+ assert_param(IS_TIM_AUTOMATIC_OUTPUT_STATE(TIM_BDTRInitStruct->TIM_AutomaticOutput));
+ /* Set the Lock level, the Break enable Bit and the Ploarity, the OSSR State,
+ the OSSI State, the dead time value and the Automatic Output Enable Bit */
+ TIMx->BDTR = (uint32_t)TIM_BDTRInitStruct->TIM_OSSRState | TIM_BDTRInitStruct->TIM_OSSIState |
+ TIM_BDTRInitStruct->TIM_LOCKLevel | TIM_BDTRInitStruct->TIM_DeadTime |
+ TIM_BDTRInitStruct->TIM_Break | TIM_BDTRInitStruct->TIM_BreakPolarity |
+ TIM_BDTRInitStruct->TIM_AutomaticOutput;
+}
+
+/**
+ * @brief Fills each TIM_TimeBaseInitStruct member with its default value.
+ * @param TIM_TimeBaseInitStruct : pointer to a TIM_TimeBaseInitTypeDef
+ * structure which will be initialized.
+ * @retval None
+ */
+void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct)
+{
+ /* Set the default configuration */
+ TIM_TimeBaseInitStruct->TIM_Period = 0xFFFF;
+ TIM_TimeBaseInitStruct->TIM_Prescaler = 0x0000;
+ TIM_TimeBaseInitStruct->TIM_ClockDivision = TIM_CKD_DIV1;
+ TIM_TimeBaseInitStruct->TIM_CounterMode = TIM_CounterMode_Up;
+ TIM_TimeBaseInitStruct->TIM_RepetitionCounter = 0x0000;
+}
+
+/**
+ * @brief Fills each TIM_OCInitStruct member with its default value.
+ * @param TIM_OCInitStruct : pointer to a TIM_OCInitTypeDef structure which will
+ * be initialized.
+ * @retval None
+ */
+void TIM_OCStructInit(TIM_OCInitTypeDef* TIM_OCInitStruct)
+{
+ /* Set the default configuration */
+ TIM_OCInitStruct->TIM_OCMode = TIM_OCMode_Timing;
+ TIM_OCInitStruct->TIM_OutputState = TIM_OutputState_Disable;
+ TIM_OCInitStruct->TIM_OutputNState = TIM_OutputNState_Disable;
+ TIM_OCInitStruct->TIM_Pulse = 0x0000;
+ TIM_OCInitStruct->TIM_OCPolarity = TIM_OCPolarity_High;
+ TIM_OCInitStruct->TIM_OCNPolarity = TIM_OCPolarity_High;
+ TIM_OCInitStruct->TIM_OCIdleState = TIM_OCIdleState_Reset;
+ TIM_OCInitStruct->TIM_OCNIdleState = TIM_OCNIdleState_Reset;
+}
+
+/**
+ * @brief Fills each TIM_ICInitStruct member with its default value.
+ * @param TIM_ICInitStruct: pointer to a TIM_ICInitTypeDef structure which will
+ * be initialized.
+ * @retval None
+ */
+void TIM_ICStructInit(TIM_ICInitTypeDef* TIM_ICInitStruct)
+{
+ /* Set the default configuration */
+ TIM_ICInitStruct->TIM_Channel = TIM_Channel_1;
+ TIM_ICInitStruct->TIM_ICPolarity = TIM_ICPolarity_Rising;
+ TIM_ICInitStruct->TIM_ICSelection = TIM_ICSelection_DirectTI;
+ TIM_ICInitStruct->TIM_ICPrescaler = TIM_ICPSC_DIV1;
+ TIM_ICInitStruct->TIM_ICFilter = 0x00;
+}
+
+/**
+ * @brief Fills each TIM_BDTRInitStruct member with its default value.
+ * @param TIM_BDTRInitStruct: pointer to a TIM_BDTRInitTypeDef structure which
+ * will be initialized.
+ * @retval None
+ */
+void TIM_BDTRStructInit(TIM_BDTRInitTypeDef* TIM_BDTRInitStruct)
+{
+ /* Set the default configuration */
+ TIM_BDTRInitStruct->TIM_OSSRState = TIM_OSSRState_Disable;
+ TIM_BDTRInitStruct->TIM_OSSIState = TIM_OSSIState_Disable;
+ TIM_BDTRInitStruct->TIM_LOCKLevel = TIM_LOCKLevel_OFF;
+ TIM_BDTRInitStruct->TIM_DeadTime = 0x00;
+ TIM_BDTRInitStruct->TIM_Break = TIM_Break_Disable;
+ TIM_BDTRInitStruct->TIM_BreakPolarity = TIM_BreakPolarity_Low;
+ TIM_BDTRInitStruct->TIM_AutomaticOutput = TIM_AutomaticOutput_Disable;
+}
+
+/**
+ * @brief Enables or disables the specified TIM peripheral.
+ * @param TIMx: where x can be 1 to 17 to select the TIMx peripheral.
+ * @param NewState: new state of the TIMx peripheral.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void TIM_Cmd(TIM_TypeDef* TIMx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the TIM Counter */
+ TIMx->CR1 |= TIM_CR1_CEN;
+ }
+ else
+ {
+ /* Disable the TIM Counter */
+ TIMx->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN));
+ }
+}
+
+/**
+ * @brief Enables or disables the TIM peripheral Main Outputs.
+ * @param TIMx: where x can be 1, 8, 15, 16 or 17 to select the TIMx peripheral.
+ * @param NewState: new state of the TIM peripheral Main Outputs.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void TIM_CtrlPWMOutputs(TIM_TypeDef* TIMx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST2_PERIPH(TIMx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the TIM Main Output */
+ TIMx->BDTR |= TIM_BDTR_MOE;
+ }
+ else
+ {
+ /* Disable the TIM Main Output */
+ TIMx->BDTR &= (uint16_t)(~((uint16_t)TIM_BDTR_MOE));
+ }
+}
+
+/**
+ * @brief Enables or disables the specified TIM interrupts.
+ * @param TIMx: where x can be 1 to 17 to select the TIMx peripheral.
+ * @param TIM_IT: specifies the TIM interrupts sources to be enabled or disabled.
+ * This parameter can be any combination of the following values:
+ * @arg TIM_IT_Update: TIM update Interrupt source
+ * @arg TIM_IT_CC1: TIM Capture Compare 1 Interrupt source
+ * @arg TIM_IT_CC2: TIM Capture Compare 2 Interrupt source
+ * @arg TIM_IT_CC3: TIM Capture Compare 3 Interrupt source
+ * @arg TIM_IT_CC4: TIM Capture Compare 4 Interrupt source
+ * @arg TIM_IT_COM: TIM Commutation Interrupt source
+ * @arg TIM_IT_Trigger: TIM Trigger Interrupt source
+ * @arg TIM_IT_Break: TIM Break Interrupt source
+ * @note
+ * - TIM6 and TIM7 can only generate an update interrupt.
+ * - TIM9, TIM12 and TIM15 can have only TIM_IT_Update, TIM_IT_CC1,
+ * TIM_IT_CC2 or TIM_IT_Trigger.
+ * - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_IT_Update or TIM_IT_CC1.
+ * - TIM_IT_Break is used only with TIM1, TIM8 and TIM15.
+ * - TIM_IT_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17.
+ * @param NewState: new state of the TIM interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void TIM_ITConfig(TIM_TypeDef* TIMx, uint16_t TIM_IT, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_TIM_IT(TIM_IT));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the Interrupt sources */
+ TIMx->DIER |= TIM_IT;
+ }
+ else
+ {
+ /* Disable the Interrupt sources */
+ TIMx->DIER &= (uint16_t)~TIM_IT;
+ }
+}
+
+/**
+ * @brief Configures the TIMx event to be generate by software.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param TIM_EventSource: specifies the event source.
+ * This parameter can be one or more of the following values:
+ * @arg TIM_EventSource_Update: Timer update Event source
+ * @arg TIM_EventSource_CC1: Timer Capture Compare 1 Event source
+ * @arg TIM_EventSource_CC2: Timer Capture Compare 2 Event source
+ * @arg TIM_EventSource_CC3: Timer Capture Compare 3 Event source
+ * @arg TIM_EventSource_CC4: Timer Capture Compare 4 Event source
+ * @arg TIM_EventSource_COM: Timer COM event source
+ * @arg TIM_EventSource_Trigger: Timer Trigger Event source
+ * @arg TIM_EventSource_Break: Timer Break event source
+ * @note
+ * - TIM6 and TIM7 can only generate an update event.
+ * - TIM_EventSource_COM and TIM_EventSource_Break are used only with TIM1 and TIM8.
+ * @retval None
+ */
+void TIM_GenerateEvent(TIM_TypeDef* TIMx, uint16_t TIM_EventSource)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_TIM_EVENT_SOURCE(TIM_EventSource));
+
+ /* Set the event sources */
+ TIMx->EGR = TIM_EventSource;
+}
+
+/**
+ * @brief Configures the TIMx's DMA interface.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 15, 16 or 17 to select
+ * the TIM peripheral.
+ * @param TIM_DMABase: DMA Base address.
+ * This parameter can be one of the following values:
+ * @arg TIM_DMABase_CR, TIM_DMABase_CR2, TIM_DMABase_SMCR,
+ * TIM_DMABase_DIER, TIM1_DMABase_SR, TIM_DMABase_EGR,
+ * TIM_DMABase_CCMR1, TIM_DMABase_CCMR2, TIM_DMABase_CCER,
+ * TIM_DMABase_CNT, TIM_DMABase_PSC, TIM_DMABase_ARR,
+ * TIM_DMABase_RCR, TIM_DMABase_CCR1, TIM_DMABase_CCR2,
+ * TIM_DMABase_CCR3, TIM_DMABase_CCR4, TIM_DMABase_BDTR,
+ * TIM_DMABase_DCR.
+ * @param TIM_DMABurstLength: DMA Burst length.
+ * This parameter can be one value between:
+ * TIM_DMABurstLength_1Transfer and TIM_DMABurstLength_18Transfers.
+ * @retval None
+ */
+void TIM_DMAConfig(TIM_TypeDef* TIMx, uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST4_PERIPH(TIMx));
+ assert_param(IS_TIM_DMA_BASE(TIM_DMABase));
+ assert_param(IS_TIM_DMA_LENGTH(TIM_DMABurstLength));
+ /* Set the DMA Base and the DMA Burst Length */
+ TIMx->DCR = TIM_DMABase | TIM_DMABurstLength;
+}
+
+/**
+ * @brief Enables or disables the TIMx's DMA Requests.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 6, 7, 8, 15, 16 or 17
+ * to select the TIM peripheral.
+ * @param TIM_DMASource: specifies the DMA Request sources.
+ * This parameter can be any combination of the following values:
+ * @arg TIM_DMA_Update: TIM update Interrupt source
+ * @arg TIM_DMA_CC1: TIM Capture Compare 1 DMA source
+ * @arg TIM_DMA_CC2: TIM Capture Compare 2 DMA source
+ * @arg TIM_DMA_CC3: TIM Capture Compare 3 DMA source
+ * @arg TIM_DMA_CC4: TIM Capture Compare 4 DMA source
+ * @arg TIM_DMA_COM: TIM Commutation DMA source
+ * @arg TIM_DMA_Trigger: TIM Trigger DMA source
+ * @param NewState: new state of the DMA Request sources.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void TIM_DMACmd(TIM_TypeDef* TIMx, uint16_t TIM_DMASource, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST9_PERIPH(TIMx));
+ assert_param(IS_TIM_DMA_SOURCE(TIM_DMASource));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the DMA sources */
+ TIMx->DIER |= TIM_DMASource;
+ }
+ else
+ {
+ /* Disable the DMA sources */
+ TIMx->DIER &= (uint16_t)~TIM_DMASource;
+ }
+}
+
+/**
+ * @brief Configures the TIMx internal Clock
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15
+ * to select the TIM peripheral.
+ * @retval None
+ */
+void TIM_InternalClockConfig(TIM_TypeDef* TIMx)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ /* Disable slave mode to clock the prescaler directly with the internal clock */
+ TIMx->SMCR &= (uint16_t)(~((uint16_t)TIM_SMCR_SMS));
+}
+
+/**
+ * @brief Configures the TIMx Internal Trigger as External Clock
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_ITRSource: Trigger source.
+ * This parameter can be one of the following values:
+ * @param TIM_TS_ITR0: Internal Trigger 0
+ * @param TIM_TS_ITR1: Internal Trigger 1
+ * @param TIM_TS_ITR2: Internal Trigger 2
+ * @param TIM_TS_ITR3: Internal Trigger 3
+ * @retval None
+ */
+void TIM_ITRxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_INTERNAL_TRIGGER_SELECTION(TIM_InputTriggerSource));
+ /* Select the Internal Trigger */
+ TIM_SelectInputTrigger(TIMx, TIM_InputTriggerSource);
+ /* Select the External clock mode1 */
+ TIMx->SMCR |= TIM_SlaveMode_External1;
+}
+
+/**
+ * @brief Configures the TIMx Trigger as External Clock
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_TIxExternalCLKSource: Trigger source.
+ * This parameter can be one of the following values:
+ * @arg TIM_TIxExternalCLK1Source_TI1ED: TI1 Edge Detector
+ * @arg TIM_TIxExternalCLK1Source_TI1: Filtered Timer Input 1
+ * @arg TIM_TIxExternalCLK1Source_TI2: Filtered Timer Input 2
+ * @param TIM_ICPolarity: specifies the TIx Polarity.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPolarity_Rising
+ * @arg TIM_ICPolarity_Falling
+ * @param ICFilter : specifies the filter value.
+ * This parameter must be a value between 0x0 and 0xF.
+ * @retval None
+ */
+void TIM_TIxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_TIxExternalCLKSource,
+ uint16_t TIM_ICPolarity, uint16_t ICFilter)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_TIXCLK_SOURCE(TIM_TIxExternalCLKSource));
+ assert_param(IS_TIM_IC_POLARITY(TIM_ICPolarity));
+ assert_param(IS_TIM_IC_FILTER(ICFilter));
+ /* Configure the Timer Input Clock Source */
+ if (TIM_TIxExternalCLKSource == TIM_TIxExternalCLK1Source_TI2)
+ {
+ TI2_Config(TIMx, TIM_ICPolarity, TIM_ICSelection_DirectTI, ICFilter);
+ }
+ else
+ {
+ TI1_Config(TIMx, TIM_ICPolarity, TIM_ICSelection_DirectTI, ICFilter);
+ }
+ /* Select the Trigger source */
+ TIM_SelectInputTrigger(TIMx, TIM_TIxExternalCLKSource);
+ /* Select the External clock mode1 */
+ TIMx->SMCR |= TIM_SlaveMode_External1;
+}
+
+/**
+ * @brief Configures the External clock Mode1
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
+ * This parameter can be one of the following values:
+ * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
+ * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
+ * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
+ * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
+ * @param TIM_ExtTRGPolarity: The external Trigger Polarity.
+ * This parameter can be one of the following values:
+ * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
+ * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
+ * @param ExtTRGFilter: External Trigger Filter.
+ * This parameter must be a value between 0x00 and 0x0F
+ * @retval None
+ */
+void TIM_ETRClockMode1Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
+ uint16_t ExtTRGFilter)
+{
+ uint16_t tmpsmcr = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_EXT_PRESCALER(TIM_ExtTRGPrescaler));
+ assert_param(IS_TIM_EXT_POLARITY(TIM_ExtTRGPolarity));
+ assert_param(IS_TIM_EXT_FILTER(ExtTRGFilter));
+ /* Configure the ETR Clock source */
+ TIM_ETRConfig(TIMx, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter);
+
+ /* Get the TIMx SMCR register value */
+ tmpsmcr = TIMx->SMCR;
+ /* Reset the SMS Bits */
+ tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_SMS));
+ /* Select the External clock mode1 */
+ tmpsmcr |= TIM_SlaveMode_External1;
+ /* Select the Trigger selection : ETRF */
+ tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_TS));
+ tmpsmcr |= TIM_TS_ETRF;
+ /* Write to TIMx SMCR */
+ TIMx->SMCR = tmpsmcr;
+}
+
+/**
+ * @brief Configures the External clock Mode2
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
+ * This parameter can be one of the following values:
+ * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
+ * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
+ * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
+ * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
+ * @param TIM_ExtTRGPolarity: The external Trigger Polarity.
+ * This parameter can be one of the following values:
+ * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
+ * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
+ * @param ExtTRGFilter: External Trigger Filter.
+ * This parameter must be a value between 0x00 and 0x0F
+ * @retval None
+ */
+void TIM_ETRClockMode2Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler,
+ uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_EXT_PRESCALER(TIM_ExtTRGPrescaler));
+ assert_param(IS_TIM_EXT_POLARITY(TIM_ExtTRGPolarity));
+ assert_param(IS_TIM_EXT_FILTER(ExtTRGFilter));
+ /* Configure the ETR Clock source */
+ TIM_ETRConfig(TIMx, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter);
+ /* Enable the External clock mode2 */
+ TIMx->SMCR |= TIM_SMCR_ECE;
+}
+
+/**
+ * @brief Configures the TIMx External Trigger (ETR).
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler.
+ * This parameter can be one of the following values:
+ * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
+ * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2.
+ * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4.
+ * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
+ * @param TIM_ExtTRGPolarity: The external Trigger Polarity.
+ * This parameter can be one of the following values:
+ * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active.
+ * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
+ * @param ExtTRGFilter: External Trigger Filter.
+ * This parameter must be a value between 0x00 and 0x0F
+ * @retval None
+ */
+void TIM_ETRConfig(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
+ uint16_t ExtTRGFilter)
+{
+ uint16_t tmpsmcr = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_EXT_PRESCALER(TIM_ExtTRGPrescaler));
+ assert_param(IS_TIM_EXT_POLARITY(TIM_ExtTRGPolarity));
+ assert_param(IS_TIM_EXT_FILTER(ExtTRGFilter));
+ tmpsmcr = TIMx->SMCR;
+ /* Reset the ETR Bits */
+ tmpsmcr &= SMCR_ETR_Mask;
+ /* Set the Prescaler, the Filter value and the Polarity */
+ tmpsmcr |= (uint16_t)(TIM_ExtTRGPrescaler | (uint16_t)(TIM_ExtTRGPolarity | (uint16_t)(ExtTRGFilter << (uint16_t)8)));
+ /* Write to TIMx SMCR */
+ TIMx->SMCR = tmpsmcr;
+}
+
+/**
+ * @brief Configures the TIMx Prescaler.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param Prescaler: specifies the Prescaler Register value
+ * @param TIM_PSCReloadMode: specifies the TIM Prescaler Reload mode
+ * This parameter can be one of the following values:
+ * @arg TIM_PSCReloadMode_Update: The Prescaler is loaded at the update event.
+ * @arg TIM_PSCReloadMode_Immediate: The Prescaler is loaded immediately.
+ * @retval None
+ */
+void TIM_PrescalerConfig(TIM_TypeDef* TIMx, uint16_t Prescaler, uint16_t TIM_PSCReloadMode)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_TIM_PRESCALER_RELOAD(TIM_PSCReloadMode));
+ /* Set the Prescaler value */
+ TIMx->PSC = Prescaler;
+ /* Set or reset the UG Bit */
+ TIMx->EGR = TIM_PSCReloadMode;
+}
+
+/**
+ * @brief Specifies the TIMx Counter Mode to be used.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_CounterMode: specifies the Counter Mode to be used
+ * This parameter can be one of the following values:
+ * @arg TIM_CounterMode_Up: TIM Up Counting Mode
+ * @arg TIM_CounterMode_Down: TIM Down Counting Mode
+ * @arg TIM_CounterMode_CenterAligned1: TIM Center Aligned Mode1
+ * @arg TIM_CounterMode_CenterAligned2: TIM Center Aligned Mode2
+ * @arg TIM_CounterMode_CenterAligned3: TIM Center Aligned Mode3
+ * @retval None
+ */
+void TIM_CounterModeConfig(TIM_TypeDef* TIMx, uint16_t TIM_CounterMode)
+{
+ uint16_t tmpcr1 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_COUNTER_MODE(TIM_CounterMode));
+ tmpcr1 = TIMx->CR1;
+ /* Reset the CMS and DIR Bits */
+ tmpcr1 &= (uint16_t)(~((uint16_t)(TIM_CR1_DIR | TIM_CR1_CMS)));
+ /* Set the Counter Mode */
+ tmpcr1 |= TIM_CounterMode;
+ /* Write to TIMx CR1 register */
+ TIMx->CR1 = tmpcr1;
+}
+
+/**
+ * @brief Selects the Input Trigger source
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_InputTriggerSource: The Input Trigger source.
+ * This parameter can be one of the following values:
+ * @arg TIM_TS_ITR0: Internal Trigger 0
+ * @arg TIM_TS_ITR1: Internal Trigger 1
+ * @arg TIM_TS_ITR2: Internal Trigger 2
+ * @arg TIM_TS_ITR3: Internal Trigger 3
+ * @arg TIM_TS_TI1F_ED: TI1 Edge Detector
+ * @arg TIM_TS_TI1FP1: Filtered Timer Input 1
+ * @arg TIM_TS_TI2FP2: Filtered Timer Input 2
+ * @arg TIM_TS_ETRF: External Trigger input
+ * @retval None
+ */
+void TIM_SelectInputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource)
+{
+ uint16_t tmpsmcr = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_TRIGGER_SELECTION(TIM_InputTriggerSource));
+ /* Get the TIMx SMCR register value */
+ tmpsmcr = TIMx->SMCR;
+ /* Reset the TS Bits */
+ tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_TS));
+ /* Set the Input Trigger source */
+ tmpsmcr |= TIM_InputTriggerSource;
+ /* Write to TIMx SMCR */
+ TIMx->SMCR = tmpsmcr;
+}
+
+/**
+ * @brief Configures the TIMx Encoder Interface.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_EncoderMode: specifies the TIMx Encoder Mode.
+ * This parameter can be one of the following values:
+ * @arg TIM_EncoderMode_TI1: Counter counts on TI1FP1 edge depending on TI2FP2 level.
+ * @arg TIM_EncoderMode_TI2: Counter counts on TI2FP2 edge depending on TI1FP1 level.
+ * @arg TIM_EncoderMode_TI12: Counter counts on both TI1FP1 and TI2FP2 edges depending
+ * on the level of the other input.
+ * @param TIM_IC1Polarity: specifies the IC1 Polarity
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPolarity_Falling: IC Falling edge.
+ * @arg TIM_ICPolarity_Rising: IC Rising edge.
+ * @param TIM_IC2Polarity: specifies the IC2 Polarity
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPolarity_Falling: IC Falling edge.
+ * @arg TIM_ICPolarity_Rising: IC Rising edge.
+ * @retval None
+ */
+void TIM_EncoderInterfaceConfig(TIM_TypeDef* TIMx, uint16_t TIM_EncoderMode,
+ uint16_t TIM_IC1Polarity, uint16_t TIM_IC2Polarity)
+{
+ uint16_t tmpsmcr = 0;
+ uint16_t tmpccmr1 = 0;
+ uint16_t tmpccer = 0;
+
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST5_PERIPH(TIMx));
+ assert_param(IS_TIM_ENCODER_MODE(TIM_EncoderMode));
+ assert_param(IS_TIM_IC_POLARITY(TIM_IC1Polarity));
+ assert_param(IS_TIM_IC_POLARITY(TIM_IC2Polarity));
+
+ /* Get the TIMx SMCR register value */
+ tmpsmcr = TIMx->SMCR;
+
+ /* Get the TIMx CCMR1 register value */
+ tmpccmr1 = TIMx->CCMR1;
+
+ /* Get the TIMx CCER register value */
+ tmpccer = TIMx->CCER;
+
+ /* Set the encoder Mode */
+ tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_SMS));
+ tmpsmcr |= TIM_EncoderMode;
+
+ /* Select the Capture Compare 1 and the Capture Compare 2 as input */
+ tmpccmr1 &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCMR1_CC1S)) & (uint16_t)(~((uint16_t)TIM_CCMR1_CC2S)));
+ tmpccmr1 |= TIM_CCMR1_CC1S_0 | TIM_CCMR1_CC2S_0;
+
+ /* Set the TI1 and the TI2 Polarities */
+ tmpccer &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCER_CC1P)) & ((uint16_t)~((uint16_t)TIM_CCER_CC2P)));
+ tmpccer |= (uint16_t)(TIM_IC1Polarity | (uint16_t)(TIM_IC2Polarity << (uint16_t)4));
+
+ /* Write to TIMx SMCR */
+ TIMx->SMCR = tmpsmcr;
+ /* Write to TIMx CCMR1 */
+ TIMx->CCMR1 = tmpccmr1;
+ /* Write to TIMx CCER */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Forces the TIMx output 1 waveform to active or inactive level.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform.
+ * This parameter can be one of the following values:
+ * @arg TIM_ForcedAction_Active: Force active level on OC1REF
+ * @arg TIM_ForcedAction_InActive: Force inactive level on OC1REF.
+ * @retval None
+ */
+void TIM_ForcedOC1Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction)
+{
+ uint16_t tmpccmr1 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
+ tmpccmr1 = TIMx->CCMR1;
+ /* Reset the OC1M Bits */
+ tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1M);
+ /* Configure The Forced output Mode */
+ tmpccmr1 |= TIM_ForcedAction;
+ /* Write to TIMx CCMR1 register */
+ TIMx->CCMR1 = tmpccmr1;
+}
+
+/**
+ * @brief Forces the TIMx output 2 waveform to active or inactive level.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform.
+ * This parameter can be one of the following values:
+ * @arg TIM_ForcedAction_Active: Force active level on OC2REF
+ * @arg TIM_ForcedAction_InActive: Force inactive level on OC2REF.
+ * @retval None
+ */
+void TIM_ForcedOC2Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction)
+{
+ uint16_t tmpccmr1 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
+ tmpccmr1 = TIMx->CCMR1;
+ /* Reset the OC2M Bits */
+ tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2M);
+ /* Configure The Forced output Mode */
+ tmpccmr1 |= (uint16_t)(TIM_ForcedAction << 8);
+ /* Write to TIMx CCMR1 register */
+ TIMx->CCMR1 = tmpccmr1;
+}
+
+/**
+ * @brief Forces the TIMx output 3 waveform to active or inactive level.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform.
+ * This parameter can be one of the following values:
+ * @arg TIM_ForcedAction_Active: Force active level on OC3REF
+ * @arg TIM_ForcedAction_InActive: Force inactive level on OC3REF.
+ * @retval None
+ */
+void TIM_ForcedOC3Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction)
+{
+ uint16_t tmpccmr2 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
+ tmpccmr2 = TIMx->CCMR2;
+ /* Reset the OC1M Bits */
+ tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3M);
+ /* Configure The Forced output Mode */
+ tmpccmr2 |= TIM_ForcedAction;
+ /* Write to TIMx CCMR2 register */
+ TIMx->CCMR2 = tmpccmr2;
+}
+
+/**
+ * @brief Forces the TIMx output 4 waveform to active or inactive level.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform.
+ * This parameter can be one of the following values:
+ * @arg TIM_ForcedAction_Active: Force active level on OC4REF
+ * @arg TIM_ForcedAction_InActive: Force inactive level on OC4REF.
+ * @retval None
+ */
+void TIM_ForcedOC4Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction)
+{
+ uint16_t tmpccmr2 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
+ tmpccmr2 = TIMx->CCMR2;
+ /* Reset the OC2M Bits */
+ tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC4M);
+ /* Configure The Forced output Mode */
+ tmpccmr2 |= (uint16_t)(TIM_ForcedAction << 8);
+ /* Write to TIMx CCMR2 register */
+ TIMx->CCMR2 = tmpccmr2;
+}
+
+/**
+ * @brief Enables or disables TIMx peripheral Preload register on ARR.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param NewState: new state of the TIMx peripheral Preload register
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void TIM_ARRPreloadConfig(TIM_TypeDef* TIMx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Set the ARR Preload Bit */
+ TIMx->CR1 |= TIM_CR1_ARPE;
+ }
+ else
+ {
+ /* Reset the ARR Preload Bit */
+ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_ARPE);
+ }
+}
+
+/**
+ * @brief Selects the TIM peripheral Commutation event.
+ * @param TIMx: where x can be 1, 8, 15, 16 or 17 to select the TIMx peripheral
+ * @param NewState: new state of the Commutation event.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void TIM_SelectCOM(TIM_TypeDef* TIMx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST2_PERIPH(TIMx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Set the COM Bit */
+ TIMx->CR2 |= TIM_CR2_CCUS;
+ }
+ else
+ {
+ /* Reset the COM Bit */
+ TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_CCUS);
+ }
+}
+
+/**
+ * @brief Selects the TIMx peripheral Capture Compare DMA source.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 15, 16 or 17 to select
+ * the TIM peripheral.
+ * @param NewState: new state of the Capture Compare DMA source
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void TIM_SelectCCDMA(TIM_TypeDef* TIMx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST4_PERIPH(TIMx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Set the CCDS Bit */
+ TIMx->CR2 |= TIM_CR2_CCDS;
+ }
+ else
+ {
+ /* Reset the CCDS Bit */
+ TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_CCDS);
+ }
+}
+
+/**
+ * @brief Sets or Resets the TIM peripheral Capture Compare Preload Control bit.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8 or 15
+ * to select the TIMx peripheral
+ * @param NewState: new state of the Capture Compare Preload Control bit
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void TIM_CCPreloadControl(TIM_TypeDef* TIMx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST5_PERIPH(TIMx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Set the CCPC Bit */
+ TIMx->CR2 |= TIM_CR2_CCPC;
+ }
+ else
+ {
+ /* Reset the CCPC Bit */
+ TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_CCPC);
+ }
+}
+
+/**
+ * @brief Enables or disables the TIMx peripheral Preload register on CCR1.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param TIM_OCPreload: new state of the TIMx peripheral Preload register
+ * This parameter can be one of the following values:
+ * @arg TIM_OCPreload_Enable
+ * @arg TIM_OCPreload_Disable
+ * @retval None
+ */
+void TIM_OC1PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload)
+{
+ uint16_t tmpccmr1 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
+ tmpccmr1 = TIMx->CCMR1;
+ /* Reset the OC1PE Bit */
+ tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1PE);
+ /* Enable or Disable the Output Compare Preload feature */
+ tmpccmr1 |= TIM_OCPreload;
+ /* Write to TIMx CCMR1 register */
+ TIMx->CCMR1 = tmpccmr1;
+}
+
+/**
+ * @brief Enables or disables the TIMx peripheral Preload register on CCR2.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select
+ * the TIM peripheral.
+ * @param TIM_OCPreload: new state of the TIMx peripheral Preload register
+ * This parameter can be one of the following values:
+ * @arg TIM_OCPreload_Enable
+ * @arg TIM_OCPreload_Disable
+ * @retval None
+ */
+void TIM_OC2PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload)
+{
+ uint16_t tmpccmr1 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
+ tmpccmr1 = TIMx->CCMR1;
+ /* Reset the OC2PE Bit */
+ tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2PE);
+ /* Enable or Disable the Output Compare Preload feature */
+ tmpccmr1 |= (uint16_t)(TIM_OCPreload << 8);
+ /* Write to TIMx CCMR1 register */
+ TIMx->CCMR1 = tmpccmr1;
+}
+
+/**
+ * @brief Enables or disables the TIMx peripheral Preload register on CCR3.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCPreload: new state of the TIMx peripheral Preload register
+ * This parameter can be one of the following values:
+ * @arg TIM_OCPreload_Enable
+ * @arg TIM_OCPreload_Disable
+ * @retval None
+ */
+void TIM_OC3PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload)
+{
+ uint16_t tmpccmr2 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
+ tmpccmr2 = TIMx->CCMR2;
+ /* Reset the OC3PE Bit */
+ tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3PE);
+ /* Enable or Disable the Output Compare Preload feature */
+ tmpccmr2 |= TIM_OCPreload;
+ /* Write to TIMx CCMR2 register */
+ TIMx->CCMR2 = tmpccmr2;
+}
+
+/**
+ * @brief Enables or disables the TIMx peripheral Preload register on CCR4.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCPreload: new state of the TIMx peripheral Preload register
+ * This parameter can be one of the following values:
+ * @arg TIM_OCPreload_Enable
+ * @arg TIM_OCPreload_Disable
+ * @retval None
+ */
+void TIM_OC4PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload)
+{
+ uint16_t tmpccmr2 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
+ tmpccmr2 = TIMx->CCMR2;
+ /* Reset the OC4PE Bit */
+ tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC4PE);
+ /* Enable or Disable the Output Compare Preload feature */
+ tmpccmr2 |= (uint16_t)(TIM_OCPreload << 8);
+ /* Write to TIMx CCMR2 register */
+ TIMx->CCMR2 = tmpccmr2;
+}
+
+/**
+ * @brief Configures the TIMx Output Compare 1 Fast feature.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCFast_Enable: TIM output compare fast enable
+ * @arg TIM_OCFast_Disable: TIM output compare fast disable
+ * @retval None
+ */
+void TIM_OC1FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast)
+{
+ uint16_t tmpccmr1 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
+ /* Get the TIMx CCMR1 register value */
+ tmpccmr1 = TIMx->CCMR1;
+ /* Reset the OC1FE Bit */
+ tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1FE);
+ /* Enable or Disable the Output Compare Fast Bit */
+ tmpccmr1 |= TIM_OCFast;
+ /* Write to TIMx CCMR1 */
+ TIMx->CCMR1 = tmpccmr1;
+}
+
+/**
+ * @brief Configures the TIMx Output Compare 2 Fast feature.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select
+ * the TIM peripheral.
+ * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCFast_Enable: TIM output compare fast enable
+ * @arg TIM_OCFast_Disable: TIM output compare fast disable
+ * @retval None
+ */
+void TIM_OC2FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast)
+{
+ uint16_t tmpccmr1 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
+ /* Get the TIMx CCMR1 register value */
+ tmpccmr1 = TIMx->CCMR1;
+ /* Reset the OC2FE Bit */
+ tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2FE);
+ /* Enable or Disable the Output Compare Fast Bit */
+ tmpccmr1 |= (uint16_t)(TIM_OCFast << 8);
+ /* Write to TIMx CCMR1 */
+ TIMx->CCMR1 = tmpccmr1;
+}
+
+/**
+ * @brief Configures the TIMx Output Compare 3 Fast feature.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCFast_Enable: TIM output compare fast enable
+ * @arg TIM_OCFast_Disable: TIM output compare fast disable
+ * @retval None
+ */
+void TIM_OC3FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast)
+{
+ uint16_t tmpccmr2 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
+ /* Get the TIMx CCMR2 register value */
+ tmpccmr2 = TIMx->CCMR2;
+ /* Reset the OC3FE Bit */
+ tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3FE);
+ /* Enable or Disable the Output Compare Fast Bit */
+ tmpccmr2 |= TIM_OCFast;
+ /* Write to TIMx CCMR2 */
+ TIMx->CCMR2 = tmpccmr2;
+}
+
+/**
+ * @brief Configures the TIMx Output Compare 4 Fast feature.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCFast_Enable: TIM output compare fast enable
+ * @arg TIM_OCFast_Disable: TIM output compare fast disable
+ * @retval None
+ */
+void TIM_OC4FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast)
+{
+ uint16_t tmpccmr2 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
+ /* Get the TIMx CCMR2 register value */
+ tmpccmr2 = TIMx->CCMR2;
+ /* Reset the OC4FE Bit */
+ tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC4FE);
+ /* Enable or Disable the Output Compare Fast Bit */
+ tmpccmr2 |= (uint16_t)(TIM_OCFast << 8);
+ /* Write to TIMx CCMR2 */
+ TIMx->CCMR2 = tmpccmr2;
+}
+
+/**
+ * @brief Clears or safeguards the OCREF1 signal on an external event
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCClear_Enable: TIM Output clear enable
+ * @arg TIM_OCClear_Disable: TIM Output clear disable
+ * @retval None
+ */
+void TIM_ClearOC1Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear)
+{
+ uint16_t tmpccmr1 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear));
+
+ tmpccmr1 = TIMx->CCMR1;
+
+ /* Reset the OC1CE Bit */
+ tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1CE);
+ /* Enable or Disable the Output Compare Clear Bit */
+ tmpccmr1 |= TIM_OCClear;
+ /* Write to TIMx CCMR1 register */
+ TIMx->CCMR1 = tmpccmr1;
+}
+
+/**
+ * @brief Clears or safeguards the OCREF2 signal on an external event
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCClear_Enable: TIM Output clear enable
+ * @arg TIM_OCClear_Disable: TIM Output clear disable
+ * @retval None
+ */
+void TIM_ClearOC2Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear)
+{
+ uint16_t tmpccmr1 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear));
+ tmpccmr1 = TIMx->CCMR1;
+ /* Reset the OC2CE Bit */
+ tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2CE);
+ /* Enable or Disable the Output Compare Clear Bit */
+ tmpccmr1 |= (uint16_t)(TIM_OCClear << 8);
+ /* Write to TIMx CCMR1 register */
+ TIMx->CCMR1 = tmpccmr1;
+}
+
+/**
+ * @brief Clears or safeguards the OCREF3 signal on an external event
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCClear_Enable: TIM Output clear enable
+ * @arg TIM_OCClear_Disable: TIM Output clear disable
+ * @retval None
+ */
+void TIM_ClearOC3Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear)
+{
+ uint16_t tmpccmr2 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear));
+ tmpccmr2 = TIMx->CCMR2;
+ /* Reset the OC3CE Bit */
+ tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3CE);
+ /* Enable or Disable the Output Compare Clear Bit */
+ tmpccmr2 |= TIM_OCClear;
+ /* Write to TIMx CCMR2 register */
+ TIMx->CCMR2 = tmpccmr2;
+}
+
+/**
+ * @brief Clears or safeguards the OCREF4 signal on an external event
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCClear_Enable: TIM Output clear enable
+ * @arg TIM_OCClear_Disable: TIM Output clear disable
+ * @retval None
+ */
+void TIM_ClearOC4Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear)
+{
+ uint16_t tmpccmr2 = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear));
+ tmpccmr2 = TIMx->CCMR2;
+ /* Reset the OC4CE Bit */
+ tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC4CE);
+ /* Enable or Disable the Output Compare Clear Bit */
+ tmpccmr2 |= (uint16_t)(TIM_OCClear << 8);
+ /* Write to TIMx CCMR2 register */
+ TIMx->CCMR2 = tmpccmr2;
+}
+
+/**
+ * @brief Configures the TIMx channel 1 polarity.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param TIM_OCPolarity: specifies the OC1 Polarity
+ * This parameter can be one of the following values:
+ * @arg TIM_OCPolarity_High: Output Compare active high
+ * @arg TIM_OCPolarity_Low: Output Compare active low
+ * @retval None
+ */
+void TIM_OC1PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity)
+{
+ uint16_t tmpccer = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity));
+ tmpccer = TIMx->CCER;
+ /* Set or Reset the CC1P Bit */
+ tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC1P);
+ tmpccer |= TIM_OCPolarity;
+ /* Write to TIMx CCER register */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Configures the TIMx Channel 1N polarity.
+ * @param TIMx: where x can be 1, 8, 15, 16 or 17 to select the TIM peripheral.
+ * @param TIM_OCNPolarity: specifies the OC1N Polarity
+ * This parameter can be one of the following values:
+ * @arg TIM_OCNPolarity_High: Output Compare active high
+ * @arg TIM_OCNPolarity_Low: Output Compare active low
+ * @retval None
+ */
+void TIM_OC1NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity)
+{
+ uint16_t tmpccer = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST2_PERIPH(TIMx));
+ assert_param(IS_TIM_OCN_POLARITY(TIM_OCNPolarity));
+
+ tmpccer = TIMx->CCER;
+ /* Set or Reset the CC1NP Bit */
+ tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC1NP);
+ tmpccer |= TIM_OCNPolarity;
+ /* Write to TIMx CCER register */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Configures the TIMx channel 2 polarity.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_OCPolarity: specifies the OC2 Polarity
+ * This parameter can be one of the following values:
+ * @arg TIM_OCPolarity_High: Output Compare active high
+ * @arg TIM_OCPolarity_Low: Output Compare active low
+ * @retval None
+ */
+void TIM_OC2PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity)
+{
+ uint16_t tmpccer = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity));
+ tmpccer = TIMx->CCER;
+ /* Set or Reset the CC2P Bit */
+ tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC2P);
+ tmpccer |= (uint16_t)(TIM_OCPolarity << 4);
+ /* Write to TIMx CCER register */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Configures the TIMx Channel 2N polarity.
+ * @param TIMx: where x can be 1 or 8 to select the TIM peripheral.
+ * @param TIM_OCNPolarity: specifies the OC2N Polarity
+ * This parameter can be one of the following values:
+ * @arg TIM_OCNPolarity_High: Output Compare active high
+ * @arg TIM_OCNPolarity_Low: Output Compare active low
+ * @retval None
+ */
+void TIM_OC2NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity)
+{
+ uint16_t tmpccer = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST1_PERIPH(TIMx));
+ assert_param(IS_TIM_OCN_POLARITY(TIM_OCNPolarity));
+
+ tmpccer = TIMx->CCER;
+ /* Set or Reset the CC2NP Bit */
+ tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC2NP);
+ tmpccer |= (uint16_t)(TIM_OCNPolarity << 4);
+ /* Write to TIMx CCER register */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Configures the TIMx channel 3 polarity.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCPolarity: specifies the OC3 Polarity
+ * This parameter can be one of the following values:
+ * @arg TIM_OCPolarity_High: Output Compare active high
+ * @arg TIM_OCPolarity_Low: Output Compare active low
+ * @retval None
+ */
+void TIM_OC3PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity)
+{
+ uint16_t tmpccer = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity));
+ tmpccer = TIMx->CCER;
+ /* Set or Reset the CC3P Bit */
+ tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC3P);
+ tmpccer |= (uint16_t)(TIM_OCPolarity << 8);
+ /* Write to TIMx CCER register */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Configures the TIMx Channel 3N polarity.
+ * @param TIMx: where x can be 1 or 8 to select the TIM peripheral.
+ * @param TIM_OCNPolarity: specifies the OC3N Polarity
+ * This parameter can be one of the following values:
+ * @arg TIM_OCNPolarity_High: Output Compare active high
+ * @arg TIM_OCNPolarity_Low: Output Compare active low
+ * @retval None
+ */
+void TIM_OC3NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity)
+{
+ uint16_t tmpccer = 0;
+
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST1_PERIPH(TIMx));
+ assert_param(IS_TIM_OCN_POLARITY(TIM_OCNPolarity));
+
+ tmpccer = TIMx->CCER;
+ /* Set or Reset the CC3NP Bit */
+ tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC3NP);
+ tmpccer |= (uint16_t)(TIM_OCNPolarity << 8);
+ /* Write to TIMx CCER register */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Configures the TIMx channel 4 polarity.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_OCPolarity: specifies the OC4 Polarity
+ * This parameter can be one of the following values:
+ * @arg TIM_OCPolarity_High: Output Compare active high
+ * @arg TIM_OCPolarity_Low: Output Compare active low
+ * @retval None
+ */
+void TIM_OC4PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity)
+{
+ uint16_t tmpccer = 0;
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity));
+ tmpccer = TIMx->CCER;
+ /* Set or Reset the CC4P Bit */
+ tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC4P);
+ tmpccer |= (uint16_t)(TIM_OCPolarity << 12);
+ /* Write to TIMx CCER register */
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Enables or disables the TIM Capture Compare Channel x.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param TIM_Channel: specifies the TIM Channel
+ * This parameter can be one of the following values:
+ * @arg TIM_Channel_1: TIM Channel 1
+ * @arg TIM_Channel_2: TIM Channel 2
+ * @arg TIM_Channel_3: TIM Channel 3
+ * @arg TIM_Channel_4: TIM Channel 4
+ * @param TIM_CCx: specifies the TIM Channel CCxE bit new state.
+ * This parameter can be: TIM_CCx_Enable or TIM_CCx_Disable.
+ * @retval None
+ */
+void TIM_CCxCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx)
+{
+ uint16_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ assert_param(IS_TIM_CHANNEL(TIM_Channel));
+ assert_param(IS_TIM_CCX(TIM_CCx));
+
+ tmp = CCER_CCE_Set << TIM_Channel;
+
+ /* Reset the CCxE Bit */
+ TIMx->CCER &= (uint16_t)~ tmp;
+
+ /* Set or reset the CCxE Bit */
+ TIMx->CCER |= (uint16_t)(TIM_CCx << TIM_Channel);
+}
+
+/**
+ * @brief Enables or disables the TIM Capture Compare Channel xN.
+ * @param TIMx: where x can be 1, 8, 15, 16 or 17 to select the TIM peripheral.
+ * @param TIM_Channel: specifies the TIM Channel
+ * This parameter can be one of the following values:
+ * @arg TIM_Channel_1: TIM Channel 1
+ * @arg TIM_Channel_2: TIM Channel 2
+ * @arg TIM_Channel_3: TIM Channel 3
+ * @param TIM_CCxN: specifies the TIM Channel CCxNE bit new state.
+ * This parameter can be: TIM_CCxN_Enable or TIM_CCxN_Disable.
+ * @retval None
+ */
+void TIM_CCxNCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN)
+{
+ uint16_t tmp = 0;
+
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST2_PERIPH(TIMx));
+ assert_param(IS_TIM_COMPLEMENTARY_CHANNEL(TIM_Channel));
+ assert_param(IS_TIM_CCXN(TIM_CCxN));
+
+ tmp = CCER_CCNE_Set << TIM_Channel;
+
+ /* Reset the CCxNE Bit */
+ TIMx->CCER &= (uint16_t) ~tmp;
+
+ /* Set or reset the CCxNE Bit */
+ TIMx->CCER |= (uint16_t)(TIM_CCxN << TIM_Channel);
+}
+
+/**
+ * @brief Selects the TIM Output Compare Mode.
+ * @note This function disables the selected channel before changing the Output
+ * Compare Mode.
+ * User has to enable this channel using TIM_CCxCmd and TIM_CCxNCmd functions.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param TIM_Channel: specifies the TIM Channel
+ * This parameter can be one of the following values:
+ * @arg TIM_Channel_1: TIM Channel 1
+ * @arg TIM_Channel_2: TIM Channel 2
+ * @arg TIM_Channel_3: TIM Channel 3
+ * @arg TIM_Channel_4: TIM Channel 4
+ * @param TIM_OCMode: specifies the TIM Output Compare Mode.
+ * This parameter can be one of the following values:
+ * @arg TIM_OCMode_Timing
+ * @arg TIM_OCMode_Active
+ * @arg TIM_OCMode_Toggle
+ * @arg TIM_OCMode_PWM1
+ * @arg TIM_OCMode_PWM2
+ * @arg TIM_ForcedAction_Active
+ * @arg TIM_ForcedAction_InActive
+ * @retval None
+ */
+void TIM_SelectOCxM(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_OCMode)
+{
+ uint32_t tmp = 0;
+ uint16_t tmp1 = 0;
+
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ assert_param(IS_TIM_CHANNEL(TIM_Channel));
+ assert_param(IS_TIM_OCM(TIM_OCMode));
+
+ tmp = (uint32_t) TIMx;
+ tmp += CCMR_Offset;
+
+ tmp1 = CCER_CCE_Set << (uint16_t)TIM_Channel;
+
+ /* Disable the Channel: Reset the CCxE Bit */
+ TIMx->CCER &= (uint16_t) ~tmp1;
+
+ if((TIM_Channel == TIM_Channel_1) ||(TIM_Channel == TIM_Channel_3))
+ {
+ tmp += (TIM_Channel>>1);
+
+ /* Reset the OCxM bits in the CCMRx register */
+ *(__IO uint32_t *) tmp &= (uint32_t)~((uint32_t)TIM_CCMR1_OC1M);
+
+ /* Configure the OCxM bits in the CCMRx register */
+ *(__IO uint32_t *) tmp |= TIM_OCMode;
+ }
+ else
+ {
+ tmp += (uint16_t)(TIM_Channel - (uint16_t)4)>> (uint16_t)1;
+
+ /* Reset the OCxM bits in the CCMRx register */
+ *(__IO uint32_t *) tmp &= (uint32_t)~((uint32_t)TIM_CCMR1_OC2M);
+
+ /* Configure the OCxM bits in the CCMRx register */
+ *(__IO uint32_t *) tmp |= (uint16_t)(TIM_OCMode << 8);
+ }
+}
+
+/**
+ * @brief Enables or Disables the TIMx Update event.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param NewState: new state of the TIMx UDIS bit
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void TIM_UpdateDisableConfig(TIM_TypeDef* TIMx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Set the Update Disable Bit */
+ TIMx->CR1 |= TIM_CR1_UDIS;
+ }
+ else
+ {
+ /* Reset the Update Disable Bit */
+ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_UDIS);
+ }
+}
+
+/**
+ * @brief Configures the TIMx Update Request Interrupt source.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param TIM_UpdateSource: specifies the Update source.
+ * This parameter can be one of the following values:
+ * @arg TIM_UpdateSource_Regular: Source of update is the counter overflow/underflow
+ or the setting of UG bit, or an update generation
+ through the slave mode controller.
+ * @arg TIM_UpdateSource_Global: Source of update is counter overflow/underflow.
+ * @retval None
+ */
+void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource));
+ if (TIM_UpdateSource != TIM_UpdateSource_Global)
+ {
+ /* Set the URS Bit */
+ TIMx->CR1 |= TIM_CR1_URS;
+ }
+ else
+ {
+ /* Reset the URS Bit */
+ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS);
+ }
+}
+
+/**
+ * @brief Enables or disables the TIMx's Hall sensor interface.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param NewState: new state of the TIMx Hall sensor interface.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void TIM_SelectHallSensor(TIM_TypeDef* TIMx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Set the TI1S Bit */
+ TIMx->CR2 |= TIM_CR2_TI1S;
+ }
+ else
+ {
+ /* Reset the TI1S Bit */
+ TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_TI1S);
+ }
+}
+
+/**
+ * @brief Selects the TIMx's One Pulse Mode.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param TIM_OPMode: specifies the OPM Mode to be used.
+ * This parameter can be one of the following values:
+ * @arg TIM_OPMode_Single
+ * @arg TIM_OPMode_Repetitive
+ * @retval None
+ */
+void TIM_SelectOnePulseMode(TIM_TypeDef* TIMx, uint16_t TIM_OPMode)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_TIM_OPM_MODE(TIM_OPMode));
+ /* Reset the OPM Bit */
+ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_OPM);
+ /* Configure the OPM Mode */
+ TIMx->CR1 |= TIM_OPMode;
+}
+
+/**
+ * @brief Selects the TIMx Trigger Output Mode.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 6, 7, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_TRGOSource: specifies the Trigger Output source.
+ * This paramter can be one of the following values:
+ *
+ * - For all TIMx
+ * @arg TIM_TRGOSource_Reset: The UG bit in the TIM_EGR register is used as the trigger output (TRGO).
+ * @arg TIM_TRGOSource_Enable: The Counter Enable CEN is used as the trigger output (TRGO).
+ * @arg TIM_TRGOSource_Update: The update event is selected as the trigger output (TRGO).
+ *
+ * - For all TIMx except TIM6 and TIM7
+ * @arg TIM_TRGOSource_OC1: The trigger output sends a positive pulse when the CC1IF flag
+ * is to be set, as soon as a capture or compare match occurs (TRGO).
+ * @arg TIM_TRGOSource_OC1Ref: OC1REF signal is used as the trigger output (TRGO).
+ * @arg TIM_TRGOSource_OC2Ref: OC2REF signal is used as the trigger output (TRGO).
+ * @arg TIM_TRGOSource_OC3Ref: OC3REF signal is used as the trigger output (TRGO).
+ * @arg TIM_TRGOSource_OC4Ref: OC4REF signal is used as the trigger output (TRGO).
+ *
+ * @retval None
+ */
+void TIM_SelectOutputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_TRGOSource)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST7_PERIPH(TIMx));
+ assert_param(IS_TIM_TRGO_SOURCE(TIM_TRGOSource));
+ /* Reset the MMS Bits */
+ TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_MMS);
+ /* Select the TRGO source */
+ TIMx->CR2 |= TIM_TRGOSource;
+}
+
+/**
+ * @brief Selects the TIMx Slave Mode.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_SlaveMode: specifies the Timer Slave Mode.
+ * This parameter can be one of the following values:
+ * @arg TIM_SlaveMode_Reset: Rising edge of the selected trigger signal (TRGI) re-initializes
+ * the counter and triggers an update of the registers.
+ * @arg TIM_SlaveMode_Gated: The counter clock is enabled when the trigger signal (TRGI) is high.
+ * @arg TIM_SlaveMode_Trigger: The counter starts at a rising edge of the trigger TRGI.
+ * @arg TIM_SlaveMode_External1: Rising edges of the selected trigger (TRGI) clock the counter.
+ * @retval None
+ */
+void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_SlaveMode)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_SLAVE_MODE(TIM_SlaveMode));
+ /* Reset the SMS Bits */
+ TIMx->SMCR &= (uint16_t)~((uint16_t)TIM_SMCR_SMS);
+ /* Select the Slave Mode */
+ TIMx->SMCR |= TIM_SlaveMode;
+}
+
+/**
+ * @brief Sets or Resets the TIMx Master/Slave Mode.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_MasterSlaveMode: specifies the Timer Master Slave Mode.
+ * This parameter can be one of the following values:
+ * @arg TIM_MasterSlaveMode_Enable: synchronization between the current timer
+ * and its slaves (through TRGO).
+ * @arg TIM_MasterSlaveMode_Disable: No action
+ * @retval None
+ */
+void TIM_SelectMasterSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_MasterSlaveMode)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_MSM_STATE(TIM_MasterSlaveMode));
+ /* Reset the MSM Bit */
+ TIMx->SMCR &= (uint16_t)~((uint16_t)TIM_SMCR_MSM);
+
+ /* Set or Reset the MSM Bit */
+ TIMx->SMCR |= TIM_MasterSlaveMode;
+}
+
+/**
+ * @brief Sets the TIMx Counter Register value
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param Counter: specifies the Counter register new value.
+ * @retval None
+ */
+void TIM_SetCounter(TIM_TypeDef* TIMx, uint16_t Counter)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ /* Set the Counter Register value */
+ TIMx->CNT = Counter;
+}
+
+/**
+ * @brief Sets the TIMx Autoreload Register value
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param Autoreload: specifies the Autoreload register new value.
+ * @retval None
+ */
+void TIM_SetAutoreload(TIM_TypeDef* TIMx, uint16_t Autoreload)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ /* Set the Autoreload Register value */
+ TIMx->ARR = Autoreload;
+}
+
+/**
+ * @brief Sets the TIMx Capture Compare1 Register value
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param Compare1: specifies the Capture Compare1 register new value.
+ * @retval None
+ */
+void TIM_SetCompare1(TIM_TypeDef* TIMx, uint16_t Compare1)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ /* Set the Capture Compare1 Register value */
+ TIMx->CCR1 = Compare1;
+}
+
+/**
+ * @brief Sets the TIMx Capture Compare2 Register value
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @param Compare2: specifies the Capture Compare2 register new value.
+ * @retval None
+ */
+void TIM_SetCompare2(TIM_TypeDef* TIMx, uint16_t Compare2)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ /* Set the Capture Compare2 Register value */
+ TIMx->CCR2 = Compare2;
+}
+
+/**
+ * @brief Sets the TIMx Capture Compare3 Register value
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param Compare3: specifies the Capture Compare3 register new value.
+ * @retval None
+ */
+void TIM_SetCompare3(TIM_TypeDef* TIMx, uint16_t Compare3)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ /* Set the Capture Compare3 Register value */
+ TIMx->CCR3 = Compare3;
+}
+
+/**
+ * @brief Sets the TIMx Capture Compare4 Register value
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param Compare4: specifies the Capture Compare4 register new value.
+ * @retval None
+ */
+void TIM_SetCompare4(TIM_TypeDef* TIMx, uint16_t Compare4)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ /* Set the Capture Compare4 Register value */
+ TIMx->CCR4 = Compare4;
+}
+
+/**
+ * @brief Sets the TIMx Input Capture 1 prescaler.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param TIM_ICPSC: specifies the Input Capture1 prescaler new value.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPSC_DIV1: no prescaler
+ * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
+ * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
+ * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
+ * @retval None
+ */
+void TIM_SetIC1Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC));
+ /* Reset the IC1PSC Bits */
+ TIMx->CCMR1 &= (uint16_t)~((uint16_t)TIM_CCMR1_IC1PSC);
+ /* Set the IC1PSC value */
+ TIMx->CCMR1 |= TIM_ICPSC;
+}
+
+/**
+ * @brief Sets the TIMx Input Capture 2 prescaler.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_ICPSC: specifies the Input Capture2 prescaler new value.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPSC_DIV1: no prescaler
+ * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
+ * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
+ * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
+ * @retval None
+ */
+void TIM_SetIC2Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC));
+ /* Reset the IC2PSC Bits */
+ TIMx->CCMR1 &= (uint16_t)~((uint16_t)TIM_CCMR1_IC2PSC);
+ /* Set the IC2PSC value */
+ TIMx->CCMR1 |= (uint16_t)(TIM_ICPSC << 8);
+}
+
+/**
+ * @brief Sets the TIMx Input Capture 3 prescaler.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_ICPSC: specifies the Input Capture3 prescaler new value.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPSC_DIV1: no prescaler
+ * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
+ * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
+ * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
+ * @retval None
+ */
+void TIM_SetIC3Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC));
+ /* Reset the IC3PSC Bits */
+ TIMx->CCMR2 &= (uint16_t)~((uint16_t)TIM_CCMR2_IC3PSC);
+ /* Set the IC3PSC value */
+ TIMx->CCMR2 |= TIM_ICPSC;
+}
+
+/**
+ * @brief Sets the TIMx Input Capture 4 prescaler.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_ICPSC: specifies the Input Capture4 prescaler new value.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPSC_DIV1: no prescaler
+ * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
+ * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
+ * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
+ * @retval None
+ */
+void TIM_SetIC4Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC));
+ /* Reset the IC4PSC Bits */
+ TIMx->CCMR2 &= (uint16_t)~((uint16_t)TIM_CCMR2_IC4PSC);
+ /* Set the IC4PSC value */
+ TIMx->CCMR2 |= (uint16_t)(TIM_ICPSC << 8);
+}
+
+/**
+ * @brief Sets the TIMx Clock Division value.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select
+ * the TIM peripheral.
+ * @param TIM_CKD: specifies the clock division value.
+ * This parameter can be one of the following value:
+ * @arg TIM_CKD_DIV1: TDTS = Tck_tim
+ * @arg TIM_CKD_DIV2: TDTS = 2*Tck_tim
+ * @arg TIM_CKD_DIV4: TDTS = 4*Tck_tim
+ * @retval None
+ */
+void TIM_SetClockDivision(TIM_TypeDef* TIMx, uint16_t TIM_CKD)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ assert_param(IS_TIM_CKD_DIV(TIM_CKD));
+ /* Reset the CKD Bits */
+ TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_CKD);
+ /* Set the CKD value */
+ TIMx->CR1 |= TIM_CKD;
+}
+
+/**
+ * @brief Gets the TIMx Input Capture 1 value.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @retval Capture Compare 1 Register value.
+ */
+uint16_t TIM_GetCapture1(TIM_TypeDef* TIMx)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST8_PERIPH(TIMx));
+ /* Get the Capture 1 Register value */
+ return TIMx->CCR1;
+}
+
+/**
+ * @brief Gets the TIMx Input Capture 2 value.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @retval Capture Compare 2 Register value.
+ */
+uint16_t TIM_GetCapture2(TIM_TypeDef* TIMx)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST6_PERIPH(TIMx));
+ /* Get the Capture 2 Register value */
+ return TIMx->CCR2;
+}
+
+/**
+ * @brief Gets the TIMx Input Capture 3 value.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @retval Capture Compare 3 Register value.
+ */
+uint16_t TIM_GetCapture3(TIM_TypeDef* TIMx)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ /* Get the Capture 3 Register value */
+ return TIMx->CCR3;
+}
+
+/**
+ * @brief Gets the TIMx Input Capture 4 value.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @retval Capture Compare 4 Register value.
+ */
+uint16_t TIM_GetCapture4(TIM_TypeDef* TIMx)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_LIST3_PERIPH(TIMx));
+ /* Get the Capture 4 Register value */
+ return TIMx->CCR4;
+}
+
+/**
+ * @brief Gets the TIMx Counter value.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @retval Counter Register value.
+ */
+uint16_t TIM_GetCounter(TIM_TypeDef* TIMx)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ /* Get the Counter Register value */
+ return TIMx->CNT;
+}
+
+/**
+ * @brief Gets the TIMx Prescaler value.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @retval Prescaler Register value.
+ */
+uint16_t TIM_GetPrescaler(TIM_TypeDef* TIMx)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ /* Get the Prescaler Register value */
+ return TIMx->PSC;
+}
+
+/**
+ * @brief Checks whether the specified TIM flag is set or not.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param TIM_FLAG: specifies the flag to check.
+ * This parameter can be one of the following values:
+ * @arg TIM_FLAG_Update: TIM update Flag
+ * @arg TIM_FLAG_CC1: TIM Capture Compare 1 Flag
+ * @arg TIM_FLAG_CC2: TIM Capture Compare 2 Flag
+ * @arg TIM_FLAG_CC3: TIM Capture Compare 3 Flag
+ * @arg TIM_FLAG_CC4: TIM Capture Compare 4 Flag
+ * @arg TIM_FLAG_COM: TIM Commutation Flag
+ * @arg TIM_FLAG_Trigger: TIM Trigger Flag
+ * @arg TIM_FLAG_Break: TIM Break Flag
+ * @arg TIM_FLAG_CC1OF: TIM Capture Compare 1 overcapture Flag
+ * @arg TIM_FLAG_CC2OF: TIM Capture Compare 2 overcapture Flag
+ * @arg TIM_FLAG_CC3OF: TIM Capture Compare 3 overcapture Flag
+ * @arg TIM_FLAG_CC4OF: TIM Capture Compare 4 overcapture Flag
+ * @note
+ * - TIM6 and TIM7 can have only one update flag.
+ * - TIM9, TIM12 and TIM15 can have only TIM_FLAG_Update, TIM_FLAG_CC1,
+ * TIM_FLAG_CC2 or TIM_FLAG_Trigger.
+ * - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_FLAG_Update or TIM_FLAG_CC1.
+ * - TIM_FLAG_Break is used only with TIM1, TIM8 and TIM15.
+ * - TIM_FLAG_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17.
+ * @retval The new state of TIM_FLAG (SET or RESET).
+ */
+FlagStatus TIM_GetFlagStatus(TIM_TypeDef* TIMx, uint16_t TIM_FLAG)
+{
+ ITStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_TIM_GET_FLAG(TIM_FLAG));
+
+ if ((TIMx->SR & TIM_FLAG) != (uint16_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the TIMx's pending flags.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param TIM_FLAG: specifies the flag bit to clear.
+ * This parameter can be any combination of the following values:
+ * @arg TIM_FLAG_Update: TIM update Flag
+ * @arg TIM_FLAG_CC1: TIM Capture Compare 1 Flag
+ * @arg TIM_FLAG_CC2: TIM Capture Compare 2 Flag
+ * @arg TIM_FLAG_CC3: TIM Capture Compare 3 Flag
+ * @arg TIM_FLAG_CC4: TIM Capture Compare 4 Flag
+ * @arg TIM_FLAG_COM: TIM Commutation Flag
+ * @arg TIM_FLAG_Trigger: TIM Trigger Flag
+ * @arg TIM_FLAG_Break: TIM Break Flag
+ * @arg TIM_FLAG_CC1OF: TIM Capture Compare 1 overcapture Flag
+ * @arg TIM_FLAG_CC2OF: TIM Capture Compare 2 overcapture Flag
+ * @arg TIM_FLAG_CC3OF: TIM Capture Compare 3 overcapture Flag
+ * @arg TIM_FLAG_CC4OF: TIM Capture Compare 4 overcapture Flag
+ * @note
+ * - TIM6 and TIM7 can have only one update flag.
+ * - TIM9, TIM12 and TIM15 can have only TIM_FLAG_Update, TIM_FLAG_CC1,
+ * TIM_FLAG_CC2 or TIM_FLAG_Trigger.
+ * - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_FLAG_Update or TIM_FLAG_CC1.
+ * - TIM_FLAG_Break is used only with TIM1, TIM8 and TIM15.
+ * - TIM_FLAG_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17.
+ * @retval None
+ */
+void TIM_ClearFlag(TIM_TypeDef* TIMx, uint16_t TIM_FLAG)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_TIM_CLEAR_FLAG(TIM_FLAG));
+
+ /* Clear the flags */
+ TIMx->SR = (uint16_t)~TIM_FLAG;
+}
+
+/**
+ * @brief Checks whether the TIM interrupt has occurred or not.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param TIM_IT: specifies the TIM interrupt source to check.
+ * This parameter can be one of the following values:
+ * @arg TIM_IT_Update: TIM update Interrupt source
+ * @arg TIM_IT_CC1: TIM Capture Compare 1 Interrupt source
+ * @arg TIM_IT_CC2: TIM Capture Compare 2 Interrupt source
+ * @arg TIM_IT_CC3: TIM Capture Compare 3 Interrupt source
+ * @arg TIM_IT_CC4: TIM Capture Compare 4 Interrupt source
+ * @arg TIM_IT_COM: TIM Commutation Interrupt source
+ * @arg TIM_IT_Trigger: TIM Trigger Interrupt source
+ * @arg TIM_IT_Break: TIM Break Interrupt source
+ * @note
+ * - TIM6 and TIM7 can generate only an update interrupt.
+ * - TIM9, TIM12 and TIM15 can have only TIM_IT_Update, TIM_IT_CC1,
+ * TIM_IT_CC2 or TIM_IT_Trigger.
+ * - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_IT_Update or TIM_IT_CC1.
+ * - TIM_IT_Break is used only with TIM1, TIM8 and TIM15.
+ * - TIM_IT_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17.
+ * @retval The new state of the TIM_IT(SET or RESET).
+ */
+ITStatus TIM_GetITStatus(TIM_TypeDef* TIMx, uint16_t TIM_IT)
+{
+ ITStatus bitstatus = RESET;
+ uint16_t itstatus = 0x0, itenable = 0x0;
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_TIM_GET_IT(TIM_IT));
+
+ itstatus = TIMx->SR & TIM_IT;
+
+ itenable = TIMx->DIER & TIM_IT;
+ if ((itstatus != (uint16_t)RESET) && (itenable != (uint16_t)RESET))
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the TIMx's interrupt pending bits.
+ * @param TIMx: where x can be 1 to 17 to select the TIM peripheral.
+ * @param TIM_IT: specifies the pending bit to clear.
+ * This parameter can be any combination of the following values:
+ * @arg TIM_IT_Update: TIM1 update Interrupt source
+ * @arg TIM_IT_CC1: TIM Capture Compare 1 Interrupt source
+ * @arg TIM_IT_CC2: TIM Capture Compare 2 Interrupt source
+ * @arg TIM_IT_CC3: TIM Capture Compare 3 Interrupt source
+ * @arg TIM_IT_CC4: TIM Capture Compare 4 Interrupt source
+ * @arg TIM_IT_COM: TIM Commutation Interrupt source
+ * @arg TIM_IT_Trigger: TIM Trigger Interrupt source
+ * @arg TIM_IT_Break: TIM Break Interrupt source
+ * @note
+ * - TIM6 and TIM7 can generate only an update interrupt.
+ * - TIM9, TIM12 and TIM15 can have only TIM_IT_Update, TIM_IT_CC1,
+ * TIM_IT_CC2 or TIM_IT_Trigger.
+ * - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_IT_Update or TIM_IT_CC1.
+ * - TIM_IT_Break is used only with TIM1, TIM8 and TIM15.
+ * - TIM_IT_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17.
+ * @retval None
+ */
+void TIM_ClearITPendingBit(TIM_TypeDef* TIMx, uint16_t TIM_IT)
+{
+ /* Check the parameters */
+ assert_param(IS_TIM_ALL_PERIPH(TIMx));
+ assert_param(IS_TIM_IT(TIM_IT));
+ /* Clear the IT pending Bit */
+ TIMx->SR = (uint16_t)~TIM_IT;
+}
+
+/**
+ * @brief Configure the TI1 as Input.
+ * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
+ * @param TIM_ICPolarity : The Input Polarity.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPolarity_Rising
+ * @arg TIM_ICPolarity_Falling
+ * @param TIM_ICSelection: specifies the input to be used.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICSelection_DirectTI: TIM Input 1 is selected to be connected to IC1.
+ * @arg TIM_ICSelection_IndirectTI: TIM Input 1 is selected to be connected to IC2.
+ * @arg TIM_ICSelection_TRC: TIM Input 1 is selected to be connected to TRC.
+ * @param TIM_ICFilter: Specifies the Input Capture Filter.
+ * This parameter must be a value between 0x00 and 0x0F.
+ * @retval None
+ */
+static void TI1_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
+ uint16_t TIM_ICFilter)
+{
+ uint16_t tmpccmr1 = 0, tmpccer = 0;
+ /* Disable the Channel 1: Reset the CC1E Bit */
+ TIMx->CCER &= (uint16_t)~((uint16_t)TIM_CCER_CC1E);
+ tmpccmr1 = TIMx->CCMR1;
+ tmpccer = TIMx->CCER;
+ /* Select the Input and set the filter */
+ tmpccmr1 &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCMR1_CC1S)) & ((uint16_t)~((uint16_t)TIM_CCMR1_IC1F)));
+ tmpccmr1 |= (uint16_t)(TIM_ICSelection | (uint16_t)(TIM_ICFilter << (uint16_t)4));
+
+ if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) ||
+ (TIMx == TIM4) ||(TIMx == TIM5))
+ {
+ /* Select the Polarity and set the CC1E Bit */
+ tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC1P));
+ tmpccer |= (uint16_t)(TIM_ICPolarity | (uint16_t)TIM_CCER_CC1E);
+ }
+ else
+ {
+ /* Select the Polarity and set the CC1E Bit */
+ tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC1P | TIM_CCER_CC1NP));
+ tmpccer |= (uint16_t)(TIM_ICPolarity | (uint16_t)TIM_CCER_CC1E);
+ }
+
+ /* Write to TIMx CCMR1 and CCER registers */
+ TIMx->CCMR1 = tmpccmr1;
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Configure the TI2 as Input.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral.
+ * @param TIM_ICPolarity : The Input Polarity.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPolarity_Rising
+ * @arg TIM_ICPolarity_Falling
+ * @param TIM_ICSelection: specifies the input to be used.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICSelection_DirectTI: TIM Input 2 is selected to be connected to IC2.
+ * @arg TIM_ICSelection_IndirectTI: TIM Input 2 is selected to be connected to IC1.
+ * @arg TIM_ICSelection_TRC: TIM Input 2 is selected to be connected to TRC.
+ * @param TIM_ICFilter: Specifies the Input Capture Filter.
+ * This parameter must be a value between 0x00 and 0x0F.
+ * @retval None
+ */
+static void TI2_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
+ uint16_t TIM_ICFilter)
+{
+ uint16_t tmpccmr1 = 0, tmpccer = 0, tmp = 0;
+ /* Disable the Channel 2: Reset the CC2E Bit */
+ TIMx->CCER &= (uint16_t)~((uint16_t)TIM_CCER_CC2E);
+ tmpccmr1 = TIMx->CCMR1;
+ tmpccer = TIMx->CCER;
+ tmp = (uint16_t)(TIM_ICPolarity << 4);
+ /* Select the Input and set the filter */
+ tmpccmr1 &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCMR1_CC2S)) & ((uint16_t)~((uint16_t)TIM_CCMR1_IC2F)));
+ tmpccmr1 |= (uint16_t)(TIM_ICFilter << 12);
+ tmpccmr1 |= (uint16_t)(TIM_ICSelection << 8);
+
+ if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) ||
+ (TIMx == TIM4) ||(TIMx == TIM5))
+ {
+ /* Select the Polarity and set the CC2E Bit */
+ tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC2P));
+ tmpccer |= (uint16_t)(tmp | (uint16_t)TIM_CCER_CC2E);
+ }
+ else
+ {
+ /* Select the Polarity and set the CC2E Bit */
+ tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC2P | TIM_CCER_CC2NP));
+ tmpccer |= (uint16_t)(TIM_ICPolarity | (uint16_t)TIM_CCER_CC2E);
+ }
+
+ /* Write to TIMx CCMR1 and CCER registers */
+ TIMx->CCMR1 = tmpccmr1 ;
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Configure the TI3 as Input.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_ICPolarity : The Input Polarity.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPolarity_Rising
+ * @arg TIM_ICPolarity_Falling
+ * @param TIM_ICSelection: specifies the input to be used.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICSelection_DirectTI: TIM Input 3 is selected to be connected to IC3.
+ * @arg TIM_ICSelection_IndirectTI: TIM Input 3 is selected to be connected to IC4.
+ * @arg TIM_ICSelection_TRC: TIM Input 3 is selected to be connected to TRC.
+ * @param TIM_ICFilter: Specifies the Input Capture Filter.
+ * This parameter must be a value between 0x00 and 0x0F.
+ * @retval None
+ */
+static void TI3_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
+ uint16_t TIM_ICFilter)
+{
+ uint16_t tmpccmr2 = 0, tmpccer = 0, tmp = 0;
+ /* Disable the Channel 3: Reset the CC3E Bit */
+ TIMx->CCER &= (uint16_t)~((uint16_t)TIM_CCER_CC3E);
+ tmpccmr2 = TIMx->CCMR2;
+ tmpccer = TIMx->CCER;
+ tmp = (uint16_t)(TIM_ICPolarity << 8);
+ /* Select the Input and set the filter */
+ tmpccmr2 &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCMR2_CC3S)) & ((uint16_t)~((uint16_t)TIM_CCMR2_IC3F)));
+ tmpccmr2 |= (uint16_t)(TIM_ICSelection | (uint16_t)(TIM_ICFilter << (uint16_t)4));
+
+ if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) ||
+ (TIMx == TIM4) ||(TIMx == TIM5))
+ {
+ /* Select the Polarity and set the CC3E Bit */
+ tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC3P));
+ tmpccer |= (uint16_t)(tmp | (uint16_t)TIM_CCER_CC3E);
+ }
+ else
+ {
+ /* Select the Polarity and set the CC3E Bit */
+ tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC3P | TIM_CCER_CC3NP));
+ tmpccer |= (uint16_t)(TIM_ICPolarity | (uint16_t)TIM_CCER_CC3E);
+ }
+
+ /* Write to TIMx CCMR2 and CCER registers */
+ TIMx->CCMR2 = tmpccmr2;
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @brief Configure the TI4 as Input.
+ * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
+ * @param TIM_ICPolarity : The Input Polarity.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICPolarity_Rising
+ * @arg TIM_ICPolarity_Falling
+ * @param TIM_ICSelection: specifies the input to be used.
+ * This parameter can be one of the following values:
+ * @arg TIM_ICSelection_DirectTI: TIM Input 4 is selected to be connected to IC4.
+ * @arg TIM_ICSelection_IndirectTI: TIM Input 4 is selected to be connected to IC3.
+ * @arg TIM_ICSelection_TRC: TIM Input 4 is selected to be connected to TRC.
+ * @param TIM_ICFilter: Specifies the Input Capture Filter.
+ * This parameter must be a value between 0x00 and 0x0F.
+ * @retval None
+ */
+static void TI4_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
+ uint16_t TIM_ICFilter)
+{
+ uint16_t tmpccmr2 = 0, tmpccer = 0, tmp = 0;
+
+ /* Disable the Channel 4: Reset the CC4E Bit */
+ TIMx->CCER &= (uint16_t)~((uint16_t)TIM_CCER_CC4E);
+ tmpccmr2 = TIMx->CCMR2;
+ tmpccer = TIMx->CCER;
+ tmp = (uint16_t)(TIM_ICPolarity << 12);
+ /* Select the Input and set the filter */
+ tmpccmr2 &= (uint16_t)((uint16_t)(~(uint16_t)TIM_CCMR2_CC4S) & ((uint16_t)~((uint16_t)TIM_CCMR2_IC4F)));
+ tmpccmr2 |= (uint16_t)(TIM_ICSelection << 8);
+ tmpccmr2 |= (uint16_t)(TIM_ICFilter << 12);
+
+ if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) ||
+ (TIMx == TIM4) ||(TIMx == TIM5))
+ {
+ /* Select the Polarity and set the CC4E Bit */
+ tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC4P));
+ tmpccer |= (uint16_t)(tmp | (uint16_t)TIM_CCER_CC4E);
+ }
+ else
+ {
+ /* Select the Polarity and set the CC4E Bit */
+ tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC3P | TIM_CCER_CC4NP));
+ tmpccer |= (uint16_t)(TIM_ICPolarity | (uint16_t)TIM_CCER_CC4E);
+ }
+ /* Write to TIMx CCMR2 and CCER registers */
+ TIMx->CCMR2 = tmpccmr2;
+ TIMx->CCER = tmpccer;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_usart.c b/st_fw_lib/src/stm32f10x_usart.c
new file mode 100644
index 0000000..e794eae
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_usart.c
@@ -0,0 +1,1058 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_usart.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the USART firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_usart.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup USART
+ * @brief USART driver modules
+ * @{
+ */
+
+/** @defgroup USART_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_Private_Defines
+ * @{
+ */
+
+#define CR1_UE_Set ((uint16_t)0x2000) /*!< USART Enable Mask */
+#define CR1_UE_Reset ((uint16_t)0xDFFF) /*!< USART Disable Mask */
+
+#define CR1_WAKE_Mask ((uint16_t)0xF7FF) /*!< USART WakeUp Method Mask */
+
+#define CR1_RWU_Set ((uint16_t)0x0002) /*!< USART mute mode Enable Mask */
+#define CR1_RWU_Reset ((uint16_t)0xFFFD) /*!< USART mute mode Enable Mask */
+#define CR1_SBK_Set ((uint16_t)0x0001) /*!< USART Break Character send Mask */
+#define CR1_CLEAR_Mask ((uint16_t)0xE9F3) /*!< USART CR1 Mask */
+#define CR2_Address_Mask ((uint16_t)0xFFF0) /*!< USART address Mask */
+
+#define CR2_LINEN_Set ((uint16_t)0x4000) /*!< USART LIN Enable Mask */
+#define CR2_LINEN_Reset ((uint16_t)0xBFFF) /*!< USART LIN Disable Mask */
+
+#define CR2_LBDL_Mask ((uint16_t)0xFFDF) /*!< USART LIN Break detection Mask */
+#define CR2_STOP_CLEAR_Mask ((uint16_t)0xCFFF) /*!< USART CR2 STOP Bits Mask */
+#define CR2_CLOCK_CLEAR_Mask ((uint16_t)0xF0FF) /*!< USART CR2 Clock Mask */
+
+#define CR3_SCEN_Set ((uint16_t)0x0020) /*!< USART SC Enable Mask */
+#define CR3_SCEN_Reset ((uint16_t)0xFFDF) /*!< USART SC Disable Mask */
+
+#define CR3_NACK_Set ((uint16_t)0x0010) /*!< USART SC NACK Enable Mask */
+#define CR3_NACK_Reset ((uint16_t)0xFFEF) /*!< USART SC NACK Disable Mask */
+
+#define CR3_HDSEL_Set ((uint16_t)0x0008) /*!< USART Half-Duplex Enable Mask */
+#define CR3_HDSEL_Reset ((uint16_t)0xFFF7) /*!< USART Half-Duplex Disable Mask */
+
+#define CR3_IRLP_Mask ((uint16_t)0xFFFB) /*!< USART IrDA LowPower mode Mask */
+#define CR3_CLEAR_Mask ((uint16_t)0xFCFF) /*!< USART CR3 Mask */
+
+#define CR3_IREN_Set ((uint16_t)0x0002) /*!< USART IrDA Enable Mask */
+#define CR3_IREN_Reset ((uint16_t)0xFFFD) /*!< USART IrDA Disable Mask */
+#define GTPR_LSB_Mask ((uint16_t)0x00FF) /*!< Guard Time Register LSB Mask */
+#define GTPR_MSB_Mask ((uint16_t)0xFF00) /*!< Guard Time Register MSB Mask */
+#define IT_Mask ((uint16_t)0x001F) /*!< USART Interrupt Mask */
+
+/* USART OverSampling-8 Mask */
+#define CR1_OVER8_Set ((u16)0x8000) /* USART OVER8 mode Enable Mask */
+#define CR1_OVER8_Reset ((u16)0x7FFF) /* USART OVER8 mode Disable Mask */
+
+/* USART One Bit Sampling Mask */
+#define CR3_ONEBITE_Set ((u16)0x0800) /* USART ONEBITE mode Enable Mask */
+#define CR3_ONEBITE_Reset ((u16)0xF7FF) /* USART ONEBITE mode Disable Mask */
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup USART_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the USARTx peripheral registers to their default reset values.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @retval None
+ */
+void USART_DeInit(USART_TypeDef* USARTx)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+
+ if (USARTx == USART1)
+ {
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, ENABLE);
+ RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, DISABLE);
+ }
+ else if (USARTx == USART2)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, DISABLE);
+ }
+ else if (USARTx == USART3)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, DISABLE);
+ }
+ else if (USARTx == UART4)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART4, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART4, DISABLE);
+ }
+ else
+ {
+ if (USARTx == UART5)
+ {
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, DISABLE);
+ }
+ }
+}
+
+/**
+ * @brief Initializes the USARTx peripheral according to the specified
+ * parameters in the USART_InitStruct .
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_InitStruct: pointer to a USART_InitTypeDef structure
+ * that contains the configuration information for the specified USART
+ * peripheral.
+ * @retval None
+ */
+void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct)
+{
+ uint32_t tmpreg = 0x00, apbclock = 0x00;
+ uint32_t integerdivider = 0x00;
+ uint32_t fractionaldivider = 0x00;
+ uint32_t usartxbase = 0;
+ RCC_ClocksTypeDef RCC_ClocksStatus;
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_BAUDRATE(USART_InitStruct->USART_BaudRate));
+ assert_param(IS_USART_WORD_LENGTH(USART_InitStruct->USART_WordLength));
+ assert_param(IS_USART_STOPBITS(USART_InitStruct->USART_StopBits));
+ assert_param(IS_USART_PARITY(USART_InitStruct->USART_Parity));
+ assert_param(IS_USART_MODE(USART_InitStruct->USART_Mode));
+ assert_param(IS_USART_HARDWARE_FLOW_CONTROL(USART_InitStruct->USART_HardwareFlowControl));
+ /* The hardware flow control is available only for USART1, USART2 and USART3 */
+ if (USART_InitStruct->USART_HardwareFlowControl != USART_HardwareFlowControl_None)
+ {
+ assert_param(IS_USART_123_PERIPH(USARTx));
+ }
+
+ usartxbase = (uint32_t)USARTx;
+
+/*---------------------------- USART CR2 Configuration -----------------------*/
+ tmpreg = USARTx->CR2;
+ /* Clear STOP[13:12] bits */
+ tmpreg &= CR2_STOP_CLEAR_Mask;
+ /* Configure the USART Stop Bits, Clock, CPOL, CPHA and LastBit ------------*/
+ /* Set STOP[13:12] bits according to USART_StopBits value */
+ tmpreg |= (uint32_t)USART_InitStruct->USART_StopBits;
+
+ /* Write to USART CR2 */
+ USARTx->CR2 = (uint16_t)tmpreg;
+
+/*---------------------------- USART CR1 Configuration -----------------------*/
+ tmpreg = USARTx->CR1;
+ /* Clear M, PCE, PS, TE and RE bits */
+ tmpreg &= CR1_CLEAR_Mask;
+ /* Configure the USART Word Length, Parity and mode ----------------------- */
+ /* Set the M bits according to USART_WordLength value */
+ /* Set PCE and PS bits according to USART_Parity value */
+ /* Set TE and RE bits according to USART_Mode value */
+ tmpreg |= (uint32_t)USART_InitStruct->USART_WordLength | USART_InitStruct->USART_Parity |
+ USART_InitStruct->USART_Mode;
+ /* Write to USART CR1 */
+ USARTx->CR1 = (uint16_t)tmpreg;
+
+/*---------------------------- USART CR3 Configuration -----------------------*/
+ tmpreg = USARTx->CR3;
+ /* Clear CTSE and RTSE bits */
+ tmpreg &= CR3_CLEAR_Mask;
+ /* Configure the USART HFC -------------------------------------------------*/
+ /* Set CTSE and RTSE bits according to USART_HardwareFlowControl value */
+ tmpreg |= USART_InitStruct->USART_HardwareFlowControl;
+ /* Write to USART CR3 */
+ USARTx->CR3 = (uint16_t)tmpreg;
+
+/*---------------------------- USART BRR Configuration -----------------------*/
+ /* Configure the USART Baud Rate -------------------------------------------*/
+ RCC_GetClocksFreq(&RCC_ClocksStatus);
+ if (usartxbase == USART1_BASE)
+ {
+ apbclock = RCC_ClocksStatus.PCLK2_Frequency;
+ }
+ else
+ {
+ apbclock = RCC_ClocksStatus.PCLK1_Frequency;
+ }
+
+ /* Determine the integer part */
+ if ((USARTx->CR1 & CR1_OVER8_Set) != 0)
+ {
+ /* Integer part computing in case Oversampling mode is 8 Samples */
+ integerdivider = ((25 * apbclock) / (2 * (USART_InitStruct->USART_BaudRate)));
+ }
+ else /* if ((USARTx->CR1 & CR1_OVER8_Set) == 0) */
+ {
+ /* Integer part computing in case Oversampling mode is 16 Samples */
+ integerdivider = ((25 * apbclock) / (4 * (USART_InitStruct->USART_BaudRate)));
+ }
+ tmpreg = (integerdivider / 100) << 4;
+
+ /* Determine the fractional part */
+ fractionaldivider = integerdivider - (100 * (tmpreg >> 4));
+
+ /* Implement the fractional part in the register */
+ if ((USARTx->CR1 & CR1_OVER8_Set) != 0)
+ {
+ tmpreg |= ((((fractionaldivider * 8) + 50) / 100)) & ((uint8_t)0x07);
+ }
+ else /* if ((USARTx->CR1 & CR1_OVER8_Set) == 0) */
+ {
+ tmpreg |= ((((fractionaldivider * 16) + 50) / 100)) & ((uint8_t)0x0F);
+ }
+
+ /* Write to USART BRR */
+ USARTx->BRR = (uint16_t)tmpreg;
+}
+
+/**
+ * @brief Fills each USART_InitStruct member with its default value.
+ * @param USART_InitStruct: pointer to a USART_InitTypeDef structure
+ * which will be initialized.
+ * @retval None
+ */
+void USART_StructInit(USART_InitTypeDef* USART_InitStruct)
+{
+ /* USART_InitStruct members default value */
+ USART_InitStruct->USART_BaudRate = 9600;
+ USART_InitStruct->USART_WordLength = USART_WordLength_8b;
+ USART_InitStruct->USART_StopBits = USART_StopBits_1;
+ USART_InitStruct->USART_Parity = USART_Parity_No ;
+ USART_InitStruct->USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
+ USART_InitStruct->USART_HardwareFlowControl = USART_HardwareFlowControl_None;
+}
+
+/**
+ * @brief Initializes the USARTx peripheral Clock according to the
+ * specified parameters in the USART_ClockInitStruct .
+ * @param USARTx: where x can be 1, 2, 3 to select the USART peripheral.
+ * @param USART_ClockInitStruct: pointer to a USART_ClockInitTypeDef
+ * structure that contains the configuration information for the specified
+ * USART peripheral.
+ * @note The Smart Card and Synchronous modes are not available for UART4 and UART5.
+ * @retval None
+ */
+void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct)
+{
+ uint32_t tmpreg = 0x00;
+ /* Check the parameters */
+ assert_param(IS_USART_123_PERIPH(USARTx));
+ assert_param(IS_USART_CLOCK(USART_ClockInitStruct->USART_Clock));
+ assert_param(IS_USART_CPOL(USART_ClockInitStruct->USART_CPOL));
+ assert_param(IS_USART_CPHA(USART_ClockInitStruct->USART_CPHA));
+ assert_param(IS_USART_LASTBIT(USART_ClockInitStruct->USART_LastBit));
+
+/*---------------------------- USART CR2 Configuration -----------------------*/
+ tmpreg = USARTx->CR2;
+ /* Clear CLKEN, CPOL, CPHA and LBCL bits */
+ tmpreg &= CR2_CLOCK_CLEAR_Mask;
+ /* Configure the USART Clock, CPOL, CPHA and LastBit ------------*/
+ /* Set CLKEN bit according to USART_Clock value */
+ /* Set CPOL bit according to USART_CPOL value */
+ /* Set CPHA bit according to USART_CPHA value */
+ /* Set LBCL bit according to USART_LastBit value */
+ tmpreg |= (uint32_t)USART_ClockInitStruct->USART_Clock | USART_ClockInitStruct->USART_CPOL |
+ USART_ClockInitStruct->USART_CPHA | USART_ClockInitStruct->USART_LastBit;
+ /* Write to USART CR2 */
+ USARTx->CR2 = (uint16_t)tmpreg;
+}
+
+/**
+ * @brief Fills each USART_ClockInitStruct member with its default value.
+ * @param USART_ClockInitStruct: pointer to a USART_ClockInitTypeDef
+ * structure which will be initialized.
+ * @retval None
+ */
+void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct)
+{
+ /* USART_ClockInitStruct members default value */
+ USART_ClockInitStruct->USART_Clock = USART_Clock_Disable;
+ USART_ClockInitStruct->USART_CPOL = USART_CPOL_Low;
+ USART_ClockInitStruct->USART_CPHA = USART_CPHA_1Edge;
+ USART_ClockInitStruct->USART_LastBit = USART_LastBit_Disable;
+}
+
+/**
+ * @brief Enables or disables the specified USART peripheral.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param NewState: new state of the USARTx peripheral.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the selected USART by setting the UE bit in the CR1 register */
+ USARTx->CR1 |= CR1_UE_Set;
+ }
+ else
+ {
+ /* Disable the selected USART by clearing the UE bit in the CR1 register */
+ USARTx->CR1 &= CR1_UE_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the specified USART interrupts.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_IT: specifies the USART interrupt sources to be enabled or disabled.
+ * This parameter can be one of the following values:
+ * @arg USART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
+ * @arg USART_IT_LBD: LIN Break detection interrupt
+ * @arg USART_IT_TXE: Transmit Data Register empty interrupt
+ * @arg USART_IT_TC: Transmission complete interrupt
+ * @arg USART_IT_RXNE: Receive Data register not empty interrupt
+ * @arg USART_IT_IDLE: Idle line detection interrupt
+ * @arg USART_IT_PE: Parity Error interrupt
+ * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
+ * @param NewState: new state of the specified USARTx interrupts.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState)
+{
+ uint32_t usartreg = 0x00, itpos = 0x00, itmask = 0x00;
+ uint32_t usartxbase = 0x00;
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_CONFIG_IT(USART_IT));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ /* The CTS interrupt is not available for UART4 and UART5 */
+ if (USART_IT == USART_IT_CTS)
+ {
+ assert_param(IS_USART_123_PERIPH(USARTx));
+ }
+
+ usartxbase = (uint32_t)USARTx;
+
+ /* Get the USART register index */
+ usartreg = (((uint8_t)USART_IT) >> 0x05);
+
+ /* Get the interrupt position */
+ itpos = USART_IT & IT_Mask;
+ itmask = (((uint32_t)0x01) << itpos);
+
+ if (usartreg == 0x01) /* The IT is in CR1 register */
+ {
+ usartxbase += 0x0C;
+ }
+ else if (usartreg == 0x02) /* The IT is in CR2 register */
+ {
+ usartxbase += 0x10;
+ }
+ else /* The IT is in CR3 register */
+ {
+ usartxbase += 0x14;
+ }
+ if (NewState != DISABLE)
+ {
+ *(__IO uint32_t*)usartxbase |= itmask;
+ }
+ else
+ {
+ *(__IO uint32_t*)usartxbase &= ~itmask;
+ }
+}
+
+/**
+ * @brief Enables or disables the USARTs DMA interface.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_DMAReq: specifies the DMA request.
+ * This parameter can be any combination of the following values:
+ * @arg USART_DMAReq_Tx: USART DMA transmit request
+ * @arg USART_DMAReq_Rx: USART DMA receive request
+ * @param NewState: new state of the DMA Request sources.
+ * This parameter can be: ENABLE or DISABLE.
+ * @note The DMA mode is not available for UART5 except in the STM32
+ * High density value line devices(STM32F10X_HD_VL).
+ * @retval None
+ */
+void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_DMAREQ(USART_DMAReq));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the DMA transfer for selected requests by setting the DMAT and/or
+ DMAR bits in the USART CR3 register */
+ USARTx->CR3 |= USART_DMAReq;
+ }
+ else
+ {
+ /* Disable the DMA transfer for selected requests by clearing the DMAT and/or
+ DMAR bits in the USART CR3 register */
+ USARTx->CR3 &= (uint16_t)~USART_DMAReq;
+ }
+}
+
+/**
+ * @brief Sets the address of the USART node.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_Address: Indicates the address of the USART node.
+ * @retval None
+ */
+void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_ADDRESS(USART_Address));
+
+ /* Clear the USART address */
+ USARTx->CR2 &= CR2_Address_Mask;
+ /* Set the USART address node */
+ USARTx->CR2 |= USART_Address;
+}
+
+/**
+ * @brief Selects the USART WakeUp method.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_WakeUp: specifies the USART wakeup method.
+ * This parameter can be one of the following values:
+ * @arg USART_WakeUp_IdleLine: WakeUp by an idle line detection
+ * @arg USART_WakeUp_AddressMark: WakeUp by an address mark
+ * @retval None
+ */
+void USART_WakeUpConfig(USART_TypeDef* USARTx, uint16_t USART_WakeUp)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_WAKEUP(USART_WakeUp));
+
+ USARTx->CR1 &= CR1_WAKE_Mask;
+ USARTx->CR1 |= USART_WakeUp;
+}
+
+/**
+ * @brief Determines if the USART is in mute mode or not.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param NewState: new state of the USART mute mode.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the USART mute mode by setting the RWU bit in the CR1 register */
+ USARTx->CR1 |= CR1_RWU_Set;
+ }
+ else
+ {
+ /* Disable the USART mute mode by clearing the RWU bit in the CR1 register */
+ USARTx->CR1 &= CR1_RWU_Reset;
+ }
+}
+
+/**
+ * @brief Sets the USART LIN Break detection length.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_LINBreakDetectLength: specifies the LIN break detection length.
+ * This parameter can be one of the following values:
+ * @arg USART_LINBreakDetectLength_10b: 10-bit break detection
+ * @arg USART_LINBreakDetectLength_11b: 11-bit break detection
+ * @retval None
+ */
+void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint16_t USART_LINBreakDetectLength)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_LIN_BREAK_DETECT_LENGTH(USART_LINBreakDetectLength));
+
+ USARTx->CR2 &= CR2_LBDL_Mask;
+ USARTx->CR2 |= USART_LINBreakDetectLength;
+}
+
+/**
+ * @brief Enables or disables the USARTs LIN mode.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param NewState: new state of the USART LIN mode.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the LIN mode by setting the LINEN bit in the CR2 register */
+ USARTx->CR2 |= CR2_LINEN_Set;
+ }
+ else
+ {
+ /* Disable the LIN mode by clearing the LINEN bit in the CR2 register */
+ USARTx->CR2 &= CR2_LINEN_Reset;
+ }
+}
+
+/**
+ * @brief Transmits single data through the USARTx peripheral.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param Data: the data to transmit.
+ * @retval None
+ */
+void USART_SendData(USART_TypeDef* USARTx, uint16_t Data)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_DATA(Data));
+
+ /* Transmit Data */
+ USARTx->DR = (Data & (uint16_t)0x01FF);
+}
+
+/**
+ * @brief Returns the most recent received data by the USARTx peripheral.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @retval The received data.
+ */
+uint16_t USART_ReceiveData(USART_TypeDef* USARTx)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+
+ /* Receive Data */
+ return (uint16_t)(USARTx->DR & (uint16_t)0x01FF);
+}
+
+/**
+ * @brief Transmits break characters.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @retval None
+ */
+void USART_SendBreak(USART_TypeDef* USARTx)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+
+ /* Send break characters */
+ USARTx->CR1 |= CR1_SBK_Set;
+}
+
+/**
+ * @brief Sets the specified USART guard time.
+ * @param USARTx: where x can be 1, 2 or 3 to select the USART peripheral.
+ * @param USART_GuardTime: specifies the guard time.
+ * @note The guard time bits are not available for UART4 and UART5.
+ * @retval None
+ */
+void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_123_PERIPH(USARTx));
+
+ /* Clear the USART Guard time */
+ USARTx->GTPR &= GTPR_LSB_Mask;
+ /* Set the USART guard time */
+ USARTx->GTPR |= (uint16_t)((uint16_t)USART_GuardTime << 0x08);
+}
+
+/**
+ * @brief Sets the system clock prescaler.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_Prescaler: specifies the prescaler clock.
+ * @note The function is used for IrDA mode with UART4 and UART5.
+ * @retval None
+ */
+void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+
+ /* Clear the USART prescaler */
+ USARTx->GTPR &= GTPR_MSB_Mask;
+ /* Set the USART prescaler */
+ USARTx->GTPR |= USART_Prescaler;
+}
+
+/**
+ * @brief Enables or disables the USARTs Smart Card mode.
+ * @param USARTx: where x can be 1, 2 or 3 to select the USART peripheral.
+ * @param NewState: new state of the Smart Card mode.
+ * This parameter can be: ENABLE or DISABLE.
+ * @note The Smart Card mode is not available for UART4 and UART5.
+ * @retval None
+ */
+void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_123_PERIPH(USARTx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the SC mode by setting the SCEN bit in the CR3 register */
+ USARTx->CR3 |= CR3_SCEN_Set;
+ }
+ else
+ {
+ /* Disable the SC mode by clearing the SCEN bit in the CR3 register */
+ USARTx->CR3 &= CR3_SCEN_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables NACK transmission.
+ * @param USARTx: where x can be 1, 2 or 3 to select the USART peripheral.
+ * @param NewState: new state of the NACK transmission.
+ * This parameter can be: ENABLE or DISABLE.
+ * @note The Smart Card mode is not available for UART4 and UART5.
+ * @retval None
+ */
+void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_123_PERIPH(USARTx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+ if (NewState != DISABLE)
+ {
+ /* Enable the NACK transmission by setting the NACK bit in the CR3 register */
+ USARTx->CR3 |= CR3_NACK_Set;
+ }
+ else
+ {
+ /* Disable the NACK transmission by clearing the NACK bit in the CR3 register */
+ USARTx->CR3 &= CR3_NACK_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the USARTs Half Duplex communication.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param NewState: new state of the USART Communication.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the Half-Duplex mode by setting the HDSEL bit in the CR3 register */
+ USARTx->CR3 |= CR3_HDSEL_Set;
+ }
+ else
+ {
+ /* Disable the Half-Duplex mode by clearing the HDSEL bit in the CR3 register */
+ USARTx->CR3 &= CR3_HDSEL_Reset;
+ }
+}
+
+
+/**
+ * @brief Enables or disables the USART's 8x oversampling mode.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param NewState: new state of the USART one bit sampling method.
+ * This parameter can be: ENABLE or DISABLE.
+ * @note
+ * This function has to be called before calling USART_Init()
+ * function in order to have correct baudrate Divider value.
+ * @retval None
+ */
+void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the 8x Oversampling mode by setting the OVER8 bit in the CR1 register */
+ USARTx->CR1 |= CR1_OVER8_Set;
+ }
+ else
+ {
+ /* Disable the 8x Oversampling mode by clearing the OVER8 bit in the CR1 register */
+ USARTx->CR1 &= CR1_OVER8_Reset;
+ }
+}
+
+/**
+ * @brief Enables or disables the USART's one bit sampling method.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param NewState: new state of the USART one bit sampling method.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the one bit method by setting the ONEBITE bit in the CR3 register */
+ USARTx->CR3 |= CR3_ONEBITE_Set;
+ }
+ else
+ {
+ /* Disable tthe one bit method by clearing the ONEBITE bit in the CR3 register */
+ USARTx->CR3 &= CR3_ONEBITE_Reset;
+ }
+}
+
+/**
+ * @brief Configures the USART's IrDA interface.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_IrDAMode: specifies the IrDA mode.
+ * This parameter can be one of the following values:
+ * @arg USART_IrDAMode_LowPower
+ * @arg USART_IrDAMode_Normal
+ * @retval None
+ */
+void USART_IrDAConfig(USART_TypeDef* USARTx, uint16_t USART_IrDAMode)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_IRDA_MODE(USART_IrDAMode));
+
+ USARTx->CR3 &= CR3_IRLP_Mask;
+ USARTx->CR3 |= USART_IrDAMode;
+}
+
+/**
+ * @brief Enables or disables the USART's IrDA interface.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param NewState: new state of the IrDA mode.
+ * This parameter can be: ENABLE or DISABLE.
+ * @retval None
+ */
+void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_FUNCTIONAL_STATE(NewState));
+
+ if (NewState != DISABLE)
+ {
+ /* Enable the IrDA mode by setting the IREN bit in the CR3 register */
+ USARTx->CR3 |= CR3_IREN_Set;
+ }
+ else
+ {
+ /* Disable the IrDA mode by clearing the IREN bit in the CR3 register */
+ USARTx->CR3 &= CR3_IREN_Reset;
+ }
+}
+
+/**
+ * @brief Checks whether the specified USART flag is set or not.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_FLAG: specifies the flag to check.
+ * This parameter can be one of the following values:
+ * @arg USART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5)
+ * @arg USART_FLAG_LBD: LIN Break detection flag
+ * @arg USART_FLAG_TXE: Transmit data register empty flag
+ * @arg USART_FLAG_TC: Transmission Complete flag
+ * @arg USART_FLAG_RXNE: Receive data register not empty flag
+ * @arg USART_FLAG_IDLE: Idle Line detection flag
+ * @arg USART_FLAG_ORE: OverRun Error flag
+ * @arg USART_FLAG_NE: Noise Error flag
+ * @arg USART_FLAG_FE: Framing Error flag
+ * @arg USART_FLAG_PE: Parity Error flag
+ * @retval The new state of USART_FLAG (SET or RESET).
+ */
+FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG)
+{
+ FlagStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_FLAG(USART_FLAG));
+ /* The CTS flag is not available for UART4 and UART5 */
+ if (USART_FLAG == USART_FLAG_CTS)
+ {
+ assert_param(IS_USART_123_PERIPH(USARTx));
+ }
+
+ if ((USARTx->SR & USART_FLAG) != (uint16_t)RESET)
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the USARTx's pending flags.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_FLAG: specifies the flag to clear.
+ * This parameter can be any combination of the following values:
+ * @arg USART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5).
+ * @arg USART_FLAG_LBD: LIN Break detection flag.
+ * @arg USART_FLAG_TC: Transmission Complete flag.
+ * @arg USART_FLAG_RXNE: Receive data register not empty flag.
+ *
+ * @note
+ * - PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun
+ * error) and IDLE (Idle line detected) flags are cleared by software
+ * sequence: a read operation to USART_SR register (USART_GetFlagStatus())
+ * followed by a read operation to USART_DR register (USART_ReceiveData()).
+ * - RXNE flag can be also cleared by a read to the USART_DR register
+ * (USART_ReceiveData()).
+ * - TC flag can be also cleared by software sequence: a read operation to
+ * USART_SR register (USART_GetFlagStatus()) followed by a write operation
+ * to USART_DR register (USART_SendData()).
+ * - TXE flag is cleared only by a write to the USART_DR register
+ * (USART_SendData()).
+ * @retval None
+ */
+void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG)
+{
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_CLEAR_FLAG(USART_FLAG));
+ /* The CTS flag is not available for UART4 and UART5 */
+ if ((USART_FLAG & USART_FLAG_CTS) == USART_FLAG_CTS)
+ {
+ assert_param(IS_USART_123_PERIPH(USARTx));
+ }
+
+ USARTx->SR = (uint16_t)~USART_FLAG;
+}
+
+/**
+ * @brief Checks whether the specified USART interrupt has occurred or not.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_IT: specifies the USART interrupt source to check.
+ * This parameter can be one of the following values:
+ * @arg USART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
+ * @arg USART_IT_LBD: LIN Break detection interrupt
+ * @arg USART_IT_TXE: Tansmit Data Register empty interrupt
+ * @arg USART_IT_TC: Transmission complete interrupt
+ * @arg USART_IT_RXNE: Receive Data register not empty interrupt
+ * @arg USART_IT_IDLE: Idle line detection interrupt
+ * @arg USART_IT_ORE: OverRun Error interrupt
+ * @arg USART_IT_NE: Noise Error interrupt
+ * @arg USART_IT_FE: Framing Error interrupt
+ * @arg USART_IT_PE: Parity Error interrupt
+ * @retval The new state of USART_IT (SET or RESET).
+ */
+ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT)
+{
+ uint32_t bitpos = 0x00, itmask = 0x00, usartreg = 0x00;
+ ITStatus bitstatus = RESET;
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_GET_IT(USART_IT));
+ /* The CTS interrupt is not available for UART4 and UART5 */
+ if (USART_IT == USART_IT_CTS)
+ {
+ assert_param(IS_USART_123_PERIPH(USARTx));
+ }
+
+ /* Get the USART register index */
+ usartreg = (((uint8_t)USART_IT) >> 0x05);
+ /* Get the interrupt position */
+ itmask = USART_IT & IT_Mask;
+ itmask = (uint32_t)0x01 << itmask;
+
+ if (usartreg == 0x01) /* The IT is in CR1 register */
+ {
+ itmask &= USARTx->CR1;
+ }
+ else if (usartreg == 0x02) /* The IT is in CR2 register */
+ {
+ itmask &= USARTx->CR2;
+ }
+ else /* The IT is in CR3 register */
+ {
+ itmask &= USARTx->CR3;
+ }
+
+ bitpos = USART_IT >> 0x08;
+ bitpos = (uint32_t)0x01 << bitpos;
+ bitpos &= USARTx->SR;
+ if ((itmask != (uint16_t)RESET)&&(bitpos != (uint16_t)RESET))
+ {
+ bitstatus = SET;
+ }
+ else
+ {
+ bitstatus = RESET;
+ }
+
+ return bitstatus;
+}
+
+/**
+ * @brief Clears the USARTx's interrupt pending bits.
+ * @param USARTx: Select the USART or the UART peripheral.
+ * This parameter can be one of the following values:
+ * USART1, USART2, USART3, UART4 or UART5.
+ * @param USART_IT: specifies the interrupt pending bit to clear.
+ * This parameter can be one of the following values:
+ * @arg USART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
+ * @arg USART_IT_LBD: LIN Break detection interrupt
+ * @arg USART_IT_TC: Transmission complete interrupt.
+ * @arg USART_IT_RXNE: Receive Data register not empty interrupt.
+ *
+ * @note
+ * - PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun
+ * error) and IDLE (Idle line detected) pending bits are cleared by
+ * software sequence: a read operation to USART_SR register
+ * (USART_GetITStatus()) followed by a read operation to USART_DR register
+ * (USART_ReceiveData()).
+ * - RXNE pending bit can be also cleared by a read to the USART_DR register
+ * (USART_ReceiveData()).
+ * - TC pending bit can be also cleared by software sequence: a read
+ * operation to USART_SR register (USART_GetITStatus()) followed by a write
+ * operation to USART_DR register (USART_SendData()).
+ * - TXE pending bit is cleared only by a write to the USART_DR register
+ * (USART_SendData()).
+ * @retval None
+ */
+void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT)
+{
+ uint16_t bitpos = 0x00, itmask = 0x00;
+ /* Check the parameters */
+ assert_param(IS_USART_ALL_PERIPH(USARTx));
+ assert_param(IS_USART_CLEAR_IT(USART_IT));
+ /* The CTS interrupt is not available for UART4 and UART5 */
+ if (USART_IT == USART_IT_CTS)
+ {
+ assert_param(IS_USART_123_PERIPH(USARTx));
+ }
+
+ bitpos = USART_IT >> 0x08;
+ itmask = ((uint16_t)0x01 << (uint16_t)bitpos);
+ USARTx->SR = (uint16_t)~itmask;
+}
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/src/stm32f10x_wwdg.c b/st_fw_lib/src/stm32f10x_wwdg.c
new file mode 100644
index 0000000..4a901e4
--- /dev/null
+++ b/st_fw_lib/src/stm32f10x_wwdg.c
@@ -0,0 +1,224 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x_wwdg.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief This file provides all the WWDG firmware functions.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_wwdg.h"
+#include "stm32f10x_rcc.h"
+
+/** @addtogroup STM32F10x_StdPeriph_Driver
+ * @{
+ */
+
+/** @defgroup WWDG
+ * @brief WWDG driver modules
+ * @{
+ */
+
+/** @defgroup WWDG_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup WWDG_Private_Defines
+ * @{
+ */
+
+/* ----------- WWDG registers bit address in the alias region ----------- */
+#define WWDG_OFFSET (WWDG_BASE - PERIPH_BASE)
+
+/* Alias word address of EWI bit */
+#define CFR_OFFSET (WWDG_OFFSET + 0x04)
+#define EWI_BitNumber 0x09
+#define CFR_EWI_BB (PERIPH_BB_BASE + (CFR_OFFSET * 32) + (EWI_BitNumber * 4))
+
+/* --------------------- WWDG registers bit mask ------------------------ */
+
+/* CR register bit mask */
+#define CR_WDGA_Set ((uint32_t)0x00000080)
+
+/* CFR register bit mask */
+#define CFR_WDGTB_Mask ((uint32_t)0xFFFFFE7F)
+#define CFR_W_Mask ((uint32_t)0xFFFFFF80)
+#define BIT_Mask ((uint8_t)0x7F)
+
+/**
+ * @}
+ */
+
+/** @defgroup WWDG_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup WWDG_Private_Variables
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup WWDG_Private_FunctionPrototypes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @defgroup WWDG_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Deinitializes the WWDG peripheral registers to their default reset values.
+ * @param None
+ * @retval None
+ */
+void WWDG_DeInit(void)
+{
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, ENABLE);
+ RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, DISABLE);
+}
+
+/**
+ * @brief Sets the WWDG Prescaler.
+ * @param WWDG_Prescaler: specifies the WWDG Prescaler.
+ * This parameter can be one of the following values:
+ * @arg WWDG_Prescaler_1: WWDG counter clock = (PCLK1/4096)/1
+ * @arg WWDG_Prescaler_2: WWDG counter clock = (PCLK1/4096)/2
+ * @arg WWDG_Prescaler_4: WWDG counter clock = (PCLK1/4096)/4
+ * @arg WWDG_Prescaler_8: WWDG counter clock = (PCLK1/4096)/8
+ * @retval None
+ */
+void WWDG_SetPrescaler(uint32_t WWDG_Prescaler)
+{
+ uint32_t tmpreg = 0;
+ /* Check the parameters */
+ assert_param(IS_WWDG_PRESCALER(WWDG_Prescaler));
+ /* Clear WDGTB[1:0] bits */
+ tmpreg = WWDG->CFR & CFR_WDGTB_Mask;
+ /* Set WDGTB[1:0] bits according to WWDG_Prescaler value */
+ tmpreg |= WWDG_Prescaler;
+ /* Store the new value */
+ WWDG->CFR = tmpreg;
+}
+
+/**
+ * @brief Sets the WWDG window value.
+ * @param WindowValue: specifies the window value to be compared to the downcounter.
+ * This parameter value must be lower than 0x80.
+ * @retval None
+ */
+void WWDG_SetWindowValue(uint8_t WindowValue)
+{
+ __IO uint32_t tmpreg = 0;
+
+ /* Check the parameters */
+ assert_param(IS_WWDG_WINDOW_VALUE(WindowValue));
+ /* Clear W[6:0] bits */
+
+ tmpreg = WWDG->CFR & CFR_W_Mask;
+
+ /* Set W[6:0] bits according to WindowValue value */
+ tmpreg |= WindowValue & (uint32_t) BIT_Mask;
+
+ /* Store the new value */
+ WWDG->CFR = tmpreg;
+}
+
+/**
+ * @brief Enables the WWDG Early Wakeup interrupt(EWI).
+ * @param None
+ * @retval None
+ */
+void WWDG_EnableIT(void)
+{
+ *(__IO uint32_t *) CFR_EWI_BB = (uint32_t)ENABLE;
+}
+
+/**
+ * @brief Sets the WWDG counter value.
+ * @param Counter: specifies the watchdog counter value.
+ * This parameter must be a number between 0x40 and 0x7F.
+ * @retval None
+ */
+void WWDG_SetCounter(uint8_t Counter)
+{
+ /* Check the parameters */
+ assert_param(IS_WWDG_COUNTER(Counter));
+ /* Write to T[6:0] bits to configure the counter value, no need to do
+ a read-modify-write; writing a 0 to WDGA bit does nothing */
+ WWDG->CR = Counter & BIT_Mask;
+}
+
+/**
+ * @brief Enables WWDG and load the counter value.
+ * @param Counter: specifies the watchdog counter value.
+ * This parameter must be a number between 0x40 and 0x7F.
+ * @retval None
+ */
+void WWDG_Enable(uint8_t Counter)
+{
+ /* Check the parameters */
+ assert_param(IS_WWDG_COUNTER(Counter));
+ WWDG->CR = CR_WDGA_Set | Counter;
+}
+
+/**
+ * @brief Checks whether the Early Wakeup interrupt flag is set or not.
+ * @param None
+ * @retval The new state of the Early Wakeup interrupt flag (SET or RESET)
+ */
+FlagStatus WWDG_GetFlagStatus(void)
+{
+ return (FlagStatus)(WWDG->SR);
+}
+
+/**
+ * @brief Clears Early Wakeup interrupt flag.
+ * @param None
+ * @retval None
+ */
+void WWDG_ClearFlag(void)
+{
+ WWDG->SR = (uint32_t)RESET;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/startup_stm32f10x_hd.s b/st_fw_lib/startup_stm32f10x_hd.s
new file mode 100644
index 0000000..baab28a
--- /dev/null
+++ b/st_fw_lib/startup_stm32f10x_hd.s
@@ -0,0 +1,358 @@
+;******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
+;* File Name : startup_stm32f10x_hd.s
+;* Author : MCD Application Team
+;* Version : V3.5.0
+;* Date : 11-March-2011
+;* Description : STM32F10x High Density Devices vector table for MDK-ARM
+;* toolchain.
+;* This module performs:
+;* - Set the initial SP
+;* - Set the initial PC == Reset_Handler
+;* - Set the vector table entries with the exceptions ISR address
+;* - Configure the clock system and also configure the external
+;* SRAM mounted on STM3210E-EVAL board to be used as data
+;* memory (optional, to be enabled by user)
+;* - Branches to __main in the C library (which eventually
+;* calls main()).
+;* After Reset the CortexM3 processor is in Thread mode,
+;* priority is Privileged, and the Stack is set to Main.
+;* <<< Use Configuration Wizard in Context Menu >>>
+;*******************************************************************************
+; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+;*******************************************************************************
+
+; Amount of memory (in bytes) allocated for Stack
+; Tailor this value to your application needs
+; <h> Stack Configuration
+; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
+; </h>
+
+Stack_Size EQU 0x00003000
+
+ AREA STACK, NOINIT, READWRITE, ALIGN=3
+Stack_Mem SPACE Stack_Size
+__initial_sp
+
+; <h> Heap Configuration
+; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
+; </h>
+
+Heap_Size EQU 0x00000000
+
+ AREA HEAP, NOINIT, READWRITE, ALIGN=3
+__heap_base
+Heap_Mem SPACE Heap_Size
+__heap_limit
+
+ PRESERVE8
+ THUMB
+
+
+; Vector Table Mapped to Address 0 at Reset
+ AREA RESET, DATA, READONLY
+ EXPORT __Vectors
+ EXPORT __Vectors_End
+ EXPORT __Vectors_Size
+
+__Vectors DCD __initial_sp ; Top of Stack
+ DCD Reset_Handler ; Reset Handler
+ DCD NMI_Handler ; NMI Handler
+ DCD HardFault_Handler ; Hard Fault Handler
+ DCD MemManage_Handler ; MPU Fault Handler
+ DCD BusFault_Handler ; Bus Fault Handler
+ DCD UsageFault_Handler ; Usage Fault Handler
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD 0 ; Reserved
+ DCD SVC_Handler ; SVCall Handler
+ DCD DebugMon_Handler ; Debug Monitor Handler
+ DCD 0 ; Reserved
+ DCD PendSV_Handler ; PendSV Handler
+ DCD SysTick_Handler ; SysTick Handler
+
+ ; External Interrupts
+ DCD WWDG_IRQHandler ; Window Watchdog
+ DCD PVD_IRQHandler ; PVD through EXTI Line detect
+ DCD TAMPER_IRQHandler ; Tamper
+ DCD RTC_IRQHandler ; RTC
+ DCD FLASH_IRQHandler ; Flash
+ DCD RCC_IRQHandler ; RCC
+ DCD EXTI0_IRQHandler ; EXTI Line 0
+ DCD EXTI1_IRQHandler ; EXTI Line 1
+ DCD EXTI2_IRQHandler ; EXTI Line 2
+ DCD EXTI3_IRQHandler ; EXTI Line 3
+ DCD EXTI4_IRQHandler ; EXTI Line 4
+ DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
+ DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
+ DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
+ DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
+ DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
+ DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
+ DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
+ DCD ADC1_2_IRQHandler ; ADC1 & ADC2
+ DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
+ DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
+ DCD CAN1_RX1_IRQHandler ; CAN1 RX1
+ DCD CAN1_SCE_IRQHandler ; CAN1 SCE
+ DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
+ DCD TIM1_BRK_IRQHandler ; TIM1 Break
+ DCD TIM1_UP_IRQHandler ; TIM1 Update
+ DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
+ DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
+ DCD TIM2_IRQHandler ; TIM2
+ DCD TIM3_IRQHandler ; TIM3
+ DCD TIM4_IRQHandler ; TIM4
+ DCD I2C1_EV_IRQHandler ; I2C1 Event
+ DCD I2C1_ER_IRQHandler ; I2C1 Error
+ DCD I2C2_EV_IRQHandler ; I2C2 Event
+ DCD I2C2_ER_IRQHandler ; I2C2 Error
+ DCD SPI1_IRQHandler ; SPI1
+ DCD SPI2_IRQHandler ; SPI2
+ DCD USART1_IRQHandler ; USART1
+ DCD USART2_IRQHandler ; USART2
+ DCD USART3_IRQHandler ; USART3
+ DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
+ DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line
+ DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
+ DCD TIM8_BRK_IRQHandler ; TIM8 Break
+ DCD TIM8_UP_IRQHandler ; TIM8 Update
+ DCD TIM8_TRG_COM_IRQHandler ; TIM8 Trigger and Commutation
+ DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
+ DCD ADC3_IRQHandler ; ADC3
+ DCD FSMC_IRQHandler ; FSMC
+ DCD SDIO_IRQHandler ; SDIO
+ DCD TIM5_IRQHandler ; TIM5
+ DCD SPI3_IRQHandler ; SPI3
+ DCD UART4_IRQHandler ; UART4
+ DCD UART5_IRQHandler ; UART5
+ DCD TIM6_IRQHandler ; TIM6
+ DCD TIM7_IRQHandler ; TIM7
+ DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1
+ DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2
+ DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3
+ DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5
+__Vectors_End
+
+__Vectors_Size EQU __Vectors_End - __Vectors
+
+ AREA |.text|, CODE, READONLY
+
+; Reset handler
+Reset_Handler PROC
+ EXPORT Reset_Handler [WEAK]
+ IMPORT __main
+ IMPORT SystemInit
+ LDR R0, =SystemInit
+ BLX R0
+ LDR R0, =__main
+ BX R0
+ ENDP
+
+; Dummy Exception Handlers (infinite loops which can be modified)
+
+NMI_Handler PROC
+ EXPORT NMI_Handler [WEAK]
+ B .
+ ENDP
+HardFault_Handler\
+ PROC
+ EXPORT HardFault_Handler [WEAK]
+ B .
+ ENDP
+MemManage_Handler\
+ PROC
+ EXPORT MemManage_Handler [WEAK]
+ B .
+ ENDP
+BusFault_Handler\
+ PROC
+ EXPORT BusFault_Handler [WEAK]
+ B .
+ ENDP
+UsageFault_Handler\
+ PROC
+ EXPORT UsageFault_Handler [WEAK]
+ B .
+ ENDP
+SVC_Handler PROC
+ EXPORT SVC_Handler [WEAK]
+ B .
+ ENDP
+DebugMon_Handler\
+ PROC
+ EXPORT DebugMon_Handler [WEAK]
+ B .
+ ENDP
+PendSV_Handler PROC
+ EXPORT PendSV_Handler [WEAK]
+ B .
+ ENDP
+SysTick_Handler PROC
+ EXPORT SysTick_Handler [WEAK]
+ B .
+ ENDP
+
+Default_Handler PROC
+
+ EXPORT WWDG_IRQHandler [WEAK]
+ EXPORT PVD_IRQHandler [WEAK]
+ EXPORT TAMPER_IRQHandler [WEAK]
+ EXPORT RTC_IRQHandler [WEAK]
+ EXPORT FLASH_IRQHandler [WEAK]
+ EXPORT RCC_IRQHandler [WEAK]
+ EXPORT EXTI0_IRQHandler [WEAK]
+ EXPORT EXTI1_IRQHandler [WEAK]
+ EXPORT EXTI2_IRQHandler [WEAK]
+ EXPORT EXTI3_IRQHandler [WEAK]
+ EXPORT EXTI4_IRQHandler [WEAK]
+ EXPORT DMA1_Channel1_IRQHandler [WEAK]
+ EXPORT DMA1_Channel2_IRQHandler [WEAK]
+ EXPORT DMA1_Channel3_IRQHandler [WEAK]
+ EXPORT DMA1_Channel4_IRQHandler [WEAK]
+ EXPORT DMA1_Channel5_IRQHandler [WEAK]
+ EXPORT DMA1_Channel6_IRQHandler [WEAK]
+ EXPORT DMA1_Channel7_IRQHandler [WEAK]
+ EXPORT ADC1_2_IRQHandler [WEAK]
+ EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
+ EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
+ EXPORT CAN1_RX1_IRQHandler [WEAK]
+ EXPORT CAN1_SCE_IRQHandler [WEAK]
+ EXPORT EXTI9_5_IRQHandler [WEAK]
+ EXPORT TIM1_BRK_IRQHandler [WEAK]
+ EXPORT TIM1_UP_IRQHandler [WEAK]
+ EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
+ EXPORT TIM1_CC_IRQHandler [WEAK]
+ EXPORT TIM2_IRQHandler [WEAK]
+ EXPORT TIM3_IRQHandler [WEAK]
+ EXPORT TIM4_IRQHandler [WEAK]
+ EXPORT I2C1_EV_IRQHandler [WEAK]
+ EXPORT I2C1_ER_IRQHandler [WEAK]
+ EXPORT I2C2_EV_IRQHandler [WEAK]
+ EXPORT I2C2_ER_IRQHandler [WEAK]
+ EXPORT SPI1_IRQHandler [WEAK]
+ EXPORT SPI2_IRQHandler [WEAK]
+ EXPORT USART1_IRQHandler [WEAK]
+ EXPORT USART2_IRQHandler [WEAK]
+ EXPORT USART3_IRQHandler [WEAK]
+ EXPORT EXTI15_10_IRQHandler [WEAK]
+ EXPORT RTCAlarm_IRQHandler [WEAK]
+ EXPORT USBWakeUp_IRQHandler [WEAK]
+ EXPORT TIM8_BRK_IRQHandler [WEAK]
+ EXPORT TIM8_UP_IRQHandler [WEAK]
+ EXPORT TIM8_TRG_COM_IRQHandler [WEAK]
+ EXPORT TIM8_CC_IRQHandler [WEAK]
+ EXPORT ADC3_IRQHandler [WEAK]
+ EXPORT FSMC_IRQHandler [WEAK]
+ EXPORT SDIO_IRQHandler [WEAK]
+ EXPORT TIM5_IRQHandler [WEAK]
+ EXPORT SPI3_IRQHandler [WEAK]
+ EXPORT UART4_IRQHandler [WEAK]
+ EXPORT UART5_IRQHandler [WEAK]
+ EXPORT TIM6_IRQHandler [WEAK]
+ EXPORT TIM7_IRQHandler [WEAK]
+ EXPORT DMA2_Channel1_IRQHandler [WEAK]
+ EXPORT DMA2_Channel2_IRQHandler [WEAK]
+ EXPORT DMA2_Channel3_IRQHandler [WEAK]
+ EXPORT DMA2_Channel4_5_IRQHandler [WEAK]
+
+WWDG_IRQHandler
+PVD_IRQHandler
+TAMPER_IRQHandler
+RTC_IRQHandler
+FLASH_IRQHandler
+RCC_IRQHandler
+EXTI0_IRQHandler
+EXTI1_IRQHandler
+EXTI2_IRQHandler
+EXTI3_IRQHandler
+EXTI4_IRQHandler
+DMA1_Channel1_IRQHandler
+DMA1_Channel2_IRQHandler
+DMA1_Channel3_IRQHandler
+DMA1_Channel4_IRQHandler
+DMA1_Channel5_IRQHandler
+DMA1_Channel6_IRQHandler
+DMA1_Channel7_IRQHandler
+ADC1_2_IRQHandler
+USB_HP_CAN1_TX_IRQHandler
+USB_LP_CAN1_RX0_IRQHandler
+CAN1_RX1_IRQHandler
+CAN1_SCE_IRQHandler
+EXTI9_5_IRQHandler
+TIM1_BRK_IRQHandler
+TIM1_UP_IRQHandler
+TIM1_TRG_COM_IRQHandler
+TIM1_CC_IRQHandler
+TIM2_IRQHandler
+TIM3_IRQHandler
+TIM4_IRQHandler
+I2C1_EV_IRQHandler
+I2C1_ER_IRQHandler
+I2C2_EV_IRQHandler
+I2C2_ER_IRQHandler
+SPI1_IRQHandler
+SPI2_IRQHandler
+USART1_IRQHandler
+USART2_IRQHandler
+USART3_IRQHandler
+EXTI15_10_IRQHandler
+RTCAlarm_IRQHandler
+USBWakeUp_IRQHandler
+TIM8_BRK_IRQHandler
+TIM8_UP_IRQHandler
+TIM8_TRG_COM_IRQHandler
+TIM8_CC_IRQHandler
+ADC3_IRQHandler
+FSMC_IRQHandler
+SDIO_IRQHandler
+TIM5_IRQHandler
+SPI3_IRQHandler
+UART4_IRQHandler
+UART5_IRQHandler
+TIM6_IRQHandler
+TIM7_IRQHandler
+DMA2_Channel1_IRQHandler
+DMA2_Channel2_IRQHandler
+DMA2_Channel3_IRQHandler
+DMA2_Channel4_5_IRQHandler
+ B .
+
+ ENDP
+
+ ALIGN
+
+;*******************************************************************************
+; User Stack and Heap initialization
+;*******************************************************************************
+ IF :DEF:__MICROLIB
+
+ EXPORT __initial_sp
+ EXPORT __heap_base
+ EXPORT __heap_limit
+
+ ELSE
+
+ IMPORT __use_two_region_memory
+ EXPORT __user_initial_stackheap
+
+__user_initial_stackheap
+
+ LDR R0, = Heap_Mem
+ LDR R1, =(Stack_Mem + Stack_Size)
+ LDR R2, = (Heap_Mem + Heap_Size)
+ LDR R3, = Stack_Mem
+ BX LR
+
+ ALIGN
+
+ ENDIF
+
+ END
+
+;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE*****
diff --git a/st_fw_lib/stm32f10x.h b/st_fw_lib/stm32f10x.h
new file mode 100644
index 0000000..8bf7624
--- /dev/null
+++ b/st_fw_lib/stm32f10x.h
@@ -0,0 +1,8336 @@
+/**
+ ******************************************************************************
+ * @file stm32f10x.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Header File.
+ * This file contains all the peripheral register's definitions, bits
+ * definitions and memory mapping for STM32F10x Connectivity line,
+ * High density, High density value line, Medium density,
+ * Medium density Value line, Low density, Low density Value line
+ * and XL-density devices.
+ *
+ * The file is the unique include file that the application programmer
+ * is using in the C source code, usually in main.c. This file contains:
+ * - Configuration section that allows to select:
+ * - The device used in the target application
+ * - To use or not the peripherals drivers in application code(i.e.
+ * code will be based on direct access to peripherals registers
+ * rather than drivers API), this option is controlled by
+ * "#define USE_STDPERIPH_DRIVER"
+ * - To change few application-specific parameters such as the HSE
+ * crystal frequency
+ * - Data structures and the address mapping for all peripherals
+ * - Peripheral's registers declarations and bits definition
+ * - Macros to access peripherals registers hardware
+ *
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/** @addtogroup CMSIS
+ * @{
+ */
+
+/** @addtogroup stm32f10x
+ * @{
+ */
+
+#ifndef __STM32F10x_H
+#define __STM32F10x_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/** @addtogroup Library_configuration_section
+ * @{
+ */
+
+/* Uncomment the line below according to the target STM32 device used in your
+ application
+ */
+
+#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL)
+ /* #define STM32F10X_LD */ /*!< STM32F10X_LD: STM32 Low density devices */
+ /* #define STM32F10X_LD_VL */ /*!< STM32F10X_LD_VL: STM32 Low density Value Line devices */
+ /* #define STM32F10X_MD */ /*!< STM32F10X_MD: STM32 Medium density devices */
+ /* #define STM32F10X_MD_VL */ /*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices */
+ /* #define STM32F10X_HD */ /*!< STM32F10X_HD: STM32 High density devices */
+ /* #define STM32F10X_HD_VL */ /*!< STM32F10X_HD_VL: STM32 High density value line devices */
+ /* #define STM32F10X_XL */ /*!< STM32F10X_XL: STM32 XL-density devices */
+ /* #define STM32F10X_CL */ /*!< STM32F10X_CL: STM32 Connectivity line devices */
+#endif
+/* Tip: To avoid modifying this file each time you need to switch between these
+ devices, you can define the device in your toolchain compiler preprocessor.
+
+ - Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
+ where the Flash memory density ranges between 16 and 32 Kbytes.
+ - Low-density value line devices are STM32F100xx microcontrollers where the Flash
+ memory density ranges between 16 and 32 Kbytes.
+ - Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
+ where the Flash memory density ranges between 64 and 128 Kbytes.
+ - Medium-density value line devices are STM32F100xx microcontrollers where the
+ Flash memory density ranges between 64 and 128 Kbytes.
+ - High-density devices are STM32F101xx and STM32F103xx microcontrollers where
+ the Flash memory density ranges between 256 and 512 Kbytes.
+ - High-density value line devices are STM32F100xx microcontrollers where the
+ Flash memory density ranges between 256 and 512 Kbytes.
+ - XL-density devices are STM32F101xx and STM32F103xx microcontrollers where
+ the Flash memory density ranges between 512 and 1024 Kbytes.
+ - Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
+ */
+
+#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL)
+ #error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
+#endif
+
+#if !defined USE_STDPERIPH_DRIVER
+/**
+ * @brief Comment the line below if you will not use the peripherals drivers.
+ In this case, these drivers will not be included and the application code will
+ be based on direct access to peripherals registers
+ */
+ /*#define USE_STDPERIPH_DRIVER*/
+#endif
+
+/**
+ * @brief In the following line adjust the value of External High Speed oscillator (HSE)
+ used in your application
+
+ Tip: To avoid modifying this file each time you need to use different HSE, you
+ can define the HSE value in your toolchain compiler preprocessor.
+ */
+#if !defined HSE_VALUE
+ #ifdef STM32F10X_CL
+ #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
+ #else
+ #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
+ #endif /* STM32F10X_CL */
+#endif /* HSE_VALUE */
+
+
+/**
+ * @brief In the following line adjust the External High Speed oscillator (HSE) Startup
+ Timeout value
+ */
+#define HSE_STARTUP_TIMEOUT ((uint16_t)0x0500) /*!< Time out for HSE start up */
+
+#define HSI_VALUE ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/
+
+/**
+ * @brief STM32F10x Standard Peripheral Library version number
+ */
+#define __STM32F10X_STDPERIPH_VERSION_MAIN (0x03) /*!< [31:24] main version */
+#define __STM32F10X_STDPERIPH_VERSION_SUB1 (0x05) /*!< [23:16] sub1 version */
+#define __STM32F10X_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
+#define __STM32F10X_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
+#define __STM32F10X_STDPERIPH_VERSION ( (__STM32F10X_STDPERIPH_VERSION_MAIN << 24)\
+ |(__STM32F10X_STDPERIPH_VERSION_SUB1 << 16)\
+ |(__STM32F10X_STDPERIPH_VERSION_SUB2 << 8)\
+ |(__STM32F10X_STDPERIPH_VERSION_RC))
+
+/**
+ * @}
+ */
+
+/** @addtogroup Configuration_section_for_CMSIS
+ * @{
+ */
+
+/**
+ * @brief Configuration of the Cortex-M3 Processor and Core Peripherals
+ */
+#ifdef STM32F10X_XL
+ #define __MPU_PRESENT 1 /*!< STM32 XL-density devices provide an MPU */
+#else
+ #define __MPU_PRESENT 0 /*!< Other STM32 devices does not provide an MPU */
+#endif /* STM32F10X_XL */
+#define __NVIC_PRIO_BITS 4 /*!< STM32 uses 4 Bits for the Priority Levels */
+#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
+
+/**
+ * @brief STM32F10x Interrupt Number Definition, according to the selected device
+ * in @ref Library_configuration_section
+ */
+typedef enum IRQn
+{
+/****** Cortex-M3 Processor Exceptions Numbers ***************************************************/
+ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */
+ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Interrupt */
+ BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */
+ UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */
+ SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */
+ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */
+ PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */
+ SysTick_IRQn = -1, /*!< 15 Cortex-M3 System Tick Interrupt */
+
+/****** STM32 specific Interrupt Numbers *********************************************************/
+ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */
+ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */
+ TAMPER_IRQn = 2, /*!< Tamper Interrupt */
+ RTC_IRQn = 3, /*!< RTC global Interrupt */
+ FLASH_IRQn = 4, /*!< FLASH global Interrupt */
+ RCC_IRQn = 5, /*!< RCC global Interrupt */
+ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */
+ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */
+ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */
+ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */
+ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */
+ DMA1_Channel1_IRQn = 11, /*!< DMA1 Channel 1 global Interrupt */
+ DMA1_Channel2_IRQn = 12, /*!< DMA1 Channel 2 global Interrupt */
+ DMA1_Channel3_IRQn = 13, /*!< DMA1 Channel 3 global Interrupt */
+ DMA1_Channel4_IRQn = 14, /*!< DMA1 Channel 4 global Interrupt */
+ DMA1_Channel5_IRQn = 15, /*!< DMA1 Channel 5 global Interrupt */
+ DMA1_Channel6_IRQn = 16, /*!< DMA1 Channel 6 global Interrupt */
+ DMA1_Channel7_IRQn = 17, /*!< DMA1 Channel 7 global Interrupt */
+
+#ifdef STM32F10X_LD
+ ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */
+ USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */
+ USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */
+ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */
+ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */
+ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
+ TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */
+ TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */
+ TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */
+ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */
+ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */
+ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */
+ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */
+ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */
+ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */
+ USART1_IRQn = 37, /*!< USART1 global Interrupt */
+ USART2_IRQn = 38, /*!< USART2 global Interrupt */
+ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
+ RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */
+ USBWakeUp_IRQn = 42 /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */
+#endif /* STM32F10X_LD */
+
+#ifdef STM32F10X_LD_VL
+ ADC1_IRQn = 18, /*!< ADC1 global Interrupt */
+ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
+ TIM1_BRK_TIM15_IRQn = 24, /*!< TIM1 Break and TIM15 Interrupts */
+ TIM1_UP_TIM16_IRQn = 25, /*!< TIM1 Update and TIM16 Interrupts */
+ TIM1_TRG_COM_TIM17_IRQn = 26, /*!< TIM1 Trigger and Commutation and TIM17 Interrupt */
+ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */
+ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */
+ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */
+ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */
+ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */
+ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */
+ USART1_IRQn = 37, /*!< USART1 global Interrupt */
+ USART2_IRQn = 38, /*!< USART2 global Interrupt */
+ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
+ RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */
+ CEC_IRQn = 42, /*!< HDMI-CEC Interrupt */
+ TIM6_DAC_IRQn = 54, /*!< TIM6 and DAC underrun Interrupt */
+ TIM7_IRQn = 55 /*!< TIM7 Interrupt */
+#endif /* STM32F10X_LD_VL */
+
+#ifdef STM32F10X_MD
+ ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */
+ USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */
+ USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */
+ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */
+ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */
+ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
+ TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */
+ TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */
+ TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */
+ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */
+ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */
+ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */
+ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */
+ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */
+ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */
+ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */
+ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */
+ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */
+ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */
+ USART1_IRQn = 37, /*!< USART1 global Interrupt */
+ USART2_IRQn = 38, /*!< USART2 global Interrupt */
+ USART3_IRQn = 39, /*!< USART3 global Interrupt */
+ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
+ RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */
+ USBWakeUp_IRQn = 42 /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */
+#endif /* STM32F10X_MD */
+
+#ifdef STM32F10X_MD_VL
+ ADC1_IRQn = 18, /*!< ADC1 global Interrupt */
+ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
+ TIM1_BRK_TIM15_IRQn = 24, /*!< TIM1 Break and TIM15 Interrupts */
+ TIM1_UP_TIM16_IRQn = 25, /*!< TIM1 Update and TIM16 Interrupts */
+ TIM1_TRG_COM_TIM17_IRQn = 26, /*!< TIM1 Trigger and Commutation and TIM17 Interrupt */
+ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */
+ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */
+ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */
+ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */
+ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */
+ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */
+ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */
+ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */
+ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */
+ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */
+ USART1_IRQn = 37, /*!< USART1 global Interrupt */
+ USART2_IRQn = 38, /*!< USART2 global Interrupt */
+ USART3_IRQn = 39, /*!< USART3 global Interrupt */
+ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
+ RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */
+ CEC_IRQn = 42, /*!< HDMI-CEC Interrupt */
+ TIM6_DAC_IRQn = 54, /*!< TIM6 and DAC underrun Interrupt */
+ TIM7_IRQn = 55 /*!< TIM7 Interrupt */
+#endif /* STM32F10X_MD_VL */
+
+#ifdef STM32F10X_HD
+ ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */
+ USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */
+ USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */
+ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */
+ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */
+ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
+ TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */
+ TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */
+ TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */
+ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */
+ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */
+ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */
+ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */
+ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */
+ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */
+ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */
+ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */
+ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */
+ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */
+ USART1_IRQn = 37, /*!< USART1 global Interrupt */
+ USART2_IRQn = 38, /*!< USART2 global Interrupt */
+ USART3_IRQn = 39, /*!< USART3 global Interrupt */
+ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
+ RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */
+ USBWakeUp_IRQn = 42, /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */
+ TIM8_BRK_IRQn = 43, /*!< TIM8 Break Interrupt */
+ TIM8_UP_IRQn = 44, /*!< TIM8 Update Interrupt */
+ TIM8_TRG_COM_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt */
+ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */
+ ADC3_IRQn = 47, /*!< ADC3 global Interrupt */
+ FSMC_IRQn = 48, /*!< FSMC global Interrupt */
+ SDIO_IRQn = 49, /*!< SDIO global Interrupt */
+ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */
+ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */
+ UART4_IRQn = 52, /*!< UART4 global Interrupt */
+ UART5_IRQn = 53, /*!< UART5 global Interrupt */
+ TIM6_IRQn = 54, /*!< TIM6 global Interrupt */
+ TIM7_IRQn = 55, /*!< TIM7 global Interrupt */
+ DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global Interrupt */
+ DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global Interrupt */
+ DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global Interrupt */
+ DMA2_Channel4_5_IRQn = 59 /*!< DMA2 Channel 4 and Channel 5 global Interrupt */
+#endif /* STM32F10X_HD */
+
+#ifdef STM32F10X_HD_VL
+ ADC1_IRQn = 18, /*!< ADC1 global Interrupt */
+ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
+ TIM1_BRK_TIM15_IRQn = 24, /*!< TIM1 Break and TIM15 Interrupts */
+ TIM1_UP_TIM16_IRQn = 25, /*!< TIM1 Update and TIM16 Interrupts */
+ TIM1_TRG_COM_TIM17_IRQn = 26, /*!< TIM1 Trigger and Commutation and TIM17 Interrupt */
+ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */
+ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */
+ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */
+ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */
+ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */
+ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */
+ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */
+ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */
+ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */
+ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */
+ USART1_IRQn = 37, /*!< USART1 global Interrupt */
+ USART2_IRQn = 38, /*!< USART2 global Interrupt */
+ USART3_IRQn = 39, /*!< USART3 global Interrupt */
+ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
+ RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */
+ CEC_IRQn = 42, /*!< HDMI-CEC Interrupt */
+ TIM12_IRQn = 43, /*!< TIM12 global Interrupt */
+ TIM13_IRQn = 44, /*!< TIM13 global Interrupt */
+ TIM14_IRQn = 45, /*!< TIM14 global Interrupt */
+ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */
+ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */
+ UART4_IRQn = 52, /*!< UART4 global Interrupt */
+ UART5_IRQn = 53, /*!< UART5 global Interrupt */
+ TIM6_DAC_IRQn = 54, /*!< TIM6 and DAC underrun Interrupt */
+ TIM7_IRQn = 55, /*!< TIM7 Interrupt */
+ DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global Interrupt */
+ DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global Interrupt */
+ DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global Interrupt */
+ DMA2_Channel4_5_IRQn = 59, /*!< DMA2 Channel 4 and Channel 5 global Interrupt */
+ DMA2_Channel5_IRQn = 60 /*!< DMA2 Channel 5 global Interrupt (DMA2 Channel 5 is
+ mapped at position 60 only if the MISC_REMAP bit in
+ the AFIO_MAPR2 register is set) */
+#endif /* STM32F10X_HD_VL */
+
+#ifdef STM32F10X_XL
+ ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */
+ USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */
+ USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */
+ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */
+ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */
+ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
+ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break Interrupt and TIM9 global Interrupt */
+ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global Interrupt */
+ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */
+ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */
+ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */
+ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */
+ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */
+ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */
+ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */
+ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */
+ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */
+ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */
+ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */
+ USART1_IRQn = 37, /*!< USART1 global Interrupt */
+ USART2_IRQn = 38, /*!< USART2 global Interrupt */
+ USART3_IRQn = 39, /*!< USART3 global Interrupt */
+ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
+ RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */
+ USBWakeUp_IRQn = 42, /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */
+ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global Interrupt */
+ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global Interrupt */
+ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */
+ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */
+ ADC3_IRQn = 47, /*!< ADC3 global Interrupt */
+ FSMC_IRQn = 48, /*!< FSMC global Interrupt */
+ SDIO_IRQn = 49, /*!< SDIO global Interrupt */
+ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */
+ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */
+ UART4_IRQn = 52, /*!< UART4 global Interrupt */
+ UART5_IRQn = 53, /*!< UART5 global Interrupt */
+ TIM6_IRQn = 54, /*!< TIM6 global Interrupt */
+ TIM7_IRQn = 55, /*!< TIM7 global Interrupt */
+ DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global Interrupt */
+ DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global Interrupt */
+ DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global Interrupt */
+ DMA2_Channel4_5_IRQn = 59 /*!< DMA2 Channel 4 and Channel 5 global Interrupt */
+#endif /* STM32F10X_XL */
+
+#ifdef STM32F10X_CL
+ ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */
+ CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */
+ CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */
+ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */
+ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */
+ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
+ TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */
+ TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */
+ TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */
+ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */
+ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */
+ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */
+ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */
+ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */
+ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */
+ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */
+ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */
+ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */
+ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */
+ USART1_IRQn = 37, /*!< USART1 global Interrupt */
+ USART2_IRQn = 38, /*!< USART2 global Interrupt */
+ USART3_IRQn = 39, /*!< USART3 global Interrupt */
+ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
+ RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */
+ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS WakeUp from suspend through EXTI Line Interrupt */
+ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */
+ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */
+ UART4_IRQn = 52, /*!< UART4 global Interrupt */
+ UART5_IRQn = 53, /*!< UART5 global Interrupt */
+ TIM6_IRQn = 54, /*!< TIM6 global Interrupt */
+ TIM7_IRQn = 55, /*!< TIM7 global Interrupt */
+ DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global Interrupt */
+ DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global Interrupt */
+ DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global Interrupt */
+ DMA2_Channel4_IRQn = 59, /*!< DMA2 Channel 4 global Interrupt */
+ DMA2_Channel5_IRQn = 60, /*!< DMA2 Channel 5 global Interrupt */
+ ETH_IRQn = 61, /*!< Ethernet global Interrupt */
+ ETH_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI line Interrupt */
+ CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */
+ CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */
+ CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */
+ CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */
+ OTG_FS_IRQn = 67 /*!< USB OTG FS global Interrupt */
+#endif /* STM32F10X_CL */
+} IRQn_Type;
+
+/**
+ * @}
+ */
+
+#include "core_cm3.h"
+#include "system_stm32f10x.h"
+#include <stdint.h>
+
+/** @addtogroup Exported_types
+ * @{
+ */
+
+/*!< STM32F10x Standard Peripheral Library old types (maintained for legacy purpose) */
+typedef int32_t s32;
+typedef int16_t s16;
+typedef int8_t s8;
+
+typedef const int32_t sc32; /*!< Read Only */
+typedef const int16_t sc16; /*!< Read Only */
+typedef const int8_t sc8; /*!< Read Only */
+
+typedef __IO int32_t vs32;
+typedef __IO int16_t vs16;
+typedef __IO int8_t vs8;
+
+typedef __I int32_t vsc32; /*!< Read Only */
+typedef __I int16_t vsc16; /*!< Read Only */
+typedef __I int8_t vsc8; /*!< Read Only */
+
+typedef uint32_t u32;
+typedef uint16_t u16;
+typedef uint8_t u8;
+
+typedef const uint32_t uc32; /*!< Read Only */
+typedef const uint16_t uc16; /*!< Read Only */
+typedef const uint8_t uc8; /*!< Read Only */
+
+typedef __IO uint32_t vu32;
+typedef __IO uint16_t vu16;
+typedef __IO uint8_t vu8;
+
+typedef __I uint32_t vuc32; /*!< Read Only */
+typedef __I uint16_t vuc16; /*!< Read Only */
+typedef __I uint8_t vuc8; /*!< Read Only */
+
+typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;
+
+typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
+#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
+
+typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
+
+/*!< STM32F10x Standard Peripheral Library old definitions (maintained for legacy purpose) */
+#define HSEStartUp_TimeOut HSE_STARTUP_TIMEOUT
+#define HSE_Value HSE_VALUE
+#define HSI_Value HSI_VALUE
+/**
+ * @}
+ */
+
+/** @addtogroup Peripheral_registers_structures
+ * @{
+ */
+
+/**
+ * @brief Analog to Digital Converter
+ */
+
+typedef struct
+{
+ __IO uint32_t SR;
+ __IO uint32_t CR1;
+ __IO uint32_t CR2;
+ __IO uint32_t SMPR1;
+ __IO uint32_t SMPR2;
+ __IO uint32_t JOFR1;
+ __IO uint32_t JOFR2;
+ __IO uint32_t JOFR3;
+ __IO uint32_t JOFR4;
+ __IO uint32_t HTR;
+ __IO uint32_t LTR;
+ __IO uint32_t SQR1;
+ __IO uint32_t SQR2;
+ __IO uint32_t SQR3;
+ __IO uint32_t JSQR;
+ __IO uint32_t JDR1;
+ __IO uint32_t JDR2;
+ __IO uint32_t JDR3;
+ __IO uint32_t JDR4;
+ __IO uint32_t DR;
+} ADC_TypeDef;
+
+/**
+ * @brief Backup Registers
+ */
+
+typedef struct
+{
+ uint32_t RESERVED0;
+ __IO uint16_t DR1;
+ uint16_t RESERVED1;
+ __IO uint16_t DR2;
+ uint16_t RESERVED2;
+ __IO uint16_t DR3;
+ uint16_t RESERVED3;
+ __IO uint16_t DR4;
+ uint16_t RESERVED4;
+ __IO uint16_t DR5;
+ uint16_t RESERVED5;
+ __IO uint16_t DR6;
+ uint16_t RESERVED6;
+ __IO uint16_t DR7;
+ uint16_t RESERVED7;
+ __IO uint16_t DR8;
+ uint16_t RESERVED8;
+ __IO uint16_t DR9;
+ uint16_t RESERVED9;
+ __IO uint16_t DR10;
+ uint16_t RESERVED10;
+ __IO uint16_t RTCCR;
+ uint16_t RESERVED11;
+ __IO uint16_t CR;
+ uint16_t RESERVED12;
+ __IO uint16_t CSR;
+ uint16_t RESERVED13[5];
+ __IO uint16_t DR11;
+ uint16_t RESERVED14;
+ __IO uint16_t DR12;
+ uint16_t RESERVED15;
+ __IO uint16_t DR13;
+ uint16_t RESERVED16;
+ __IO uint16_t DR14;
+ uint16_t RESERVED17;
+ __IO uint16_t DR15;
+ uint16_t RESERVED18;
+ __IO uint16_t DR16;
+ uint16_t RESERVED19;
+ __IO uint16_t DR17;
+ uint16_t RESERVED20;
+ __IO uint16_t DR18;
+ uint16_t RESERVED21;
+ __IO uint16_t DR19;
+ uint16_t RESERVED22;
+ __IO uint16_t DR20;
+ uint16_t RESERVED23;
+ __IO uint16_t DR21;
+ uint16_t RESERVED24;
+ __IO uint16_t DR22;
+ uint16_t RESERVED25;
+ __IO uint16_t DR23;
+ uint16_t RESERVED26;
+ __IO uint16_t DR24;
+ uint16_t RESERVED27;
+ __IO uint16_t DR25;
+ uint16_t RESERVED28;
+ __IO uint16_t DR26;
+ uint16_t RESERVED29;
+ __IO uint16_t DR27;
+ uint16_t RESERVED30;
+ __IO uint16_t DR28;
+ uint16_t RESERVED31;
+ __IO uint16_t DR29;
+ uint16_t RESERVED32;
+ __IO uint16_t DR30;
+ uint16_t RESERVED33;
+ __IO uint16_t DR31;
+ uint16_t RESERVED34;
+ __IO uint16_t DR32;
+ uint16_t RESERVED35;
+ __IO uint16_t DR33;
+ uint16_t RESERVED36;
+ __IO uint16_t DR34;
+ uint16_t RESERVED37;
+ __IO uint16_t DR35;
+ uint16_t RESERVED38;
+ __IO uint16_t DR36;
+ uint16_t RESERVED39;
+ __IO uint16_t DR37;
+ uint16_t RESERVED40;
+ __IO uint16_t DR38;
+ uint16_t RESERVED41;
+ __IO uint16_t DR39;
+ uint16_t RESERVED42;
+ __IO uint16_t DR40;
+ uint16_t RESERVED43;
+ __IO uint16_t DR41;
+ uint16_t RESERVED44;
+ __IO uint16_t DR42;
+ uint16_t RESERVED45;
+} BKP_TypeDef;
+
+/**
+ * @brief Controller Area Network TxMailBox
+ */
+
+typedef struct
+{
+ __IO uint32_t TIR;
+ __IO uint32_t TDTR;
+ __IO uint32_t TDLR;
+ __IO uint32_t TDHR;
+} CAN_TxMailBox_TypeDef;
+
+/**
+ * @brief Controller Area Network FIFOMailBox
+ */
+
+typedef struct
+{
+ __IO uint32_t RIR;
+ __IO uint32_t RDTR;
+ __IO uint32_t RDLR;
+ __IO uint32_t RDHR;
+} CAN_FIFOMailBox_TypeDef;
+
+/**
+ * @brief Controller Area Network FilterRegister
+ */
+
+typedef struct
+{
+ __IO uint32_t FR1;
+ __IO uint32_t FR2;
+} CAN_FilterRegister_TypeDef;
+
+/**
+ * @brief Controller Area Network
+ */
+
+typedef struct
+{
+ __IO uint32_t MCR;
+ __IO uint32_t MSR;
+ __IO uint32_t TSR;
+ __IO uint32_t RF0R;
+ __IO uint32_t RF1R;
+ __IO uint32_t IER;
+ __IO uint32_t ESR;
+ __IO uint32_t BTR;
+ uint32_t RESERVED0[88];
+ CAN_TxMailBox_TypeDef sTxMailBox[3];
+ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2];
+ uint32_t RESERVED1[12];
+ __IO uint32_t FMR;
+ __IO uint32_t FM1R;
+ uint32_t RESERVED2;
+ __IO uint32_t FS1R;
+ uint32_t RESERVED3;
+ __IO uint32_t FFA1R;
+ uint32_t RESERVED4;
+ __IO uint32_t FA1R;
+ uint32_t RESERVED5[8];
+#ifndef STM32F10X_CL
+ CAN_FilterRegister_TypeDef sFilterRegister[14];
+#else
+ CAN_FilterRegister_TypeDef sFilterRegister[28];
+#endif /* STM32F10X_CL */
+} CAN_TypeDef;
+
+/**
+ * @brief Consumer Electronics Control (CEC)
+ */
+typedef struct
+{
+ __IO uint32_t CFGR;
+ __IO uint32_t OAR;
+ __IO uint32_t PRES;
+ __IO uint32_t ESR;
+ __IO uint32_t CSR;
+ __IO uint32_t TXD;
+ __IO uint32_t RXD;
+} CEC_TypeDef;
+
+/**
+ * @brief CRC calculation unit
+ */
+
+typedef struct
+{
+ __IO uint32_t DR;
+ __IO uint8_t IDR;
+ uint8_t RESERVED0;
+ uint16_t RESERVED1;
+ __IO uint32_t CR;
+} CRC_TypeDef;
+
+/**
+ * @brief Digital to Analog Converter
+ */
+
+typedef struct
+{
+ __IO uint32_t CR;
+ __IO uint32_t SWTRIGR;
+ __IO uint32_t DHR12R1;
+ __IO uint32_t DHR12L1;
+ __IO uint32_t DHR8R1;
+ __IO uint32_t DHR12R2;
+ __IO uint32_t DHR12L2;
+ __IO uint32_t DHR8R2;
+ __IO uint32_t DHR12RD;
+ __IO uint32_t DHR12LD;
+ __IO uint32_t DHR8RD;
+ __IO uint32_t DOR1;
+ __IO uint32_t DOR2;
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+ __IO uint32_t SR;
+#endif
+} DAC_TypeDef;
+
+/**
+ * @brief Debug MCU
+ */
+
+typedef struct
+{
+ __IO uint32_t IDCODE;
+ __IO uint32_t CR;
+}DBGMCU_TypeDef;
+
+/**
+ * @brief DMA Controller
+ */
+
+typedef struct
+{
+ __IO uint32_t CCR;
+ __IO uint32_t CNDTR;
+ __IO uint32_t CPAR;
+ __IO uint32_t CMAR;
+} DMA_Channel_TypeDef;
+
+typedef struct
+{
+ __IO uint32_t ISR;
+ __IO uint32_t IFCR;
+} DMA_TypeDef;
+
+/**
+ * @brief Ethernet MAC
+ */
+
+typedef struct
+{
+ __IO uint32_t MACCR;
+ __IO uint32_t MACFFR;
+ __IO uint32_t MACHTHR;
+ __IO uint32_t MACHTLR;
+ __IO uint32_t MACMIIAR;
+ __IO uint32_t MACMIIDR;
+ __IO uint32_t MACFCR;
+ __IO uint32_t MACVLANTR; /* 8 */
+ uint32_t RESERVED0[2];
+ __IO uint32_t MACRWUFFR; /* 11 */
+ __IO uint32_t MACPMTCSR;
+ uint32_t RESERVED1[2];
+ __IO uint32_t MACSR; /* 15 */
+ __IO uint32_t MACIMR;
+ __IO uint32_t MACA0HR;
+ __IO uint32_t MACA0LR;
+ __IO uint32_t MACA1HR;
+ __IO uint32_t MACA1LR;
+ __IO uint32_t MACA2HR;
+ __IO uint32_t MACA2LR;
+ __IO uint32_t MACA3HR;
+ __IO uint32_t MACA3LR; /* 24 */
+ uint32_t RESERVED2[40];
+ __IO uint32_t MMCCR; /* 65 */
+ __IO uint32_t MMCRIR;
+ __IO uint32_t MMCTIR;
+ __IO uint32_t MMCRIMR;
+ __IO uint32_t MMCTIMR; /* 69 */
+ uint32_t RESERVED3[14];
+ __IO uint32_t MMCTGFSCCR; /* 84 */
+ __IO uint32_t MMCTGFMSCCR;
+ uint32_t RESERVED4[5];
+ __IO uint32_t MMCTGFCR;
+ uint32_t RESERVED5[10];
+ __IO uint32_t MMCRFCECR;
+ __IO uint32_t MMCRFAECR;
+ uint32_t RESERVED6[10];
+ __IO uint32_t MMCRGUFCR;
+ uint32_t RESERVED7[334];
+ __IO uint32_t PTPTSCR;
+ __IO uint32_t PTPSSIR;
+ __IO uint32_t PTPTSHR;
+ __IO uint32_t PTPTSLR;
+ __IO uint32_t PTPTSHUR;
+ __IO uint32_t PTPTSLUR;
+ __IO uint32_t PTPTSAR;
+ __IO uint32_t PTPTTHR;
+ __IO uint32_t PTPTTLR;
+ uint32_t RESERVED8[567];
+ __IO uint32_t DMABMR;
+ __IO uint32_t DMATPDR;
+ __IO uint32_t DMARPDR;
+ __IO uint32_t DMARDLAR;
+ __IO uint32_t DMATDLAR;
+ __IO uint32_t DMASR;
+ __IO uint32_t DMAOMR;
+ __IO uint32_t DMAIER;
+ __IO uint32_t DMAMFBOCR;
+ uint32_t RESERVED9[9];
+ __IO uint32_t DMACHTDR;
+ __IO uint32_t DMACHRDR;
+ __IO uint32_t DMACHTBAR;
+ __IO uint32_t DMACHRBAR;
+} ETH_TypeDef;
+
+/**
+ * @brief External Interrupt/Event Controller
+ */
+
+typedef struct
+{
+ __IO uint32_t IMR;
+ __IO uint32_t EMR;
+ __IO uint32_t RTSR;
+ __IO uint32_t FTSR;
+ __IO uint32_t SWIER;
+ __IO uint32_t PR;
+} EXTI_TypeDef;
+
+/**
+ * @brief FLASH Registers
+ */
+
+typedef struct
+{
+ __IO uint32_t ACR;
+ __IO uint32_t KEYR;
+ __IO uint32_t OPTKEYR;
+ __IO uint32_t SR;
+ __IO uint32_t CR;
+ __IO uint32_t AR;
+ __IO uint32_t RESERVED;
+ __IO uint32_t OBR;
+ __IO uint32_t WRPR;
+#ifdef STM32F10X_XL
+ uint32_t RESERVED1[8];
+ __IO uint32_t KEYR2;
+ uint32_t RESERVED2;
+ __IO uint32_t SR2;
+ __IO uint32_t CR2;
+ __IO uint32_t AR2;
+#endif /* STM32F10X_XL */
+} FLASH_TypeDef;
+
+/**
+ * @brief Option Bytes Registers
+ */
+
+typedef struct
+{
+ __IO uint16_t RDP;
+ __IO uint16_t USER;
+ __IO uint16_t Data0;
+ __IO uint16_t Data1;
+ __IO uint16_t WRP0;
+ __IO uint16_t WRP1;
+ __IO uint16_t WRP2;
+ __IO uint16_t WRP3;
+} OB_TypeDef;
+
+/**
+ * @brief Flexible Static Memory Controller
+ */
+
+typedef struct
+{
+ __IO uint32_t BTCR[8];
+} FSMC_Bank1_TypeDef;
+
+/**
+ * @brief Flexible Static Memory Controller Bank1E
+ */
+
+typedef struct
+{
+ __IO uint32_t BWTR[7];
+} FSMC_Bank1E_TypeDef;
+
+/**
+ * @brief Flexible Static Memory Controller Bank2
+ */
+
+typedef struct
+{
+ __IO uint32_t PCR2;
+ __IO uint32_t SR2;
+ __IO uint32_t PMEM2;
+ __IO uint32_t PATT2;
+ uint32_t RESERVED0;
+ __IO uint32_t ECCR2;
+} FSMC_Bank2_TypeDef;
+
+/**
+ * @brief Flexible Static Memory Controller Bank3
+ */
+
+typedef struct
+{
+ __IO uint32_t PCR3;
+ __IO uint32_t SR3;
+ __IO uint32_t PMEM3;
+ __IO uint32_t PATT3;
+ uint32_t RESERVED0;
+ __IO uint32_t ECCR3;
+} FSMC_Bank3_TypeDef;
+
+/**
+ * @brief Flexible Static Memory Controller Bank4
+ */
+
+typedef struct
+{
+ __IO uint32_t PCR4;
+ __IO uint32_t SR4;
+ __IO uint32_t PMEM4;
+ __IO uint32_t PATT4;
+ __IO uint32_t PIO4;
+} FSMC_Bank4_TypeDef;
+
+/**
+ * @brief General Purpose I/O
+ */
+
+typedef struct
+{
+ __IO uint32_t CRL;
+ __IO uint32_t CRH;
+ __IO uint32_t IDR;
+ __IO uint32_t ODR;
+ __IO uint32_t BSRR;
+ __IO uint32_t BRR;
+ __IO uint32_t LCKR;
+} GPIO_TypeDef;
+
+/**
+ * @brief Alternate Function I/O
+ */
+
+typedef struct
+{
+ __IO uint32_t EVCR;
+ __IO uint32_t MAPR;
+ __IO uint32_t EXTICR[4];
+ uint32_t RESERVED0;
+ __IO uint32_t MAPR2;
+} AFIO_TypeDef;
+/**
+ * @brief Inter Integrated Circuit Interface
+ */
+
+typedef struct
+{
+ __IO uint16_t CR1;
+ uint16_t RESERVED0;
+ __IO uint16_t CR2;
+ uint16_t RESERVED1;
+ __IO uint16_t OAR1;
+ uint16_t RESERVED2;
+ __IO uint16_t OAR2;
+ uint16_t RESERVED3;
+ __IO uint16_t DR;
+ uint16_t RESERVED4;
+ __IO uint16_t SR1;
+ uint16_t RESERVED5;
+ __IO uint16_t SR2;
+ uint16_t RESERVED6;
+ __IO uint16_t CCR;
+ uint16_t RESERVED7;
+ __IO uint16_t TRISE;
+ uint16_t RESERVED8;
+} I2C_TypeDef;
+
+/**
+ * @brief Independent WATCHDOG
+ */
+
+typedef struct
+{
+ __IO uint32_t KR;
+ __IO uint32_t PR;
+ __IO uint32_t RLR;
+ __IO uint32_t SR;
+} IWDG_TypeDef;
+
+/**
+ * @brief Power Control
+ */
+
+typedef struct
+{
+ __IO uint32_t CR;
+ __IO uint32_t CSR;
+} PWR_TypeDef;
+
+/**
+ * @brief Reset and Clock Control
+ */
+
+typedef struct
+{
+ __IO uint32_t CR;
+ __IO uint32_t CFGR;
+ __IO uint32_t CIR;
+ __IO uint32_t APB2RSTR;
+ __IO uint32_t APB1RSTR;
+ __IO uint32_t AHBENR;
+ __IO uint32_t APB2ENR;
+ __IO uint32_t APB1ENR;
+ __IO uint32_t BDCR;
+ __IO uint32_t CSR;
+
+#ifdef STM32F10X_CL
+ __IO uint32_t AHBRSTR;
+ __IO uint32_t CFGR2;
+#endif /* STM32F10X_CL */
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+ uint32_t RESERVED0;
+ __IO uint32_t CFGR2;
+#endif /* STM32F10X_LD_VL || STM32F10X_MD_VL || STM32F10X_HD_VL */
+} RCC_TypeDef;
+
+/**
+ * @brief Real-Time Clock
+ */
+
+typedef struct
+{
+ __IO uint16_t CRH;
+ uint16_t RESERVED0;
+ __IO uint16_t CRL;
+ uint16_t RESERVED1;
+ __IO uint16_t PRLH;
+ uint16_t RESERVED2;
+ __IO uint16_t PRLL;
+ uint16_t RESERVED3;
+ __IO uint16_t DIVH;
+ uint16_t RESERVED4;
+ __IO uint16_t DIVL;
+ uint16_t RESERVED5;
+ __IO uint16_t CNTH;
+ uint16_t RESERVED6;
+ __IO uint16_t CNTL;
+ uint16_t RESERVED7;
+ __IO uint16_t ALRH;
+ uint16_t RESERVED8;
+ __IO uint16_t ALRL;
+ uint16_t RESERVED9;
+} RTC_TypeDef;
+
+/**
+ * @brief SD host Interface
+ */
+
+typedef struct
+{
+ __IO uint32_t POWER;
+ __IO uint32_t CLKCR;
+ __IO uint32_t ARG;
+ __IO uint32_t CMD;
+ __I uint32_t RESPCMD;
+ __I uint32_t RESP1;
+ __I uint32_t RESP2;
+ __I uint32_t RESP3;
+ __I uint32_t RESP4;
+ __IO uint32_t DTIMER;
+ __IO uint32_t DLEN;
+ __IO uint32_t DCTRL;
+ __I uint32_t DCOUNT;
+ __I uint32_t STA;
+ __IO uint32_t ICR;
+ __IO uint32_t MASK;
+ uint32_t RESERVED0[2];
+ __I uint32_t FIFOCNT;
+ uint32_t RESERVED1[13];
+ __IO uint32_t FIFO;
+} SDIO_TypeDef;
+
+/**
+ * @brief Serial Peripheral Interface
+ */
+
+typedef struct
+{
+ __IO uint16_t CR1;
+ uint16_t RESERVED0;
+ __IO uint16_t CR2;
+ uint16_t RESERVED1;
+ __IO uint16_t SR;
+ uint16_t RESERVED2;
+ __IO uint16_t DR;
+ uint16_t RESERVED3;
+ __IO uint16_t CRCPR;
+ uint16_t RESERVED4;
+ __IO uint16_t RXCRCR;
+ uint16_t RESERVED5;
+ __IO uint16_t TXCRCR;
+ uint16_t RESERVED6;
+ __IO uint16_t I2SCFGR;
+ uint16_t RESERVED7;
+ __IO uint16_t I2SPR;
+ uint16_t RESERVED8;
+} SPI_TypeDef;
+
+/**
+ * @brief TIM
+ */
+
+typedef struct
+{
+ __IO uint16_t CR1;
+ uint16_t RESERVED0;
+ __IO uint16_t CR2;
+ uint16_t RESERVED1;
+ __IO uint16_t SMCR;
+ uint16_t RESERVED2;
+ __IO uint16_t DIER;
+ uint16_t RESERVED3;
+ __IO uint16_t SR;
+ uint16_t RESERVED4;
+ __IO uint16_t EGR;
+ uint16_t RESERVED5;
+ __IO uint16_t CCMR1;
+ uint16_t RESERVED6;
+ __IO uint16_t CCMR2;
+ uint16_t RESERVED7;
+ __IO uint16_t CCER;
+ uint16_t RESERVED8;
+ __IO uint16_t CNT;
+ uint16_t RESERVED9;
+ __IO uint16_t PSC;
+ uint16_t RESERVED10;
+ __IO uint16_t ARR;
+ uint16_t RESERVED11;
+ __IO uint16_t RCR;
+ uint16_t RESERVED12;
+ __IO uint16_t CCR1;
+ uint16_t RESERVED13;
+ __IO uint16_t CCR2;
+ uint16_t RESERVED14;
+ __IO uint16_t CCR3;
+ uint16_t RESERVED15;
+ __IO uint16_t CCR4;
+ uint16_t RESERVED16;
+ __IO uint16_t BDTR;
+ uint16_t RESERVED17;
+ __IO uint16_t DCR;
+ uint16_t RESERVED18;
+ __IO uint16_t DMAR;
+ uint16_t RESERVED19;
+} TIM_TypeDef;
+
+/**
+ * @brief Universal Synchronous Asynchronous Receiver Transmitter
+ */
+
+typedef struct
+{
+ __IO uint16_t SR;
+ uint16_t RESERVED0;
+ __IO uint16_t DR;
+ uint16_t RESERVED1;
+ __IO uint16_t BRR;
+ uint16_t RESERVED2;
+ __IO uint16_t CR1;
+ uint16_t RESERVED3;
+ __IO uint16_t CR2;
+ uint16_t RESERVED4;
+ __IO uint16_t CR3;
+ uint16_t RESERVED5;
+ __IO uint16_t GTPR;
+ uint16_t RESERVED6;
+} USART_TypeDef;
+
+/**
+ * @brief Window WATCHDOG
+ */
+
+typedef struct
+{
+ __IO uint32_t CR;
+ __IO uint32_t CFR;
+ __IO uint32_t SR;
+} WWDG_TypeDef;
+
+/**
+ * @}
+ */
+
+/** @addtogroup Peripheral_memory_map
+ * @{
+ */
+
+
+#define FLASH_BASE ((uint32_t)0x08000000) /*!< FLASH base address in the alias region */
+#define SRAM_BASE ((uint32_t)0x20000000) /*!< SRAM base address in the alias region */
+#define PERIPH_BASE ((uint32_t)0x40000000) /*!< Peripheral base address in the alias region */
+
+#define SRAM_BB_BASE ((uint32_t)0x22000000) /*!< SRAM base address in the bit-band region */
+#define PERIPH_BB_BASE ((uint32_t)0x42000000) /*!< Peripheral base address in the bit-band region */
+
+#define FSMC_R_BASE ((uint32_t)0xA0000000) /*!< FSMC registers base address */
+
+/*!< Peripheral memory map */
+#define APB1PERIPH_BASE PERIPH_BASE
+#define APB2PERIPH_BASE (PERIPH_BASE + 0x10000)
+#define AHBPERIPH_BASE (PERIPH_BASE + 0x20000)
+
+#define TIM2_BASE (APB1PERIPH_BASE + 0x0000)
+#define TIM3_BASE (APB1PERIPH_BASE + 0x0400)
+#define TIM4_BASE (APB1PERIPH_BASE + 0x0800)
+#define TIM5_BASE (APB1PERIPH_BASE + 0x0C00)
+#define TIM6_BASE (APB1PERIPH_BASE + 0x1000)
+#define TIM7_BASE (APB1PERIPH_BASE + 0x1400)
+#define TIM12_BASE (APB1PERIPH_BASE + 0x1800)
+#define TIM13_BASE (APB1PERIPH_BASE + 0x1C00)
+#define TIM14_BASE (APB1PERIPH_BASE + 0x2000)
+#define RTC_BASE (APB1PERIPH_BASE + 0x2800)
+#define WWDG_BASE (APB1PERIPH_BASE + 0x2C00)
+#define IWDG_BASE (APB1PERIPH_BASE + 0x3000)
+#define SPI2_BASE (APB1PERIPH_BASE + 0x3800)
+#define SPI3_BASE (APB1PERIPH_BASE + 0x3C00)
+#define USART2_BASE (APB1PERIPH_BASE + 0x4400)
+#define USART3_BASE (APB1PERIPH_BASE + 0x4800)
+#define UART4_BASE (APB1PERIPH_BASE + 0x4C00)
+#define UART5_BASE (APB1PERIPH_BASE + 0x5000)
+#define I2C1_BASE (APB1PERIPH_BASE + 0x5400)
+#define I2C2_BASE (APB1PERIPH_BASE + 0x5800)
+#define CAN1_BASE (APB1PERIPH_BASE + 0x6400)
+#define CAN2_BASE (APB1PERIPH_BASE + 0x6800)
+#define BKP_BASE (APB1PERIPH_BASE + 0x6C00)
+#define PWR_BASE (APB1PERIPH_BASE + 0x7000)
+#define DAC_BASE (APB1PERIPH_BASE + 0x7400)
+#define CEC_BASE (APB1PERIPH_BASE + 0x7800)
+
+#define AFIO_BASE (APB2PERIPH_BASE + 0x0000)
+#define EXTI_BASE (APB2PERIPH_BASE + 0x0400)
+#define GPIOA_BASE (APB2PERIPH_BASE + 0x0800)
+#define GPIOB_BASE (APB2PERIPH_BASE + 0x0C00)
+#define GPIOC_BASE (APB2PERIPH_BASE + 0x1000)
+#define GPIOD_BASE (APB2PERIPH_BASE + 0x1400)
+#define GPIOE_BASE (APB2PERIPH_BASE + 0x1800)
+#define GPIOF_BASE (APB2PERIPH_BASE + 0x1C00)
+#define GPIOG_BASE (APB2PERIPH_BASE + 0x2000)
+#define ADC1_BASE (APB2PERIPH_BASE + 0x2400)
+#define ADC2_BASE (APB2PERIPH_BASE + 0x2800)
+#define TIM1_BASE (APB2PERIPH_BASE + 0x2C00)
+#define SPI1_BASE (APB2PERIPH_BASE + 0x3000)
+#define TIM8_BASE (APB2PERIPH_BASE + 0x3400)
+#define USART1_BASE (APB2PERIPH_BASE + 0x3800)
+#define ADC3_BASE (APB2PERIPH_BASE + 0x3C00)
+#define TIM15_BASE (APB2PERIPH_BASE + 0x4000)
+#define TIM16_BASE (APB2PERIPH_BASE + 0x4400)
+#define TIM17_BASE (APB2PERIPH_BASE + 0x4800)
+#define TIM9_BASE (APB2PERIPH_BASE + 0x4C00)
+#define TIM10_BASE (APB2PERIPH_BASE + 0x5000)
+#define TIM11_BASE (APB2PERIPH_BASE + 0x5400)
+
+#define SDIO_BASE (PERIPH_BASE + 0x18000)
+
+#define DMA1_BASE (AHBPERIPH_BASE + 0x0000)
+#define DMA1_Channel1_BASE (AHBPERIPH_BASE + 0x0008)
+#define DMA1_Channel2_BASE (AHBPERIPH_BASE + 0x001C)
+#define DMA1_Channel3_BASE (AHBPERIPH_BASE + 0x0030)
+#define DMA1_Channel4_BASE (AHBPERIPH_BASE + 0x0044)
+#define DMA1_Channel5_BASE (AHBPERIPH_BASE + 0x0058)
+#define DMA1_Channel6_BASE (AHBPERIPH_BASE + 0x006C)
+#define DMA1_Channel7_BASE (AHBPERIPH_BASE + 0x0080)
+#define DMA2_BASE (AHBPERIPH_BASE + 0x0400)
+#define DMA2_Channel1_BASE (AHBPERIPH_BASE + 0x0408)
+#define DMA2_Channel2_BASE (AHBPERIPH_BASE + 0x041C)
+#define DMA2_Channel3_BASE (AHBPERIPH_BASE + 0x0430)
+#define DMA2_Channel4_BASE (AHBPERIPH_BASE + 0x0444)
+#define DMA2_Channel5_BASE (AHBPERIPH_BASE + 0x0458)
+#define RCC_BASE (AHBPERIPH_BASE + 0x1000)
+#define CRC_BASE (AHBPERIPH_BASE + 0x3000)
+
+#define FLASH_R_BASE (AHBPERIPH_BASE + 0x2000) /*!< Flash registers base address */
+#define OB_BASE ((uint32_t)0x1FFFF800) /*!< Flash Option Bytes base address */
+
+#define ETH_BASE (AHBPERIPH_BASE + 0x8000)
+#define ETH_MAC_BASE (ETH_BASE)
+#define ETH_MMC_BASE (ETH_BASE + 0x0100)
+#define ETH_PTP_BASE (ETH_BASE + 0x0700)
+#define ETH_DMA_BASE (ETH_BASE + 0x1000)
+
+#define FSMC_Bank1_R_BASE (FSMC_R_BASE + 0x0000) /*!< FSMC Bank1 registers base address */
+#define FSMC_Bank1E_R_BASE (FSMC_R_BASE + 0x0104) /*!< FSMC Bank1E registers base address */
+#define FSMC_Bank2_R_BASE (FSMC_R_BASE + 0x0060) /*!< FSMC Bank2 registers base address */
+#define FSMC_Bank3_R_BASE (FSMC_R_BASE + 0x0080) /*!< FSMC Bank3 registers base address */
+#define FSMC_Bank4_R_BASE (FSMC_R_BASE + 0x00A0) /*!< FSMC Bank4 registers base address */
+
+#define DBGMCU_BASE ((uint32_t)0xE0042000) /*!< Debug MCU registers base address */
+
+/**
+ * @}
+ */
+
+/** @addtogroup Peripheral_declaration
+ * @{
+ */
+
+#define TIM2 ((TIM_TypeDef *) TIM2_BASE)
+#define TIM3 ((TIM_TypeDef *) TIM3_BASE)
+#define TIM4 ((TIM_TypeDef *) TIM4_BASE)
+#define TIM5 ((TIM_TypeDef *) TIM5_BASE)
+#define TIM6 ((TIM_TypeDef *) TIM6_BASE)
+#define TIM7 ((TIM_TypeDef *) TIM7_BASE)
+#define TIM12 ((TIM_TypeDef *) TIM12_BASE)
+#define TIM13 ((TIM_TypeDef *) TIM13_BASE)
+#define TIM14 ((TIM_TypeDef *) TIM14_BASE)
+#define RTC ((RTC_TypeDef *) RTC_BASE)
+#define WWDG ((WWDG_TypeDef *) WWDG_BASE)
+#define IWDG ((IWDG_TypeDef *) IWDG_BASE)
+#define SPI2 ((SPI_TypeDef *) SPI2_BASE)
+#define SPI3 ((SPI_TypeDef *) SPI3_BASE)
+#define USART2 ((USART_TypeDef *) USART2_BASE)
+#define USART3 ((USART_TypeDef *) USART3_BASE)
+#define UART4 ((USART_TypeDef *) UART4_BASE)
+#define UART5 ((USART_TypeDef *) UART5_BASE)
+#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
+#define I2C2 ((I2C_TypeDef *) I2C2_BASE)
+#define CAN1 ((CAN_TypeDef *) CAN1_BASE)
+#define CAN2 ((CAN_TypeDef *) CAN2_BASE)
+#define BKP ((BKP_TypeDef *) BKP_BASE)
+#define PWR ((PWR_TypeDef *) PWR_BASE)
+#define DAC ((DAC_TypeDef *) DAC_BASE)
+#define CEC ((CEC_TypeDef *) CEC_BASE)
+#define AFIO ((AFIO_TypeDef *) AFIO_BASE)
+#define EXTI ((EXTI_TypeDef *) EXTI_BASE)
+#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE)
+#define GPIOB ((GPIO_TypeDef *) GPIOB_BASE)
+#define GPIOC ((GPIO_TypeDef *) GPIOC_BASE)
+#define GPIOD ((GPIO_TypeDef *) GPIOD_BASE)
+#define GPIOE ((GPIO_TypeDef *) GPIOE_BASE)
+#define GPIOF ((GPIO_TypeDef *) GPIOF_BASE)
+#define GPIOG ((GPIO_TypeDef *) GPIOG_BASE)
+#define ADC1 ((ADC_TypeDef *) ADC1_BASE)
+#define ADC2 ((ADC_TypeDef *) ADC2_BASE)
+#define TIM1 ((TIM_TypeDef *) TIM1_BASE)
+#define SPI1 ((SPI_TypeDef *) SPI1_BASE)
+#define TIM8 ((TIM_TypeDef *) TIM8_BASE)
+#define USART1 ((USART_TypeDef *) USART1_BASE)
+#define ADC3 ((ADC_TypeDef *) ADC3_BASE)
+#define TIM15 ((TIM_TypeDef *) TIM15_BASE)
+#define TIM16 ((TIM_TypeDef *) TIM16_BASE)
+#define TIM17 ((TIM_TypeDef *) TIM17_BASE)
+#define TIM9 ((TIM_TypeDef *) TIM9_BASE)
+#define TIM10 ((TIM_TypeDef *) TIM10_BASE)
+#define TIM11 ((TIM_TypeDef *) TIM11_BASE)
+#define SDIO ((SDIO_TypeDef *) SDIO_BASE)
+#define DMA1 ((DMA_TypeDef *) DMA1_BASE)
+#define DMA2 ((DMA_TypeDef *) DMA2_BASE)
+#define DMA1_Channel1 ((DMA_Channel_TypeDef *) DMA1_Channel1_BASE)
+#define DMA1_Channel2 ((DMA_Channel_TypeDef *) DMA1_Channel2_BASE)
+#define DMA1_Channel3 ((DMA_Channel_TypeDef *) DMA1_Channel3_BASE)
+#define DMA1_Channel4 ((DMA_Channel_TypeDef *) DMA1_Channel4_BASE)
+#define DMA1_Channel5 ((DMA_Channel_TypeDef *) DMA1_Channel5_BASE)
+#define DMA1_Channel6 ((DMA_Channel_TypeDef *) DMA1_Channel6_BASE)
+#define DMA1_Channel7 ((DMA_Channel_TypeDef *) DMA1_Channel7_BASE)
+#define DMA2_Channel1 ((DMA_Channel_TypeDef *) DMA2_Channel1_BASE)
+#define DMA2_Channel2 ((DMA_Channel_TypeDef *) DMA2_Channel2_BASE)
+#define DMA2_Channel3 ((DMA_Channel_TypeDef *) DMA2_Channel3_BASE)
+#define DMA2_Channel4 ((DMA_Channel_TypeDef *) DMA2_Channel4_BASE)
+#define DMA2_Channel5 ((DMA_Channel_TypeDef *) DMA2_Channel5_BASE)
+#define RCC ((RCC_TypeDef *) RCC_BASE)
+#define CRC ((CRC_TypeDef *) CRC_BASE)
+#define FLASH ((FLASH_TypeDef *) FLASH_R_BASE)
+#define OB ((OB_TypeDef *) OB_BASE)
+#define ETH ((ETH_TypeDef *) ETH_BASE)
+#define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE)
+#define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE)
+#define FSMC_Bank2 ((FSMC_Bank2_TypeDef *) FSMC_Bank2_R_BASE)
+#define FSMC_Bank3 ((FSMC_Bank3_TypeDef *) FSMC_Bank3_R_BASE)
+#define FSMC_Bank4 ((FSMC_Bank4_TypeDef *) FSMC_Bank4_R_BASE)
+#define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE)
+
+/**
+ * @}
+ */
+
+/** @addtogroup Exported_constants
+ * @{
+ */
+
+ /** @addtogroup Peripheral_Registers_Bits_Definition
+ * @{
+ */
+
+/******************************************************************************/
+/* Peripheral Registers_Bits_Definition */
+/******************************************************************************/
+
+/******************************************************************************/
+/* */
+/* CRC calculation unit */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for CRC_DR register *********************/
+#define CRC_DR_DR ((uint32_t)0xFFFFFFFF) /*!< Data register bits */
+
+
+/******************* Bit definition for CRC_IDR register ********************/
+#define CRC_IDR_IDR ((uint8_t)0xFF) /*!< General-purpose 8-bit data register bits */
+
+
+/******************** Bit definition for CRC_CR register ********************/
+#define CRC_CR_RESET ((uint8_t)0x01) /*!< RESET bit */
+
+/******************************************************************************/
+/* */
+/* Power Control */
+/* */
+/******************************************************************************/
+
+/******************** Bit definition for PWR_CR register ********************/
+#define PWR_CR_LPDS ((uint16_t)0x0001) /*!< Low-Power Deepsleep */
+#define PWR_CR_PDDS ((uint16_t)0x0002) /*!< Power Down Deepsleep */
+#define PWR_CR_CWUF ((uint16_t)0x0004) /*!< Clear Wakeup Flag */
+#define PWR_CR_CSBF ((uint16_t)0x0008) /*!< Clear Standby Flag */
+#define PWR_CR_PVDE ((uint16_t)0x0010) /*!< Power Voltage Detector Enable */
+
+#define PWR_CR_PLS ((uint16_t)0x00E0) /*!< PLS[2:0] bits (PVD Level Selection) */
+#define PWR_CR_PLS_0 ((uint16_t)0x0020) /*!< Bit 0 */
+#define PWR_CR_PLS_1 ((uint16_t)0x0040) /*!< Bit 1 */
+#define PWR_CR_PLS_2 ((uint16_t)0x0080) /*!< Bit 2 */
+
+/*!< PVD level configuration */
+#define PWR_CR_PLS_2V2 ((uint16_t)0x0000) /*!< PVD level 2.2V */
+#define PWR_CR_PLS_2V3 ((uint16_t)0x0020) /*!< PVD level 2.3V */
+#define PWR_CR_PLS_2V4 ((uint16_t)0x0040) /*!< PVD level 2.4V */
+#define PWR_CR_PLS_2V5 ((uint16_t)0x0060) /*!< PVD level 2.5V */
+#define PWR_CR_PLS_2V6 ((uint16_t)0x0080) /*!< PVD level 2.6V */
+#define PWR_CR_PLS_2V7 ((uint16_t)0x00A0) /*!< PVD level 2.7V */
+#define PWR_CR_PLS_2V8 ((uint16_t)0x00C0) /*!< PVD level 2.8V */
+#define PWR_CR_PLS_2V9 ((uint16_t)0x00E0) /*!< PVD level 2.9V */
+
+#define PWR_CR_DBP ((uint16_t)0x0100) /*!< Disable Backup Domain write protection */
+
+
+/******************* Bit definition for PWR_CSR register ********************/
+#define PWR_CSR_WUF ((uint16_t)0x0001) /*!< Wakeup Flag */
+#define PWR_CSR_SBF ((uint16_t)0x0002) /*!< Standby Flag */
+#define PWR_CSR_PVDO ((uint16_t)0x0004) /*!< PVD Output */
+#define PWR_CSR_EWUP ((uint16_t)0x0100) /*!< Enable WKUP pin */
+
+/******************************************************************************/
+/* */
+/* Backup registers */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for BKP_DR1 register ********************/
+#define BKP_DR1_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR2 register ********************/
+#define BKP_DR2_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR3 register ********************/
+#define BKP_DR3_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR4 register ********************/
+#define BKP_DR4_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR5 register ********************/
+#define BKP_DR5_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR6 register ********************/
+#define BKP_DR6_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR7 register ********************/
+#define BKP_DR7_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR8 register ********************/
+#define BKP_DR8_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR9 register ********************/
+#define BKP_DR9_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR10 register *******************/
+#define BKP_DR10_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR11 register *******************/
+#define BKP_DR11_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR12 register *******************/
+#define BKP_DR12_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR13 register *******************/
+#define BKP_DR13_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR14 register *******************/
+#define BKP_DR14_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR15 register *******************/
+#define BKP_DR15_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR16 register *******************/
+#define BKP_DR16_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR17 register *******************/
+#define BKP_DR17_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/****************** Bit definition for BKP_DR18 register ********************/
+#define BKP_DR18_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR19 register *******************/
+#define BKP_DR19_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR20 register *******************/
+#define BKP_DR20_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR21 register *******************/
+#define BKP_DR21_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR22 register *******************/
+#define BKP_DR22_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR23 register *******************/
+#define BKP_DR23_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR24 register *******************/
+#define BKP_DR24_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR25 register *******************/
+#define BKP_DR25_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR26 register *******************/
+#define BKP_DR26_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR27 register *******************/
+#define BKP_DR27_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR28 register *******************/
+#define BKP_DR28_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR29 register *******************/
+#define BKP_DR29_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR30 register *******************/
+#define BKP_DR30_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR31 register *******************/
+#define BKP_DR31_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR32 register *******************/
+#define BKP_DR32_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR33 register *******************/
+#define BKP_DR33_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR34 register *******************/
+#define BKP_DR34_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR35 register *******************/
+#define BKP_DR35_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR36 register *******************/
+#define BKP_DR36_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR37 register *******************/
+#define BKP_DR37_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR38 register *******************/
+#define BKP_DR38_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR39 register *******************/
+#define BKP_DR39_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR40 register *******************/
+#define BKP_DR40_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR41 register *******************/
+#define BKP_DR41_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/******************* Bit definition for BKP_DR42 register *******************/
+#define BKP_DR42_D ((uint16_t)0xFFFF) /*!< Backup data */
+
+/****************** Bit definition for BKP_RTCCR register *******************/
+#define BKP_RTCCR_CAL ((uint16_t)0x007F) /*!< Calibration value */
+#define BKP_RTCCR_CCO ((uint16_t)0x0080) /*!< Calibration Clock Output */
+#define BKP_RTCCR_ASOE ((uint16_t)0x0100) /*!< Alarm or Second Output Enable */
+#define BKP_RTCCR_ASOS ((uint16_t)0x0200) /*!< Alarm or Second Output Selection */
+
+/******************** Bit definition for BKP_CR register ********************/
+#define BKP_CR_TPE ((uint8_t)0x01) /*!< TAMPER pin enable */
+#define BKP_CR_TPAL ((uint8_t)0x02) /*!< TAMPER pin active level */
+
+/******************* Bit definition for BKP_CSR register ********************/
+#define BKP_CSR_CTE ((uint16_t)0x0001) /*!< Clear Tamper event */
+#define BKP_CSR_CTI ((uint16_t)0x0002) /*!< Clear Tamper Interrupt */
+#define BKP_CSR_TPIE ((uint16_t)0x0004) /*!< TAMPER Pin interrupt enable */
+#define BKP_CSR_TEF ((uint16_t)0x0100) /*!< Tamper Event Flag */
+#define BKP_CSR_TIF ((uint16_t)0x0200) /*!< Tamper Interrupt Flag */
+
+/******************************************************************************/
+/* */
+/* Reset and Clock Control */
+/* */
+/******************************************************************************/
+
+/******************** Bit definition for RCC_CR register ********************/
+#define RCC_CR_HSION ((uint32_t)0x00000001) /*!< Internal High Speed clock enable */
+#define RCC_CR_HSIRDY ((uint32_t)0x00000002) /*!< Internal High Speed clock ready flag */
+#define RCC_CR_HSITRIM ((uint32_t)0x000000F8) /*!< Internal High Speed clock trimming */
+#define RCC_CR_HSICAL ((uint32_t)0x0000FF00) /*!< Internal High Speed clock Calibration */
+#define RCC_CR_HSEON ((uint32_t)0x00010000) /*!< External High Speed clock enable */
+#define RCC_CR_HSERDY ((uint32_t)0x00020000) /*!< External High Speed clock ready flag */
+#define RCC_CR_HSEBYP ((uint32_t)0x00040000) /*!< External High Speed clock Bypass */
+#define RCC_CR_CSSON ((uint32_t)0x00080000) /*!< Clock Security System enable */
+#define RCC_CR_PLLON ((uint32_t)0x01000000) /*!< PLL enable */
+#define RCC_CR_PLLRDY ((uint32_t)0x02000000) /*!< PLL clock ready flag */
+
+#ifdef STM32F10X_CL
+ #define RCC_CR_PLL2ON ((uint32_t)0x04000000) /*!< PLL2 enable */
+ #define RCC_CR_PLL2RDY ((uint32_t)0x08000000) /*!< PLL2 clock ready flag */
+ #define RCC_CR_PLL3ON ((uint32_t)0x10000000) /*!< PLL3 enable */
+ #define RCC_CR_PLL3RDY ((uint32_t)0x20000000) /*!< PLL3 clock ready flag */
+#endif /* STM32F10X_CL */
+
+/******************* Bit definition for RCC_CFGR register *******************/
+/*!< SW configuration */
+#define RCC_CFGR_SW ((uint32_t)0x00000003) /*!< SW[1:0] bits (System clock Switch) */
+#define RCC_CFGR_SW_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define RCC_CFGR_SW_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+
+#define RCC_CFGR_SW_HSI ((uint32_t)0x00000000) /*!< HSI selected as system clock */
+#define RCC_CFGR_SW_HSE ((uint32_t)0x00000001) /*!< HSE selected as system clock */
+#define RCC_CFGR_SW_PLL ((uint32_t)0x00000002) /*!< PLL selected as system clock */
+
+/*!< SWS configuration */
+#define RCC_CFGR_SWS ((uint32_t)0x0000000C) /*!< SWS[1:0] bits (System Clock Switch Status) */
+#define RCC_CFGR_SWS_0 ((uint32_t)0x00000004) /*!< Bit 0 */
+#define RCC_CFGR_SWS_1 ((uint32_t)0x00000008) /*!< Bit 1 */
+
+#define RCC_CFGR_SWS_HSI ((uint32_t)0x00000000) /*!< HSI oscillator used as system clock */
+#define RCC_CFGR_SWS_HSE ((uint32_t)0x00000004) /*!< HSE oscillator used as system clock */
+#define RCC_CFGR_SWS_PLL ((uint32_t)0x00000008) /*!< PLL used as system clock */
+
+/*!< HPRE configuration */
+#define RCC_CFGR_HPRE ((uint32_t)0x000000F0) /*!< HPRE[3:0] bits (AHB prescaler) */
+#define RCC_CFGR_HPRE_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define RCC_CFGR_HPRE_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+#define RCC_CFGR_HPRE_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+#define RCC_CFGR_HPRE_3 ((uint32_t)0x00000080) /*!< Bit 3 */
+
+#define RCC_CFGR_HPRE_DIV1 ((uint32_t)0x00000000) /*!< SYSCLK not divided */
+#define RCC_CFGR_HPRE_DIV2 ((uint32_t)0x00000080) /*!< SYSCLK divided by 2 */
+#define RCC_CFGR_HPRE_DIV4 ((uint32_t)0x00000090) /*!< SYSCLK divided by 4 */
+#define RCC_CFGR_HPRE_DIV8 ((uint32_t)0x000000A0) /*!< SYSCLK divided by 8 */
+#define RCC_CFGR_HPRE_DIV16 ((uint32_t)0x000000B0) /*!< SYSCLK divided by 16 */
+#define RCC_CFGR_HPRE_DIV64 ((uint32_t)0x000000C0) /*!< SYSCLK divided by 64 */
+#define RCC_CFGR_HPRE_DIV128 ((uint32_t)0x000000D0) /*!< SYSCLK divided by 128 */
+#define RCC_CFGR_HPRE_DIV256 ((uint32_t)0x000000E0) /*!< SYSCLK divided by 256 */
+#define RCC_CFGR_HPRE_DIV512 ((uint32_t)0x000000F0) /*!< SYSCLK divided by 512 */
+
+/*!< PPRE1 configuration */
+#define RCC_CFGR_PPRE1 ((uint32_t)0x00000700) /*!< PRE1[2:0] bits (APB1 prescaler) */
+#define RCC_CFGR_PPRE1_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define RCC_CFGR_PPRE1_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define RCC_CFGR_PPRE1_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+
+#define RCC_CFGR_PPRE1_DIV1 ((uint32_t)0x00000000) /*!< HCLK not divided */
+#define RCC_CFGR_PPRE1_DIV2 ((uint32_t)0x00000400) /*!< HCLK divided by 2 */
+#define RCC_CFGR_PPRE1_DIV4 ((uint32_t)0x00000500) /*!< HCLK divided by 4 */
+#define RCC_CFGR_PPRE1_DIV8 ((uint32_t)0x00000600) /*!< HCLK divided by 8 */
+#define RCC_CFGR_PPRE1_DIV16 ((uint32_t)0x00000700) /*!< HCLK divided by 16 */
+
+/*!< PPRE2 configuration */
+#define RCC_CFGR_PPRE2 ((uint32_t)0x00003800) /*!< PRE2[2:0] bits (APB2 prescaler) */
+#define RCC_CFGR_PPRE2_0 ((uint32_t)0x00000800) /*!< Bit 0 */
+#define RCC_CFGR_PPRE2_1 ((uint32_t)0x00001000) /*!< Bit 1 */
+#define RCC_CFGR_PPRE2_2 ((uint32_t)0x00002000) /*!< Bit 2 */
+
+#define RCC_CFGR_PPRE2_DIV1 ((uint32_t)0x00000000) /*!< HCLK not divided */
+#define RCC_CFGR_PPRE2_DIV2 ((uint32_t)0x00002000) /*!< HCLK divided by 2 */
+#define RCC_CFGR_PPRE2_DIV4 ((uint32_t)0x00002800) /*!< HCLK divided by 4 */
+#define RCC_CFGR_PPRE2_DIV8 ((uint32_t)0x00003000) /*!< HCLK divided by 8 */
+#define RCC_CFGR_PPRE2_DIV16 ((uint32_t)0x00003800) /*!< HCLK divided by 16 */
+
+/*!< ADCPPRE configuration */
+#define RCC_CFGR_ADCPRE ((uint32_t)0x0000C000) /*!< ADCPRE[1:0] bits (ADC prescaler) */
+#define RCC_CFGR_ADCPRE_0 ((uint32_t)0x00004000) /*!< Bit 0 */
+#define RCC_CFGR_ADCPRE_1 ((uint32_t)0x00008000) /*!< Bit 1 */
+
+#define RCC_CFGR_ADCPRE_DIV2 ((uint32_t)0x00000000) /*!< PCLK2 divided by 2 */
+#define RCC_CFGR_ADCPRE_DIV4 ((uint32_t)0x00004000) /*!< PCLK2 divided by 4 */
+#define RCC_CFGR_ADCPRE_DIV6 ((uint32_t)0x00008000) /*!< PCLK2 divided by 6 */
+#define RCC_CFGR_ADCPRE_DIV8 ((uint32_t)0x0000C000) /*!< PCLK2 divided by 8 */
+
+#define RCC_CFGR_PLLSRC ((uint32_t)0x00010000) /*!< PLL entry clock source */
+
+#define RCC_CFGR_PLLXTPRE ((uint32_t)0x00020000) /*!< HSE divider for PLL entry */
+
+/*!< PLLMUL configuration */
+#define RCC_CFGR_PLLMULL ((uint32_t)0x003C0000) /*!< PLLMUL[3:0] bits (PLL multiplication factor) */
+#define RCC_CFGR_PLLMULL_0 ((uint32_t)0x00040000) /*!< Bit 0 */
+#define RCC_CFGR_PLLMULL_1 ((uint32_t)0x00080000) /*!< Bit 1 */
+#define RCC_CFGR_PLLMULL_2 ((uint32_t)0x00100000) /*!< Bit 2 */
+#define RCC_CFGR_PLLMULL_3 ((uint32_t)0x00200000) /*!< Bit 3 */
+
+#ifdef STM32F10X_CL
+ #define RCC_CFGR_PLLSRC_HSI_Div2 ((uint32_t)0x00000000) /*!< HSI clock divided by 2 selected as PLL entry clock source */
+ #define RCC_CFGR_PLLSRC_PREDIV1 ((uint32_t)0x00010000) /*!< PREDIV1 clock selected as PLL entry clock source */
+
+ #define RCC_CFGR_PLLXTPRE_PREDIV1 ((uint32_t)0x00000000) /*!< PREDIV1 clock not divided for PLL entry */
+ #define RCC_CFGR_PLLXTPRE_PREDIV1_Div2 ((uint32_t)0x00020000) /*!< PREDIV1 clock divided by 2 for PLL entry */
+
+ #define RCC_CFGR_PLLMULL4 ((uint32_t)0x00080000) /*!< PLL input clock * 4 */
+ #define RCC_CFGR_PLLMULL5 ((uint32_t)0x000C0000) /*!< PLL input clock * 5 */
+ #define RCC_CFGR_PLLMULL6 ((uint32_t)0x00100000) /*!< PLL input clock * 6 */
+ #define RCC_CFGR_PLLMULL7 ((uint32_t)0x00140000) /*!< PLL input clock * 7 */
+ #define RCC_CFGR_PLLMULL8 ((uint32_t)0x00180000) /*!< PLL input clock * 8 */
+ #define RCC_CFGR_PLLMULL9 ((uint32_t)0x001C0000) /*!< PLL input clock * 9 */
+ #define RCC_CFGR_PLLMULL6_5 ((uint32_t)0x00340000) /*!< PLL input clock * 6.5 */
+
+ #define RCC_CFGR_OTGFSPRE ((uint32_t)0x00400000) /*!< USB OTG FS prescaler */
+
+/*!< MCO configuration */
+ #define RCC_CFGR_MCO ((uint32_t)0x0F000000) /*!< MCO[3:0] bits (Microcontroller Clock Output) */
+ #define RCC_CFGR_MCO_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+ #define RCC_CFGR_MCO_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+ #define RCC_CFGR_MCO_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+ #define RCC_CFGR_MCO_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+
+ #define RCC_CFGR_MCO_NOCLOCK ((uint32_t)0x00000000) /*!< No clock */
+ #define RCC_CFGR_MCO_SYSCLK ((uint32_t)0x04000000) /*!< System clock selected as MCO source */
+ #define RCC_CFGR_MCO_HSI ((uint32_t)0x05000000) /*!< HSI clock selected as MCO source */
+ #define RCC_CFGR_MCO_HSE ((uint32_t)0x06000000) /*!< HSE clock selected as MCO source */
+ #define RCC_CFGR_MCO_PLLCLK_Div2 ((uint32_t)0x07000000) /*!< PLL clock divided by 2 selected as MCO source */
+ #define RCC_CFGR_MCO_PLL2CLK ((uint32_t)0x08000000) /*!< PLL2 clock selected as MCO source*/
+ #define RCC_CFGR_MCO_PLL3CLK_Div2 ((uint32_t)0x09000000) /*!< PLL3 clock divided by 2 selected as MCO source*/
+ #define RCC_CFGR_MCO_Ext_HSE ((uint32_t)0x0A000000) /*!< XT1 external 3-25 MHz oscillator clock selected as MCO source */
+ #define RCC_CFGR_MCO_PLL3CLK ((uint32_t)0x0B000000) /*!< PLL3 clock selected as MCO source */
+#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+ #define RCC_CFGR_PLLSRC_HSI_Div2 ((uint32_t)0x00000000) /*!< HSI clock divided by 2 selected as PLL entry clock source */
+ #define RCC_CFGR_PLLSRC_PREDIV1 ((uint32_t)0x00010000) /*!< PREDIV1 clock selected as PLL entry clock source */
+
+ #define RCC_CFGR_PLLXTPRE_PREDIV1 ((uint32_t)0x00000000) /*!< PREDIV1 clock not divided for PLL entry */
+ #define RCC_CFGR_PLLXTPRE_PREDIV1_Div2 ((uint32_t)0x00020000) /*!< PREDIV1 clock divided by 2 for PLL entry */
+
+ #define RCC_CFGR_PLLMULL2 ((uint32_t)0x00000000) /*!< PLL input clock*2 */
+ #define RCC_CFGR_PLLMULL3 ((uint32_t)0x00040000) /*!< PLL input clock*3 */
+ #define RCC_CFGR_PLLMULL4 ((uint32_t)0x00080000) /*!< PLL input clock*4 */
+ #define RCC_CFGR_PLLMULL5 ((uint32_t)0x000C0000) /*!< PLL input clock*5 */
+ #define RCC_CFGR_PLLMULL6 ((uint32_t)0x00100000) /*!< PLL input clock*6 */
+ #define RCC_CFGR_PLLMULL7 ((uint32_t)0x00140000) /*!< PLL input clock*7 */
+ #define RCC_CFGR_PLLMULL8 ((uint32_t)0x00180000) /*!< PLL input clock*8 */
+ #define RCC_CFGR_PLLMULL9 ((uint32_t)0x001C0000) /*!< PLL input clock*9 */
+ #define RCC_CFGR_PLLMULL10 ((uint32_t)0x00200000) /*!< PLL input clock10 */
+ #define RCC_CFGR_PLLMULL11 ((uint32_t)0x00240000) /*!< PLL input clock*11 */
+ #define RCC_CFGR_PLLMULL12 ((uint32_t)0x00280000) /*!< PLL input clock*12 */
+ #define RCC_CFGR_PLLMULL13 ((uint32_t)0x002C0000) /*!< PLL input clock*13 */
+ #define RCC_CFGR_PLLMULL14 ((uint32_t)0x00300000) /*!< PLL input clock*14 */
+ #define RCC_CFGR_PLLMULL15 ((uint32_t)0x00340000) /*!< PLL input clock*15 */
+ #define RCC_CFGR_PLLMULL16 ((uint32_t)0x00380000) /*!< PLL input clock*16 */
+
+/*!< MCO configuration */
+ #define RCC_CFGR_MCO ((uint32_t)0x07000000) /*!< MCO[2:0] bits (Microcontroller Clock Output) */
+ #define RCC_CFGR_MCO_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+ #define RCC_CFGR_MCO_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+ #define RCC_CFGR_MCO_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+
+ #define RCC_CFGR_MCO_NOCLOCK ((uint32_t)0x00000000) /*!< No clock */
+ #define RCC_CFGR_MCO_SYSCLK ((uint32_t)0x04000000) /*!< System clock selected as MCO source */
+ #define RCC_CFGR_MCO_HSI ((uint32_t)0x05000000) /*!< HSI clock selected as MCO source */
+ #define RCC_CFGR_MCO_HSE ((uint32_t)0x06000000) /*!< HSE clock selected as MCO source */
+ #define RCC_CFGR_MCO_PLL ((uint32_t)0x07000000) /*!< PLL clock divided by 2 selected as MCO source */
+#else
+ #define RCC_CFGR_PLLSRC_HSI_Div2 ((uint32_t)0x00000000) /*!< HSI clock divided by 2 selected as PLL entry clock source */
+ #define RCC_CFGR_PLLSRC_HSE ((uint32_t)0x00010000) /*!< HSE clock selected as PLL entry clock source */
+
+ #define RCC_CFGR_PLLXTPRE_HSE ((uint32_t)0x00000000) /*!< HSE clock not divided for PLL entry */
+ #define RCC_CFGR_PLLXTPRE_HSE_Div2 ((uint32_t)0x00020000) /*!< HSE clock divided by 2 for PLL entry */
+
+ #define RCC_CFGR_PLLMULL2 ((uint32_t)0x00000000) /*!< PLL input clock*2 */
+ #define RCC_CFGR_PLLMULL3 ((uint32_t)0x00040000) /*!< PLL input clock*3 */
+ #define RCC_CFGR_PLLMULL4 ((uint32_t)0x00080000) /*!< PLL input clock*4 */
+ #define RCC_CFGR_PLLMULL5 ((uint32_t)0x000C0000) /*!< PLL input clock*5 */
+ #define RCC_CFGR_PLLMULL6 ((uint32_t)0x00100000) /*!< PLL input clock*6 */
+ #define RCC_CFGR_PLLMULL7 ((uint32_t)0x00140000) /*!< PLL input clock*7 */
+ #define RCC_CFGR_PLLMULL8 ((uint32_t)0x00180000) /*!< PLL input clock*8 */
+ #define RCC_CFGR_PLLMULL9 ((uint32_t)0x001C0000) /*!< PLL input clock*9 */
+ #define RCC_CFGR_PLLMULL10 ((uint32_t)0x00200000) /*!< PLL input clock10 */
+ #define RCC_CFGR_PLLMULL11 ((uint32_t)0x00240000) /*!< PLL input clock*11 */
+ #define RCC_CFGR_PLLMULL12 ((uint32_t)0x00280000) /*!< PLL input clock*12 */
+ #define RCC_CFGR_PLLMULL13 ((uint32_t)0x002C0000) /*!< PLL input clock*13 */
+ #define RCC_CFGR_PLLMULL14 ((uint32_t)0x00300000) /*!< PLL input clock*14 */
+ #define RCC_CFGR_PLLMULL15 ((uint32_t)0x00340000) /*!< PLL input clock*15 */
+ #define RCC_CFGR_PLLMULL16 ((uint32_t)0x00380000) /*!< PLL input clock*16 */
+ #define RCC_CFGR_USBPRE ((uint32_t)0x00400000) /*!< USB Device prescaler */
+
+/*!< MCO configuration */
+ #define RCC_CFGR_MCO ((uint32_t)0x07000000) /*!< MCO[2:0] bits (Microcontroller Clock Output) */
+ #define RCC_CFGR_MCO_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+ #define RCC_CFGR_MCO_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+ #define RCC_CFGR_MCO_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+
+ #define RCC_CFGR_MCO_NOCLOCK ((uint32_t)0x00000000) /*!< No clock */
+ #define RCC_CFGR_MCO_SYSCLK ((uint32_t)0x04000000) /*!< System clock selected as MCO source */
+ #define RCC_CFGR_MCO_HSI ((uint32_t)0x05000000) /*!< HSI clock selected as MCO source */
+ #define RCC_CFGR_MCO_HSE ((uint32_t)0x06000000) /*!< HSE clock selected as MCO source */
+ #define RCC_CFGR_MCO_PLL ((uint32_t)0x07000000) /*!< PLL clock divided by 2 selected as MCO source */
+#endif /* STM32F10X_CL */
+
+/*!<****************** Bit definition for RCC_CIR register ********************/
+#define RCC_CIR_LSIRDYF ((uint32_t)0x00000001) /*!< LSI Ready Interrupt flag */
+#define RCC_CIR_LSERDYF ((uint32_t)0x00000002) /*!< LSE Ready Interrupt flag */
+#define RCC_CIR_HSIRDYF ((uint32_t)0x00000004) /*!< HSI Ready Interrupt flag */
+#define RCC_CIR_HSERDYF ((uint32_t)0x00000008) /*!< HSE Ready Interrupt flag */
+#define RCC_CIR_PLLRDYF ((uint32_t)0x00000010) /*!< PLL Ready Interrupt flag */
+#define RCC_CIR_CSSF ((uint32_t)0x00000080) /*!< Clock Security System Interrupt flag */
+#define RCC_CIR_LSIRDYIE ((uint32_t)0x00000100) /*!< LSI Ready Interrupt Enable */
+#define RCC_CIR_LSERDYIE ((uint32_t)0x00000200) /*!< LSE Ready Interrupt Enable */
+#define RCC_CIR_HSIRDYIE ((uint32_t)0x00000400) /*!< HSI Ready Interrupt Enable */
+#define RCC_CIR_HSERDYIE ((uint32_t)0x00000800) /*!< HSE Ready Interrupt Enable */
+#define RCC_CIR_PLLRDYIE ((uint32_t)0x00001000) /*!< PLL Ready Interrupt Enable */
+#define RCC_CIR_LSIRDYC ((uint32_t)0x00010000) /*!< LSI Ready Interrupt Clear */
+#define RCC_CIR_LSERDYC ((uint32_t)0x00020000) /*!< LSE Ready Interrupt Clear */
+#define RCC_CIR_HSIRDYC ((uint32_t)0x00040000) /*!< HSI Ready Interrupt Clear */
+#define RCC_CIR_HSERDYC ((uint32_t)0x00080000) /*!< HSE Ready Interrupt Clear */
+#define RCC_CIR_PLLRDYC ((uint32_t)0x00100000) /*!< PLL Ready Interrupt Clear */
+#define RCC_CIR_CSSC ((uint32_t)0x00800000) /*!< Clock Security System Interrupt Clear */
+
+#ifdef STM32F10X_CL
+ #define RCC_CIR_PLL2RDYF ((uint32_t)0x00000020) /*!< PLL2 Ready Interrupt flag */
+ #define RCC_CIR_PLL3RDYF ((uint32_t)0x00000040) /*!< PLL3 Ready Interrupt flag */
+ #define RCC_CIR_PLL2RDYIE ((uint32_t)0x00002000) /*!< PLL2 Ready Interrupt Enable */
+ #define RCC_CIR_PLL3RDYIE ((uint32_t)0x00004000) /*!< PLL3 Ready Interrupt Enable */
+ #define RCC_CIR_PLL2RDYC ((uint32_t)0x00200000) /*!< PLL2 Ready Interrupt Clear */
+ #define RCC_CIR_PLL3RDYC ((uint32_t)0x00400000) /*!< PLL3 Ready Interrupt Clear */
+#endif /* STM32F10X_CL */
+
+/***************** Bit definition for RCC_APB2RSTR register *****************/
+#define RCC_APB2RSTR_AFIORST ((uint32_t)0x00000001) /*!< Alternate Function I/O reset */
+#define RCC_APB2RSTR_IOPARST ((uint32_t)0x00000004) /*!< I/O port A reset */
+#define RCC_APB2RSTR_IOPBRST ((uint32_t)0x00000008) /*!< I/O port B reset */
+#define RCC_APB2RSTR_IOPCRST ((uint32_t)0x00000010) /*!< I/O port C reset */
+#define RCC_APB2RSTR_IOPDRST ((uint32_t)0x00000020) /*!< I/O port D reset */
+#define RCC_APB2RSTR_ADC1RST ((uint32_t)0x00000200) /*!< ADC 1 interface reset */
+
+#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
+#define RCC_APB2RSTR_ADC2RST ((uint32_t)0x00000400) /*!< ADC 2 interface reset */
+#endif
+
+#define RCC_APB2RSTR_TIM1RST ((uint32_t)0x00000800) /*!< TIM1 Timer reset */
+#define RCC_APB2RSTR_SPI1RST ((uint32_t)0x00001000) /*!< SPI 1 reset */
+#define RCC_APB2RSTR_USART1RST ((uint32_t)0x00004000) /*!< USART1 reset */
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+#define RCC_APB2RSTR_TIM15RST ((uint32_t)0x00010000) /*!< TIM15 Timer reset */
+#define RCC_APB2RSTR_TIM16RST ((uint32_t)0x00020000) /*!< TIM16 Timer reset */
+#define RCC_APB2RSTR_TIM17RST ((uint32_t)0x00040000) /*!< TIM17 Timer reset */
+#endif
+
+#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
+ #define RCC_APB2RSTR_IOPERST ((uint32_t)0x00000040) /*!< I/O port E reset */
+#endif /* STM32F10X_LD && STM32F10X_LD_VL */
+
+#if defined (STM32F10X_HD) || defined (STM32F10X_XL)
+ #define RCC_APB2RSTR_IOPFRST ((uint32_t)0x00000080) /*!< I/O port F reset */
+ #define RCC_APB2RSTR_IOPGRST ((uint32_t)0x00000100) /*!< I/O port G reset */
+ #define RCC_APB2RSTR_TIM8RST ((uint32_t)0x00002000) /*!< TIM8 Timer reset */
+ #define RCC_APB2RSTR_ADC3RST ((uint32_t)0x00008000) /*!< ADC3 interface reset */
+#endif
+
+#if defined (STM32F10X_HD_VL)
+ #define RCC_APB2RSTR_IOPFRST ((uint32_t)0x00000080) /*!< I/O port F reset */
+ #define RCC_APB2RSTR_IOPGRST ((uint32_t)0x00000100) /*!< I/O port G reset */
+#endif
+
+#ifdef STM32F10X_XL
+ #define RCC_APB2RSTR_TIM9RST ((uint32_t)0x00080000) /*!< TIM9 Timer reset */
+ #define RCC_APB2RSTR_TIM10RST ((uint32_t)0x00100000) /*!< TIM10 Timer reset */
+ #define RCC_APB2RSTR_TIM11RST ((uint32_t)0x00200000) /*!< TIM11 Timer reset */
+#endif /* STM32F10X_XL */
+
+/***************** Bit definition for RCC_APB1RSTR register *****************/
+#define RCC_APB1RSTR_TIM2RST ((uint32_t)0x00000001) /*!< Timer 2 reset */
+#define RCC_APB1RSTR_TIM3RST ((uint32_t)0x00000002) /*!< Timer 3 reset */
+#define RCC_APB1RSTR_WWDGRST ((uint32_t)0x00000800) /*!< Window Watchdog reset */
+#define RCC_APB1RSTR_USART2RST ((uint32_t)0x00020000) /*!< USART 2 reset */
+#define RCC_APB1RSTR_I2C1RST ((uint32_t)0x00200000) /*!< I2C 1 reset */
+
+#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
+#define RCC_APB1RSTR_CAN1RST ((uint32_t)0x02000000) /*!< CAN1 reset */
+#endif
+
+#define RCC_APB1RSTR_BKPRST ((uint32_t)0x08000000) /*!< Backup interface reset */
+#define RCC_APB1RSTR_PWRRST ((uint32_t)0x10000000) /*!< Power interface reset */
+
+#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
+ #define RCC_APB1RSTR_TIM4RST ((uint32_t)0x00000004) /*!< Timer 4 reset */
+ #define RCC_APB1RSTR_SPI2RST ((uint32_t)0x00004000) /*!< SPI 2 reset */
+ #define RCC_APB1RSTR_USART3RST ((uint32_t)0x00040000) /*!< USART 3 reset */
+ #define RCC_APB1RSTR_I2C2RST ((uint32_t)0x00400000) /*!< I2C 2 reset */
+#endif /* STM32F10X_LD && STM32F10X_LD_VL */
+
+#if defined (STM32F10X_HD) || defined (STM32F10X_MD) || defined (STM32F10X_LD) || defined (STM32F10X_XL)
+ #define RCC_APB1RSTR_USBRST ((uint32_t)0x00800000) /*!< USB Device reset */
+#endif
+
+#if defined (STM32F10X_HD) || defined (STM32F10X_CL) || defined (STM32F10X_XL)
+ #define RCC_APB1RSTR_TIM5RST ((uint32_t)0x00000008) /*!< Timer 5 reset */
+ #define RCC_APB1RSTR_TIM6RST ((uint32_t)0x00000010) /*!< Timer 6 reset */
+ #define RCC_APB1RSTR_TIM7RST ((uint32_t)0x00000020) /*!< Timer 7 reset */
+ #define RCC_APB1RSTR_SPI3RST ((uint32_t)0x00008000) /*!< SPI 3 reset */
+ #define RCC_APB1RSTR_UART4RST ((uint32_t)0x00080000) /*!< UART 4 reset */
+ #define RCC_APB1RSTR_UART5RST ((uint32_t)0x00100000) /*!< UART 5 reset */
+ #define RCC_APB1RSTR_DACRST ((uint32_t)0x20000000) /*!< DAC interface reset */
+#endif
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+ #define RCC_APB1RSTR_TIM6RST ((uint32_t)0x00000010) /*!< Timer 6 reset */
+ #define RCC_APB1RSTR_TIM7RST ((uint32_t)0x00000020) /*!< Timer 7 reset */
+ #define RCC_APB1RSTR_DACRST ((uint32_t)0x20000000) /*!< DAC interface reset */
+ #define RCC_APB1RSTR_CECRST ((uint32_t)0x40000000) /*!< CEC interface reset */
+#endif
+
+#if defined (STM32F10X_HD_VL)
+ #define RCC_APB1RSTR_TIM5RST ((uint32_t)0x00000008) /*!< Timer 5 reset */
+ #define RCC_APB1RSTR_TIM12RST ((uint32_t)0x00000040) /*!< TIM12 Timer reset */
+ #define RCC_APB1RSTR_TIM13RST ((uint32_t)0x00000080) /*!< TIM13 Timer reset */
+ #define RCC_APB1RSTR_TIM14RST ((uint32_t)0x00000100) /*!< TIM14 Timer reset */
+ #define RCC_APB1RSTR_SPI3RST ((uint32_t)0x00008000) /*!< SPI 3 reset */
+ #define RCC_APB1RSTR_UART4RST ((uint32_t)0x00080000) /*!< UART 4 reset */
+ #define RCC_APB1RSTR_UART5RST ((uint32_t)0x00100000) /*!< UART 5 reset */
+#endif
+
+#ifdef STM32F10X_CL
+ #define RCC_APB1RSTR_CAN2RST ((uint32_t)0x04000000) /*!< CAN2 reset */
+#endif /* STM32F10X_CL */
+
+#ifdef STM32F10X_XL
+ #define RCC_APB1RSTR_TIM12RST ((uint32_t)0x00000040) /*!< TIM12 Timer reset */
+ #define RCC_APB1RSTR_TIM13RST ((uint32_t)0x00000080) /*!< TIM13 Timer reset */
+ #define RCC_APB1RSTR_TIM14RST ((uint32_t)0x00000100) /*!< TIM14 Timer reset */
+#endif /* STM32F10X_XL */
+
+/****************** Bit definition for RCC_AHBENR register ******************/
+#define RCC_AHBENR_DMA1EN ((uint16_t)0x0001) /*!< DMA1 clock enable */
+#define RCC_AHBENR_SRAMEN ((uint16_t)0x0004) /*!< SRAM interface clock enable */
+#define RCC_AHBENR_FLITFEN ((uint16_t)0x0010) /*!< FLITF clock enable */
+#define RCC_AHBENR_CRCEN ((uint16_t)0x0040) /*!< CRC clock enable */
+
+#if defined (STM32F10X_HD) || defined (STM32F10X_CL) || defined (STM32F10X_HD_VL)
+ #define RCC_AHBENR_DMA2EN ((uint16_t)0x0002) /*!< DMA2 clock enable */
+#endif
+
+#if defined (STM32F10X_HD) || defined (STM32F10X_XL)
+ #define RCC_AHBENR_FSMCEN ((uint16_t)0x0100) /*!< FSMC clock enable */
+ #define RCC_AHBENR_SDIOEN ((uint16_t)0x0400) /*!< SDIO clock enable */
+#endif
+
+#if defined (STM32F10X_HD_VL)
+ #define RCC_AHBENR_FSMCEN ((uint16_t)0x0100) /*!< FSMC clock enable */
+#endif
+
+#ifdef STM32F10X_CL
+ #define RCC_AHBENR_OTGFSEN ((uint32_t)0x00001000) /*!< USB OTG FS clock enable */
+ #define RCC_AHBENR_ETHMACEN ((uint32_t)0x00004000) /*!< ETHERNET MAC clock enable */
+ #define RCC_AHBENR_ETHMACTXEN ((uint32_t)0x00008000) /*!< ETHERNET MAC Tx clock enable */
+ #define RCC_AHBENR_ETHMACRXEN ((uint32_t)0x00010000) /*!< ETHERNET MAC Rx clock enable */
+#endif /* STM32F10X_CL */
+
+/****************** Bit definition for RCC_APB2ENR register *****************/
+#define RCC_APB2ENR_AFIOEN ((uint32_t)0x00000001) /*!< Alternate Function I/O clock enable */
+#define RCC_APB2ENR_IOPAEN ((uint32_t)0x00000004) /*!< I/O port A clock enable */
+#define RCC_APB2ENR_IOPBEN ((uint32_t)0x00000008) /*!< I/O port B clock enable */
+#define RCC_APB2ENR_IOPCEN ((uint32_t)0x00000010) /*!< I/O port C clock enable */
+#define RCC_APB2ENR_IOPDEN ((uint32_t)0x00000020) /*!< I/O port D clock enable */
+#define RCC_APB2ENR_ADC1EN ((uint32_t)0x00000200) /*!< ADC 1 interface clock enable */
+
+#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
+#define RCC_APB2ENR_ADC2EN ((uint32_t)0x00000400) /*!< ADC 2 interface clock enable */
+#endif
+
+#define RCC_APB2ENR_TIM1EN ((uint32_t)0x00000800) /*!< TIM1 Timer clock enable */
+#define RCC_APB2ENR_SPI1EN ((uint32_t)0x00001000) /*!< SPI 1 clock enable */
+#define RCC_APB2ENR_USART1EN ((uint32_t)0x00004000) /*!< USART1 clock enable */
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+#define RCC_APB2ENR_TIM15EN ((uint32_t)0x00010000) /*!< TIM15 Timer clock enable */
+#define RCC_APB2ENR_TIM16EN ((uint32_t)0x00020000) /*!< TIM16 Timer clock enable */
+#define RCC_APB2ENR_TIM17EN ((uint32_t)0x00040000) /*!< TIM17 Timer clock enable */
+#endif
+
+#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
+ #define RCC_APB2ENR_IOPEEN ((uint32_t)0x00000040) /*!< I/O port E clock enable */
+#endif /* STM32F10X_LD && STM32F10X_LD_VL */
+
+#if defined (STM32F10X_HD) || defined (STM32F10X_XL)
+ #define RCC_APB2ENR_IOPFEN ((uint32_t)0x00000080) /*!< I/O port F clock enable */
+ #define RCC_APB2ENR_IOPGEN ((uint32_t)0x00000100) /*!< I/O port G clock enable */
+ #define RCC_APB2ENR_TIM8EN ((uint32_t)0x00002000) /*!< TIM8 Timer clock enable */
+ #define RCC_APB2ENR_ADC3EN ((uint32_t)0x00008000) /*!< DMA1 clock enable */
+#endif
+
+#if defined (STM32F10X_HD_VL)
+ #define RCC_APB2ENR_IOPFEN ((uint32_t)0x00000080) /*!< I/O port F clock enable */
+ #define RCC_APB2ENR_IOPGEN ((uint32_t)0x00000100) /*!< I/O port G clock enable */
+#endif
+
+#ifdef STM32F10X_XL
+ #define RCC_APB2ENR_TIM9EN ((uint32_t)0x00080000) /*!< TIM9 Timer clock enable */
+ #define RCC_APB2ENR_TIM10EN ((uint32_t)0x00100000) /*!< TIM10 Timer clock enable */
+ #define RCC_APB2ENR_TIM11EN ((uint32_t)0x00200000) /*!< TIM11 Timer clock enable */
+#endif
+
+/***************** Bit definition for RCC_APB1ENR register ******************/
+#define RCC_APB1ENR_TIM2EN ((uint32_t)0x00000001) /*!< Timer 2 clock enabled*/
+#define RCC_APB1ENR_TIM3EN ((uint32_t)0x00000002) /*!< Timer 3 clock enable */
+#define RCC_APB1ENR_WWDGEN ((uint32_t)0x00000800) /*!< Window Watchdog clock enable */
+#define RCC_APB1ENR_USART2EN ((uint32_t)0x00020000) /*!< USART 2 clock enable */
+#define RCC_APB1ENR_I2C1EN ((uint32_t)0x00200000) /*!< I2C 1 clock enable */
+
+#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL)
+#define RCC_APB1ENR_CAN1EN ((uint32_t)0x02000000) /*!< CAN1 clock enable */
+#endif
+
+#define RCC_APB1ENR_BKPEN ((uint32_t)0x08000000) /*!< Backup interface clock enable */
+#define RCC_APB1ENR_PWREN ((uint32_t)0x10000000) /*!< Power interface clock enable */
+
+#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL)
+ #define RCC_APB1ENR_TIM4EN ((uint32_t)0x00000004) /*!< Timer 4 clock enable */
+ #define RCC_APB1ENR_SPI2EN ((uint32_t)0x00004000) /*!< SPI 2 clock enable */
+ #define RCC_APB1ENR_USART3EN ((uint32_t)0x00040000) /*!< USART 3 clock enable */
+ #define RCC_APB1ENR_I2C2EN ((uint32_t)0x00400000) /*!< I2C 2 clock enable */
+#endif /* STM32F10X_LD && STM32F10X_LD_VL */
+
+#if defined (STM32F10X_HD) || defined (STM32F10X_MD) || defined (STM32F10X_LD)
+ #define RCC_APB1ENR_USBEN ((uint32_t)0x00800000) /*!< USB Device clock enable */
+#endif
+
+#if defined (STM32F10X_HD) || defined (STM32F10X_CL)
+ #define RCC_APB1ENR_TIM5EN ((uint32_t)0x00000008) /*!< Timer 5 clock enable */
+ #define RCC_APB1ENR_TIM6EN ((uint32_t)0x00000010) /*!< Timer 6 clock enable */
+ #define RCC_APB1ENR_TIM7EN ((uint32_t)0x00000020) /*!< Timer 7 clock enable */
+ #define RCC_APB1ENR_SPI3EN ((uint32_t)0x00008000) /*!< SPI 3 clock enable */
+ #define RCC_APB1ENR_UART4EN ((uint32_t)0x00080000) /*!< UART 4 clock enable */
+ #define RCC_APB1ENR_UART5EN ((uint32_t)0x00100000) /*!< UART 5 clock enable */
+ #define RCC_APB1ENR_DACEN ((uint32_t)0x20000000) /*!< DAC interface clock enable */
+#endif
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+ #define RCC_APB1ENR_TIM6EN ((uint32_t)0x00000010) /*!< Timer 6 clock enable */
+ #define RCC_APB1ENR_TIM7EN ((uint32_t)0x00000020) /*!< Timer 7 clock enable */
+ #define RCC_APB1ENR_DACEN ((uint32_t)0x20000000) /*!< DAC interface clock enable */
+ #define RCC_APB1ENR_CECEN ((uint32_t)0x40000000) /*!< CEC interface clock enable */
+#endif
+
+#ifdef STM32F10X_HD_VL
+ #define RCC_APB1ENR_TIM5EN ((uint32_t)0x00000008) /*!< Timer 5 clock enable */
+ #define RCC_APB1ENR_TIM12EN ((uint32_t)0x00000040) /*!< TIM12 Timer clock enable */
+ #define RCC_APB1ENR_TIM13EN ((uint32_t)0x00000080) /*!< TIM13 Timer clock enable */
+ #define RCC_APB1ENR_TIM14EN ((uint32_t)0x00000100) /*!< TIM14 Timer clock enable */
+ #define RCC_APB1ENR_SPI3EN ((uint32_t)0x00008000) /*!< SPI 3 clock enable */
+ #define RCC_APB1ENR_UART4EN ((uint32_t)0x00080000) /*!< UART 4 clock enable */
+ #define RCC_APB1ENR_UART5EN ((uint32_t)0x00100000) /*!< UART 5 clock enable */
+#endif /* STM32F10X_HD_VL */
+
+#ifdef STM32F10X_CL
+ #define RCC_APB1ENR_CAN2EN ((uint32_t)0x04000000) /*!< CAN2 clock enable */
+#endif /* STM32F10X_CL */
+
+#ifdef STM32F10X_XL
+ #define RCC_APB1ENR_TIM12EN ((uint32_t)0x00000040) /*!< TIM12 Timer clock enable */
+ #define RCC_APB1ENR_TIM13EN ((uint32_t)0x00000080) /*!< TIM13 Timer clock enable */
+ #define RCC_APB1ENR_TIM14EN ((uint32_t)0x00000100) /*!< TIM14 Timer clock enable */
+#endif /* STM32F10X_XL */
+
+/******************* Bit definition for RCC_BDCR register *******************/
+#define RCC_BDCR_LSEON ((uint32_t)0x00000001) /*!< External Low Speed oscillator enable */
+#define RCC_BDCR_LSERDY ((uint32_t)0x00000002) /*!< External Low Speed oscillator Ready */
+#define RCC_BDCR_LSEBYP ((uint32_t)0x00000004) /*!< External Low Speed oscillator Bypass */
+
+#define RCC_BDCR_RTCSEL ((uint32_t)0x00000300) /*!< RTCSEL[1:0] bits (RTC clock source selection) */
+#define RCC_BDCR_RTCSEL_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define RCC_BDCR_RTCSEL_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+
+/*!< RTC congiguration */
+#define RCC_BDCR_RTCSEL_NOCLOCK ((uint32_t)0x00000000) /*!< No clock */
+#define RCC_BDCR_RTCSEL_LSE ((uint32_t)0x00000100) /*!< LSE oscillator clock used as RTC clock */
+#define RCC_BDCR_RTCSEL_LSI ((uint32_t)0x00000200) /*!< LSI oscillator clock used as RTC clock */
+#define RCC_BDCR_RTCSEL_HSE ((uint32_t)0x00000300) /*!< HSE oscillator clock divided by 128 used as RTC clock */
+
+#define RCC_BDCR_RTCEN ((uint32_t)0x00008000) /*!< RTC clock enable */
+#define RCC_BDCR_BDRST ((uint32_t)0x00010000) /*!< Backup domain software reset */
+
+/******************* Bit definition for RCC_CSR register ********************/
+#define RCC_CSR_LSION ((uint32_t)0x00000001) /*!< Internal Low Speed oscillator enable */
+#define RCC_CSR_LSIRDY ((uint32_t)0x00000002) /*!< Internal Low Speed oscillator Ready */
+#define RCC_CSR_RMVF ((uint32_t)0x01000000) /*!< Remove reset flag */
+#define RCC_CSR_PINRSTF ((uint32_t)0x04000000) /*!< PIN reset flag */
+#define RCC_CSR_PORRSTF ((uint32_t)0x08000000) /*!< POR/PDR reset flag */
+#define RCC_CSR_SFTRSTF ((uint32_t)0x10000000) /*!< Software Reset flag */
+#define RCC_CSR_IWDGRSTF ((uint32_t)0x20000000) /*!< Independent Watchdog reset flag */
+#define RCC_CSR_WWDGRSTF ((uint32_t)0x40000000) /*!< Window watchdog reset flag */
+#define RCC_CSR_LPWRRSTF ((uint32_t)0x80000000) /*!< Low-Power reset flag */
+
+#ifdef STM32F10X_CL
+/******************* Bit definition for RCC_AHBRSTR register ****************/
+ #define RCC_AHBRSTR_OTGFSRST ((uint32_t)0x00001000) /*!< USB OTG FS reset */
+ #define RCC_AHBRSTR_ETHMACRST ((uint32_t)0x00004000) /*!< ETHERNET MAC reset */
+
+/******************* Bit definition for RCC_CFGR2 register ******************/
+/*!< PREDIV1 configuration */
+ #define RCC_CFGR2_PREDIV1 ((uint32_t)0x0000000F) /*!< PREDIV1[3:0] bits */
+ #define RCC_CFGR2_PREDIV1_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+ #define RCC_CFGR2_PREDIV1_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+ #define RCC_CFGR2_PREDIV1_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+ #define RCC_CFGR2_PREDIV1_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+
+ #define RCC_CFGR2_PREDIV1_DIV1 ((uint32_t)0x00000000) /*!< PREDIV1 input clock not divided */
+ #define RCC_CFGR2_PREDIV1_DIV2 ((uint32_t)0x00000001) /*!< PREDIV1 input clock divided by 2 */
+ #define RCC_CFGR2_PREDIV1_DIV3 ((uint32_t)0x00000002) /*!< PREDIV1 input clock divided by 3 */
+ #define RCC_CFGR2_PREDIV1_DIV4 ((uint32_t)0x00000003) /*!< PREDIV1 input clock divided by 4 */
+ #define RCC_CFGR2_PREDIV1_DIV5 ((uint32_t)0x00000004) /*!< PREDIV1 input clock divided by 5 */
+ #define RCC_CFGR2_PREDIV1_DIV6 ((uint32_t)0x00000005) /*!< PREDIV1 input clock divided by 6 */
+ #define RCC_CFGR2_PREDIV1_DIV7 ((uint32_t)0x00000006) /*!< PREDIV1 input clock divided by 7 */
+ #define RCC_CFGR2_PREDIV1_DIV8 ((uint32_t)0x00000007) /*!< PREDIV1 input clock divided by 8 */
+ #define RCC_CFGR2_PREDIV1_DIV9 ((uint32_t)0x00000008) /*!< PREDIV1 input clock divided by 9 */
+ #define RCC_CFGR2_PREDIV1_DIV10 ((uint32_t)0x00000009) /*!< PREDIV1 input clock divided by 10 */
+ #define RCC_CFGR2_PREDIV1_DIV11 ((uint32_t)0x0000000A) /*!< PREDIV1 input clock divided by 11 */
+ #define RCC_CFGR2_PREDIV1_DIV12 ((uint32_t)0x0000000B) /*!< PREDIV1 input clock divided by 12 */
+ #define RCC_CFGR2_PREDIV1_DIV13 ((uint32_t)0x0000000C) /*!< PREDIV1 input clock divided by 13 */
+ #define RCC_CFGR2_PREDIV1_DIV14 ((uint32_t)0x0000000D) /*!< PREDIV1 input clock divided by 14 */
+ #define RCC_CFGR2_PREDIV1_DIV15 ((uint32_t)0x0000000E) /*!< PREDIV1 input clock divided by 15 */
+ #define RCC_CFGR2_PREDIV1_DIV16 ((uint32_t)0x0000000F) /*!< PREDIV1 input clock divided by 16 */
+
+/*!< PREDIV2 configuration */
+ #define RCC_CFGR2_PREDIV2 ((uint32_t)0x000000F0) /*!< PREDIV2[3:0] bits */
+ #define RCC_CFGR2_PREDIV2_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+ #define RCC_CFGR2_PREDIV2_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+ #define RCC_CFGR2_PREDIV2_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+ #define RCC_CFGR2_PREDIV2_3 ((uint32_t)0x00000080) /*!< Bit 3 */
+
+ #define RCC_CFGR2_PREDIV2_DIV1 ((uint32_t)0x00000000) /*!< PREDIV2 input clock not divided */
+ #define RCC_CFGR2_PREDIV2_DIV2 ((uint32_t)0x00000010) /*!< PREDIV2 input clock divided by 2 */
+ #define RCC_CFGR2_PREDIV2_DIV3 ((uint32_t)0x00000020) /*!< PREDIV2 input clock divided by 3 */
+ #define RCC_CFGR2_PREDIV2_DIV4 ((uint32_t)0x00000030) /*!< PREDIV2 input clock divided by 4 */
+ #define RCC_CFGR2_PREDIV2_DIV5 ((uint32_t)0x00000040) /*!< PREDIV2 input clock divided by 5 */
+ #define RCC_CFGR2_PREDIV2_DIV6 ((uint32_t)0x00000050) /*!< PREDIV2 input clock divided by 6 */
+ #define RCC_CFGR2_PREDIV2_DIV7 ((uint32_t)0x00000060) /*!< PREDIV2 input clock divided by 7 */
+ #define RCC_CFGR2_PREDIV2_DIV8 ((uint32_t)0x00000070) /*!< PREDIV2 input clock divided by 8 */
+ #define RCC_CFGR2_PREDIV2_DIV9 ((uint32_t)0x00000080) /*!< PREDIV2 input clock divided by 9 */
+ #define RCC_CFGR2_PREDIV2_DIV10 ((uint32_t)0x00000090) /*!< PREDIV2 input clock divided by 10 */
+ #define RCC_CFGR2_PREDIV2_DIV11 ((uint32_t)0x000000A0) /*!< PREDIV2 input clock divided by 11 */
+ #define RCC_CFGR2_PREDIV2_DIV12 ((uint32_t)0x000000B0) /*!< PREDIV2 input clock divided by 12 */
+ #define RCC_CFGR2_PREDIV2_DIV13 ((uint32_t)0x000000C0) /*!< PREDIV2 input clock divided by 13 */
+ #define RCC_CFGR2_PREDIV2_DIV14 ((uint32_t)0x000000D0) /*!< PREDIV2 input clock divided by 14 */
+ #define RCC_CFGR2_PREDIV2_DIV15 ((uint32_t)0x000000E0) /*!< PREDIV2 input clock divided by 15 */
+ #define RCC_CFGR2_PREDIV2_DIV16 ((uint32_t)0x000000F0) /*!< PREDIV2 input clock divided by 16 */
+
+/*!< PLL2MUL configuration */
+ #define RCC_CFGR2_PLL2MUL ((uint32_t)0x00000F00) /*!< PLL2MUL[3:0] bits */
+ #define RCC_CFGR2_PLL2MUL_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+ #define RCC_CFGR2_PLL2MUL_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+ #define RCC_CFGR2_PLL2MUL_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+ #define RCC_CFGR2_PLL2MUL_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+
+ #define RCC_CFGR2_PLL2MUL8 ((uint32_t)0x00000600) /*!< PLL2 input clock * 8 */
+ #define RCC_CFGR2_PLL2MUL9 ((uint32_t)0x00000700) /*!< PLL2 input clock * 9 */
+ #define RCC_CFGR2_PLL2MUL10 ((uint32_t)0x00000800) /*!< PLL2 input clock * 10 */
+ #define RCC_CFGR2_PLL2MUL11 ((uint32_t)0x00000900) /*!< PLL2 input clock * 11 */
+ #define RCC_CFGR2_PLL2MUL12 ((uint32_t)0x00000A00) /*!< PLL2 input clock * 12 */
+ #define RCC_CFGR2_PLL2MUL13 ((uint32_t)0x00000B00) /*!< PLL2 input clock * 13 */
+ #define RCC_CFGR2_PLL2MUL14 ((uint32_t)0x00000C00) /*!< PLL2 input clock * 14 */
+ #define RCC_CFGR2_PLL2MUL16 ((uint32_t)0x00000E00) /*!< PLL2 input clock * 16 */
+ #define RCC_CFGR2_PLL2MUL20 ((uint32_t)0x00000F00) /*!< PLL2 input clock * 20 */
+
+/*!< PLL3MUL configuration */
+ #define RCC_CFGR2_PLL3MUL ((uint32_t)0x0000F000) /*!< PLL3MUL[3:0] bits */
+ #define RCC_CFGR2_PLL3MUL_0 ((uint32_t)0x00001000) /*!< Bit 0 */
+ #define RCC_CFGR2_PLL3MUL_1 ((uint32_t)0x00002000) /*!< Bit 1 */
+ #define RCC_CFGR2_PLL3MUL_2 ((uint32_t)0x00004000) /*!< Bit 2 */
+ #define RCC_CFGR2_PLL3MUL_3 ((uint32_t)0x00008000) /*!< Bit 3 */
+
+ #define RCC_CFGR2_PLL3MUL8 ((uint32_t)0x00006000) /*!< PLL3 input clock * 8 */
+ #define RCC_CFGR2_PLL3MUL9 ((uint32_t)0x00007000) /*!< PLL3 input clock * 9 */
+ #define RCC_CFGR2_PLL3MUL10 ((uint32_t)0x00008000) /*!< PLL3 input clock * 10 */
+ #define RCC_CFGR2_PLL3MUL11 ((uint32_t)0x00009000) /*!< PLL3 input clock * 11 */
+ #define RCC_CFGR2_PLL3MUL12 ((uint32_t)0x0000A000) /*!< PLL3 input clock * 12 */
+ #define RCC_CFGR2_PLL3MUL13 ((uint32_t)0x0000B000) /*!< PLL3 input clock * 13 */
+ #define RCC_CFGR2_PLL3MUL14 ((uint32_t)0x0000C000) /*!< PLL3 input clock * 14 */
+ #define RCC_CFGR2_PLL3MUL16 ((uint32_t)0x0000E000) /*!< PLL3 input clock * 16 */
+ #define RCC_CFGR2_PLL3MUL20 ((uint32_t)0x0000F000) /*!< PLL3 input clock * 20 */
+
+ #define RCC_CFGR2_PREDIV1SRC ((uint32_t)0x00010000) /*!< PREDIV1 entry clock source */
+ #define RCC_CFGR2_PREDIV1SRC_PLL2 ((uint32_t)0x00010000) /*!< PLL2 selected as PREDIV1 entry clock source */
+ #define RCC_CFGR2_PREDIV1SRC_HSE ((uint32_t)0x00000000) /*!< HSE selected as PREDIV1 entry clock source */
+ #define RCC_CFGR2_I2S2SRC ((uint32_t)0x00020000) /*!< I2S2 entry clock source */
+ #define RCC_CFGR2_I2S3SRC ((uint32_t)0x00040000) /*!< I2S3 clock source */
+#endif /* STM32F10X_CL */
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+/******************* Bit definition for RCC_CFGR2 register ******************/
+/*!< PREDIV1 configuration */
+ #define RCC_CFGR2_PREDIV1 ((uint32_t)0x0000000F) /*!< PREDIV1[3:0] bits */
+ #define RCC_CFGR2_PREDIV1_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+ #define RCC_CFGR2_PREDIV1_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+ #define RCC_CFGR2_PREDIV1_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+ #define RCC_CFGR2_PREDIV1_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+
+ #define RCC_CFGR2_PREDIV1_DIV1 ((uint32_t)0x00000000) /*!< PREDIV1 input clock not divided */
+ #define RCC_CFGR2_PREDIV1_DIV2 ((uint32_t)0x00000001) /*!< PREDIV1 input clock divided by 2 */
+ #define RCC_CFGR2_PREDIV1_DIV3 ((uint32_t)0x00000002) /*!< PREDIV1 input clock divided by 3 */
+ #define RCC_CFGR2_PREDIV1_DIV4 ((uint32_t)0x00000003) /*!< PREDIV1 input clock divided by 4 */
+ #define RCC_CFGR2_PREDIV1_DIV5 ((uint32_t)0x00000004) /*!< PREDIV1 input clock divided by 5 */
+ #define RCC_CFGR2_PREDIV1_DIV6 ((uint32_t)0x00000005) /*!< PREDIV1 input clock divided by 6 */
+ #define RCC_CFGR2_PREDIV1_DIV7 ((uint32_t)0x00000006) /*!< PREDIV1 input clock divided by 7 */
+ #define RCC_CFGR2_PREDIV1_DIV8 ((uint32_t)0x00000007) /*!< PREDIV1 input clock divided by 8 */
+ #define RCC_CFGR2_PREDIV1_DIV9 ((uint32_t)0x00000008) /*!< PREDIV1 input clock divided by 9 */
+ #define RCC_CFGR2_PREDIV1_DIV10 ((uint32_t)0x00000009) /*!< PREDIV1 input clock divided by 10 */
+ #define RCC_CFGR2_PREDIV1_DIV11 ((uint32_t)0x0000000A) /*!< PREDIV1 input clock divided by 11 */
+ #define RCC_CFGR2_PREDIV1_DIV12 ((uint32_t)0x0000000B) /*!< PREDIV1 input clock divided by 12 */
+ #define RCC_CFGR2_PREDIV1_DIV13 ((uint32_t)0x0000000C) /*!< PREDIV1 input clock divided by 13 */
+ #define RCC_CFGR2_PREDIV1_DIV14 ((uint32_t)0x0000000D) /*!< PREDIV1 input clock divided by 14 */
+ #define RCC_CFGR2_PREDIV1_DIV15 ((uint32_t)0x0000000E) /*!< PREDIV1 input clock divided by 15 */
+ #define RCC_CFGR2_PREDIV1_DIV16 ((uint32_t)0x0000000F) /*!< PREDIV1 input clock divided by 16 */
+#endif
+
+/******************************************************************************/
+/* */
+/* General Purpose and Alternate Function I/O */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for GPIO_CRL register *******************/
+#define GPIO_CRL_MODE ((uint32_t)0x33333333) /*!< Port x mode bits */
+
+#define GPIO_CRL_MODE0 ((uint32_t)0x00000003) /*!< MODE0[1:0] bits (Port x mode bits, pin 0) */
+#define GPIO_CRL_MODE0_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define GPIO_CRL_MODE0_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+
+#define GPIO_CRL_MODE1 ((uint32_t)0x00000030) /*!< MODE1[1:0] bits (Port x mode bits, pin 1) */
+#define GPIO_CRL_MODE1_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define GPIO_CRL_MODE1_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+
+#define GPIO_CRL_MODE2 ((uint32_t)0x00000300) /*!< MODE2[1:0] bits (Port x mode bits, pin 2) */
+#define GPIO_CRL_MODE2_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define GPIO_CRL_MODE2_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+
+#define GPIO_CRL_MODE3 ((uint32_t)0x00003000) /*!< MODE3[1:0] bits (Port x mode bits, pin 3) */
+#define GPIO_CRL_MODE3_0 ((uint32_t)0x00001000) /*!< Bit 0 */
+#define GPIO_CRL_MODE3_1 ((uint32_t)0x00002000) /*!< Bit 1 */
+
+#define GPIO_CRL_MODE4 ((uint32_t)0x00030000) /*!< MODE4[1:0] bits (Port x mode bits, pin 4) */
+#define GPIO_CRL_MODE4_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define GPIO_CRL_MODE4_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+
+#define GPIO_CRL_MODE5 ((uint32_t)0x00300000) /*!< MODE5[1:0] bits (Port x mode bits, pin 5) */
+#define GPIO_CRL_MODE5_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define GPIO_CRL_MODE5_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+
+#define GPIO_CRL_MODE6 ((uint32_t)0x03000000) /*!< MODE6[1:0] bits (Port x mode bits, pin 6) */
+#define GPIO_CRL_MODE6_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define GPIO_CRL_MODE6_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+
+#define GPIO_CRL_MODE7 ((uint32_t)0x30000000) /*!< MODE7[1:0] bits (Port x mode bits, pin 7) */
+#define GPIO_CRL_MODE7_0 ((uint32_t)0x10000000) /*!< Bit 0 */
+#define GPIO_CRL_MODE7_1 ((uint32_t)0x20000000) /*!< Bit 1 */
+
+#define GPIO_CRL_CNF ((uint32_t)0xCCCCCCCC) /*!< Port x configuration bits */
+
+#define GPIO_CRL_CNF0 ((uint32_t)0x0000000C) /*!< CNF0[1:0] bits (Port x configuration bits, pin 0) */
+#define GPIO_CRL_CNF0_0 ((uint32_t)0x00000004) /*!< Bit 0 */
+#define GPIO_CRL_CNF0_1 ((uint32_t)0x00000008) /*!< Bit 1 */
+
+#define GPIO_CRL_CNF1 ((uint32_t)0x000000C0) /*!< CNF1[1:0] bits (Port x configuration bits, pin 1) */
+#define GPIO_CRL_CNF1_0 ((uint32_t)0x00000040) /*!< Bit 0 */
+#define GPIO_CRL_CNF1_1 ((uint32_t)0x00000080) /*!< Bit 1 */
+
+#define GPIO_CRL_CNF2 ((uint32_t)0x00000C00) /*!< CNF2[1:0] bits (Port x configuration bits, pin 2) */
+#define GPIO_CRL_CNF2_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define GPIO_CRL_CNF2_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+
+#define GPIO_CRL_CNF3 ((uint32_t)0x0000C000) /*!< CNF3[1:0] bits (Port x configuration bits, pin 3) */
+#define GPIO_CRL_CNF3_0 ((uint32_t)0x00004000) /*!< Bit 0 */
+#define GPIO_CRL_CNF3_1 ((uint32_t)0x00008000) /*!< Bit 1 */
+
+#define GPIO_CRL_CNF4 ((uint32_t)0x000C0000) /*!< CNF4[1:0] bits (Port x configuration bits, pin 4) */
+#define GPIO_CRL_CNF4_0 ((uint32_t)0x00040000) /*!< Bit 0 */
+#define GPIO_CRL_CNF4_1 ((uint32_t)0x00080000) /*!< Bit 1 */
+
+#define GPIO_CRL_CNF5 ((uint32_t)0x00C00000) /*!< CNF5[1:0] bits (Port x configuration bits, pin 5) */
+#define GPIO_CRL_CNF5_0 ((uint32_t)0x00400000) /*!< Bit 0 */
+#define GPIO_CRL_CNF5_1 ((uint32_t)0x00800000) /*!< Bit 1 */
+
+#define GPIO_CRL_CNF6 ((uint32_t)0x0C000000) /*!< CNF6[1:0] bits (Port x configuration bits, pin 6) */
+#define GPIO_CRL_CNF6_0 ((uint32_t)0x04000000) /*!< Bit 0 */
+#define GPIO_CRL_CNF6_1 ((uint32_t)0x08000000) /*!< Bit 1 */
+
+#define GPIO_CRL_CNF7 ((uint32_t)0xC0000000) /*!< CNF7[1:0] bits (Port x configuration bits, pin 7) */
+#define GPIO_CRL_CNF7_0 ((uint32_t)0x40000000) /*!< Bit 0 */
+#define GPIO_CRL_CNF7_1 ((uint32_t)0x80000000) /*!< Bit 1 */
+
+/******************* Bit definition for GPIO_CRH register *******************/
+#define GPIO_CRH_MODE ((uint32_t)0x33333333) /*!< Port x mode bits */
+
+#define GPIO_CRH_MODE8 ((uint32_t)0x00000003) /*!< MODE8[1:0] bits (Port x mode bits, pin 8) */
+#define GPIO_CRH_MODE8_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define GPIO_CRH_MODE8_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+
+#define GPIO_CRH_MODE9 ((uint32_t)0x00000030) /*!< MODE9[1:0] bits (Port x mode bits, pin 9) */
+#define GPIO_CRH_MODE9_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define GPIO_CRH_MODE9_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+
+#define GPIO_CRH_MODE10 ((uint32_t)0x00000300) /*!< MODE10[1:0] bits (Port x mode bits, pin 10) */
+#define GPIO_CRH_MODE10_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define GPIO_CRH_MODE10_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+
+#define GPIO_CRH_MODE11 ((uint32_t)0x00003000) /*!< MODE11[1:0] bits (Port x mode bits, pin 11) */
+#define GPIO_CRH_MODE11_0 ((uint32_t)0x00001000) /*!< Bit 0 */
+#define GPIO_CRH_MODE11_1 ((uint32_t)0x00002000) /*!< Bit 1 */
+
+#define GPIO_CRH_MODE12 ((uint32_t)0x00030000) /*!< MODE12[1:0] bits (Port x mode bits, pin 12) */
+#define GPIO_CRH_MODE12_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define GPIO_CRH_MODE12_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+
+#define GPIO_CRH_MODE13 ((uint32_t)0x00300000) /*!< MODE13[1:0] bits (Port x mode bits, pin 13) */
+#define GPIO_CRH_MODE13_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define GPIO_CRH_MODE13_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+
+#define GPIO_CRH_MODE14 ((uint32_t)0x03000000) /*!< MODE14[1:0] bits (Port x mode bits, pin 14) */
+#define GPIO_CRH_MODE14_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define GPIO_CRH_MODE14_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+
+#define GPIO_CRH_MODE15 ((uint32_t)0x30000000) /*!< MODE15[1:0] bits (Port x mode bits, pin 15) */
+#define GPIO_CRH_MODE15_0 ((uint32_t)0x10000000) /*!< Bit 0 */
+#define GPIO_CRH_MODE15_1 ((uint32_t)0x20000000) /*!< Bit 1 */
+
+#define GPIO_CRH_CNF ((uint32_t)0xCCCCCCCC) /*!< Port x configuration bits */
+
+#define GPIO_CRH_CNF8 ((uint32_t)0x0000000C) /*!< CNF8[1:0] bits (Port x configuration bits, pin 8) */
+#define GPIO_CRH_CNF8_0 ((uint32_t)0x00000004) /*!< Bit 0 */
+#define GPIO_CRH_CNF8_1 ((uint32_t)0x00000008) /*!< Bit 1 */
+
+#define GPIO_CRH_CNF9 ((uint32_t)0x000000C0) /*!< CNF9[1:0] bits (Port x configuration bits, pin 9) */
+#define GPIO_CRH_CNF9_0 ((uint32_t)0x00000040) /*!< Bit 0 */
+#define GPIO_CRH_CNF9_1 ((uint32_t)0x00000080) /*!< Bit 1 */
+
+#define GPIO_CRH_CNF10 ((uint32_t)0x00000C00) /*!< CNF10[1:0] bits (Port x configuration bits, pin 10) */
+#define GPIO_CRH_CNF10_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define GPIO_CRH_CNF10_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+
+#define GPIO_CRH_CNF11 ((uint32_t)0x0000C000) /*!< CNF11[1:0] bits (Port x configuration bits, pin 11) */
+#define GPIO_CRH_CNF11_0 ((uint32_t)0x00004000) /*!< Bit 0 */
+#define GPIO_CRH_CNF11_1 ((uint32_t)0x00008000) /*!< Bit 1 */
+
+#define GPIO_CRH_CNF12 ((uint32_t)0x000C0000) /*!< CNF12[1:0] bits (Port x configuration bits, pin 12) */
+#define GPIO_CRH_CNF12_0 ((uint32_t)0x00040000) /*!< Bit 0 */
+#define GPIO_CRH_CNF12_1 ((uint32_t)0x00080000) /*!< Bit 1 */
+
+#define GPIO_CRH_CNF13 ((uint32_t)0x00C00000) /*!< CNF13[1:0] bits (Port x configuration bits, pin 13) */
+#define GPIO_CRH_CNF13_0 ((uint32_t)0x00400000) /*!< Bit 0 */
+#define GPIO_CRH_CNF13_1 ((uint32_t)0x00800000) /*!< Bit 1 */
+
+#define GPIO_CRH_CNF14 ((uint32_t)0x0C000000) /*!< CNF14[1:0] bits (Port x configuration bits, pin 14) */
+#define GPIO_CRH_CNF14_0 ((uint32_t)0x04000000) /*!< Bit 0 */
+#define GPIO_CRH_CNF14_1 ((uint32_t)0x08000000) /*!< Bit 1 */
+
+#define GPIO_CRH_CNF15 ((uint32_t)0xC0000000) /*!< CNF15[1:0] bits (Port x configuration bits, pin 15) */
+#define GPIO_CRH_CNF15_0 ((uint32_t)0x40000000) /*!< Bit 0 */
+#define GPIO_CRH_CNF15_1 ((uint32_t)0x80000000) /*!< Bit 1 */
+
+/*!<****************** Bit definition for GPIO_IDR register *******************/
+#define GPIO_IDR_IDR0 ((uint16_t)0x0001) /*!< Port input data, bit 0 */
+#define GPIO_IDR_IDR1 ((uint16_t)0x0002) /*!< Port input data, bit 1 */
+#define GPIO_IDR_IDR2 ((uint16_t)0x0004) /*!< Port input data, bit 2 */
+#define GPIO_IDR_IDR3 ((uint16_t)0x0008) /*!< Port input data, bit 3 */
+#define GPIO_IDR_IDR4 ((uint16_t)0x0010) /*!< Port input data, bit 4 */
+#define GPIO_IDR_IDR5 ((uint16_t)0x0020) /*!< Port input data, bit 5 */
+#define GPIO_IDR_IDR6 ((uint16_t)0x0040) /*!< Port input data, bit 6 */
+#define GPIO_IDR_IDR7 ((uint16_t)0x0080) /*!< Port input data, bit 7 */
+#define GPIO_IDR_IDR8 ((uint16_t)0x0100) /*!< Port input data, bit 8 */
+#define GPIO_IDR_IDR9 ((uint16_t)0x0200) /*!< Port input data, bit 9 */
+#define GPIO_IDR_IDR10 ((uint16_t)0x0400) /*!< Port input data, bit 10 */
+#define GPIO_IDR_IDR11 ((uint16_t)0x0800) /*!< Port input data, bit 11 */
+#define GPIO_IDR_IDR12 ((uint16_t)0x1000) /*!< Port input data, bit 12 */
+#define GPIO_IDR_IDR13 ((uint16_t)0x2000) /*!< Port input data, bit 13 */
+#define GPIO_IDR_IDR14 ((uint16_t)0x4000) /*!< Port input data, bit 14 */
+#define GPIO_IDR_IDR15 ((uint16_t)0x8000) /*!< Port input data, bit 15 */
+
+/******************* Bit definition for GPIO_ODR register *******************/
+#define GPIO_ODR_ODR0 ((uint16_t)0x0001) /*!< Port output data, bit 0 */
+#define GPIO_ODR_ODR1 ((uint16_t)0x0002) /*!< Port output data, bit 1 */
+#define GPIO_ODR_ODR2 ((uint16_t)0x0004) /*!< Port output data, bit 2 */
+#define GPIO_ODR_ODR3 ((uint16_t)0x0008) /*!< Port output data, bit 3 */
+#define GPIO_ODR_ODR4 ((uint16_t)0x0010) /*!< Port output data, bit 4 */
+#define GPIO_ODR_ODR5 ((uint16_t)0x0020) /*!< Port output data, bit 5 */
+#define GPIO_ODR_ODR6 ((uint16_t)0x0040) /*!< Port output data, bit 6 */
+#define GPIO_ODR_ODR7 ((uint16_t)0x0080) /*!< Port output data, bit 7 */
+#define GPIO_ODR_ODR8 ((uint16_t)0x0100) /*!< Port output data, bit 8 */
+#define GPIO_ODR_ODR9 ((uint16_t)0x0200) /*!< Port output data, bit 9 */
+#define GPIO_ODR_ODR10 ((uint16_t)0x0400) /*!< Port output data, bit 10 */
+#define GPIO_ODR_ODR11 ((uint16_t)0x0800) /*!< Port output data, bit 11 */
+#define GPIO_ODR_ODR12 ((uint16_t)0x1000) /*!< Port output data, bit 12 */
+#define GPIO_ODR_ODR13 ((uint16_t)0x2000) /*!< Port output data, bit 13 */
+#define GPIO_ODR_ODR14 ((uint16_t)0x4000) /*!< Port output data, bit 14 */
+#define GPIO_ODR_ODR15 ((uint16_t)0x8000) /*!< Port output data, bit 15 */
+
+/****************** Bit definition for GPIO_BSRR register *******************/
+#define GPIO_BSRR_BS0 ((uint32_t)0x00000001) /*!< Port x Set bit 0 */
+#define GPIO_BSRR_BS1 ((uint32_t)0x00000002) /*!< Port x Set bit 1 */
+#define GPIO_BSRR_BS2 ((uint32_t)0x00000004) /*!< Port x Set bit 2 */
+#define GPIO_BSRR_BS3 ((uint32_t)0x00000008) /*!< Port x Set bit 3 */
+#define GPIO_BSRR_BS4 ((uint32_t)0x00000010) /*!< Port x Set bit 4 */
+#define GPIO_BSRR_BS5 ((uint32_t)0x00000020) /*!< Port x Set bit 5 */
+#define GPIO_BSRR_BS6 ((uint32_t)0x00000040) /*!< Port x Set bit 6 */
+#define GPIO_BSRR_BS7 ((uint32_t)0x00000080) /*!< Port x Set bit 7 */
+#define GPIO_BSRR_BS8 ((uint32_t)0x00000100) /*!< Port x Set bit 8 */
+#define GPIO_BSRR_BS9 ((uint32_t)0x00000200) /*!< Port x Set bit 9 */
+#define GPIO_BSRR_BS10 ((uint32_t)0x00000400) /*!< Port x Set bit 10 */
+#define GPIO_BSRR_BS11 ((uint32_t)0x00000800) /*!< Port x Set bit 11 */
+#define GPIO_BSRR_BS12 ((uint32_t)0x00001000) /*!< Port x Set bit 12 */
+#define GPIO_BSRR_BS13 ((uint32_t)0x00002000) /*!< Port x Set bit 13 */
+#define GPIO_BSRR_BS14 ((uint32_t)0x00004000) /*!< Port x Set bit 14 */
+#define GPIO_BSRR_BS15 ((uint32_t)0x00008000) /*!< Port x Set bit 15 */
+
+#define GPIO_BSRR_BR0 ((uint32_t)0x00010000) /*!< Port x Reset bit 0 */
+#define GPIO_BSRR_BR1 ((uint32_t)0x00020000) /*!< Port x Reset bit 1 */
+#define GPIO_BSRR_BR2 ((uint32_t)0x00040000) /*!< Port x Reset bit 2 */
+#define GPIO_BSRR_BR3 ((uint32_t)0x00080000) /*!< Port x Reset bit 3 */
+#define GPIO_BSRR_BR4 ((uint32_t)0x00100000) /*!< Port x Reset bit 4 */
+#define GPIO_BSRR_BR5 ((uint32_t)0x00200000) /*!< Port x Reset bit 5 */
+#define GPIO_BSRR_BR6 ((uint32_t)0x00400000) /*!< Port x Reset bit 6 */
+#define GPIO_BSRR_BR7 ((uint32_t)0x00800000) /*!< Port x Reset bit 7 */
+#define GPIO_BSRR_BR8 ((uint32_t)0x01000000) /*!< Port x Reset bit 8 */
+#define GPIO_BSRR_BR9 ((uint32_t)0x02000000) /*!< Port x Reset bit 9 */
+#define GPIO_BSRR_BR10 ((uint32_t)0x04000000) /*!< Port x Reset bit 10 */
+#define GPIO_BSRR_BR11 ((uint32_t)0x08000000) /*!< Port x Reset bit 11 */
+#define GPIO_BSRR_BR12 ((uint32_t)0x10000000) /*!< Port x Reset bit 12 */
+#define GPIO_BSRR_BR13 ((uint32_t)0x20000000) /*!< Port x Reset bit 13 */
+#define GPIO_BSRR_BR14 ((uint32_t)0x40000000) /*!< Port x Reset bit 14 */
+#define GPIO_BSRR_BR15 ((uint32_t)0x80000000) /*!< Port x Reset bit 15 */
+
+/******************* Bit definition for GPIO_BRR register *******************/
+#define GPIO_BRR_BR0 ((uint16_t)0x0001) /*!< Port x Reset bit 0 */
+#define GPIO_BRR_BR1 ((uint16_t)0x0002) /*!< Port x Reset bit 1 */
+#define GPIO_BRR_BR2 ((uint16_t)0x0004) /*!< Port x Reset bit 2 */
+#define GPIO_BRR_BR3 ((uint16_t)0x0008) /*!< Port x Reset bit 3 */
+#define GPIO_BRR_BR4 ((uint16_t)0x0010) /*!< Port x Reset bit 4 */
+#define GPIO_BRR_BR5 ((uint16_t)0x0020) /*!< Port x Reset bit 5 */
+#define GPIO_BRR_BR6 ((uint16_t)0x0040) /*!< Port x Reset bit 6 */
+#define GPIO_BRR_BR7 ((uint16_t)0x0080) /*!< Port x Reset bit 7 */
+#define GPIO_BRR_BR8 ((uint16_t)0x0100) /*!< Port x Reset bit 8 */
+#define GPIO_BRR_BR9 ((uint16_t)0x0200) /*!< Port x Reset bit 9 */
+#define GPIO_BRR_BR10 ((uint16_t)0x0400) /*!< Port x Reset bit 10 */
+#define GPIO_BRR_BR11 ((uint16_t)0x0800) /*!< Port x Reset bit 11 */
+#define GPIO_BRR_BR12 ((uint16_t)0x1000) /*!< Port x Reset bit 12 */
+#define GPIO_BRR_BR13 ((uint16_t)0x2000) /*!< Port x Reset bit 13 */
+#define GPIO_BRR_BR14 ((uint16_t)0x4000) /*!< Port x Reset bit 14 */
+#define GPIO_BRR_BR15 ((uint16_t)0x8000) /*!< Port x Reset bit 15 */
+
+/****************** Bit definition for GPIO_LCKR register *******************/
+#define GPIO_LCKR_LCK0 ((uint32_t)0x00000001) /*!< Port x Lock bit 0 */
+#define GPIO_LCKR_LCK1 ((uint32_t)0x00000002) /*!< Port x Lock bit 1 */
+#define GPIO_LCKR_LCK2 ((uint32_t)0x00000004) /*!< Port x Lock bit 2 */
+#define GPIO_LCKR_LCK3 ((uint32_t)0x00000008) /*!< Port x Lock bit 3 */
+#define GPIO_LCKR_LCK4 ((uint32_t)0x00000010) /*!< Port x Lock bit 4 */
+#define GPIO_LCKR_LCK5 ((uint32_t)0x00000020) /*!< Port x Lock bit 5 */
+#define GPIO_LCKR_LCK6 ((uint32_t)0x00000040) /*!< Port x Lock bit 6 */
+#define GPIO_LCKR_LCK7 ((uint32_t)0x00000080) /*!< Port x Lock bit 7 */
+#define GPIO_LCKR_LCK8 ((uint32_t)0x00000100) /*!< Port x Lock bit 8 */
+#define GPIO_LCKR_LCK9 ((uint32_t)0x00000200) /*!< Port x Lock bit 9 */
+#define GPIO_LCKR_LCK10 ((uint32_t)0x00000400) /*!< Port x Lock bit 10 */
+#define GPIO_LCKR_LCK11 ((uint32_t)0x00000800) /*!< Port x Lock bit 11 */
+#define GPIO_LCKR_LCK12 ((uint32_t)0x00001000) /*!< Port x Lock bit 12 */
+#define GPIO_LCKR_LCK13 ((uint32_t)0x00002000) /*!< Port x Lock bit 13 */
+#define GPIO_LCKR_LCK14 ((uint32_t)0x00004000) /*!< Port x Lock bit 14 */
+#define GPIO_LCKR_LCK15 ((uint32_t)0x00008000) /*!< Port x Lock bit 15 */
+#define GPIO_LCKR_LCKK ((uint32_t)0x00010000) /*!< Lock key */
+
+/*----------------------------------------------------------------------------*/
+
+/****************** Bit definition for AFIO_EVCR register *******************/
+#define AFIO_EVCR_PIN ((uint8_t)0x0F) /*!< PIN[3:0] bits (Pin selection) */
+#define AFIO_EVCR_PIN_0 ((uint8_t)0x01) /*!< Bit 0 */
+#define AFIO_EVCR_PIN_1 ((uint8_t)0x02) /*!< Bit 1 */
+#define AFIO_EVCR_PIN_2 ((uint8_t)0x04) /*!< Bit 2 */
+#define AFIO_EVCR_PIN_3 ((uint8_t)0x08) /*!< Bit 3 */
+
+/*!< PIN configuration */
+#define AFIO_EVCR_PIN_PX0 ((uint8_t)0x00) /*!< Pin 0 selected */
+#define AFIO_EVCR_PIN_PX1 ((uint8_t)0x01) /*!< Pin 1 selected */
+#define AFIO_EVCR_PIN_PX2 ((uint8_t)0x02) /*!< Pin 2 selected */
+#define AFIO_EVCR_PIN_PX3 ((uint8_t)0x03) /*!< Pin 3 selected */
+#define AFIO_EVCR_PIN_PX4 ((uint8_t)0x04) /*!< Pin 4 selected */
+#define AFIO_EVCR_PIN_PX5 ((uint8_t)0x05) /*!< Pin 5 selected */
+#define AFIO_EVCR_PIN_PX6 ((uint8_t)0x06) /*!< Pin 6 selected */
+#define AFIO_EVCR_PIN_PX7 ((uint8_t)0x07) /*!< Pin 7 selected */
+#define AFIO_EVCR_PIN_PX8 ((uint8_t)0x08) /*!< Pin 8 selected */
+#define AFIO_EVCR_PIN_PX9 ((uint8_t)0x09) /*!< Pin 9 selected */
+#define AFIO_EVCR_PIN_PX10 ((uint8_t)0x0A) /*!< Pin 10 selected */
+#define AFIO_EVCR_PIN_PX11 ((uint8_t)0x0B) /*!< Pin 11 selected */
+#define AFIO_EVCR_PIN_PX12 ((uint8_t)0x0C) /*!< Pin 12 selected */
+#define AFIO_EVCR_PIN_PX13 ((uint8_t)0x0D) /*!< Pin 13 selected */
+#define AFIO_EVCR_PIN_PX14 ((uint8_t)0x0E) /*!< Pin 14 selected */
+#define AFIO_EVCR_PIN_PX15 ((uint8_t)0x0F) /*!< Pin 15 selected */
+
+#define AFIO_EVCR_PORT ((uint8_t)0x70) /*!< PORT[2:0] bits (Port selection) */
+#define AFIO_EVCR_PORT_0 ((uint8_t)0x10) /*!< Bit 0 */
+#define AFIO_EVCR_PORT_1 ((uint8_t)0x20) /*!< Bit 1 */
+#define AFIO_EVCR_PORT_2 ((uint8_t)0x40) /*!< Bit 2 */
+
+/*!< PORT configuration */
+#define AFIO_EVCR_PORT_PA ((uint8_t)0x00) /*!< Port A selected */
+#define AFIO_EVCR_PORT_PB ((uint8_t)0x10) /*!< Port B selected */
+#define AFIO_EVCR_PORT_PC ((uint8_t)0x20) /*!< Port C selected */
+#define AFIO_EVCR_PORT_PD ((uint8_t)0x30) /*!< Port D selected */
+#define AFIO_EVCR_PORT_PE ((uint8_t)0x40) /*!< Port E selected */
+
+#define AFIO_EVCR_EVOE ((uint8_t)0x80) /*!< Event Output Enable */
+
+/****************** Bit definition for AFIO_MAPR register *******************/
+#define AFIO_MAPR_SPI1_REMAP ((uint32_t)0x00000001) /*!< SPI1 remapping */
+#define AFIO_MAPR_I2C1_REMAP ((uint32_t)0x00000002) /*!< I2C1 remapping */
+#define AFIO_MAPR_USART1_REMAP ((uint32_t)0x00000004) /*!< USART1 remapping */
+#define AFIO_MAPR_USART2_REMAP ((uint32_t)0x00000008) /*!< USART2 remapping */
+
+#define AFIO_MAPR_USART3_REMAP ((uint32_t)0x00000030) /*!< USART3_REMAP[1:0] bits (USART3 remapping) */
+#define AFIO_MAPR_USART3_REMAP_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define AFIO_MAPR_USART3_REMAP_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+
+/* USART3_REMAP configuration */
+#define AFIO_MAPR_USART3_REMAP_NOREMAP ((uint32_t)0x00000000) /*!< No remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14) */
+#define AFIO_MAPR_USART3_REMAP_PARTIALREMAP ((uint32_t)0x00000010) /*!< Partial remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14) */
+#define AFIO_MAPR_USART3_REMAP_FULLREMAP ((uint32_t)0x00000030) /*!< Full remap (TX/PD8, RX/PD9, CK/PD10, CTS/PD11, RTS/PD12) */
+
+#define AFIO_MAPR_TIM1_REMAP ((uint32_t)0x000000C0) /*!< TIM1_REMAP[1:0] bits (TIM1 remapping) */
+#define AFIO_MAPR_TIM1_REMAP_0 ((uint32_t)0x00000040) /*!< Bit 0 */
+#define AFIO_MAPR_TIM1_REMAP_1 ((uint32_t)0x00000080) /*!< Bit 1 */
+
+/*!< TIM1_REMAP configuration */
+#define AFIO_MAPR_TIM1_REMAP_NOREMAP ((uint32_t)0x00000000) /*!< No remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15) */
+#define AFIO_MAPR_TIM1_REMAP_PARTIALREMAP ((uint32_t)0x00000040) /*!< Partial remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PA6, CH1N/PA7, CH2N/PB0, CH3N/PB1) */
+#define AFIO_MAPR_TIM1_REMAP_FULLREMAP ((uint32_t)0x000000C0) /*!< Full remap (ETR/PE7, CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15, CH1N/PE8, CH2N/PE10, CH3N/PE12) */
+
+#define AFIO_MAPR_TIM2_REMAP ((uint32_t)0x00000300) /*!< TIM2_REMAP[1:0] bits (TIM2 remapping) */
+#define AFIO_MAPR_TIM2_REMAP_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define AFIO_MAPR_TIM2_REMAP_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+
+/*!< TIM2_REMAP configuration */
+#define AFIO_MAPR_TIM2_REMAP_NOREMAP ((uint32_t)0x00000000) /*!< No remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3) */
+#define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1 ((uint32_t)0x00000100) /*!< Partial remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2, CH4/PA3) */
+#define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2 ((uint32_t)0x00000200) /*!< Partial remap (CH1/ETR/PA0, CH2/PA1, CH3/PB10, CH4/PB11) */
+#define AFIO_MAPR_TIM2_REMAP_FULLREMAP ((uint32_t)0x00000300) /*!< Full remap (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11) */
+
+#define AFIO_MAPR_TIM3_REMAP ((uint32_t)0x00000C00) /*!< TIM3_REMAP[1:0] bits (TIM3 remapping) */
+#define AFIO_MAPR_TIM3_REMAP_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define AFIO_MAPR_TIM3_REMAP_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+
+/*!< TIM3_REMAP configuration */
+#define AFIO_MAPR_TIM3_REMAP_NOREMAP ((uint32_t)0x00000000) /*!< No remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1) */
+#define AFIO_MAPR_TIM3_REMAP_PARTIALREMAP ((uint32_t)0x00000800) /*!< Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1) */
+#define AFIO_MAPR_TIM3_REMAP_FULLREMAP ((uint32_t)0x00000C00) /*!< Full remap (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9) */
+
+#define AFIO_MAPR_TIM4_REMAP ((uint32_t)0x00001000) /*!< TIM4_REMAP bit (TIM4 remapping) */
+
+#define AFIO_MAPR_CAN_REMAP ((uint32_t)0x00006000) /*!< CAN_REMAP[1:0] bits (CAN Alternate function remapping) */
+#define AFIO_MAPR_CAN_REMAP_0 ((uint32_t)0x00002000) /*!< Bit 0 */
+#define AFIO_MAPR_CAN_REMAP_1 ((uint32_t)0x00004000) /*!< Bit 1 */
+
+/*!< CAN_REMAP configuration */
+#define AFIO_MAPR_CAN_REMAP_REMAP1 ((uint32_t)0x00000000) /*!< CANRX mapped to PA11, CANTX mapped to PA12 */
+#define AFIO_MAPR_CAN_REMAP_REMAP2 ((uint32_t)0x00004000) /*!< CANRX mapped to PB8, CANTX mapped to PB9 */
+#define AFIO_MAPR_CAN_REMAP_REMAP3 ((uint32_t)0x00006000) /*!< CANRX mapped to PD0, CANTX mapped to PD1 */
+
+#define AFIO_MAPR_PD01_REMAP ((uint32_t)0x00008000) /*!< Port D0/Port D1 mapping on OSC_IN/OSC_OUT */
+#define AFIO_MAPR_TIM5CH4_IREMAP ((uint32_t)0x00010000) /*!< TIM5 Channel4 Internal Remap */
+#define AFIO_MAPR_ADC1_ETRGINJ_REMAP ((uint32_t)0x00020000) /*!< ADC 1 External Trigger Injected Conversion remapping */
+#define AFIO_MAPR_ADC1_ETRGREG_REMAP ((uint32_t)0x00040000) /*!< ADC 1 External Trigger Regular Conversion remapping */
+#define AFIO_MAPR_ADC2_ETRGINJ_REMAP ((uint32_t)0x00080000) /*!< ADC 2 External Trigger Injected Conversion remapping */
+#define AFIO_MAPR_ADC2_ETRGREG_REMAP ((uint32_t)0x00100000) /*!< ADC 2 External Trigger Regular Conversion remapping */
+
+/*!< SWJ_CFG configuration */
+#define AFIO_MAPR_SWJ_CFG ((uint32_t)0x07000000) /*!< SWJ_CFG[2:0] bits (Serial Wire JTAG configuration) */
+#define AFIO_MAPR_SWJ_CFG_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define AFIO_MAPR_SWJ_CFG_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define AFIO_MAPR_SWJ_CFG_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+
+#define AFIO_MAPR_SWJ_CFG_RESET ((uint32_t)0x00000000) /*!< Full SWJ (JTAG-DP + SW-DP) : Reset State */
+#define AFIO_MAPR_SWJ_CFG_NOJNTRST ((uint32_t)0x01000000) /*!< Full SWJ (JTAG-DP + SW-DP) but without JNTRST */
+#define AFIO_MAPR_SWJ_CFG_JTAGDISABLE ((uint32_t)0x02000000) /*!< JTAG-DP Disabled and SW-DP Enabled */
+#define AFIO_MAPR_SWJ_CFG_DISABLE ((uint32_t)0x04000000) /*!< JTAG-DP Disabled and SW-DP Disabled */
+
+#ifdef STM32F10X_CL
+/*!< ETH_REMAP configuration */
+ #define AFIO_MAPR_ETH_REMAP ((uint32_t)0x00200000) /*!< SPI3_REMAP bit (Ethernet MAC I/O remapping) */
+
+/*!< CAN2_REMAP configuration */
+ #define AFIO_MAPR_CAN2_REMAP ((uint32_t)0x00400000) /*!< CAN2_REMAP bit (CAN2 I/O remapping) */
+
+/*!< MII_RMII_SEL configuration */
+ #define AFIO_MAPR_MII_RMII_SEL ((uint32_t)0x00800000) /*!< MII_RMII_SEL bit (Ethernet MII or RMII selection) */
+
+/*!< SPI3_REMAP configuration */
+ #define AFIO_MAPR_SPI3_REMAP ((uint32_t)0x10000000) /*!< SPI3_REMAP bit (SPI3 remapping) */
+
+/*!< TIM2ITR1_IREMAP configuration */
+ #define AFIO_MAPR_TIM2ITR1_IREMAP ((uint32_t)0x20000000) /*!< TIM2ITR1_IREMAP bit (TIM2 internal trigger 1 remapping) */
+
+/*!< PTP_PPS_REMAP configuration */
+ #define AFIO_MAPR_PTP_PPS_REMAP ((uint32_t)0x40000000) /*!< PTP_PPS_REMAP bit (Ethernet PTP PPS remapping) */
+#endif
+
+/***************** Bit definition for AFIO_EXTICR1 register *****************/
+#define AFIO_EXTICR1_EXTI0 ((uint16_t)0x000F) /*!< EXTI 0 configuration */
+#define AFIO_EXTICR1_EXTI1 ((uint16_t)0x00F0) /*!< EXTI 1 configuration */
+#define AFIO_EXTICR1_EXTI2 ((uint16_t)0x0F00) /*!< EXTI 2 configuration */
+#define AFIO_EXTICR1_EXTI3 ((uint16_t)0xF000) /*!< EXTI 3 configuration */
+
+/*!< EXTI0 configuration */
+#define AFIO_EXTICR1_EXTI0_PA ((uint16_t)0x0000) /*!< PA[0] pin */
+#define AFIO_EXTICR1_EXTI0_PB ((uint16_t)0x0001) /*!< PB[0] pin */
+#define AFIO_EXTICR1_EXTI0_PC ((uint16_t)0x0002) /*!< PC[0] pin */
+#define AFIO_EXTICR1_EXTI0_PD ((uint16_t)0x0003) /*!< PD[0] pin */
+#define AFIO_EXTICR1_EXTI0_PE ((uint16_t)0x0004) /*!< PE[0] pin */
+#define AFIO_EXTICR1_EXTI0_PF ((uint16_t)0x0005) /*!< PF[0] pin */
+#define AFIO_EXTICR1_EXTI0_PG ((uint16_t)0x0006) /*!< PG[0] pin */
+
+/*!< EXTI1 configuration */
+#define AFIO_EXTICR1_EXTI1_PA ((uint16_t)0x0000) /*!< PA[1] pin */
+#define AFIO_EXTICR1_EXTI1_PB ((uint16_t)0x0010) /*!< PB[1] pin */
+#define AFIO_EXTICR1_EXTI1_PC ((uint16_t)0x0020) /*!< PC[1] pin */
+#define AFIO_EXTICR1_EXTI1_PD ((uint16_t)0x0030) /*!< PD[1] pin */
+#define AFIO_EXTICR1_EXTI1_PE ((uint16_t)0x0040) /*!< PE[1] pin */
+#define AFIO_EXTICR1_EXTI1_PF ((uint16_t)0x0050) /*!< PF[1] pin */
+#define AFIO_EXTICR1_EXTI1_PG ((uint16_t)0x0060) /*!< PG[1] pin */
+
+/*!< EXTI2 configuration */
+#define AFIO_EXTICR1_EXTI2_PA ((uint16_t)0x0000) /*!< PA[2] pin */
+#define AFIO_EXTICR1_EXTI2_PB ((uint16_t)0x0100) /*!< PB[2] pin */
+#define AFIO_EXTICR1_EXTI2_PC ((uint16_t)0x0200) /*!< PC[2] pin */
+#define AFIO_EXTICR1_EXTI2_PD ((uint16_t)0x0300) /*!< PD[2] pin */
+#define AFIO_EXTICR1_EXTI2_PE ((uint16_t)0x0400) /*!< PE[2] pin */
+#define AFIO_EXTICR1_EXTI2_PF ((uint16_t)0x0500) /*!< PF[2] pin */
+#define AFIO_EXTICR1_EXTI2_PG ((uint16_t)0x0600) /*!< PG[2] pin */
+
+/*!< EXTI3 configuration */
+#define AFIO_EXTICR1_EXTI3_PA ((uint16_t)0x0000) /*!< PA[3] pin */
+#define AFIO_EXTICR1_EXTI3_PB ((uint16_t)0x1000) /*!< PB[3] pin */
+#define AFIO_EXTICR1_EXTI3_PC ((uint16_t)0x2000) /*!< PC[3] pin */
+#define AFIO_EXTICR1_EXTI3_PD ((uint16_t)0x3000) /*!< PD[3] pin */
+#define AFIO_EXTICR1_EXTI3_PE ((uint16_t)0x4000) /*!< PE[3] pin */
+#define AFIO_EXTICR1_EXTI3_PF ((uint16_t)0x5000) /*!< PF[3] pin */
+#define AFIO_EXTICR1_EXTI3_PG ((uint16_t)0x6000) /*!< PG[3] pin */
+
+/***************** Bit definition for AFIO_EXTICR2 register *****************/
+#define AFIO_EXTICR2_EXTI4 ((uint16_t)0x000F) /*!< EXTI 4 configuration */
+#define AFIO_EXTICR2_EXTI5 ((uint16_t)0x00F0) /*!< EXTI 5 configuration */
+#define AFIO_EXTICR2_EXTI6 ((uint16_t)0x0F00) /*!< EXTI 6 configuration */
+#define AFIO_EXTICR2_EXTI7 ((uint16_t)0xF000) /*!< EXTI 7 configuration */
+
+/*!< EXTI4 configuration */
+#define AFIO_EXTICR2_EXTI4_PA ((uint16_t)0x0000) /*!< PA[4] pin */
+#define AFIO_EXTICR2_EXTI4_PB ((uint16_t)0x0001) /*!< PB[4] pin */
+#define AFIO_EXTICR2_EXTI4_PC ((uint16_t)0x0002) /*!< PC[4] pin */
+#define AFIO_EXTICR2_EXTI4_PD ((uint16_t)0x0003) /*!< PD[4] pin */
+#define AFIO_EXTICR2_EXTI4_PE ((uint16_t)0x0004) /*!< PE[4] pin */
+#define AFIO_EXTICR2_EXTI4_PF ((uint16_t)0x0005) /*!< PF[4] pin */
+#define AFIO_EXTICR2_EXTI4_PG ((uint16_t)0x0006) /*!< PG[4] pin */
+
+/* EXTI5 configuration */
+#define AFIO_EXTICR2_EXTI5_PA ((uint16_t)0x0000) /*!< PA[5] pin */
+#define AFIO_EXTICR2_EXTI5_PB ((uint16_t)0x0010) /*!< PB[5] pin */
+#define AFIO_EXTICR2_EXTI5_PC ((uint16_t)0x0020) /*!< PC[5] pin */
+#define AFIO_EXTICR2_EXTI5_PD ((uint16_t)0x0030) /*!< PD[5] pin */
+#define AFIO_EXTICR2_EXTI5_PE ((uint16_t)0x0040) /*!< PE[5] pin */
+#define AFIO_EXTICR2_EXTI5_PF ((uint16_t)0x0050) /*!< PF[5] pin */
+#define AFIO_EXTICR2_EXTI5_PG ((uint16_t)0x0060) /*!< PG[5] pin */
+
+/*!< EXTI6 configuration */
+#define AFIO_EXTICR2_EXTI6_PA ((uint16_t)0x0000) /*!< PA[6] pin */
+#define AFIO_EXTICR2_EXTI6_PB ((uint16_t)0x0100) /*!< PB[6] pin */
+#define AFIO_EXTICR2_EXTI6_PC ((uint16_t)0x0200) /*!< PC[6] pin */
+#define AFIO_EXTICR2_EXTI6_PD ((uint16_t)0x0300) /*!< PD[6] pin */
+#define AFIO_EXTICR2_EXTI6_PE ((uint16_t)0x0400) /*!< PE[6] pin */
+#define AFIO_EXTICR2_EXTI6_PF ((uint16_t)0x0500) /*!< PF[6] pin */
+#define AFIO_EXTICR2_EXTI6_PG ((uint16_t)0x0600) /*!< PG[6] pin */
+
+/*!< EXTI7 configuration */
+#define AFIO_EXTICR2_EXTI7_PA ((uint16_t)0x0000) /*!< PA[7] pin */
+#define AFIO_EXTICR2_EXTI7_PB ((uint16_t)0x1000) /*!< PB[7] pin */
+#define AFIO_EXTICR2_EXTI7_PC ((uint16_t)0x2000) /*!< PC[7] pin */
+#define AFIO_EXTICR2_EXTI7_PD ((uint16_t)0x3000) /*!< PD[7] pin */
+#define AFIO_EXTICR2_EXTI7_PE ((uint16_t)0x4000) /*!< PE[7] pin */
+#define AFIO_EXTICR2_EXTI7_PF ((uint16_t)0x5000) /*!< PF[7] pin */
+#define AFIO_EXTICR2_EXTI7_PG ((uint16_t)0x6000) /*!< PG[7] pin */
+
+/***************** Bit definition for AFIO_EXTICR3 register *****************/
+#define AFIO_EXTICR3_EXTI8 ((uint16_t)0x000F) /*!< EXTI 8 configuration */
+#define AFIO_EXTICR3_EXTI9 ((uint16_t)0x00F0) /*!< EXTI 9 configuration */
+#define AFIO_EXTICR3_EXTI10 ((uint16_t)0x0F00) /*!< EXTI 10 configuration */
+#define AFIO_EXTICR3_EXTI11 ((uint16_t)0xF000) /*!< EXTI 11 configuration */
+
+/*!< EXTI8 configuration */
+#define AFIO_EXTICR3_EXTI8_PA ((uint16_t)0x0000) /*!< PA[8] pin */
+#define AFIO_EXTICR3_EXTI8_PB ((uint16_t)0x0001) /*!< PB[8] pin */
+#define AFIO_EXTICR3_EXTI8_PC ((uint16_t)0x0002) /*!< PC[8] pin */
+#define AFIO_EXTICR3_EXTI8_PD ((uint16_t)0x0003) /*!< PD[8] pin */
+#define AFIO_EXTICR3_EXTI8_PE ((uint16_t)0x0004) /*!< PE[8] pin */
+#define AFIO_EXTICR3_EXTI8_PF ((uint16_t)0x0005) /*!< PF[8] pin */
+#define AFIO_EXTICR3_EXTI8_PG ((uint16_t)0x0006) /*!< PG[8] pin */
+
+/*!< EXTI9 configuration */
+#define AFIO_EXTICR3_EXTI9_PA ((uint16_t)0x0000) /*!< PA[9] pin */
+#define AFIO_EXTICR3_EXTI9_PB ((uint16_t)0x0010) /*!< PB[9] pin */
+#define AFIO_EXTICR3_EXTI9_PC ((uint16_t)0x0020) /*!< PC[9] pin */
+#define AFIO_EXTICR3_EXTI9_PD ((uint16_t)0x0030) /*!< PD[9] pin */
+#define AFIO_EXTICR3_EXTI9_PE ((uint16_t)0x0040) /*!< PE[9] pin */
+#define AFIO_EXTICR3_EXTI9_PF ((uint16_t)0x0050) /*!< PF[9] pin */
+#define AFIO_EXTICR3_EXTI9_PG ((uint16_t)0x0060) /*!< PG[9] pin */
+
+/*!< EXTI10 configuration */
+#define AFIO_EXTICR3_EXTI10_PA ((uint16_t)0x0000) /*!< PA[10] pin */
+#define AFIO_EXTICR3_EXTI10_PB ((uint16_t)0x0100) /*!< PB[10] pin */
+#define AFIO_EXTICR3_EXTI10_PC ((uint16_t)0x0200) /*!< PC[10] pin */
+#define AFIO_EXTICR3_EXTI10_PD ((uint16_t)0x0300) /*!< PD[10] pin */
+#define AFIO_EXTICR3_EXTI10_PE ((uint16_t)0x0400) /*!< PE[10] pin */
+#define AFIO_EXTICR3_EXTI10_PF ((uint16_t)0x0500) /*!< PF[10] pin */
+#define AFIO_EXTICR3_EXTI10_PG ((uint16_t)0x0600) /*!< PG[10] pin */
+
+/*!< EXTI11 configuration */
+#define AFIO_EXTICR3_EXTI11_PA ((uint16_t)0x0000) /*!< PA[11] pin */
+#define AFIO_EXTICR3_EXTI11_PB ((uint16_t)0x1000) /*!< PB[11] pin */
+#define AFIO_EXTICR3_EXTI11_PC ((uint16_t)0x2000) /*!< PC[11] pin */
+#define AFIO_EXTICR3_EXTI11_PD ((uint16_t)0x3000) /*!< PD[11] pin */
+#define AFIO_EXTICR3_EXTI11_PE ((uint16_t)0x4000) /*!< PE[11] pin */
+#define AFIO_EXTICR3_EXTI11_PF ((uint16_t)0x5000) /*!< PF[11] pin */
+#define AFIO_EXTICR3_EXTI11_PG ((uint16_t)0x6000) /*!< PG[11] pin */
+
+/***************** Bit definition for AFIO_EXTICR4 register *****************/
+#define AFIO_EXTICR4_EXTI12 ((uint16_t)0x000F) /*!< EXTI 12 configuration */
+#define AFIO_EXTICR4_EXTI13 ((uint16_t)0x00F0) /*!< EXTI 13 configuration */
+#define AFIO_EXTICR4_EXTI14 ((uint16_t)0x0F00) /*!< EXTI 14 configuration */
+#define AFIO_EXTICR4_EXTI15 ((uint16_t)0xF000) /*!< EXTI 15 configuration */
+
+/* EXTI12 configuration */
+#define AFIO_EXTICR4_EXTI12_PA ((uint16_t)0x0000) /*!< PA[12] pin */
+#define AFIO_EXTICR4_EXTI12_PB ((uint16_t)0x0001) /*!< PB[12] pin */
+#define AFIO_EXTICR4_EXTI12_PC ((uint16_t)0x0002) /*!< PC[12] pin */
+#define AFIO_EXTICR4_EXTI12_PD ((uint16_t)0x0003) /*!< PD[12] pin */
+#define AFIO_EXTICR4_EXTI12_PE ((uint16_t)0x0004) /*!< PE[12] pin */
+#define AFIO_EXTICR4_EXTI12_PF ((uint16_t)0x0005) /*!< PF[12] pin */
+#define AFIO_EXTICR4_EXTI12_PG ((uint16_t)0x0006) /*!< PG[12] pin */
+
+/* EXTI13 configuration */
+#define AFIO_EXTICR4_EXTI13_PA ((uint16_t)0x0000) /*!< PA[13] pin */
+#define AFIO_EXTICR4_EXTI13_PB ((uint16_t)0x0010) /*!< PB[13] pin */
+#define AFIO_EXTICR4_EXTI13_PC ((uint16_t)0x0020) /*!< PC[13] pin */
+#define AFIO_EXTICR4_EXTI13_PD ((uint16_t)0x0030) /*!< PD[13] pin */
+#define AFIO_EXTICR4_EXTI13_PE ((uint16_t)0x0040) /*!< PE[13] pin */
+#define AFIO_EXTICR4_EXTI13_PF ((uint16_t)0x0050) /*!< PF[13] pin */
+#define AFIO_EXTICR4_EXTI13_PG ((uint16_t)0x0060) /*!< PG[13] pin */
+
+/*!< EXTI14 configuration */
+#define AFIO_EXTICR4_EXTI14_PA ((uint16_t)0x0000) /*!< PA[14] pin */
+#define AFIO_EXTICR4_EXTI14_PB ((uint16_t)0x0100) /*!< PB[14] pin */
+#define AFIO_EXTICR4_EXTI14_PC ((uint16_t)0x0200) /*!< PC[14] pin */
+#define AFIO_EXTICR4_EXTI14_PD ((uint16_t)0x0300) /*!< PD[14] pin */
+#define AFIO_EXTICR4_EXTI14_PE ((uint16_t)0x0400) /*!< PE[14] pin */
+#define AFIO_EXTICR4_EXTI14_PF ((uint16_t)0x0500) /*!< PF[14] pin */
+#define AFIO_EXTICR4_EXTI14_PG ((uint16_t)0x0600) /*!< PG[14] pin */
+
+/*!< EXTI15 configuration */
+#define AFIO_EXTICR4_EXTI15_PA ((uint16_t)0x0000) /*!< PA[15] pin */
+#define AFIO_EXTICR4_EXTI15_PB ((uint16_t)0x1000) /*!< PB[15] pin */
+#define AFIO_EXTICR4_EXTI15_PC ((uint16_t)0x2000) /*!< PC[15] pin */
+#define AFIO_EXTICR4_EXTI15_PD ((uint16_t)0x3000) /*!< PD[15] pin */
+#define AFIO_EXTICR4_EXTI15_PE ((uint16_t)0x4000) /*!< PE[15] pin */
+#define AFIO_EXTICR4_EXTI15_PF ((uint16_t)0x5000) /*!< PF[15] pin */
+#define AFIO_EXTICR4_EXTI15_PG ((uint16_t)0x6000) /*!< PG[15] pin */
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+/****************** Bit definition for AFIO_MAPR2 register ******************/
+#define AFIO_MAPR2_TIM15_REMAP ((uint32_t)0x00000001) /*!< TIM15 remapping */
+#define AFIO_MAPR2_TIM16_REMAP ((uint32_t)0x00000002) /*!< TIM16 remapping */
+#define AFIO_MAPR2_TIM17_REMAP ((uint32_t)0x00000004) /*!< TIM17 remapping */
+#define AFIO_MAPR2_CEC_REMAP ((uint32_t)0x00000008) /*!< CEC remapping */
+#define AFIO_MAPR2_TIM1_DMA_REMAP ((uint32_t)0x00000010) /*!< TIM1_DMA remapping */
+#endif
+
+#ifdef STM32F10X_HD_VL
+#define AFIO_MAPR2_TIM13_REMAP ((uint32_t)0x00000100) /*!< TIM13 remapping */
+#define AFIO_MAPR2_TIM14_REMAP ((uint32_t)0x00000200) /*!< TIM14 remapping */
+#define AFIO_MAPR2_FSMC_NADV_REMAP ((uint32_t)0x00000400) /*!< FSMC NADV remapping */
+#define AFIO_MAPR2_TIM67_DAC_DMA_REMAP ((uint32_t)0x00000800) /*!< TIM6/TIM7 and DAC DMA remapping */
+#define AFIO_MAPR2_TIM12_REMAP ((uint32_t)0x00001000) /*!< TIM12 remapping */
+#define AFIO_MAPR2_MISC_REMAP ((uint32_t)0x00002000) /*!< Miscellaneous remapping */
+#endif
+
+#ifdef STM32F10X_XL
+/****************** Bit definition for AFIO_MAPR2 register ******************/
+#define AFIO_MAPR2_TIM9_REMAP ((uint32_t)0x00000020) /*!< TIM9 remapping */
+#define AFIO_MAPR2_TIM10_REMAP ((uint32_t)0x00000040) /*!< TIM10 remapping */
+#define AFIO_MAPR2_TIM11_REMAP ((uint32_t)0x00000080) /*!< TIM11 remapping */
+#define AFIO_MAPR2_TIM13_REMAP ((uint32_t)0x00000100) /*!< TIM13 remapping */
+#define AFIO_MAPR2_TIM14_REMAP ((uint32_t)0x00000200) /*!< TIM14 remapping */
+#define AFIO_MAPR2_FSMC_NADV_REMAP ((uint32_t)0x00000400) /*!< FSMC NADV remapping */
+#endif
+
+/******************************************************************************/
+/* */
+/* SystemTick */
+/* */
+/******************************************************************************/
+
+/***************** Bit definition for SysTick_CTRL register *****************/
+#define SysTick_CTRL_ENABLE ((uint32_t)0x00000001) /*!< Counter enable */
+#define SysTick_CTRL_TICKINT ((uint32_t)0x00000002) /*!< Counting down to 0 pends the SysTick handler */
+#define SysTick_CTRL_CLKSOURCE ((uint32_t)0x00000004) /*!< Clock source */
+#define SysTick_CTRL_COUNTFLAG ((uint32_t)0x00010000) /*!< Count Flag */
+
+/***************** Bit definition for SysTick_LOAD register *****************/
+#define SysTick_LOAD_RELOAD ((uint32_t)0x00FFFFFF) /*!< Value to load into the SysTick Current Value Register when the counter reaches 0 */
+
+/***************** Bit definition for SysTick_VAL register ******************/
+#define SysTick_VAL_CURRENT ((uint32_t)0x00FFFFFF) /*!< Current value at the time the register is accessed */
+
+/***************** Bit definition for SysTick_CALIB register ****************/
+#define SysTick_CALIB_TENMS ((uint32_t)0x00FFFFFF) /*!< Reload value to use for 10ms timing */
+#define SysTick_CALIB_SKEW ((uint32_t)0x40000000) /*!< Calibration value is not exactly 10 ms */
+#define SysTick_CALIB_NOREF ((uint32_t)0x80000000) /*!< The reference clock is not provided */
+
+/******************************************************************************/
+/* */
+/* Nested Vectored Interrupt Controller */
+/* */
+/******************************************************************************/
+
+/****************** Bit definition for NVIC_ISER register *******************/
+#define NVIC_ISER_SETENA ((uint32_t)0xFFFFFFFF) /*!< Interrupt set enable bits */
+#define NVIC_ISER_SETENA_0 ((uint32_t)0x00000001) /*!< bit 0 */
+#define NVIC_ISER_SETENA_1 ((uint32_t)0x00000002) /*!< bit 1 */
+#define NVIC_ISER_SETENA_2 ((uint32_t)0x00000004) /*!< bit 2 */
+#define NVIC_ISER_SETENA_3 ((uint32_t)0x00000008) /*!< bit 3 */
+#define NVIC_ISER_SETENA_4 ((uint32_t)0x00000010) /*!< bit 4 */
+#define NVIC_ISER_SETENA_5 ((uint32_t)0x00000020) /*!< bit 5 */
+#define NVIC_ISER_SETENA_6 ((uint32_t)0x00000040) /*!< bit 6 */
+#define NVIC_ISER_SETENA_7 ((uint32_t)0x00000080) /*!< bit 7 */
+#define NVIC_ISER_SETENA_8 ((uint32_t)0x00000100) /*!< bit 8 */
+#define NVIC_ISER_SETENA_9 ((uint32_t)0x00000200) /*!< bit 9 */
+#define NVIC_ISER_SETENA_10 ((uint32_t)0x00000400) /*!< bit 10 */
+#define NVIC_ISER_SETENA_11 ((uint32_t)0x00000800) /*!< bit 11 */
+#define NVIC_ISER_SETENA_12 ((uint32_t)0x00001000) /*!< bit 12 */
+#define NVIC_ISER_SETENA_13 ((uint32_t)0x00002000) /*!< bit 13 */
+#define NVIC_ISER_SETENA_14 ((uint32_t)0x00004000) /*!< bit 14 */
+#define NVIC_ISER_SETENA_15 ((uint32_t)0x00008000) /*!< bit 15 */
+#define NVIC_ISER_SETENA_16 ((uint32_t)0x00010000) /*!< bit 16 */
+#define NVIC_ISER_SETENA_17 ((uint32_t)0x00020000) /*!< bit 17 */
+#define NVIC_ISER_SETENA_18 ((uint32_t)0x00040000) /*!< bit 18 */
+#define NVIC_ISER_SETENA_19 ((uint32_t)0x00080000) /*!< bit 19 */
+#define NVIC_ISER_SETENA_20 ((uint32_t)0x00100000) /*!< bit 20 */
+#define NVIC_ISER_SETENA_21 ((uint32_t)0x00200000) /*!< bit 21 */
+#define NVIC_ISER_SETENA_22 ((uint32_t)0x00400000) /*!< bit 22 */
+#define NVIC_ISER_SETENA_23 ((uint32_t)0x00800000) /*!< bit 23 */
+#define NVIC_ISER_SETENA_24 ((uint32_t)0x01000000) /*!< bit 24 */
+#define NVIC_ISER_SETENA_25 ((uint32_t)0x02000000) /*!< bit 25 */
+#define NVIC_ISER_SETENA_26 ((uint32_t)0x04000000) /*!< bit 26 */
+#define NVIC_ISER_SETENA_27 ((uint32_t)0x08000000) /*!< bit 27 */
+#define NVIC_ISER_SETENA_28 ((uint32_t)0x10000000) /*!< bit 28 */
+#define NVIC_ISER_SETENA_29 ((uint32_t)0x20000000) /*!< bit 29 */
+#define NVIC_ISER_SETENA_30 ((uint32_t)0x40000000) /*!< bit 30 */
+#define NVIC_ISER_SETENA_31 ((uint32_t)0x80000000) /*!< bit 31 */
+
+/****************** Bit definition for NVIC_ICER register *******************/
+#define NVIC_ICER_CLRENA ((uint32_t)0xFFFFFFFF) /*!< Interrupt clear-enable bits */
+#define NVIC_ICER_CLRENA_0 ((uint32_t)0x00000001) /*!< bit 0 */
+#define NVIC_ICER_CLRENA_1 ((uint32_t)0x00000002) /*!< bit 1 */
+#define NVIC_ICER_CLRENA_2 ((uint32_t)0x00000004) /*!< bit 2 */
+#define NVIC_ICER_CLRENA_3 ((uint32_t)0x00000008) /*!< bit 3 */
+#define NVIC_ICER_CLRENA_4 ((uint32_t)0x00000010) /*!< bit 4 */
+#define NVIC_ICER_CLRENA_5 ((uint32_t)0x00000020) /*!< bit 5 */
+#define NVIC_ICER_CLRENA_6 ((uint32_t)0x00000040) /*!< bit 6 */
+#define NVIC_ICER_CLRENA_7 ((uint32_t)0x00000080) /*!< bit 7 */
+#define NVIC_ICER_CLRENA_8 ((uint32_t)0x00000100) /*!< bit 8 */
+#define NVIC_ICER_CLRENA_9 ((uint32_t)0x00000200) /*!< bit 9 */
+#define NVIC_ICER_CLRENA_10 ((uint32_t)0x00000400) /*!< bit 10 */
+#define NVIC_ICER_CLRENA_11 ((uint32_t)0x00000800) /*!< bit 11 */
+#define NVIC_ICER_CLRENA_12 ((uint32_t)0x00001000) /*!< bit 12 */
+#define NVIC_ICER_CLRENA_13 ((uint32_t)0x00002000) /*!< bit 13 */
+#define NVIC_ICER_CLRENA_14 ((uint32_t)0x00004000) /*!< bit 14 */
+#define NVIC_ICER_CLRENA_15 ((uint32_t)0x00008000) /*!< bit 15 */
+#define NVIC_ICER_CLRENA_16 ((uint32_t)0x00010000) /*!< bit 16 */
+#define NVIC_ICER_CLRENA_17 ((uint32_t)0x00020000) /*!< bit 17 */
+#define NVIC_ICER_CLRENA_18 ((uint32_t)0x00040000) /*!< bit 18 */
+#define NVIC_ICER_CLRENA_19 ((uint32_t)0x00080000) /*!< bit 19 */
+#define NVIC_ICER_CLRENA_20 ((uint32_t)0x00100000) /*!< bit 20 */
+#define NVIC_ICER_CLRENA_21 ((uint32_t)0x00200000) /*!< bit 21 */
+#define NVIC_ICER_CLRENA_22 ((uint32_t)0x00400000) /*!< bit 22 */
+#define NVIC_ICER_CLRENA_23 ((uint32_t)0x00800000) /*!< bit 23 */
+#define NVIC_ICER_CLRENA_24 ((uint32_t)0x01000000) /*!< bit 24 */
+#define NVIC_ICER_CLRENA_25 ((uint32_t)0x02000000) /*!< bit 25 */
+#define NVIC_ICER_CLRENA_26 ((uint32_t)0x04000000) /*!< bit 26 */
+#define NVIC_ICER_CLRENA_27 ((uint32_t)0x08000000) /*!< bit 27 */
+#define NVIC_ICER_CLRENA_28 ((uint32_t)0x10000000) /*!< bit 28 */
+#define NVIC_ICER_CLRENA_29 ((uint32_t)0x20000000) /*!< bit 29 */
+#define NVIC_ICER_CLRENA_30 ((uint32_t)0x40000000) /*!< bit 30 */
+#define NVIC_ICER_CLRENA_31 ((uint32_t)0x80000000) /*!< bit 31 */
+
+/****************** Bit definition for NVIC_ISPR register *******************/
+#define NVIC_ISPR_SETPEND ((uint32_t)0xFFFFFFFF) /*!< Interrupt set-pending bits */
+#define NVIC_ISPR_SETPEND_0 ((uint32_t)0x00000001) /*!< bit 0 */
+#define NVIC_ISPR_SETPEND_1 ((uint32_t)0x00000002) /*!< bit 1 */
+#define NVIC_ISPR_SETPEND_2 ((uint32_t)0x00000004) /*!< bit 2 */
+#define NVIC_ISPR_SETPEND_3 ((uint32_t)0x00000008) /*!< bit 3 */
+#define NVIC_ISPR_SETPEND_4 ((uint32_t)0x00000010) /*!< bit 4 */
+#define NVIC_ISPR_SETPEND_5 ((uint32_t)0x00000020) /*!< bit 5 */
+#define NVIC_ISPR_SETPEND_6 ((uint32_t)0x00000040) /*!< bit 6 */
+#define NVIC_ISPR_SETPEND_7 ((uint32_t)0x00000080) /*!< bit 7 */
+#define NVIC_ISPR_SETPEND_8 ((uint32_t)0x00000100) /*!< bit 8 */
+#define NVIC_ISPR_SETPEND_9 ((uint32_t)0x00000200) /*!< bit 9 */
+#define NVIC_ISPR_SETPEND_10 ((uint32_t)0x00000400) /*!< bit 10 */
+#define NVIC_ISPR_SETPEND_11 ((uint32_t)0x00000800) /*!< bit 11 */
+#define NVIC_ISPR_SETPEND_12 ((uint32_t)0x00001000) /*!< bit 12 */
+#define NVIC_ISPR_SETPEND_13 ((uint32_t)0x00002000) /*!< bit 13 */
+#define NVIC_ISPR_SETPEND_14 ((uint32_t)0x00004000) /*!< bit 14 */
+#define NVIC_ISPR_SETPEND_15 ((uint32_t)0x00008000) /*!< bit 15 */
+#define NVIC_ISPR_SETPEND_16 ((uint32_t)0x00010000) /*!< bit 16 */
+#define NVIC_ISPR_SETPEND_17 ((uint32_t)0x00020000) /*!< bit 17 */
+#define NVIC_ISPR_SETPEND_18 ((uint32_t)0x00040000) /*!< bit 18 */
+#define NVIC_ISPR_SETPEND_19 ((uint32_t)0x00080000) /*!< bit 19 */
+#define NVIC_ISPR_SETPEND_20 ((uint32_t)0x00100000) /*!< bit 20 */
+#define NVIC_ISPR_SETPEND_21 ((uint32_t)0x00200000) /*!< bit 21 */
+#define NVIC_ISPR_SETPEND_22 ((uint32_t)0x00400000) /*!< bit 22 */
+#define NVIC_ISPR_SETPEND_23 ((uint32_t)0x00800000) /*!< bit 23 */
+#define NVIC_ISPR_SETPEND_24 ((uint32_t)0x01000000) /*!< bit 24 */
+#define NVIC_ISPR_SETPEND_25 ((uint32_t)0x02000000) /*!< bit 25 */
+#define NVIC_ISPR_SETPEND_26 ((uint32_t)0x04000000) /*!< bit 26 */
+#define NVIC_ISPR_SETPEND_27 ((uint32_t)0x08000000) /*!< bit 27 */
+#define NVIC_ISPR_SETPEND_28 ((uint32_t)0x10000000) /*!< bit 28 */
+#define NVIC_ISPR_SETPEND_29 ((uint32_t)0x20000000) /*!< bit 29 */
+#define NVIC_ISPR_SETPEND_30 ((uint32_t)0x40000000) /*!< bit 30 */
+#define NVIC_ISPR_SETPEND_31 ((uint32_t)0x80000000) /*!< bit 31 */
+
+/****************** Bit definition for NVIC_ICPR register *******************/
+#define NVIC_ICPR_CLRPEND ((uint32_t)0xFFFFFFFF) /*!< Interrupt clear-pending bits */
+#define NVIC_ICPR_CLRPEND_0 ((uint32_t)0x00000001) /*!< bit 0 */
+#define NVIC_ICPR_CLRPEND_1 ((uint32_t)0x00000002) /*!< bit 1 */
+#define NVIC_ICPR_CLRPEND_2 ((uint32_t)0x00000004) /*!< bit 2 */
+#define NVIC_ICPR_CLRPEND_3 ((uint32_t)0x00000008) /*!< bit 3 */
+#define NVIC_ICPR_CLRPEND_4 ((uint32_t)0x00000010) /*!< bit 4 */
+#define NVIC_ICPR_CLRPEND_5 ((uint32_t)0x00000020) /*!< bit 5 */
+#define NVIC_ICPR_CLRPEND_6 ((uint32_t)0x00000040) /*!< bit 6 */
+#define NVIC_ICPR_CLRPEND_7 ((uint32_t)0x00000080) /*!< bit 7 */
+#define NVIC_ICPR_CLRPEND_8 ((uint32_t)0x00000100) /*!< bit 8 */
+#define NVIC_ICPR_CLRPEND_9 ((uint32_t)0x00000200) /*!< bit 9 */
+#define NVIC_ICPR_CLRPEND_10 ((uint32_t)0x00000400) /*!< bit 10 */
+#define NVIC_ICPR_CLRPEND_11 ((uint32_t)0x00000800) /*!< bit 11 */
+#define NVIC_ICPR_CLRPEND_12 ((uint32_t)0x00001000) /*!< bit 12 */
+#define NVIC_ICPR_CLRPEND_13 ((uint32_t)0x00002000) /*!< bit 13 */
+#define NVIC_ICPR_CLRPEND_14 ((uint32_t)0x00004000) /*!< bit 14 */
+#define NVIC_ICPR_CLRPEND_15 ((uint32_t)0x00008000) /*!< bit 15 */
+#define NVIC_ICPR_CLRPEND_16 ((uint32_t)0x00010000) /*!< bit 16 */
+#define NVIC_ICPR_CLRPEND_17 ((uint32_t)0x00020000) /*!< bit 17 */
+#define NVIC_ICPR_CLRPEND_18 ((uint32_t)0x00040000) /*!< bit 18 */
+#define NVIC_ICPR_CLRPEND_19 ((uint32_t)0x00080000) /*!< bit 19 */
+#define NVIC_ICPR_CLRPEND_20 ((uint32_t)0x00100000) /*!< bit 20 */
+#define NVIC_ICPR_CLRPEND_21 ((uint32_t)0x00200000) /*!< bit 21 */
+#define NVIC_ICPR_CLRPEND_22 ((uint32_t)0x00400000) /*!< bit 22 */
+#define NVIC_ICPR_CLRPEND_23 ((uint32_t)0x00800000) /*!< bit 23 */
+#define NVIC_ICPR_CLRPEND_24 ((uint32_t)0x01000000) /*!< bit 24 */
+#define NVIC_ICPR_CLRPEND_25 ((uint32_t)0x02000000) /*!< bit 25 */
+#define NVIC_ICPR_CLRPEND_26 ((uint32_t)0x04000000) /*!< bit 26 */
+#define NVIC_ICPR_CLRPEND_27 ((uint32_t)0x08000000) /*!< bit 27 */
+#define NVIC_ICPR_CLRPEND_28 ((uint32_t)0x10000000) /*!< bit 28 */
+#define NVIC_ICPR_CLRPEND_29 ((uint32_t)0x20000000) /*!< bit 29 */
+#define NVIC_ICPR_CLRPEND_30 ((uint32_t)0x40000000) /*!< bit 30 */
+#define NVIC_ICPR_CLRPEND_31 ((uint32_t)0x80000000) /*!< bit 31 */
+
+/****************** Bit definition for NVIC_IABR register *******************/
+#define NVIC_IABR_ACTIVE ((uint32_t)0xFFFFFFFF) /*!< Interrupt active flags */
+#define NVIC_IABR_ACTIVE_0 ((uint32_t)0x00000001) /*!< bit 0 */
+#define NVIC_IABR_ACTIVE_1 ((uint32_t)0x00000002) /*!< bit 1 */
+#define NVIC_IABR_ACTIVE_2 ((uint32_t)0x00000004) /*!< bit 2 */
+#define NVIC_IABR_ACTIVE_3 ((uint32_t)0x00000008) /*!< bit 3 */
+#define NVIC_IABR_ACTIVE_4 ((uint32_t)0x00000010) /*!< bit 4 */
+#define NVIC_IABR_ACTIVE_5 ((uint32_t)0x00000020) /*!< bit 5 */
+#define NVIC_IABR_ACTIVE_6 ((uint32_t)0x00000040) /*!< bit 6 */
+#define NVIC_IABR_ACTIVE_7 ((uint32_t)0x00000080) /*!< bit 7 */
+#define NVIC_IABR_ACTIVE_8 ((uint32_t)0x00000100) /*!< bit 8 */
+#define NVIC_IABR_ACTIVE_9 ((uint32_t)0x00000200) /*!< bit 9 */
+#define NVIC_IABR_ACTIVE_10 ((uint32_t)0x00000400) /*!< bit 10 */
+#define NVIC_IABR_ACTIVE_11 ((uint32_t)0x00000800) /*!< bit 11 */
+#define NVIC_IABR_ACTIVE_12 ((uint32_t)0x00001000) /*!< bit 12 */
+#define NVIC_IABR_ACTIVE_13 ((uint32_t)0x00002000) /*!< bit 13 */
+#define NVIC_IABR_ACTIVE_14 ((uint32_t)0x00004000) /*!< bit 14 */
+#define NVIC_IABR_ACTIVE_15 ((uint32_t)0x00008000) /*!< bit 15 */
+#define NVIC_IABR_ACTIVE_16 ((uint32_t)0x00010000) /*!< bit 16 */
+#define NVIC_IABR_ACTIVE_17 ((uint32_t)0x00020000) /*!< bit 17 */
+#define NVIC_IABR_ACTIVE_18 ((uint32_t)0x00040000) /*!< bit 18 */
+#define NVIC_IABR_ACTIVE_19 ((uint32_t)0x00080000) /*!< bit 19 */
+#define NVIC_IABR_ACTIVE_20 ((uint32_t)0x00100000) /*!< bit 20 */
+#define NVIC_IABR_ACTIVE_21 ((uint32_t)0x00200000) /*!< bit 21 */
+#define NVIC_IABR_ACTIVE_22 ((uint32_t)0x00400000) /*!< bit 22 */
+#define NVIC_IABR_ACTIVE_23 ((uint32_t)0x00800000) /*!< bit 23 */
+#define NVIC_IABR_ACTIVE_24 ((uint32_t)0x01000000) /*!< bit 24 */
+#define NVIC_IABR_ACTIVE_25 ((uint32_t)0x02000000) /*!< bit 25 */
+#define NVIC_IABR_ACTIVE_26 ((uint32_t)0x04000000) /*!< bit 26 */
+#define NVIC_IABR_ACTIVE_27 ((uint32_t)0x08000000) /*!< bit 27 */
+#define NVIC_IABR_ACTIVE_28 ((uint32_t)0x10000000) /*!< bit 28 */
+#define NVIC_IABR_ACTIVE_29 ((uint32_t)0x20000000) /*!< bit 29 */
+#define NVIC_IABR_ACTIVE_30 ((uint32_t)0x40000000) /*!< bit 30 */
+#define NVIC_IABR_ACTIVE_31 ((uint32_t)0x80000000) /*!< bit 31 */
+
+/****************** Bit definition for NVIC_PRI0 register *******************/
+#define NVIC_IPR0_PRI_0 ((uint32_t)0x000000FF) /*!< Priority of interrupt 0 */
+#define NVIC_IPR0_PRI_1 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 1 */
+#define NVIC_IPR0_PRI_2 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 2 */
+#define NVIC_IPR0_PRI_3 ((uint32_t)0xFF000000) /*!< Priority of interrupt 3 */
+
+/****************** Bit definition for NVIC_PRI1 register *******************/
+#define NVIC_IPR1_PRI_4 ((uint32_t)0x000000FF) /*!< Priority of interrupt 4 */
+#define NVIC_IPR1_PRI_5 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 5 */
+#define NVIC_IPR1_PRI_6 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 6 */
+#define NVIC_IPR1_PRI_7 ((uint32_t)0xFF000000) /*!< Priority of interrupt 7 */
+
+/****************** Bit definition for NVIC_PRI2 register *******************/
+#define NVIC_IPR2_PRI_8 ((uint32_t)0x000000FF) /*!< Priority of interrupt 8 */
+#define NVIC_IPR2_PRI_9 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 9 */
+#define NVIC_IPR2_PRI_10 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 10 */
+#define NVIC_IPR2_PRI_11 ((uint32_t)0xFF000000) /*!< Priority of interrupt 11 */
+
+/****************** Bit definition for NVIC_PRI3 register *******************/
+#define NVIC_IPR3_PRI_12 ((uint32_t)0x000000FF) /*!< Priority of interrupt 12 */
+#define NVIC_IPR3_PRI_13 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 13 */
+#define NVIC_IPR3_PRI_14 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 14 */
+#define NVIC_IPR3_PRI_15 ((uint32_t)0xFF000000) /*!< Priority of interrupt 15 */
+
+/****************** Bit definition for NVIC_PRI4 register *******************/
+#define NVIC_IPR4_PRI_16 ((uint32_t)0x000000FF) /*!< Priority of interrupt 16 */
+#define NVIC_IPR4_PRI_17 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 17 */
+#define NVIC_IPR4_PRI_18 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 18 */
+#define NVIC_IPR4_PRI_19 ((uint32_t)0xFF000000) /*!< Priority of interrupt 19 */
+
+/****************** Bit definition for NVIC_PRI5 register *******************/
+#define NVIC_IPR5_PRI_20 ((uint32_t)0x000000FF) /*!< Priority of interrupt 20 */
+#define NVIC_IPR5_PRI_21 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 21 */
+#define NVIC_IPR5_PRI_22 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 22 */
+#define NVIC_IPR5_PRI_23 ((uint32_t)0xFF000000) /*!< Priority of interrupt 23 */
+
+/****************** Bit definition for NVIC_PRI6 register *******************/
+#define NVIC_IPR6_PRI_24 ((uint32_t)0x000000FF) /*!< Priority of interrupt 24 */
+#define NVIC_IPR6_PRI_25 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 25 */
+#define NVIC_IPR6_PRI_26 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 26 */
+#define NVIC_IPR6_PRI_27 ((uint32_t)0xFF000000) /*!< Priority of interrupt 27 */
+
+/****************** Bit definition for NVIC_PRI7 register *******************/
+#define NVIC_IPR7_PRI_28 ((uint32_t)0x000000FF) /*!< Priority of interrupt 28 */
+#define NVIC_IPR7_PRI_29 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 29 */
+#define NVIC_IPR7_PRI_30 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 30 */
+#define NVIC_IPR7_PRI_31 ((uint32_t)0xFF000000) /*!< Priority of interrupt 31 */
+
+/****************** Bit definition for SCB_CPUID register *******************/
+#define SCB_CPUID_REVISION ((uint32_t)0x0000000F) /*!< Implementation defined revision number */
+#define SCB_CPUID_PARTNO ((uint32_t)0x0000FFF0) /*!< Number of processor within family */
+#define SCB_CPUID_Constant ((uint32_t)0x000F0000) /*!< Reads as 0x0F */
+#define SCB_CPUID_VARIANT ((uint32_t)0x00F00000) /*!< Implementation defined variant number */
+#define SCB_CPUID_IMPLEMENTER ((uint32_t)0xFF000000) /*!< Implementer code. ARM is 0x41 */
+
+/******************* Bit definition for SCB_ICSR register *******************/
+#define SCB_ICSR_VECTACTIVE ((uint32_t)0x000001FF) /*!< Active ISR number field */
+#define SCB_ICSR_RETTOBASE ((uint32_t)0x00000800) /*!< All active exceptions minus the IPSR_current_exception yields the empty set */
+#define SCB_ICSR_VECTPENDING ((uint32_t)0x003FF000) /*!< Pending ISR number field */
+#define SCB_ICSR_ISRPENDING ((uint32_t)0x00400000) /*!< Interrupt pending flag */
+#define SCB_ICSR_ISRPREEMPT ((uint32_t)0x00800000) /*!< It indicates that a pending interrupt becomes active in the next running cycle */
+#define SCB_ICSR_PENDSTCLR ((uint32_t)0x02000000) /*!< Clear pending SysTick bit */
+#define SCB_ICSR_PENDSTSET ((uint32_t)0x04000000) /*!< Set pending SysTick bit */
+#define SCB_ICSR_PENDSVCLR ((uint32_t)0x08000000) /*!< Clear pending pendSV bit */
+#define SCB_ICSR_PENDSVSET ((uint32_t)0x10000000) /*!< Set pending pendSV bit */
+#define SCB_ICSR_NMIPENDSET ((uint32_t)0x80000000) /*!< Set pending NMI bit */
+
+/******************* Bit definition for SCB_VTOR register *******************/
+#define SCB_VTOR_TBLOFF ((uint32_t)0x1FFFFF80) /*!< Vector table base offset field */
+#define SCB_VTOR_TBLBASE ((uint32_t)0x20000000) /*!< Table base in code(0) or RAM(1) */
+
+/*!<***************** Bit definition for SCB_AIRCR register *******************/
+#define SCB_AIRCR_VECTRESET ((uint32_t)0x00000001) /*!< System Reset bit */
+#define SCB_AIRCR_VECTCLRACTIVE ((uint32_t)0x00000002) /*!< Clear active vector bit */
+#define SCB_AIRCR_SYSRESETREQ ((uint32_t)0x00000004) /*!< Requests chip control logic to generate a reset */
+
+#define SCB_AIRCR_PRIGROUP ((uint32_t)0x00000700) /*!< PRIGROUP[2:0] bits (Priority group) */
+#define SCB_AIRCR_PRIGROUP_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define SCB_AIRCR_PRIGROUP_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define SCB_AIRCR_PRIGROUP_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+
+/* prority group configuration */
+#define SCB_AIRCR_PRIGROUP0 ((uint32_t)0x00000000) /*!< Priority group=0 (7 bits of pre-emption priority, 1 bit of subpriority) */
+#define SCB_AIRCR_PRIGROUP1 ((uint32_t)0x00000100) /*!< Priority group=1 (6 bits of pre-emption priority, 2 bits of subpriority) */
+#define SCB_AIRCR_PRIGROUP2 ((uint32_t)0x00000200) /*!< Priority group=2 (5 bits of pre-emption priority, 3 bits of subpriority) */
+#define SCB_AIRCR_PRIGROUP3 ((uint32_t)0x00000300) /*!< Priority group=3 (4 bits of pre-emption priority, 4 bits of subpriority) */
+#define SCB_AIRCR_PRIGROUP4 ((uint32_t)0x00000400) /*!< Priority group=4 (3 bits of pre-emption priority, 5 bits of subpriority) */
+#define SCB_AIRCR_PRIGROUP5 ((uint32_t)0x00000500) /*!< Priority group=5 (2 bits of pre-emption priority, 6 bits of subpriority) */
+#define SCB_AIRCR_PRIGROUP6 ((uint32_t)0x00000600) /*!< Priority group=6 (1 bit of pre-emption priority, 7 bits of subpriority) */
+#define SCB_AIRCR_PRIGROUP7 ((uint32_t)0x00000700) /*!< Priority group=7 (no pre-emption priority, 8 bits of subpriority) */
+
+#define SCB_AIRCR_ENDIANESS ((uint32_t)0x00008000) /*!< Data endianness bit */
+#define SCB_AIRCR_VECTKEY ((uint32_t)0xFFFF0000) /*!< Register key (VECTKEY) - Reads as 0xFA05 (VECTKEYSTAT) */
+
+/******************* Bit definition for SCB_SCR register ********************/
+#define SCB_SCR_SLEEPONEXIT ((uint8_t)0x02) /*!< Sleep on exit bit */
+#define SCB_SCR_SLEEPDEEP ((uint8_t)0x04) /*!< Sleep deep bit */
+#define SCB_SCR_SEVONPEND ((uint8_t)0x10) /*!< Wake up from WFE */
+
+/******************** Bit definition for SCB_CCR register *******************/
+#define SCB_CCR_NONBASETHRDENA ((uint16_t)0x0001) /*!< Thread mode can be entered from any level in Handler mode by controlled return value */
+#define SCB_CCR_USERSETMPEND ((uint16_t)0x0002) /*!< Enables user code to write the Software Trigger Interrupt register to trigger (pend) a Main exception */
+#define SCB_CCR_UNALIGN_TRP ((uint16_t)0x0008) /*!< Trap for unaligned access */
+#define SCB_CCR_DIV_0_TRP ((uint16_t)0x0010) /*!< Trap on Divide by 0 */
+#define SCB_CCR_BFHFNMIGN ((uint16_t)0x0100) /*!< Handlers running at priority -1 and -2 */
+#define SCB_CCR_STKALIGN ((uint16_t)0x0200) /*!< On exception entry, the SP used prior to the exception is adjusted to be 8-byte aligned */
+
+/******************* Bit definition for SCB_SHPR register ********************/
+#define SCB_SHPR_PRI_N ((uint32_t)0x000000FF) /*!< Priority of system handler 4,8, and 12. Mem Manage, reserved and Debug Monitor */
+#define SCB_SHPR_PRI_N1 ((uint32_t)0x0000FF00) /*!< Priority of system handler 5,9, and 13. Bus Fault, reserved and reserved */
+#define SCB_SHPR_PRI_N2 ((uint32_t)0x00FF0000) /*!< Priority of system handler 6,10, and 14. Usage Fault, reserved and PendSV */
+#define SCB_SHPR_PRI_N3 ((uint32_t)0xFF000000) /*!< Priority of system handler 7,11, and 15. Reserved, SVCall and SysTick */
+
+/****************** Bit definition for SCB_SHCSR register *******************/
+#define SCB_SHCSR_MEMFAULTACT ((uint32_t)0x00000001) /*!< MemManage is active */
+#define SCB_SHCSR_BUSFAULTACT ((uint32_t)0x00000002) /*!< BusFault is active */
+#define SCB_SHCSR_USGFAULTACT ((uint32_t)0x00000008) /*!< UsageFault is active */
+#define SCB_SHCSR_SVCALLACT ((uint32_t)0x00000080) /*!< SVCall is active */
+#define SCB_SHCSR_MONITORACT ((uint32_t)0x00000100) /*!< Monitor is active */
+#define SCB_SHCSR_PENDSVACT ((uint32_t)0x00000400) /*!< PendSV is active */
+#define SCB_SHCSR_SYSTICKACT ((uint32_t)0x00000800) /*!< SysTick is active */
+#define SCB_SHCSR_USGFAULTPENDED ((uint32_t)0x00001000) /*!< Usage Fault is pended */
+#define SCB_SHCSR_MEMFAULTPENDED ((uint32_t)0x00002000) /*!< MemManage is pended */
+#define SCB_SHCSR_BUSFAULTPENDED ((uint32_t)0x00004000) /*!< Bus Fault is pended */
+#define SCB_SHCSR_SVCALLPENDED ((uint32_t)0x00008000) /*!< SVCall is pended */
+#define SCB_SHCSR_MEMFAULTENA ((uint32_t)0x00010000) /*!< MemManage enable */
+#define SCB_SHCSR_BUSFAULTENA ((uint32_t)0x00020000) /*!< Bus Fault enable */
+#define SCB_SHCSR_USGFAULTENA ((uint32_t)0x00040000) /*!< UsageFault enable */
+
+/******************* Bit definition for SCB_CFSR register *******************/
+/*!< MFSR */
+#define SCB_CFSR_IACCVIOL ((uint32_t)0x00000001) /*!< Instruction access violation */
+#define SCB_CFSR_DACCVIOL ((uint32_t)0x00000002) /*!< Data access violation */
+#define SCB_CFSR_MUNSTKERR ((uint32_t)0x00000008) /*!< Unstacking error */
+#define SCB_CFSR_MSTKERR ((uint32_t)0x00000010) /*!< Stacking error */
+#define SCB_CFSR_MMARVALID ((uint32_t)0x00000080) /*!< Memory Manage Address Register address valid flag */
+/*!< BFSR */
+#define SCB_CFSR_IBUSERR ((uint32_t)0x00000100) /*!< Instruction bus error flag */
+#define SCB_CFSR_PRECISERR ((uint32_t)0x00000200) /*!< Precise data bus error */
+#define SCB_CFSR_IMPRECISERR ((uint32_t)0x00000400) /*!< Imprecise data bus error */
+#define SCB_CFSR_UNSTKERR ((uint32_t)0x00000800) /*!< Unstacking error */
+#define SCB_CFSR_STKERR ((uint32_t)0x00001000) /*!< Stacking error */
+#define SCB_CFSR_BFARVALID ((uint32_t)0x00008000) /*!< Bus Fault Address Register address valid flag */
+/*!< UFSR */
+#define SCB_CFSR_UNDEFINSTR ((uint32_t)0x00010000) /*!< The processor attempt to execute an undefined instruction */
+#define SCB_CFSR_INVSTATE ((uint32_t)0x00020000) /*!< Invalid combination of EPSR and instruction */
+#define SCB_CFSR_INVPC ((uint32_t)0x00040000) /*!< Attempt to load EXC_RETURN into pc illegally */
+#define SCB_CFSR_NOCP ((uint32_t)0x00080000) /*!< Attempt to use a coprocessor instruction */
+#define SCB_CFSR_UNALIGNED ((uint32_t)0x01000000) /*!< Fault occurs when there is an attempt to make an unaligned memory access */
+#define SCB_CFSR_DIVBYZERO ((uint32_t)0x02000000) /*!< Fault occurs when SDIV or DIV instruction is used with a divisor of 0 */
+
+/******************* Bit definition for SCB_HFSR register *******************/
+#define SCB_HFSR_VECTTBL ((uint32_t)0x00000002) /*!< Fault occurs because of vector table read on exception processing */
+#define SCB_HFSR_FORCED ((uint32_t)0x40000000) /*!< Hard Fault activated when a configurable Fault was received and cannot activate */
+#define SCB_HFSR_DEBUGEVT ((uint32_t)0x80000000) /*!< Fault related to debug */
+
+/******************* Bit definition for SCB_DFSR register *******************/
+#define SCB_DFSR_HALTED ((uint8_t)0x01) /*!< Halt request flag */
+#define SCB_DFSR_BKPT ((uint8_t)0x02) /*!< BKPT flag */
+#define SCB_DFSR_DWTTRAP ((uint8_t)0x04) /*!< Data Watchpoint and Trace (DWT) flag */
+#define SCB_DFSR_VCATCH ((uint8_t)0x08) /*!< Vector catch flag */
+#define SCB_DFSR_EXTERNAL ((uint8_t)0x10) /*!< External debug request flag */
+
+/******************* Bit definition for SCB_MMFAR register ******************/
+#define SCB_MMFAR_ADDRESS ((uint32_t)0xFFFFFFFF) /*!< Mem Manage fault address field */
+
+/******************* Bit definition for SCB_BFAR register *******************/
+#define SCB_BFAR_ADDRESS ((uint32_t)0xFFFFFFFF) /*!< Bus fault address field */
+
+/******************* Bit definition for SCB_afsr register *******************/
+#define SCB_AFSR_IMPDEF ((uint32_t)0xFFFFFFFF) /*!< Implementation defined */
+
+/******************************************************************************/
+/* */
+/* External Interrupt/Event Controller */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for EXTI_IMR register *******************/
+#define EXTI_IMR_MR0 ((uint32_t)0x00000001) /*!< Interrupt Mask on line 0 */
+#define EXTI_IMR_MR1 ((uint32_t)0x00000002) /*!< Interrupt Mask on line 1 */
+#define EXTI_IMR_MR2 ((uint32_t)0x00000004) /*!< Interrupt Mask on line 2 */
+#define EXTI_IMR_MR3 ((uint32_t)0x00000008) /*!< Interrupt Mask on line 3 */
+#define EXTI_IMR_MR4 ((uint32_t)0x00000010) /*!< Interrupt Mask on line 4 */
+#define EXTI_IMR_MR5 ((uint32_t)0x00000020) /*!< Interrupt Mask on line 5 */
+#define EXTI_IMR_MR6 ((uint32_t)0x00000040) /*!< Interrupt Mask on line 6 */
+#define EXTI_IMR_MR7 ((uint32_t)0x00000080) /*!< Interrupt Mask on line 7 */
+#define EXTI_IMR_MR8 ((uint32_t)0x00000100) /*!< Interrupt Mask on line 8 */
+#define EXTI_IMR_MR9 ((uint32_t)0x00000200) /*!< Interrupt Mask on line 9 */
+#define EXTI_IMR_MR10 ((uint32_t)0x00000400) /*!< Interrupt Mask on line 10 */
+#define EXTI_IMR_MR11 ((uint32_t)0x00000800) /*!< Interrupt Mask on line 11 */
+#define EXTI_IMR_MR12 ((uint32_t)0x00001000) /*!< Interrupt Mask on line 12 */
+#define EXTI_IMR_MR13 ((uint32_t)0x00002000) /*!< Interrupt Mask on line 13 */
+#define EXTI_IMR_MR14 ((uint32_t)0x00004000) /*!< Interrupt Mask on line 14 */
+#define EXTI_IMR_MR15 ((uint32_t)0x00008000) /*!< Interrupt Mask on line 15 */
+#define EXTI_IMR_MR16 ((uint32_t)0x00010000) /*!< Interrupt Mask on line 16 */
+#define EXTI_IMR_MR17 ((uint32_t)0x00020000) /*!< Interrupt Mask on line 17 */
+#define EXTI_IMR_MR18 ((uint32_t)0x00040000) /*!< Interrupt Mask on line 18 */
+#define EXTI_IMR_MR19 ((uint32_t)0x00080000) /*!< Interrupt Mask on line 19 */
+
+/******************* Bit definition for EXTI_EMR register *******************/
+#define EXTI_EMR_MR0 ((uint32_t)0x00000001) /*!< Event Mask on line 0 */
+#define EXTI_EMR_MR1 ((uint32_t)0x00000002) /*!< Event Mask on line 1 */
+#define EXTI_EMR_MR2 ((uint32_t)0x00000004) /*!< Event Mask on line 2 */
+#define EXTI_EMR_MR3 ((uint32_t)0x00000008) /*!< Event Mask on line 3 */
+#define EXTI_EMR_MR4 ((uint32_t)0x00000010) /*!< Event Mask on line 4 */
+#define EXTI_EMR_MR5 ((uint32_t)0x00000020) /*!< Event Mask on line 5 */
+#define EXTI_EMR_MR6 ((uint32_t)0x00000040) /*!< Event Mask on line 6 */
+#define EXTI_EMR_MR7 ((uint32_t)0x00000080) /*!< Event Mask on line 7 */
+#define EXTI_EMR_MR8 ((uint32_t)0x00000100) /*!< Event Mask on line 8 */
+#define EXTI_EMR_MR9 ((uint32_t)0x00000200) /*!< Event Mask on line 9 */
+#define EXTI_EMR_MR10 ((uint32_t)0x00000400) /*!< Event Mask on line 10 */
+#define EXTI_EMR_MR11 ((uint32_t)0x00000800) /*!< Event Mask on line 11 */
+#define EXTI_EMR_MR12 ((uint32_t)0x00001000) /*!< Event Mask on line 12 */
+#define EXTI_EMR_MR13 ((uint32_t)0x00002000) /*!< Event Mask on line 13 */
+#define EXTI_EMR_MR14 ((uint32_t)0x00004000) /*!< Event Mask on line 14 */
+#define EXTI_EMR_MR15 ((uint32_t)0x00008000) /*!< Event Mask on line 15 */
+#define EXTI_EMR_MR16 ((uint32_t)0x00010000) /*!< Event Mask on line 16 */
+#define EXTI_EMR_MR17 ((uint32_t)0x00020000) /*!< Event Mask on line 17 */
+#define EXTI_EMR_MR18 ((uint32_t)0x00040000) /*!< Event Mask on line 18 */
+#define EXTI_EMR_MR19 ((uint32_t)0x00080000) /*!< Event Mask on line 19 */
+
+/****************** Bit definition for EXTI_RTSR register *******************/
+#define EXTI_RTSR_TR0 ((uint32_t)0x00000001) /*!< Rising trigger event configuration bit of line 0 */
+#define EXTI_RTSR_TR1 ((uint32_t)0x00000002) /*!< Rising trigger event configuration bit of line 1 */
+#define EXTI_RTSR_TR2 ((uint32_t)0x00000004) /*!< Rising trigger event configuration bit of line 2 */
+#define EXTI_RTSR_TR3 ((uint32_t)0x00000008) /*!< Rising trigger event configuration bit of line 3 */
+#define EXTI_RTSR_TR4 ((uint32_t)0x00000010) /*!< Rising trigger event configuration bit of line 4 */
+#define EXTI_RTSR_TR5 ((uint32_t)0x00000020) /*!< Rising trigger event configuration bit of line 5 */
+#define EXTI_RTSR_TR6 ((uint32_t)0x00000040) /*!< Rising trigger event configuration bit of line 6 */
+#define EXTI_RTSR_TR7 ((uint32_t)0x00000080) /*!< Rising trigger event configuration bit of line 7 */
+#define EXTI_RTSR_TR8 ((uint32_t)0x00000100) /*!< Rising trigger event configuration bit of line 8 */
+#define EXTI_RTSR_TR9 ((uint32_t)0x00000200) /*!< Rising trigger event configuration bit of line 9 */
+#define EXTI_RTSR_TR10 ((uint32_t)0x00000400) /*!< Rising trigger event configuration bit of line 10 */
+#define EXTI_RTSR_TR11 ((uint32_t)0x00000800) /*!< Rising trigger event configuration bit of line 11 */
+#define EXTI_RTSR_TR12 ((uint32_t)0x00001000) /*!< Rising trigger event configuration bit of line 12 */
+#define EXTI_RTSR_TR13 ((uint32_t)0x00002000) /*!< Rising trigger event configuration bit of line 13 */
+#define EXTI_RTSR_TR14 ((uint32_t)0x00004000) /*!< Rising trigger event configuration bit of line 14 */
+#define EXTI_RTSR_TR15 ((uint32_t)0x00008000) /*!< Rising trigger event configuration bit of line 15 */
+#define EXTI_RTSR_TR16 ((uint32_t)0x00010000) /*!< Rising trigger event configuration bit of line 16 */
+#define EXTI_RTSR_TR17 ((uint32_t)0x00020000) /*!< Rising trigger event configuration bit of line 17 */
+#define EXTI_RTSR_TR18 ((uint32_t)0x00040000) /*!< Rising trigger event configuration bit of line 18 */
+#define EXTI_RTSR_TR19 ((uint32_t)0x00080000) /*!< Rising trigger event configuration bit of line 19 */
+
+/****************** Bit definition for EXTI_FTSR register *******************/
+#define EXTI_FTSR_TR0 ((uint32_t)0x00000001) /*!< Falling trigger event configuration bit of line 0 */
+#define EXTI_FTSR_TR1 ((uint32_t)0x00000002) /*!< Falling trigger event configuration bit of line 1 */
+#define EXTI_FTSR_TR2 ((uint32_t)0x00000004) /*!< Falling trigger event configuration bit of line 2 */
+#define EXTI_FTSR_TR3 ((uint32_t)0x00000008) /*!< Falling trigger event configuration bit of line 3 */
+#define EXTI_FTSR_TR4 ((uint32_t)0x00000010) /*!< Falling trigger event configuration bit of line 4 */
+#define EXTI_FTSR_TR5 ((uint32_t)0x00000020) /*!< Falling trigger event configuration bit of line 5 */
+#define EXTI_FTSR_TR6 ((uint32_t)0x00000040) /*!< Falling trigger event configuration bit of line 6 */
+#define EXTI_FTSR_TR7 ((uint32_t)0x00000080) /*!< Falling trigger event configuration bit of line 7 */
+#define EXTI_FTSR_TR8 ((uint32_t)0x00000100) /*!< Falling trigger event configuration bit of line 8 */
+#define EXTI_FTSR_TR9 ((uint32_t)0x00000200) /*!< Falling trigger event configuration bit of line 9 */
+#define EXTI_FTSR_TR10 ((uint32_t)0x00000400) /*!< Falling trigger event configuration bit of line 10 */
+#define EXTI_FTSR_TR11 ((uint32_t)0x00000800) /*!< Falling trigger event configuration bit of line 11 */
+#define EXTI_FTSR_TR12 ((uint32_t)0x00001000) /*!< Falling trigger event configuration bit of line 12 */
+#define EXTI_FTSR_TR13 ((uint32_t)0x00002000) /*!< Falling trigger event configuration bit of line 13 */
+#define EXTI_FTSR_TR14 ((uint32_t)0x00004000) /*!< Falling trigger event configuration bit of line 14 */
+#define EXTI_FTSR_TR15 ((uint32_t)0x00008000) /*!< Falling trigger event configuration bit of line 15 */
+#define EXTI_FTSR_TR16 ((uint32_t)0x00010000) /*!< Falling trigger event configuration bit of line 16 */
+#define EXTI_FTSR_TR17 ((uint32_t)0x00020000) /*!< Falling trigger event configuration bit of line 17 */
+#define EXTI_FTSR_TR18 ((uint32_t)0x00040000) /*!< Falling trigger event configuration bit of line 18 */
+#define EXTI_FTSR_TR19 ((uint32_t)0x00080000) /*!< Falling trigger event configuration bit of line 19 */
+
+/****************** Bit definition for EXTI_SWIER register ******************/
+#define EXTI_SWIER_SWIER0 ((uint32_t)0x00000001) /*!< Software Interrupt on line 0 */
+#define EXTI_SWIER_SWIER1 ((uint32_t)0x00000002) /*!< Software Interrupt on line 1 */
+#define EXTI_SWIER_SWIER2 ((uint32_t)0x00000004) /*!< Software Interrupt on line 2 */
+#define EXTI_SWIER_SWIER3 ((uint32_t)0x00000008) /*!< Software Interrupt on line 3 */
+#define EXTI_SWIER_SWIER4 ((uint32_t)0x00000010) /*!< Software Interrupt on line 4 */
+#define EXTI_SWIER_SWIER5 ((uint32_t)0x00000020) /*!< Software Interrupt on line 5 */
+#define EXTI_SWIER_SWIER6 ((uint32_t)0x00000040) /*!< Software Interrupt on line 6 */
+#define EXTI_SWIER_SWIER7 ((uint32_t)0x00000080) /*!< Software Interrupt on line 7 */
+#define EXTI_SWIER_SWIER8 ((uint32_t)0x00000100) /*!< Software Interrupt on line 8 */
+#define EXTI_SWIER_SWIER9 ((uint32_t)0x00000200) /*!< Software Interrupt on line 9 */
+#define EXTI_SWIER_SWIER10 ((uint32_t)0x00000400) /*!< Software Interrupt on line 10 */
+#define EXTI_SWIER_SWIER11 ((uint32_t)0x00000800) /*!< Software Interrupt on line 11 */
+#define EXTI_SWIER_SWIER12 ((uint32_t)0x00001000) /*!< Software Interrupt on line 12 */
+#define EXTI_SWIER_SWIER13 ((uint32_t)0x00002000) /*!< Software Interrupt on line 13 */
+#define EXTI_SWIER_SWIER14 ((uint32_t)0x00004000) /*!< Software Interrupt on line 14 */
+#define EXTI_SWIER_SWIER15 ((uint32_t)0x00008000) /*!< Software Interrupt on line 15 */
+#define EXTI_SWIER_SWIER16 ((uint32_t)0x00010000) /*!< Software Interrupt on line 16 */
+#define EXTI_SWIER_SWIER17 ((uint32_t)0x00020000) /*!< Software Interrupt on line 17 */
+#define EXTI_SWIER_SWIER18 ((uint32_t)0x00040000) /*!< Software Interrupt on line 18 */
+#define EXTI_SWIER_SWIER19 ((uint32_t)0x00080000) /*!< Software Interrupt on line 19 */
+
+/******************* Bit definition for EXTI_PR register ********************/
+#define EXTI_PR_PR0 ((uint32_t)0x00000001) /*!< Pending bit for line 0 */
+#define EXTI_PR_PR1 ((uint32_t)0x00000002) /*!< Pending bit for line 1 */
+#define EXTI_PR_PR2 ((uint32_t)0x00000004) /*!< Pending bit for line 2 */
+#define EXTI_PR_PR3 ((uint32_t)0x00000008) /*!< Pending bit for line 3 */
+#define EXTI_PR_PR4 ((uint32_t)0x00000010) /*!< Pending bit for line 4 */
+#define EXTI_PR_PR5 ((uint32_t)0x00000020) /*!< Pending bit for line 5 */
+#define EXTI_PR_PR6 ((uint32_t)0x00000040) /*!< Pending bit for line 6 */
+#define EXTI_PR_PR7 ((uint32_t)0x00000080) /*!< Pending bit for line 7 */
+#define EXTI_PR_PR8 ((uint32_t)0x00000100) /*!< Pending bit for line 8 */
+#define EXTI_PR_PR9 ((uint32_t)0x00000200) /*!< Pending bit for line 9 */
+#define EXTI_PR_PR10 ((uint32_t)0x00000400) /*!< Pending bit for line 10 */
+#define EXTI_PR_PR11 ((uint32_t)0x00000800) /*!< Pending bit for line 11 */
+#define EXTI_PR_PR12 ((uint32_t)0x00001000) /*!< Pending bit for line 12 */
+#define EXTI_PR_PR13 ((uint32_t)0x00002000) /*!< Pending bit for line 13 */
+#define EXTI_PR_PR14 ((uint32_t)0x00004000) /*!< Pending bit for line 14 */
+#define EXTI_PR_PR15 ((uint32_t)0x00008000) /*!< Pending bit for line 15 */
+#define EXTI_PR_PR16 ((uint32_t)0x00010000) /*!< Pending bit for line 16 */
+#define EXTI_PR_PR17 ((uint32_t)0x00020000) /*!< Pending bit for line 17 */
+#define EXTI_PR_PR18 ((uint32_t)0x00040000) /*!< Pending bit for line 18 */
+#define EXTI_PR_PR19 ((uint32_t)0x00080000) /*!< Pending bit for line 19 */
+
+/******************************************************************************/
+/* */
+/* DMA Controller */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for DMA_ISR register ********************/
+#define DMA_ISR_GIF1 ((uint32_t)0x00000001) /*!< Channel 1 Global interrupt flag */
+#define DMA_ISR_TCIF1 ((uint32_t)0x00000002) /*!< Channel 1 Transfer Complete flag */
+#define DMA_ISR_HTIF1 ((uint32_t)0x00000004) /*!< Channel 1 Half Transfer flag */
+#define DMA_ISR_TEIF1 ((uint32_t)0x00000008) /*!< Channel 1 Transfer Error flag */
+#define DMA_ISR_GIF2 ((uint32_t)0x00000010) /*!< Channel 2 Global interrupt flag */
+#define DMA_ISR_TCIF2 ((uint32_t)0x00000020) /*!< Channel 2 Transfer Complete flag */
+#define DMA_ISR_HTIF2 ((uint32_t)0x00000040) /*!< Channel 2 Half Transfer flag */
+#define DMA_ISR_TEIF2 ((uint32_t)0x00000080) /*!< Channel 2 Transfer Error flag */
+#define DMA_ISR_GIF3 ((uint32_t)0x00000100) /*!< Channel 3 Global interrupt flag */
+#define DMA_ISR_TCIF3 ((uint32_t)0x00000200) /*!< Channel 3 Transfer Complete flag */
+#define DMA_ISR_HTIF3 ((uint32_t)0x00000400) /*!< Channel 3 Half Transfer flag */
+#define DMA_ISR_TEIF3 ((uint32_t)0x00000800) /*!< Channel 3 Transfer Error flag */
+#define DMA_ISR_GIF4 ((uint32_t)0x00001000) /*!< Channel 4 Global interrupt flag */
+#define DMA_ISR_TCIF4 ((uint32_t)0x00002000) /*!< Channel 4 Transfer Complete flag */
+#define DMA_ISR_HTIF4 ((uint32_t)0x00004000) /*!< Channel 4 Half Transfer flag */
+#define DMA_ISR_TEIF4 ((uint32_t)0x00008000) /*!< Channel 4 Transfer Error flag */
+#define DMA_ISR_GIF5 ((uint32_t)0x00010000) /*!< Channel 5 Global interrupt flag */
+#define DMA_ISR_TCIF5 ((uint32_t)0x00020000) /*!< Channel 5 Transfer Complete flag */
+#define DMA_ISR_HTIF5 ((uint32_t)0x00040000) /*!< Channel 5 Half Transfer flag */
+#define DMA_ISR_TEIF5 ((uint32_t)0x00080000) /*!< Channel 5 Transfer Error flag */
+#define DMA_ISR_GIF6 ((uint32_t)0x00100000) /*!< Channel 6 Global interrupt flag */
+#define DMA_ISR_TCIF6 ((uint32_t)0x00200000) /*!< Channel 6 Transfer Complete flag */
+#define DMA_ISR_HTIF6 ((uint32_t)0x00400000) /*!< Channel 6 Half Transfer flag */
+#define DMA_ISR_TEIF6 ((uint32_t)0x00800000) /*!< Channel 6 Transfer Error flag */
+#define DMA_ISR_GIF7 ((uint32_t)0x01000000) /*!< Channel 7 Global interrupt flag */
+#define DMA_ISR_TCIF7 ((uint32_t)0x02000000) /*!< Channel 7 Transfer Complete flag */
+#define DMA_ISR_HTIF7 ((uint32_t)0x04000000) /*!< Channel 7 Half Transfer flag */
+#define DMA_ISR_TEIF7 ((uint32_t)0x08000000) /*!< Channel 7 Transfer Error flag */
+
+/******************* Bit definition for DMA_IFCR register *******************/
+#define DMA_IFCR_CGIF1 ((uint32_t)0x00000001) /*!< Channel 1 Global interrupt clear */
+#define DMA_IFCR_CTCIF1 ((uint32_t)0x00000002) /*!< Channel 1 Transfer Complete clear */
+#define DMA_IFCR_CHTIF1 ((uint32_t)0x00000004) /*!< Channel 1 Half Transfer clear */
+#define DMA_IFCR_CTEIF1 ((uint32_t)0x00000008) /*!< Channel 1 Transfer Error clear */
+#define DMA_IFCR_CGIF2 ((uint32_t)0x00000010) /*!< Channel 2 Global interrupt clear */
+#define DMA_IFCR_CTCIF2 ((uint32_t)0x00000020) /*!< Channel 2 Transfer Complete clear */
+#define DMA_IFCR_CHTIF2 ((uint32_t)0x00000040) /*!< Channel 2 Half Transfer clear */
+#define DMA_IFCR_CTEIF2 ((uint32_t)0x00000080) /*!< Channel 2 Transfer Error clear */
+#define DMA_IFCR_CGIF3 ((uint32_t)0x00000100) /*!< Channel 3 Global interrupt clear */
+#define DMA_IFCR_CTCIF3 ((uint32_t)0x00000200) /*!< Channel 3 Transfer Complete clear */
+#define DMA_IFCR_CHTIF3 ((uint32_t)0x00000400) /*!< Channel 3 Half Transfer clear */
+#define DMA_IFCR_CTEIF3 ((uint32_t)0x00000800) /*!< Channel 3 Transfer Error clear */
+#define DMA_IFCR_CGIF4 ((uint32_t)0x00001000) /*!< Channel 4 Global interrupt clear */
+#define DMA_IFCR_CTCIF4 ((uint32_t)0x00002000) /*!< Channel 4 Transfer Complete clear */
+#define DMA_IFCR_CHTIF4 ((uint32_t)0x00004000) /*!< Channel 4 Half Transfer clear */
+#define DMA_IFCR_CTEIF4 ((uint32_t)0x00008000) /*!< Channel 4 Transfer Error clear */
+#define DMA_IFCR_CGIF5 ((uint32_t)0x00010000) /*!< Channel 5 Global interrupt clear */
+#define DMA_IFCR_CTCIF5 ((uint32_t)0x00020000) /*!< Channel 5 Transfer Complete clear */
+#define DMA_IFCR_CHTIF5 ((uint32_t)0x00040000) /*!< Channel 5 Half Transfer clear */
+#define DMA_IFCR_CTEIF5 ((uint32_t)0x00080000) /*!< Channel 5 Transfer Error clear */
+#define DMA_IFCR_CGIF6 ((uint32_t)0x00100000) /*!< Channel 6 Global interrupt clear */
+#define DMA_IFCR_CTCIF6 ((uint32_t)0x00200000) /*!< Channel 6 Transfer Complete clear */
+#define DMA_IFCR_CHTIF6 ((uint32_t)0x00400000) /*!< Channel 6 Half Transfer clear */
+#define DMA_IFCR_CTEIF6 ((uint32_t)0x00800000) /*!< Channel 6 Transfer Error clear */
+#define DMA_IFCR_CGIF7 ((uint32_t)0x01000000) /*!< Channel 7 Global interrupt clear */
+#define DMA_IFCR_CTCIF7 ((uint32_t)0x02000000) /*!< Channel 7 Transfer Complete clear */
+#define DMA_IFCR_CHTIF7 ((uint32_t)0x04000000) /*!< Channel 7 Half Transfer clear */
+#define DMA_IFCR_CTEIF7 ((uint32_t)0x08000000) /*!< Channel 7 Transfer Error clear */
+
+/******************* Bit definition for DMA_CCR1 register *******************/
+#define DMA_CCR1_EN ((uint16_t)0x0001) /*!< Channel enable*/
+#define DMA_CCR1_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */
+#define DMA_CCR1_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */
+#define DMA_CCR1_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */
+#define DMA_CCR1_DIR ((uint16_t)0x0010) /*!< Data transfer direction */
+#define DMA_CCR1_CIRC ((uint16_t)0x0020) /*!< Circular mode */
+#define DMA_CCR1_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */
+#define DMA_CCR1_MINC ((uint16_t)0x0080) /*!< Memory increment mode */
+
+#define DMA_CCR1_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */
+#define DMA_CCR1_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define DMA_CCR1_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define DMA_CCR1_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */
+#define DMA_CCR1_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define DMA_CCR1_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */
+
+#define DMA_CCR1_PL ((uint16_t)0x3000) /*!< PL[1:0] bits(Channel Priority level) */
+#define DMA_CCR1_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define DMA_CCR1_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define DMA_CCR1_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode */
+
+/******************* Bit definition for DMA_CCR2 register *******************/
+#define DMA_CCR2_EN ((uint16_t)0x0001) /*!< Channel enable */
+#define DMA_CCR2_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */
+#define DMA_CCR2_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */
+#define DMA_CCR2_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */
+#define DMA_CCR2_DIR ((uint16_t)0x0010) /*!< Data transfer direction */
+#define DMA_CCR2_CIRC ((uint16_t)0x0020) /*!< Circular mode */
+#define DMA_CCR2_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */
+#define DMA_CCR2_MINC ((uint16_t)0x0080) /*!< Memory increment mode */
+
+#define DMA_CCR2_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */
+#define DMA_CCR2_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define DMA_CCR2_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define DMA_CCR2_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */
+#define DMA_CCR2_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define DMA_CCR2_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */
+
+#define DMA_CCR2_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */
+#define DMA_CCR2_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define DMA_CCR2_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define DMA_CCR2_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode */
+
+/******************* Bit definition for DMA_CCR3 register *******************/
+#define DMA_CCR3_EN ((uint16_t)0x0001) /*!< Channel enable */
+#define DMA_CCR3_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */
+#define DMA_CCR3_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */
+#define DMA_CCR3_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */
+#define DMA_CCR3_DIR ((uint16_t)0x0010) /*!< Data transfer direction */
+#define DMA_CCR3_CIRC ((uint16_t)0x0020) /*!< Circular mode */
+#define DMA_CCR3_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */
+#define DMA_CCR3_MINC ((uint16_t)0x0080) /*!< Memory increment mode */
+
+#define DMA_CCR3_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */
+#define DMA_CCR3_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define DMA_CCR3_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define DMA_CCR3_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */
+#define DMA_CCR3_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define DMA_CCR3_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */
+
+#define DMA_CCR3_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */
+#define DMA_CCR3_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define DMA_CCR3_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define DMA_CCR3_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode */
+
+/*!<****************** Bit definition for DMA_CCR4 register *******************/
+#define DMA_CCR4_EN ((uint16_t)0x0001) /*!< Channel enable */
+#define DMA_CCR4_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */
+#define DMA_CCR4_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */
+#define DMA_CCR4_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */
+#define DMA_CCR4_DIR ((uint16_t)0x0010) /*!< Data transfer direction */
+#define DMA_CCR4_CIRC ((uint16_t)0x0020) /*!< Circular mode */
+#define DMA_CCR4_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */
+#define DMA_CCR4_MINC ((uint16_t)0x0080) /*!< Memory increment mode */
+
+#define DMA_CCR4_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */
+#define DMA_CCR4_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define DMA_CCR4_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define DMA_CCR4_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */
+#define DMA_CCR4_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define DMA_CCR4_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */
+
+#define DMA_CCR4_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */
+#define DMA_CCR4_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define DMA_CCR4_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define DMA_CCR4_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode */
+
+/****************** Bit definition for DMA_CCR5 register *******************/
+#define DMA_CCR5_EN ((uint16_t)0x0001) /*!< Channel enable */
+#define DMA_CCR5_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */
+#define DMA_CCR5_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */
+#define DMA_CCR5_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */
+#define DMA_CCR5_DIR ((uint16_t)0x0010) /*!< Data transfer direction */
+#define DMA_CCR5_CIRC ((uint16_t)0x0020) /*!< Circular mode */
+#define DMA_CCR5_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */
+#define DMA_CCR5_MINC ((uint16_t)0x0080) /*!< Memory increment mode */
+
+#define DMA_CCR5_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */
+#define DMA_CCR5_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define DMA_CCR5_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define DMA_CCR5_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */
+#define DMA_CCR5_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define DMA_CCR5_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */
+
+#define DMA_CCR5_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */
+#define DMA_CCR5_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define DMA_CCR5_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define DMA_CCR5_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode enable */
+
+/******************* Bit definition for DMA_CCR6 register *******************/
+#define DMA_CCR6_EN ((uint16_t)0x0001) /*!< Channel enable */
+#define DMA_CCR6_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */
+#define DMA_CCR6_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */
+#define DMA_CCR6_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */
+#define DMA_CCR6_DIR ((uint16_t)0x0010) /*!< Data transfer direction */
+#define DMA_CCR6_CIRC ((uint16_t)0x0020) /*!< Circular mode */
+#define DMA_CCR6_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */
+#define DMA_CCR6_MINC ((uint16_t)0x0080) /*!< Memory increment mode */
+
+#define DMA_CCR6_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */
+#define DMA_CCR6_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define DMA_CCR6_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define DMA_CCR6_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */
+#define DMA_CCR6_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define DMA_CCR6_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */
+
+#define DMA_CCR6_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */
+#define DMA_CCR6_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define DMA_CCR6_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define DMA_CCR6_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode */
+
+/******************* Bit definition for DMA_CCR7 register *******************/
+#define DMA_CCR7_EN ((uint16_t)0x0001) /*!< Channel enable */
+#define DMA_CCR7_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */
+#define DMA_CCR7_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */
+#define DMA_CCR7_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */
+#define DMA_CCR7_DIR ((uint16_t)0x0010) /*!< Data transfer direction */
+#define DMA_CCR7_CIRC ((uint16_t)0x0020) /*!< Circular mode */
+#define DMA_CCR7_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */
+#define DMA_CCR7_MINC ((uint16_t)0x0080) /*!< Memory increment mode */
+
+#define DMA_CCR7_PSIZE , ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */
+#define DMA_CCR7_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define DMA_CCR7_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define DMA_CCR7_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */
+#define DMA_CCR7_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define DMA_CCR7_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */
+
+#define DMA_CCR7_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */
+#define DMA_CCR7_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define DMA_CCR7_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define DMA_CCR7_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode enable */
+
+/****************** Bit definition for DMA_CNDTR1 register ******************/
+#define DMA_CNDTR1_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */
+
+/****************** Bit definition for DMA_CNDTR2 register ******************/
+#define DMA_CNDTR2_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */
+
+/****************** Bit definition for DMA_CNDTR3 register ******************/
+#define DMA_CNDTR3_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */
+
+/****************** Bit definition for DMA_CNDTR4 register ******************/
+#define DMA_CNDTR4_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */
+
+/****************** Bit definition for DMA_CNDTR5 register ******************/
+#define DMA_CNDTR5_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */
+
+/****************** Bit definition for DMA_CNDTR6 register ******************/
+#define DMA_CNDTR6_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */
+
+/****************** Bit definition for DMA_CNDTR7 register ******************/
+#define DMA_CNDTR7_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */
+
+/****************** Bit definition for DMA_CPAR1 register *******************/
+#define DMA_CPAR1_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */
+
+/****************** Bit definition for DMA_CPAR2 register *******************/
+#define DMA_CPAR2_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */
+
+/****************** Bit definition for DMA_CPAR3 register *******************/
+#define DMA_CPAR3_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */
+
+
+/****************** Bit definition for DMA_CPAR4 register *******************/
+#define DMA_CPAR4_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */
+
+/****************** Bit definition for DMA_CPAR5 register *******************/
+#define DMA_CPAR5_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */
+
+/****************** Bit definition for DMA_CPAR6 register *******************/
+#define DMA_CPAR6_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */
+
+
+/****************** Bit definition for DMA_CPAR7 register *******************/
+#define DMA_CPAR7_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */
+
+/****************** Bit definition for DMA_CMAR1 register *******************/
+#define DMA_CMAR1_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */
+
+/****************** Bit definition for DMA_CMAR2 register *******************/
+#define DMA_CMAR2_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */
+
+/****************** Bit definition for DMA_CMAR3 register *******************/
+#define DMA_CMAR3_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */
+
+
+/****************** Bit definition for DMA_CMAR4 register *******************/
+#define DMA_CMAR4_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */
+
+/****************** Bit definition for DMA_CMAR5 register *******************/
+#define DMA_CMAR5_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */
+
+/****************** Bit definition for DMA_CMAR6 register *******************/
+#define DMA_CMAR6_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */
+
+/****************** Bit definition for DMA_CMAR7 register *******************/
+#define DMA_CMAR7_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */
+
+/******************************************************************************/
+/* */
+/* Analog to Digital Converter */
+/* */
+/******************************************************************************/
+
+/******************** Bit definition for ADC_SR register ********************/
+#define ADC_SR_AWD ((uint8_t)0x01) /*!< Analog watchdog flag */
+#define ADC_SR_EOC ((uint8_t)0x02) /*!< End of conversion */
+#define ADC_SR_JEOC ((uint8_t)0x04) /*!< Injected channel end of conversion */
+#define ADC_SR_JSTRT ((uint8_t)0x08) /*!< Injected channel Start flag */
+#define ADC_SR_STRT ((uint8_t)0x10) /*!< Regular channel Start flag */
+
+/******************* Bit definition for ADC_CR1 register ********************/
+#define ADC_CR1_AWDCH ((uint32_t)0x0000001F) /*!< AWDCH[4:0] bits (Analog watchdog channel select bits) */
+#define ADC_CR1_AWDCH_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define ADC_CR1_AWDCH_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define ADC_CR1_AWDCH_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define ADC_CR1_AWDCH_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define ADC_CR1_AWDCH_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+
+#define ADC_CR1_EOCIE ((uint32_t)0x00000020) /*!< Interrupt enable for EOC */
+#define ADC_CR1_AWDIE ((uint32_t)0x00000040) /*!< Analog Watchdog interrupt enable */
+#define ADC_CR1_JEOCIE ((uint32_t)0x00000080) /*!< Interrupt enable for injected channels */
+#define ADC_CR1_SCAN ((uint32_t)0x00000100) /*!< Scan mode */
+#define ADC_CR1_AWDSGL ((uint32_t)0x00000200) /*!< Enable the watchdog on a single channel in scan mode */
+#define ADC_CR1_JAUTO ((uint32_t)0x00000400) /*!< Automatic injected group conversion */
+#define ADC_CR1_DISCEN ((uint32_t)0x00000800) /*!< Discontinuous mode on regular channels */
+#define ADC_CR1_JDISCEN ((uint32_t)0x00001000) /*!< Discontinuous mode on injected channels */
+
+#define ADC_CR1_DISCNUM ((uint32_t)0x0000E000) /*!< DISCNUM[2:0] bits (Discontinuous mode channel count) */
+#define ADC_CR1_DISCNUM_0 ((uint32_t)0x00002000) /*!< Bit 0 */
+#define ADC_CR1_DISCNUM_1 ((uint32_t)0x00004000) /*!< Bit 1 */
+#define ADC_CR1_DISCNUM_2 ((uint32_t)0x00008000) /*!< Bit 2 */
+
+#define ADC_CR1_DUALMOD ((uint32_t)0x000F0000) /*!< DUALMOD[3:0] bits (Dual mode selection) */
+#define ADC_CR1_DUALMOD_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define ADC_CR1_DUALMOD_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define ADC_CR1_DUALMOD_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define ADC_CR1_DUALMOD_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+
+#define ADC_CR1_JAWDEN ((uint32_t)0x00400000) /*!< Analog watchdog enable on injected channels */
+#define ADC_CR1_AWDEN ((uint32_t)0x00800000) /*!< Analog watchdog enable on regular channels */
+
+
+/******************* Bit definition for ADC_CR2 register ********************/
+#define ADC_CR2_ADON ((uint32_t)0x00000001) /*!< A/D Converter ON / OFF */
+#define ADC_CR2_CONT ((uint32_t)0x00000002) /*!< Continuous Conversion */
+#define ADC_CR2_CAL ((uint32_t)0x00000004) /*!< A/D Calibration */
+#define ADC_CR2_RSTCAL ((uint32_t)0x00000008) /*!< Reset Calibration */
+#define ADC_CR2_DMA ((uint32_t)0x00000100) /*!< Direct Memory access mode */
+#define ADC_CR2_ALIGN ((uint32_t)0x00000800) /*!< Data Alignment */
+
+#define ADC_CR2_JEXTSEL ((uint32_t)0x00007000) /*!< JEXTSEL[2:0] bits (External event select for injected group) */
+#define ADC_CR2_JEXTSEL_0 ((uint32_t)0x00001000) /*!< Bit 0 */
+#define ADC_CR2_JEXTSEL_1 ((uint32_t)0x00002000) /*!< Bit 1 */
+#define ADC_CR2_JEXTSEL_2 ((uint32_t)0x00004000) /*!< Bit 2 */
+
+#define ADC_CR2_JEXTTRIG ((uint32_t)0x00008000) /*!< External Trigger Conversion mode for injected channels */
+
+#define ADC_CR2_EXTSEL ((uint32_t)0x000E0000) /*!< EXTSEL[2:0] bits (External Event Select for regular group) */
+#define ADC_CR2_EXTSEL_0 ((uint32_t)0x00020000) /*!< Bit 0 */
+#define ADC_CR2_EXTSEL_1 ((uint32_t)0x00040000) /*!< Bit 1 */
+#define ADC_CR2_EXTSEL_2 ((uint32_t)0x00080000) /*!< Bit 2 */
+
+#define ADC_CR2_EXTTRIG ((uint32_t)0x00100000) /*!< External Trigger Conversion mode for regular channels */
+#define ADC_CR2_JSWSTART ((uint32_t)0x00200000) /*!< Start Conversion of injected channels */
+#define ADC_CR2_SWSTART ((uint32_t)0x00400000) /*!< Start Conversion of regular channels */
+#define ADC_CR2_TSVREFE ((uint32_t)0x00800000) /*!< Temperature Sensor and VREFINT Enable */
+
+/****************** Bit definition for ADC_SMPR1 register *******************/
+#define ADC_SMPR1_SMP10 ((uint32_t)0x00000007) /*!< SMP10[2:0] bits (Channel 10 Sample time selection) */
+#define ADC_SMPR1_SMP10_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define ADC_SMPR1_SMP10_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define ADC_SMPR1_SMP10_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+
+#define ADC_SMPR1_SMP11 ((uint32_t)0x00000038) /*!< SMP11[2:0] bits (Channel 11 Sample time selection) */
+#define ADC_SMPR1_SMP11_0 ((uint32_t)0x00000008) /*!< Bit 0 */
+#define ADC_SMPR1_SMP11_1 ((uint32_t)0x00000010) /*!< Bit 1 */
+#define ADC_SMPR1_SMP11_2 ((uint32_t)0x00000020) /*!< Bit 2 */
+
+#define ADC_SMPR1_SMP12 ((uint32_t)0x000001C0) /*!< SMP12[2:0] bits (Channel 12 Sample time selection) */
+#define ADC_SMPR1_SMP12_0 ((uint32_t)0x00000040) /*!< Bit 0 */
+#define ADC_SMPR1_SMP12_1 ((uint32_t)0x00000080) /*!< Bit 1 */
+#define ADC_SMPR1_SMP12_2 ((uint32_t)0x00000100) /*!< Bit 2 */
+
+#define ADC_SMPR1_SMP13 ((uint32_t)0x00000E00) /*!< SMP13[2:0] bits (Channel 13 Sample time selection) */
+#define ADC_SMPR1_SMP13_0 ((uint32_t)0x00000200) /*!< Bit 0 */
+#define ADC_SMPR1_SMP13_1 ((uint32_t)0x00000400) /*!< Bit 1 */
+#define ADC_SMPR1_SMP13_2 ((uint32_t)0x00000800) /*!< Bit 2 */
+
+#define ADC_SMPR1_SMP14 ((uint32_t)0x00007000) /*!< SMP14[2:0] bits (Channel 14 Sample time selection) */
+#define ADC_SMPR1_SMP14_0 ((uint32_t)0x00001000) /*!< Bit 0 */
+#define ADC_SMPR1_SMP14_1 ((uint32_t)0x00002000) /*!< Bit 1 */
+#define ADC_SMPR1_SMP14_2 ((uint32_t)0x00004000) /*!< Bit 2 */
+
+#define ADC_SMPR1_SMP15 ((uint32_t)0x00038000) /*!< SMP15[2:0] bits (Channel 15 Sample time selection) */
+#define ADC_SMPR1_SMP15_0 ((uint32_t)0x00008000) /*!< Bit 0 */
+#define ADC_SMPR1_SMP15_1 ((uint32_t)0x00010000) /*!< Bit 1 */
+#define ADC_SMPR1_SMP15_2 ((uint32_t)0x00020000) /*!< Bit 2 */
+
+#define ADC_SMPR1_SMP16 ((uint32_t)0x001C0000) /*!< SMP16[2:0] bits (Channel 16 Sample time selection) */
+#define ADC_SMPR1_SMP16_0 ((uint32_t)0x00040000) /*!< Bit 0 */
+#define ADC_SMPR1_SMP16_1 ((uint32_t)0x00080000) /*!< Bit 1 */
+#define ADC_SMPR1_SMP16_2 ((uint32_t)0x00100000) /*!< Bit 2 */
+
+#define ADC_SMPR1_SMP17 ((uint32_t)0x00E00000) /*!< SMP17[2:0] bits (Channel 17 Sample time selection) */
+#define ADC_SMPR1_SMP17_0 ((uint32_t)0x00200000) /*!< Bit 0 */
+#define ADC_SMPR1_SMP17_1 ((uint32_t)0x00400000) /*!< Bit 1 */
+#define ADC_SMPR1_SMP17_2 ((uint32_t)0x00800000) /*!< Bit 2 */
+
+/****************** Bit definition for ADC_SMPR2 register *******************/
+#define ADC_SMPR2_SMP0 ((uint32_t)0x00000007) /*!< SMP0[2:0] bits (Channel 0 Sample time selection) */
+#define ADC_SMPR2_SMP0_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define ADC_SMPR2_SMP0_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define ADC_SMPR2_SMP0_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+
+#define ADC_SMPR2_SMP1 ((uint32_t)0x00000038) /*!< SMP1[2:0] bits (Channel 1 Sample time selection) */
+#define ADC_SMPR2_SMP1_0 ((uint32_t)0x00000008) /*!< Bit 0 */
+#define ADC_SMPR2_SMP1_1 ((uint32_t)0x00000010) /*!< Bit 1 */
+#define ADC_SMPR2_SMP1_2 ((uint32_t)0x00000020) /*!< Bit 2 */
+
+#define ADC_SMPR2_SMP2 ((uint32_t)0x000001C0) /*!< SMP2[2:0] bits (Channel 2 Sample time selection) */
+#define ADC_SMPR2_SMP2_0 ((uint32_t)0x00000040) /*!< Bit 0 */
+#define ADC_SMPR2_SMP2_1 ((uint32_t)0x00000080) /*!< Bit 1 */
+#define ADC_SMPR2_SMP2_2 ((uint32_t)0x00000100) /*!< Bit 2 */
+
+#define ADC_SMPR2_SMP3 ((uint32_t)0x00000E00) /*!< SMP3[2:0] bits (Channel 3 Sample time selection) */
+#define ADC_SMPR2_SMP3_0 ((uint32_t)0x00000200) /*!< Bit 0 */
+#define ADC_SMPR2_SMP3_1 ((uint32_t)0x00000400) /*!< Bit 1 */
+#define ADC_SMPR2_SMP3_2 ((uint32_t)0x00000800) /*!< Bit 2 */
+
+#define ADC_SMPR2_SMP4 ((uint32_t)0x00007000) /*!< SMP4[2:0] bits (Channel 4 Sample time selection) */
+#define ADC_SMPR2_SMP4_0 ((uint32_t)0x00001000) /*!< Bit 0 */
+#define ADC_SMPR2_SMP4_1 ((uint32_t)0x00002000) /*!< Bit 1 */
+#define ADC_SMPR2_SMP4_2 ((uint32_t)0x00004000) /*!< Bit 2 */
+
+#define ADC_SMPR2_SMP5 ((uint32_t)0x00038000) /*!< SMP5[2:0] bits (Channel 5 Sample time selection) */
+#define ADC_SMPR2_SMP5_0 ((uint32_t)0x00008000) /*!< Bit 0 */
+#define ADC_SMPR2_SMP5_1 ((uint32_t)0x00010000) /*!< Bit 1 */
+#define ADC_SMPR2_SMP5_2 ((uint32_t)0x00020000) /*!< Bit 2 */
+
+#define ADC_SMPR2_SMP6 ((uint32_t)0x001C0000) /*!< SMP6[2:0] bits (Channel 6 Sample time selection) */
+#define ADC_SMPR2_SMP6_0 ((uint32_t)0x00040000) /*!< Bit 0 */
+#define ADC_SMPR2_SMP6_1 ((uint32_t)0x00080000) /*!< Bit 1 */
+#define ADC_SMPR2_SMP6_2 ((uint32_t)0x00100000) /*!< Bit 2 */
+
+#define ADC_SMPR2_SMP7 ((uint32_t)0x00E00000) /*!< SMP7[2:0] bits (Channel 7 Sample time selection) */
+#define ADC_SMPR2_SMP7_0 ((uint32_t)0x00200000) /*!< Bit 0 */
+#define ADC_SMPR2_SMP7_1 ((uint32_t)0x00400000) /*!< Bit 1 */
+#define ADC_SMPR2_SMP7_2 ((uint32_t)0x00800000) /*!< Bit 2 */
+
+#define ADC_SMPR2_SMP8 ((uint32_t)0x07000000) /*!< SMP8[2:0] bits (Channel 8 Sample time selection) */
+#define ADC_SMPR2_SMP8_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define ADC_SMPR2_SMP8_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define ADC_SMPR2_SMP8_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+
+#define ADC_SMPR2_SMP9 ((uint32_t)0x38000000) /*!< SMP9[2:0] bits (Channel 9 Sample time selection) */
+#define ADC_SMPR2_SMP9_0 ((uint32_t)0x08000000) /*!< Bit 0 */
+#define ADC_SMPR2_SMP9_1 ((uint32_t)0x10000000) /*!< Bit 1 */
+#define ADC_SMPR2_SMP9_2 ((uint32_t)0x20000000) /*!< Bit 2 */
+
+/****************** Bit definition for ADC_JOFR1 register *******************/
+#define ADC_JOFR1_JOFFSET1 ((uint16_t)0x0FFF) /*!< Data offset for injected channel 1 */
+
+/****************** Bit definition for ADC_JOFR2 register *******************/
+#define ADC_JOFR2_JOFFSET2 ((uint16_t)0x0FFF) /*!< Data offset for injected channel 2 */
+
+/****************** Bit definition for ADC_JOFR3 register *******************/
+#define ADC_JOFR3_JOFFSET3 ((uint16_t)0x0FFF) /*!< Data offset for injected channel 3 */
+
+/****************** Bit definition for ADC_JOFR4 register *******************/
+#define ADC_JOFR4_JOFFSET4 ((uint16_t)0x0FFF) /*!< Data offset for injected channel 4 */
+
+/******************* Bit definition for ADC_HTR register ********************/
+#define ADC_HTR_HT ((uint16_t)0x0FFF) /*!< Analog watchdog high threshold */
+
+/******************* Bit definition for ADC_LTR register ********************/
+#define ADC_LTR_LT ((uint16_t)0x0FFF) /*!< Analog watchdog low threshold */
+
+/******************* Bit definition for ADC_SQR1 register *******************/
+#define ADC_SQR1_SQ13 ((uint32_t)0x0000001F) /*!< SQ13[4:0] bits (13th conversion in regular sequence) */
+#define ADC_SQR1_SQ13_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define ADC_SQR1_SQ13_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define ADC_SQR1_SQ13_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define ADC_SQR1_SQ13_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define ADC_SQR1_SQ13_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+
+#define ADC_SQR1_SQ14 ((uint32_t)0x000003E0) /*!< SQ14[4:0] bits (14th conversion in regular sequence) */
+#define ADC_SQR1_SQ14_0 ((uint32_t)0x00000020) /*!< Bit 0 */
+#define ADC_SQR1_SQ14_1 ((uint32_t)0x00000040) /*!< Bit 1 */
+#define ADC_SQR1_SQ14_2 ((uint32_t)0x00000080) /*!< Bit 2 */
+#define ADC_SQR1_SQ14_3 ((uint32_t)0x00000100) /*!< Bit 3 */
+#define ADC_SQR1_SQ14_4 ((uint32_t)0x00000200) /*!< Bit 4 */
+
+#define ADC_SQR1_SQ15 ((uint32_t)0x00007C00) /*!< SQ15[4:0] bits (15th conversion in regular sequence) */
+#define ADC_SQR1_SQ15_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define ADC_SQR1_SQ15_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define ADC_SQR1_SQ15_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define ADC_SQR1_SQ15_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define ADC_SQR1_SQ15_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define ADC_SQR1_SQ16 ((uint32_t)0x000F8000) /*!< SQ16[4:0] bits (16th conversion in regular sequence) */
+#define ADC_SQR1_SQ16_0 ((uint32_t)0x00008000) /*!< Bit 0 */
+#define ADC_SQR1_SQ16_1 ((uint32_t)0x00010000) /*!< Bit 1 */
+#define ADC_SQR1_SQ16_2 ((uint32_t)0x00020000) /*!< Bit 2 */
+#define ADC_SQR1_SQ16_3 ((uint32_t)0x00040000) /*!< Bit 3 */
+#define ADC_SQR1_SQ16_4 ((uint32_t)0x00080000) /*!< Bit 4 */
+
+#define ADC_SQR1_L ((uint32_t)0x00F00000) /*!< L[3:0] bits (Regular channel sequence length) */
+#define ADC_SQR1_L_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define ADC_SQR1_L_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+#define ADC_SQR1_L_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define ADC_SQR1_L_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+
+/******************* Bit definition for ADC_SQR2 register *******************/
+#define ADC_SQR2_SQ7 ((uint32_t)0x0000001F) /*!< SQ7[4:0] bits (7th conversion in regular sequence) */
+#define ADC_SQR2_SQ7_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define ADC_SQR2_SQ7_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define ADC_SQR2_SQ7_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define ADC_SQR2_SQ7_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define ADC_SQR2_SQ7_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+
+#define ADC_SQR2_SQ8 ((uint32_t)0x000003E0) /*!< SQ8[4:0] bits (8th conversion in regular sequence) */
+#define ADC_SQR2_SQ8_0 ((uint32_t)0x00000020) /*!< Bit 0 */
+#define ADC_SQR2_SQ8_1 ((uint32_t)0x00000040) /*!< Bit 1 */
+#define ADC_SQR2_SQ8_2 ((uint32_t)0x00000080) /*!< Bit 2 */
+#define ADC_SQR2_SQ8_3 ((uint32_t)0x00000100) /*!< Bit 3 */
+#define ADC_SQR2_SQ8_4 ((uint32_t)0x00000200) /*!< Bit 4 */
+
+#define ADC_SQR2_SQ9 ((uint32_t)0x00007C00) /*!< SQ9[4:0] bits (9th conversion in regular sequence) */
+#define ADC_SQR2_SQ9_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define ADC_SQR2_SQ9_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define ADC_SQR2_SQ9_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define ADC_SQR2_SQ9_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define ADC_SQR2_SQ9_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define ADC_SQR2_SQ10 ((uint32_t)0x000F8000) /*!< SQ10[4:0] bits (10th conversion in regular sequence) */
+#define ADC_SQR2_SQ10_0 ((uint32_t)0x00008000) /*!< Bit 0 */
+#define ADC_SQR2_SQ10_1 ((uint32_t)0x00010000) /*!< Bit 1 */
+#define ADC_SQR2_SQ10_2 ((uint32_t)0x00020000) /*!< Bit 2 */
+#define ADC_SQR2_SQ10_3 ((uint32_t)0x00040000) /*!< Bit 3 */
+#define ADC_SQR2_SQ10_4 ((uint32_t)0x00080000) /*!< Bit 4 */
+
+#define ADC_SQR2_SQ11 ((uint32_t)0x01F00000) /*!< SQ11[4:0] bits (11th conversion in regular sequence) */
+#define ADC_SQR2_SQ11_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define ADC_SQR2_SQ11_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+#define ADC_SQR2_SQ11_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define ADC_SQR2_SQ11_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+#define ADC_SQR2_SQ11_4 ((uint32_t)0x01000000) /*!< Bit 4 */
+
+#define ADC_SQR2_SQ12 ((uint32_t)0x3E000000) /*!< SQ12[4:0] bits (12th conversion in regular sequence) */
+#define ADC_SQR2_SQ12_0 ((uint32_t)0x02000000) /*!< Bit 0 */
+#define ADC_SQR2_SQ12_1 ((uint32_t)0x04000000) /*!< Bit 1 */
+#define ADC_SQR2_SQ12_2 ((uint32_t)0x08000000) /*!< Bit 2 */
+#define ADC_SQR2_SQ12_3 ((uint32_t)0x10000000) /*!< Bit 3 */
+#define ADC_SQR2_SQ12_4 ((uint32_t)0x20000000) /*!< Bit 4 */
+
+/******************* Bit definition for ADC_SQR3 register *******************/
+#define ADC_SQR3_SQ1 ((uint32_t)0x0000001F) /*!< SQ1[4:0] bits (1st conversion in regular sequence) */
+#define ADC_SQR3_SQ1_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define ADC_SQR3_SQ1_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define ADC_SQR3_SQ1_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define ADC_SQR3_SQ1_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define ADC_SQR3_SQ1_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+
+#define ADC_SQR3_SQ2 ((uint32_t)0x000003E0) /*!< SQ2[4:0] bits (2nd conversion in regular sequence) */
+#define ADC_SQR3_SQ2_0 ((uint32_t)0x00000020) /*!< Bit 0 */
+#define ADC_SQR3_SQ2_1 ((uint32_t)0x00000040) /*!< Bit 1 */
+#define ADC_SQR3_SQ2_2 ((uint32_t)0x00000080) /*!< Bit 2 */
+#define ADC_SQR3_SQ2_3 ((uint32_t)0x00000100) /*!< Bit 3 */
+#define ADC_SQR3_SQ2_4 ((uint32_t)0x00000200) /*!< Bit 4 */
+
+#define ADC_SQR3_SQ3 ((uint32_t)0x00007C00) /*!< SQ3[4:0] bits (3rd conversion in regular sequence) */
+#define ADC_SQR3_SQ3_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define ADC_SQR3_SQ3_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define ADC_SQR3_SQ3_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define ADC_SQR3_SQ3_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define ADC_SQR3_SQ3_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define ADC_SQR3_SQ4 ((uint32_t)0x000F8000) /*!< SQ4[4:0] bits (4th conversion in regular sequence) */
+#define ADC_SQR3_SQ4_0 ((uint32_t)0x00008000) /*!< Bit 0 */
+#define ADC_SQR3_SQ4_1 ((uint32_t)0x00010000) /*!< Bit 1 */
+#define ADC_SQR3_SQ4_2 ((uint32_t)0x00020000) /*!< Bit 2 */
+#define ADC_SQR3_SQ4_3 ((uint32_t)0x00040000) /*!< Bit 3 */
+#define ADC_SQR3_SQ4_4 ((uint32_t)0x00080000) /*!< Bit 4 */
+
+#define ADC_SQR3_SQ5 ((uint32_t)0x01F00000) /*!< SQ5[4:0] bits (5th conversion in regular sequence) */
+#define ADC_SQR3_SQ5_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define ADC_SQR3_SQ5_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+#define ADC_SQR3_SQ5_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define ADC_SQR3_SQ5_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+#define ADC_SQR3_SQ5_4 ((uint32_t)0x01000000) /*!< Bit 4 */
+
+#define ADC_SQR3_SQ6 ((uint32_t)0x3E000000) /*!< SQ6[4:0] bits (6th conversion in regular sequence) */
+#define ADC_SQR3_SQ6_0 ((uint32_t)0x02000000) /*!< Bit 0 */
+#define ADC_SQR3_SQ6_1 ((uint32_t)0x04000000) /*!< Bit 1 */
+#define ADC_SQR3_SQ6_2 ((uint32_t)0x08000000) /*!< Bit 2 */
+#define ADC_SQR3_SQ6_3 ((uint32_t)0x10000000) /*!< Bit 3 */
+#define ADC_SQR3_SQ6_4 ((uint32_t)0x20000000) /*!< Bit 4 */
+
+/******************* Bit definition for ADC_JSQR register *******************/
+#define ADC_JSQR_JSQ1 ((uint32_t)0x0000001F) /*!< JSQ1[4:0] bits (1st conversion in injected sequence) */
+#define ADC_JSQR_JSQ1_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define ADC_JSQR_JSQ1_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define ADC_JSQR_JSQ1_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define ADC_JSQR_JSQ1_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define ADC_JSQR_JSQ1_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+
+#define ADC_JSQR_JSQ2 ((uint32_t)0x000003E0) /*!< JSQ2[4:0] bits (2nd conversion in injected sequence) */
+#define ADC_JSQR_JSQ2_0 ((uint32_t)0x00000020) /*!< Bit 0 */
+#define ADC_JSQR_JSQ2_1 ((uint32_t)0x00000040) /*!< Bit 1 */
+#define ADC_JSQR_JSQ2_2 ((uint32_t)0x00000080) /*!< Bit 2 */
+#define ADC_JSQR_JSQ2_3 ((uint32_t)0x00000100) /*!< Bit 3 */
+#define ADC_JSQR_JSQ2_4 ((uint32_t)0x00000200) /*!< Bit 4 */
+
+#define ADC_JSQR_JSQ3 ((uint32_t)0x00007C00) /*!< JSQ3[4:0] bits (3rd conversion in injected sequence) */
+#define ADC_JSQR_JSQ3_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define ADC_JSQR_JSQ3_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define ADC_JSQR_JSQ3_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define ADC_JSQR_JSQ3_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define ADC_JSQR_JSQ3_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define ADC_JSQR_JSQ4 ((uint32_t)0x000F8000) /*!< JSQ4[4:0] bits (4th conversion in injected sequence) */
+#define ADC_JSQR_JSQ4_0 ((uint32_t)0x00008000) /*!< Bit 0 */
+#define ADC_JSQR_JSQ4_1 ((uint32_t)0x00010000) /*!< Bit 1 */
+#define ADC_JSQR_JSQ4_2 ((uint32_t)0x00020000) /*!< Bit 2 */
+#define ADC_JSQR_JSQ4_3 ((uint32_t)0x00040000) /*!< Bit 3 */
+#define ADC_JSQR_JSQ4_4 ((uint32_t)0x00080000) /*!< Bit 4 */
+
+#define ADC_JSQR_JL ((uint32_t)0x00300000) /*!< JL[1:0] bits (Injected Sequence length) */
+#define ADC_JSQR_JL_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define ADC_JSQR_JL_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+
+/******************* Bit definition for ADC_JDR1 register *******************/
+#define ADC_JDR1_JDATA ((uint16_t)0xFFFF) /*!< Injected data */
+
+/******************* Bit definition for ADC_JDR2 register *******************/
+#define ADC_JDR2_JDATA ((uint16_t)0xFFFF) /*!< Injected data */
+
+/******************* Bit definition for ADC_JDR3 register *******************/
+#define ADC_JDR3_JDATA ((uint16_t)0xFFFF) /*!< Injected data */
+
+/******************* Bit definition for ADC_JDR4 register *******************/
+#define ADC_JDR4_JDATA ((uint16_t)0xFFFF) /*!< Injected data */
+
+/******************** Bit definition for ADC_DR register ********************/
+#define ADC_DR_DATA ((uint32_t)0x0000FFFF) /*!< Regular data */
+#define ADC_DR_ADC2DATA ((uint32_t)0xFFFF0000) /*!< ADC2 data */
+
+/******************************************************************************/
+/* */
+/* Digital to Analog Converter */
+/* */
+/******************************************************************************/
+
+/******************** Bit definition for DAC_CR register ********************/
+#define DAC_CR_EN1 ((uint32_t)0x00000001) /*!< DAC channel1 enable */
+#define DAC_CR_BOFF1 ((uint32_t)0x00000002) /*!< DAC channel1 output buffer disable */
+#define DAC_CR_TEN1 ((uint32_t)0x00000004) /*!< DAC channel1 Trigger enable */
+
+#define DAC_CR_TSEL1 ((uint32_t)0x00000038) /*!< TSEL1[2:0] (DAC channel1 Trigger selection) */
+#define DAC_CR_TSEL1_0 ((uint32_t)0x00000008) /*!< Bit 0 */
+#define DAC_CR_TSEL1_1 ((uint32_t)0x00000010) /*!< Bit 1 */
+#define DAC_CR_TSEL1_2 ((uint32_t)0x00000020) /*!< Bit 2 */
+
+#define DAC_CR_WAVE1 ((uint32_t)0x000000C0) /*!< WAVE1[1:0] (DAC channel1 noise/triangle wave generation enable) */
+#define DAC_CR_WAVE1_0 ((uint32_t)0x00000040) /*!< Bit 0 */
+#define DAC_CR_WAVE1_1 ((uint32_t)0x00000080) /*!< Bit 1 */
+
+#define DAC_CR_MAMP1 ((uint32_t)0x00000F00) /*!< MAMP1[3:0] (DAC channel1 Mask/Amplitude selector) */
+#define DAC_CR_MAMP1_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define DAC_CR_MAMP1_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define DAC_CR_MAMP1_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define DAC_CR_MAMP1_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+
+#define DAC_CR_DMAEN1 ((uint32_t)0x00001000) /*!< DAC channel1 DMA enable */
+#define DAC_CR_EN2 ((uint32_t)0x00010000) /*!< DAC channel2 enable */
+#define DAC_CR_BOFF2 ((uint32_t)0x00020000) /*!< DAC channel2 output buffer disable */
+#define DAC_CR_TEN2 ((uint32_t)0x00040000) /*!< DAC channel2 Trigger enable */
+
+#define DAC_CR_TSEL2 ((uint32_t)0x00380000) /*!< TSEL2[2:0] (DAC channel2 Trigger selection) */
+#define DAC_CR_TSEL2_0 ((uint32_t)0x00080000) /*!< Bit 0 */
+#define DAC_CR_TSEL2_1 ((uint32_t)0x00100000) /*!< Bit 1 */
+#define DAC_CR_TSEL2_2 ((uint32_t)0x00200000) /*!< Bit 2 */
+
+#define DAC_CR_WAVE2 ((uint32_t)0x00C00000) /*!< WAVE2[1:0] (DAC channel2 noise/triangle wave generation enable) */
+#define DAC_CR_WAVE2_0 ((uint32_t)0x00400000) /*!< Bit 0 */
+#define DAC_CR_WAVE2_1 ((uint32_t)0x00800000) /*!< Bit 1 */
+
+#define DAC_CR_MAMP2 ((uint32_t)0x0F000000) /*!< MAMP2[3:0] (DAC channel2 Mask/Amplitude selector) */
+#define DAC_CR_MAMP2_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define DAC_CR_MAMP2_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define DAC_CR_MAMP2_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define DAC_CR_MAMP2_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+
+#define DAC_CR_DMAEN2 ((uint32_t)0x10000000) /*!< DAC channel2 DMA enabled */
+
+/***************** Bit definition for DAC_SWTRIGR register ******************/
+#define DAC_SWTRIGR_SWTRIG1 ((uint8_t)0x01) /*!< DAC channel1 software trigger */
+#define DAC_SWTRIGR_SWTRIG2 ((uint8_t)0x02) /*!< DAC channel2 software trigger */
+
+/***************** Bit definition for DAC_DHR12R1 register ******************/
+#define DAC_DHR12R1_DACC1DHR ((uint16_t)0x0FFF) /*!< DAC channel1 12-bit Right aligned data */
+
+/***************** Bit definition for DAC_DHR12L1 register ******************/
+#define DAC_DHR12L1_DACC1DHR ((uint16_t)0xFFF0) /*!< DAC channel1 12-bit Left aligned data */
+
+/****************** Bit definition for DAC_DHR8R1 register ******************/
+#define DAC_DHR8R1_DACC1DHR ((uint8_t)0xFF) /*!< DAC channel1 8-bit Right aligned data */
+
+/***************** Bit definition for DAC_DHR12R2 register ******************/
+#define DAC_DHR12R2_DACC2DHR ((uint16_t)0x0FFF) /*!< DAC channel2 12-bit Right aligned data */
+
+/***************** Bit definition for DAC_DHR12L2 register ******************/
+#define DAC_DHR12L2_DACC2DHR ((uint16_t)0xFFF0) /*!< DAC channel2 12-bit Left aligned data */
+
+/****************** Bit definition for DAC_DHR8R2 register ******************/
+#define DAC_DHR8R2_DACC2DHR ((uint8_t)0xFF) /*!< DAC channel2 8-bit Right aligned data */
+
+/***************** Bit definition for DAC_DHR12RD register ******************/
+#define DAC_DHR12RD_DACC1DHR ((uint32_t)0x00000FFF) /*!< DAC channel1 12-bit Right aligned data */
+#define DAC_DHR12RD_DACC2DHR ((uint32_t)0x0FFF0000) /*!< DAC channel2 12-bit Right aligned data */
+
+/***************** Bit definition for DAC_DHR12LD register ******************/
+#define DAC_DHR12LD_DACC1DHR ((uint32_t)0x0000FFF0) /*!< DAC channel1 12-bit Left aligned data */
+#define DAC_DHR12LD_DACC2DHR ((uint32_t)0xFFF00000) /*!< DAC channel2 12-bit Left aligned data */
+
+/****************** Bit definition for DAC_DHR8RD register ******************/
+#define DAC_DHR8RD_DACC1DHR ((uint16_t)0x00FF) /*!< DAC channel1 8-bit Right aligned data */
+#define DAC_DHR8RD_DACC2DHR ((uint16_t)0xFF00) /*!< DAC channel2 8-bit Right aligned data */
+
+/******************* Bit definition for DAC_DOR1 register *******************/
+#define DAC_DOR1_DACC1DOR ((uint16_t)0x0FFF) /*!< DAC channel1 data output */
+
+/******************* Bit definition for DAC_DOR2 register *******************/
+#define DAC_DOR2_DACC2DOR ((uint16_t)0x0FFF) /*!< DAC channel2 data output */
+
+/******************** Bit definition for DAC_SR register ********************/
+#define DAC_SR_DMAUDR1 ((uint32_t)0x00002000) /*!< DAC channel1 DMA underrun flag */
+#define DAC_SR_DMAUDR2 ((uint32_t)0x20000000) /*!< DAC channel2 DMA underrun flag */
+
+/******************************************************************************/
+/* */
+/* CEC */
+/* */
+/******************************************************************************/
+/******************** Bit definition for CEC_CFGR register ******************/
+#define CEC_CFGR_PE ((uint16_t)0x0001) /*!< Peripheral Enable */
+#define CEC_CFGR_IE ((uint16_t)0x0002) /*!< Interrupt Enable */
+#define CEC_CFGR_BTEM ((uint16_t)0x0004) /*!< Bit Timing Error Mode */
+#define CEC_CFGR_BPEM ((uint16_t)0x0008) /*!< Bit Period Error Mode */
+
+/******************** Bit definition for CEC_OAR register ******************/
+#define CEC_OAR_OA ((uint16_t)0x000F) /*!< OA[3:0]: Own Address */
+#define CEC_OAR_OA_0 ((uint16_t)0x0001) /*!< Bit 0 */
+#define CEC_OAR_OA_1 ((uint16_t)0x0002) /*!< Bit 1 */
+#define CEC_OAR_OA_2 ((uint16_t)0x0004) /*!< Bit 2 */
+#define CEC_OAR_OA_3 ((uint16_t)0x0008) /*!< Bit 3 */
+
+/******************** Bit definition for CEC_PRES register ******************/
+#define CEC_PRES_PRES ((uint16_t)0x3FFF) /*!< Prescaler Counter Value */
+
+/******************** Bit definition for CEC_ESR register ******************/
+#define CEC_ESR_BTE ((uint16_t)0x0001) /*!< Bit Timing Error */
+#define CEC_ESR_BPE ((uint16_t)0x0002) /*!< Bit Period Error */
+#define CEC_ESR_RBTFE ((uint16_t)0x0004) /*!< Rx Block Transfer Finished Error */
+#define CEC_ESR_SBE ((uint16_t)0x0008) /*!< Start Bit Error */
+#define CEC_ESR_ACKE ((uint16_t)0x0010) /*!< Block Acknowledge Error */
+#define CEC_ESR_LINE ((uint16_t)0x0020) /*!< Line Error */
+#define CEC_ESR_TBTFE ((uint16_t)0x0040) /*!< Tx Block Transfer Finished Error */
+
+/******************** Bit definition for CEC_CSR register ******************/
+#define CEC_CSR_TSOM ((uint16_t)0x0001) /*!< Tx Start Of Message */
+#define CEC_CSR_TEOM ((uint16_t)0x0002) /*!< Tx End Of Message */
+#define CEC_CSR_TERR ((uint16_t)0x0004) /*!< Tx Error */
+#define CEC_CSR_TBTRF ((uint16_t)0x0008) /*!< Tx Byte Transfer Request or Block Transfer Finished */
+#define CEC_CSR_RSOM ((uint16_t)0x0010) /*!< Rx Start Of Message */
+#define CEC_CSR_REOM ((uint16_t)0x0020) /*!< Rx End Of Message */
+#define CEC_CSR_RERR ((uint16_t)0x0040) /*!< Rx Error */
+#define CEC_CSR_RBTF ((uint16_t)0x0080) /*!< Rx Block Transfer Finished */
+
+/******************** Bit definition for CEC_TXD register ******************/
+#define CEC_TXD_TXD ((uint16_t)0x00FF) /*!< Tx Data register */
+
+/******************** Bit definition for CEC_RXD register ******************/
+#define CEC_RXD_RXD ((uint16_t)0x00FF) /*!< Rx Data register */
+
+/******************************************************************************/
+/* */
+/* TIM */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for TIM_CR1 register ********************/
+#define TIM_CR1_CEN ((uint16_t)0x0001) /*!< Counter enable */
+#define TIM_CR1_UDIS ((uint16_t)0x0002) /*!< Update disable */
+#define TIM_CR1_URS ((uint16_t)0x0004) /*!< Update request source */
+#define TIM_CR1_OPM ((uint16_t)0x0008) /*!< One pulse mode */
+#define TIM_CR1_DIR ((uint16_t)0x0010) /*!< Direction */
+
+#define TIM_CR1_CMS ((uint16_t)0x0060) /*!< CMS[1:0] bits (Center-aligned mode selection) */
+#define TIM_CR1_CMS_0 ((uint16_t)0x0020) /*!< Bit 0 */
+#define TIM_CR1_CMS_1 ((uint16_t)0x0040) /*!< Bit 1 */
+
+#define TIM_CR1_ARPE ((uint16_t)0x0080) /*!< Auto-reload preload enable */
+
+#define TIM_CR1_CKD ((uint16_t)0x0300) /*!< CKD[1:0] bits (clock division) */
+#define TIM_CR1_CKD_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define TIM_CR1_CKD_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+/******************* Bit definition for TIM_CR2 register ********************/
+#define TIM_CR2_CCPC ((uint16_t)0x0001) /*!< Capture/Compare Preloaded Control */
+#define TIM_CR2_CCUS ((uint16_t)0x0004) /*!< Capture/Compare Control Update Selection */
+#define TIM_CR2_CCDS ((uint16_t)0x0008) /*!< Capture/Compare DMA Selection */
+
+#define TIM_CR2_MMS ((uint16_t)0x0070) /*!< MMS[2:0] bits (Master Mode Selection) */
+#define TIM_CR2_MMS_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define TIM_CR2_MMS_1 ((uint16_t)0x0020) /*!< Bit 1 */
+#define TIM_CR2_MMS_2 ((uint16_t)0x0040) /*!< Bit 2 */
+
+#define TIM_CR2_TI1S ((uint16_t)0x0080) /*!< TI1 Selection */
+#define TIM_CR2_OIS1 ((uint16_t)0x0100) /*!< Output Idle state 1 (OC1 output) */
+#define TIM_CR2_OIS1N ((uint16_t)0x0200) /*!< Output Idle state 1 (OC1N output) */
+#define TIM_CR2_OIS2 ((uint16_t)0x0400) /*!< Output Idle state 2 (OC2 output) */
+#define TIM_CR2_OIS2N ((uint16_t)0x0800) /*!< Output Idle state 2 (OC2N output) */
+#define TIM_CR2_OIS3 ((uint16_t)0x1000) /*!< Output Idle state 3 (OC3 output) */
+#define TIM_CR2_OIS3N ((uint16_t)0x2000) /*!< Output Idle state 3 (OC3N output) */
+#define TIM_CR2_OIS4 ((uint16_t)0x4000) /*!< Output Idle state 4 (OC4 output) */
+
+/******************* Bit definition for TIM_SMCR register *******************/
+#define TIM_SMCR_SMS ((uint16_t)0x0007) /*!< SMS[2:0] bits (Slave mode selection) */
+#define TIM_SMCR_SMS_0 ((uint16_t)0x0001) /*!< Bit 0 */
+#define TIM_SMCR_SMS_1 ((uint16_t)0x0002) /*!< Bit 1 */
+#define TIM_SMCR_SMS_2 ((uint16_t)0x0004) /*!< Bit 2 */
+
+#define TIM_SMCR_TS ((uint16_t)0x0070) /*!< TS[2:0] bits (Trigger selection) */
+#define TIM_SMCR_TS_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define TIM_SMCR_TS_1 ((uint16_t)0x0020) /*!< Bit 1 */
+#define TIM_SMCR_TS_2 ((uint16_t)0x0040) /*!< Bit 2 */
+
+#define TIM_SMCR_MSM ((uint16_t)0x0080) /*!< Master/slave mode */
+
+#define TIM_SMCR_ETF ((uint16_t)0x0F00) /*!< ETF[3:0] bits (External trigger filter) */
+#define TIM_SMCR_ETF_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define TIM_SMCR_ETF_1 ((uint16_t)0x0200) /*!< Bit 1 */
+#define TIM_SMCR_ETF_2 ((uint16_t)0x0400) /*!< Bit 2 */
+#define TIM_SMCR_ETF_3 ((uint16_t)0x0800) /*!< Bit 3 */
+
+#define TIM_SMCR_ETPS ((uint16_t)0x3000) /*!< ETPS[1:0] bits (External trigger prescaler) */
+#define TIM_SMCR_ETPS_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define TIM_SMCR_ETPS_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define TIM_SMCR_ECE ((uint16_t)0x4000) /*!< External clock enable */
+#define TIM_SMCR_ETP ((uint16_t)0x8000) /*!< External trigger polarity */
+
+/******************* Bit definition for TIM_DIER register *******************/
+#define TIM_DIER_UIE ((uint16_t)0x0001) /*!< Update interrupt enable */
+#define TIM_DIER_CC1IE ((uint16_t)0x0002) /*!< Capture/Compare 1 interrupt enable */
+#define TIM_DIER_CC2IE ((uint16_t)0x0004) /*!< Capture/Compare 2 interrupt enable */
+#define TIM_DIER_CC3IE ((uint16_t)0x0008) /*!< Capture/Compare 3 interrupt enable */
+#define TIM_DIER_CC4IE ((uint16_t)0x0010) /*!< Capture/Compare 4 interrupt enable */
+#define TIM_DIER_COMIE ((uint16_t)0x0020) /*!< COM interrupt enable */
+#define TIM_DIER_TIE ((uint16_t)0x0040) /*!< Trigger interrupt enable */
+#define TIM_DIER_BIE ((uint16_t)0x0080) /*!< Break interrupt enable */
+#define TIM_DIER_UDE ((uint16_t)0x0100) /*!< Update DMA request enable */
+#define TIM_DIER_CC1DE ((uint16_t)0x0200) /*!< Capture/Compare 1 DMA request enable */
+#define TIM_DIER_CC2DE ((uint16_t)0x0400) /*!< Capture/Compare 2 DMA request enable */
+#define TIM_DIER_CC3DE ((uint16_t)0x0800) /*!< Capture/Compare 3 DMA request enable */
+#define TIM_DIER_CC4DE ((uint16_t)0x1000) /*!< Capture/Compare 4 DMA request enable */
+#define TIM_DIER_COMDE ((uint16_t)0x2000) /*!< COM DMA request enable */
+#define TIM_DIER_TDE ((uint16_t)0x4000) /*!< Trigger DMA request enable */
+
+/******************** Bit definition for TIM_SR register ********************/
+#define TIM_SR_UIF ((uint16_t)0x0001) /*!< Update interrupt Flag */
+#define TIM_SR_CC1IF ((uint16_t)0x0002) /*!< Capture/Compare 1 interrupt Flag */
+#define TIM_SR_CC2IF ((uint16_t)0x0004) /*!< Capture/Compare 2 interrupt Flag */
+#define TIM_SR_CC3IF ((uint16_t)0x0008) /*!< Capture/Compare 3 interrupt Flag */
+#define TIM_SR_CC4IF ((uint16_t)0x0010) /*!< Capture/Compare 4 interrupt Flag */
+#define TIM_SR_COMIF ((uint16_t)0x0020) /*!< COM interrupt Flag */
+#define TIM_SR_TIF ((uint16_t)0x0040) /*!< Trigger interrupt Flag */
+#define TIM_SR_BIF ((uint16_t)0x0080) /*!< Break interrupt Flag */
+#define TIM_SR_CC1OF ((uint16_t)0x0200) /*!< Capture/Compare 1 Overcapture Flag */
+#define TIM_SR_CC2OF ((uint16_t)0x0400) /*!< Capture/Compare 2 Overcapture Flag */
+#define TIM_SR_CC3OF ((uint16_t)0x0800) /*!< Capture/Compare 3 Overcapture Flag */
+#define TIM_SR_CC4OF ((uint16_t)0x1000) /*!< Capture/Compare 4 Overcapture Flag */
+
+/******************* Bit definition for TIM_EGR register ********************/
+#define TIM_EGR_UG ((uint8_t)0x01) /*!< Update Generation */
+#define TIM_EGR_CC1G ((uint8_t)0x02) /*!< Capture/Compare 1 Generation */
+#define TIM_EGR_CC2G ((uint8_t)0x04) /*!< Capture/Compare 2 Generation */
+#define TIM_EGR_CC3G ((uint8_t)0x08) /*!< Capture/Compare 3 Generation */
+#define TIM_EGR_CC4G ((uint8_t)0x10) /*!< Capture/Compare 4 Generation */
+#define TIM_EGR_COMG ((uint8_t)0x20) /*!< Capture/Compare Control Update Generation */
+#define TIM_EGR_TG ((uint8_t)0x40) /*!< Trigger Generation */
+#define TIM_EGR_BG ((uint8_t)0x80) /*!< Break Generation */
+
+/****************** Bit definition for TIM_CCMR1 register *******************/
+#define TIM_CCMR1_CC1S ((uint16_t)0x0003) /*!< CC1S[1:0] bits (Capture/Compare 1 Selection) */
+#define TIM_CCMR1_CC1S_0 ((uint16_t)0x0001) /*!< Bit 0 */
+#define TIM_CCMR1_CC1S_1 ((uint16_t)0x0002) /*!< Bit 1 */
+
+#define TIM_CCMR1_OC1FE ((uint16_t)0x0004) /*!< Output Compare 1 Fast enable */
+#define TIM_CCMR1_OC1PE ((uint16_t)0x0008) /*!< Output Compare 1 Preload enable */
+
+#define TIM_CCMR1_OC1M ((uint16_t)0x0070) /*!< OC1M[2:0] bits (Output Compare 1 Mode) */
+#define TIM_CCMR1_OC1M_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define TIM_CCMR1_OC1M_1 ((uint16_t)0x0020) /*!< Bit 1 */
+#define TIM_CCMR1_OC1M_2 ((uint16_t)0x0040) /*!< Bit 2 */
+
+#define TIM_CCMR1_OC1CE ((uint16_t)0x0080) /*!< Output Compare 1Clear Enable */
+
+#define TIM_CCMR1_CC2S ((uint16_t)0x0300) /*!< CC2S[1:0] bits (Capture/Compare 2 Selection) */
+#define TIM_CCMR1_CC2S_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define TIM_CCMR1_CC2S_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define TIM_CCMR1_OC2FE ((uint16_t)0x0400) /*!< Output Compare 2 Fast enable */
+#define TIM_CCMR1_OC2PE ((uint16_t)0x0800) /*!< Output Compare 2 Preload enable */
+
+#define TIM_CCMR1_OC2M ((uint16_t)0x7000) /*!< OC2M[2:0] bits (Output Compare 2 Mode) */
+#define TIM_CCMR1_OC2M_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define TIM_CCMR1_OC2M_1 ((uint16_t)0x2000) /*!< Bit 1 */
+#define TIM_CCMR1_OC2M_2 ((uint16_t)0x4000) /*!< Bit 2 */
+
+#define TIM_CCMR1_OC2CE ((uint16_t)0x8000) /*!< Output Compare 2 Clear Enable */
+
+/*----------------------------------------------------------------------------*/
+
+#define TIM_CCMR1_IC1PSC ((uint16_t)0x000C) /*!< IC1PSC[1:0] bits (Input Capture 1 Prescaler) */
+#define TIM_CCMR1_IC1PSC_0 ((uint16_t)0x0004) /*!< Bit 0 */
+#define TIM_CCMR1_IC1PSC_1 ((uint16_t)0x0008) /*!< Bit 1 */
+
+#define TIM_CCMR1_IC1F ((uint16_t)0x00F0) /*!< IC1F[3:0] bits (Input Capture 1 Filter) */
+#define TIM_CCMR1_IC1F_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define TIM_CCMR1_IC1F_1 ((uint16_t)0x0020) /*!< Bit 1 */
+#define TIM_CCMR1_IC1F_2 ((uint16_t)0x0040) /*!< Bit 2 */
+#define TIM_CCMR1_IC1F_3 ((uint16_t)0x0080) /*!< Bit 3 */
+
+#define TIM_CCMR1_IC2PSC ((uint16_t)0x0C00) /*!< IC2PSC[1:0] bits (Input Capture 2 Prescaler) */
+#define TIM_CCMR1_IC2PSC_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define TIM_CCMR1_IC2PSC_1 ((uint16_t)0x0800) /*!< Bit 1 */
+
+#define TIM_CCMR1_IC2F ((uint16_t)0xF000) /*!< IC2F[3:0] bits (Input Capture 2 Filter) */
+#define TIM_CCMR1_IC2F_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define TIM_CCMR1_IC2F_1 ((uint16_t)0x2000) /*!< Bit 1 */
+#define TIM_CCMR1_IC2F_2 ((uint16_t)0x4000) /*!< Bit 2 */
+#define TIM_CCMR1_IC2F_3 ((uint16_t)0x8000) /*!< Bit 3 */
+
+/****************** Bit definition for TIM_CCMR2 register *******************/
+#define TIM_CCMR2_CC3S ((uint16_t)0x0003) /*!< CC3S[1:0] bits (Capture/Compare 3 Selection) */
+#define TIM_CCMR2_CC3S_0 ((uint16_t)0x0001) /*!< Bit 0 */
+#define TIM_CCMR2_CC3S_1 ((uint16_t)0x0002) /*!< Bit 1 */
+
+#define TIM_CCMR2_OC3FE ((uint16_t)0x0004) /*!< Output Compare 3 Fast enable */
+#define TIM_CCMR2_OC3PE ((uint16_t)0x0008) /*!< Output Compare 3 Preload enable */
+
+#define TIM_CCMR2_OC3M ((uint16_t)0x0070) /*!< OC3M[2:0] bits (Output Compare 3 Mode) */
+#define TIM_CCMR2_OC3M_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define TIM_CCMR2_OC3M_1 ((uint16_t)0x0020) /*!< Bit 1 */
+#define TIM_CCMR2_OC3M_2 ((uint16_t)0x0040) /*!< Bit 2 */
+
+#define TIM_CCMR2_OC3CE ((uint16_t)0x0080) /*!< Output Compare 3 Clear Enable */
+
+#define TIM_CCMR2_CC4S ((uint16_t)0x0300) /*!< CC4S[1:0] bits (Capture/Compare 4 Selection) */
+#define TIM_CCMR2_CC4S_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define TIM_CCMR2_CC4S_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define TIM_CCMR2_OC4FE ((uint16_t)0x0400) /*!< Output Compare 4 Fast enable */
+#define TIM_CCMR2_OC4PE ((uint16_t)0x0800) /*!< Output Compare 4 Preload enable */
+
+#define TIM_CCMR2_OC4M ((uint16_t)0x7000) /*!< OC4M[2:0] bits (Output Compare 4 Mode) */
+#define TIM_CCMR2_OC4M_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define TIM_CCMR2_OC4M_1 ((uint16_t)0x2000) /*!< Bit 1 */
+#define TIM_CCMR2_OC4M_2 ((uint16_t)0x4000) /*!< Bit 2 */
+
+#define TIM_CCMR2_OC4CE ((uint16_t)0x8000) /*!< Output Compare 4 Clear Enable */
+
+/*----------------------------------------------------------------------------*/
+
+#define TIM_CCMR2_IC3PSC ((uint16_t)0x000C) /*!< IC3PSC[1:0] bits (Input Capture 3 Prescaler) */
+#define TIM_CCMR2_IC3PSC_0 ((uint16_t)0x0004) /*!< Bit 0 */
+#define TIM_CCMR2_IC3PSC_1 ((uint16_t)0x0008) /*!< Bit 1 */
+
+#define TIM_CCMR2_IC3F ((uint16_t)0x00F0) /*!< IC3F[3:0] bits (Input Capture 3 Filter) */
+#define TIM_CCMR2_IC3F_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define TIM_CCMR2_IC3F_1 ((uint16_t)0x0020) /*!< Bit 1 */
+#define TIM_CCMR2_IC3F_2 ((uint16_t)0x0040) /*!< Bit 2 */
+#define TIM_CCMR2_IC3F_3 ((uint16_t)0x0080) /*!< Bit 3 */
+
+#define TIM_CCMR2_IC4PSC ((uint16_t)0x0C00) /*!< IC4PSC[1:0] bits (Input Capture 4 Prescaler) */
+#define TIM_CCMR2_IC4PSC_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define TIM_CCMR2_IC4PSC_1 ((uint16_t)0x0800) /*!< Bit 1 */
+
+#define TIM_CCMR2_IC4F ((uint16_t)0xF000) /*!< IC4F[3:0] bits (Input Capture 4 Filter) */
+#define TIM_CCMR2_IC4F_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define TIM_CCMR2_IC4F_1 ((uint16_t)0x2000) /*!< Bit 1 */
+#define TIM_CCMR2_IC4F_2 ((uint16_t)0x4000) /*!< Bit 2 */
+#define TIM_CCMR2_IC4F_3 ((uint16_t)0x8000) /*!< Bit 3 */
+
+/******************* Bit definition for TIM_CCER register *******************/
+#define TIM_CCER_CC1E ((uint16_t)0x0001) /*!< Capture/Compare 1 output enable */
+#define TIM_CCER_CC1P ((uint16_t)0x0002) /*!< Capture/Compare 1 output Polarity */
+#define TIM_CCER_CC1NE ((uint16_t)0x0004) /*!< Capture/Compare 1 Complementary output enable */
+#define TIM_CCER_CC1NP ((uint16_t)0x0008) /*!< Capture/Compare 1 Complementary output Polarity */
+#define TIM_CCER_CC2E ((uint16_t)0x0010) /*!< Capture/Compare 2 output enable */
+#define TIM_CCER_CC2P ((uint16_t)0x0020) /*!< Capture/Compare 2 output Polarity */
+#define TIM_CCER_CC2NE ((uint16_t)0x0040) /*!< Capture/Compare 2 Complementary output enable */
+#define TIM_CCER_CC2NP ((uint16_t)0x0080) /*!< Capture/Compare 2 Complementary output Polarity */
+#define TIM_CCER_CC3E ((uint16_t)0x0100) /*!< Capture/Compare 3 output enable */
+#define TIM_CCER_CC3P ((uint16_t)0x0200) /*!< Capture/Compare 3 output Polarity */
+#define TIM_CCER_CC3NE ((uint16_t)0x0400) /*!< Capture/Compare 3 Complementary output enable */
+#define TIM_CCER_CC3NP ((uint16_t)0x0800) /*!< Capture/Compare 3 Complementary output Polarity */
+#define TIM_CCER_CC4E ((uint16_t)0x1000) /*!< Capture/Compare 4 output enable */
+#define TIM_CCER_CC4P ((uint16_t)0x2000) /*!< Capture/Compare 4 output Polarity */
+#define TIM_CCER_CC4NP ((uint16_t)0x8000) /*!< Capture/Compare 4 Complementary output Polarity */
+
+/******************* Bit definition for TIM_CNT register ********************/
+#define TIM_CNT_CNT ((uint16_t)0xFFFF) /*!< Counter Value */
+
+/******************* Bit definition for TIM_PSC register ********************/
+#define TIM_PSC_PSC ((uint16_t)0xFFFF) /*!< Prescaler Value */
+
+/******************* Bit definition for TIM_ARR register ********************/
+#define TIM_ARR_ARR ((uint16_t)0xFFFF) /*!< actual auto-reload Value */
+
+/******************* Bit definition for TIM_RCR register ********************/
+#define TIM_RCR_REP ((uint8_t)0xFF) /*!< Repetition Counter Value */
+
+/******************* Bit definition for TIM_CCR1 register *******************/
+#define TIM_CCR1_CCR1 ((uint16_t)0xFFFF) /*!< Capture/Compare 1 Value */
+
+/******************* Bit definition for TIM_CCR2 register *******************/
+#define TIM_CCR2_CCR2 ((uint16_t)0xFFFF) /*!< Capture/Compare 2 Value */
+
+/******************* Bit definition for TIM_CCR3 register *******************/
+#define TIM_CCR3_CCR3 ((uint16_t)0xFFFF) /*!< Capture/Compare 3 Value */
+
+/******************* Bit definition for TIM_CCR4 register *******************/
+#define TIM_CCR4_CCR4 ((uint16_t)0xFFFF) /*!< Capture/Compare 4 Value */
+
+/******************* Bit definition for TIM_BDTR register *******************/
+#define TIM_BDTR_DTG ((uint16_t)0x00FF) /*!< DTG[0:7] bits (Dead-Time Generator set-up) */
+#define TIM_BDTR_DTG_0 ((uint16_t)0x0001) /*!< Bit 0 */
+#define TIM_BDTR_DTG_1 ((uint16_t)0x0002) /*!< Bit 1 */
+#define TIM_BDTR_DTG_2 ((uint16_t)0x0004) /*!< Bit 2 */
+#define TIM_BDTR_DTG_3 ((uint16_t)0x0008) /*!< Bit 3 */
+#define TIM_BDTR_DTG_4 ((uint16_t)0x0010) /*!< Bit 4 */
+#define TIM_BDTR_DTG_5 ((uint16_t)0x0020) /*!< Bit 5 */
+#define TIM_BDTR_DTG_6 ((uint16_t)0x0040) /*!< Bit 6 */
+#define TIM_BDTR_DTG_7 ((uint16_t)0x0080) /*!< Bit 7 */
+
+#define TIM_BDTR_LOCK ((uint16_t)0x0300) /*!< LOCK[1:0] bits (Lock Configuration) */
+#define TIM_BDTR_LOCK_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define TIM_BDTR_LOCK_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define TIM_BDTR_OSSI ((uint16_t)0x0400) /*!< Off-State Selection for Idle mode */
+#define TIM_BDTR_OSSR ((uint16_t)0x0800) /*!< Off-State Selection for Run mode */
+#define TIM_BDTR_BKE ((uint16_t)0x1000) /*!< Break enable */
+#define TIM_BDTR_BKP ((uint16_t)0x2000) /*!< Break Polarity */
+#define TIM_BDTR_AOE ((uint16_t)0x4000) /*!< Automatic Output enable */
+#define TIM_BDTR_MOE ((uint16_t)0x8000) /*!< Main Output enable */
+
+/******************* Bit definition for TIM_DCR register ********************/
+#define TIM_DCR_DBA ((uint16_t)0x001F) /*!< DBA[4:0] bits (DMA Base Address) */
+#define TIM_DCR_DBA_0 ((uint16_t)0x0001) /*!< Bit 0 */
+#define TIM_DCR_DBA_1 ((uint16_t)0x0002) /*!< Bit 1 */
+#define TIM_DCR_DBA_2 ((uint16_t)0x0004) /*!< Bit 2 */
+#define TIM_DCR_DBA_3 ((uint16_t)0x0008) /*!< Bit 3 */
+#define TIM_DCR_DBA_4 ((uint16_t)0x0010) /*!< Bit 4 */
+
+#define TIM_DCR_DBL ((uint16_t)0x1F00) /*!< DBL[4:0] bits (DMA Burst Length) */
+#define TIM_DCR_DBL_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define TIM_DCR_DBL_1 ((uint16_t)0x0200) /*!< Bit 1 */
+#define TIM_DCR_DBL_2 ((uint16_t)0x0400) /*!< Bit 2 */
+#define TIM_DCR_DBL_3 ((uint16_t)0x0800) /*!< Bit 3 */
+#define TIM_DCR_DBL_4 ((uint16_t)0x1000) /*!< Bit 4 */
+
+/******************* Bit definition for TIM_DMAR register *******************/
+#define TIM_DMAR_DMAB ((uint16_t)0xFFFF) /*!< DMA register for burst accesses */
+
+/******************************************************************************/
+/* */
+/* Real-Time Clock */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for RTC_CRH register ********************/
+#define RTC_CRH_SECIE ((uint8_t)0x01) /*!< Second Interrupt Enable */
+#define RTC_CRH_ALRIE ((uint8_t)0x02) /*!< Alarm Interrupt Enable */
+#define RTC_CRH_OWIE ((uint8_t)0x04) /*!< OverfloW Interrupt Enable */
+
+/******************* Bit definition for RTC_CRL register ********************/
+#define RTC_CRL_SECF ((uint8_t)0x01) /*!< Second Flag */
+#define RTC_CRL_ALRF ((uint8_t)0x02) /*!< Alarm Flag */
+#define RTC_CRL_OWF ((uint8_t)0x04) /*!< OverfloW Flag */
+#define RTC_CRL_RSF ((uint8_t)0x08) /*!< Registers Synchronized Flag */
+#define RTC_CRL_CNF ((uint8_t)0x10) /*!< Configuration Flag */
+#define RTC_CRL_RTOFF ((uint8_t)0x20) /*!< RTC operation OFF */
+
+/******************* Bit definition for RTC_PRLH register *******************/
+#define RTC_PRLH_PRL ((uint16_t)0x000F) /*!< RTC Prescaler Reload Value High */
+
+/******************* Bit definition for RTC_PRLL register *******************/
+#define RTC_PRLL_PRL ((uint16_t)0xFFFF) /*!< RTC Prescaler Reload Value Low */
+
+/******************* Bit definition for RTC_DIVH register *******************/
+#define RTC_DIVH_RTC_DIV ((uint16_t)0x000F) /*!< RTC Clock Divider High */
+
+/******************* Bit definition for RTC_DIVL register *******************/
+#define RTC_DIVL_RTC_DIV ((uint16_t)0xFFFF) /*!< RTC Clock Divider Low */
+
+/******************* Bit definition for RTC_CNTH register *******************/
+#define RTC_CNTH_RTC_CNT ((uint16_t)0xFFFF) /*!< RTC Counter High */
+
+/******************* Bit definition for RTC_CNTL register *******************/
+#define RTC_CNTL_RTC_CNT ((uint16_t)0xFFFF) /*!< RTC Counter Low */
+
+/******************* Bit definition for RTC_ALRH register *******************/
+#define RTC_ALRH_RTC_ALR ((uint16_t)0xFFFF) /*!< RTC Alarm High */
+
+/******************* Bit definition for RTC_ALRL register *******************/
+#define RTC_ALRL_RTC_ALR ((uint16_t)0xFFFF) /*!< RTC Alarm Low */
+
+/******************************************************************************/
+/* */
+/* Independent WATCHDOG */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for IWDG_KR register ********************/
+#define IWDG_KR_KEY ((uint16_t)0xFFFF) /*!< Key value (write only, read 0000h) */
+
+/******************* Bit definition for IWDG_PR register ********************/
+#define IWDG_PR_PR ((uint8_t)0x07) /*!< PR[2:0] (Prescaler divider) */
+#define IWDG_PR_PR_0 ((uint8_t)0x01) /*!< Bit 0 */
+#define IWDG_PR_PR_1 ((uint8_t)0x02) /*!< Bit 1 */
+#define IWDG_PR_PR_2 ((uint8_t)0x04) /*!< Bit 2 */
+
+/******************* Bit definition for IWDG_RLR register *******************/
+#define IWDG_RLR_RL ((uint16_t)0x0FFF) /*!< Watchdog counter reload value */
+
+/******************* Bit definition for IWDG_SR register ********************/
+#define IWDG_SR_PVU ((uint8_t)0x01) /*!< Watchdog prescaler value update */
+#define IWDG_SR_RVU ((uint8_t)0x02) /*!< Watchdog counter reload value update */
+
+/******************************************************************************/
+/* */
+/* Window WATCHDOG */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for WWDG_CR register ********************/
+#define WWDG_CR_T ((uint8_t)0x7F) /*!< T[6:0] bits (7-Bit counter (MSB to LSB)) */
+#define WWDG_CR_T0 ((uint8_t)0x01) /*!< Bit 0 */
+#define WWDG_CR_T1 ((uint8_t)0x02) /*!< Bit 1 */
+#define WWDG_CR_T2 ((uint8_t)0x04) /*!< Bit 2 */
+#define WWDG_CR_T3 ((uint8_t)0x08) /*!< Bit 3 */
+#define WWDG_CR_T4 ((uint8_t)0x10) /*!< Bit 4 */
+#define WWDG_CR_T5 ((uint8_t)0x20) /*!< Bit 5 */
+#define WWDG_CR_T6 ((uint8_t)0x40) /*!< Bit 6 */
+
+#define WWDG_CR_WDGA ((uint8_t)0x80) /*!< Activation bit */
+
+/******************* Bit definition for WWDG_CFR register *******************/
+#define WWDG_CFR_W ((uint16_t)0x007F) /*!< W[6:0] bits (7-bit window value) */
+#define WWDG_CFR_W0 ((uint16_t)0x0001) /*!< Bit 0 */
+#define WWDG_CFR_W1 ((uint16_t)0x0002) /*!< Bit 1 */
+#define WWDG_CFR_W2 ((uint16_t)0x0004) /*!< Bit 2 */
+#define WWDG_CFR_W3 ((uint16_t)0x0008) /*!< Bit 3 */
+#define WWDG_CFR_W4 ((uint16_t)0x0010) /*!< Bit 4 */
+#define WWDG_CFR_W5 ((uint16_t)0x0020) /*!< Bit 5 */
+#define WWDG_CFR_W6 ((uint16_t)0x0040) /*!< Bit 6 */
+
+#define WWDG_CFR_WDGTB ((uint16_t)0x0180) /*!< WDGTB[1:0] bits (Timer Base) */
+#define WWDG_CFR_WDGTB0 ((uint16_t)0x0080) /*!< Bit 0 */
+#define WWDG_CFR_WDGTB1 ((uint16_t)0x0100) /*!< Bit 1 */
+
+#define WWDG_CFR_EWI ((uint16_t)0x0200) /*!< Early Wakeup Interrupt */
+
+/******************* Bit definition for WWDG_SR register ********************/
+#define WWDG_SR_EWIF ((uint8_t)0x01) /*!< Early Wakeup Interrupt Flag */
+
+/******************************************************************************/
+/* */
+/* Flexible Static Memory Controller */
+/* */
+/******************************************************************************/
+
+/****************** Bit definition for FSMC_BCR1 register *******************/
+#define FSMC_BCR1_MBKEN ((uint32_t)0x00000001) /*!< Memory bank enable bit */
+#define FSMC_BCR1_MUXEN ((uint32_t)0x00000002) /*!< Address/data multiplexing enable bit */
+
+#define FSMC_BCR1_MTYP ((uint32_t)0x0000000C) /*!< MTYP[1:0] bits (Memory type) */
+#define FSMC_BCR1_MTYP_0 ((uint32_t)0x00000004) /*!< Bit 0 */
+#define FSMC_BCR1_MTYP_1 ((uint32_t)0x00000008) /*!< Bit 1 */
+
+#define FSMC_BCR1_MWID ((uint32_t)0x00000030) /*!< MWID[1:0] bits (Memory data bus width) */
+#define FSMC_BCR1_MWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BCR1_MWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+
+#define FSMC_BCR1_FACCEN ((uint32_t)0x00000040) /*!< Flash access enable */
+#define FSMC_BCR1_BURSTEN ((uint32_t)0x00000100) /*!< Burst enable bit */
+#define FSMC_BCR1_WAITPOL ((uint32_t)0x00000200) /*!< Wait signal polarity bit */
+#define FSMC_BCR1_WRAPMOD ((uint32_t)0x00000400) /*!< Wrapped burst mode support */
+#define FSMC_BCR1_WAITCFG ((uint32_t)0x00000800) /*!< Wait timing configuration */
+#define FSMC_BCR1_WREN ((uint32_t)0x00001000) /*!< Write enable bit */
+#define FSMC_BCR1_WAITEN ((uint32_t)0x00002000) /*!< Wait enable bit */
+#define FSMC_BCR1_EXTMOD ((uint32_t)0x00004000) /*!< Extended mode enable */
+#define FSMC_BCR1_ASYNCWAIT ((uint32_t)0x00008000) /*!< Asynchronous wait */
+#define FSMC_BCR1_CBURSTRW ((uint32_t)0x00080000) /*!< Write burst enable */
+
+/****************** Bit definition for FSMC_BCR2 register *******************/
+#define FSMC_BCR2_MBKEN ((uint32_t)0x00000001) /*!< Memory bank enable bit */
+#define FSMC_BCR2_MUXEN ((uint32_t)0x00000002) /*!< Address/data multiplexing enable bit */
+
+#define FSMC_BCR2_MTYP ((uint32_t)0x0000000C) /*!< MTYP[1:0] bits (Memory type) */
+#define FSMC_BCR2_MTYP_0 ((uint32_t)0x00000004) /*!< Bit 0 */
+#define FSMC_BCR2_MTYP_1 ((uint32_t)0x00000008) /*!< Bit 1 */
+
+#define FSMC_BCR2_MWID ((uint32_t)0x00000030) /*!< MWID[1:0] bits (Memory data bus width) */
+#define FSMC_BCR2_MWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BCR2_MWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+
+#define FSMC_BCR2_FACCEN ((uint32_t)0x00000040) /*!< Flash access enable */
+#define FSMC_BCR2_BURSTEN ((uint32_t)0x00000100) /*!< Burst enable bit */
+#define FSMC_BCR2_WAITPOL ((uint32_t)0x00000200) /*!< Wait signal polarity bit */
+#define FSMC_BCR2_WRAPMOD ((uint32_t)0x00000400) /*!< Wrapped burst mode support */
+#define FSMC_BCR2_WAITCFG ((uint32_t)0x00000800) /*!< Wait timing configuration */
+#define FSMC_BCR2_WREN ((uint32_t)0x00001000) /*!< Write enable bit */
+#define FSMC_BCR2_WAITEN ((uint32_t)0x00002000) /*!< Wait enable bit */
+#define FSMC_BCR2_EXTMOD ((uint32_t)0x00004000) /*!< Extended mode enable */
+#define FSMC_BCR2_ASYNCWAIT ((uint32_t)0x00008000) /*!< Asynchronous wait */
+#define FSMC_BCR2_CBURSTRW ((uint32_t)0x00080000) /*!< Write burst enable */
+
+/****************** Bit definition for FSMC_BCR3 register *******************/
+#define FSMC_BCR3_MBKEN ((uint32_t)0x00000001) /*!< Memory bank enable bit */
+#define FSMC_BCR3_MUXEN ((uint32_t)0x00000002) /*!< Address/data multiplexing enable bit */
+
+#define FSMC_BCR3_MTYP ((uint32_t)0x0000000C) /*!< MTYP[1:0] bits (Memory type) */
+#define FSMC_BCR3_MTYP_0 ((uint32_t)0x00000004) /*!< Bit 0 */
+#define FSMC_BCR3_MTYP_1 ((uint32_t)0x00000008) /*!< Bit 1 */
+
+#define FSMC_BCR3_MWID ((uint32_t)0x00000030) /*!< MWID[1:0] bits (Memory data bus width) */
+#define FSMC_BCR3_MWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BCR3_MWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+
+#define FSMC_BCR3_FACCEN ((uint32_t)0x00000040) /*!< Flash access enable */
+#define FSMC_BCR3_BURSTEN ((uint32_t)0x00000100) /*!< Burst enable bit */
+#define FSMC_BCR3_WAITPOL ((uint32_t)0x00000200) /*!< Wait signal polarity bit. */
+#define FSMC_BCR3_WRAPMOD ((uint32_t)0x00000400) /*!< Wrapped burst mode support */
+#define FSMC_BCR3_WAITCFG ((uint32_t)0x00000800) /*!< Wait timing configuration */
+#define FSMC_BCR3_WREN ((uint32_t)0x00001000) /*!< Write enable bit */
+#define FSMC_BCR3_WAITEN ((uint32_t)0x00002000) /*!< Wait enable bit */
+#define FSMC_BCR3_EXTMOD ((uint32_t)0x00004000) /*!< Extended mode enable */
+#define FSMC_BCR3_ASYNCWAIT ((uint32_t)0x00008000) /*!< Asynchronous wait */
+#define FSMC_BCR3_CBURSTRW ((uint32_t)0x00080000) /*!< Write burst enable */
+
+/****************** Bit definition for FSMC_BCR4 register *******************/
+#define FSMC_BCR4_MBKEN ((uint32_t)0x00000001) /*!< Memory bank enable bit */
+#define FSMC_BCR4_MUXEN ((uint32_t)0x00000002) /*!< Address/data multiplexing enable bit */
+
+#define FSMC_BCR4_MTYP ((uint32_t)0x0000000C) /*!< MTYP[1:0] bits (Memory type) */
+#define FSMC_BCR4_MTYP_0 ((uint32_t)0x00000004) /*!< Bit 0 */
+#define FSMC_BCR4_MTYP_1 ((uint32_t)0x00000008) /*!< Bit 1 */
+
+#define FSMC_BCR4_MWID ((uint32_t)0x00000030) /*!< MWID[1:0] bits (Memory data bus width) */
+#define FSMC_BCR4_MWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BCR4_MWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+
+#define FSMC_BCR4_FACCEN ((uint32_t)0x00000040) /*!< Flash access enable */
+#define FSMC_BCR4_BURSTEN ((uint32_t)0x00000100) /*!< Burst enable bit */
+#define FSMC_BCR4_WAITPOL ((uint32_t)0x00000200) /*!< Wait signal polarity bit */
+#define FSMC_BCR4_WRAPMOD ((uint32_t)0x00000400) /*!< Wrapped burst mode support */
+#define FSMC_BCR4_WAITCFG ((uint32_t)0x00000800) /*!< Wait timing configuration */
+#define FSMC_BCR4_WREN ((uint32_t)0x00001000) /*!< Write enable bit */
+#define FSMC_BCR4_WAITEN ((uint32_t)0x00002000) /*!< Wait enable bit */
+#define FSMC_BCR4_EXTMOD ((uint32_t)0x00004000) /*!< Extended mode enable */
+#define FSMC_BCR4_ASYNCWAIT ((uint32_t)0x00008000) /*!< Asynchronous wait */
+#define FSMC_BCR4_CBURSTRW ((uint32_t)0x00080000) /*!< Write burst enable */
+
+/****************** Bit definition for FSMC_BTR1 register ******************/
+#define FSMC_BTR1_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */
+#define FSMC_BTR1_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_BTR1_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_BTR1_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_BTR1_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+
+#define FSMC_BTR1_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
+#define FSMC_BTR1_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BTR1_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+#define FSMC_BTR1_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+#define FSMC_BTR1_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */
+
+#define FSMC_BTR1_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */
+#define FSMC_BTR1_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_BTR1_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_BTR1_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_BTR1_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+
+#define FSMC_BTR1_BUSTURN ((uint32_t)0x000F0000) /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */
+#define FSMC_BTR1_BUSTURN_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_BTR1_BUSTURN_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_BTR1_BUSTURN_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_BTR1_BUSTURN_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+
+#define FSMC_BTR1_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */
+#define FSMC_BTR1_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define FSMC_BTR1_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+#define FSMC_BTR1_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define FSMC_BTR1_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+
+#define FSMC_BTR1_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */
+#define FSMC_BTR1_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_BTR1_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_BTR1_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_BTR1_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+
+#define FSMC_BTR1_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */
+#define FSMC_BTR1_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */
+#define FSMC_BTR1_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */
+
+/****************** Bit definition for FSMC_BTR2 register *******************/
+#define FSMC_BTR2_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */
+#define FSMC_BTR2_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_BTR2_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_BTR2_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_BTR2_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+
+#define FSMC_BTR2_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
+#define FSMC_BTR2_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BTR2_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+#define FSMC_BTR2_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+#define FSMC_BTR2_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */
+
+#define FSMC_BTR2_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */
+#define FSMC_BTR2_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_BTR2_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_BTR2_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_BTR2_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+
+#define FSMC_BTR2_BUSTURN ((uint32_t)0x000F0000) /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */
+#define FSMC_BTR2_BUSTURN_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_BTR2_BUSTURN_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_BTR2_BUSTURN_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_BTR2_BUSTURN_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+
+#define FSMC_BTR2_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */
+#define FSMC_BTR2_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define FSMC_BTR2_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+#define FSMC_BTR2_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define FSMC_BTR2_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+
+#define FSMC_BTR2_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */
+#define FSMC_BTR2_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_BTR2_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_BTR2_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_BTR2_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+
+#define FSMC_BTR2_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */
+#define FSMC_BTR2_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */
+#define FSMC_BTR2_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */
+
+/******************* Bit definition for FSMC_BTR3 register *******************/
+#define FSMC_BTR3_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */
+#define FSMC_BTR3_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_BTR3_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_BTR3_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_BTR3_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+
+#define FSMC_BTR3_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
+#define FSMC_BTR3_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BTR3_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+#define FSMC_BTR3_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+#define FSMC_BTR3_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */
+
+#define FSMC_BTR3_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */
+#define FSMC_BTR3_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_BTR3_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_BTR3_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_BTR3_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+
+#define FSMC_BTR3_BUSTURN ((uint32_t)0x000F0000) /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */
+#define FSMC_BTR3_BUSTURN_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_BTR3_BUSTURN_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_BTR3_BUSTURN_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_BTR3_BUSTURN_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+
+#define FSMC_BTR3_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */
+#define FSMC_BTR3_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define FSMC_BTR3_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+#define FSMC_BTR3_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define FSMC_BTR3_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+
+#define FSMC_BTR3_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */
+#define FSMC_BTR3_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_BTR3_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_BTR3_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_BTR3_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+
+#define FSMC_BTR3_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */
+#define FSMC_BTR3_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */
+#define FSMC_BTR3_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */
+
+/****************** Bit definition for FSMC_BTR4 register *******************/
+#define FSMC_BTR4_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */
+#define FSMC_BTR4_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_BTR4_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_BTR4_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_BTR4_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+
+#define FSMC_BTR4_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
+#define FSMC_BTR4_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BTR4_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+#define FSMC_BTR4_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+#define FSMC_BTR4_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */
+
+#define FSMC_BTR4_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */
+#define FSMC_BTR4_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_BTR4_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_BTR4_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_BTR4_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+
+#define FSMC_BTR4_BUSTURN ((uint32_t)0x000F0000) /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */
+#define FSMC_BTR4_BUSTURN_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_BTR4_BUSTURN_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_BTR4_BUSTURN_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_BTR4_BUSTURN_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+
+#define FSMC_BTR4_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */
+#define FSMC_BTR4_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define FSMC_BTR4_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+#define FSMC_BTR4_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define FSMC_BTR4_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+
+#define FSMC_BTR4_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */
+#define FSMC_BTR4_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_BTR4_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_BTR4_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_BTR4_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+
+#define FSMC_BTR4_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */
+#define FSMC_BTR4_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */
+#define FSMC_BTR4_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */
+
+/****************** Bit definition for FSMC_BWTR1 register ******************/
+#define FSMC_BWTR1_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */
+#define FSMC_BWTR1_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_BWTR1_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_BWTR1_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_BWTR1_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+
+#define FSMC_BWTR1_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
+#define FSMC_BWTR1_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BWTR1_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+#define FSMC_BWTR1_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+#define FSMC_BWTR1_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */
+
+#define FSMC_BWTR1_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */
+#define FSMC_BWTR1_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_BWTR1_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_BWTR1_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_BWTR1_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+
+#define FSMC_BWTR1_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */
+#define FSMC_BWTR1_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define FSMC_BWTR1_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+#define FSMC_BWTR1_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define FSMC_BWTR1_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+
+#define FSMC_BWTR1_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */
+#define FSMC_BWTR1_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_BWTR1_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_BWTR1_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_BWTR1_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+
+#define FSMC_BWTR1_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */
+#define FSMC_BWTR1_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */
+#define FSMC_BWTR1_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */
+
+/****************** Bit definition for FSMC_BWTR2 register ******************/
+#define FSMC_BWTR2_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */
+#define FSMC_BWTR2_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_BWTR2_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_BWTR2_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_BWTR2_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+
+#define FSMC_BWTR2_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
+#define FSMC_BWTR2_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BWTR2_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+#define FSMC_BWTR2_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+#define FSMC_BWTR2_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */
+
+#define FSMC_BWTR2_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */
+#define FSMC_BWTR2_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_BWTR2_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_BWTR2_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_BWTR2_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+
+#define FSMC_BWTR2_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */
+#define FSMC_BWTR2_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define FSMC_BWTR2_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1*/
+#define FSMC_BWTR2_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define FSMC_BWTR2_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+
+#define FSMC_BWTR2_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */
+#define FSMC_BWTR2_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_BWTR2_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_BWTR2_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_BWTR2_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+
+#define FSMC_BWTR2_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */
+#define FSMC_BWTR2_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */
+#define FSMC_BWTR2_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */
+
+/****************** Bit definition for FSMC_BWTR3 register ******************/
+#define FSMC_BWTR3_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */
+#define FSMC_BWTR3_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_BWTR3_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_BWTR3_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_BWTR3_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+
+#define FSMC_BWTR3_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
+#define FSMC_BWTR3_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BWTR3_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+#define FSMC_BWTR3_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+#define FSMC_BWTR3_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */
+
+#define FSMC_BWTR3_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */
+#define FSMC_BWTR3_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_BWTR3_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_BWTR3_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_BWTR3_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+
+#define FSMC_BWTR3_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */
+#define FSMC_BWTR3_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define FSMC_BWTR3_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+#define FSMC_BWTR3_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define FSMC_BWTR3_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+
+#define FSMC_BWTR3_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */
+#define FSMC_BWTR3_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_BWTR3_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_BWTR3_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_BWTR3_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+
+#define FSMC_BWTR3_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */
+#define FSMC_BWTR3_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */
+#define FSMC_BWTR3_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */
+
+/****************** Bit definition for FSMC_BWTR4 register ******************/
+#define FSMC_BWTR4_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */
+#define FSMC_BWTR4_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_BWTR4_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_BWTR4_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_BWTR4_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+
+#define FSMC_BWTR4_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */
+#define FSMC_BWTR4_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_BWTR4_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+#define FSMC_BWTR4_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+#define FSMC_BWTR4_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */
+
+#define FSMC_BWTR4_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */
+#define FSMC_BWTR4_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_BWTR4_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_BWTR4_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_BWTR4_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+
+#define FSMC_BWTR4_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */
+#define FSMC_BWTR4_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */
+#define FSMC_BWTR4_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */
+#define FSMC_BWTR4_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */
+#define FSMC_BWTR4_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */
+
+#define FSMC_BWTR4_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */
+#define FSMC_BWTR4_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_BWTR4_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_BWTR4_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_BWTR4_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+
+#define FSMC_BWTR4_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */
+#define FSMC_BWTR4_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */
+#define FSMC_BWTR4_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */
+
+/****************** Bit definition for FSMC_PCR2 register *******************/
+#define FSMC_PCR2_PWAITEN ((uint32_t)0x00000002) /*!< Wait feature enable bit */
+#define FSMC_PCR2_PBKEN ((uint32_t)0x00000004) /*!< PC Card/NAND Flash memory bank enable bit */
+#define FSMC_PCR2_PTYP ((uint32_t)0x00000008) /*!< Memory type */
+
+#define FSMC_PCR2_PWID ((uint32_t)0x00000030) /*!< PWID[1:0] bits (NAND Flash databus width) */
+#define FSMC_PCR2_PWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_PCR2_PWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+
+#define FSMC_PCR2_ECCEN ((uint32_t)0x00000040) /*!< ECC computation logic enable bit */
+
+#define FSMC_PCR2_TCLR ((uint32_t)0x00001E00) /*!< TCLR[3:0] bits (CLE to RE delay) */
+#define FSMC_PCR2_TCLR_0 ((uint32_t)0x00000200) /*!< Bit 0 */
+#define FSMC_PCR2_TCLR_1 ((uint32_t)0x00000400) /*!< Bit 1 */
+#define FSMC_PCR2_TCLR_2 ((uint32_t)0x00000800) /*!< Bit 2 */
+#define FSMC_PCR2_TCLR_3 ((uint32_t)0x00001000) /*!< Bit 3 */
+
+#define FSMC_PCR2_TAR ((uint32_t)0x0001E000) /*!< TAR[3:0] bits (ALE to RE delay) */
+#define FSMC_PCR2_TAR_0 ((uint32_t)0x00002000) /*!< Bit 0 */
+#define FSMC_PCR2_TAR_1 ((uint32_t)0x00004000) /*!< Bit 1 */
+#define FSMC_PCR2_TAR_2 ((uint32_t)0x00008000) /*!< Bit 2 */
+#define FSMC_PCR2_TAR_3 ((uint32_t)0x00010000) /*!< Bit 3 */
+
+#define FSMC_PCR2_ECCPS ((uint32_t)0x000E0000) /*!< ECCPS[1:0] bits (ECC page size) */
+#define FSMC_PCR2_ECCPS_0 ((uint32_t)0x00020000) /*!< Bit 0 */
+#define FSMC_PCR2_ECCPS_1 ((uint32_t)0x00040000) /*!< Bit 1 */
+#define FSMC_PCR2_ECCPS_2 ((uint32_t)0x00080000) /*!< Bit 2 */
+
+/****************** Bit definition for FSMC_PCR3 register *******************/
+#define FSMC_PCR3_PWAITEN ((uint32_t)0x00000002) /*!< Wait feature enable bit */
+#define FSMC_PCR3_PBKEN ((uint32_t)0x00000004) /*!< PC Card/NAND Flash memory bank enable bit */
+#define FSMC_PCR3_PTYP ((uint32_t)0x00000008) /*!< Memory type */
+
+#define FSMC_PCR3_PWID ((uint32_t)0x00000030) /*!< PWID[1:0] bits (NAND Flash databus width) */
+#define FSMC_PCR3_PWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_PCR3_PWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+
+#define FSMC_PCR3_ECCEN ((uint32_t)0x00000040) /*!< ECC computation logic enable bit */
+
+#define FSMC_PCR3_TCLR ((uint32_t)0x00001E00) /*!< TCLR[3:0] bits (CLE to RE delay) */
+#define FSMC_PCR3_TCLR_0 ((uint32_t)0x00000200) /*!< Bit 0 */
+#define FSMC_PCR3_TCLR_1 ((uint32_t)0x00000400) /*!< Bit 1 */
+#define FSMC_PCR3_TCLR_2 ((uint32_t)0x00000800) /*!< Bit 2 */
+#define FSMC_PCR3_TCLR_3 ((uint32_t)0x00001000) /*!< Bit 3 */
+
+#define FSMC_PCR3_TAR ((uint32_t)0x0001E000) /*!< TAR[3:0] bits (ALE to RE delay) */
+#define FSMC_PCR3_TAR_0 ((uint32_t)0x00002000) /*!< Bit 0 */
+#define FSMC_PCR3_TAR_1 ((uint32_t)0x00004000) /*!< Bit 1 */
+#define FSMC_PCR3_TAR_2 ((uint32_t)0x00008000) /*!< Bit 2 */
+#define FSMC_PCR3_TAR_3 ((uint32_t)0x00010000) /*!< Bit 3 */
+
+#define FSMC_PCR3_ECCPS ((uint32_t)0x000E0000) /*!< ECCPS[2:0] bits (ECC page size) */
+#define FSMC_PCR3_ECCPS_0 ((uint32_t)0x00020000) /*!< Bit 0 */
+#define FSMC_PCR3_ECCPS_1 ((uint32_t)0x00040000) /*!< Bit 1 */
+#define FSMC_PCR3_ECCPS_2 ((uint32_t)0x00080000) /*!< Bit 2 */
+
+/****************** Bit definition for FSMC_PCR4 register *******************/
+#define FSMC_PCR4_PWAITEN ((uint32_t)0x00000002) /*!< Wait feature enable bit */
+#define FSMC_PCR4_PBKEN ((uint32_t)0x00000004) /*!< PC Card/NAND Flash memory bank enable bit */
+#define FSMC_PCR4_PTYP ((uint32_t)0x00000008) /*!< Memory type */
+
+#define FSMC_PCR4_PWID ((uint32_t)0x00000030) /*!< PWID[1:0] bits (NAND Flash databus width) */
+#define FSMC_PCR4_PWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define FSMC_PCR4_PWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+
+#define FSMC_PCR4_ECCEN ((uint32_t)0x00000040) /*!< ECC computation logic enable bit */
+
+#define FSMC_PCR4_TCLR ((uint32_t)0x00001E00) /*!< TCLR[3:0] bits (CLE to RE delay) */
+#define FSMC_PCR4_TCLR_0 ((uint32_t)0x00000200) /*!< Bit 0 */
+#define FSMC_PCR4_TCLR_1 ((uint32_t)0x00000400) /*!< Bit 1 */
+#define FSMC_PCR4_TCLR_2 ((uint32_t)0x00000800) /*!< Bit 2 */
+#define FSMC_PCR4_TCLR_3 ((uint32_t)0x00001000) /*!< Bit 3 */
+
+#define FSMC_PCR4_TAR ((uint32_t)0x0001E000) /*!< TAR[3:0] bits (ALE to RE delay) */
+#define FSMC_PCR4_TAR_0 ((uint32_t)0x00002000) /*!< Bit 0 */
+#define FSMC_PCR4_TAR_1 ((uint32_t)0x00004000) /*!< Bit 1 */
+#define FSMC_PCR4_TAR_2 ((uint32_t)0x00008000) /*!< Bit 2 */
+#define FSMC_PCR4_TAR_3 ((uint32_t)0x00010000) /*!< Bit 3 */
+
+#define FSMC_PCR4_ECCPS ((uint32_t)0x000E0000) /*!< ECCPS[2:0] bits (ECC page size) */
+#define FSMC_PCR4_ECCPS_0 ((uint32_t)0x00020000) /*!< Bit 0 */
+#define FSMC_PCR4_ECCPS_1 ((uint32_t)0x00040000) /*!< Bit 1 */
+#define FSMC_PCR4_ECCPS_2 ((uint32_t)0x00080000) /*!< Bit 2 */
+
+/******************* Bit definition for FSMC_SR2 register *******************/
+#define FSMC_SR2_IRS ((uint8_t)0x01) /*!< Interrupt Rising Edge status */
+#define FSMC_SR2_ILS ((uint8_t)0x02) /*!< Interrupt Level status */
+#define FSMC_SR2_IFS ((uint8_t)0x04) /*!< Interrupt Falling Edge status */
+#define FSMC_SR2_IREN ((uint8_t)0x08) /*!< Interrupt Rising Edge detection Enable bit */
+#define FSMC_SR2_ILEN ((uint8_t)0x10) /*!< Interrupt Level detection Enable bit */
+#define FSMC_SR2_IFEN ((uint8_t)0x20) /*!< Interrupt Falling Edge detection Enable bit */
+#define FSMC_SR2_FEMPT ((uint8_t)0x40) /*!< FIFO empty */
+
+/******************* Bit definition for FSMC_SR3 register *******************/
+#define FSMC_SR3_IRS ((uint8_t)0x01) /*!< Interrupt Rising Edge status */
+#define FSMC_SR3_ILS ((uint8_t)0x02) /*!< Interrupt Level status */
+#define FSMC_SR3_IFS ((uint8_t)0x04) /*!< Interrupt Falling Edge status */
+#define FSMC_SR3_IREN ((uint8_t)0x08) /*!< Interrupt Rising Edge detection Enable bit */
+#define FSMC_SR3_ILEN ((uint8_t)0x10) /*!< Interrupt Level detection Enable bit */
+#define FSMC_SR3_IFEN ((uint8_t)0x20) /*!< Interrupt Falling Edge detection Enable bit */
+#define FSMC_SR3_FEMPT ((uint8_t)0x40) /*!< FIFO empty */
+
+/******************* Bit definition for FSMC_SR4 register *******************/
+#define FSMC_SR4_IRS ((uint8_t)0x01) /*!< Interrupt Rising Edge status */
+#define FSMC_SR4_ILS ((uint8_t)0x02) /*!< Interrupt Level status */
+#define FSMC_SR4_IFS ((uint8_t)0x04) /*!< Interrupt Falling Edge status */
+#define FSMC_SR4_IREN ((uint8_t)0x08) /*!< Interrupt Rising Edge detection Enable bit */
+#define FSMC_SR4_ILEN ((uint8_t)0x10) /*!< Interrupt Level detection Enable bit */
+#define FSMC_SR4_IFEN ((uint8_t)0x20) /*!< Interrupt Falling Edge detection Enable bit */
+#define FSMC_SR4_FEMPT ((uint8_t)0x40) /*!< FIFO empty */
+
+/****************** Bit definition for FSMC_PMEM2 register ******************/
+#define FSMC_PMEM2_MEMSET2 ((uint32_t)0x000000FF) /*!< MEMSET2[7:0] bits (Common memory 2 setup time) */
+#define FSMC_PMEM2_MEMSET2_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_PMEM2_MEMSET2_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_PMEM2_MEMSET2_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_PMEM2_MEMSET2_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define FSMC_PMEM2_MEMSET2_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+#define FSMC_PMEM2_MEMSET2_5 ((uint32_t)0x00000020) /*!< Bit 5 */
+#define FSMC_PMEM2_MEMSET2_6 ((uint32_t)0x00000040) /*!< Bit 6 */
+#define FSMC_PMEM2_MEMSET2_7 ((uint32_t)0x00000080) /*!< Bit 7 */
+
+#define FSMC_PMEM2_MEMWAIT2 ((uint32_t)0x0000FF00) /*!< MEMWAIT2[7:0] bits (Common memory 2 wait time) */
+#define FSMC_PMEM2_MEMWAIT2_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_PMEM2_MEMWAIT2_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_PMEM2_MEMWAIT2_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_PMEM2_MEMWAIT2_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+#define FSMC_PMEM2_MEMWAIT2_4 ((uint32_t)0x00001000) /*!< Bit 4 */
+#define FSMC_PMEM2_MEMWAIT2_5 ((uint32_t)0x00002000) /*!< Bit 5 */
+#define FSMC_PMEM2_MEMWAIT2_6 ((uint32_t)0x00004000) /*!< Bit 6 */
+#define FSMC_PMEM2_MEMWAIT2_7 ((uint32_t)0x00008000) /*!< Bit 7 */
+
+#define FSMC_PMEM2_MEMHOLD2 ((uint32_t)0x00FF0000) /*!< MEMHOLD2[7:0] bits (Common memory 2 hold time) */
+#define FSMC_PMEM2_MEMHOLD2_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_PMEM2_MEMHOLD2_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_PMEM2_MEMHOLD2_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_PMEM2_MEMHOLD2_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+#define FSMC_PMEM2_MEMHOLD2_4 ((uint32_t)0x00100000) /*!< Bit 4 */
+#define FSMC_PMEM2_MEMHOLD2_5 ((uint32_t)0x00200000) /*!< Bit 5 */
+#define FSMC_PMEM2_MEMHOLD2_6 ((uint32_t)0x00400000) /*!< Bit 6 */
+#define FSMC_PMEM2_MEMHOLD2_7 ((uint32_t)0x00800000) /*!< Bit 7 */
+
+#define FSMC_PMEM2_MEMHIZ2 ((uint32_t)0xFF000000) /*!< MEMHIZ2[7:0] bits (Common memory 2 databus HiZ time) */
+#define FSMC_PMEM2_MEMHIZ2_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_PMEM2_MEMHIZ2_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_PMEM2_MEMHIZ2_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_PMEM2_MEMHIZ2_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+#define FSMC_PMEM2_MEMHIZ2_4 ((uint32_t)0x10000000) /*!< Bit 4 */
+#define FSMC_PMEM2_MEMHIZ2_5 ((uint32_t)0x20000000) /*!< Bit 5 */
+#define FSMC_PMEM2_MEMHIZ2_6 ((uint32_t)0x40000000) /*!< Bit 6 */
+#define FSMC_PMEM2_MEMHIZ2_7 ((uint32_t)0x80000000) /*!< Bit 7 */
+
+/****************** Bit definition for FSMC_PMEM3 register ******************/
+#define FSMC_PMEM3_MEMSET3 ((uint32_t)0x000000FF) /*!< MEMSET3[7:0] bits (Common memory 3 setup time) */
+#define FSMC_PMEM3_MEMSET3_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_PMEM3_MEMSET3_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_PMEM3_MEMSET3_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_PMEM3_MEMSET3_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define FSMC_PMEM3_MEMSET3_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+#define FSMC_PMEM3_MEMSET3_5 ((uint32_t)0x00000020) /*!< Bit 5 */
+#define FSMC_PMEM3_MEMSET3_6 ((uint32_t)0x00000040) /*!< Bit 6 */
+#define FSMC_PMEM3_MEMSET3_7 ((uint32_t)0x00000080) /*!< Bit 7 */
+
+#define FSMC_PMEM3_MEMWAIT3 ((uint32_t)0x0000FF00) /*!< MEMWAIT3[7:0] bits (Common memory 3 wait time) */
+#define FSMC_PMEM3_MEMWAIT3_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_PMEM3_MEMWAIT3_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_PMEM3_MEMWAIT3_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_PMEM3_MEMWAIT3_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+#define FSMC_PMEM3_MEMWAIT3_4 ((uint32_t)0x00001000) /*!< Bit 4 */
+#define FSMC_PMEM3_MEMWAIT3_5 ((uint32_t)0x00002000) /*!< Bit 5 */
+#define FSMC_PMEM3_MEMWAIT3_6 ((uint32_t)0x00004000) /*!< Bit 6 */
+#define FSMC_PMEM3_MEMWAIT3_7 ((uint32_t)0x00008000) /*!< Bit 7 */
+
+#define FSMC_PMEM3_MEMHOLD3 ((uint32_t)0x00FF0000) /*!< MEMHOLD3[7:0] bits (Common memory 3 hold time) */
+#define FSMC_PMEM3_MEMHOLD3_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_PMEM3_MEMHOLD3_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_PMEM3_MEMHOLD3_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_PMEM3_MEMHOLD3_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+#define FSMC_PMEM3_MEMHOLD3_4 ((uint32_t)0x00100000) /*!< Bit 4 */
+#define FSMC_PMEM3_MEMHOLD3_5 ((uint32_t)0x00200000) /*!< Bit 5 */
+#define FSMC_PMEM3_MEMHOLD3_6 ((uint32_t)0x00400000) /*!< Bit 6 */
+#define FSMC_PMEM3_MEMHOLD3_7 ((uint32_t)0x00800000) /*!< Bit 7 */
+
+#define FSMC_PMEM3_MEMHIZ3 ((uint32_t)0xFF000000) /*!< MEMHIZ3[7:0] bits (Common memory 3 databus HiZ time) */
+#define FSMC_PMEM3_MEMHIZ3_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_PMEM3_MEMHIZ3_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_PMEM3_MEMHIZ3_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_PMEM3_MEMHIZ3_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+#define FSMC_PMEM3_MEMHIZ3_4 ((uint32_t)0x10000000) /*!< Bit 4 */
+#define FSMC_PMEM3_MEMHIZ3_5 ((uint32_t)0x20000000) /*!< Bit 5 */
+#define FSMC_PMEM3_MEMHIZ3_6 ((uint32_t)0x40000000) /*!< Bit 6 */
+#define FSMC_PMEM3_MEMHIZ3_7 ((uint32_t)0x80000000) /*!< Bit 7 */
+
+/****************** Bit definition for FSMC_PMEM4 register ******************/
+#define FSMC_PMEM4_MEMSET4 ((uint32_t)0x000000FF) /*!< MEMSET4[7:0] bits (Common memory 4 setup time) */
+#define FSMC_PMEM4_MEMSET4_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_PMEM4_MEMSET4_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_PMEM4_MEMSET4_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_PMEM4_MEMSET4_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define FSMC_PMEM4_MEMSET4_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+#define FSMC_PMEM4_MEMSET4_5 ((uint32_t)0x00000020) /*!< Bit 5 */
+#define FSMC_PMEM4_MEMSET4_6 ((uint32_t)0x00000040) /*!< Bit 6 */
+#define FSMC_PMEM4_MEMSET4_7 ((uint32_t)0x00000080) /*!< Bit 7 */
+
+#define FSMC_PMEM4_MEMWAIT4 ((uint32_t)0x0000FF00) /*!< MEMWAIT4[7:0] bits (Common memory 4 wait time) */
+#define FSMC_PMEM4_MEMWAIT4_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_PMEM4_MEMWAIT4_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_PMEM4_MEMWAIT4_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_PMEM4_MEMWAIT4_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+#define FSMC_PMEM4_MEMWAIT4_4 ((uint32_t)0x00001000) /*!< Bit 4 */
+#define FSMC_PMEM4_MEMWAIT4_5 ((uint32_t)0x00002000) /*!< Bit 5 */
+#define FSMC_PMEM4_MEMWAIT4_6 ((uint32_t)0x00004000) /*!< Bit 6 */
+#define FSMC_PMEM4_MEMWAIT4_7 ((uint32_t)0x00008000) /*!< Bit 7 */
+
+#define FSMC_PMEM4_MEMHOLD4 ((uint32_t)0x00FF0000) /*!< MEMHOLD4[7:0] bits (Common memory 4 hold time) */
+#define FSMC_PMEM4_MEMHOLD4_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_PMEM4_MEMHOLD4_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_PMEM4_MEMHOLD4_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_PMEM4_MEMHOLD4_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+#define FSMC_PMEM4_MEMHOLD4_4 ((uint32_t)0x00100000) /*!< Bit 4 */
+#define FSMC_PMEM4_MEMHOLD4_5 ((uint32_t)0x00200000) /*!< Bit 5 */
+#define FSMC_PMEM4_MEMHOLD4_6 ((uint32_t)0x00400000) /*!< Bit 6 */
+#define FSMC_PMEM4_MEMHOLD4_7 ((uint32_t)0x00800000) /*!< Bit 7 */
+
+#define FSMC_PMEM4_MEMHIZ4 ((uint32_t)0xFF000000) /*!< MEMHIZ4[7:0] bits (Common memory 4 databus HiZ time) */
+#define FSMC_PMEM4_MEMHIZ4_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_PMEM4_MEMHIZ4_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_PMEM4_MEMHIZ4_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_PMEM4_MEMHIZ4_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+#define FSMC_PMEM4_MEMHIZ4_4 ((uint32_t)0x10000000) /*!< Bit 4 */
+#define FSMC_PMEM4_MEMHIZ4_5 ((uint32_t)0x20000000) /*!< Bit 5 */
+#define FSMC_PMEM4_MEMHIZ4_6 ((uint32_t)0x40000000) /*!< Bit 6 */
+#define FSMC_PMEM4_MEMHIZ4_7 ((uint32_t)0x80000000) /*!< Bit 7 */
+
+/****************** Bit definition for FSMC_PATT2 register ******************/
+#define FSMC_PATT2_ATTSET2 ((uint32_t)0x000000FF) /*!< ATTSET2[7:0] bits (Attribute memory 2 setup time) */
+#define FSMC_PATT2_ATTSET2_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_PATT2_ATTSET2_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_PATT2_ATTSET2_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_PATT2_ATTSET2_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define FSMC_PATT2_ATTSET2_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+#define FSMC_PATT2_ATTSET2_5 ((uint32_t)0x00000020) /*!< Bit 5 */
+#define FSMC_PATT2_ATTSET2_6 ((uint32_t)0x00000040) /*!< Bit 6 */
+#define FSMC_PATT2_ATTSET2_7 ((uint32_t)0x00000080) /*!< Bit 7 */
+
+#define FSMC_PATT2_ATTWAIT2 ((uint32_t)0x0000FF00) /*!< ATTWAIT2[7:0] bits (Attribute memory 2 wait time) */
+#define FSMC_PATT2_ATTWAIT2_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_PATT2_ATTWAIT2_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_PATT2_ATTWAIT2_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_PATT2_ATTWAIT2_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+#define FSMC_PATT2_ATTWAIT2_4 ((uint32_t)0x00001000) /*!< Bit 4 */
+#define FSMC_PATT2_ATTWAIT2_5 ((uint32_t)0x00002000) /*!< Bit 5 */
+#define FSMC_PATT2_ATTWAIT2_6 ((uint32_t)0x00004000) /*!< Bit 6 */
+#define FSMC_PATT2_ATTWAIT2_7 ((uint32_t)0x00008000) /*!< Bit 7 */
+
+#define FSMC_PATT2_ATTHOLD2 ((uint32_t)0x00FF0000) /*!< ATTHOLD2[7:0] bits (Attribute memory 2 hold time) */
+#define FSMC_PATT2_ATTHOLD2_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_PATT2_ATTHOLD2_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_PATT2_ATTHOLD2_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_PATT2_ATTHOLD2_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+#define FSMC_PATT2_ATTHOLD2_4 ((uint32_t)0x00100000) /*!< Bit 4 */
+#define FSMC_PATT2_ATTHOLD2_5 ((uint32_t)0x00200000) /*!< Bit 5 */
+#define FSMC_PATT2_ATTHOLD2_6 ((uint32_t)0x00400000) /*!< Bit 6 */
+#define FSMC_PATT2_ATTHOLD2_7 ((uint32_t)0x00800000) /*!< Bit 7 */
+
+#define FSMC_PATT2_ATTHIZ2 ((uint32_t)0xFF000000) /*!< ATTHIZ2[7:0] bits (Attribute memory 2 databus HiZ time) */
+#define FSMC_PATT2_ATTHIZ2_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_PATT2_ATTHIZ2_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_PATT2_ATTHIZ2_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_PATT2_ATTHIZ2_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+#define FSMC_PATT2_ATTHIZ2_4 ((uint32_t)0x10000000) /*!< Bit 4 */
+#define FSMC_PATT2_ATTHIZ2_5 ((uint32_t)0x20000000) /*!< Bit 5 */
+#define FSMC_PATT2_ATTHIZ2_6 ((uint32_t)0x40000000) /*!< Bit 6 */
+#define FSMC_PATT2_ATTHIZ2_7 ((uint32_t)0x80000000) /*!< Bit 7 */
+
+/****************** Bit definition for FSMC_PATT3 register ******************/
+#define FSMC_PATT3_ATTSET3 ((uint32_t)0x000000FF) /*!< ATTSET3[7:0] bits (Attribute memory 3 setup time) */
+#define FSMC_PATT3_ATTSET3_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_PATT3_ATTSET3_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_PATT3_ATTSET3_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_PATT3_ATTSET3_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define FSMC_PATT3_ATTSET3_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+#define FSMC_PATT3_ATTSET3_5 ((uint32_t)0x00000020) /*!< Bit 5 */
+#define FSMC_PATT3_ATTSET3_6 ((uint32_t)0x00000040) /*!< Bit 6 */
+#define FSMC_PATT3_ATTSET3_7 ((uint32_t)0x00000080) /*!< Bit 7 */
+
+#define FSMC_PATT3_ATTWAIT3 ((uint32_t)0x0000FF00) /*!< ATTWAIT3[7:0] bits (Attribute memory 3 wait time) */
+#define FSMC_PATT3_ATTWAIT3_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_PATT3_ATTWAIT3_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_PATT3_ATTWAIT3_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_PATT3_ATTWAIT3_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+#define FSMC_PATT3_ATTWAIT3_4 ((uint32_t)0x00001000) /*!< Bit 4 */
+#define FSMC_PATT3_ATTWAIT3_5 ((uint32_t)0x00002000) /*!< Bit 5 */
+#define FSMC_PATT3_ATTWAIT3_6 ((uint32_t)0x00004000) /*!< Bit 6 */
+#define FSMC_PATT3_ATTWAIT3_7 ((uint32_t)0x00008000) /*!< Bit 7 */
+
+#define FSMC_PATT3_ATTHOLD3 ((uint32_t)0x00FF0000) /*!< ATTHOLD3[7:0] bits (Attribute memory 3 hold time) */
+#define FSMC_PATT3_ATTHOLD3_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_PATT3_ATTHOLD3_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_PATT3_ATTHOLD3_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_PATT3_ATTHOLD3_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+#define FSMC_PATT3_ATTHOLD3_4 ((uint32_t)0x00100000) /*!< Bit 4 */
+#define FSMC_PATT3_ATTHOLD3_5 ((uint32_t)0x00200000) /*!< Bit 5 */
+#define FSMC_PATT3_ATTHOLD3_6 ((uint32_t)0x00400000) /*!< Bit 6 */
+#define FSMC_PATT3_ATTHOLD3_7 ((uint32_t)0x00800000) /*!< Bit 7 */
+
+#define FSMC_PATT3_ATTHIZ3 ((uint32_t)0xFF000000) /*!< ATTHIZ3[7:0] bits (Attribute memory 3 databus HiZ time) */
+#define FSMC_PATT3_ATTHIZ3_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_PATT3_ATTHIZ3_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_PATT3_ATTHIZ3_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_PATT3_ATTHIZ3_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+#define FSMC_PATT3_ATTHIZ3_4 ((uint32_t)0x10000000) /*!< Bit 4 */
+#define FSMC_PATT3_ATTHIZ3_5 ((uint32_t)0x20000000) /*!< Bit 5 */
+#define FSMC_PATT3_ATTHIZ3_6 ((uint32_t)0x40000000) /*!< Bit 6 */
+#define FSMC_PATT3_ATTHIZ3_7 ((uint32_t)0x80000000) /*!< Bit 7 */
+
+/****************** Bit definition for FSMC_PATT4 register ******************/
+#define FSMC_PATT4_ATTSET4 ((uint32_t)0x000000FF) /*!< ATTSET4[7:0] bits (Attribute memory 4 setup time) */
+#define FSMC_PATT4_ATTSET4_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_PATT4_ATTSET4_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_PATT4_ATTSET4_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_PATT4_ATTSET4_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define FSMC_PATT4_ATTSET4_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+#define FSMC_PATT4_ATTSET4_5 ((uint32_t)0x00000020) /*!< Bit 5 */
+#define FSMC_PATT4_ATTSET4_6 ((uint32_t)0x00000040) /*!< Bit 6 */
+#define FSMC_PATT4_ATTSET4_7 ((uint32_t)0x00000080) /*!< Bit 7 */
+
+#define FSMC_PATT4_ATTWAIT4 ((uint32_t)0x0000FF00) /*!< ATTWAIT4[7:0] bits (Attribute memory 4 wait time) */
+#define FSMC_PATT4_ATTWAIT4_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_PATT4_ATTWAIT4_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_PATT4_ATTWAIT4_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_PATT4_ATTWAIT4_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+#define FSMC_PATT4_ATTWAIT4_4 ((uint32_t)0x00001000) /*!< Bit 4 */
+#define FSMC_PATT4_ATTWAIT4_5 ((uint32_t)0x00002000) /*!< Bit 5 */
+#define FSMC_PATT4_ATTWAIT4_6 ((uint32_t)0x00004000) /*!< Bit 6 */
+#define FSMC_PATT4_ATTWAIT4_7 ((uint32_t)0x00008000) /*!< Bit 7 */
+
+#define FSMC_PATT4_ATTHOLD4 ((uint32_t)0x00FF0000) /*!< ATTHOLD4[7:0] bits (Attribute memory 4 hold time) */
+#define FSMC_PATT4_ATTHOLD4_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_PATT4_ATTHOLD4_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_PATT4_ATTHOLD4_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_PATT4_ATTHOLD4_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+#define FSMC_PATT4_ATTHOLD4_4 ((uint32_t)0x00100000) /*!< Bit 4 */
+#define FSMC_PATT4_ATTHOLD4_5 ((uint32_t)0x00200000) /*!< Bit 5 */
+#define FSMC_PATT4_ATTHOLD4_6 ((uint32_t)0x00400000) /*!< Bit 6 */
+#define FSMC_PATT4_ATTHOLD4_7 ((uint32_t)0x00800000) /*!< Bit 7 */
+
+#define FSMC_PATT4_ATTHIZ4 ((uint32_t)0xFF000000) /*!< ATTHIZ4[7:0] bits (Attribute memory 4 databus HiZ time) */
+#define FSMC_PATT4_ATTHIZ4_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_PATT4_ATTHIZ4_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_PATT4_ATTHIZ4_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_PATT4_ATTHIZ4_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+#define FSMC_PATT4_ATTHIZ4_4 ((uint32_t)0x10000000) /*!< Bit 4 */
+#define FSMC_PATT4_ATTHIZ4_5 ((uint32_t)0x20000000) /*!< Bit 5 */
+#define FSMC_PATT4_ATTHIZ4_6 ((uint32_t)0x40000000) /*!< Bit 6 */
+#define FSMC_PATT4_ATTHIZ4_7 ((uint32_t)0x80000000) /*!< Bit 7 */
+
+/****************** Bit definition for FSMC_PIO4 register *******************/
+#define FSMC_PIO4_IOSET4 ((uint32_t)0x000000FF) /*!< IOSET4[7:0] bits (I/O 4 setup time) */
+#define FSMC_PIO4_IOSET4_0 ((uint32_t)0x00000001) /*!< Bit 0 */
+#define FSMC_PIO4_IOSET4_1 ((uint32_t)0x00000002) /*!< Bit 1 */
+#define FSMC_PIO4_IOSET4_2 ((uint32_t)0x00000004) /*!< Bit 2 */
+#define FSMC_PIO4_IOSET4_3 ((uint32_t)0x00000008) /*!< Bit 3 */
+#define FSMC_PIO4_IOSET4_4 ((uint32_t)0x00000010) /*!< Bit 4 */
+#define FSMC_PIO4_IOSET4_5 ((uint32_t)0x00000020) /*!< Bit 5 */
+#define FSMC_PIO4_IOSET4_6 ((uint32_t)0x00000040) /*!< Bit 6 */
+#define FSMC_PIO4_IOSET4_7 ((uint32_t)0x00000080) /*!< Bit 7 */
+
+#define FSMC_PIO4_IOWAIT4 ((uint32_t)0x0000FF00) /*!< IOWAIT4[7:0] bits (I/O 4 wait time) */
+#define FSMC_PIO4_IOWAIT4_0 ((uint32_t)0x00000100) /*!< Bit 0 */
+#define FSMC_PIO4_IOWAIT4_1 ((uint32_t)0x00000200) /*!< Bit 1 */
+#define FSMC_PIO4_IOWAIT4_2 ((uint32_t)0x00000400) /*!< Bit 2 */
+#define FSMC_PIO4_IOWAIT4_3 ((uint32_t)0x00000800) /*!< Bit 3 */
+#define FSMC_PIO4_IOWAIT4_4 ((uint32_t)0x00001000) /*!< Bit 4 */
+#define FSMC_PIO4_IOWAIT4_5 ((uint32_t)0x00002000) /*!< Bit 5 */
+#define FSMC_PIO4_IOWAIT4_6 ((uint32_t)0x00004000) /*!< Bit 6 */
+#define FSMC_PIO4_IOWAIT4_7 ((uint32_t)0x00008000) /*!< Bit 7 */
+
+#define FSMC_PIO4_IOHOLD4 ((uint32_t)0x00FF0000) /*!< IOHOLD4[7:0] bits (I/O 4 hold time) */
+#define FSMC_PIO4_IOHOLD4_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define FSMC_PIO4_IOHOLD4_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define FSMC_PIO4_IOHOLD4_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define FSMC_PIO4_IOHOLD4_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+#define FSMC_PIO4_IOHOLD4_4 ((uint32_t)0x00100000) /*!< Bit 4 */
+#define FSMC_PIO4_IOHOLD4_5 ((uint32_t)0x00200000) /*!< Bit 5 */
+#define FSMC_PIO4_IOHOLD4_6 ((uint32_t)0x00400000) /*!< Bit 6 */
+#define FSMC_PIO4_IOHOLD4_7 ((uint32_t)0x00800000) /*!< Bit 7 */
+
+#define FSMC_PIO4_IOHIZ4 ((uint32_t)0xFF000000) /*!< IOHIZ4[7:0] bits (I/O 4 databus HiZ time) */
+#define FSMC_PIO4_IOHIZ4_0 ((uint32_t)0x01000000) /*!< Bit 0 */
+#define FSMC_PIO4_IOHIZ4_1 ((uint32_t)0x02000000) /*!< Bit 1 */
+#define FSMC_PIO4_IOHIZ4_2 ((uint32_t)0x04000000) /*!< Bit 2 */
+#define FSMC_PIO4_IOHIZ4_3 ((uint32_t)0x08000000) /*!< Bit 3 */
+#define FSMC_PIO4_IOHIZ4_4 ((uint32_t)0x10000000) /*!< Bit 4 */
+#define FSMC_PIO4_IOHIZ4_5 ((uint32_t)0x20000000) /*!< Bit 5 */
+#define FSMC_PIO4_IOHIZ4_6 ((uint32_t)0x40000000) /*!< Bit 6 */
+#define FSMC_PIO4_IOHIZ4_7 ((uint32_t)0x80000000) /*!< Bit 7 */
+
+/****************** Bit definition for FSMC_ECCR2 register ******************/
+#define FSMC_ECCR2_ECC2 ((uint32_t)0xFFFFFFFF) /*!< ECC result */
+
+/****************** Bit definition for FSMC_ECCR3 register ******************/
+#define FSMC_ECCR3_ECC3 ((uint32_t)0xFFFFFFFF) /*!< ECC result */
+
+/******************************************************************************/
+/* */
+/* SD host Interface */
+/* */
+/******************************************************************************/
+
+/****************** Bit definition for SDIO_POWER register ******************/
+#define SDIO_POWER_PWRCTRL ((uint8_t)0x03) /*!< PWRCTRL[1:0] bits (Power supply control bits) */
+#define SDIO_POWER_PWRCTRL_0 ((uint8_t)0x01) /*!< Bit 0 */
+#define SDIO_POWER_PWRCTRL_1 ((uint8_t)0x02) /*!< Bit 1 */
+
+/****************** Bit definition for SDIO_CLKCR register ******************/
+#define SDIO_CLKCR_CLKDIV ((uint16_t)0x00FF) /*!< Clock divide factor */
+#define SDIO_CLKCR_CLKEN ((uint16_t)0x0100) /*!< Clock enable bit */
+#define SDIO_CLKCR_PWRSAV ((uint16_t)0x0200) /*!< Power saving configuration bit */
+#define SDIO_CLKCR_BYPASS ((uint16_t)0x0400) /*!< Clock divider bypass enable bit */
+
+#define SDIO_CLKCR_WIDBUS ((uint16_t)0x1800) /*!< WIDBUS[1:0] bits (Wide bus mode enable bit) */
+#define SDIO_CLKCR_WIDBUS_0 ((uint16_t)0x0800) /*!< Bit 0 */
+#define SDIO_CLKCR_WIDBUS_1 ((uint16_t)0x1000) /*!< Bit 1 */
+
+#define SDIO_CLKCR_NEGEDGE ((uint16_t)0x2000) /*!< SDIO_CK dephasing selection bit */
+#define SDIO_CLKCR_HWFC_EN ((uint16_t)0x4000) /*!< HW Flow Control enable */
+
+/******************* Bit definition for SDIO_ARG register *******************/
+#define SDIO_ARG_CMDARG ((uint32_t)0xFFFFFFFF) /*!< Command argument */
+
+/******************* Bit definition for SDIO_CMD register *******************/
+#define SDIO_CMD_CMDINDEX ((uint16_t)0x003F) /*!< Command Index */
+
+#define SDIO_CMD_WAITRESP ((uint16_t)0x00C0) /*!< WAITRESP[1:0] bits (Wait for response bits) */
+#define SDIO_CMD_WAITRESP_0 ((uint16_t)0x0040) /*!< Bit 0 */
+#define SDIO_CMD_WAITRESP_1 ((uint16_t)0x0080) /*!< Bit 1 */
+
+#define SDIO_CMD_WAITINT ((uint16_t)0x0100) /*!< CPSM Waits for Interrupt Request */
+#define SDIO_CMD_WAITPEND ((uint16_t)0x0200) /*!< CPSM Waits for ends of data transfer (CmdPend internal signal) */
+#define SDIO_CMD_CPSMEN ((uint16_t)0x0400) /*!< Command path state machine (CPSM) Enable bit */
+#define SDIO_CMD_SDIOSUSPEND ((uint16_t)0x0800) /*!< SD I/O suspend command */
+#define SDIO_CMD_ENCMDCOMPL ((uint16_t)0x1000) /*!< Enable CMD completion */
+#define SDIO_CMD_NIEN ((uint16_t)0x2000) /*!< Not Interrupt Enable */
+#define SDIO_CMD_CEATACMD ((uint16_t)0x4000) /*!< CE-ATA command */
+
+/***************** Bit definition for SDIO_RESPCMD register *****************/
+#define SDIO_RESPCMD_RESPCMD ((uint8_t)0x3F) /*!< Response command index */
+
+/****************** Bit definition for SDIO_RESP0 register ******************/
+#define SDIO_RESP0_CARDSTATUS0 ((uint32_t)0xFFFFFFFF) /*!< Card Status */
+
+/****************** Bit definition for SDIO_RESP1 register ******************/
+#define SDIO_RESP1_CARDSTATUS1 ((uint32_t)0xFFFFFFFF) /*!< Card Status */
+
+/****************** Bit definition for SDIO_RESP2 register ******************/
+#define SDIO_RESP2_CARDSTATUS2 ((uint32_t)0xFFFFFFFF) /*!< Card Status */
+
+/****************** Bit definition for SDIO_RESP3 register ******************/
+#define SDIO_RESP3_CARDSTATUS3 ((uint32_t)0xFFFFFFFF) /*!< Card Status */
+
+/****************** Bit definition for SDIO_RESP4 register ******************/
+#define SDIO_RESP4_CARDSTATUS4 ((uint32_t)0xFFFFFFFF) /*!< Card Status */
+
+/****************** Bit definition for SDIO_DTIMER register *****************/
+#define SDIO_DTIMER_DATATIME ((uint32_t)0xFFFFFFFF) /*!< Data timeout period. */
+
+/****************** Bit definition for SDIO_DLEN register *******************/
+#define SDIO_DLEN_DATALENGTH ((uint32_t)0x01FFFFFF) /*!< Data length value */
+
+/****************** Bit definition for SDIO_DCTRL register ******************/
+#define SDIO_DCTRL_DTEN ((uint16_t)0x0001) /*!< Data transfer enabled bit */
+#define SDIO_DCTRL_DTDIR ((uint16_t)0x0002) /*!< Data transfer direction selection */
+#define SDIO_DCTRL_DTMODE ((uint16_t)0x0004) /*!< Data transfer mode selection */
+#define SDIO_DCTRL_DMAEN ((uint16_t)0x0008) /*!< DMA enabled bit */
+
+#define SDIO_DCTRL_DBLOCKSIZE ((uint16_t)0x00F0) /*!< DBLOCKSIZE[3:0] bits (Data block size) */
+#define SDIO_DCTRL_DBLOCKSIZE_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define SDIO_DCTRL_DBLOCKSIZE_1 ((uint16_t)0x0020) /*!< Bit 1 */
+#define SDIO_DCTRL_DBLOCKSIZE_2 ((uint16_t)0x0040) /*!< Bit 2 */
+#define SDIO_DCTRL_DBLOCKSIZE_3 ((uint16_t)0x0080) /*!< Bit 3 */
+
+#define SDIO_DCTRL_RWSTART ((uint16_t)0x0100) /*!< Read wait start */
+#define SDIO_DCTRL_RWSTOP ((uint16_t)0x0200) /*!< Read wait stop */
+#define SDIO_DCTRL_RWMOD ((uint16_t)0x0400) /*!< Read wait mode */
+#define SDIO_DCTRL_SDIOEN ((uint16_t)0x0800) /*!< SD I/O enable functions */
+
+/****************** Bit definition for SDIO_DCOUNT register *****************/
+#define SDIO_DCOUNT_DATACOUNT ((uint32_t)0x01FFFFFF) /*!< Data count value */
+
+/****************** Bit definition for SDIO_STA register ********************/
+#define SDIO_STA_CCRCFAIL ((uint32_t)0x00000001) /*!< Command response received (CRC check failed) */
+#define SDIO_STA_DCRCFAIL ((uint32_t)0x00000002) /*!< Data block sent/received (CRC check failed) */
+#define SDIO_STA_CTIMEOUT ((uint32_t)0x00000004) /*!< Command response timeout */
+#define SDIO_STA_DTIMEOUT ((uint32_t)0x00000008) /*!< Data timeout */
+#define SDIO_STA_TXUNDERR ((uint32_t)0x00000010) /*!< Transmit FIFO underrun error */
+#define SDIO_STA_RXOVERR ((uint32_t)0x00000020) /*!< Received FIFO overrun error */
+#define SDIO_STA_CMDREND ((uint32_t)0x00000040) /*!< Command response received (CRC check passed) */
+#define SDIO_STA_CMDSENT ((uint32_t)0x00000080) /*!< Command sent (no response required) */
+#define SDIO_STA_DATAEND ((uint32_t)0x00000100) /*!< Data end (data counter, SDIDCOUNT, is zero) */
+#define SDIO_STA_STBITERR ((uint32_t)0x00000200) /*!< Start bit not detected on all data signals in wide bus mode */
+#define SDIO_STA_DBCKEND ((uint32_t)0x00000400) /*!< Data block sent/received (CRC check passed) */
+#define SDIO_STA_CMDACT ((uint32_t)0x00000800) /*!< Command transfer in progress */
+#define SDIO_STA_TXACT ((uint32_t)0x00001000) /*!< Data transmit in progress */
+#define SDIO_STA_RXACT ((uint32_t)0x00002000) /*!< Data receive in progress */
+#define SDIO_STA_TXFIFOHE ((uint32_t)0x00004000) /*!< Transmit FIFO Half Empty: at least 8 words can be written into the FIFO */
+#define SDIO_STA_RXFIFOHF ((uint32_t)0x00008000) /*!< Receive FIFO Half Full: there are at least 8 words in the FIFO */
+#define SDIO_STA_TXFIFOF ((uint32_t)0x00010000) /*!< Transmit FIFO full */
+#define SDIO_STA_RXFIFOF ((uint32_t)0x00020000) /*!< Receive FIFO full */
+#define SDIO_STA_TXFIFOE ((uint32_t)0x00040000) /*!< Transmit FIFO empty */
+#define SDIO_STA_RXFIFOE ((uint32_t)0x00080000) /*!< Receive FIFO empty */
+#define SDIO_STA_TXDAVL ((uint32_t)0x00100000) /*!< Data available in transmit FIFO */
+#define SDIO_STA_RXDAVL ((uint32_t)0x00200000) /*!< Data available in receive FIFO */
+#define SDIO_STA_SDIOIT ((uint32_t)0x00400000) /*!< SDIO interrupt received */
+#define SDIO_STA_CEATAEND ((uint32_t)0x00800000) /*!< CE-ATA command completion signal received for CMD61 */
+
+/******************* Bit definition for SDIO_ICR register *******************/
+#define SDIO_ICR_CCRCFAILC ((uint32_t)0x00000001) /*!< CCRCFAIL flag clear bit */
+#define SDIO_ICR_DCRCFAILC ((uint32_t)0x00000002) /*!< DCRCFAIL flag clear bit */
+#define SDIO_ICR_CTIMEOUTC ((uint32_t)0x00000004) /*!< CTIMEOUT flag clear bit */
+#define SDIO_ICR_DTIMEOUTC ((uint32_t)0x00000008) /*!< DTIMEOUT flag clear bit */
+#define SDIO_ICR_TXUNDERRC ((uint32_t)0x00000010) /*!< TXUNDERR flag clear bit */
+#define SDIO_ICR_RXOVERRC ((uint32_t)0x00000020) /*!< RXOVERR flag clear bit */
+#define SDIO_ICR_CMDRENDC ((uint32_t)0x00000040) /*!< CMDREND flag clear bit */
+#define SDIO_ICR_CMDSENTC ((uint32_t)0x00000080) /*!< CMDSENT flag clear bit */
+#define SDIO_ICR_DATAENDC ((uint32_t)0x00000100) /*!< DATAEND flag clear bit */
+#define SDIO_ICR_STBITERRC ((uint32_t)0x00000200) /*!< STBITERR flag clear bit */
+#define SDIO_ICR_DBCKENDC ((uint32_t)0x00000400) /*!< DBCKEND flag clear bit */
+#define SDIO_ICR_SDIOITC ((uint32_t)0x00400000) /*!< SDIOIT flag clear bit */
+#define SDIO_ICR_CEATAENDC ((uint32_t)0x00800000) /*!< CEATAEND flag clear bit */
+
+/****************** Bit definition for SDIO_MASK register *******************/
+#define SDIO_MASK_CCRCFAILIE ((uint32_t)0x00000001) /*!< Command CRC Fail Interrupt Enable */
+#define SDIO_MASK_DCRCFAILIE ((uint32_t)0x00000002) /*!< Data CRC Fail Interrupt Enable */
+#define SDIO_MASK_CTIMEOUTIE ((uint32_t)0x00000004) /*!< Command TimeOut Interrupt Enable */
+#define SDIO_MASK_DTIMEOUTIE ((uint32_t)0x00000008) /*!< Data TimeOut Interrupt Enable */
+#define SDIO_MASK_TXUNDERRIE ((uint32_t)0x00000010) /*!< Tx FIFO UnderRun Error Interrupt Enable */
+#define SDIO_MASK_RXOVERRIE ((uint32_t)0x00000020) /*!< Rx FIFO OverRun Error Interrupt Enable */
+#define SDIO_MASK_CMDRENDIE ((uint32_t)0x00000040) /*!< Command Response Received Interrupt Enable */
+#define SDIO_MASK_CMDSENTIE ((uint32_t)0x00000080) /*!< Command Sent Interrupt Enable */
+#define SDIO_MASK_DATAENDIE ((uint32_t)0x00000100) /*!< Data End Interrupt Enable */
+#define SDIO_MASK_STBITERRIE ((uint32_t)0x00000200) /*!< Start Bit Error Interrupt Enable */
+#define SDIO_MASK_DBCKENDIE ((uint32_t)0x00000400) /*!< Data Block End Interrupt Enable */
+#define SDIO_MASK_CMDACTIE ((uint32_t)0x00000800) /*!< Command Acting Interrupt Enable */
+#define SDIO_MASK_TXACTIE ((uint32_t)0x00001000) /*!< Data Transmit Acting Interrupt Enable */
+#define SDIO_MASK_RXACTIE ((uint32_t)0x00002000) /*!< Data receive acting interrupt enabled */
+#define SDIO_MASK_TXFIFOHEIE ((uint32_t)0x00004000) /*!< Tx FIFO Half Empty interrupt Enable */
+#define SDIO_MASK_RXFIFOHFIE ((uint32_t)0x00008000) /*!< Rx FIFO Half Full interrupt Enable */
+#define SDIO_MASK_TXFIFOFIE ((uint32_t)0x00010000) /*!< Tx FIFO Full interrupt Enable */
+#define SDIO_MASK_RXFIFOFIE ((uint32_t)0x00020000) /*!< Rx FIFO Full interrupt Enable */
+#define SDIO_MASK_TXFIFOEIE ((uint32_t)0x00040000) /*!< Tx FIFO Empty interrupt Enable */
+#define SDIO_MASK_RXFIFOEIE ((uint32_t)0x00080000) /*!< Rx FIFO Empty interrupt Enable */
+#define SDIO_MASK_TXDAVLIE ((uint32_t)0x00100000) /*!< Data available in Tx FIFO interrupt Enable */
+#define SDIO_MASK_RXDAVLIE ((uint32_t)0x00200000) /*!< Data available in Rx FIFO interrupt Enable */
+#define SDIO_MASK_SDIOITIE ((uint32_t)0x00400000) /*!< SDIO Mode Interrupt Received interrupt Enable */
+#define SDIO_MASK_CEATAENDIE ((uint32_t)0x00800000) /*!< CE-ATA command completion signal received Interrupt Enable */
+
+/***************** Bit definition for SDIO_FIFOCNT register *****************/
+#define SDIO_FIFOCNT_FIFOCOUNT ((uint32_t)0x00FFFFFF) /*!< Remaining number of words to be written to or read from the FIFO */
+
+/****************** Bit definition for SDIO_FIFO register *******************/
+#define SDIO_FIFO_FIFODATA ((uint32_t)0xFFFFFFFF) /*!< Receive and transmit FIFO data */
+
+/******************************************************************************/
+/* */
+/* USB Device FS */
+/* */
+/******************************************************************************/
+
+/*!< Endpoint-specific registers */
+/******************* Bit definition for USB_EP0R register *******************/
+#define USB_EP0R_EA ((uint16_t)0x000F) /*!< Endpoint Address */
+
+#define USB_EP0R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */
+#define USB_EP0R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define USB_EP0R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */
+
+#define USB_EP0R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */
+#define USB_EP0R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */
+#define USB_EP0R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */
+
+#define USB_EP0R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */
+#define USB_EP0R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */
+#define USB_EP0R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */
+
+#define USB_EP0R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */
+
+#define USB_EP0R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */
+#define USB_EP0R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define USB_EP0R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define USB_EP0R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */
+#define USB_EP0R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */
+
+/******************* Bit definition for USB_EP1R register *******************/
+#define USB_EP1R_EA ((uint16_t)0x000F) /*!< Endpoint Address */
+
+#define USB_EP1R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */
+#define USB_EP1R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define USB_EP1R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */
+
+#define USB_EP1R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */
+#define USB_EP1R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */
+#define USB_EP1R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */
+
+#define USB_EP1R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */
+#define USB_EP1R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */
+#define USB_EP1R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */
+
+#define USB_EP1R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */
+
+#define USB_EP1R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */
+#define USB_EP1R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define USB_EP1R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define USB_EP1R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */
+#define USB_EP1R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */
+
+/******************* Bit definition for USB_EP2R register *******************/
+#define USB_EP2R_EA ((uint16_t)0x000F) /*!< Endpoint Address */
+
+#define USB_EP2R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */
+#define USB_EP2R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define USB_EP2R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */
+
+#define USB_EP2R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */
+#define USB_EP2R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */
+#define USB_EP2R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */
+
+#define USB_EP2R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */
+#define USB_EP2R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */
+#define USB_EP2R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */
+
+#define USB_EP2R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */
+
+#define USB_EP2R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */
+#define USB_EP2R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define USB_EP2R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define USB_EP2R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */
+#define USB_EP2R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */
+
+/******************* Bit definition for USB_EP3R register *******************/
+#define USB_EP3R_EA ((uint16_t)0x000F) /*!< Endpoint Address */
+
+#define USB_EP3R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */
+#define USB_EP3R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define USB_EP3R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */
+
+#define USB_EP3R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */
+#define USB_EP3R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */
+#define USB_EP3R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */
+
+#define USB_EP3R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */
+#define USB_EP3R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */
+#define USB_EP3R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */
+
+#define USB_EP3R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */
+
+#define USB_EP3R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */
+#define USB_EP3R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define USB_EP3R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define USB_EP3R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */
+#define USB_EP3R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */
+
+/******************* Bit definition for USB_EP4R register *******************/
+#define USB_EP4R_EA ((uint16_t)0x000F) /*!< Endpoint Address */
+
+#define USB_EP4R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */
+#define USB_EP4R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define USB_EP4R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */
+
+#define USB_EP4R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */
+#define USB_EP4R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */
+#define USB_EP4R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */
+
+#define USB_EP4R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */
+#define USB_EP4R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */
+#define USB_EP4R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */
+
+#define USB_EP4R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */
+
+#define USB_EP4R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */
+#define USB_EP4R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define USB_EP4R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define USB_EP4R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */
+#define USB_EP4R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */
+
+/******************* Bit definition for USB_EP5R register *******************/
+#define USB_EP5R_EA ((uint16_t)0x000F) /*!< Endpoint Address */
+
+#define USB_EP5R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */
+#define USB_EP5R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define USB_EP5R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */
+
+#define USB_EP5R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */
+#define USB_EP5R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */
+#define USB_EP5R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */
+
+#define USB_EP5R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */
+#define USB_EP5R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */
+#define USB_EP5R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */
+
+#define USB_EP5R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */
+
+#define USB_EP5R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */
+#define USB_EP5R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define USB_EP5R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define USB_EP5R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */
+#define USB_EP5R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */
+
+/******************* Bit definition for USB_EP6R register *******************/
+#define USB_EP6R_EA ((uint16_t)0x000F) /*!< Endpoint Address */
+
+#define USB_EP6R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */
+#define USB_EP6R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define USB_EP6R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */
+
+#define USB_EP6R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */
+#define USB_EP6R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */
+#define USB_EP6R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */
+
+#define USB_EP6R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */
+#define USB_EP6R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */
+#define USB_EP6R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */
+
+#define USB_EP6R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */
+
+#define USB_EP6R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */
+#define USB_EP6R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define USB_EP6R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define USB_EP6R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */
+#define USB_EP6R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */
+
+/******************* Bit definition for USB_EP7R register *******************/
+#define USB_EP7R_EA ((uint16_t)0x000F) /*!< Endpoint Address */
+
+#define USB_EP7R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */
+#define USB_EP7R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define USB_EP7R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */
+
+#define USB_EP7R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */
+#define USB_EP7R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */
+#define USB_EP7R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */
+
+#define USB_EP7R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */
+#define USB_EP7R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */
+#define USB_EP7R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */
+
+#define USB_EP7R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */
+
+#define USB_EP7R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */
+#define USB_EP7R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define USB_EP7R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define USB_EP7R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */
+#define USB_EP7R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */
+
+/*!< Common registers */
+/******************* Bit definition for USB_CNTR register *******************/
+#define USB_CNTR_FRES ((uint16_t)0x0001) /*!< Force USB Reset */
+#define USB_CNTR_PDWN ((uint16_t)0x0002) /*!< Power down */
+#define USB_CNTR_LP_MODE ((uint16_t)0x0004) /*!< Low-power mode */
+#define USB_CNTR_FSUSP ((uint16_t)0x0008) /*!< Force suspend */
+#define USB_CNTR_RESUME ((uint16_t)0x0010) /*!< Resume request */
+#define USB_CNTR_ESOFM ((uint16_t)0x0100) /*!< Expected Start Of Frame Interrupt Mask */
+#define USB_CNTR_SOFM ((uint16_t)0x0200) /*!< Start Of Frame Interrupt Mask */
+#define USB_CNTR_RESETM ((uint16_t)0x0400) /*!< RESET Interrupt Mask */
+#define USB_CNTR_SUSPM ((uint16_t)0x0800) /*!< Suspend mode Interrupt Mask */
+#define USB_CNTR_WKUPM ((uint16_t)0x1000) /*!< Wakeup Interrupt Mask */
+#define USB_CNTR_ERRM ((uint16_t)0x2000) /*!< Error Interrupt Mask */
+#define USB_CNTR_PMAOVRM ((uint16_t)0x4000) /*!< Packet Memory Area Over / Underrun Interrupt Mask */
+#define USB_CNTR_CTRM ((uint16_t)0x8000) /*!< Correct Transfer Interrupt Mask */
+
+/******************* Bit definition for USB_ISTR register *******************/
+#define USB_ISTR_EP_ID ((uint16_t)0x000F) /*!< Endpoint Identifier */
+#define USB_ISTR_DIR ((uint16_t)0x0010) /*!< Direction of transaction */
+#define USB_ISTR_ESOF ((uint16_t)0x0100) /*!< Expected Start Of Frame */
+#define USB_ISTR_SOF ((uint16_t)0x0200) /*!< Start Of Frame */
+#define USB_ISTR_RESET ((uint16_t)0x0400) /*!< USB RESET request */
+#define USB_ISTR_SUSP ((uint16_t)0x0800) /*!< Suspend mode request */
+#define USB_ISTR_WKUP ((uint16_t)0x1000) /*!< Wake up */
+#define USB_ISTR_ERR ((uint16_t)0x2000) /*!< Error */
+#define USB_ISTR_PMAOVR ((uint16_t)0x4000) /*!< Packet Memory Area Over / Underrun */
+#define USB_ISTR_CTR ((uint16_t)0x8000) /*!< Correct Transfer */
+
+/******************* Bit definition for USB_FNR register ********************/
+#define USB_FNR_FN ((uint16_t)0x07FF) /*!< Frame Number */
+#define USB_FNR_LSOF ((uint16_t)0x1800) /*!< Lost SOF */
+#define USB_FNR_LCK ((uint16_t)0x2000) /*!< Locked */
+#define USB_FNR_RXDM ((uint16_t)0x4000) /*!< Receive Data - Line Status */
+#define USB_FNR_RXDP ((uint16_t)0x8000) /*!< Receive Data + Line Status */
+
+/****************** Bit definition for USB_DADDR register *******************/
+#define USB_DADDR_ADD ((uint8_t)0x7F) /*!< ADD[6:0] bits (Device Address) */
+#define USB_DADDR_ADD0 ((uint8_t)0x01) /*!< Bit 0 */
+#define USB_DADDR_ADD1 ((uint8_t)0x02) /*!< Bit 1 */
+#define USB_DADDR_ADD2 ((uint8_t)0x04) /*!< Bit 2 */
+#define USB_DADDR_ADD3 ((uint8_t)0x08) /*!< Bit 3 */
+#define USB_DADDR_ADD4 ((uint8_t)0x10) /*!< Bit 4 */
+#define USB_DADDR_ADD5 ((uint8_t)0x20) /*!< Bit 5 */
+#define USB_DADDR_ADD6 ((uint8_t)0x40) /*!< Bit 6 */
+
+#define USB_DADDR_EF ((uint8_t)0x80) /*!< Enable Function */
+
+/****************** Bit definition for USB_BTABLE register ******************/
+#define USB_BTABLE_BTABLE ((uint16_t)0xFFF8) /*!< Buffer Table */
+
+/*!< Buffer descriptor table */
+/***************** Bit definition for USB_ADDR0_TX register *****************/
+#define USB_ADDR0_TX_ADDR0_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 0 */
+
+/***************** Bit definition for USB_ADDR1_TX register *****************/
+#define USB_ADDR1_TX_ADDR1_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 1 */
+
+/***************** Bit definition for USB_ADDR2_TX register *****************/
+#define USB_ADDR2_TX_ADDR2_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 2 */
+
+/***************** Bit definition for USB_ADDR3_TX register *****************/
+#define USB_ADDR3_TX_ADDR3_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 3 */
+
+/***************** Bit definition for USB_ADDR4_TX register *****************/
+#define USB_ADDR4_TX_ADDR4_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 4 */
+
+/***************** Bit definition for USB_ADDR5_TX register *****************/
+#define USB_ADDR5_TX_ADDR5_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 5 */
+
+/***************** Bit definition for USB_ADDR6_TX register *****************/
+#define USB_ADDR6_TX_ADDR6_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 6 */
+
+/***************** Bit definition for USB_ADDR7_TX register *****************/
+#define USB_ADDR7_TX_ADDR7_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 7 */
+
+/*----------------------------------------------------------------------------*/
+
+/***************** Bit definition for USB_COUNT0_TX register ****************/
+#define USB_COUNT0_TX_COUNT0_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 0 */
+
+/***************** Bit definition for USB_COUNT1_TX register ****************/
+#define USB_COUNT1_TX_COUNT1_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 1 */
+
+/***************** Bit definition for USB_COUNT2_TX register ****************/
+#define USB_COUNT2_TX_COUNT2_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 2 */
+
+/***************** Bit definition for USB_COUNT3_TX register ****************/
+#define USB_COUNT3_TX_COUNT3_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 3 */
+
+/***************** Bit definition for USB_COUNT4_TX register ****************/
+#define USB_COUNT4_TX_COUNT4_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 4 */
+
+/***************** Bit definition for USB_COUNT5_TX register ****************/
+#define USB_COUNT5_TX_COUNT5_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 5 */
+
+/***************** Bit definition for USB_COUNT6_TX register ****************/
+#define USB_COUNT6_TX_COUNT6_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 6 */
+
+/***************** Bit definition for USB_COUNT7_TX register ****************/
+#define USB_COUNT7_TX_COUNT7_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 7 */
+
+/*----------------------------------------------------------------------------*/
+
+/**************** Bit definition for USB_COUNT0_TX_0 register ***************/
+#define USB_COUNT0_TX_0_COUNT0_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 0 (low) */
+
+/**************** Bit definition for USB_COUNT0_TX_1 register ***************/
+#define USB_COUNT0_TX_1_COUNT0_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 0 (high) */
+
+/**************** Bit definition for USB_COUNT1_TX_0 register ***************/
+#define USB_COUNT1_TX_0_COUNT1_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 1 (low) */
+
+/**************** Bit definition for USB_COUNT1_TX_1 register ***************/
+#define USB_COUNT1_TX_1_COUNT1_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 1 (high) */
+
+/**************** Bit definition for USB_COUNT2_TX_0 register ***************/
+#define USB_COUNT2_TX_0_COUNT2_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 2 (low) */
+
+/**************** Bit definition for USB_COUNT2_TX_1 register ***************/
+#define USB_COUNT2_TX_1_COUNT2_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 2 (high) */
+
+/**************** Bit definition for USB_COUNT3_TX_0 register ***************/
+#define USB_COUNT3_TX_0_COUNT3_TX_0 ((uint16_t)0x000003FF) /*!< Transmission Byte Count 3 (low) */
+
+/**************** Bit definition for USB_COUNT3_TX_1 register ***************/
+#define USB_COUNT3_TX_1_COUNT3_TX_1 ((uint16_t)0x03FF0000) /*!< Transmission Byte Count 3 (high) */
+
+/**************** Bit definition for USB_COUNT4_TX_0 register ***************/
+#define USB_COUNT4_TX_0_COUNT4_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 4 (low) */
+
+/**************** Bit definition for USB_COUNT4_TX_1 register ***************/
+#define USB_COUNT4_TX_1_COUNT4_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 4 (high) */
+
+/**************** Bit definition for USB_COUNT5_TX_0 register ***************/
+#define USB_COUNT5_TX_0_COUNT5_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 5 (low) */
+
+/**************** Bit definition for USB_COUNT5_TX_1 register ***************/
+#define USB_COUNT5_TX_1_COUNT5_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 5 (high) */
+
+/**************** Bit definition for USB_COUNT6_TX_0 register ***************/
+#define USB_COUNT6_TX_0_COUNT6_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 6 (low) */
+
+/**************** Bit definition for USB_COUNT6_TX_1 register ***************/
+#define USB_COUNT6_TX_1_COUNT6_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 6 (high) */
+
+/**************** Bit definition for USB_COUNT7_TX_0 register ***************/
+#define USB_COUNT7_TX_0_COUNT7_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 7 (low) */
+
+/**************** Bit definition for USB_COUNT7_TX_1 register ***************/
+#define USB_COUNT7_TX_1_COUNT7_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 7 (high) */
+
+/*----------------------------------------------------------------------------*/
+
+/***************** Bit definition for USB_ADDR0_RX register *****************/
+#define USB_ADDR0_RX_ADDR0_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 0 */
+
+/***************** Bit definition for USB_ADDR1_RX register *****************/
+#define USB_ADDR1_RX_ADDR1_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 1 */
+
+/***************** Bit definition for USB_ADDR2_RX register *****************/
+#define USB_ADDR2_RX_ADDR2_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 2 */
+
+/***************** Bit definition for USB_ADDR3_RX register *****************/
+#define USB_ADDR3_RX_ADDR3_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 3 */
+
+/***************** Bit definition for USB_ADDR4_RX register *****************/
+#define USB_ADDR4_RX_ADDR4_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 4 */
+
+/***************** Bit definition for USB_ADDR5_RX register *****************/
+#define USB_ADDR5_RX_ADDR5_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 5 */
+
+/***************** Bit definition for USB_ADDR6_RX register *****************/
+#define USB_ADDR6_RX_ADDR6_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 6 */
+
+/***************** Bit definition for USB_ADDR7_RX register *****************/
+#define USB_ADDR7_RX_ADDR7_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 7 */
+
+/*----------------------------------------------------------------------------*/
+
+/***************** Bit definition for USB_COUNT0_RX register ****************/
+#define USB_COUNT0_RX_COUNT0_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */
+
+#define USB_COUNT0_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */
+#define USB_COUNT0_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define USB_COUNT0_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */
+#define USB_COUNT0_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */
+#define USB_COUNT0_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */
+#define USB_COUNT0_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */
+
+#define USB_COUNT0_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */
+
+/***************** Bit definition for USB_COUNT1_RX register ****************/
+#define USB_COUNT1_RX_COUNT1_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */
+
+#define USB_COUNT1_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */
+#define USB_COUNT1_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define USB_COUNT1_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */
+#define USB_COUNT1_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */
+#define USB_COUNT1_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */
+#define USB_COUNT1_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */
+
+#define USB_COUNT1_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */
+
+/***************** Bit definition for USB_COUNT2_RX register ****************/
+#define USB_COUNT2_RX_COUNT2_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */
+
+#define USB_COUNT2_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */
+#define USB_COUNT2_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define USB_COUNT2_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */
+#define USB_COUNT2_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */
+#define USB_COUNT2_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */
+#define USB_COUNT2_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */
+
+#define USB_COUNT2_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */
+
+/***************** Bit definition for USB_COUNT3_RX register ****************/
+#define USB_COUNT3_RX_COUNT3_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */
+
+#define USB_COUNT3_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */
+#define USB_COUNT3_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define USB_COUNT3_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */
+#define USB_COUNT3_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */
+#define USB_COUNT3_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */
+#define USB_COUNT3_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */
+
+#define USB_COUNT3_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */
+
+/***************** Bit definition for USB_COUNT4_RX register ****************/
+#define USB_COUNT4_RX_COUNT4_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */
+
+#define USB_COUNT4_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */
+#define USB_COUNT4_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define USB_COUNT4_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */
+#define USB_COUNT4_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */
+#define USB_COUNT4_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */
+#define USB_COUNT4_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */
+
+#define USB_COUNT4_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */
+
+/***************** Bit definition for USB_COUNT5_RX register ****************/
+#define USB_COUNT5_RX_COUNT5_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */
+
+#define USB_COUNT5_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */
+#define USB_COUNT5_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define USB_COUNT5_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */
+#define USB_COUNT5_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */
+#define USB_COUNT5_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */
+#define USB_COUNT5_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */
+
+#define USB_COUNT5_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */
+
+/***************** Bit definition for USB_COUNT6_RX register ****************/
+#define USB_COUNT6_RX_COUNT6_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */
+
+#define USB_COUNT6_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */
+#define USB_COUNT6_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define USB_COUNT6_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */
+#define USB_COUNT6_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */
+#define USB_COUNT6_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */
+#define USB_COUNT6_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */
+
+#define USB_COUNT6_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */
+
+/***************** Bit definition for USB_COUNT7_RX register ****************/
+#define USB_COUNT7_RX_COUNT7_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */
+
+#define USB_COUNT7_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */
+#define USB_COUNT7_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */
+#define USB_COUNT7_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */
+#define USB_COUNT7_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */
+#define USB_COUNT7_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */
+#define USB_COUNT7_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */
+
+#define USB_COUNT7_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */
+
+/*----------------------------------------------------------------------------*/
+
+/**************** Bit definition for USB_COUNT0_RX_0 register ***************/
+#define USB_COUNT0_RX_0_COUNT0_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */
+
+#define USB_COUNT0_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */
+#define USB_COUNT0_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define USB_COUNT0_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define USB_COUNT0_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define USB_COUNT0_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define USB_COUNT0_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define USB_COUNT0_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */
+
+/**************** Bit definition for USB_COUNT0_RX_1 register ***************/
+#define USB_COUNT0_RX_1_COUNT0_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */
+
+#define USB_COUNT0_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */
+#define USB_COUNT0_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 1 */
+#define USB_COUNT0_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */
+#define USB_COUNT0_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */
+#define USB_COUNT0_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */
+#define USB_COUNT0_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */
+
+#define USB_COUNT0_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */
+
+/**************** Bit definition for USB_COUNT1_RX_0 register ***************/
+#define USB_COUNT1_RX_0_COUNT1_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */
+
+#define USB_COUNT1_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */
+#define USB_COUNT1_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define USB_COUNT1_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define USB_COUNT1_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define USB_COUNT1_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define USB_COUNT1_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define USB_COUNT1_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */
+
+/**************** Bit definition for USB_COUNT1_RX_1 register ***************/
+#define USB_COUNT1_RX_1_COUNT1_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */
+
+#define USB_COUNT1_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */
+#define USB_COUNT1_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */
+#define USB_COUNT1_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */
+#define USB_COUNT1_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */
+#define USB_COUNT1_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */
+#define USB_COUNT1_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */
+
+#define USB_COUNT1_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */
+
+/**************** Bit definition for USB_COUNT2_RX_0 register ***************/
+#define USB_COUNT2_RX_0_COUNT2_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */
+
+#define USB_COUNT2_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */
+#define USB_COUNT2_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define USB_COUNT2_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define USB_COUNT2_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define USB_COUNT2_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define USB_COUNT2_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define USB_COUNT2_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */
+
+/**************** Bit definition for USB_COUNT2_RX_1 register ***************/
+#define USB_COUNT2_RX_1_COUNT2_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */
+
+#define USB_COUNT2_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */
+#define USB_COUNT2_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */
+#define USB_COUNT2_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */
+#define USB_COUNT2_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */
+#define USB_COUNT2_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */
+#define USB_COUNT2_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */
+
+#define USB_COUNT2_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */
+
+/**************** Bit definition for USB_COUNT3_RX_0 register ***************/
+#define USB_COUNT3_RX_0_COUNT3_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */
+
+#define USB_COUNT3_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */
+#define USB_COUNT3_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define USB_COUNT3_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define USB_COUNT3_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define USB_COUNT3_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define USB_COUNT3_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define USB_COUNT3_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */
+
+/**************** Bit definition for USB_COUNT3_RX_1 register ***************/
+#define USB_COUNT3_RX_1_COUNT3_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */
+
+#define USB_COUNT3_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */
+#define USB_COUNT3_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */
+#define USB_COUNT3_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */
+#define USB_COUNT3_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */
+#define USB_COUNT3_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */
+#define USB_COUNT3_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */
+
+#define USB_COUNT3_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */
+
+/**************** Bit definition for USB_COUNT4_RX_0 register ***************/
+#define USB_COUNT4_RX_0_COUNT4_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */
+
+#define USB_COUNT4_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */
+#define USB_COUNT4_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define USB_COUNT4_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define USB_COUNT4_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define USB_COUNT4_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define USB_COUNT4_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define USB_COUNT4_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */
+
+/**************** Bit definition for USB_COUNT4_RX_1 register ***************/
+#define USB_COUNT4_RX_1_COUNT4_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */
+
+#define USB_COUNT4_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */
+#define USB_COUNT4_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */
+#define USB_COUNT4_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */
+#define USB_COUNT4_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */
+#define USB_COUNT4_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */
+#define USB_COUNT4_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */
+
+#define USB_COUNT4_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */
+
+/**************** Bit definition for USB_COUNT5_RX_0 register ***************/
+#define USB_COUNT5_RX_0_COUNT5_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */
+
+#define USB_COUNT5_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */
+#define USB_COUNT5_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define USB_COUNT5_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define USB_COUNT5_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define USB_COUNT5_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define USB_COUNT5_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define USB_COUNT5_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */
+
+/**************** Bit definition for USB_COUNT5_RX_1 register ***************/
+#define USB_COUNT5_RX_1_COUNT5_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */
+
+#define USB_COUNT5_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */
+#define USB_COUNT5_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */
+#define USB_COUNT5_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */
+#define USB_COUNT5_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */
+#define USB_COUNT5_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */
+#define USB_COUNT5_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */
+
+#define USB_COUNT5_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */
+
+/*************** Bit definition for USB_COUNT6_RX_0 register ***************/
+#define USB_COUNT6_RX_0_COUNT6_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */
+
+#define USB_COUNT6_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */
+#define USB_COUNT6_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define USB_COUNT6_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define USB_COUNT6_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define USB_COUNT6_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define USB_COUNT6_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define USB_COUNT6_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */
+
+/**************** Bit definition for USB_COUNT6_RX_1 register ***************/
+#define USB_COUNT6_RX_1_COUNT6_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */
+
+#define USB_COUNT6_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */
+#define USB_COUNT6_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */
+#define USB_COUNT6_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */
+#define USB_COUNT6_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */
+#define USB_COUNT6_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */
+#define USB_COUNT6_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */
+
+#define USB_COUNT6_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */
+
+/*************** Bit definition for USB_COUNT7_RX_0 register ****************/
+#define USB_COUNT7_RX_0_COUNT7_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */
+
+#define USB_COUNT7_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */
+#define USB_COUNT7_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */
+#define USB_COUNT7_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */
+#define USB_COUNT7_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */
+#define USB_COUNT7_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */
+#define USB_COUNT7_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */
+
+#define USB_COUNT7_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */
+
+/*************** Bit definition for USB_COUNT7_RX_1 register ****************/
+#define USB_COUNT7_RX_1_COUNT7_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */
+
+#define USB_COUNT7_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */
+#define USB_COUNT7_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */
+#define USB_COUNT7_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */
+#define USB_COUNT7_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */
+#define USB_COUNT7_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */
+#define USB_COUNT7_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */
+
+#define USB_COUNT7_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */
+
+/******************************************************************************/
+/* */
+/* Controller Area Network */
+/* */
+/******************************************************************************/
+
+/*!< CAN control and status registers */
+/******************* Bit definition for CAN_MCR register ********************/
+#define CAN_MCR_INRQ ((uint16_t)0x0001) /*!< Initialization Request */
+#define CAN_MCR_SLEEP ((uint16_t)0x0002) /*!< Sleep Mode Request */
+#define CAN_MCR_TXFP ((uint16_t)0x0004) /*!< Transmit FIFO Priority */
+#define CAN_MCR_RFLM ((uint16_t)0x0008) /*!< Receive FIFO Locked Mode */
+#define CAN_MCR_NART ((uint16_t)0x0010) /*!< No Automatic Retransmission */
+#define CAN_MCR_AWUM ((uint16_t)0x0020) /*!< Automatic Wakeup Mode */
+#define CAN_MCR_ABOM ((uint16_t)0x0040) /*!< Automatic Bus-Off Management */
+#define CAN_MCR_TTCM ((uint16_t)0x0080) /*!< Time Triggered Communication Mode */
+#define CAN_MCR_RESET ((uint16_t)0x8000) /*!< CAN software master reset */
+
+/******************* Bit definition for CAN_MSR register ********************/
+#define CAN_MSR_INAK ((uint16_t)0x0001) /*!< Initialization Acknowledge */
+#define CAN_MSR_SLAK ((uint16_t)0x0002) /*!< Sleep Acknowledge */
+#define CAN_MSR_ERRI ((uint16_t)0x0004) /*!< Error Interrupt */
+#define CAN_MSR_WKUI ((uint16_t)0x0008) /*!< Wakeup Interrupt */
+#define CAN_MSR_SLAKI ((uint16_t)0x0010) /*!< Sleep Acknowledge Interrupt */
+#define CAN_MSR_TXM ((uint16_t)0x0100) /*!< Transmit Mode */
+#define CAN_MSR_RXM ((uint16_t)0x0200) /*!< Receive Mode */
+#define CAN_MSR_SAMP ((uint16_t)0x0400) /*!< Last Sample Point */
+#define CAN_MSR_RX ((uint16_t)0x0800) /*!< CAN Rx Signal */
+
+/******************* Bit definition for CAN_TSR register ********************/
+#define CAN_TSR_RQCP0 ((uint32_t)0x00000001) /*!< Request Completed Mailbox0 */
+#define CAN_TSR_TXOK0 ((uint32_t)0x00000002) /*!< Transmission OK of Mailbox0 */
+#define CAN_TSR_ALST0 ((uint32_t)0x00000004) /*!< Arbitration Lost for Mailbox0 */
+#define CAN_TSR_TERR0 ((uint32_t)0x00000008) /*!< Transmission Error of Mailbox0 */
+#define CAN_TSR_ABRQ0 ((uint32_t)0x00000080) /*!< Abort Request for Mailbox0 */
+#define CAN_TSR_RQCP1 ((uint32_t)0x00000100) /*!< Request Completed Mailbox1 */
+#define CAN_TSR_TXOK1 ((uint32_t)0x00000200) /*!< Transmission OK of Mailbox1 */
+#define CAN_TSR_ALST1 ((uint32_t)0x00000400) /*!< Arbitration Lost for Mailbox1 */
+#define CAN_TSR_TERR1 ((uint32_t)0x00000800) /*!< Transmission Error of Mailbox1 */
+#define CAN_TSR_ABRQ1 ((uint32_t)0x00008000) /*!< Abort Request for Mailbox 1 */
+#define CAN_TSR_RQCP2 ((uint32_t)0x00010000) /*!< Request Completed Mailbox2 */
+#define CAN_TSR_TXOK2 ((uint32_t)0x00020000) /*!< Transmission OK of Mailbox 2 */
+#define CAN_TSR_ALST2 ((uint32_t)0x00040000) /*!< Arbitration Lost for mailbox 2 */
+#define CAN_TSR_TERR2 ((uint32_t)0x00080000) /*!< Transmission Error of Mailbox 2 */
+#define CAN_TSR_ABRQ2 ((uint32_t)0x00800000) /*!< Abort Request for Mailbox 2 */
+#define CAN_TSR_CODE ((uint32_t)0x03000000) /*!< Mailbox Code */
+
+#define CAN_TSR_TME ((uint32_t)0x1C000000) /*!< TME[2:0] bits */
+#define CAN_TSR_TME0 ((uint32_t)0x04000000) /*!< Transmit Mailbox 0 Empty */
+#define CAN_TSR_TME1 ((uint32_t)0x08000000) /*!< Transmit Mailbox 1 Empty */
+#define CAN_TSR_TME2 ((uint32_t)0x10000000) /*!< Transmit Mailbox 2 Empty */
+
+#define CAN_TSR_LOW ((uint32_t)0xE0000000) /*!< LOW[2:0] bits */
+#define CAN_TSR_LOW0 ((uint32_t)0x20000000) /*!< Lowest Priority Flag for Mailbox 0 */
+#define CAN_TSR_LOW1 ((uint32_t)0x40000000) /*!< Lowest Priority Flag for Mailbox 1 */
+#define CAN_TSR_LOW2 ((uint32_t)0x80000000) /*!< Lowest Priority Flag for Mailbox 2 */
+
+/******************* Bit definition for CAN_RF0R register *******************/
+#define CAN_RF0R_FMP0 ((uint8_t)0x03) /*!< FIFO 0 Message Pending */
+#define CAN_RF0R_FULL0 ((uint8_t)0x08) /*!< FIFO 0 Full */
+#define CAN_RF0R_FOVR0 ((uint8_t)0x10) /*!< FIFO 0 Overrun */
+#define CAN_RF0R_RFOM0 ((uint8_t)0x20) /*!< Release FIFO 0 Output Mailbox */
+
+/******************* Bit definition for CAN_RF1R register *******************/
+#define CAN_RF1R_FMP1 ((uint8_t)0x03) /*!< FIFO 1 Message Pending */
+#define CAN_RF1R_FULL1 ((uint8_t)0x08) /*!< FIFO 1 Full */
+#define CAN_RF1R_FOVR1 ((uint8_t)0x10) /*!< FIFO 1 Overrun */
+#define CAN_RF1R_RFOM1 ((uint8_t)0x20) /*!< Release FIFO 1 Output Mailbox */
+
+/******************** Bit definition for CAN_IER register *******************/
+#define CAN_IER_TMEIE ((uint32_t)0x00000001) /*!< Transmit Mailbox Empty Interrupt Enable */
+#define CAN_IER_FMPIE0 ((uint32_t)0x00000002) /*!< FIFO Message Pending Interrupt Enable */
+#define CAN_IER_FFIE0 ((uint32_t)0x00000004) /*!< FIFO Full Interrupt Enable */
+#define CAN_IER_FOVIE0 ((uint32_t)0x00000008) /*!< FIFO Overrun Interrupt Enable */
+#define CAN_IER_FMPIE1 ((uint32_t)0x00000010) /*!< FIFO Message Pending Interrupt Enable */
+#define CAN_IER_FFIE1 ((uint32_t)0x00000020) /*!< FIFO Full Interrupt Enable */
+#define CAN_IER_FOVIE1 ((uint32_t)0x00000040) /*!< FIFO Overrun Interrupt Enable */
+#define CAN_IER_EWGIE ((uint32_t)0x00000100) /*!< Error Warning Interrupt Enable */
+#define CAN_IER_EPVIE ((uint32_t)0x00000200) /*!< Error Passive Interrupt Enable */
+#define CAN_IER_BOFIE ((uint32_t)0x00000400) /*!< Bus-Off Interrupt Enable */
+#define CAN_IER_LECIE ((uint32_t)0x00000800) /*!< Last Error Code Interrupt Enable */
+#define CAN_IER_ERRIE ((uint32_t)0x00008000) /*!< Error Interrupt Enable */
+#define CAN_IER_WKUIE ((uint32_t)0x00010000) /*!< Wakeup Interrupt Enable */
+#define CAN_IER_SLKIE ((uint32_t)0x00020000) /*!< Sleep Interrupt Enable */
+
+/******************** Bit definition for CAN_ESR register *******************/
+#define CAN_ESR_EWGF ((uint32_t)0x00000001) /*!< Error Warning Flag */
+#define CAN_ESR_EPVF ((uint32_t)0x00000002) /*!< Error Passive Flag */
+#define CAN_ESR_BOFF ((uint32_t)0x00000004) /*!< Bus-Off Flag */
+
+#define CAN_ESR_LEC ((uint32_t)0x00000070) /*!< LEC[2:0] bits (Last Error Code) */
+#define CAN_ESR_LEC_0 ((uint32_t)0x00000010) /*!< Bit 0 */
+#define CAN_ESR_LEC_1 ((uint32_t)0x00000020) /*!< Bit 1 */
+#define CAN_ESR_LEC_2 ((uint32_t)0x00000040) /*!< Bit 2 */
+
+#define CAN_ESR_TEC ((uint32_t)0x00FF0000) /*!< Least significant byte of the 9-bit Transmit Error Counter */
+#define CAN_ESR_REC ((uint32_t)0xFF000000) /*!< Receive Error Counter */
+
+/******************* Bit definition for CAN_BTR register ********************/
+#define CAN_BTR_BRP ((uint32_t)0x000003FF) /*!< Baud Rate Prescaler */
+#define CAN_BTR_TS1 ((uint32_t)0x000F0000) /*!< Time Segment 1 */
+#define CAN_BTR_TS2 ((uint32_t)0x00700000) /*!< Time Segment 2 */
+#define CAN_BTR_SJW ((uint32_t)0x03000000) /*!< Resynchronization Jump Width */
+#define CAN_BTR_LBKM ((uint32_t)0x40000000) /*!< Loop Back Mode (Debug) */
+#define CAN_BTR_SILM ((uint32_t)0x80000000) /*!< Silent Mode */
+
+/*!< Mailbox registers */
+/****************** Bit definition for CAN_TI0R register ********************/
+#define CAN_TI0R_TXRQ ((uint32_t)0x00000001) /*!< Transmit Mailbox Request */
+#define CAN_TI0R_RTR ((uint32_t)0x00000002) /*!< Remote Transmission Request */
+#define CAN_TI0R_IDE ((uint32_t)0x00000004) /*!< Identifier Extension */
+#define CAN_TI0R_EXID ((uint32_t)0x001FFFF8) /*!< Extended Identifier */
+#define CAN_TI0R_STID ((uint32_t)0xFFE00000) /*!< Standard Identifier or Extended Identifier */
+
+/****************** Bit definition for CAN_TDT0R register *******************/
+#define CAN_TDT0R_DLC ((uint32_t)0x0000000F) /*!< Data Length Code */
+#define CAN_TDT0R_TGT ((uint32_t)0x00000100) /*!< Transmit Global Time */
+#define CAN_TDT0R_TIME ((uint32_t)0xFFFF0000) /*!< Message Time Stamp */
+
+/****************** Bit definition for CAN_TDL0R register *******************/
+#define CAN_TDL0R_DATA0 ((uint32_t)0x000000FF) /*!< Data byte 0 */
+#define CAN_TDL0R_DATA1 ((uint32_t)0x0000FF00) /*!< Data byte 1 */
+#define CAN_TDL0R_DATA2 ((uint32_t)0x00FF0000) /*!< Data byte 2 */
+#define CAN_TDL0R_DATA3 ((uint32_t)0xFF000000) /*!< Data byte 3 */
+
+/****************** Bit definition for CAN_TDH0R register *******************/
+#define CAN_TDH0R_DATA4 ((uint32_t)0x000000FF) /*!< Data byte 4 */
+#define CAN_TDH0R_DATA5 ((uint32_t)0x0000FF00) /*!< Data byte 5 */
+#define CAN_TDH0R_DATA6 ((uint32_t)0x00FF0000) /*!< Data byte 6 */
+#define CAN_TDH0R_DATA7 ((uint32_t)0xFF000000) /*!< Data byte 7 */
+
+/******************* Bit definition for CAN_TI1R register *******************/
+#define CAN_TI1R_TXRQ ((uint32_t)0x00000001) /*!< Transmit Mailbox Request */
+#define CAN_TI1R_RTR ((uint32_t)0x00000002) /*!< Remote Transmission Request */
+#define CAN_TI1R_IDE ((uint32_t)0x00000004) /*!< Identifier Extension */
+#define CAN_TI1R_EXID ((uint32_t)0x001FFFF8) /*!< Extended Identifier */
+#define CAN_TI1R_STID ((uint32_t)0xFFE00000) /*!< Standard Identifier or Extended Identifier */
+
+/******************* Bit definition for CAN_TDT1R register ******************/
+#define CAN_TDT1R_DLC ((uint32_t)0x0000000F) /*!< Data Length Code */
+#define CAN_TDT1R_TGT ((uint32_t)0x00000100) /*!< Transmit Global Time */
+#define CAN_TDT1R_TIME ((uint32_t)0xFFFF0000) /*!< Message Time Stamp */
+
+/******************* Bit definition for CAN_TDL1R register ******************/
+#define CAN_TDL1R_DATA0 ((uint32_t)0x000000FF) /*!< Data byte 0 */
+#define CAN_TDL1R_DATA1 ((uint32_t)0x0000FF00) /*!< Data byte 1 */
+#define CAN_TDL1R_DATA2 ((uint32_t)0x00FF0000) /*!< Data byte 2 */
+#define CAN_TDL1R_DATA3 ((uint32_t)0xFF000000) /*!< Data byte 3 */
+
+/******************* Bit definition for CAN_TDH1R register ******************/
+#define CAN_TDH1R_DATA4 ((uint32_t)0x000000FF) /*!< Data byte 4 */
+#define CAN_TDH1R_DATA5 ((uint32_t)0x0000FF00) /*!< Data byte 5 */
+#define CAN_TDH1R_DATA6 ((uint32_t)0x00FF0000) /*!< Data byte 6 */
+#define CAN_TDH1R_DATA7 ((uint32_t)0xFF000000) /*!< Data byte 7 */
+
+/******************* Bit definition for CAN_TI2R register *******************/
+#define CAN_TI2R_TXRQ ((uint32_t)0x00000001) /*!< Transmit Mailbox Request */
+#define CAN_TI2R_RTR ((uint32_t)0x00000002) /*!< Remote Transmission Request */
+#define CAN_TI2R_IDE ((uint32_t)0x00000004) /*!< Identifier Extension */
+#define CAN_TI2R_EXID ((uint32_t)0x001FFFF8) /*!< Extended identifier */
+#define CAN_TI2R_STID ((uint32_t)0xFFE00000) /*!< Standard Identifier or Extended Identifier */
+
+/******************* Bit definition for CAN_TDT2R register ******************/
+#define CAN_TDT2R_DLC ((uint32_t)0x0000000F) /*!< Data Length Code */
+#define CAN_TDT2R_TGT ((uint32_t)0x00000100) /*!< Transmit Global Time */
+#define CAN_TDT2R_TIME ((uint32_t)0xFFFF0000) /*!< Message Time Stamp */
+
+/******************* Bit definition for CAN_TDL2R register ******************/
+#define CAN_TDL2R_DATA0 ((uint32_t)0x000000FF) /*!< Data byte 0 */
+#define CAN_TDL2R_DATA1 ((uint32_t)0x0000FF00) /*!< Data byte 1 */
+#define CAN_TDL2R_DATA2 ((uint32_t)0x00FF0000) /*!< Data byte 2 */
+#define CAN_TDL2R_DATA3 ((uint32_t)0xFF000000) /*!< Data byte 3 */
+
+/******************* Bit definition for CAN_TDH2R register ******************/
+#define CAN_TDH2R_DATA4 ((uint32_t)0x000000FF) /*!< Data byte 4 */
+#define CAN_TDH2R_DATA5 ((uint32_t)0x0000FF00) /*!< Data byte 5 */
+#define CAN_TDH2R_DATA6 ((uint32_t)0x00FF0000) /*!< Data byte 6 */
+#define CAN_TDH2R_DATA7 ((uint32_t)0xFF000000) /*!< Data byte 7 */
+
+/******************* Bit definition for CAN_RI0R register *******************/
+#define CAN_RI0R_RTR ((uint32_t)0x00000002) /*!< Remote Transmission Request */
+#define CAN_RI0R_IDE ((uint32_t)0x00000004) /*!< Identifier Extension */
+#define CAN_RI0R_EXID ((uint32_t)0x001FFFF8) /*!< Extended Identifier */
+#define CAN_RI0R_STID ((uint32_t)0xFFE00000) /*!< Standard Identifier or Extended Identifier */
+
+/******************* Bit definition for CAN_RDT0R register ******************/
+#define CAN_RDT0R_DLC ((uint32_t)0x0000000F) /*!< Data Length Code */
+#define CAN_RDT0R_FMI ((uint32_t)0x0000FF00) /*!< Filter Match Index */
+#define CAN_RDT0R_TIME ((uint32_t)0xFFFF0000) /*!< Message Time Stamp */
+
+/******************* Bit definition for CAN_RDL0R register ******************/
+#define CAN_RDL0R_DATA0 ((uint32_t)0x000000FF) /*!< Data byte 0 */
+#define CAN_RDL0R_DATA1 ((uint32_t)0x0000FF00) /*!< Data byte 1 */
+#define CAN_RDL0R_DATA2 ((uint32_t)0x00FF0000) /*!< Data byte 2 */
+#define CAN_RDL0R_DATA3 ((uint32_t)0xFF000000) /*!< Data byte 3 */
+
+/******************* Bit definition for CAN_RDH0R register ******************/
+#define CAN_RDH0R_DATA4 ((uint32_t)0x000000FF) /*!< Data byte 4 */
+#define CAN_RDH0R_DATA5 ((uint32_t)0x0000FF00) /*!< Data byte 5 */
+#define CAN_RDH0R_DATA6 ((uint32_t)0x00FF0000) /*!< Data byte 6 */
+#define CAN_RDH0R_DATA7 ((uint32_t)0xFF000000) /*!< Data byte 7 */
+
+/******************* Bit definition for CAN_RI1R register *******************/
+#define CAN_RI1R_RTR ((uint32_t)0x00000002) /*!< Remote Transmission Request */
+#define CAN_RI1R_IDE ((uint32_t)0x00000004) /*!< Identifier Extension */
+#define CAN_RI1R_EXID ((uint32_t)0x001FFFF8) /*!< Extended identifier */
+#define CAN_RI1R_STID ((uint32_t)0xFFE00000) /*!< Standard Identifier or Extended Identifier */
+
+/******************* Bit definition for CAN_RDT1R register ******************/
+#define CAN_RDT1R_DLC ((uint32_t)0x0000000F) /*!< Data Length Code */
+#define CAN_RDT1R_FMI ((uint32_t)0x0000FF00) /*!< Filter Match Index */
+#define CAN_RDT1R_TIME ((uint32_t)0xFFFF0000) /*!< Message Time Stamp */
+
+/******************* Bit definition for CAN_RDL1R register ******************/
+#define CAN_RDL1R_DATA0 ((uint32_t)0x000000FF) /*!< Data byte 0 */
+#define CAN_RDL1R_DATA1 ((uint32_t)0x0000FF00) /*!< Data byte 1 */
+#define CAN_RDL1R_DATA2 ((uint32_t)0x00FF0000) /*!< Data byte 2 */
+#define CAN_RDL1R_DATA3 ((uint32_t)0xFF000000) /*!< Data byte 3 */
+
+/******************* Bit definition for CAN_RDH1R register ******************/
+#define CAN_RDH1R_DATA4 ((uint32_t)0x000000FF) /*!< Data byte 4 */
+#define CAN_RDH1R_DATA5 ((uint32_t)0x0000FF00) /*!< Data byte 5 */
+#define CAN_RDH1R_DATA6 ((uint32_t)0x00FF0000) /*!< Data byte 6 */
+#define CAN_RDH1R_DATA7 ((uint32_t)0xFF000000) /*!< Data byte 7 */
+
+/*!< CAN filter registers */
+/******************* Bit definition for CAN_FMR register ********************/
+#define CAN_FMR_FINIT ((uint8_t)0x01) /*!< Filter Init Mode */
+
+/******************* Bit definition for CAN_FM1R register *******************/
+#define CAN_FM1R_FBM ((uint16_t)0x3FFF) /*!< Filter Mode */
+#define CAN_FM1R_FBM0 ((uint16_t)0x0001) /*!< Filter Init Mode bit 0 */
+#define CAN_FM1R_FBM1 ((uint16_t)0x0002) /*!< Filter Init Mode bit 1 */
+#define CAN_FM1R_FBM2 ((uint16_t)0x0004) /*!< Filter Init Mode bit 2 */
+#define CAN_FM1R_FBM3 ((uint16_t)0x0008) /*!< Filter Init Mode bit 3 */
+#define CAN_FM1R_FBM4 ((uint16_t)0x0010) /*!< Filter Init Mode bit 4 */
+#define CAN_FM1R_FBM5 ((uint16_t)0x0020) /*!< Filter Init Mode bit 5 */
+#define CAN_FM1R_FBM6 ((uint16_t)0x0040) /*!< Filter Init Mode bit 6 */
+#define CAN_FM1R_FBM7 ((uint16_t)0x0080) /*!< Filter Init Mode bit 7 */
+#define CAN_FM1R_FBM8 ((uint16_t)0x0100) /*!< Filter Init Mode bit 8 */
+#define CAN_FM1R_FBM9 ((uint16_t)0x0200) /*!< Filter Init Mode bit 9 */
+#define CAN_FM1R_FBM10 ((uint16_t)0x0400) /*!< Filter Init Mode bit 10 */
+#define CAN_FM1R_FBM11 ((uint16_t)0x0800) /*!< Filter Init Mode bit 11 */
+#define CAN_FM1R_FBM12 ((uint16_t)0x1000) /*!< Filter Init Mode bit 12 */
+#define CAN_FM1R_FBM13 ((uint16_t)0x2000) /*!< Filter Init Mode bit 13 */
+
+/******************* Bit definition for CAN_FS1R register *******************/
+#define CAN_FS1R_FSC ((uint16_t)0x3FFF) /*!< Filter Scale Configuration */
+#define CAN_FS1R_FSC0 ((uint16_t)0x0001) /*!< Filter Scale Configuration bit 0 */
+#define CAN_FS1R_FSC1 ((uint16_t)0x0002) /*!< Filter Scale Configuration bit 1 */
+#define CAN_FS1R_FSC2 ((uint16_t)0x0004) /*!< Filter Scale Configuration bit 2 */
+#define CAN_FS1R_FSC3 ((uint16_t)0x0008) /*!< Filter Scale Configuration bit 3 */
+#define CAN_FS1R_FSC4 ((uint16_t)0x0010) /*!< Filter Scale Configuration bit 4 */
+#define CAN_FS1R_FSC5 ((uint16_t)0x0020) /*!< Filter Scale Configuration bit 5 */
+#define CAN_FS1R_FSC6 ((uint16_t)0x0040) /*!< Filter Scale Configuration bit 6 */
+#define CAN_FS1R_FSC7 ((uint16_t)0x0080) /*!< Filter Scale Configuration bit 7 */
+#define CAN_FS1R_FSC8 ((uint16_t)0x0100) /*!< Filter Scale Configuration bit 8 */
+#define CAN_FS1R_FSC9 ((uint16_t)0x0200) /*!< Filter Scale Configuration bit 9 */
+#define CAN_FS1R_FSC10 ((uint16_t)0x0400) /*!< Filter Scale Configuration bit 10 */
+#define CAN_FS1R_FSC11 ((uint16_t)0x0800) /*!< Filter Scale Configuration bit 11 */
+#define CAN_FS1R_FSC12 ((uint16_t)0x1000) /*!< Filter Scale Configuration bit 12 */
+#define CAN_FS1R_FSC13 ((uint16_t)0x2000) /*!< Filter Scale Configuration bit 13 */
+
+/****************** Bit definition for CAN_FFA1R register *******************/
+#define CAN_FFA1R_FFA ((uint16_t)0x3FFF) /*!< Filter FIFO Assignment */
+#define CAN_FFA1R_FFA0 ((uint16_t)0x0001) /*!< Filter FIFO Assignment for Filter 0 */
+#define CAN_FFA1R_FFA1 ((uint16_t)0x0002) /*!< Filter FIFO Assignment for Filter 1 */
+#define CAN_FFA1R_FFA2 ((uint16_t)0x0004) /*!< Filter FIFO Assignment for Filter 2 */
+#define CAN_FFA1R_FFA3 ((uint16_t)0x0008) /*!< Filter FIFO Assignment for Filter 3 */
+#define CAN_FFA1R_FFA4 ((uint16_t)0x0010) /*!< Filter FIFO Assignment for Filter 4 */
+#define CAN_FFA1R_FFA5 ((uint16_t)0x0020) /*!< Filter FIFO Assignment for Filter 5 */
+#define CAN_FFA1R_FFA6 ((uint16_t)0x0040) /*!< Filter FIFO Assignment for Filter 6 */
+#define CAN_FFA1R_FFA7 ((uint16_t)0x0080) /*!< Filter FIFO Assignment for Filter 7 */
+#define CAN_FFA1R_FFA8 ((uint16_t)0x0100) /*!< Filter FIFO Assignment for Filter 8 */
+#define CAN_FFA1R_FFA9 ((uint16_t)0x0200) /*!< Filter FIFO Assignment for Filter 9 */
+#define CAN_FFA1R_FFA10 ((uint16_t)0x0400) /*!< Filter FIFO Assignment for Filter 10 */
+#define CAN_FFA1R_FFA11 ((uint16_t)0x0800) /*!< Filter FIFO Assignment for Filter 11 */
+#define CAN_FFA1R_FFA12 ((uint16_t)0x1000) /*!< Filter FIFO Assignment for Filter 12 */
+#define CAN_FFA1R_FFA13 ((uint16_t)0x2000) /*!< Filter FIFO Assignment for Filter 13 */
+
+/******************* Bit definition for CAN_FA1R register *******************/
+#define CAN_FA1R_FACT ((uint16_t)0x3FFF) /*!< Filter Active */
+#define CAN_FA1R_FACT0 ((uint16_t)0x0001) /*!< Filter 0 Active */
+#define CAN_FA1R_FACT1 ((uint16_t)0x0002) /*!< Filter 1 Active */
+#define CAN_FA1R_FACT2 ((uint16_t)0x0004) /*!< Filter 2 Active */
+#define CAN_FA1R_FACT3 ((uint16_t)0x0008) /*!< Filter 3 Active */
+#define CAN_FA1R_FACT4 ((uint16_t)0x0010) /*!< Filter 4 Active */
+#define CAN_FA1R_FACT5 ((uint16_t)0x0020) /*!< Filter 5 Active */
+#define CAN_FA1R_FACT6 ((uint16_t)0x0040) /*!< Filter 6 Active */
+#define CAN_FA1R_FACT7 ((uint16_t)0x0080) /*!< Filter 7 Active */
+#define CAN_FA1R_FACT8 ((uint16_t)0x0100) /*!< Filter 8 Active */
+#define CAN_FA1R_FACT9 ((uint16_t)0x0200) /*!< Filter 9 Active */
+#define CAN_FA1R_FACT10 ((uint16_t)0x0400) /*!< Filter 10 Active */
+#define CAN_FA1R_FACT11 ((uint16_t)0x0800) /*!< Filter 11 Active */
+#define CAN_FA1R_FACT12 ((uint16_t)0x1000) /*!< Filter 12 Active */
+#define CAN_FA1R_FACT13 ((uint16_t)0x2000) /*!< Filter 13 Active */
+
+/******************* Bit definition for CAN_F0R1 register *******************/
+#define CAN_F0R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F0R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F0R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F0R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F0R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F0R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F0R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F0R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F0R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F0R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F0R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F0R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F0R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F0R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F0R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F0R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F0R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F0R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F0R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F0R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F0R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F0R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F0R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F0R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F0R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F0R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F0R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F0R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F0R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F0R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F0R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F0R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F1R1 register *******************/
+#define CAN_F1R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F1R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F1R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F1R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F1R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F1R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F1R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F1R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F1R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F1R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F1R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F1R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F1R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F1R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F1R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F1R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F1R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F1R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F1R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F1R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F1R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F1R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F1R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F1R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F1R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F1R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F1R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F1R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F1R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F1R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F1R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F1R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F2R1 register *******************/
+#define CAN_F2R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F2R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F2R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F2R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F2R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F2R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F2R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F2R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F2R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F2R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F2R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F2R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F2R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F2R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F2R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F2R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F2R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F2R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F2R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F2R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F2R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F2R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F2R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F2R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F2R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F2R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F2R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F2R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F2R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F2R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F2R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F2R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F3R1 register *******************/
+#define CAN_F3R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F3R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F3R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F3R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F3R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F3R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F3R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F3R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F3R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F3R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F3R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F3R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F3R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F3R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F3R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F3R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F3R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F3R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F3R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F3R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F3R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F3R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F3R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F3R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F3R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F3R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F3R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F3R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F3R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F3R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F3R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F3R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F4R1 register *******************/
+#define CAN_F4R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F4R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F4R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F4R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F4R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F4R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F4R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F4R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F4R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F4R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F4R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F4R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F4R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F4R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F4R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F4R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F4R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F4R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F4R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F4R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F4R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F4R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F4R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F4R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F4R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F4R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F4R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F4R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F4R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F4R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F4R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F4R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F5R1 register *******************/
+#define CAN_F5R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F5R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F5R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F5R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F5R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F5R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F5R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F5R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F5R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F5R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F5R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F5R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F5R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F5R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F5R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F5R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F5R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F5R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F5R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F5R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F5R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F5R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F5R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F5R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F5R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F5R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F5R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F5R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F5R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F5R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F5R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F5R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F6R1 register *******************/
+#define CAN_F6R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F6R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F6R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F6R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F6R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F6R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F6R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F6R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F6R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F6R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F6R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F6R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F6R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F6R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F6R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F6R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F6R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F6R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F6R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F6R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F6R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F6R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F6R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F6R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F6R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F6R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F6R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F6R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F6R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F6R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F6R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F6R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F7R1 register *******************/
+#define CAN_F7R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F7R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F7R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F7R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F7R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F7R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F7R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F7R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F7R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F7R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F7R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F7R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F7R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F7R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F7R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F7R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F7R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F7R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F7R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F7R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F7R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F7R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F7R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F7R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F7R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F7R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F7R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F7R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F7R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F7R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F7R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F7R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F8R1 register *******************/
+#define CAN_F8R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F8R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F8R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F8R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F8R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F8R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F8R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F8R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F8R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F8R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F8R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F8R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F8R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F8R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F8R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F8R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F8R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F8R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F8R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F8R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F8R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F8R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F8R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F8R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F8R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F8R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F8R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F8R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F8R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F8R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F8R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F8R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F9R1 register *******************/
+#define CAN_F9R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F9R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F9R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F9R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F9R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F9R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F9R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F9R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F9R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F9R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F9R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F9R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F9R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F9R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F9R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F9R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F9R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F9R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F9R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F9R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F9R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F9R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F9R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F9R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F9R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F9R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F9R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F9R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F9R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F9R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F9R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F9R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F10R1 register ******************/
+#define CAN_F10R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F10R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F10R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F10R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F10R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F10R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F10R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F10R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F10R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F10R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F10R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F10R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F10R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F10R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F10R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F10R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F10R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F10R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F10R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F10R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F10R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F10R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F10R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F10R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F10R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F10R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F10R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F10R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F10R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F10R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F10R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F10R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F11R1 register ******************/
+#define CAN_F11R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F11R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F11R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F11R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F11R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F11R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F11R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F11R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F11R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F11R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F11R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F11R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F11R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F11R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F11R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F11R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F11R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F11R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F11R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F11R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F11R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F11R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F11R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F11R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F11R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F11R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F11R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F11R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F11R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F11R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F11R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F11R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F12R1 register ******************/
+#define CAN_F12R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F12R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F12R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F12R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F12R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F12R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F12R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F12R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F12R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F12R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F12R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F12R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F12R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F12R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F12R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F12R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F12R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F12R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F12R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F12R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F12R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F12R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F12R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F12R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F12R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F12R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F12R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F12R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F12R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F12R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F12R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F12R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F13R1 register ******************/
+#define CAN_F13R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F13R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F13R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F13R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F13R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F13R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F13R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F13R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F13R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F13R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F13R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F13R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F13R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F13R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F13R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F13R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F13R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F13R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F13R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F13R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F13R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F13R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F13R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F13R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F13R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F13R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F13R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F13R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F13R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F13R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F13R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F13R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F0R2 register *******************/
+#define CAN_F0R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F0R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F0R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F0R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F0R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F0R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F0R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F0R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F0R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F0R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F0R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F0R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F0R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F0R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F0R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F0R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F0R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F0R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F0R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F0R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F0R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F0R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F0R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F0R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F0R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F0R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F0R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F0R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F0R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F0R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F0R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F0R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F1R2 register *******************/
+#define CAN_F1R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F1R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F1R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F1R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F1R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F1R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F1R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F1R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F1R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F1R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F1R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F1R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F1R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F1R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F1R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F1R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F1R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F1R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F1R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F1R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F1R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F1R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F1R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F1R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F1R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F1R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F1R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F1R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F1R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F1R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F1R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F1R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F2R2 register *******************/
+#define CAN_F2R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F2R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F2R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F2R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F2R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F2R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F2R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F2R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F2R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F2R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F2R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F2R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F2R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F2R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F2R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F2R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F2R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F2R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F2R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F2R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F2R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F2R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F2R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F2R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F2R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F2R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F2R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F2R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F2R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F2R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F2R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F2R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F3R2 register *******************/
+#define CAN_F3R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F3R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F3R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F3R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F3R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F3R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F3R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F3R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F3R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F3R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F3R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F3R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F3R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F3R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F3R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F3R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F3R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F3R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F3R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F3R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F3R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F3R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F3R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F3R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F3R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F3R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F3R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F3R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F3R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F3R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F3R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F3R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F4R2 register *******************/
+#define CAN_F4R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F4R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F4R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F4R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F4R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F4R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F4R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F4R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F4R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F4R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F4R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F4R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F4R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F4R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F4R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F4R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F4R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F4R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F4R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F4R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F4R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F4R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F4R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F4R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F4R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F4R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F4R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F4R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F4R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F4R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F4R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F4R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F5R2 register *******************/
+#define CAN_F5R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F5R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F5R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F5R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F5R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F5R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F5R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F5R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F5R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F5R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F5R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F5R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F5R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F5R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F5R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F5R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F5R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F5R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F5R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F5R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F5R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F5R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F5R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F5R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F5R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F5R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F5R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F5R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F5R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F5R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F5R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F5R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F6R2 register *******************/
+#define CAN_F6R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F6R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F6R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F6R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F6R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F6R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F6R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F6R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F6R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F6R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F6R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F6R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F6R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F6R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F6R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F6R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F6R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F6R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F6R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F6R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F6R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F6R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F6R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F6R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F6R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F6R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F6R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F6R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F6R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F6R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F6R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F6R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F7R2 register *******************/
+#define CAN_F7R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F7R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F7R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F7R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F7R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F7R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F7R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F7R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F7R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F7R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F7R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F7R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F7R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F7R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F7R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F7R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F7R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F7R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F7R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F7R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F7R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F7R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F7R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F7R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F7R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F7R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F7R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F7R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F7R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F7R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F7R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F7R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F8R2 register *******************/
+#define CAN_F8R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F8R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F8R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F8R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F8R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F8R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F8R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F8R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F8R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F8R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F8R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F8R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F8R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F8R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F8R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F8R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F8R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F8R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F8R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F8R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F8R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F8R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F8R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F8R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F8R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F8R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F8R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F8R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F8R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F8R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F8R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F8R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F9R2 register *******************/
+#define CAN_F9R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F9R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F9R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F9R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F9R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F9R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F9R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F9R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F9R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F9R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F9R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F9R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F9R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F9R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F9R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F9R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F9R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F9R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F9R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F9R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F9R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F9R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F9R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F9R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F9R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F9R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F9R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F9R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F9R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F9R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F9R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F9R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F10R2 register ******************/
+#define CAN_F10R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F10R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F10R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F10R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F10R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F10R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F10R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F10R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F10R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F10R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F10R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F10R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F10R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F10R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F10R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F10R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F10R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F10R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F10R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F10R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F10R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F10R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F10R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F10R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F10R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F10R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F10R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F10R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F10R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F10R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F10R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F10R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F11R2 register ******************/
+#define CAN_F11R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F11R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F11R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F11R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F11R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F11R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F11R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F11R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F11R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F11R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F11R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F11R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F11R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F11R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F11R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F11R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F11R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F11R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F11R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F11R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F11R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F11R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F11R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F11R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F11R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F11R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F11R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F11R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F11R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F11R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F11R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F11R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F12R2 register ******************/
+#define CAN_F12R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F12R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F12R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F12R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F12R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F12R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F12R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F12R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F12R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F12R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F12R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F12R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F12R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F12R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F12R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F12R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F12R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F12R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F12R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F12R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F12R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F12R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F12R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F12R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F12R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F12R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F12R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F12R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F12R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F12R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F12R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F12R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************* Bit definition for CAN_F13R2 register ******************/
+#define CAN_F13R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */
+#define CAN_F13R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */
+#define CAN_F13R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */
+#define CAN_F13R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */
+#define CAN_F13R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */
+#define CAN_F13R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */
+#define CAN_F13R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */
+#define CAN_F13R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */
+#define CAN_F13R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */
+#define CAN_F13R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */
+#define CAN_F13R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */
+#define CAN_F13R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */
+#define CAN_F13R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */
+#define CAN_F13R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */
+#define CAN_F13R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */
+#define CAN_F13R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */
+#define CAN_F13R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */
+#define CAN_F13R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */
+#define CAN_F13R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */
+#define CAN_F13R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */
+#define CAN_F13R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */
+#define CAN_F13R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */
+#define CAN_F13R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */
+#define CAN_F13R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */
+#define CAN_F13R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */
+#define CAN_F13R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */
+#define CAN_F13R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */
+#define CAN_F13R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */
+#define CAN_F13R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */
+#define CAN_F13R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */
+#define CAN_F13R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */
+#define CAN_F13R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */
+
+/******************************************************************************/
+/* */
+/* Serial Peripheral Interface */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for SPI_CR1 register ********************/
+#define SPI_CR1_CPHA ((uint16_t)0x0001) /*!< Clock Phase */
+#define SPI_CR1_CPOL ((uint16_t)0x0002) /*!< Clock Polarity */
+#define SPI_CR1_MSTR ((uint16_t)0x0004) /*!< Master Selection */
+
+#define SPI_CR1_BR ((uint16_t)0x0038) /*!< BR[2:0] bits (Baud Rate Control) */
+#define SPI_CR1_BR_0 ((uint16_t)0x0008) /*!< Bit 0 */
+#define SPI_CR1_BR_1 ((uint16_t)0x0010) /*!< Bit 1 */
+#define SPI_CR1_BR_2 ((uint16_t)0x0020) /*!< Bit 2 */
+
+#define SPI_CR1_SPE ((uint16_t)0x0040) /*!< SPI Enable */
+#define SPI_CR1_LSBFIRST ((uint16_t)0x0080) /*!< Frame Format */
+#define SPI_CR1_SSI ((uint16_t)0x0100) /*!< Internal slave select */
+#define SPI_CR1_SSM ((uint16_t)0x0200) /*!< Software slave management */
+#define SPI_CR1_RXONLY ((uint16_t)0x0400) /*!< Receive only */
+#define SPI_CR1_DFF ((uint16_t)0x0800) /*!< Data Frame Format */
+#define SPI_CR1_CRCNEXT ((uint16_t)0x1000) /*!< Transmit CRC next */
+#define SPI_CR1_CRCEN ((uint16_t)0x2000) /*!< Hardware CRC calculation enable */
+#define SPI_CR1_BIDIOE ((uint16_t)0x4000) /*!< Output enable in bidirectional mode */
+#define SPI_CR1_BIDIMODE ((uint16_t)0x8000) /*!< Bidirectional data mode enable */
+
+/******************* Bit definition for SPI_CR2 register ********************/
+#define SPI_CR2_RXDMAEN ((uint8_t)0x01) /*!< Rx Buffer DMA Enable */
+#define SPI_CR2_TXDMAEN ((uint8_t)0x02) /*!< Tx Buffer DMA Enable */
+#define SPI_CR2_SSOE ((uint8_t)0x04) /*!< SS Output Enable */
+#define SPI_CR2_ERRIE ((uint8_t)0x20) /*!< Error Interrupt Enable */
+#define SPI_CR2_RXNEIE ((uint8_t)0x40) /*!< RX buffer Not Empty Interrupt Enable */
+#define SPI_CR2_TXEIE ((uint8_t)0x80) /*!< Tx buffer Empty Interrupt Enable */
+
+/******************** Bit definition for SPI_SR register ********************/
+#define SPI_SR_RXNE ((uint8_t)0x01) /*!< Receive buffer Not Empty */
+#define SPI_SR_TXE ((uint8_t)0x02) /*!< Transmit buffer Empty */
+#define SPI_SR_CHSIDE ((uint8_t)0x04) /*!< Channel side */
+#define SPI_SR_UDR ((uint8_t)0x08) /*!< Underrun flag */
+#define SPI_SR_CRCERR ((uint8_t)0x10) /*!< CRC Error flag */
+#define SPI_SR_MODF ((uint8_t)0x20) /*!< Mode fault */
+#define SPI_SR_OVR ((uint8_t)0x40) /*!< Overrun flag */
+#define SPI_SR_BSY ((uint8_t)0x80) /*!< Busy flag */
+
+/******************** Bit definition for SPI_DR register ********************/
+#define SPI_DR_DR ((uint16_t)0xFFFF) /*!< Data Register */
+
+/******************* Bit definition for SPI_CRCPR register ******************/
+#define SPI_CRCPR_CRCPOLY ((uint16_t)0xFFFF) /*!< CRC polynomial register */
+
+/****************** Bit definition for SPI_RXCRCR register ******************/
+#define SPI_RXCRCR_RXCRC ((uint16_t)0xFFFF) /*!< Rx CRC Register */
+
+/****************** Bit definition for SPI_TXCRCR register ******************/
+#define SPI_TXCRCR_TXCRC ((uint16_t)0xFFFF) /*!< Tx CRC Register */
+
+/****************** Bit definition for SPI_I2SCFGR register *****************/
+#define SPI_I2SCFGR_CHLEN ((uint16_t)0x0001) /*!< Channel length (number of bits per audio channel) */
+
+#define SPI_I2SCFGR_DATLEN ((uint16_t)0x0006) /*!< DATLEN[1:0] bits (Data length to be transferred) */
+#define SPI_I2SCFGR_DATLEN_0 ((uint16_t)0x0002) /*!< Bit 0 */
+#define SPI_I2SCFGR_DATLEN_1 ((uint16_t)0x0004) /*!< Bit 1 */
+
+#define SPI_I2SCFGR_CKPOL ((uint16_t)0x0008) /*!< steady state clock polarity */
+
+#define SPI_I2SCFGR_I2SSTD ((uint16_t)0x0030) /*!< I2SSTD[1:0] bits (I2S standard selection) */
+#define SPI_I2SCFGR_I2SSTD_0 ((uint16_t)0x0010) /*!< Bit 0 */
+#define SPI_I2SCFGR_I2SSTD_1 ((uint16_t)0x0020) /*!< Bit 1 */
+
+#define SPI_I2SCFGR_PCMSYNC ((uint16_t)0x0080) /*!< PCM frame synchronization */
+
+#define SPI_I2SCFGR_I2SCFG ((uint16_t)0x0300) /*!< I2SCFG[1:0] bits (I2S configuration mode) */
+#define SPI_I2SCFGR_I2SCFG_0 ((uint16_t)0x0100) /*!< Bit 0 */
+#define SPI_I2SCFGR_I2SCFG_1 ((uint16_t)0x0200) /*!< Bit 1 */
+
+#define SPI_I2SCFGR_I2SE ((uint16_t)0x0400) /*!< I2S Enable */
+#define SPI_I2SCFGR_I2SMOD ((uint16_t)0x0800) /*!< I2S mode selection */
+
+/****************** Bit definition for SPI_I2SPR register *******************/
+#define SPI_I2SPR_I2SDIV ((uint16_t)0x00FF) /*!< I2S Linear prescaler */
+#define SPI_I2SPR_ODD ((uint16_t)0x0100) /*!< Odd factor for the prescaler */
+#define SPI_I2SPR_MCKOE ((uint16_t)0x0200) /*!< Master Clock Output Enable */
+
+/******************************************************************************/
+/* */
+/* Inter-integrated Circuit Interface */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for I2C_CR1 register ********************/
+#define I2C_CR1_PE ((uint16_t)0x0001) /*!< Peripheral Enable */
+#define I2C_CR1_SMBUS ((uint16_t)0x0002) /*!< SMBus Mode */
+#define I2C_CR1_SMBTYPE ((uint16_t)0x0008) /*!< SMBus Type */
+#define I2C_CR1_ENARP ((uint16_t)0x0010) /*!< ARP Enable */
+#define I2C_CR1_ENPEC ((uint16_t)0x0020) /*!< PEC Enable */
+#define I2C_CR1_ENGC ((uint16_t)0x0040) /*!< General Call Enable */
+#define I2C_CR1_NOSTRETCH ((uint16_t)0x0080) /*!< Clock Stretching Disable (Slave mode) */
+#define I2C_CR1_START ((uint16_t)0x0100) /*!< Start Generation */
+#define I2C_CR1_STOP ((uint16_t)0x0200) /*!< Stop Generation */
+#define I2C_CR1_ACK ((uint16_t)0x0400) /*!< Acknowledge Enable */
+#define I2C_CR1_POS ((uint16_t)0x0800) /*!< Acknowledge/PEC Position (for data reception) */
+#define I2C_CR1_PEC ((uint16_t)0x1000) /*!< Packet Error Checking */
+#define I2C_CR1_ALERT ((uint16_t)0x2000) /*!< SMBus Alert */
+#define I2C_CR1_SWRST ((uint16_t)0x8000) /*!< Software Reset */
+
+/******************* Bit definition for I2C_CR2 register ********************/
+#define I2C_CR2_FREQ ((uint16_t)0x003F) /*!< FREQ[5:0] bits (Peripheral Clock Frequency) */
+#define I2C_CR2_FREQ_0 ((uint16_t)0x0001) /*!< Bit 0 */
+#define I2C_CR2_FREQ_1 ((uint16_t)0x0002) /*!< Bit 1 */
+#define I2C_CR2_FREQ_2 ((uint16_t)0x0004) /*!< Bit 2 */
+#define I2C_CR2_FREQ_3 ((uint16_t)0x0008) /*!< Bit 3 */
+#define I2C_CR2_FREQ_4 ((uint16_t)0x0010) /*!< Bit 4 */
+#define I2C_CR2_FREQ_5 ((uint16_t)0x0020) /*!< Bit 5 */
+
+#define I2C_CR2_ITERREN ((uint16_t)0x0100) /*!< Error Interrupt Enable */
+#define I2C_CR2_ITEVTEN ((uint16_t)0x0200) /*!< Event Interrupt Enable */
+#define I2C_CR2_ITBUFEN ((uint16_t)0x0400) /*!< Buffer Interrupt Enable */
+#define I2C_CR2_DMAEN ((uint16_t)0x0800) /*!< DMA Requests Enable */
+#define I2C_CR2_LAST ((uint16_t)0x1000) /*!< DMA Last Transfer */
+
+/******************* Bit definition for I2C_OAR1 register *******************/
+#define I2C_OAR1_ADD1_7 ((uint16_t)0x00FE) /*!< Interface Address */
+#define I2C_OAR1_ADD8_9 ((uint16_t)0x0300) /*!< Interface Address */
+
+#define I2C_OAR1_ADD0 ((uint16_t)0x0001) /*!< Bit 0 */
+#define I2C_OAR1_ADD1 ((uint16_t)0x0002) /*!< Bit 1 */
+#define I2C_OAR1_ADD2 ((uint16_t)0x0004) /*!< Bit 2 */
+#define I2C_OAR1_ADD3 ((uint16_t)0x0008) /*!< Bit 3 */
+#define I2C_OAR1_ADD4 ((uint16_t)0x0010) /*!< Bit 4 */
+#define I2C_OAR1_ADD5 ((uint16_t)0x0020) /*!< Bit 5 */
+#define I2C_OAR1_ADD6 ((uint16_t)0x0040) /*!< Bit 6 */
+#define I2C_OAR1_ADD7 ((uint16_t)0x0080) /*!< Bit 7 */
+#define I2C_OAR1_ADD8 ((uint16_t)0x0100) /*!< Bit 8 */
+#define I2C_OAR1_ADD9 ((uint16_t)0x0200) /*!< Bit 9 */
+
+#define I2C_OAR1_ADDMODE ((uint16_t)0x8000) /*!< Addressing Mode (Slave mode) */
+
+/******************* Bit definition for I2C_OAR2 register *******************/
+#define I2C_OAR2_ENDUAL ((uint8_t)0x01) /*!< Dual addressing mode enable */
+#define I2C_OAR2_ADD2 ((uint8_t)0xFE) /*!< Interface address */
+
+/******************** Bit definition for I2C_DR register ********************/
+#define I2C_DR_DR ((uint8_t)0xFF) /*!< 8-bit Data Register */
+
+/******************* Bit definition for I2C_SR1 register ********************/
+#define I2C_SR1_SB ((uint16_t)0x0001) /*!< Start Bit (Master mode) */
+#define I2C_SR1_ADDR ((uint16_t)0x0002) /*!< Address sent (master mode)/matched (slave mode) */
+#define I2C_SR1_BTF ((uint16_t)0x0004) /*!< Byte Transfer Finished */
+#define I2C_SR1_ADD10 ((uint16_t)0x0008) /*!< 10-bit header sent (Master mode) */
+#define I2C_SR1_STOPF ((uint16_t)0x0010) /*!< Stop detection (Slave mode) */
+#define I2C_SR1_RXNE ((uint16_t)0x0040) /*!< Data Register not Empty (receivers) */
+#define I2C_SR1_TXE ((uint16_t)0x0080) /*!< Data Register Empty (transmitters) */
+#define I2C_SR1_BERR ((uint16_t)0x0100) /*!< Bus Error */
+#define I2C_SR1_ARLO ((uint16_t)0x0200) /*!< Arbitration Lost (master mode) */
+#define I2C_SR1_AF ((uint16_t)0x0400) /*!< Acknowledge Failure */
+#define I2C_SR1_OVR ((uint16_t)0x0800) /*!< Overrun/Underrun */
+#define I2C_SR1_PECERR ((uint16_t)0x1000) /*!< PEC Error in reception */
+#define I2C_SR1_TIMEOUT ((uint16_t)0x4000) /*!< Timeout or Tlow Error */
+#define I2C_SR1_SMBALERT ((uint16_t)0x8000) /*!< SMBus Alert */
+
+/******************* Bit definition for I2C_SR2 register ********************/
+#define I2C_SR2_MSL ((uint16_t)0x0001) /*!< Master/Slave */
+#define I2C_SR2_BUSY ((uint16_t)0x0002) /*!< Bus Busy */
+#define I2C_SR2_TRA ((uint16_t)0x0004) /*!< Transmitter/Receiver */
+#define I2C_SR2_GENCALL ((uint16_t)0x0010) /*!< General Call Address (Slave mode) */
+#define I2C_SR2_SMBDEFAULT ((uint16_t)0x0020) /*!< SMBus Device Default Address (Slave mode) */
+#define I2C_SR2_SMBHOST ((uint16_t)0x0040) /*!< SMBus Host Header (Slave mode) */
+#define I2C_SR2_DUALF ((uint16_t)0x0080) /*!< Dual Flag (Slave mode) */
+#define I2C_SR2_PEC ((uint16_t)0xFF00) /*!< Packet Error Checking Register */
+
+/******************* Bit definition for I2C_CCR register ********************/
+#define I2C_CCR_CCR ((uint16_t)0x0FFF) /*!< Clock Control Register in Fast/Standard mode (Master mode) */
+#define I2C_CCR_DUTY ((uint16_t)0x4000) /*!< Fast Mode Duty Cycle */
+#define I2C_CCR_FS ((uint16_t)0x8000) /*!< I2C Master Mode Selection */
+
+/****************** Bit definition for I2C_TRISE register *******************/
+#define I2C_TRISE_TRISE ((uint8_t)0x3F) /*!< Maximum Rise Time in Fast/Standard mode (Master mode) */
+
+/******************************************************************************/
+/* */
+/* Universal Synchronous Asynchronous Receiver Transmitter */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for USART_SR register *******************/
+#define USART_SR_PE ((uint16_t)0x0001) /*!< Parity Error */
+#define USART_SR_FE ((uint16_t)0x0002) /*!< Framing Error */
+#define USART_SR_NE ((uint16_t)0x0004) /*!< Noise Error Flag */
+#define USART_SR_ORE ((uint16_t)0x0008) /*!< OverRun Error */
+#define USART_SR_IDLE ((uint16_t)0x0010) /*!< IDLE line detected */
+#define USART_SR_RXNE ((uint16_t)0x0020) /*!< Read Data Register Not Empty */
+#define USART_SR_TC ((uint16_t)0x0040) /*!< Transmission Complete */
+#define USART_SR_TXE ((uint16_t)0x0080) /*!< Transmit Data Register Empty */
+#define USART_SR_LBD ((uint16_t)0x0100) /*!< LIN Break Detection Flag */
+#define USART_SR_CTS ((uint16_t)0x0200) /*!< CTS Flag */
+
+/******************* Bit definition for USART_DR register *******************/
+#define USART_DR_DR ((uint16_t)0x01FF) /*!< Data value */
+
+/****************** Bit definition for USART_BRR register *******************/
+#define USART_BRR_DIV_Fraction ((uint16_t)0x000F) /*!< Fraction of USARTDIV */
+#define USART_BRR_DIV_Mantissa ((uint16_t)0xFFF0) /*!< Mantissa of USARTDIV */
+
+/****************** Bit definition for USART_CR1 register *******************/
+#define USART_CR1_SBK ((uint16_t)0x0001) /*!< Send Break */
+#define USART_CR1_RWU ((uint16_t)0x0002) /*!< Receiver wakeup */
+#define USART_CR1_RE ((uint16_t)0x0004) /*!< Receiver Enable */
+#define USART_CR1_TE ((uint16_t)0x0008) /*!< Transmitter Enable */
+#define USART_CR1_IDLEIE ((uint16_t)0x0010) /*!< IDLE Interrupt Enable */
+#define USART_CR1_RXNEIE ((uint16_t)0x0020) /*!< RXNE Interrupt Enable */
+#define USART_CR1_TCIE ((uint16_t)0x0040) /*!< Transmission Complete Interrupt Enable */
+#define USART_CR1_TXEIE ((uint16_t)0x0080) /*!< PE Interrupt Enable */
+#define USART_CR1_PEIE ((uint16_t)0x0100) /*!< PE Interrupt Enable */
+#define USART_CR1_PS ((uint16_t)0x0200) /*!< Parity Selection */
+#define USART_CR1_PCE ((uint16_t)0x0400) /*!< Parity Control Enable */
+#define USART_CR1_WAKE ((uint16_t)0x0800) /*!< Wakeup method */
+#define USART_CR1_M ((uint16_t)0x1000) /*!< Word length */
+#define USART_CR1_UE ((uint16_t)0x2000) /*!< USART Enable */
+#define USART_CR1_OVER8 ((uint16_t)0x8000) /*!< USART Oversmapling 8-bits */
+
+/****************** Bit definition for USART_CR2 register *******************/
+#define USART_CR2_ADD ((uint16_t)0x000F) /*!< Address of the USART node */
+#define USART_CR2_LBDL ((uint16_t)0x0020) /*!< LIN Break Detection Length */
+#define USART_CR2_LBDIE ((uint16_t)0x0040) /*!< LIN Break Detection Interrupt Enable */
+#define USART_CR2_LBCL ((uint16_t)0x0100) /*!< Last Bit Clock pulse */
+#define USART_CR2_CPHA ((uint16_t)0x0200) /*!< Clock Phase */
+#define USART_CR2_CPOL ((uint16_t)0x0400) /*!< Clock Polarity */
+#define USART_CR2_CLKEN ((uint16_t)0x0800) /*!< Clock Enable */
+
+#define USART_CR2_STOP ((uint16_t)0x3000) /*!< STOP[1:0] bits (STOP bits) */
+#define USART_CR2_STOP_0 ((uint16_t)0x1000) /*!< Bit 0 */
+#define USART_CR2_STOP_1 ((uint16_t)0x2000) /*!< Bit 1 */
+
+#define USART_CR2_LINEN ((uint16_t)0x4000) /*!< LIN mode enable */
+
+/****************** Bit definition for USART_CR3 register *******************/
+#define USART_CR3_EIE ((uint16_t)0x0001) /*!< Error Interrupt Enable */
+#define USART_CR3_IREN ((uint16_t)0x0002) /*!< IrDA mode Enable */
+#define USART_CR3_IRLP ((uint16_t)0x0004) /*!< IrDA Low-Power */
+#define USART_CR3_HDSEL ((uint16_t)0x0008) /*!< Half-Duplex Selection */
+#define USART_CR3_NACK ((uint16_t)0x0010) /*!< Smartcard NACK enable */
+#define USART_CR3_SCEN ((uint16_t)0x0020) /*!< Smartcard mode enable */
+#define USART_CR3_DMAR ((uint16_t)0x0040) /*!< DMA Enable Receiver */
+#define USART_CR3_DMAT ((uint16_t)0x0080) /*!< DMA Enable Transmitter */
+#define USART_CR3_RTSE ((uint16_t)0x0100) /*!< RTS Enable */
+#define USART_CR3_CTSE ((uint16_t)0x0200) /*!< CTS Enable */
+#define USART_CR3_CTSIE ((uint16_t)0x0400) /*!< CTS Interrupt Enable */
+#define USART_CR3_ONEBIT ((uint16_t)0x0800) /*!< One Bit method */
+
+/****************** Bit definition for USART_GTPR register ******************/
+#define USART_GTPR_PSC ((uint16_t)0x00FF) /*!< PSC[7:0] bits (Prescaler value) */
+#define USART_GTPR_PSC_0 ((uint16_t)0x0001) /*!< Bit 0 */
+#define USART_GTPR_PSC_1 ((uint16_t)0x0002) /*!< Bit 1 */
+#define USART_GTPR_PSC_2 ((uint16_t)0x0004) /*!< Bit 2 */
+#define USART_GTPR_PSC_3 ((uint16_t)0x0008) /*!< Bit 3 */
+#define USART_GTPR_PSC_4 ((uint16_t)0x0010) /*!< Bit 4 */
+#define USART_GTPR_PSC_5 ((uint16_t)0x0020) /*!< Bit 5 */
+#define USART_GTPR_PSC_6 ((uint16_t)0x0040) /*!< Bit 6 */
+#define USART_GTPR_PSC_7 ((uint16_t)0x0080) /*!< Bit 7 */
+
+#define USART_GTPR_GT ((uint16_t)0xFF00) /*!< Guard time value */
+
+/******************************************************************************/
+/* */
+/* Debug MCU */
+/* */
+/******************************************************************************/
+
+/**************** Bit definition for DBGMCU_IDCODE register *****************/
+#define DBGMCU_IDCODE_DEV_ID ((uint32_t)0x00000FFF) /*!< Device Identifier */
+
+#define DBGMCU_IDCODE_REV_ID ((uint32_t)0xFFFF0000) /*!< REV_ID[15:0] bits (Revision Identifier) */
+#define DBGMCU_IDCODE_REV_ID_0 ((uint32_t)0x00010000) /*!< Bit 0 */
+#define DBGMCU_IDCODE_REV_ID_1 ((uint32_t)0x00020000) /*!< Bit 1 */
+#define DBGMCU_IDCODE_REV_ID_2 ((uint32_t)0x00040000) /*!< Bit 2 */
+#define DBGMCU_IDCODE_REV_ID_3 ((uint32_t)0x00080000) /*!< Bit 3 */
+#define DBGMCU_IDCODE_REV_ID_4 ((uint32_t)0x00100000) /*!< Bit 4 */
+#define DBGMCU_IDCODE_REV_ID_5 ((uint32_t)0x00200000) /*!< Bit 5 */
+#define DBGMCU_IDCODE_REV_ID_6 ((uint32_t)0x00400000) /*!< Bit 6 */
+#define DBGMCU_IDCODE_REV_ID_7 ((uint32_t)0x00800000) /*!< Bit 7 */
+#define DBGMCU_IDCODE_REV_ID_8 ((uint32_t)0x01000000) /*!< Bit 8 */
+#define DBGMCU_IDCODE_REV_ID_9 ((uint32_t)0x02000000) /*!< Bit 9 */
+#define DBGMCU_IDCODE_REV_ID_10 ((uint32_t)0x04000000) /*!< Bit 10 */
+#define DBGMCU_IDCODE_REV_ID_11 ((uint32_t)0x08000000) /*!< Bit 11 */
+#define DBGMCU_IDCODE_REV_ID_12 ((uint32_t)0x10000000) /*!< Bit 12 */
+#define DBGMCU_IDCODE_REV_ID_13 ((uint32_t)0x20000000) /*!< Bit 13 */
+#define DBGMCU_IDCODE_REV_ID_14 ((uint32_t)0x40000000) /*!< Bit 14 */
+#define DBGMCU_IDCODE_REV_ID_15 ((uint32_t)0x80000000) /*!< Bit 15 */
+
+/****************** Bit definition for DBGMCU_CR register *******************/
+#define DBGMCU_CR_DBG_SLEEP ((uint32_t)0x00000001) /*!< Debug Sleep Mode */
+#define DBGMCU_CR_DBG_STOP ((uint32_t)0x00000002) /*!< Debug Stop Mode */
+#define DBGMCU_CR_DBG_STANDBY ((uint32_t)0x00000004) /*!< Debug Standby mode */
+#define DBGMCU_CR_TRACE_IOEN ((uint32_t)0x00000020) /*!< Trace Pin Assignment Control */
+
+#define DBGMCU_CR_TRACE_MODE ((uint32_t)0x000000C0) /*!< TRACE_MODE[1:0] bits (Trace Pin Assignment Control) */
+#define DBGMCU_CR_TRACE_MODE_0 ((uint32_t)0x00000040) /*!< Bit 0 */
+#define DBGMCU_CR_TRACE_MODE_1 ((uint32_t)0x00000080) /*!< Bit 1 */
+
+#define DBGMCU_CR_DBG_IWDG_STOP ((uint32_t)0x00000100) /*!< Debug Independent Watchdog stopped when Core is halted */
+#define DBGMCU_CR_DBG_WWDG_STOP ((uint32_t)0x00000200) /*!< Debug Window Watchdog stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM1_STOP ((uint32_t)0x00000400) /*!< TIM1 counter stopped when core is halted */
+#define DBGMCU_CR_DBG_TIM2_STOP ((uint32_t)0x00000800) /*!< TIM2 counter stopped when core is halted */
+#define DBGMCU_CR_DBG_TIM3_STOP ((uint32_t)0x00001000) /*!< TIM3 counter stopped when core is halted */
+#define DBGMCU_CR_DBG_TIM4_STOP ((uint32_t)0x00002000) /*!< TIM4 counter stopped when core is halted */
+#define DBGMCU_CR_DBG_CAN1_STOP ((uint32_t)0x00004000) /*!< Debug CAN1 stopped when Core is halted */
+#define DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000) /*!< SMBUS timeout mode stopped when Core is halted */
+#define DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000) /*!< SMBUS timeout mode stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM8_STOP ((uint32_t)0x00020000) /*!< TIM8 counter stopped when core is halted */
+#define DBGMCU_CR_DBG_TIM5_STOP ((uint32_t)0x00040000) /*!< TIM5 counter stopped when core is halted */
+#define DBGMCU_CR_DBG_TIM6_STOP ((uint32_t)0x00080000) /*!< TIM6 counter stopped when core is halted */
+#define DBGMCU_CR_DBG_TIM7_STOP ((uint32_t)0x00100000) /*!< TIM7 counter stopped when core is halted */
+#define DBGMCU_CR_DBG_CAN2_STOP ((uint32_t)0x00200000) /*!< Debug CAN2 stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM15_STOP ((uint32_t)0x00400000) /*!< Debug TIM15 stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM16_STOP ((uint32_t)0x00800000) /*!< Debug TIM16 stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM17_STOP ((uint32_t)0x01000000) /*!< Debug TIM17 stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM12_STOP ((uint32_t)0x02000000) /*!< Debug TIM12 stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM13_STOP ((uint32_t)0x04000000) /*!< Debug TIM13 stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM14_STOP ((uint32_t)0x08000000) /*!< Debug TIM14 stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM9_STOP ((uint32_t)0x10000000) /*!< Debug TIM9 stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM10_STOP ((uint32_t)0x20000000) /*!< Debug TIM10 stopped when Core is halted */
+#define DBGMCU_CR_DBG_TIM11_STOP ((uint32_t)0x40000000) /*!< Debug TIM11 stopped when Core is halted */
+
+/******************************************************************************/
+/* */
+/* FLASH and Option Bytes Registers */
+/* */
+/******************************************************************************/
+
+/******************* Bit definition for FLASH_ACR register ******************/
+#define FLASH_ACR_LATENCY ((uint8_t)0x03) /*!< LATENCY[2:0] bits (Latency) */
+#define FLASH_ACR_LATENCY_0 ((uint8_t)0x00) /*!< Bit 0 */
+#define FLASH_ACR_LATENCY_1 ((uint8_t)0x01) /*!< Bit 0 */
+#define FLASH_ACR_LATENCY_2 ((uint8_t)0x02) /*!< Bit 1 */
+
+#define FLASH_ACR_HLFCYA ((uint8_t)0x08) /*!< Flash Half Cycle Access Enable */
+#define FLASH_ACR_PRFTBE ((uint8_t)0x10) /*!< Prefetch Buffer Enable */
+#define FLASH_ACR_PRFTBS ((uint8_t)0x20) /*!< Prefetch Buffer Status */
+
+/****************** Bit definition for FLASH_KEYR register ******************/
+#define FLASH_KEYR_FKEYR ((uint32_t)0xFFFFFFFF) /*!< FPEC Key */
+
+/***************** Bit definition for FLASH_OPTKEYR register ****************/
+#define FLASH_OPTKEYR_OPTKEYR ((uint32_t)0xFFFFFFFF) /*!< Option Byte Key */
+
+/****************** Bit definition for FLASH_SR register *******************/
+#define FLASH_SR_BSY ((uint8_t)0x01) /*!< Busy */
+#define FLASH_SR_PGERR ((uint8_t)0x04) /*!< Programming Error */
+#define FLASH_SR_WRPRTERR ((uint8_t)0x10) /*!< Write Protection Error */
+#define FLASH_SR_EOP ((uint8_t)0x20) /*!< End of operation */
+
+/******************* Bit definition for FLASH_CR register *******************/
+#define FLASH_CR_PG ((uint16_t)0x0001) /*!< Programming */
+#define FLASH_CR_PER ((uint16_t)0x0002) /*!< Page Erase */
+#define FLASH_CR_MER ((uint16_t)0x0004) /*!< Mass Erase */
+#define FLASH_CR_OPTPG ((uint16_t)0x0010) /*!< Option Byte Programming */
+#define FLASH_CR_OPTER ((uint16_t)0x0020) /*!< Option Byte Erase */
+#define FLASH_CR_STRT ((uint16_t)0x0040) /*!< Start */
+#define FLASH_CR_LOCK ((uint16_t)0x0080) /*!< Lock */
+#define FLASH_CR_OPTWRE ((uint16_t)0x0200) /*!< Option Bytes Write Enable */
+#define FLASH_CR_ERRIE ((uint16_t)0x0400) /*!< Error Interrupt Enable */
+#define FLASH_CR_EOPIE ((uint16_t)0x1000) /*!< End of operation interrupt enable */
+
+/******************* Bit definition for FLASH_AR register *******************/
+#define FLASH_AR_FAR ((uint32_t)0xFFFFFFFF) /*!< Flash Address */
+
+/****************** Bit definition for FLASH_OBR register *******************/
+#define FLASH_OBR_OPTERR ((uint16_t)0x0001) /*!< Option Byte Error */
+#define FLASH_OBR_RDPRT ((uint16_t)0x0002) /*!< Read protection */
+
+#define FLASH_OBR_USER ((uint16_t)0x03FC) /*!< User Option Bytes */
+#define FLASH_OBR_WDG_SW ((uint16_t)0x0004) /*!< WDG_SW */
+#define FLASH_OBR_nRST_STOP ((uint16_t)0x0008) /*!< nRST_STOP */
+#define FLASH_OBR_nRST_STDBY ((uint16_t)0x0010) /*!< nRST_STDBY */
+#define FLASH_OBR_BFB2 ((uint16_t)0x0020) /*!< BFB2 */
+
+/****************** Bit definition for FLASH_WRPR register ******************/
+#define FLASH_WRPR_WRP ((uint32_t)0xFFFFFFFF) /*!< Write Protect */
+
+/*----------------------------------------------------------------------------*/
+
+/****************** Bit definition for FLASH_RDP register *******************/
+#define FLASH_RDP_RDP ((uint32_t)0x000000FF) /*!< Read protection option byte */
+#define FLASH_RDP_nRDP ((uint32_t)0x0000FF00) /*!< Read protection complemented option byte */
+
+/****************** Bit definition for FLASH_USER register ******************/
+#define FLASH_USER_USER ((uint32_t)0x00FF0000) /*!< User option byte */
+#define FLASH_USER_nUSER ((uint32_t)0xFF000000) /*!< User complemented option byte */
+
+/****************** Bit definition for FLASH_Data0 register *****************/
+#define FLASH_Data0_Data0 ((uint32_t)0x000000FF) /*!< User data storage option byte */
+#define FLASH_Data0_nData0 ((uint32_t)0x0000FF00) /*!< User data storage complemented option byte */
+
+/****************** Bit definition for FLASH_Data1 register *****************/
+#define FLASH_Data1_Data1 ((uint32_t)0x00FF0000) /*!< User data storage option byte */
+#define FLASH_Data1_nData1 ((uint32_t)0xFF000000) /*!< User data storage complemented option byte */
+
+/****************** Bit definition for FLASH_WRP0 register ******************/
+#define FLASH_WRP0_WRP0 ((uint32_t)0x000000FF) /*!< Flash memory write protection option bytes */
+#define FLASH_WRP0_nWRP0 ((uint32_t)0x0000FF00) /*!< Flash memory write protection complemented option bytes */
+
+/****************** Bit definition for FLASH_WRP1 register ******************/
+#define FLASH_WRP1_WRP1 ((uint32_t)0x00FF0000) /*!< Flash memory write protection option bytes */
+#define FLASH_WRP1_nWRP1 ((uint32_t)0xFF000000) /*!< Flash memory write protection complemented option bytes */
+
+/****************** Bit definition for FLASH_WRP2 register ******************/
+#define FLASH_WRP2_WRP2 ((uint32_t)0x000000FF) /*!< Flash memory write protection option bytes */
+#define FLASH_WRP2_nWRP2 ((uint32_t)0x0000FF00) /*!< Flash memory write protection complemented option bytes */
+
+/****************** Bit definition for FLASH_WRP3 register ******************/
+#define FLASH_WRP3_WRP3 ((uint32_t)0x00FF0000) /*!< Flash memory write protection option bytes */
+#define FLASH_WRP3_nWRP3 ((uint32_t)0xFF000000) /*!< Flash memory write protection complemented option bytes */
+
+#ifdef STM32F10X_CL
+/******************************************************************************/
+/* Ethernet MAC Registers bits definitions */
+/******************************************************************************/
+/* Bit definition for Ethernet MAC Control Register register */
+#define ETH_MACCR_WD ((uint32_t)0x00800000) /* Watchdog disable */
+#define ETH_MACCR_JD ((uint32_t)0x00400000) /* Jabber disable */
+#define ETH_MACCR_IFG ((uint32_t)0x000E0000) /* Inter-frame gap */
+ #define ETH_MACCR_IFG_96Bit ((uint32_t)0x00000000) /* Minimum IFG between frames during transmission is 96Bit */
+ #define ETH_MACCR_IFG_88Bit ((uint32_t)0x00020000) /* Minimum IFG between frames during transmission is 88Bit */
+ #define ETH_MACCR_IFG_80Bit ((uint32_t)0x00040000) /* Minimum IFG between frames during transmission is 80Bit */
+ #define ETH_MACCR_IFG_72Bit ((uint32_t)0x00060000) /* Minimum IFG between frames during transmission is 72Bit */
+ #define ETH_MACCR_IFG_64Bit ((uint32_t)0x00080000) /* Minimum IFG between frames during transmission is 64Bit */
+ #define ETH_MACCR_IFG_56Bit ((uint32_t)0x000A0000) /* Minimum IFG between frames during transmission is 56Bit */
+ #define ETH_MACCR_IFG_48Bit ((uint32_t)0x000C0000) /* Minimum IFG between frames during transmission is 48Bit */
+ #define ETH_MACCR_IFG_40Bit ((uint32_t)0x000E0000) /* Minimum IFG between frames during transmission is 40Bit */
+#define ETH_MACCR_CSD ((uint32_t)0x00010000) /* Carrier sense disable (during transmission) */
+#define ETH_MACCR_FES ((uint32_t)0x00004000) /* Fast ethernet speed */
+#define ETH_MACCR_ROD ((uint32_t)0x00002000) /* Receive own disable */
+#define ETH_MACCR_LM ((uint32_t)0x00001000) /* loopback mode */
+#define ETH_MACCR_DM ((uint32_t)0x00000800) /* Duplex mode */
+#define ETH_MACCR_IPCO ((uint32_t)0x00000400) /* IP Checksum offload */
+#define ETH_MACCR_RD ((uint32_t)0x00000200) /* Retry disable */
+#define ETH_MACCR_APCS ((uint32_t)0x00000080) /* Automatic Pad/CRC stripping */
+#define ETH_MACCR_BL ((uint32_t)0x00000060) /* Back-off limit: random integer number (r) of slot time delays before rescheduling
+ a transmission attempt during retries after a collision: 0 =< r <2^k */
+ #define ETH_MACCR_BL_10 ((uint32_t)0x00000000) /* k = min (n, 10) */
+ #define ETH_MACCR_BL_8 ((uint32_t)0x00000020) /* k = min (n, 8) */
+ #define ETH_MACCR_BL_4 ((uint32_t)0x00000040) /* k = min (n, 4) */
+ #define ETH_MACCR_BL_1 ((uint32_t)0x00000060) /* k = min (n, 1) */
+#define ETH_MACCR_DC ((uint32_t)0x00000010) /* Defferal check */
+#define ETH_MACCR_TE ((uint32_t)0x00000008) /* Transmitter enable */
+#define ETH_MACCR_RE ((uint32_t)0x00000004) /* Receiver enable */
+
+/* Bit definition for Ethernet MAC Frame Filter Register */
+#define ETH_MACFFR_RA ((uint32_t)0x80000000) /* Receive all */
+#define ETH_MACFFR_HPF ((uint32_t)0x00000400) /* Hash or perfect filter */
+#define ETH_MACFFR_SAF ((uint32_t)0x00000200) /* Source address filter enable */
+#define ETH_MACFFR_SAIF ((uint32_t)0x00000100) /* SA inverse filtering */
+#define ETH_MACFFR_PCF ((uint32_t)0x000000C0) /* Pass control frames: 3 cases */
+ #define ETH_MACFFR_PCF_BlockAll ((uint32_t)0x00000040) /* MAC filters all control frames from reaching the application */
+ #define ETH_MACFFR_PCF_ForwardAll ((uint32_t)0x00000080) /* MAC forwards all control frames to application even if they fail the Address Filter */
+ #define ETH_MACFFR_PCF_ForwardPassedAddrFilter ((uint32_t)0x000000C0) /* MAC forwards control frames that pass the Address Filter. */
+#define ETH_MACFFR_BFD ((uint32_t)0x00000020) /* Broadcast frame disable */
+#define ETH_MACFFR_PAM ((uint32_t)0x00000010) /* Pass all mutlicast */
+#define ETH_MACFFR_DAIF ((uint32_t)0x00000008) /* DA Inverse filtering */
+#define ETH_MACFFR_HM ((uint32_t)0x00000004) /* Hash multicast */
+#define ETH_MACFFR_HU ((uint32_t)0x00000002) /* Hash unicast */
+#define ETH_MACFFR_PM ((uint32_t)0x00000001) /* Promiscuous mode */
+
+/* Bit definition for Ethernet MAC Hash Table High Register */
+#define ETH_MACHTHR_HTH ((uint32_t)0xFFFFFFFF) /* Hash table high */
+
+/* Bit definition for Ethernet MAC Hash Table Low Register */
+#define ETH_MACHTLR_HTL ((uint32_t)0xFFFFFFFF) /* Hash table low */
+
+/* Bit definition for Ethernet MAC MII Address Register */
+#define ETH_MACMIIAR_PA ((uint32_t)0x0000F800) /* Physical layer address */
+#define ETH_MACMIIAR_MR ((uint32_t)0x000007C0) /* MII register in the selected PHY */
+#define ETH_MACMIIAR_CR ((uint32_t)0x0000001C) /* CR clock range: 6 cases */
+ #define ETH_MACMIIAR_CR_Div42 ((uint32_t)0x00000000) /* HCLK:60-72 MHz; MDC clock= HCLK/42 */
+ #define ETH_MACMIIAR_CR_Div16 ((uint32_t)0x00000008) /* HCLK:20-35 MHz; MDC clock= HCLK/16 */
+ #define ETH_MACMIIAR_CR_Div26 ((uint32_t)0x0000000C) /* HCLK:35-60 MHz; MDC clock= HCLK/26 */
+#define ETH_MACMIIAR_MW ((uint32_t)0x00000002) /* MII write */
+#define ETH_MACMIIAR_MB ((uint32_t)0x00000001) /* MII busy */
+
+/* Bit definition for Ethernet MAC MII Data Register */
+#define ETH_MACMIIDR_MD ((uint32_t)0x0000FFFF) /* MII data: read/write data from/to PHY */
+
+/* Bit definition for Ethernet MAC Flow Control Register */
+#define ETH_MACFCR_PT ((uint32_t)0xFFFF0000) /* Pause time */
+#define ETH_MACFCR_ZQPD ((uint32_t)0x00000080) /* Zero-quanta pause disable */
+#define ETH_MACFCR_PLT ((uint32_t)0x00000030) /* Pause low threshold: 4 cases */
+ #define ETH_MACFCR_PLT_Minus4 ((uint32_t)0x00000000) /* Pause time minus 4 slot times */
+ #define ETH_MACFCR_PLT_Minus28 ((uint32_t)0x00000010) /* Pause time minus 28 slot times */
+ #define ETH_MACFCR_PLT_Minus144 ((uint32_t)0x00000020) /* Pause time minus 144 slot times */
+ #define ETH_MACFCR_PLT_Minus256 ((uint32_t)0x00000030) /* Pause time minus 256 slot times */
+#define ETH_MACFCR_UPFD ((uint32_t)0x00000008) /* Unicast pause frame detect */
+#define ETH_MACFCR_RFCE ((uint32_t)0x00000004) /* Receive flow control enable */
+#define ETH_MACFCR_TFCE ((uint32_t)0x00000002) /* Transmit flow control enable */
+#define ETH_MACFCR_FCBBPA ((uint32_t)0x00000001) /* Flow control busy/backpressure activate */
+
+/* Bit definition for Ethernet MAC VLAN Tag Register */
+#define ETH_MACVLANTR_VLANTC ((uint32_t)0x00010000) /* 12-bit VLAN tag comparison */
+#define ETH_MACVLANTR_VLANTI ((uint32_t)0x0000FFFF) /* VLAN tag identifier (for receive frames) */
+
+/* Bit definition for Ethernet MAC Remote Wake-UpFrame Filter Register */
+#define ETH_MACRWUFFR_D ((uint32_t)0xFFFFFFFF) /* Wake-up frame filter register data */
+/* Eight sequential Writes to this address (offset 0x28) will write all Wake-UpFrame Filter Registers.
+ Eight sequential Reads from this address (offset 0x28) will read all Wake-UpFrame Filter Registers. */
+/* Wake-UpFrame Filter Reg0 : Filter 0 Byte Mask
+ Wake-UpFrame Filter Reg1 : Filter 1 Byte Mask
+ Wake-UpFrame Filter Reg2 : Filter 2 Byte Mask
+ Wake-UpFrame Filter Reg3 : Filter 3 Byte Mask
+ Wake-UpFrame Filter Reg4 : RSVD - Filter3 Command - RSVD - Filter2 Command -
+ RSVD - Filter1 Command - RSVD - Filter0 Command
+ Wake-UpFrame Filter Re5 : Filter3 Offset - Filter2 Offset - Filter1 Offset - Filter0 Offset
+ Wake-UpFrame Filter Re6 : Filter1 CRC16 - Filter0 CRC16
+ Wake-UpFrame Filter Re7 : Filter3 CRC16 - Filter2 CRC16 */
+
+/* Bit definition for Ethernet MAC PMT Control and Status Register */
+#define ETH_MACPMTCSR_WFFRPR ((uint32_t)0x80000000) /* Wake-Up Frame Filter Register Pointer Reset */
+#define ETH_MACPMTCSR_GU ((uint32_t)0x00000200) /* Global Unicast */
+#define ETH_MACPMTCSR_WFR ((uint32_t)0x00000040) /* Wake-Up Frame Received */
+#define ETH_MACPMTCSR_MPR ((uint32_t)0x00000020) /* Magic Packet Received */
+#define ETH_MACPMTCSR_WFE ((uint32_t)0x00000004) /* Wake-Up Frame Enable */
+#define ETH_MACPMTCSR_MPE ((uint32_t)0x00000002) /* Magic Packet Enable */
+#define ETH_MACPMTCSR_PD ((uint32_t)0x00000001) /* Power Down */
+
+/* Bit definition for Ethernet MAC Status Register */
+#define ETH_MACSR_TSTS ((uint32_t)0x00000200) /* Time stamp trigger status */
+#define ETH_MACSR_MMCTS ((uint32_t)0x00000040) /* MMC transmit status */
+#define ETH_MACSR_MMMCRS ((uint32_t)0x00000020) /* MMC receive status */
+#define ETH_MACSR_MMCS ((uint32_t)0x00000010) /* MMC status */
+#define ETH_MACSR_PMTS ((uint32_t)0x00000008) /* PMT status */
+
+/* Bit definition for Ethernet MAC Interrupt Mask Register */
+#define ETH_MACIMR_TSTIM ((uint32_t)0x00000200) /* Time stamp trigger interrupt mask */
+#define ETH_MACIMR_PMTIM ((uint32_t)0x00000008) /* PMT interrupt mask */
+
+/* Bit definition for Ethernet MAC Address0 High Register */
+#define ETH_MACA0HR_MACA0H ((uint32_t)0x0000FFFF) /* MAC address0 high */
+
+/* Bit definition for Ethernet MAC Address0 Low Register */
+#define ETH_MACA0LR_MACA0L ((uint32_t)0xFFFFFFFF) /* MAC address0 low */
+
+/* Bit definition for Ethernet MAC Address1 High Register */
+#define ETH_MACA1HR_AE ((uint32_t)0x80000000) /* Address enable */
+#define ETH_MACA1HR_SA ((uint32_t)0x40000000) /* Source address */
+#define ETH_MACA1HR_MBC ((uint32_t)0x3F000000) /* Mask byte control: bits to mask for comparison of the MAC Address bytes */
+ #define ETH_MACA1HR_MBC_HBits15_8 ((uint32_t)0x20000000) /* Mask MAC Address high reg bits [15:8] */
+ #define ETH_MACA1HR_MBC_HBits7_0 ((uint32_t)0x10000000) /* Mask MAC Address high reg bits [7:0] */
+ #define ETH_MACA1HR_MBC_LBits31_24 ((uint32_t)0x08000000) /* Mask MAC Address low reg bits [31:24] */
+ #define ETH_MACA1HR_MBC_LBits23_16 ((uint32_t)0x04000000) /* Mask MAC Address low reg bits [23:16] */
+ #define ETH_MACA1HR_MBC_LBits15_8 ((uint32_t)0x02000000) /* Mask MAC Address low reg bits [15:8] */
+ #define ETH_MACA1HR_MBC_LBits7_0 ((uint32_t)0x01000000) /* Mask MAC Address low reg bits [7:0] */
+#define ETH_MACA1HR_MACA1H ((uint32_t)0x0000FFFF) /* MAC address1 high */
+
+/* Bit definition for Ethernet MAC Address1 Low Register */
+#define ETH_MACA1LR_MACA1L ((uint32_t)0xFFFFFFFF) /* MAC address1 low */
+
+/* Bit definition for Ethernet MAC Address2 High Register */
+#define ETH_MACA2HR_AE ((uint32_t)0x80000000) /* Address enable */
+#define ETH_MACA2HR_SA ((uint32_t)0x40000000) /* Source address */
+#define ETH_MACA2HR_MBC ((uint32_t)0x3F000000) /* Mask byte control */
+ #define ETH_MACA2HR_MBC_HBits15_8 ((uint32_t)0x20000000) /* Mask MAC Address high reg bits [15:8] */
+ #define ETH_MACA2HR_MBC_HBits7_0 ((uint32_t)0x10000000) /* Mask MAC Address high reg bits [7:0] */
+ #define ETH_MACA2HR_MBC_LBits31_24 ((uint32_t)0x08000000) /* Mask MAC Address low reg bits [31:24] */
+ #define ETH_MACA2HR_MBC_LBits23_16 ((uint32_t)0x04000000) /* Mask MAC Address low reg bits [23:16] */
+ #define ETH_MACA2HR_MBC_LBits15_8 ((uint32_t)0x02000000) /* Mask MAC Address low reg bits [15:8] */
+ #define ETH_MACA2HR_MBC_LBits7_0 ((uint32_t)0x01000000) /* Mask MAC Address low reg bits [70] */
+#define ETH_MACA2HR_MACA2H ((uint32_t)0x0000FFFF) /* MAC address1 high */
+
+/* Bit definition for Ethernet MAC Address2 Low Register */
+#define ETH_MACA2LR_MACA2L ((uint32_t)0xFFFFFFFF) /* MAC address2 low */
+
+/* Bit definition for Ethernet MAC Address3 High Register */
+#define ETH_MACA3HR_AE ((uint32_t)0x80000000) /* Address enable */
+#define ETH_MACA3HR_SA ((uint32_t)0x40000000) /* Source address */
+#define ETH_MACA3HR_MBC ((uint32_t)0x3F000000) /* Mask byte control */
+ #define ETH_MACA3HR_MBC_HBits15_8 ((uint32_t)0x20000000) /* Mask MAC Address high reg bits [15:8] */
+ #define ETH_MACA3HR_MBC_HBits7_0 ((uint32_t)0x10000000) /* Mask MAC Address high reg bits [7:0] */
+ #define ETH_MACA3HR_MBC_LBits31_24 ((uint32_t)0x08000000) /* Mask MAC Address low reg bits [31:24] */
+ #define ETH_MACA3HR_MBC_LBits23_16 ((uint32_t)0x04000000) /* Mask MAC Address low reg bits [23:16] */
+ #define ETH_MACA3HR_MBC_LBits15_8 ((uint32_t)0x02000000) /* Mask MAC Address low reg bits [15:8] */
+ #define ETH_MACA3HR_MBC_LBits7_0 ((uint32_t)0x01000000) /* Mask MAC Address low reg bits [70] */
+#define ETH_MACA3HR_MACA3H ((uint32_t)0x0000FFFF) /* MAC address3 high */
+
+/* Bit definition for Ethernet MAC Address3 Low Register */
+#define ETH_MACA3LR_MACA3L ((uint32_t)0xFFFFFFFF) /* MAC address3 low */
+
+/******************************************************************************/
+/* Ethernet MMC Registers bits definition */
+/******************************************************************************/
+
+/* Bit definition for Ethernet MMC Contol Register */
+#define ETH_MMCCR_MCF ((uint32_t)0x00000008) /* MMC Counter Freeze */
+#define ETH_MMCCR_ROR ((uint32_t)0x00000004) /* Reset on Read */
+#define ETH_MMCCR_CSR ((uint32_t)0x00000002) /* Counter Stop Rollover */
+#define ETH_MMCCR_CR ((uint32_t)0x00000001) /* Counters Reset */
+
+/* Bit definition for Ethernet MMC Receive Interrupt Register */
+#define ETH_MMCRIR_RGUFS ((uint32_t)0x00020000) /* Set when Rx good unicast frames counter reaches half the maximum value */
+#define ETH_MMCRIR_RFAES ((uint32_t)0x00000040) /* Set when Rx alignment error counter reaches half the maximum value */
+#define ETH_MMCRIR_RFCES ((uint32_t)0x00000020) /* Set when Rx crc error counter reaches half the maximum value */
+
+/* Bit definition for Ethernet MMC Transmit Interrupt Register */
+#define ETH_MMCTIR_TGFS ((uint32_t)0x00200000) /* Set when Tx good frame count counter reaches half the maximum value */
+#define ETH_MMCTIR_TGFMSCS ((uint32_t)0x00008000) /* Set when Tx good multi col counter reaches half the maximum value */
+#define ETH_MMCTIR_TGFSCS ((uint32_t)0x00004000) /* Set when Tx good single col counter reaches half the maximum value */
+
+/* Bit definition for Ethernet MMC Receive Interrupt Mask Register */
+#define ETH_MMCRIMR_RGUFM ((uint32_t)0x00020000) /* Mask the interrupt when Rx good unicast frames counter reaches half the maximum value */
+#define ETH_MMCRIMR_RFAEM ((uint32_t)0x00000040) /* Mask the interrupt when when Rx alignment error counter reaches half the maximum value */
+#define ETH_MMCRIMR_RFCEM ((uint32_t)0x00000020) /* Mask the interrupt when Rx crc error counter reaches half the maximum value */
+
+/* Bit definition for Ethernet MMC Transmit Interrupt Mask Register */
+#define ETH_MMCTIMR_TGFM ((uint32_t)0x00200000) /* Mask the interrupt when Tx good frame count counter reaches half the maximum value */
+#define ETH_MMCTIMR_TGFMSCM ((uint32_t)0x00008000) /* Mask the interrupt when Tx good multi col counter reaches half the maximum value */
+#define ETH_MMCTIMR_TGFSCM ((uint32_t)0x00004000) /* Mask the interrupt when Tx good single col counter reaches half the maximum value */
+
+/* Bit definition for Ethernet MMC Transmitted Good Frames after Single Collision Counter Register */
+#define ETH_MMCTGFSCCR_TGFSCC ((uint32_t)0xFFFFFFFF) /* Number of successfully transmitted frames after a single collision in Half-duplex mode. */
+
+/* Bit definition for Ethernet MMC Transmitted Good Frames after More than a Single Collision Counter Register */
+#define ETH_MMCTGFMSCCR_TGFMSCC ((uint32_t)0xFFFFFFFF) /* Number of successfully transmitted frames after more than a single collision in Half-duplex mode. */
+
+/* Bit definition for Ethernet MMC Transmitted Good Frames Counter Register */
+#define ETH_MMCTGFCR_TGFC ((uint32_t)0xFFFFFFFF) /* Number of good frames transmitted. */
+
+/* Bit definition for Ethernet MMC Received Frames with CRC Error Counter Register */
+#define ETH_MMCRFCECR_RFCEC ((uint32_t)0xFFFFFFFF) /* Number of frames received with CRC error. */
+
+/* Bit definition for Ethernet MMC Received Frames with Alignement Error Counter Register */
+#define ETH_MMCRFAECR_RFAEC ((uint32_t)0xFFFFFFFF) /* Number of frames received with alignment (dribble) error */
+
+/* Bit definition for Ethernet MMC Received Good Unicast Frames Counter Register */
+#define ETH_MMCRGUFCR_RGUFC ((uint32_t)0xFFFFFFFF) /* Number of good unicast frames received. */
+
+/******************************************************************************/
+/* Ethernet PTP Registers bits definition */
+/******************************************************************************/
+
+/* Bit definition for Ethernet PTP Time Stamp Contol Register */
+#define ETH_PTPTSCR_TSARU ((uint32_t)0x00000020) /* Addend register update */
+#define ETH_PTPTSCR_TSITE ((uint32_t)0x00000010) /* Time stamp interrupt trigger enable */
+#define ETH_PTPTSCR_TSSTU ((uint32_t)0x00000008) /* Time stamp update */
+#define ETH_PTPTSCR_TSSTI ((uint32_t)0x00000004) /* Time stamp initialize */
+#define ETH_PTPTSCR_TSFCU ((uint32_t)0x00000002) /* Time stamp fine or coarse update */
+#define ETH_PTPTSCR_TSE ((uint32_t)0x00000001) /* Time stamp enable */
+
+/* Bit definition for Ethernet PTP Sub-Second Increment Register */
+#define ETH_PTPSSIR_STSSI ((uint32_t)0x000000FF) /* System time Sub-second increment value */
+
+/* Bit definition for Ethernet PTP Time Stamp High Register */
+#define ETH_PTPTSHR_STS ((uint32_t)0xFFFFFFFF) /* System Time second */
+
+/* Bit definition for Ethernet PTP Time Stamp Low Register */
+#define ETH_PTPTSLR_STPNS ((uint32_t)0x80000000) /* System Time Positive or negative time */
+#define ETH_PTPTSLR_STSS ((uint32_t)0x7FFFFFFF) /* System Time sub-seconds */
+
+/* Bit definition for Ethernet PTP Time Stamp High Update Register */
+#define ETH_PTPTSHUR_TSUS ((uint32_t)0xFFFFFFFF) /* Time stamp update seconds */
+
+/* Bit definition for Ethernet PTP Time Stamp Low Update Register */
+#define ETH_PTPTSLUR_TSUPNS ((uint32_t)0x80000000) /* Time stamp update Positive or negative time */
+#define ETH_PTPTSLUR_TSUSS ((uint32_t)0x7FFFFFFF) /* Time stamp update sub-seconds */
+
+/* Bit definition for Ethernet PTP Time Stamp Addend Register */
+#define ETH_PTPTSAR_TSA ((uint32_t)0xFFFFFFFF) /* Time stamp addend */
+
+/* Bit definition for Ethernet PTP Target Time High Register */
+#define ETH_PTPTTHR_TTSH ((uint32_t)0xFFFFFFFF) /* Target time stamp high */
+
+/* Bit definition for Ethernet PTP Target Time Low Register */
+#define ETH_PTPTTLR_TTSL ((uint32_t)0xFFFFFFFF) /* Target time stamp low */
+
+/******************************************************************************/
+/* Ethernet DMA Registers bits definition */
+/******************************************************************************/
+
+/* Bit definition for Ethernet DMA Bus Mode Register */
+#define ETH_DMABMR_AAB ((uint32_t)0x02000000) /* Address-Aligned beats */
+#define ETH_DMABMR_FPM ((uint32_t)0x01000000) /* 4xPBL mode */
+#define ETH_DMABMR_USP ((uint32_t)0x00800000) /* Use separate PBL */
+#define ETH_DMABMR_RDP ((uint32_t)0x007E0000) /* RxDMA PBL */
+ #define ETH_DMABMR_RDP_1Beat ((uint32_t)0x00020000) /* maximum number of beats to be transferred in one RxDMA transaction is 1 */
+ #define ETH_DMABMR_RDP_2Beat ((uint32_t)0x00040000) /* maximum number of beats to be transferred in one RxDMA transaction is 2 */
+ #define ETH_DMABMR_RDP_4Beat ((uint32_t)0x00080000) /* maximum number of beats to be transferred in one RxDMA transaction is 4 */
+ #define ETH_DMABMR_RDP_8Beat ((uint32_t)0x00100000) /* maximum number of beats to be transferred in one RxDMA transaction is 8 */
+ #define ETH_DMABMR_RDP_16Beat ((uint32_t)0x00200000) /* maximum number of beats to be transferred in one RxDMA transaction is 16 */
+ #define ETH_DMABMR_RDP_32Beat ((uint32_t)0x00400000) /* maximum number of beats to be transferred in one RxDMA transaction is 32 */
+ #define ETH_DMABMR_RDP_4xPBL_4Beat ((uint32_t)0x01020000) /* maximum number of beats to be transferred in one RxDMA transaction is 4 */
+ #define ETH_DMABMR_RDP_4xPBL_8Beat ((uint32_t)0x01040000) /* maximum number of beats to be transferred in one RxDMA transaction is 8 */
+ #define ETH_DMABMR_RDP_4xPBL_16Beat ((uint32_t)0x01080000) /* maximum number of beats to be transferred in one RxDMA transaction is 16 */
+ #define ETH_DMABMR_RDP_4xPBL_32Beat ((uint32_t)0x01100000) /* maximum number of beats to be transferred in one RxDMA transaction is 32 */
+ #define ETH_DMABMR_RDP_4xPBL_64Beat ((uint32_t)0x01200000) /* maximum number of beats to be transferred in one RxDMA transaction is 64 */
+ #define ETH_DMABMR_RDP_4xPBL_128Beat ((uint32_t)0x01400000) /* maximum number of beats to be transferred in one RxDMA transaction is 128 */
+#define ETH_DMABMR_FB ((uint32_t)0x00010000) /* Fixed Burst */
+#define ETH_DMABMR_RTPR ((uint32_t)0x0000C000) /* Rx Tx priority ratio */
+ #define ETH_DMABMR_RTPR_1_1 ((uint32_t)0x00000000) /* Rx Tx priority ratio */
+ #define ETH_DMABMR_RTPR_2_1 ((uint32_t)0x00004000) /* Rx Tx priority ratio */
+ #define ETH_DMABMR_RTPR_3_1 ((uint32_t)0x00008000) /* Rx Tx priority ratio */
+ #define ETH_DMABMR_RTPR_4_1 ((uint32_t)0x0000C000) /* Rx Tx priority ratio */
+#define ETH_DMABMR_PBL ((uint32_t)0x00003F00) /* Programmable burst length */
+ #define ETH_DMABMR_PBL_1Beat ((uint32_t)0x00000100) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 1 */
+ #define ETH_DMABMR_PBL_2Beat ((uint32_t)0x00000200) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 2 */
+ #define ETH_DMABMR_PBL_4Beat ((uint32_t)0x00000400) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */
+ #define ETH_DMABMR_PBL_8Beat ((uint32_t)0x00000800) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */
+ #define ETH_DMABMR_PBL_16Beat ((uint32_t)0x00001000) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */
+ #define ETH_DMABMR_PBL_32Beat ((uint32_t)0x00002000) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */
+ #define ETH_DMABMR_PBL_4xPBL_4Beat ((uint32_t)0x01000100) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */
+ #define ETH_DMABMR_PBL_4xPBL_8Beat ((uint32_t)0x01000200) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */
+ #define ETH_DMABMR_PBL_4xPBL_16Beat ((uint32_t)0x01000400) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */
+ #define ETH_DMABMR_PBL_4xPBL_32Beat ((uint32_t)0x01000800) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */
+ #define ETH_DMABMR_PBL_4xPBL_64Beat ((uint32_t)0x01001000) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 64 */
+ #define ETH_DMABMR_PBL_4xPBL_128Beat ((uint32_t)0x01002000) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 128 */
+#define ETH_DMABMR_DSL ((uint32_t)0x0000007C) /* Descriptor Skip Length */
+#define ETH_DMABMR_DA ((uint32_t)0x00000002) /* DMA arbitration scheme */
+#define ETH_DMABMR_SR ((uint32_t)0x00000001) /* Software reset */
+
+/* Bit definition for Ethernet DMA Transmit Poll Demand Register */
+#define ETH_DMATPDR_TPD ((uint32_t)0xFFFFFFFF) /* Transmit poll demand */
+
+/* Bit definition for Ethernet DMA Receive Poll Demand Register */
+#define ETH_DMARPDR_RPD ((uint32_t)0xFFFFFFFF) /* Receive poll demand */
+
+/* Bit definition for Ethernet DMA Receive Descriptor List Address Register */
+#define ETH_DMARDLAR_SRL ((uint32_t)0xFFFFFFFF) /* Start of receive list */
+
+/* Bit definition for Ethernet DMA Transmit Descriptor List Address Register */
+#define ETH_DMATDLAR_STL ((uint32_t)0xFFFFFFFF) /* Start of transmit list */
+
+/* Bit definition for Ethernet DMA Status Register */
+#define ETH_DMASR_TSTS ((uint32_t)0x20000000) /* Time-stamp trigger status */
+#define ETH_DMASR_PMTS ((uint32_t)0x10000000) /* PMT status */
+#define ETH_DMASR_MMCS ((uint32_t)0x08000000) /* MMC status */
+#define ETH_DMASR_EBS ((uint32_t)0x03800000) /* Error bits status */
+ /* combination with EBS[2:0] for GetFlagStatus function */
+ #define ETH_DMASR_EBS_DescAccess ((uint32_t)0x02000000) /* Error bits 0-data buffer, 1-desc. access */
+ #define ETH_DMASR_EBS_ReadTransf ((uint32_t)0x01000000) /* Error bits 0-write trnsf, 1-read transfr */
+ #define ETH_DMASR_EBS_DataTransfTx ((uint32_t)0x00800000) /* Error bits 0-Rx DMA, 1-Tx DMA */
+#define ETH_DMASR_TPS ((uint32_t)0x00700000) /* Transmit process state */
+ #define ETH_DMASR_TPS_Stopped ((uint32_t)0x00000000) /* Stopped - Reset or Stop Tx Command issued */
+ #define ETH_DMASR_TPS_Fetching ((uint32_t)0x00100000) /* Running - fetching the Tx descriptor */
+ #define ETH_DMASR_TPS_Waiting ((uint32_t)0x00200000) /* Running - waiting for status */
+ #define ETH_DMASR_TPS_Reading ((uint32_t)0x00300000) /* Running - reading the data from host memory */
+ #define ETH_DMASR_TPS_Suspended ((uint32_t)0x00600000) /* Suspended - Tx Descriptor unavailabe */
+ #define ETH_DMASR_TPS_Closing ((uint32_t)0x00700000) /* Running - closing Rx descriptor */
+#define ETH_DMASR_RPS ((uint32_t)0x000E0000) /* Receive process state */
+ #define ETH_DMASR_RPS_Stopped ((uint32_t)0x00000000) /* Stopped - Reset or Stop Rx Command issued */
+ #define ETH_DMASR_RPS_Fetching ((uint32_t)0x00020000) /* Running - fetching the Rx descriptor */
+ #define ETH_DMASR_RPS_Waiting ((uint32_t)0x00060000) /* Running - waiting for packet */
+ #define ETH_DMASR_RPS_Suspended ((uint32_t)0x00080000) /* Suspended - Rx Descriptor unavailable */
+ #define ETH_DMASR_RPS_Closing ((uint32_t)0x000A0000) /* Running - closing descriptor */
+ #define ETH_DMASR_RPS_Queuing ((uint32_t)0x000E0000) /* Running - queuing the recieve frame into host memory */
+#define ETH_DMASR_NIS ((uint32_t)0x00010000) /* Normal interrupt summary */
+#define ETH_DMASR_AIS ((uint32_t)0x00008000) /* Abnormal interrupt summary */
+#define ETH_DMASR_ERS ((uint32_t)0x00004000) /* Early receive status */
+#define ETH_DMASR_FBES ((uint32_t)0x00002000) /* Fatal bus error status */
+#define ETH_DMASR_ETS ((uint32_t)0x00000400) /* Early transmit status */
+#define ETH_DMASR_RWTS ((uint32_t)0x00000200) /* Receive watchdog timeout status */
+#define ETH_DMASR_RPSS ((uint32_t)0x00000100) /* Receive process stopped status */
+#define ETH_DMASR_RBUS ((uint32_t)0x00000080) /* Receive buffer unavailable status */
+#define ETH_DMASR_RS ((uint32_t)0x00000040) /* Receive status */
+#define ETH_DMASR_TUS ((uint32_t)0x00000020) /* Transmit underflow status */
+#define ETH_DMASR_ROS ((uint32_t)0x00000010) /* Receive overflow status */
+#define ETH_DMASR_TJTS ((uint32_t)0x00000008) /* Transmit jabber timeout status */
+#define ETH_DMASR_TBUS ((uint32_t)0x00000004) /* Transmit buffer unavailable status */
+#define ETH_DMASR_TPSS ((uint32_t)0x00000002) /* Transmit process stopped status */
+#define ETH_DMASR_TS ((uint32_t)0x00000001) /* Transmit status */
+
+/* Bit definition for Ethernet DMA Operation Mode Register */
+#define ETH_DMAOMR_DTCEFD ((uint32_t)0x04000000) /* Disable Dropping of TCP/IP checksum error frames */
+#define ETH_DMAOMR_RSF ((uint32_t)0x02000000) /* Receive store and forward */
+#define ETH_DMAOMR_DFRF ((uint32_t)0x01000000) /* Disable flushing of received frames */
+#define ETH_DMAOMR_TSF ((uint32_t)0x00200000) /* Transmit store and forward */
+#define ETH_DMAOMR_FTF ((uint32_t)0x00100000) /* Flush transmit FIFO */
+#define ETH_DMAOMR_TTC ((uint32_t)0x0001C000) /* Transmit threshold control */
+ #define ETH_DMAOMR_TTC_64Bytes ((uint32_t)0x00000000) /* threshold level of the MTL Transmit FIFO is 64 Bytes */
+ #define ETH_DMAOMR_TTC_128Bytes ((uint32_t)0x00004000) /* threshold level of the MTL Transmit FIFO is 128 Bytes */
+ #define ETH_DMAOMR_TTC_192Bytes ((uint32_t)0x00008000) /* threshold level of the MTL Transmit FIFO is 192 Bytes */
+ #define ETH_DMAOMR_TTC_256Bytes ((uint32_t)0x0000C000) /* threshold level of the MTL Transmit FIFO is 256 Bytes */
+ #define ETH_DMAOMR_TTC_40Bytes ((uint32_t)0x00010000) /* threshold level of the MTL Transmit FIFO is 40 Bytes */
+ #define ETH_DMAOMR_TTC_32Bytes ((uint32_t)0x00014000) /* threshold level of the MTL Transmit FIFO is 32 Bytes */
+ #define ETH_DMAOMR_TTC_24Bytes ((uint32_t)0x00018000) /* threshold level of the MTL Transmit FIFO is 24 Bytes */
+ #define ETH_DMAOMR_TTC_16Bytes ((uint32_t)0x0001C000) /* threshold level of the MTL Transmit FIFO is 16 Bytes */
+#define ETH_DMAOMR_ST ((uint32_t)0x00002000) /* Start/stop transmission command */
+#define ETH_DMAOMR_FEF ((uint32_t)0x00000080) /* Forward error frames */
+#define ETH_DMAOMR_FUGF ((uint32_t)0x00000040) /* Forward undersized good frames */
+#define ETH_DMAOMR_RTC ((uint32_t)0x00000018) /* receive threshold control */
+ #define ETH_DMAOMR_RTC_64Bytes ((uint32_t)0x00000000) /* threshold level of the MTL Receive FIFO is 64 Bytes */
+ #define ETH_DMAOMR_RTC_32Bytes ((uint32_t)0x00000008) /* threshold level of the MTL Receive FIFO is 32 Bytes */
+ #define ETH_DMAOMR_RTC_96Bytes ((uint32_t)0x00000010) /* threshold level of the MTL Receive FIFO is 96 Bytes */
+ #define ETH_DMAOMR_RTC_128Bytes ((uint32_t)0x00000018) /* threshold level of the MTL Receive FIFO is 128 Bytes */
+#define ETH_DMAOMR_OSF ((uint32_t)0x00000004) /* operate on second frame */
+#define ETH_DMAOMR_SR ((uint32_t)0x00000002) /* Start/stop receive */
+
+/* Bit definition for Ethernet DMA Interrupt Enable Register */
+#define ETH_DMAIER_NISE ((uint32_t)0x00010000) /* Normal interrupt summary enable */
+#define ETH_DMAIER_AISE ((uint32_t)0x00008000) /* Abnormal interrupt summary enable */
+#define ETH_DMAIER_ERIE ((uint32_t)0x00004000) /* Early receive interrupt enable */
+#define ETH_DMAIER_FBEIE ((uint32_t)0x00002000) /* Fatal bus error interrupt enable */
+#define ETH_DMAIER_ETIE ((uint32_t)0x00000400) /* Early transmit interrupt enable */
+#define ETH_DMAIER_RWTIE ((uint32_t)0x00000200) /* Receive watchdog timeout interrupt enable */
+#define ETH_DMAIER_RPSIE ((uint32_t)0x00000100) /* Receive process stopped interrupt enable */
+#define ETH_DMAIER_RBUIE ((uint32_t)0x00000080) /* Receive buffer unavailable interrupt enable */
+#define ETH_DMAIER_RIE ((uint32_t)0x00000040) /* Receive interrupt enable */
+#define ETH_DMAIER_TUIE ((uint32_t)0x00000020) /* Transmit Underflow interrupt enable */
+#define ETH_DMAIER_ROIE ((uint32_t)0x00000010) /* Receive Overflow interrupt enable */
+#define ETH_DMAIER_TJTIE ((uint32_t)0x00000008) /* Transmit jabber timeout interrupt enable */
+#define ETH_DMAIER_TBUIE ((uint32_t)0x00000004) /* Transmit buffer unavailable interrupt enable */
+#define ETH_DMAIER_TPSIE ((uint32_t)0x00000002) /* Transmit process stopped interrupt enable */
+#define ETH_DMAIER_TIE ((uint32_t)0x00000001) /* Transmit interrupt enable */
+
+/* Bit definition for Ethernet DMA Missed Frame and Buffer Overflow Counter Register */
+#define ETH_DMAMFBOCR_OFOC ((uint32_t)0x10000000) /* Overflow bit for FIFO overflow counter */
+#define ETH_DMAMFBOCR_MFA ((uint32_t)0x0FFE0000) /* Number of frames missed by the application */
+#define ETH_DMAMFBOCR_OMFC ((uint32_t)0x00010000) /* Overflow bit for missed frame counter */
+#define ETH_DMAMFBOCR_MFC ((uint32_t)0x0000FFFF) /* Number of frames missed by the controller */
+
+/* Bit definition for Ethernet DMA Current Host Transmit Descriptor Register */
+#define ETH_DMACHTDR_HTDAP ((uint32_t)0xFFFFFFFF) /* Host transmit descriptor address pointer */
+
+/* Bit definition for Ethernet DMA Current Host Receive Descriptor Register */
+#define ETH_DMACHRDR_HRDAP ((uint32_t)0xFFFFFFFF) /* Host receive descriptor address pointer */
+
+/* Bit definition for Ethernet DMA Current Host Transmit Buffer Address Register */
+#define ETH_DMACHTBAR_HTBAP ((uint32_t)0xFFFFFFFF) /* Host transmit buffer address pointer */
+
+/* Bit definition for Ethernet DMA Current Host Receive Buffer Address Register */
+#define ETH_DMACHRBAR_HRBAP ((uint32_t)0xFFFFFFFF) /* Host receive buffer address pointer */
+#endif /* STM32F10X_CL */
+
+/**
+ * @}
+ */
+
+ /**
+ * @}
+ */
+
+#ifdef USE_STDPERIPH_DRIVER
+ #include "stm32f10x_conf.h"
+#endif
+
+/** @addtogroup Exported_macro
+ * @{
+ */
+
+#define SET_BIT(REG, BIT) ((REG) |= (BIT))
+
+#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
+
+#define READ_BIT(REG, BIT) ((REG) & (BIT))
+
+#define CLEAR_REG(REG) ((REG) = (0x0))
+
+#define WRITE_REG(REG, VAL) ((REG) = (VAL))
+
+#define READ_REG(REG) ((REG))
+
+#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F10x_H */
+
+/**
+ * @}
+ */
+
+ /**
+ * @}
+ */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/stm32f10x_conf.h b/st_fw_lib/stm32f10x_conf.h
new file mode 100644
index 0000000..b0a0df2
--- /dev/null
+++ b/st_fw_lib/stm32f10x_conf.h
@@ -0,0 +1,77 @@
+/**
+ ******************************************************************************
+ * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_conf.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 08-April-2011
+ * @brief Library configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_CONF_H
+#define __STM32F10x_CONF_H
+
+/* Includes ------------------------------------------------------------------*/
+/* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */
+#include "inc/stm32f10x_adc.h"
+#include "inc/stm32f10x_bkp.h"
+#include "inc/stm32f10x_can.h"
+#include "inc/stm32f10x_cec.h"
+#include "inc/stm32f10x_crc.h"
+#include "inc/stm32f10x_dac.h"
+#include "inc/stm32f10x_dbgmcu.h"
+#include "inc/stm32f10x_dma.h"
+#include "inc/stm32f10x_exti.h"
+#include "inc/stm32f10x_flash.h"
+#include "inc/stm32f10x_fsmc.h"
+#include "inc/stm32f10x_gpio.h"
+#include "inc/stm32f10x_i2c.h"
+#include "inc/stm32f10x_iwdg.h"
+#include "inc/stm32f10x_pwr.h"
+#include "inc/stm32f10x_rcc.h"
+#include "inc/stm32f10x_rtc.h"
+#include "inc/stm32f10x_sdio.h"
+#include "inc/stm32f10x_spi.h"
+#include "inc/stm32f10x_tim.h"
+#include "inc/stm32f10x_usart.h"
+#include "inc/stm32f10x_wwdg.h"
+#include "inc/misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Uncomment the line below to expanse the "assert_param" macro in the
+ Standard Peripheral Library drivers code */
+/* #define USE_FULL_ASSERT 1 */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function which reports
+ * the name of the source file and the source line number of the call
+ * that failed. If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0)
+#endif /* USE_FULL_ASSERT */
+
+#endif /* __STM32F10x_CONF_H */
+
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/system_stm32f10x.c b/st_fw_lib/system_stm32f10x.c
new file mode 100644
index 0000000..1cb760e
--- /dev/null
+++ b/st_fw_lib/system_stm32f10x.c
@@ -0,0 +1,1094 @@
+/**
+ ******************************************************************************
+ * @file system_stm32f10x.c
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 08-April-2011
+ * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.
+ *
+ * 1. This file provides two functions and one global variable to be called from
+ * user application:
+ * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
+ * factors, AHB/APBx prescalers and Flash settings).
+ * This function is called at startup just after reset and
+ * before branch to main program. This call is made inside
+ * the "startup_stm32f10x_xx.s" file.
+ *
+ * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
+ * by the user application to setup the SysTick
+ * timer or configure other parameters.
+ *
+ * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
+ * be called whenever the core clock is changed
+ * during program execution.
+ *
+ * 2. After each device reset the HSI (8 MHz) is used as system clock source.
+ * Then SystemInit() function is called, in "startup_stm32f10x_xx.s" file, to
+ * configure the system clock before to branch to main program.
+ *
+ * 3. If the system clock source selected by user fails to startup, the SystemInit()
+ * function will do nothing and HSI still used as system clock source. User can
+ * add some code to deal with this issue inside the SetSysClock() function.
+ *
+ * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depedning on
+ * the product used), refer to "HSE_VALUE" define in "stm32f10x.h" file.
+ * When HSE is used as system clock source, directly or through PLL, and you
+ * are using different crystal you have to adapt the HSE value to your own
+ * configuration.
+ *
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/** @addtogroup CMSIS
+ * @{
+ */
+
+/** @addtogroup stm32f10x_system
+ * @{
+ */
+
+/** @addtogroup STM32F10x_System_Private_Includes
+ * @{
+ */
+
+#include "stm32f10x.h"
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F10x_System_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F10x_System_Private_Defines
+ * @{
+ */
+
+/*!< Uncomment the line corresponding to the desired System clock (SYSCLK)
+ frequency (after reset the HSI is used as SYSCLK source)
+
+ IMPORTANT NOTE:
+ ==============
+ 1. After each device reset the HSI is used as System clock source.
+
+ 2. Please make sure that the selected System clock doesn't exceed your device's
+ maximum frequency.
+
+ 3. If none of the define below is enabled, the HSI is used as System clock
+ source.
+
+ 4. The System clock configuration functions provided within this file assume that:
+ - For Low, Medium and High density Value line devices an external 8MHz
+ crystal is used to drive the System clock.
+ - For Low, Medium and High density devices an external 8MHz crystal is
+ used to drive the System clock.
+ - For Connectivity line devices an external 25MHz crystal is used to drive
+ the System clock.
+ If you are using different crystal you have to adapt those functions accordingly.
+ */
+
+#if defined (STM32F10X_LD_VL) || (defined STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
+/* #define SYSCLK_FREQ_HSE HSE_VALUE */
+ #define SYSCLK_FREQ_24MHz 24000000
+#else
+/* #define SYSCLK_FREQ_HSE HSE_VALUE */
+/* #define SYSCLK_FREQ_24MHz 24000000 */
+/* #define SYSCLK_FREQ_36MHz 36000000 */
+/* #define SYSCLK_FREQ_48MHz 48000000 */
+/* #define SYSCLK_FREQ_56MHz 56000000 */
+#define SYSCLK_FREQ_72MHz 72000000
+#endif
+
+/*!< Uncomment the following line if you need to use external SRAM mounted
+ on STM3210E-EVAL board (STM32 High density and XL-density devices) or on
+ STM32100E-EVAL board (STM32 High-density value line devices) as data memory */
+#if defined (STM32F10X_HD) || (defined STM32F10X_XL) || (defined STM32F10X_HD_VL)
+/* #define DATA_IN_ExtSRAM */
+#endif
+
+/*!< Uncomment the following line if you need to relocate your vector Table in
+ Internal SRAM. */
+/* #define VECT_TAB_SRAM */
+#define VECT_TAB_OFFSET 0x4000 /*!< Vector Table base offset field.
+ This value must be a multiple of 0x200. */
+
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F10x_System_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F10x_System_Private_Variables
+ * @{
+ */
+
+/*******************************************************************************
+* Clock Definitions
+*******************************************************************************/
+#ifdef SYSCLK_FREQ_HSE
+ uint32_t SystemCoreClock = SYSCLK_FREQ_HSE; /*!< System Clock Frequency (Core Clock) */
+#elif defined SYSCLK_FREQ_24MHz
+ uint32_t SystemCoreClock = SYSCLK_FREQ_24MHz; /*!< System Clock Frequency (Core Clock) */
+#elif defined SYSCLK_FREQ_36MHz
+ uint32_t SystemCoreClock = SYSCLK_FREQ_36MHz; /*!< System Clock Frequency (Core Clock) */
+#elif defined SYSCLK_FREQ_48MHz
+ uint32_t SystemCoreClock = SYSCLK_FREQ_48MHz; /*!< System Clock Frequency (Core Clock) */
+#elif defined SYSCLK_FREQ_56MHz
+ uint32_t SystemCoreClock = SYSCLK_FREQ_56MHz; /*!< System Clock Frequency (Core Clock) */
+#elif defined SYSCLK_FREQ_72MHz
+ uint32_t SystemCoreClock = SYSCLK_FREQ_72MHz; /*!< System Clock Frequency (Core Clock) */
+#else /*!< HSI Selected as System Clock source */
+ uint32_t SystemCoreClock = HSI_VALUE; /*!< System Clock Frequency (Core Clock) */
+#endif
+
+__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F10x_System_Private_FunctionPrototypes
+ * @{
+ */
+
+static void SetSysClock(void);
+
+#ifdef SYSCLK_FREQ_HSE
+ static void SetSysClockToHSE(void);
+#elif defined SYSCLK_FREQ_24MHz
+ static void SetSysClockTo24(void);
+#elif defined SYSCLK_FREQ_36MHz
+ static void SetSysClockTo36(void);
+#elif defined SYSCLK_FREQ_48MHz
+ static void SetSysClockTo48(void);
+#elif defined SYSCLK_FREQ_56MHz
+ static void SetSysClockTo56(void);
+#elif defined SYSCLK_FREQ_72MHz
+ static void SetSysClockTo72(void);
+#endif
+
+#ifdef DATA_IN_ExtSRAM
+ static void SystemInit_ExtMemCtl(void);
+#endif /* DATA_IN_ExtSRAM */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F10x_System_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Setup the microcontroller system
+ * Initialize the Embedded Flash Interface, the PLL and update the
+ * SystemCoreClock variable.
+ * @note This function should be used only after reset.
+ * @param None
+ * @retval None
+ */
+void SystemInit (void)
+{
+ /* Reset the RCC clock configuration to the default reset state(for debug purpose) */
+ /* Set HSION bit */
+ RCC->CR |= (uint32_t)0x00000001;
+
+ /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */
+#ifndef STM32F10X_CL
+ RCC->CFGR &= (uint32_t)0xF8FF0000;
+#else
+ RCC->CFGR &= (uint32_t)0xF0FF0000;
+#endif /* STM32F10X_CL */
+
+ /* Reset HSEON, CSSON and PLLON bits */
+ RCC->CR &= (uint32_t)0xFEF6FFFF;
+
+ /* Reset HSEBYP bit */
+ RCC->CR &= (uint32_t)0xFFFBFFFF;
+
+ /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */
+ RCC->CFGR &= (uint32_t)0xFF80FFFF;
+
+#ifdef STM32F10X_CL
+ /* Reset PLL2ON and PLL3ON bits */
+ RCC->CR &= (uint32_t)0xEBFFFFFF;
+
+ /* Disable all interrupts and clear pending bits */
+ RCC->CIR = 0x00FF0000;
+
+ /* Reset CFGR2 register */
+ RCC->CFGR2 = 0x00000000;
+#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
+ /* Disable all interrupts and clear pending bits */
+ RCC->CIR = 0x009F0000;
+
+ /* Reset CFGR2 register */
+ RCC->CFGR2 = 0x00000000;
+#else
+ /* Disable all interrupts and clear pending bits */
+ RCC->CIR = 0x009F0000;
+#endif /* STM32F10X_CL */
+
+#if defined (STM32F10X_HD) || (defined STM32F10X_XL) || (defined STM32F10X_HD_VL)
+ #ifdef DATA_IN_ExtSRAM
+ SystemInit_ExtMemCtl();
+ #endif /* DATA_IN_ExtSRAM */
+#endif
+
+ /* Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers */
+ /* Configure the Flash Latency cycles and enable prefetch buffer */
+ SetSysClock();
+
+#ifdef VECT_TAB_SRAM
+ SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
+#else
+ SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
+#endif
+}
+
+/**
+ * @brief Update SystemCoreClock variable according to Clock Register Values.
+ * The SystemCoreClock variable contains the core clock (HCLK), it can
+ * be used by the user application to setup the SysTick timer or configure
+ * other parameters.
+ *
+ * @note Each time the core clock (HCLK) changes, this function must be called
+ * to update SystemCoreClock variable value. Otherwise, any configuration
+ * based on this variable will be incorrect.
+ *
+ * @note - The system frequency computed by this function is not the real
+ * frequency in the chip. It is calculated based on the predefined
+ * constant and the selected clock source:
+ *
+ * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
+ *
+ * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
+ *
+ * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
+ * or HSI_VALUE(*) multiplied by the PLL factors.
+ *
+ * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value
+ * 8 MHz) but the real value may vary depending on the variations
+ * in voltage and temperature.
+ *
+ * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value
+ * 8 MHz or 25 MHz, depedning on the product used), user has to ensure
+ * that HSE_VALUE is same as the real frequency of the crystal used.
+ * Otherwise, this function may have wrong result.
+ *
+ * - The result of this function could be not correct when using fractional
+ * value for HSE crystal.
+ * @param None
+ * @retval None
+ */
+void SystemCoreClockUpdate (void)
+{
+ uint32_t tmp = 0, pllmull = 0, pllsource = 0;
+
+#ifdef STM32F10X_CL
+ uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0;
+#endif /* STM32F10X_CL */
+
+#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
+ uint32_t prediv1factor = 0;
+#endif /* STM32F10X_LD_VL or STM32F10X_MD_VL or STM32F10X_HD_VL */
+
+ /* Get SYSCLK source -------------------------------------------------------*/
+ tmp = RCC->CFGR & RCC_CFGR_SWS;
+
+ switch (tmp)
+ {
+ case 0x00: /* HSI used as system clock */
+ SystemCoreClock = HSI_VALUE;
+ break;
+ case 0x04: /* HSE used as system clock */
+ SystemCoreClock = HSE_VALUE;
+ break;
+ case 0x08: /* PLL used as system clock */
+
+ /* Get PLL clock source and multiplication factor ----------------------*/
+ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
+ pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
+
+#ifndef STM32F10X_CL
+ pllmull = ( pllmull >> 18) + 2;
+
+ if (pllsource == 0x00)
+ {
+ /* HSI oscillator clock divided by 2 selected as PLL clock entry */
+ SystemCoreClock = (HSI_VALUE >> 1) * pllmull;
+ }
+ else
+ {
+ #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
+ prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1;
+ /* HSE oscillator clock selected as PREDIV1 clock entry */
+ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
+ #else
+ /* HSE selected as PLL clock entry */
+ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET)
+ {/* HSE oscillator clock divided by 2 */
+ SystemCoreClock = (HSE_VALUE >> 1) * pllmull;
+ }
+ else
+ {
+ SystemCoreClock = HSE_VALUE * pllmull;
+ }
+ #endif
+ }
+#else
+ pllmull = pllmull >> 18;
+
+ if (pllmull != 0x0D)
+ {
+ pllmull += 2;
+ }
+ else
+ { /* PLL multiplication factor = PLL input clock * 6.5 */
+ pllmull = 13 / 2;
+ }
+
+ if (pllsource == 0x00)
+ {
+ /* HSI oscillator clock divided by 2 selected as PLL clock entry */
+ SystemCoreClock = (HSI_VALUE >> 1) * pllmull;
+ }
+ else
+ {/* PREDIV1 selected as PLL clock entry */
+
+ /* Get PREDIV1 clock source and division factor */
+ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC;
+ prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1;
+
+ if (prediv1source == 0)
+ {
+ /* HSE oscillator clock selected as PREDIV1 clock entry */
+ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
+ }
+ else
+ {/* PLL2 clock selected as PREDIV1 clock entry */
+
+ /* Get PREDIV2 division factor and PLL2 multiplication factor */
+ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1;
+ pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2;
+ SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull;
+ }
+ }
+#endif /* STM32F10X_CL */
+ break;
+
+ default:
+ SystemCoreClock = HSI_VALUE;
+ break;
+ }
+
+ /* Compute HCLK clock frequency ----------------*/
+ /* Get HCLK prescaler */
+ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
+ /* HCLK clock frequency */
+ SystemCoreClock >>= tmp;
+}
+
+/**
+ * @brief Configures the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers.
+ * @param None
+ * @retval None
+ */
+static void SetSysClock(void)
+{
+#ifdef SYSCLK_FREQ_HSE
+ SetSysClockToHSE();
+#elif defined SYSCLK_FREQ_24MHz
+ SetSysClockTo24();
+#elif defined SYSCLK_FREQ_36MHz
+ SetSysClockTo36();
+#elif defined SYSCLK_FREQ_48MHz
+ SetSysClockTo48();
+#elif defined SYSCLK_FREQ_56MHz
+ SetSysClockTo56();
+#elif defined SYSCLK_FREQ_72MHz
+ SetSysClockTo72();
+#endif
+
+ /* If none of the define above is enabled, the HSI is used as System clock
+ source (default after reset) */
+}
+
+/**
+ * @brief Setup the external memory controller. Called in startup_stm32f10x.s
+ * before jump to __main
+ * @param None
+ * @retval None
+ */
+#ifdef DATA_IN_ExtSRAM
+/**
+ * @brief Setup the external memory controller.
+ * Called in startup_stm32f10x_xx.s/.c before jump to main.
+ * This function configures the external SRAM mounted on STM3210E-EVAL
+ * board (STM32 High density devices). This SRAM will be used as program
+ * data memory (including heap and stack).
+ * @param None
+ * @retval None
+ */
+void SystemInit_ExtMemCtl(void)
+{
+/*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is
+ required, then adjust the Register Addresses */
+
+ /* Enable FSMC clock */
+ RCC->AHBENR = 0x00000114;
+
+ /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */
+ RCC->APB2ENR = 0x000001E0;
+
+/* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/
+/*---------------- SRAM Address lines configuration -------------------------*/
+/*---------------- NOE and NWE configuration --------------------------------*/
+/*---------------- NE3 configuration ----------------------------------------*/
+/*---------------- NBL0, NBL1 configuration ---------------------------------*/
+
+ GPIOD->CRL = 0x44BB44BB;
+ GPIOD->CRH = 0xBBBBBBBB;
+
+ GPIOE->CRL = 0xB44444BB;
+ GPIOE->CRH = 0xBBBBBBBB;
+
+ GPIOF->CRL = 0x44BBBBBB;
+ GPIOF->CRH = 0xBBBB4444;
+
+ GPIOG->CRL = 0x44BBBBBB;
+ GPIOG->CRH = 0x44444B44;
+
+/*---------------- FSMC Configuration ---------------------------------------*/
+/*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/
+
+ FSMC_Bank1->BTCR[4] = 0x00001011;
+ FSMC_Bank1->BTCR[5] = 0x00000200;
+}
+#endif /* DATA_IN_ExtSRAM */
+
+#ifdef SYSCLK_FREQ_HSE
+/**
+ * @brief Selects HSE as System clock source and configure HCLK, PCLK2
+ * and PCLK1 prescalers.
+ * @note This function should be used only after reset.
+ * @param None
+ * @retval None
+ */
+static void SetSysClockToHSE(void)
+{
+ __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
+
+ /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/
+ /* Enable HSE */
+ RCC->CR |= ((uint32_t)RCC_CR_HSEON);
+
+ /* Wait till HSE is ready and if Time out is reached exit */
+ do
+ {
+ HSEStatus = RCC->CR & RCC_CR_HSERDY;
+ StartUpCounter++;
+ } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
+
+ if ((RCC->CR & RCC_CR_HSERDY) != RESET)
+ {
+ HSEStatus = (uint32_t)0x01;
+ }
+ else
+ {
+ HSEStatus = (uint32_t)0x00;
+ }
+
+ if (HSEStatus == (uint32_t)0x01)
+ {
+
+#if !defined STM32F10X_LD_VL && !defined STM32F10X_MD_VL && !defined STM32F10X_HD_VL
+ /* Enable Prefetch Buffer */
+ FLASH->ACR |= FLASH_ACR_PRFTBE;
+
+ /* Flash 0 wait state */
+ FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);
+
+#ifndef STM32F10X_CL
+ FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_0;
+#else
+ if (HSE_VALUE <= 24000000)
+ {
+ FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_0;
+ }
+ else
+ {
+ FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_1;
+ }
+#endif /* STM32F10X_CL */
+#endif
+
+ /* HCLK = SYSCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
+
+ /* PCLK2 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;
+
+ /* PCLK1 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV1;
+
+ /* Select HSE as system clock source */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
+ RCC->CFGR |= (uint32_t)RCC_CFGR_SW_HSE;
+
+ /* Wait till HSE is used as system clock source */
+ while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x04)
+ {
+ }
+ }
+ else
+ { /* If HSE fails to start-up, the application will have wrong clock
+ configuration. User can add here some code to deal with this error */
+ }
+}
+#elif defined SYSCLK_FREQ_24MHz
+/**
+ * @brief Sets System clock frequency to 24MHz and configure HCLK, PCLK2
+ * and PCLK1 prescalers.
+ * @note This function should be used only after reset.
+ * @param None
+ * @retval None
+ */
+static void SetSysClockTo24(void)
+{
+ __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
+
+ /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/
+ /* Enable HSE */
+ RCC->CR |= ((uint32_t)RCC_CR_HSEON);
+
+ /* Wait till HSE is ready and if Time out is reached exit */
+ do
+ {
+ HSEStatus = RCC->CR & RCC_CR_HSERDY;
+ StartUpCounter++;
+ } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
+
+ if ((RCC->CR & RCC_CR_HSERDY) != RESET)
+ {
+ HSEStatus = (uint32_t)0x01;
+ }
+ else
+ {
+ HSEStatus = (uint32_t)0x00;
+ }
+
+ if (HSEStatus == (uint32_t)0x01)
+ {
+#if !defined STM32F10X_LD_VL && !defined STM32F10X_MD_VL && !defined STM32F10X_HD_VL
+ /* Enable Prefetch Buffer */
+ FLASH->ACR |= FLASH_ACR_PRFTBE;
+
+ /* Flash 0 wait state */
+ FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);
+ FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_0;
+#endif
+
+ /* HCLK = SYSCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
+
+ /* PCLK2 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;
+
+ /* PCLK1 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV1;
+
+#ifdef STM32F10X_CL
+ /* Configure PLLs ------------------------------------------------------*/
+ /* PLL configuration: PLLCLK = PREDIV1 * 6 = 24 MHz */
+ RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL);
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 |
+ RCC_CFGR_PLLMULL6);
+
+ /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */
+ /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 10 = 4 MHz */
+ RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
+ RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC);
+ RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 |
+ RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV10);
+
+ /* Enable PLL2 */
+ RCC->CR |= RCC_CR_PLL2ON;
+ /* Wait till PLL2 is ready */
+ while((RCC->CR & RCC_CR_PLL2RDY) == 0)
+ {
+ }
+#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL)
+ /* PLL configuration: = (HSE / 2) * 6 = 24 MHz */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL));
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLXTPRE_PREDIV1_Div2 | RCC_CFGR_PLLMULL6);
+#else
+ /* PLL configuration: = (HSE / 2) * 6 = 24 MHz */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL));
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLXTPRE_HSE_Div2 | RCC_CFGR_PLLMULL6);
+#endif /* STM32F10X_CL */
+
+ /* Enable PLL */
+ RCC->CR |= RCC_CR_PLLON;
+
+ /* Wait till PLL is ready */
+ while((RCC->CR & RCC_CR_PLLRDY) == 0)
+ {
+ }
+
+ /* Select PLL as system clock source */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
+ RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
+
+ /* Wait till PLL is used as system clock source */
+ while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08)
+ {
+ }
+ }
+ else
+ { /* If HSE fails to start-up, the application will have wrong clock
+ configuration. User can add here some code to deal with this error */
+ }
+}
+#elif defined SYSCLK_FREQ_36MHz
+/**
+ * @brief Sets System clock frequency to 36MHz and configure HCLK, PCLK2
+ * and PCLK1 prescalers.
+ * @note This function should be used only after reset.
+ * @param None
+ * @retval None
+ */
+static void SetSysClockTo36(void)
+{
+ __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
+
+ /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/
+ /* Enable HSE */
+ RCC->CR |= ((uint32_t)RCC_CR_HSEON);
+
+ /* Wait till HSE is ready and if Time out is reached exit */
+ do
+ {
+ HSEStatus = RCC->CR & RCC_CR_HSERDY;
+ StartUpCounter++;
+ } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
+
+ if ((RCC->CR & RCC_CR_HSERDY) != RESET)
+ {
+ HSEStatus = (uint32_t)0x01;
+ }
+ else
+ {
+ HSEStatus = (uint32_t)0x00;
+ }
+
+ if (HSEStatus == (uint32_t)0x01)
+ {
+ /* Enable Prefetch Buffer */
+ FLASH->ACR |= FLASH_ACR_PRFTBE;
+
+ /* Flash 1 wait state */
+ FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);
+ FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_1;
+
+ /* HCLK = SYSCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
+
+ /* PCLK2 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;
+
+ /* PCLK1 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV1;
+
+#ifdef STM32F10X_CL
+ /* Configure PLLs ------------------------------------------------------*/
+
+ /* PLL configuration: PLLCLK = PREDIV1 * 9 = 36 MHz */
+ RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL);
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 |
+ RCC_CFGR_PLLMULL9);
+
+ /*!< PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */
+ /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 10 = 4 MHz */
+
+ RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
+ RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC);
+ RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 |
+ RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV10);
+
+ /* Enable PLL2 */
+ RCC->CR |= RCC_CR_PLL2ON;
+ /* Wait till PLL2 is ready */
+ while((RCC->CR & RCC_CR_PLL2RDY) == 0)
+ {
+ }
+
+#else
+ /* PLL configuration: PLLCLK = (HSE / 2) * 9 = 36 MHz */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL));
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLXTPRE_HSE_Div2 | RCC_CFGR_PLLMULL9);
+#endif /* STM32F10X_CL */
+
+ /* Enable PLL */
+ RCC->CR |= RCC_CR_PLLON;
+
+ /* Wait till PLL is ready */
+ while((RCC->CR & RCC_CR_PLLRDY) == 0)
+ {
+ }
+
+ /* Select PLL as system clock source */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
+ RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
+
+ /* Wait till PLL is used as system clock source */
+ while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08)
+ {
+ }
+ }
+ else
+ { /* If HSE fails to start-up, the application will have wrong clock
+ configuration. User can add here some code to deal with this error */
+ }
+}
+#elif defined SYSCLK_FREQ_48MHz
+/**
+ * @brief Sets System clock frequency to 48MHz and configure HCLK, PCLK2
+ * and PCLK1 prescalers.
+ * @note This function should be used only after reset.
+ * @param None
+ * @retval None
+ */
+static void SetSysClockTo48(void)
+{
+ __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
+
+ /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/
+ /* Enable HSE */
+ RCC->CR |= ((uint32_t)RCC_CR_HSEON);
+
+ /* Wait till HSE is ready and if Time out is reached exit */
+ do
+ {
+ HSEStatus = RCC->CR & RCC_CR_HSERDY;
+ StartUpCounter++;
+ } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
+
+ if ((RCC->CR & RCC_CR_HSERDY) != RESET)
+ {
+ HSEStatus = (uint32_t)0x01;
+ }
+ else
+ {
+ HSEStatus = (uint32_t)0x00;
+ }
+
+ if (HSEStatus == (uint32_t)0x01)
+ {
+ /* Enable Prefetch Buffer */
+ FLASH->ACR |= FLASH_ACR_PRFTBE;
+
+ /* Flash 1 wait state */
+ FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);
+ FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_1;
+
+ /* HCLK = SYSCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
+
+ /* PCLK2 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;
+
+ /* PCLK1 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2;
+
+#ifdef STM32F10X_CL
+ /* Configure PLLs ------------------------------------------------------*/
+ /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */
+ /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 5 = 8 MHz */
+
+ RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
+ RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC);
+ RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 |
+ RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV5);
+
+ /* Enable PLL2 */
+ RCC->CR |= RCC_CR_PLL2ON;
+ /* Wait till PLL2 is ready */
+ while((RCC->CR & RCC_CR_PLL2RDY) == 0)
+ {
+ }
+
+
+ /* PLL configuration: PLLCLK = PREDIV1 * 6 = 48 MHz */
+ RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL);
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 |
+ RCC_CFGR_PLLMULL6);
+#else
+ /* PLL configuration: PLLCLK = HSE * 6 = 48 MHz */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL));
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL6);
+#endif /* STM32F10X_CL */
+
+ /* Enable PLL */
+ RCC->CR |= RCC_CR_PLLON;
+
+ /* Wait till PLL is ready */
+ while((RCC->CR & RCC_CR_PLLRDY) == 0)
+ {
+ }
+
+ /* Select PLL as system clock source */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
+ RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
+
+ /* Wait till PLL is used as system clock source */
+ while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08)
+ {
+ }
+ }
+ else
+ { /* If HSE fails to start-up, the application will have wrong clock
+ configuration. User can add here some code to deal with this error */
+ }
+}
+
+#elif defined SYSCLK_FREQ_56MHz
+/**
+ * @brief Sets System clock frequency to 56MHz and configure HCLK, PCLK2
+ * and PCLK1 prescalers.
+ * @note This function should be used only after reset.
+ * @param None
+ * @retval None
+ */
+static void SetSysClockTo56(void)
+{
+ __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
+
+ /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/
+ /* Enable HSE */
+ RCC->CR |= ((uint32_t)RCC_CR_HSEON);
+
+ /* Wait till HSE is ready and if Time out is reached exit */
+ do
+ {
+ HSEStatus = RCC->CR & RCC_CR_HSERDY;
+ StartUpCounter++;
+ } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
+
+ if ((RCC->CR & RCC_CR_HSERDY) != RESET)
+ {
+ HSEStatus = (uint32_t)0x01;
+ }
+ else
+ {
+ HSEStatus = (uint32_t)0x00;
+ }
+
+ if (HSEStatus == (uint32_t)0x01)
+ {
+ /* Enable Prefetch Buffer */
+ FLASH->ACR |= FLASH_ACR_PRFTBE;
+
+ /* Flash 2 wait state */
+ FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);
+ FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_2;
+
+ /* HCLK = SYSCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
+
+ /* PCLK2 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;
+
+ /* PCLK1 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2;
+
+#ifdef STM32F10X_CL
+ /* Configure PLLs ------------------------------------------------------*/
+ /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */
+ /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 5 = 8 MHz */
+
+ RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
+ RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC);
+ RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 |
+ RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV5);
+
+ /* Enable PLL2 */
+ RCC->CR |= RCC_CR_PLL2ON;
+ /* Wait till PLL2 is ready */
+ while((RCC->CR & RCC_CR_PLL2RDY) == 0)
+ {
+ }
+
+
+ /* PLL configuration: PLLCLK = PREDIV1 * 7 = 56 MHz */
+ RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL);
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 |
+ RCC_CFGR_PLLMULL7);
+#else
+ /* PLL configuration: PLLCLK = HSE * 7 = 56 MHz */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL));
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL7);
+
+#endif /* STM32F10X_CL */
+
+ /* Enable PLL */
+ RCC->CR |= RCC_CR_PLLON;
+
+ /* Wait till PLL is ready */
+ while((RCC->CR & RCC_CR_PLLRDY) == 0)
+ {
+ }
+
+ /* Select PLL as system clock source */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
+ RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
+
+ /* Wait till PLL is used as system clock source */
+ while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08)
+ {
+ }
+ }
+ else
+ { /* If HSE fails to start-up, the application will have wrong clock
+ configuration. User can add here some code to deal with this error */
+ }
+}
+
+#elif defined SYSCLK_FREQ_72MHz
+/**
+ * @brief Sets System clock frequency to 72MHz and configure HCLK, PCLK2
+ * and PCLK1 prescalers.
+ * @note This function should be used only after reset.
+ * @param None
+ * @retval None
+ */
+static void SetSysClockTo72(void)
+{
+ __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
+
+ /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/
+ /* Enable HSE */
+ RCC->CR |= ((uint32_t)RCC_CR_HSEON);
+
+ /* Wait till HSE is ready and if Time out is reached exit */
+ do
+ {
+ HSEStatus = RCC->CR & RCC_CR_HSERDY;
+ StartUpCounter++;
+ } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
+
+ if ((RCC->CR & RCC_CR_HSERDY) != RESET)
+ {
+ HSEStatus = (uint32_t)0x01;
+ }
+ else
+ {
+ HSEStatus = (uint32_t)0x00;
+ }
+
+ if (HSEStatus == (uint32_t)0x01)
+ {
+ /* Enable Prefetch Buffer */
+ FLASH->ACR |= FLASH_ACR_PRFTBE;
+
+ /* Flash 2 wait state */
+ FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);
+ FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_2;
+
+
+ /* HCLK = SYSCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
+
+ /* PCLK2 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;
+
+ /* PCLK1 = HCLK */
+ RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2;
+
+#ifdef STM32F10X_CL
+ /* Configure PLLs ------------------------------------------------------*/
+ /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */
+ /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 5 = 8 MHz */
+
+ RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
+ RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC);
+ RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 |
+ RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV5);
+
+ /* Enable PLL2 */
+ RCC->CR |= RCC_CR_PLL2ON;
+ /* Wait till PLL2 is ready */
+ while((RCC->CR & RCC_CR_PLL2RDY) == 0)
+ {
+ }
+
+
+ /* PLL configuration: PLLCLK = PREDIV1 * 9 = 72 MHz */
+ RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL);
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 |
+ RCC_CFGR_PLLMULL9);
+#else
+ /* PLL configuration: PLLCLK = HSE * 9 = 72 MHz */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE |
+ RCC_CFGR_PLLMULL));
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL9);
+#endif /* STM32F10X_CL */
+
+ /* Enable PLL */
+ RCC->CR |= RCC_CR_PLLON;
+
+ /* Wait till PLL is ready */
+ while((RCC->CR & RCC_CR_PLLRDY) == 0)
+ {
+ }
+
+ /* Select PLL as system clock source */
+ RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
+ RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;
+
+ /* Wait till PLL is used as system clock source */
+ while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08)
+ {
+ }
+ }
+ else
+ { /* If HSE fails to start-up, the application will have wrong clock
+ configuration. User can add here some code to deal with this error */
+ }
+}
+#endif
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/st_fw_lib/system_stm32f10x.h b/st_fw_lib/system_stm32f10x.h
new file mode 100644
index 0000000..54bc1ab
--- /dev/null
+++ b/st_fw_lib/system_stm32f10x.h
@@ -0,0 +1,98 @@
+/**
+ ******************************************************************************
+ * @file system_stm32f10x.h
+ * @author MCD Application Team
+ * @version V3.5.0
+ * @date 11-March-2011
+ * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File.
+ ******************************************************************************
+ * @attention
+ *
+ * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+ * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
+ * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
+ * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
+ * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
+ * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ *
+ * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
+ ******************************************************************************
+ */
+
+/** @addtogroup CMSIS
+ * @{
+ */
+
+/** @addtogroup stm32f10x_system
+ * @{
+ */
+
+/**
+ * @brief Define to prevent recursive inclusion
+ */
+#ifndef __SYSTEM_STM32F10X_H
+#define __SYSTEM_STM32F10X_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/** @addtogroup STM32F10x_System_Includes
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+
+/** @addtogroup STM32F10x_System_Exported_types
+ * @{
+ */
+
+extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F10x_System_Exported_Constants
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F10x_System_Exported_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F10x_System_Exported_Functions
+ * @{
+ */
+
+extern void SystemInit(void);
+extern void SystemCoreClockUpdate(void);
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__SYSTEM_STM32F10X_H */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/supwisdom/main.c b/supwisdom/main.c
new file mode 100644
index 0000000..c5fdc97
--- /dev/null
+++ b/supwisdom/main.c
@@ -0,0 +1,53 @@
+//пªÆÕË®¿Ø³ÌÐò
+#include "stdio.h"
+#include "stdlib.h"
+#include "string.h"
+#include "sp_config.h"
+#include "sp_display.h"
+#include "sp_data.h"
+#include "sp_util.h"
+#include "sp_consume.h"
+#include "sp_communicate.h"
+
+static sp_pos_t POS;
+
+int main(void)
+{
+ uint32 tick = 0;
+ uint32 lasttick = 0;
+ sp_cardworkstate_t cardWorkState;
+ MEMCLEAR(&POS, sizeof(POS));
+ MEMCLEAR(&cardWorkState, sizeof(cardWorkState));
+ sp_init();
+ sp_key_init();
+ Delay_ms(DELAY_TIME1s);
+ sp_load_config(&POS);
+
+ show_home(&POS);
+
+ while(1)
+ {
+ tick = sp_get_ticker();
+ sp_feed_dog();
+ sp_valve_control();
+ sp_confirm_paymode(&POS, &cardWorkState);
+ sp_communicate(&POS);
+ if(POS.paymode == PAYMODE_QRCODE)
+ {
+ if(tick - lasttick >= DELAY_TIME100ms)
+ {
+ lasttick = tick;
+ sp_qrcode_handle(&POS, &cardWorkState);
+ }
+ }
+ else
+ {
+ if(tick - lasttick >= DELAY_TIME100ms)
+ {
+ lasttick = tick;
+ sp_test_card_state(&POS, &cardWorkState, tick);
+ sp_card_handle(&POS, &cardWorkState);
+ }
+ }
+ }
+}
diff --git a/supwisdom/sp_card.c b/supwisdom/sp_card.c
new file mode 100644
index 0000000..5c6796a
--- /dev/null
+++ b/supwisdom/sp_card.c
@@ -0,0 +1,98 @@
+#include "../nec_apdu.h"
+#include "sp_des.h"
+#include "sp_constant.h"
+#include "sp_util.h"
+#include "sp_card.h"
+
+static uint8* prcv_buff = NULL;
+static uint8 rcv_len = 0;
+
+uint16 sp_select_sfi(uint8 sfi[2])
+{
+ uint16 ret;
+ uint8 cmd_buff[10];
+
+ cmd_buff[0] = 0x00; //CLA
+ cmd_buff[1] = 0xA4; //INS
+ cmd_buff[2] = 0x00; //P1
+ cmd_buff[3] = 0x00; //P2
+ cmd_buff[4] = 0x02; //Lc
+ memcpy(cmd_buff + 5, sfi, 2);
+
+ ret = card_cpu_exchange(cmd_buff, 2 + 5, 0, &prcv_buff, &rcv_len);
+ if(ret != RETCODE_OK)
+ {
+ return ret;
+ }
+ return 0;
+}
+
+uint16 sp_select_adf(void)
+{
+ uint16 ret;
+ uint8 cmd_buff[] = {"\x00\xA4\x04\x00\x0F\xD1\x56\x00\x00\x01\xBD\xF0\xCA\xCB\xB4\xEF\xD6\xA7\xB8\xB6"};
+ ret = card_cpu_exchange(cmd_buff, sizeof(cmd_buff) - 1, 0, &prcv_buff, &rcv_len);
+ if(ret != RETCODE_OK)
+ {
+ return ret;
+ }
+ return 0;
+}
+
+uint8 sp_card_request(sp_card_t* cardpcd)
+{
+
+ uint8 sak;
+ uint8 snr[8];
+
+ if(!card_request(&sak, snr))
+ {
+ if((sak & 0x20))
+ {
+ if(!card_cpu_mode())
+ {
+ Delay_ms(200);
+ if(sp_select_sfi("\x3f\x00") == 0)
+ {
+ sp_select_adf();
+ cardpcd->cardphyid[0] = snr[3];
+ cardpcd->cardphyid[1] = snr[2];
+ cardpcd->cardphyid[2] = snr[1];
+ cardpcd->cardphyid[3] = snr[0];
+ cardpcd->cardtype = TAG_TYPE_CPU;
+ return 0;
+ }
+ }
+ }
+ else
+ {
+ cardpcd->cardtype = TAG_TYPE_UNKONWN;
+ return 1;
+ }
+ }
+ return 1;
+}
+
+int8 sp_check_cpu_exist(void)
+{
+ return card_cpu_exist();
+}
+
+static uint16 sp_cpu_read(sp_card_t* card)
+{
+ uint16 ret = 0;
+ MEMCLEAR(card->citizen_cardno, sizeof(card->citizen_cardno));
+ MEMCPY(card->expiredate, "\x20\x22\x08\x02", 4);
+ return ret;
+}
+
+uint16 sp_card_read(sp_card_t* card)
+{
+ switch(card->cardtype)
+ {
+ case TAG_TYPE_CPU:
+ return sp_cpu_read(card);
+ default:
+ return 1;
+ }
+}
diff --git a/supwisdom/sp_card.h b/supwisdom/sp_card.h
new file mode 100644
index 0000000..5981cfa
--- /dev/null
+++ b/supwisdom/sp_card.h
@@ -0,0 +1,26 @@
+#ifndef _SP_CARD_H_
+#define _SP_CARD_H_
+
+#include "sp_config.h"
+
+#define SP_FILE09 0x01
+#define SP_FILE10 0x02
+#define SP_FILE12 0x04
+#define SP_FILE15 0x08
+
+#define WATER_RECORD_NO 4
+#define RETCODE_OK 0x9000
+#define RETCODE_INSUFFICIENT 0x9401 //Óà¶î²»×ã
+#define RC_CPU_FILENOTFOUND 0x6A82
+#define RC_CPU_NO_EXTAUTH 0x6982
+#define RC_CPU_FILE_NOT_EXIST 0x6A83
+#define RC_CPU_NOMAC 0x9406
+
+#define CARD_STATUS_OK 0
+
+uint8 sp_card_request(sp_card_t* cardpcd);
+int8 sp_check_cpu_exist(void);
+int8 sp_card_rf_reset(void);
+uint16 sp_card_read(sp_card_t* card);
+
+#endif
diff --git a/supwisdom/sp_communicate.c b/supwisdom/sp_communicate.c
new file mode 100644
index 0000000..7e3ac69
--- /dev/null
+++ b/supwisdom/sp_communicate.c
@@ -0,0 +1,590 @@
+#include "sp_communicate.h"
+#include "sp_util.h"
+#include "sp_flash.h"
+#include "sp_constant.h"
+#include "sp_data.h"
+#include "sp_msgpack.h"
+#include "sp_display.h"
+#include "../sys_hw/drv_usart.h"
+
+static void sp_usart_send(sp_pos_t* pos, sp_protocol_request_t* req)
+{
+ uint8 sendBuff[264];
+ MEMCLEAR(sendBuff, sizeof(sendBuff));
+
+ pos->last_comm_status.command = req->excmd;
+ pos->last_comm_status.sendtime = sp_get_ticker();
+
+ sp_protocol_crc((uint8*)req +2, req->datalen, (uint8*)req +2 +req->datalen);
+ req->datalen += 2;
+ MEMCPY(sendBuff, req, req->datalen+2);
+ usart_send(sendBuff, req->datalen+2);
+}
+
+static uint8 sp_usart_recv(sp_pos_t* pos, sp_protocol_response_t* resp, int32 timeout_ms)
+{
+ uint32 tick = 0;
+ tick = sp_get_ticker();
+ while(1)
+ {
+ MEMCLEAR(resp, sizeof(sp_protocol_response_t));
+ usart_read((u8*)resp, sizeof(sp_protocol_response_t));
+ if(pos->last_comm_status.command == resp->excmd)
+ {
+ MEMCLEAR(&(pos->last_comm_status), sizeof(sp_comm_status_t));
+ return resp->retcode;
+ }
+ if((sp_get_ticker() - tick) >= timeout_ms)
+ {
+ return 1;
+ }
+ }
+}
+uint8 sp_comm_call(sp_pos_t* pos, sp_protocol_request_t* req,
+ sp_protocol_response_t* resp, int32 timeout_ms)
+{
+ sp_usart_send(pos, req);
+ return sp_usart_recv(pos, resp, timeout_ms);
+}
+
+void sp_protocol_req_init(sp_protocol_request_t* req, uint8 command)
+{
+ MEMCLEAR(req,sizeof(sp_protocol_request_t));
+ req->command = PROTOCOL_COMMAND_V2;
+ req->excmd = command;
+ req->flag = PROTOCOL_FLAG_PACK(req->flag);
+ req->flag = PROTOCOL_WITHOUT_MAC(req->flag);
+ req->datalen = 3;
+}
+
+static uint16 sp_confirm_card_authentication(sp_pos_t* pos, sp_card_t* card)
+{
+ uint8 size;
+ uint16 ret;
+ int32 timeout_ms = COMM_WAIT_TIME;
+ cw_unpack_context unpack;
+ unpack_field_t field;
+ sp_protocol_response_t resp;
+
+ disp_hint_info(pos,"ÕýÔÚÉí·ÝÈÏÖ¤ÖÐ",DELAY_TIME2s);
+ ret = sp_usart_recv(pos, &resp, timeout_ms);
+ if(ret)
+ {
+ ret = RC_CARD_AUTHENTICATION;
+ return ret;
+ }
+
+ sp_unpack_init(&unpack,resp.data,resp.datalen);
+ size = sp_unpack_map_size(&unpack);
+ while(size-- > 0)
+ {
+ sp_unpack_value(&unpack,&field);
+ if(IS_KEY(PK_INT_WATERLIMIT,field.key))
+ {
+ card->waterlimit = field.val.intval;
+ }
+ else if(IS_KEY(PK_BIN_BILLNO,field.key))
+ {
+ MEMCPY(card->billno, field.val.binval, field.strlen);
+ }
+ else if(IS_KEY(PK_INT_FEEAMOUNT,field.key))
+ {
+ card->feepara.fee_amt = field.val.intval;
+ }
+ else if(IS_KEY(PK_INT_FEEUNIT, field.key))
+ {
+ card->feepara.fee_unit = field.val.intval;
+ }
+ else if(IS_KEY(PK_INT_FEESTART, field.key))
+ {
+ card->feepara.fee_start = field.val.intval;
+ }
+ }
+ disp_hint_info(pos,"Éí·ÝÈÏÖ¤³É¹¦",DELAY_TIME1s);
+ return 0;
+}
+
+//ºǫ́¶Ô¿¨µÄÉí·ÝÈÏÖ¤
+uint16 sp_card_authentication(sp_pos_t* pos, sp_card_t* card)
+{
+ uint8 ctime[6];
+ sp_protocol_request_t req;
+ cw_pack_context pack;
+ MEMCLEAR(&req, sizeof(req));
+ MEMCLEAR(&pack, sizeof(req));
+ MEMCLEAR(ctime, sizeof ctime);
+
+ sp_get_bcdtime(ctime);
+ sp_protocol_req_init(&req, SP_CMD_CARD_AUTHENTICATION);
+ sp_pack_init(&pack, req.data, sizeof(req.data));
+ cw_pack_map_size(&pack,4);
+
+ sp_pack_put_bin(&pack, PK_BIN_CARDPHYID, card->cardphyid, 4);
+ sp_pack_put_bin(&pack, PK_BIN_CITIZEN_CARDNO, card->citizen_cardno, 12);
+ sp_pack_put_bin(&pack, PK_BIN_DEVPHYID, pos->devphyid, 4);
+ sp_pack_put_bin(&pack, PK_BIN_DEVTIME, ctime, 6);
+
+ req.datalen += sp_pack_length(&pack);
+ sp_usart_send(pos, &req);
+ return sp_confirm_card_authentication(pos, card);
+}
+
+//É豸ǩµ½
+uint16 sp_async_equipment_login(sp_pos_t* pos)
+{
+ sp_protocol_request_t req;
+ cw_pack_context pack;
+ uint8 ctime[6];
+ MEMCLEAR(ctime, sizeof(ctime));
+ pos->heartbeat.heart_status = HEART_SEND;
+
+ sp_get_bcdtime(ctime);
+ sp_protocol_req_init(&req, SP_CMD_LOGIN);
+ sp_pack_init(&pack, req.data, sizeof(req.data));
+ cw_pack_map_size(&pack, 5);
+
+ sp_pack_put_bin(&pack, PK_BIN_DEVPHYID, pos->devphyid, 4);
+ sp_pack_put_bin(&pack, PK_BIN_DEVTIME, ctime, 6);
+ sp_pack_put_str(&pack, PK_STR_DEVTYPE, DEV_TYPE);
+ sp_pack_put_str(&pack, PK_STR_VERSION, PRO_VERSION);
+ sp_pack_put_bin(&pack, PK_BIN_DEVICEKEY, (pos->sysconf.deviceKey), 8);
+
+ req.datalen += sp_pack_length(&pack);
+ sp_usart_send(pos, &req);
+ return 0;
+}
+
+//ÐÄÌøÈ·ÈÏ£¬¼ì²âÍøÂçÊÇ·ñÕý³£
+uint16 sp_async_heartbeat(sp_pos_t* pos)
+{
+ uint8 ctime[6];
+ uint8 unconfirm_transnum = 0;
+ sp_protocol_request_t req;
+ cw_pack_context pack;
+
+ pos->heartbeat.heart_status = HEART_SEND;
+ if(pos->unconfirm_transdtl.transaddr <= pos->last_transdtl.transaddr)
+ {
+ unconfirm_transnum = ((pos->last_transdtl.transaddr - pos->unconfirm_transdtl.transaddr) /
+ sizeof(sp_transdtl_t)) + 1;
+ }
+ else
+ {
+ unconfirm_transnum = 0;
+ }
+ sp_protocol_req_init(&req, SP_CMD_HEARTBEAT);
+ sp_pack_init(&pack, req.data, sizeof(req.data));
+ cw_pack_map_size(&pack, 6);
+
+ sp_get_bcdtime(ctime);
+ sp_pack_put_bin(&pack, PK_BIN_DEVPHYID, pos->devphyid, 4);
+ sp_pack_put_bin(&pack, PK_BIN_DEVTIME, ctime, 6);
+ sp_pack_put_str(&pack, PK_STR_DEVTYPE, DEV_TYPE);
+ sp_pack_put_str(&pack, PK_STR_VERSION, PRO_VERSION);
+ sp_pack_put_int(&pack, PK_INT_UNTRANSCONST, unconfirm_transnum);
+ sp_pack_put_int(&pack, PK_INT_WORKMODE, pos->sysconf.work_mode);
+
+ req.datalen += sp_pack_length(&pack);
+ sp_usart_send(pos, &req);
+ return 0;
+}
+
+static uint16 sp_confirm_qrcode_init(sp_pos_t* pos, sp_card_t* card)
+{
+ uint8 size;
+ uint16 ret;
+ int32 timeout_ms = COMM_WAIT_TIME;
+ cw_unpack_context unpack;
+ unpack_field_t field;
+ sp_protocol_response_t resp;
+
+ ret = sp_usart_recv(pos, &resp, timeout_ms);
+ if(ret)
+ {
+ ret = RC_QRCODE_FAILURE;
+ return ret;
+ }
+
+ sp_unpack_init(&unpack,resp.data,resp.datalen);
+ size = sp_unpack_map_size(&unpack);
+ while(size-- > 0)
+ {
+ sp_unpack_value(&unpack,&field);
+ if(IS_KEY(PK_STR_SHORT_URL, field.key))
+ {
+ MEMCPY(card->qrcode.qrcode_url, field.val.strval, field.strlen);
+ }
+ else if(IS_KEY(PK_BIN_BILLNO, field.key))
+ {
+ MEMCPY(card->billno, field.val.binval, field.strlen);
+ }
+ else if(IS_KEY(PK_INT_VAILDTIME, field.key))
+ {
+ card->qrcode.validtime = field.val.intval;
+ }
+ }
+ card->qrcode.starttime = sp_get_ticker();
+ return 0;
+}
+
+//¶þάÂë»ñÈ¡
+uint16 sp_qrcode_init(sp_pos_t* pos, sp_card_t* card)
+{
+ uint8 ctime[6];
+ sp_protocol_request_t req;
+ cw_pack_context pack;
+
+ sp_get_bcdtime(ctime);
+ sp_protocol_req_init(&req, SP_CMD_SHORTURL);
+ sp_pack_init(&pack, req.data, sizeof(req.data));
+ cw_pack_map_size(&pack, 2);
+
+ sp_pack_put_bin(&pack, PK_BIN_DEVPHYID, pos->devphyid, 4);
+ sp_pack_put_bin(&pack, PK_BIN_DEVTIME, ctime, 6);
+
+ req.datalen += sp_pack_length(&pack);
+ sp_usart_send(pos, &req);
+ return sp_confirm_qrcode_init(pos, card);
+}
+
+//¶þάÂëÈ·ÈÏ£¬»ñȡ֧¸¶×´Ì¬
+static uint16 sp_confirm_qrcode_query(sp_pos_t* pos, sp_card_t* card)
+{
+ uint8 size;
+ uint16 ret;
+ int32 timeout_ms = COMM_WAIT_TIME;
+ cw_unpack_context unpack;
+ unpack_field_t field;
+ sp_protocol_response_t resp;
+
+ ret = sp_usart_recv(pos, &resp, timeout_ms);
+ if(ret)
+ {
+ ret = RC_QRCODE_QUERY_FAIL;
+ return ret;
+ }
+
+ sp_unpack_init(&unpack,resp.data,resp.datalen);
+ size = sp_unpack_map_size(&unpack);
+ while(size-- > 0)
+ {
+ sp_unpack_value(&unpack,&field);
+ if(IS_KEY(PK_BIN_BILLNO, field.key))
+ {
+ MEMCPY(card->billno, field.val.binval, field.strlen);
+ }
+ else if(IS_KEY(PK_INT_AUTHSTATUS, field.key))
+ {
+ card->qrcode.authstatus = field.val.intval;
+ }
+ else if(IS_KEY(PK_INT_PAYSTATUS, field.key))
+ {
+ card->qrcode.paystatus = field.val.intval;
+ }
+ else if(IS_KEY(PK_INT_PAYAMT, field.key))
+ {
+ card->qrcode.paidAmount = field.val.intval;
+ }
+ else if(IS_KEY(PK_INT_FEEAMOUNT,field.key))
+ {
+ card->feepara.fee_amt = field.val.intval;
+ }
+ else if(IS_KEY(PK_INT_FEEUNIT, field.key))
+ {
+ card->feepara.fee_unit = field.val.intval;
+ }
+ }
+ return resp.retcode;
+}
+
+uint16 sp_qrcode_query(sp_pos_t* pos, sp_card_t* card)
+{
+ uint8 ctime[6];
+ sp_protocol_request_t req;
+ cw_pack_context pack;
+
+ sp_get_bcdtime(ctime);
+ sp_protocol_req_init(&req, SP_CMD_QRCODE_PAY_QUERY);
+ sp_pack_init(&pack, req.data, sizeof(req.data));
+ cw_pack_map_size(&pack, 2);
+
+ sp_pack_put_bin(&pack, PK_BIN_DEVPHYID, pos->devphyid, 4);
+ sp_pack_put_bin(&pack, PK_BIN_BILLNO, card->billno, sizeof(card->billno));
+
+ req.datalen += sp_pack_length(&pack);
+ sp_usart_send(pos, &req);
+ return sp_confirm_qrcode_query(pos, card);
+}
+
+//Á÷Ë®ÉÏ´«
+static uint8 transdtl_account_bilLno[10];
+static uint16 sp_async_upload_transdtl(sp_pos_t* pos, sp_transdtl_t* transdtl)
+{
+ uint8 crc[2];
+ cw_pack_context pack;
+ sp_protocol_request_t req;
+
+ MEMCPY(transdtl_account_bilLno, transdtl->billno, sizeof(transdtl->billno));
+ sp_protocol_req_init(&req, SP_CMD_TRANSDTL_ACCOUNT);
+ sp_pack_init(&pack,req.data,sizeof(req.data));
+ cw_pack_map_size(&pack,10);
+
+ sp_pack_put_bin(&pack, PK_BIN_DEVPHYID, transdtl->devphyid,4);
+ sp_pack_put_bin(&pack, PK_BIN_TRANSDATE, transdtl->transdate,3);
+ sp_pack_put_bin(&pack, PK_BIN_TRANSTIME, transdtl->transtime,3);
+ sp_pack_put_bin(&pack, PK_BIN_BILLNO, transdtl->billno, sizeof(transdtl->billno));
+ sp_pack_put_bin(&pack, PK_BIN_CARDPHYID, transdtl->cardphyid,
+ sizeof(transdtl->cardphyid));
+ sp_pack_put_int(&pack, PK_INT_TRANSWAY, transdtl->transway);
+ sp_pack_put_int(&pack, PK_INT_AMOUNT, transdtl->amount);
+ sp_pack_put_int(&pack, PK_INT_PAYAMT, transdtl->paidAmount);
+ sp_pack_put_int(&pack, PK_INT_FLOWSENSORS, transdtl->flowsensors);
+ sp_pack_put_int(&pack, PK_INT_FLAG, transdtl->transtatus);
+
+ sp_protocol_crc((uint8*)transdtl, sizeof(sp_transdtl_t)-2,crc);
+ req.datalen += sp_pack_length(&pack);
+ sp_usart_send(pos, &req);
+ return 0;
+}
+
+//È·ÈÏÁ÷ˮ״̬
+static uint8 sp_confirm_transdtl_account(sp_protocol_response_t* resp, sp_pos_t* pos)
+{
+ uint8 size;
+ cw_unpack_context unpack;
+ unpack_field_t field;
+
+ if(!resp->retcode)
+ {
+ sp_unpack_init(&unpack, resp->data, resp->datalen);
+ size = sp_unpack_map_size(&unpack);
+ while(size-- > 0)
+ {
+ sp_unpack_value(&unpack,&field);
+ if(IS_KEY(PK_BIN_BILLNO,field.key))
+ {
+ if(MEMCMP(field.val.binval, transdtl_account_bilLno,
+ sizeof(transdtl_account_bilLno)) == 0)
+ {
+ pos->unconfirm_transdtl.transaddr+= sizeof(sp_transdtl_t);
+ if(ADDR_TRANSDTL_END <= pos->unconfirm_transdtl.transaddr)
+ {
+ pos->unconfirm_transdtl.transaddr= ADDR_TRANSDTL_BEGIN;
+ }
+ return sp_write_unconfirm_record(pos);
+ }
+ }
+ }
+ }
+ return resp->retcode;
+
+}
+
+static uint8 sp_confirm_heartbeat(sp_protocol_response_t* resp, sp_pos_t* pos)
+{
+ uint8 size;
+ uint8 ctime[6];
+ uint8 systime[7];
+ uint8 login_flag = 0;
+ cw_unpack_context unpack;
+ unpack_field_t field;
+
+ if(resp->retcode)
+ {
+ return resp->retcode;
+ }
+ pos->heartbeat.heart_status = HEART_RECV;
+
+ sp_unpack_init(&unpack,resp->data,resp->datalen);
+ size = sp_unpack_map_size(&unpack);
+ while(size-- > 0)
+ {
+ sp_unpack_value(&unpack,&field);
+ if(IS_KEY(PK_BIN_SYSTIME, field.key))
+ {
+ if(field.strlen == 7)
+ {
+ MEMCPY(systime,field.val.binval,7);
+ sp_get_bcdtime(ctime);
+ if(MEMCMP(ctime,systime +1,5) != 0)
+ {
+ if(!sp_check_time_valid(systime +1))
+ {
+ sp_set_bcdtime(systime +1);
+ }
+ }
+ }
+ }
+ else if(IS_KEY(PK_STR_STATUS, field.key))
+ {
+ if(MEMCMP(field.val.strval, "normal", field.strlen) == 0)
+ {
+ login_flag = 1;
+ }
+ else if(MEMCMP(field.val.strval, "logout", field.strlen) == 0)
+ {
+ login_flag = 0;
+ }
+ else if(MEMCMP(field.val.strval, "closed", field.strlen) == 0)
+ {
+ login_flag = 2;
+ }
+ }
+ }
+ sp_save_heartbeat_info(pos, login_flag);
+ return resp->retcode;
+}
+
+uint8 sp_confirm_login(sp_protocol_response_t* resp, sp_pos_t* pos)
+{
+ uint8 size;
+ uint8 ctime[6];
+ uint8 systime[7];
+ uint8 login_flag = 0;
+ uint8 unit = 0;
+ uint8 offline_maxhour = 0;
+ cw_unpack_context unpack;
+ unpack_field_t field;
+
+ MEMCLEAR(ctime, sizeof(ctime));
+ MEMCLEAR(systime, sizeof(systime));
+ if(resp->retcode)
+ {
+ return resp->retcode;
+ }
+ pos->heartbeat.heart_status = HEART_RECV;
+
+ sp_unpack_init(&unpack,resp->data,resp->datalen);
+ size = sp_unpack_map_size(&unpack);
+ while(size-- > 0)
+ {
+ sp_unpack_value(&unpack,&field);
+ if(IS_KEY(PK_INT_OFFLINEMAXHOUR, field.key))
+ {
+ offline_maxhour = field.val.intval;
+ }
+ else if(IS_KEY(PK_INT_PULSEINHML, field.key))
+ {
+ unit = field.val.intval;
+ }
+ else if(IS_KEY(PK_BIN_SYSTIME, field.key))
+ {
+ if(field.strlen == 7)
+ {
+ MEMCPY(systime,field.val.binval,7);
+ sp_get_bcdtime(ctime);
+ if(MEMCMP(ctime,systime +1,5) != 0)
+ {
+ if(!sp_check_time_valid(systime +1))
+ {
+ sp_set_bcdtime(systime +1);
+ }
+ }
+ }
+ }
+ }
+
+ login_flag = 1;
+ sp_save_login_info(pos, login_flag, unit, offline_maxhour);
+ return resp->retcode;
+}
+
+static protocol_cmd_t protocol_cmds[] =
+{
+ {SP_CMD_TRANSDTL_ACCOUNT, sp_confirm_transdtl_account},
+ {SP_CMD_HEARTBEAT, sp_confirm_heartbeat},
+ {SP_CMD_LOGIN, sp_confirm_login},
+ {0, NULL}
+};
+
+static uint16 sp_async_confirm_process(sp_pos_t* pos)
+{
+ uint8 ret = 0;
+ uint8 i = 0;
+ int32 timeout_ms = COMM_WAIT_TIME;
+ sp_protocol_response_t resp;
+
+ ret = sp_usart_recv(pos, &resp, timeout_ms);
+ if(ret)
+ {
+ return ret;
+ }
+ while(protocol_cmds[i].func != NULL && protocol_cmds[i].cmd != 0)
+ {
+ if(protocol_cmds[i].cmd == resp.excmd)
+ {
+ return protocol_cmds[i].func(&resp, pos);
+ }
+ ++i;
+ }
+ return 1;
+}
+
+//¼ì²âÉ豸ͨѶ״̬£¬¿ÕÏÐʱ¼ä½øÐÐÁ÷Ë®´¦ÀíµÈ¹¤×÷
+static void sp_check_and_switch_linkstat(sp_pos_t* pos)
+{
+ if(pos->heartbeat.heart_status == HEART_SEND)
+ {
+ //ÒÑ·¢ËÍÐÄÌø£¬Î´ÊÕµ½Ó¦´ð
+ pos->link_stat = 0;
+ pos->heartbeat.heart_status = HEART_INIT;
+ }
+ else if(pos->heartbeat.heart_status == HEART_RECV)
+ {
+ //ÒÑ·¢ËÍÐÄÌø£¬ÊÕµ½Ó¦´ð
+ pos->link_stat = 1;
+ pos->heartbeat.heart_status = HEART_INIT;
+ }
+}
+
+void sp_communicate(sp_pos_t* pos)
+{
+ uint16 ret = 0;
+ uint32 ticker = 0;
+ sp_transdtl_t transdtl;
+
+ if(pos->deviceno == 0)
+ {
+ return;
+ }
+ ticker = sp_get_ticker();
+ if(ticker - pos->last_comm_status.sendtime > COMM_WAIT_TIME)
+ {
+ if(pos->devlogin.last_login_ticker == 0 || pos->devlogin.login_flag == 0
+ || (ticker - pos->devlogin.last_login_ticker) > DELAY_TIME60s*60*24)
+ {
+ pos->devlogin.last_login_ticker = ticker;
+ sp_async_equipment_login(pos);
+ }
+ else if(ticker < pos->heartbeat.last_heartbeat_ticker
+ || pos->heartbeat.last_heartbeat_ticker == 0
+ || (ticker - pos->heartbeat.last_heartbeat_ticker) > DELAY_TIME60s*2)
+ {
+ pos->heartbeat.last_heartbeat_ticker = ticker;
+ sp_async_heartbeat(pos);
+ }
+ else
+ {
+ sp_check_and_switch_linkstat(pos);
+ if(pos->link_stat)
+ {
+ //¼ì²âµ±Ç°ÊÇ·ñÓÐδÉÏ´«µÄÁ÷Ë®
+ if(pos->unconfirm_transdtl.transaddr <= pos->last_transdtl.transaddr)
+ {
+ ret = sp_flash_read((uint32)pos->unconfirm_transdtl.transaddr, (uint8*)&transdtl,
+ sizeof(transdtl));
+ if(!ret)
+ {
+ if(!pos->sysconf.work_mode)
+ {
+ pos->heartbeat.last_heartbeat_ticker = ticker;
+ sp_async_upload_transdtl(pos, &transdtl);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ sp_async_confirm_process(pos);
+}
diff --git a/supwisdom/sp_communicate.h b/supwisdom/sp_communicate.h
new file mode 100644
index 0000000..b8daf77
--- /dev/null
+++ b/supwisdom/sp_communicate.h
@@ -0,0 +1,139 @@
+#ifndef _SP_COMMUNICATE_H_
+#define _SP_COMMUNICATE_H_
+
+#include "sp_config.h"
+
+#define PROTOCOL_COMMAND_V2 0x80
+#define PROTOCOL_WITH_MAC(x) ((x) | 0x80)
+#define PROTOCOL_WITHOUT_MAC(x) ((x) & 0x7F)
+#define PROTOCOL_FLAG_PACK(x) ((x) | 0x01)
+#define PROTOCOL_FLAG_DES_PACK(x) ((x) & 0xFE)
+
+#define PK_BIN_DEVPHYID "a"
+#define PK_INT_CARDNO "b"
+#define PK_BIN_CARDVERNO "c"
+#define PK_INT_DEVSEQNO "d"
+#define PK_STR_VERSION "e"
+#define PK_INT_BLKINDEX "f"
+#define PK_BIN_TRANSDATE "g"
+#define PK_BIN_TRANSTIME "h"
+#define PK_INT_PAYAMT "i"
+#define PK_INT_AMOUNT "j"
+#define PK_INT_FLAG "k"
+#define PK_STR_AVAIABLE "l"
+#define PK_BIN_SYSTIME "m"
+#define PK_STR_UPGRADE "n"
+#define PK_BIN_BLKBITMAP "o"
+#define PK_BIN_FILECRC "p"
+#define PK_INT_FILESIZE "q"
+#define PK_INT_SEQNO "r"
+#define PK_BIN_FILEDATA "s"
+#define PK_INT_MAXSEQNO "t"
+#define PK_INT_SECONDS "u"
+#define PK_INT_CREDIT_TOTAL "v"
+#define PK_INT_CREDIT_PAYCNT "w"
+#define PK_INT_CREDIT_AVAILABAL "x"
+#define PK_INT_CREDIT_NO "y"
+#define PK_BIN_EXPIRE "z"
+#define PK_INT_FEETYPE "A"
+#define PK_BIN_CARDPHYID "B"
+#define PK_STR_STATUS "C"
+#define PK_INT_BALANCE "D"
+#define PK_INT_OFFLINE_FORBID_FLAG "E"
+#define PK_INT_CREDIT_PAYCNT_LACK "F"
+#define PK_INT_ONCETIME_LIMIT "G"
+#define PK_INT_DAYTOTAL_LIMIT "H"
+#define PK_INT_COUNT "J"
+#define PK_BIN_BLKLIST "K"
+#define PK_INT_CREDIT_NEXT_NO "L"
+#define PK_BIN_RANDOM "M"
+#define PK_INT_DEVICENO "N"
+#define PK_BIN_DEVTIME "O"
+#define PK_STR_DEVTYPE "P"
+#define PK_BIN_SAMNO "Q"
+#define PK_INT_PARAVERNO "R"
+#define PK_INT_PARA_GROUPID "S"
+#define PK_INT_FEEVERNO "T"
+#define PK_INT_FEE_CFGID "U"
+#define PK_BIN_WSCLIENT_ID "V"
+#define PK_INT_WSCLIENT_STATUS "W"
+#define PK_INT_FLOWSENSORS "X"
+#define PK_BIN_SOFT_MD5 "Y"
+#define PK_INT_CUSTID "Z"
+#define PK_STR_SHORT_URL "0"
+#define PK_INT_WATERSTATUS "1"
+#define PK_INT_WATERMUCH "2"
+
+#define PK_BIN_BILLNO "3"
+#define PK_INT_TRANSWAY "4"
+#define PK_INT_UNTRANSCONST "5"
+#define PK_BIN_DEVICEKEY "6"
+#define PK_INT_WORKMODE "7"
+#define PK_INT_OFFLINEMAXHOUR "8"
+#define PK_INT_PULSEINHML "9"
+#define PK_BIN_CITIZEN_CARDNO "10"
+#define PK_INT_WATERLIMIT "11"
+#define PK_INT_FEEAMOUNT "12"
+#define PK_INT_FEEUNIT "13"
+#define PK_INT_VAILDTIME "14"
+#define PK_INT_AUTHSTATUS "15"
+#define PK_INT_PAYSTATUS "16"
+#define PK_INT_FEESTART "17"
+
+#define SP_CMD_UPGRADE 0x20 //ÔÚÏßÉý¼¶
+#define SP_CMD_TRANSDTL_ACCOUNT 0x22 //¼ÇÕËÁ÷Ë®
+#define SP_CMD_HEARTBEAT 0x24 //ÐÄÌø
+#define SP_CMD_CARD_AUTHENTICATION 0x26 //¿¨ÔÚÏßÈÏÖ¤
+#define SP_CMD_LOGIN 0x2C //怬
+#define SP_CMD_FACTORY_LINK_TEST 0x2E //¹¤³§Á´Â·²âÊÔ
+#define SP_CMD_SHORTURL 0x28 //»ñÈ¡¶þάÂë¶ÌµØÖ·
+#define SP_CMD_QRCODE_PAY_QUERY 0x2A //¶þάÂëÏû·ÑÈ·ÈÏ
+
+#define IS_PUSH_FLOW(cmd) (0x1&(cmd))
+
+#pragma pack(push)
+#pragma pack(1)
+
+typedef struct
+{
+ uint16 datalen;
+ uint8 command;
+ uint8 excmd; // ÇëÇóÃüÁîÒªÇóżÊý
+ uint8 flag;
+ uint8 data[256];
+} sp_protocol_request_t;
+
+typedef struct
+{
+ uint16 datalen;
+ uint8 command;
+ uint8 excmd; // ÇëÇóÃüÁîÒªÇóżÊý
+ uint8 flag;
+ uint8 retcode;
+ uint8 data[256];
+} sp_protocol_response_t;
+
+#pragma pack(pop)
+
+typedef uint8(* protocol_cmd_func_t)(sp_protocol_response_t* resp, sp_pos_t* pos);
+
+typedef struct
+{
+ uint8 cmd;
+ protocol_cmd_func_t func;
+} protocol_cmd_t;
+
+void sp_communicate(sp_pos_t* pos);
+uint16 sp_card_authentication(sp_pos_t* pos, sp_card_t* card);
+uint16 sp_async_equipment_login(sp_pos_t* pos);
+uint16 sp_async_heartbeat(sp_pos_t* pos);
+uint16 sp_async_upload_transdtl(sp_pos_t* pos, sp_transdtl_t* dtl);
+uint16 sp_qrcode_init(sp_pos_t* pos, sp_card_t* card);
+uint16 sp_qrcode_query(sp_pos_t* pos, sp_card_t* card);
+
+//ͨѶ
+uint8 sp_comm_call(sp_pos_t* pos, sp_protocol_request_t* req,
+ sp_protocol_response_t* resp, int32 timeout_ms);
+void sp_protocol_req_init(sp_protocol_request_t* req, uint8 command);
+#endif
+
diff --git a/supwisdom/sp_config.h b/supwisdom/sp_config.h
new file mode 100644
index 0000000..81f4140
--- /dev/null
+++ b/supwisdom/sp_config.h
@@ -0,0 +1,280 @@
+#ifndef _SP_CONFIG_H
+#define _SP_CONFIG_H
+
+#include "sp_version.h"
+#include "../nec_hardware.h"
+
+#ifndef int8
+#define int8 signed char
+#endif
+
+#ifndef uint8
+#define uint8 unsigned char
+#endif
+
+#ifndef int16
+#define int16 signed short
+#endif
+
+#ifndef uint16
+#define uint16 unsigned short
+#endif
+
+#ifndef int32
+#define int32 signed int
+#endif
+
+#ifndef uint32
+#define uint32 unsigned int
+#endif
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+#define DEV_TYPE "G401302"
+#define DEV_OFFLINE_DEFAULT_HOUR 168
+#define DEV_BLKBITMAP_DONE 1984
+#define DEV_MAX_DEVICENO 99
+
+#define PRO_VERSION GIT_VERSION
+#define BUILD_DATE __DATE__ // " " __TIME__
+#ifdef FLOWSENSOR
+#define PURCHASE_FLOWSENSOR 1
+#else
+#define PURCHASE_FLOWSENSOR 0
+#endif
+
+enum
+{
+ SP_KEY_NONE = 0xFF,
+ SP_KEY_0 = 0,
+ SP_KEY_1 = 1,
+ SP_KEY_2 = 2,
+ SP_KEY_3 = 3,
+ SP_KEY_4 = 4,
+ SP_KEY_5 = 5,
+ SP_KEY_6 = 6,
+ SP_KEY_7 = 7,
+ SP_KEY_8 = 8,
+ SP_KEY_9 = 9,
+ SP_KEY_ENTER = 12,
+ SP_KEY_CLEAR = 11
+};
+
+typedef enum
+{
+ PAYMODE_INIT = 0,
+ PAYMODE_CARD = 1,
+ PAYMODE_QRCODE = 2,
+} sp_paymode_e;
+
+#pragma pack(push)
+#pragma pack(1)
+
+typedef struct
+{
+ uint8 command;
+ uint32 sendtime;
+} sp_comm_status_t;
+
+typedef struct
+{
+ uint32 last_heartbeat_ticker;
+ uint8 hwVer[16]; //É豸°æ±¾ºÅ
+ uint8 offlineRecordCount; //δÉÏ´«Á÷Ë®ÊýÁ¿
+ uint8 workMode; //µ±Ç°×´Ì¬£¬0-¿ÕÏУ¬1-ÕýÔÚʹÓã¬9-ÒÉËÆ¹ÊÕÏ
+ uint8 heart_status; //ÐÄÌø×´Ì¬£¬0-³õʼ»¯£¬1-·¢ËÍ£¬2-½ÓÊÕ
+} sp_heartbeat_t;
+
+typedef struct
+{
+ uint32 last_login_ticker;
+ uint8 login_flag; //0-δǩµ½£¬1-ÒÑÇ©µ½£¬2-×¢Ïú
+ uint8 hwVer[16]; //É豸°æ±¾ºÅ
+ uint8 deviceKey; //É豸¹¤×÷ÃÜÔ¿
+} sp_login_t;
+
+//Ïû·ÑÁ÷Ë®ÐÅÏ¢½á¹¹
+typedef struct
+{
+ uint8 devphyid[4]; //É豸±àºÅ
+ uint8 transdate[3]; //YYDDMM¸ñʽÈÕÆÚ
+ uint8 transtime[3];
+ uint8 billno[10]; //½»Ò×¶©µ¥±àºÅ
+ uint8 cardphyid[4]; //¿¨ÎïÀíid
+ uint8 transway; //½»Ò×·½Ê½£¬0-³õʼ£¬1-Ë¢¿¨£¬2-ɨÂë
+ uint8 amount; //ʵ¼ÊÖ§¸¶½ð¶î
+ uint8 paidAmount; //ÒÑÖ§¸¶½ð¶î£¬µ±ÊÇÏȿ۷ÑģʽÏ£¬¼Ç¼ÒÑÖ§¸¶µÄ½ð¶î
+ uint8 flowsensors; //ʵ¼ÊʹÓüÆÁ¿£¨µ¥Î»£º°ÙºÁÉý£©
+ uint8 transtatus; //Á÷ˮ״̬£¬0-³õʼ£¬1-³É¹¦£¬2-ʧ°Ü
+ uint8 reverse[1]; //ռλ·û
+ uint8 crc[2]; //len=32
+} sp_transdtl_t;
+
+typedef struct
+{
+ uint8 offline_work_hour; //ÔÊÐíÍÑ»ú¹¤×÷×î´óСʱ 0 ~ 168 Сʱ£¬0 ±íʾ²»ÏÞÖÆ
+ uint8 deviceno; //»úºÅ
+ uint8 devphyid[4]; //ÎïÀíID
+ uint8 flowsensor_unit; // 100ml¶ÔÓ¦Âö³åÊý
+ uint8 unused[54];
+ uint8 login_flag; //0-δǩµ½£¬1-ÒÑÇ©µ½£¬2-ÒÑ×¢Ïú
+ uint8 crc[2];
+} sp_config_t;
+
+typedef struct
+{
+ uint32 transaddr; //µØÖ·
+ uint16 this_offset; //Ò³Æ«ÒÆÎ»
+ uint8 crc[2]; //len=8
+} sp_last_transdtl_t;
+
+typedef struct
+{
+ uint32 transaddr; //µØÖ·
+ uint16 this_offset; //Ò³Æ«ÒÆÎ»
+ uint8 crc[2]; //len=8
+} sp_unconfirm_transdtl_t;
+
+//Ïû·ÑÐÅÏ¢
+typedef struct
+{
+ uint32 free_used_num; //ÒÑÃâ·ÑʹÓüÆÁ¿(µ¥Î»:100ml)
+
+ uint8 starttime[6]; //Ë¢¿¨Ê±¼ä
+ /*Ïȿۿîºó³öË®*/
+ uint16 prepaid_num; //µ¥´Î¿ÉÓüÆÁ¿(µ¥Î»:100ml)
+ uint16 prepaid_amt; //µ¥´ÎÔ¤¸¶½ðÇ®
+
+ uint16 paid_num; //ÀۼƿÉÓüÆÁ¿(µ¥Î»:100ml)
+ uint16 paid_sum; //ÀÛ¼ÆÖ§¸¶½ð¶î
+ uint16 used_num; //ÒÑʹÓüÆÁ¿(µ¥Î»:100ml)
+} sp_purchase_t;
+
+//¶þάÂëÐÅÏ¢
+typedef struct
+{
+ char qrcode_url[32]; ///¶þάÂë¶ÌÂë
+ uint32 starttime; //¶þάÂ뿪ʼʱ¼ä
+ uint32 nowtime; //¶þάÂ뵱ǰʱ¼ä
+ uint32 validtime; //¶þάÂëÓÐЧʱ¼ä
+ uint8 authstatus; //Óû§È·ÈÏ״̬£¨0-δȷÈÏ£¬1-ÒÑÈ·ÈÏ£©
+ uint8 paystatus; //Ö§¸¶×´Ì¬£¨0-´ýÖ§¸¶£¬ 1-ÒÑÖ§¸¶£¬ 2-´ú¿Û£¬3 - ¹Ø±Õ£©
+ uint8 paidAmount; //µ±¶©µ¥ÊÇÒÑÖ§¸¶×´Ì¬£¬·µ»ØÖ§¸¶³É¹¦½ð¶î £¬ ·ñÔòÊÇ 0
+} sp_qrcode_t;
+
+//É豸²ÎÊý
+typedef struct
+{
+ uint8 dev_offline_maxhour; //É豸ÍÑ»ú×î´ó¹¤×÷ʱ¼ä(Сʱ),0-²»ÏÞÖÆ,168-ĬÈÏʱ¼ä
+ uint8 flowsensor_unit; //100ml¶ÔÓ¦Âö³åÊý
+ uint8 hwVer[16]; //É豸°æ±¾ºÅ
+ uint8 deviceKey[8]; //É豸¹¤×÷ÃØÔ¿
+ uint8 work_mode; //É豸¹¤×÷״̬
+} sp_sysconf_t;
+
+
+typedef struct
+{
+ uint8 tag_type;
+ uint8 cur_state;
+ uint8 snr[8];
+ uint32 firsttick; //Ê״ζÁ¿¨Ê±¼ä
+ uint32 lasttick; //×îºó¶Á¿¨Ê±¼ä
+} sp_cardstate_t;
+
+typedef struct
+{
+ uint8 current_state; //µ±Ç°¹¤×÷״̬
+ uint16 errcode;
+ uint32 tick;
+ uint8 last_state; //ÉÏÒ»´Î״̬
+
+ uint8 pause_status; //Óû§Ê¹ÓÃ״̬£¬0--ʹÓÃÖУ¬!0--ÔÝÍ£
+ uint32 pause_tick; //ÔÝͣʱµÄʱ¼ä
+} sp_cardworkstate_t;
+
+//Ë®¿ØÆ÷É豸ÐÅÏ¢
+typedef struct
+{
+ uint8 link_stat; //0--Á´Â·¹¤×÷ÖУ¬1---Á´Â·¿ÉÓÃ
+ uint8 load_para_status; //0--Õý³££¬!0--´íÎó
+ uint8 deviceno;
+ uint8 local_deviceno;
+ uint8 devphyid[4];
+
+ sp_cardstate_t cardState;
+ sp_sysconf_t sysconf;
+ sp_comm_status_t last_comm_status;
+ sp_heartbeat_t heartbeat;
+ sp_login_t devlogin;
+ sp_last_transdtl_t last_transdtl;
+ sp_unconfirm_transdtl_t unconfirm_transdtl;
+
+ sp_paymode_e paymode;
+ sp_purchase_t purchase;
+} sp_pos_t;
+
+//·ÑÂÊÐÅÏ¢
+typedef struct
+{
+ uint8 fee_start; //T°ÙºÁÉý¿ªÊ¼;
+ uint8 fee_unit; //µ¥´Î¿Û·Ñ¿ÉÓÃÁ÷Á¿£¨µ¥Î»:100ml£©
+ uint8 fee_amt; //µ¥´Î¿Û·Ñ½ð¶î£¬ÒÔ·ÖΪµ¥Î»
+} sp_feepara_t;
+
+//¿¨½á¹¹ÐÅÏ¢
+typedef struct
+{
+ uint8 cardphyid[4];
+ uint8 citizen_cardno[12]; //ÊÐÃñºÅ
+ uint8 cardtype;
+ uint8 expiredate[4];
+
+ uint8 waterlimit; //µ¥´Î³öË®ÉÏÏÞ£¨100ml£©
+ uint8 billno[10]; //½»Ò×¶©µ¥±àºÅ,BCDÂë
+ sp_qrcode_t qrcode; //¶þάÂë
+ sp_feepara_t feepara;
+} sp_card_t;
+
+#pragma pack(pop)
+
+typedef enum
+{
+ HEART_INIT = 0,
+ HEART_SEND = 1,
+ HEART_RECV = 2
+} sp_heart_status_t;
+
+typedef enum
+{
+ TAG_TYPE_UNKONWN = 0, //δ֪¿¨ÀàÐÍ
+ TAG_TYPE_M1, //M1¿¨
+ TAG_TYPE_CPU //CPU¿¨
+} sp_cardTag_type;
+
+typedef enum
+{
+ STATE_NONE = 0,
+ STATE_EXIST,
+ STATE_ERROR=0xFF
+} sp_cardState_type;
+
+typedef enum
+{
+ CARDWORKSTATUS_NONE = 0,
+ CARDWORKSTATUS_READY,
+ CARDWORKSTATUS_WORKING,
+ CARDWORKSTATUS_WORKING_WITHOUTCARD,
+ CARDWORKSTATUS_PAUSE,
+ CARDWORKSTATUS_STOPPING,
+ CARDWORKSTATUS_STOPPED,
+ CARDWORKSTATUS_TAKEOFF,
+ CARDWORKSTATUS_WORKERROR,
+ CARDWORKSTATUS_FEECARD_WORKING,
+ CARDWORKSTATUS_SET_DEV,
+ CARDWORKSTATUS_ERROR=0xff
+} sp_cardWorkState_type;
+
+#endif
diff --git a/supwisdom/sp_constant.h b/supwisdom/sp_constant.h
new file mode 100644
index 0000000..3081fc0
--- /dev/null
+++ b/supwisdom/sp_constant.h
@@ -0,0 +1,58 @@
+#ifndef _SP_CONSTANT_H_
+#define _SP_CONSTANT_H_
+
+///////////////////////////////////////////////////////////////////////////////
+#define RC_CPU_FILENOTFOUND 0x6A82
+#define RC_CPU_RECORDNOTFOUND 0x6A83
+#define RC_CPU_NOMAC 0x9406
+
+////////////////////////////////////////////////////////////////////////////////
+#define RC_SUCCESS 0 // ³É¹¦
+#define RC_PSAM_ERR 1 //SAM¸´Î»Ê§°Ü
+#define RC_CARD_LOGIN 2 //ÑéÖ¤ÃÜԿʧ°Ü
+#define RC_CARD_READ 3 //¶Á¿¨Ê§°Ü
+#define RC_CARD_WRITE 4 //д¿¨Ê§°Ü
+#define RC_FLASH_ERR 5 //FLASH´íÎó
+#define RC_HARDWARE_ERR 6 //Ó²¼þ¼ÓÔØ´íÎó
+#define RC_FLASH_NO_RIGHT 7 //·Ç¿Éдflash
+
+#define RC_CARD_NORIGHT 11 //¿¨ÎÞȨÏÞ
+#define RC_CARD_EXPIRED 12 //¹ýÆÚ¿¨
+#define RC_CARD_AUTHENTICATION 13 //¿¨ÈÏ֤ʧ°Ü
+#define RC_CARD_LOST 14 //ºÚÃûµ¥¿¨
+#define RC_CARDNO_EXCEPT 17 //¿¨ºÅÒì³£
+#define RC_CARD_TIMEOUT 18 //ʹÓÃʱ¼äÌ«³¤
+#define RC_CARDBAL_EXCEPT 19 //¿¨Óà¶îÒì³£
+#define RC_CARDBAL_LACK 20 //¿¨Óà¶î²»×ã
+
+#define RC_DEVPHYID_NOTSET 21 //É豸µØÖ·Î´ÉèÖÃ
+#define RC_FEERATE_NOTSET 22 //·ÑÂÊδ³õʼ»¯
+#define RC_DEV_OFFLINE_ERROR 23 // É豸ÍÑ»ú¹¤×÷Ì«³¤
+#define RC_FILE09_CRC_ERR 25 ////¼Ç¼CRC´íÎó
+#define RC_FILE10_CRC_ERR 26 //Ë®¿ØÇ®°üCRC´íÎó
+#define RC_CARD_INVALID 27 //ÎÞЧ¿¨
+#define RC_FEENUM_ERROR 28 //·ÑÂʸöÊý´íÎó
+#define RC_NOTSUPPORT 29 //²»Ö§³Ö
+#define RC_NOT_SAME_CARD 30 //²»Í¬¿¨
+
+#define RC_MODE_NOT_SUPPORT 42 //Ïû·Ñģʽ²»Ö§³Ö
+#define RC_UPDPROG_ERR 43 //Éý¼¶Ê§°Ü
+
+#define RC_CONFPARA_CRC_ERR 55 //ÅäÖòÎÊýcrc´íÎó
+#define RC_TRANSDTL_FULL 58 // Á÷Ë®ÒÑÂú
+#define RC_TRANSDTL_NO_ERR 59 //Á÷Ë®ºÅÒì³£
+#define RC_DEVICENO_OUT 60 // »úºÅ¹ý´ó
+
+#define RC_QRCODE_FAILURE 61 //¶þάÂë»ñȡʧ°Ü
+#define RC_QRCODE_TIMEOUT 62 //¶þάÂ볬ʱ
+#define RC_QRCODE_QUERY_FAIL 63 //¶þάÂëÈÏ֤ʧ°Ü
+
+#define RC_DEV_LOGIN_FAIL 64 //É豸µÇ¼ʧ°Ü
+#define RC_DEV_NOT_LOGIN 65 //É豸δǩµ½
+#define RC_DEV_FAULT 66 //É豸ÒÉËÆ¹ÊÕÏ
+#define RC_DEV_NOSET_FLOWSENSOR_UNIT 67 //É豸Á÷Á¿¼ÆË㵥λδÉèÖÃ
+#define STATUS_KEEPOPEN 1 //³£¿ª¿¨
+#define STATUS_CLOSED 0 //È¡Ïû³£¿ª¿¨
+
+#endif
+
diff --git a/supwisdom/sp_consume.c b/supwisdom/sp_consume.c
new file mode 100644
index 0000000..587e2a4
--- /dev/null
+++ b/supwisdom/sp_consume.c
@@ -0,0 +1,729 @@
+#include "sp_util.h"
+#include "sp_constant.h"
+#include "sp_display.h"
+#include "sp_flash.h"
+#include "sp_card.h"
+#include "sp_des.h"
+#include "sp_msgpack.h"
+#include "sp_menu.h"
+#include "sp_data.h"
+#include "sp_consume.h"
+#include "sp_communicate.h"
+
+static int count = 0;
+static uint16 sp_calc_payamt_by_flowsensor(sp_pos_t* pos, sp_card_t* card)
+{
+ uint32 usedcount = 0;
+
+ if(pos->purchase.paid_num < 1)
+ {
+ //Ê×ÏÈÔ¤¿ÛÒ»±Ê
+ if(card->feepara.fee_start > 0)
+ {
+ //ǰnË®Ãâ·Ñ
+ pos->purchase.prepaid_num = card->feepara.fee_start;
+ pos->purchase.prepaid_amt = 0;
+ }
+ else
+ {
+ pos->purchase.prepaid_num = card->feepara.fee_unit;
+ pos->purchase.prepaid_amt = card->feepara.fee_amt;
+ }
+ pos->purchase.used_num = 0;
+ return 0;
+ }
+ //usedcount = sp_flowsensor_get_count()/pos->sysconf.flowsensor_uint;
+ usedcount = count/pos->sysconf.flowsensor_unit;
+ count++;
+ if(usedcount < pos->purchase.paid_num)
+ {
+ //ûÓдﵽ¿Û·ÑÁ÷Á¿
+ return 0;
+ }
+ pos->purchase.used_num = pos->purchase.paid_num;
+ pos->purchase.prepaid_num = card->feepara.fee_unit;
+ pos->purchase.prepaid_amt = card->feepara.fee_amt;
+ return 0;
+}
+
+//¼ÇÕËģʽÏû·Ñ
+uint16 sp_account_purchase(uint16 amount)
+{
+ return 0;
+}
+
+static uint8 gPICC_SNR[4]; /* ¿¨Æ¬SNºÅ */
+
+void sp_test_card_state(sp_pos_t* pos, sp_cardworkstate_t* cardWorkState, uint32 tick)
+{
+ uint8 ret = 0;
+ sp_card_t cardpcd;
+ switch(pos->cardState.cur_state)
+ {
+ case STATE_NONE:
+ MEMCLEAR(&cardpcd, sizeof(cardpcd));
+ if(sp_card_request(&cardpcd) == 0)
+ {
+ MEMCPY(pos->cardState.snr, cardpcd.cardphyid, sizeof(cardpcd.cardphyid));
+ MEMCPY(gPICC_SNR, cardpcd.cardphyid, sizeof(cardpcd.cardphyid));
+ pos->cardState.tag_type = cardpcd.cardtype;
+ pos->cardState.cur_state = STATE_EXIST;
+ pos->cardState.firsttick = tick;
+ pos->cardState.lasttick = tick;
+ }
+ else
+ {
+ cardWorkState->errcode = RC_CARD_INVALID;
+ }
+ break;
+ case STATE_EXIST:
+ //¼ì²â¿¨ÊÇ·ñ¼ÌÐø´æÔÚ
+ if(pos->cardState.tag_type == TAG_TYPE_CPU)
+ {
+ ret = sp_check_cpu_exist();
+ if(ret)
+ {
+ pos->cardState.cur_state = STATE_NONE;
+ break;
+ }
+ else
+ {
+ memcpy(pos->cardState.snr, gPICC_SNR, 8);
+ pos->cardState.lasttick = tick;
+ }
+ }
+ break;
+ default:
+ pos->cardState.cur_state = STATE_NONE;
+ break;
+ }
+}
+
+static uint16 sp_dev_config_check(const sp_pos_t* pos)
+{
+ uint8 devphyid[4];
+ MEMCLEAR(devphyid, sizeof(devphyid));
+ if(MEMCMP(pos->devphyid, devphyid, sizeof(devphyid)) == 0)
+ {
+ return RC_DEVPHYID_NOTSET;
+ }
+ if(pos->devlogin.login_flag != 1)
+ {
+ return RC_DEV_NOT_LOGIN;
+ }
+ if(pos->sysconf.work_mode == 9)
+ {
+ return RC_DEV_FAULT;
+ }
+ if(pos->sysconf.flowsensor_unit == 0)
+ {
+ return RC_DEV_NOSET_FLOWSENSOR_UNIT;
+ }
+ return 0;
+}
+
+//¶ÁÈ¡µÚÒ»±ÊδÉÏ´«Á÷Ë®Ïû·ÑÈÕÆÚʱ¼ä
+static uint8 sp_read_unconfirm_first_record(uint8 termtime[6])
+{
+ return 1;
+}
+
+static uint16 sp_dev_offline_check(const sp_pos_t* pos)
+{
+ uint8 ret;
+ uint8 record_termtime[6];
+ uint8 ctime[6];
+ int32 nowtime;
+ int32 dtltime;
+
+ if(pos->sysconf.dev_offline_maxhour == 0)
+ {
+ return 0;
+ }
+ memset(record_termtime,0,sizeof(record_termtime));
+ ret = sp_read_unconfirm_first_record(record_termtime);
+ if(ret)
+ {
+ return 0;
+ }
+ sp_get_bcdtime(ctime);
+ nowtime = format_time_covert_secs(ctime);
+ dtltime = format_time_covert_secs(record_termtime);
+
+ /**
+ *Á÷ˮʱ¼ä´óÓÚÉ豸ʱÖÓÇÒ³¬¹ý24Сʱ
+ **/
+ if((dtltime > nowtime) &&
+ ((dtltime - nowtime) > (24*60*DELAY_TIME60s)))
+ {
+ if(sp_valve_state())
+ {
+ sp_valve_off();
+ }
+ return RC_DEV_OFFLINE_ERROR;
+ }
+ /**
+ *Á÷ˮʱ¼äСÓÚÉ豸ʱÖÓÇÒ³¬¹ýãÐÖµ
+ **/
+ if((dtltime < nowtime) &&
+ ((nowtime - dtltime) > (pos->sysconf.dev_offline_maxhour*3600)))
+ {
+ if(sp_valve_state())
+ {
+ sp_valve_off();
+ }
+ return RC_DEV_OFFLINE_ERROR;
+ }
+ return 0;
+}
+
+static uint16 sp_card_valid_check(const sp_card_t* card)
+{
+ uint8 ctime[6];
+ /*
+ if(card->cardno < 1)
+ {
+ return RC_CARDNO_EXCEPT;
+ }
+ */
+ sp_get_bcdtime(ctime);
+ if(memcmp(card->expiredate +1, ctime, 3) < 0)
+ {
+ return RC_CARD_EXPIRED;
+ }
+ return 0;
+}
+
+static uint16 sp_check_dev(const sp_pos_t* pos)
+{
+ uint16 ret = 0;
+ uint8 ctime[6];
+ MEMCLEAR(ctime, sizeof(ctime));
+ sp_get_bcdtime(ctime);
+ if(pos->load_para_status)
+ {
+ return pos->load_para_status;
+ }
+ ret = sp_dev_config_check(pos);
+ if(ret)
+ {
+ return ret;
+ }
+ ret = sp_dev_offline_check(pos);
+ if(ret)
+ {
+ return ret;
+ }
+
+ return 0;
+}
+
+static uint16 do_idle(sp_pos_t* pos)
+{
+ uint8 ctime[6];
+ MEMCLEAR(ctime, sizeof(ctime));
+ sp_get_bcdtime(ctime);
+ show_home(pos);
+ return 0;
+}
+
+static uint16 do_new(sp_pos_t* pos, sp_card_t* card)
+{
+ uint16 ret = 0;
+ sp_transdtl_t record;
+ MEMCLEAR(&record, sizeof(record));
+ card->cardtype = pos->cardState.tag_type;
+ MEMCPY(card->cardphyid, pos->cardState.snr, 4);
+ ret = sp_card_read(card);
+ if(ret)
+ {
+ ret = RC_CARD_INVALID;
+ return ret;
+ }
+ ret = sp_card_authentication(pos, card);
+ if(ret)
+ {
+ ret = RC_CARD_AUTHENTICATION;
+ return ret;
+ }
+ if(pos->load_para_status)
+ {
+ return pos->load_para_status;
+ }
+ ret = sp_dev_config_check(pos);
+ if(ret)
+ {
+ return ret;
+ }
+ ret = sp_dev_offline_check(pos);
+ if(ret)
+ {
+ return ret;
+ }
+
+ ret = sp_card_valid_check(card);
+ if(ret)
+ {
+ return ret;
+ }
+ ret = sp_prepare_behalf_transdtl(pos, card, &record);
+ if(ret)
+ {
+ return ret;
+ }
+ pos->sysconf.work_mode = 1;
+ pos->paymode = PAYMODE_CARD;
+ return 0;
+}
+
+static uint16 do_start(sp_pos_t* pos)
+{
+ MEMCLEAR(&pos->purchase,sizeof(sp_purchase_t));
+ sp_flowsensor_count_clear();
+ sp_get_bcdtime(pos->purchase.starttime);
+ sp_valve_on();
+ show_money(pos, pos->purchase.paid_sum);
+ return 0;
+}
+
+static uint16 do_work_check(const sp_pos_t* pos)
+{
+ //ÅжÏÏû·Ñ½ð¶îÈç¹û´óÓÚ20»òÕßÁ¬ÐøÏû·Ñ³¬¹ý2Сʱ£¬ÔòÍ£Ö¹³öË®
+ if(pos->purchase.used_num >= 1000 || pos->purchase.paid_sum >= 1000)
+ {
+ return RC_CARD_TIMEOUT;
+ }
+ return 0;
+}
+
+static uint16 do_work(sp_pos_t* pos, sp_card_t* card)
+{
+ uint16 ret = 0;
+ sp_valve_on();
+ ret = do_work_check(pos);
+ if(ret)
+ {
+ return ret;
+ }
+ //¼ÆËãÏû·Ñ½ð¶î
+ ret = sp_calc_payamt_by_flowsensor(pos, card);
+ if(ret)
+ {
+ return ret;
+ }
+ if(pos->purchase.prepaid_amt > 0)
+ {
+ //ĬÈϼÇÕËģʽ
+ ret = sp_account_purchase(pos->purchase.prepaid_amt);
+ if(ret)
+ {
+ return ret;
+ }
+ }
+
+ if(pos->purchase.prepaid_num > 0)
+ {
+ pos->purchase.paid_num += pos->purchase.prepaid_num;
+ pos->purchase.paid_sum += pos->purchase.prepaid_amt;
+ pos->purchase.prepaid_num = 0;
+ pos->purchase.prepaid_amt = 0;
+ }
+ show_money(pos, pos->purchase.paid_sum);
+ return 0;
+}
+
+static uint16 do_stop(sp_pos_t* pos, sp_card_t* card)
+{
+ uint16 ret;
+ sp_transdtl_t record;
+ sp_valve_off();
+
+ if(pos->purchase.paid_num > 0)
+ {
+ MEMCLEAR(&record, sizeof(record));
+ ret = sp_prepare_below_transdtl(pos, card, &record);
+ if(ret)
+ {
+ return ret;
+ }
+ }
+ pos->paymode = PAYMODE_INIT;
+ pos->sysconf.work_mode = 0;
+ count = 0;
+ MEMCLEAR(&pos->purchase, sizeof(sp_purchase_t));
+ MEMCLEAR(card, sizeof(sp_card_t));
+ return 0;
+}
+
+static void do_pause(sp_pos_t* pos)
+{
+ char msg[17];
+ MEMCLEAR(msg, sizeof(msg));
+ sp_valve_off();
+ if(pos->purchase.paid_sum > 0)
+ {
+ sprintf(msg,"¹²¼Æ %0.2fÔª",pos->purchase.paid_sum/100.0f);
+ disp_hint_info_two(pos,"½áÊø¼Æ·Ñ",msg,DELAY_TIME2s);
+ }
+ else
+ {
+ disp_hint_info_two(pos,"½áÊø¼Æ·Ñ","Ãâ·ÑʹÓÃ",DELAY_TIME2s);
+ }
+}
+
+static void do_error(sp_pos_t* pos, uint16 errcode)
+{
+ if(errcode)
+ {
+ show_error(pos,"²Ù×÷ʧ°Ü:",errcode);
+ pos->paymode = PAYMODE_INIT;
+ pos->sysconf.work_mode = 0;
+ count = 0;
+ MEMCLEAR(&pos->purchase, sizeof(sp_purchase_t));
+ }
+}
+
+static uint16 sp_card_exist_handle(sp_pos_t* pos, sp_card_t* card,
+ sp_cardworkstate_t* cardWorkState)
+{
+ uint16 ret = 0;
+ uint16 err = 0;
+ sp_card_t cardpcd;
+ switch(cardWorkState->current_state)
+ {
+ case CARDWORKSTATUS_NONE:
+ if(timer_get_ticker() - pos->cardState.firsttick < 1500)
+ {
+ break;
+ }
+ ret = do_new(pos, card);
+ if(ret)
+ {
+ if(0x1018 == ret || 0x2001 == ret||
+ 0x1014 == ret || 0x1030 == ret)
+ {
+ if(0 == sp_card_request(&cardpcd))
+ {
+ break;
+ }
+ }
+ cardWorkState->errcode = ret;
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ break;
+ }
+ cardWorkState->current_state = CARDWORKSTATUS_READY;
+ break;
+ case CARDWORKSTATUS_READY:
+ if(MEMCMP(pos->cardState.snr, card->cardphyid, 4) != 0)
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ break;
+ }
+ ret = do_start(pos);
+ if(ret)
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ break;
+ }
+ cardWorkState->current_state = CARDWORKSTATUS_WORKING;
+ break;
+ case CARDWORKSTATUS_PAUSE:
+ cardWorkState->current_state = CARDWORKSTATUS_WORKING;
+ break;
+ case CARDWORKSTATUS_WORKING:
+ if(MEMCMP(pos->cardState.snr, card->cardphyid, 4) != 0)
+ {
+ ret = RC_NOT_SAME_CARD;
+ cardWorkState->current_state = CARDWORKSTATUS_STOPPING;
+ break;
+ }
+ cardWorkState->pause_status = 0;
+ ret = do_work(pos, card);
+ if(ret)
+ {
+ show_error(pos,"Ïû·Ñʧ°Ü",ret);
+ err = do_stop(pos, card);
+ if(err != 0)
+ {
+ ret = err;
+ }
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ break;
+ }
+ if(pos->purchase.paid_num > card->waterlimit)
+ {
+ disp_hint_info(pos,"ÒÑ´ïµ¥´Î³öË®ÉÏÏÞ",DELAY_TIME2s);
+ cardWorkState->current_state = CARDWORKSTATUS_STOPPING;
+ }
+ cardWorkState->pause_tick = timer_get_ticker();
+ break;
+ case CARDWORKSTATUS_STOPPING:
+ ret = do_stop(pos, card);
+ if(ret)
+ {
+ cardWorkState->errcode = ret;
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ break;
+ }
+ cardWorkState->current_state = CARDWORKSTATUS_STOPPED;
+ break;
+ case CARDWORKSTATUS_STOPPED:
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ break;
+ case CARDWORKSTATUS_FEECARD_WORKING:
+ if(MEMCMP(pos->cardState.snr, card->cardphyid, 4) != 0)
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ break;
+ }
+ //show_menu_options();
+ break;
+ case CARDWORKSTATUS_ERROR:
+ do_error(pos, cardWorkState->errcode);
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ break;
+ default:
+ Delay_ms(DELAY_TIME200ms);
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ break;
+ }
+ cardWorkState->errcode = ret;
+ return ret;
+}
+
+static uint16 sp_card_noexist_handle(sp_pos_t* pos, sp_card_t* card,
+ sp_cardworkstate_t* cardWorkState)
+{
+ //Óп¨µ½ÎÞ¿¨
+ uint16 ret = 0;
+ switch(cardWorkState->current_state)
+ {
+ case CARDWORKSTATUS_NONE:
+ do_idle(pos);
+ break;
+ case CARDWORKSTATUS_READY:
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ break;
+ case CARDWORKSTATUS_WORKING:
+ cardWorkState->current_state = CARDWORKSTATUS_PAUSE;
+ break;
+ case CARDWORKSTATUS_PAUSE:
+ if(MEMCMP(pos->cardState.snr, card->cardphyid, 4) == 0)
+ {
+ //¿¨ÄÃ×ßÒ»·ÖÖÓÖ®ÄÚĬÈÏÔÝͣʹÓÃ
+ if((timer_get_ticker() - cardWorkState->pause_tick) <= DELAY_TIME60s)
+ {
+ if(!cardWorkState->pause_status)
+ {
+ do_pause(pos);
+ show_home(pos);
+ }
+ show_home(pos);
+ cardWorkState->pause_status = 1;
+ }
+ else
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_STOPPING;
+ cardWorkState->pause_status = 0;
+ }
+ }
+ else
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_STOPPING;
+ cardWorkState->pause_status = 0;
+ }
+ cardWorkState->last_state = CARDWORKSTATUS_PAUSE;
+ break;
+ case CARDWORKSTATUS_STOPPING:
+ ret = do_stop(pos, card);
+ if(ret)
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ break;
+ }
+ cardWorkState->current_state = CARDWORKSTATUS_STOPPED;
+ cardWorkState->tick = timer_get_ticker();
+ break;
+ case CARDWORKSTATUS_STOPPED:
+ if(timer_get_ticker() - cardWorkState->tick > DELAY_TIME3s)
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ cardWorkState->last_state = cardWorkState->current_state;
+ cardWorkState->tick = 0;
+ }
+ break;
+ case CARDWORKSTATUS_SET_DEV:
+ if(sp_check_passwd(pos, "É豸¹ÜÀíÃÜÂë", "\x9\x1\x4\x3\x8\x7") == 0)
+ {
+ sp_menu_options(pos);
+ }
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ break;
+ case CARDWORKSTATUS_ERROR:
+ do_error(pos,cardWorkState->errcode);
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ break;
+ default:
+ Delay_ms(DELAY_TIME200ms);
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ break;
+ }
+ cardWorkState->errcode = ret;
+ return ret;
+}
+
+static sp_card_t CARD;
+void sp_card_handle(sp_pos_t* pos, sp_cardworkstate_t* cardWorkState)
+{
+ if(pos->cardState.cur_state)
+ {
+ sp_card_exist_handle(pos, &CARD, cardWorkState);
+ }
+ else
+ {
+ sp_card_noexist_handle(pos, &CARD, cardWorkState);
+ }
+}
+
+void sp_confirm_paymode(sp_pos_t* pos, sp_cardworkstate_t* cardWorkState)
+{
+ uint8 keycode = SP_KEY_NONE;
+ keycode = sp_get_key();
+ //ÔÚ¿¨Ïû·ÑÔÝÍ£Çé¿öϰ´ÈÎÒâ¼üΪ½áÊøµ±Ç°Ïû·Ñ״̬
+ if(keycode >= SP_KEY_0 && keycode <= SP_KEY_ENTER && pos->cardState.cur_state == STATE_NONE
+ && cardWorkState->current_state == CARDWORKSTATUS_PAUSE && pos->paymode == PAYMODE_CARD)
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_STOPPING;
+ return;
+ }
+ //Ïû·Ñģʽ³õʼ»¯×´Ì¬Ï°´È·ÈϼüÑ¡Ôñ¶þάÂëÏû·Ñ
+ if((keycode == SP_KEY_ENTER) && (pos->paymode == PAYMODE_INIT))
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ pos->paymode = PAYMODE_QRCODE;
+ return;
+ }
+ //¶þάÂëģʽϰ´È¡Ïû¼üΪֹͣ¹¤×÷
+ if((pos->paymode == PAYMODE_QRCODE) && (keycode == SP_KEY_CLEAR))
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_STOPPING;
+ return;
+ }
+ //°´0¼ü½øÈëÉ豸²Ù×÷½çÃæ
+ if(keycode == SP_KEY_0 && (pos->paymode == PAYMODE_INIT))
+ {
+ cardWorkState->current_state = CARDWORKSTATUS_SET_DEV;
+ return;
+ }
+}
+
+//¶þάÂëÏû·Ñ´¦Àí
+uint32 tick = 0;
+void sp_qrcode_handle(sp_pos_t* pos, sp_cardworkstate_t* cardWorkState)
+{
+ uint16 ret = 0;
+ sp_transdtl_t record;
+ MEMCLEAR(&record, sizeof(record));
+ switch(cardWorkState->current_state)
+ {
+ case CARDWORKSTATUS_NONE:
+ ret = sp_check_dev(pos);
+ if(ret)
+ {
+ cardWorkState->errcode = ret;
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ break;
+ }
+ ret = sp_qrcode_init(pos, &CARD);
+ if(ret)
+ {
+ cardWorkState->errcode = ret;
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ break;
+ }
+ ret = sp_prepare_behalf_transdtl(pos, &CARD, &record);
+ if(ret)
+ {
+ cardWorkState->errcode = RC_QRCODE_TIMEOUT;
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ break;
+ }
+ pos->sysconf.work_mode = 1;
+ CARD.qrcode.starttime = sp_get_ticker();
+ disp_hint_info(pos, "ÕýÔÚÉú³É¶þάÂë", DELAY_TIME2s);
+ cardWorkState->last_state = cardWorkState->current_state;
+ cardWorkState->current_state = CARDWORKSTATUS_READY;
+ break;
+ case CARDWORKSTATUS_READY:
+ CARD.qrcode.nowtime = sp_get_ticker();
+ if((CARD.qrcode.nowtime - CARD.qrcode.starttime) > CARD.qrcode.validtime)
+ {
+ show_home(pos);
+ show_home_qrcode(CARD.qrcode.qrcode_url);
+ if(CARD.qrcode.nowtime - tick > DELAY_TIME3s)
+ {
+ tick = CARD.qrcode.nowtime;
+ ret = sp_qrcode_query(pos, &CARD);
+ if(!ret && CARD.qrcode.authstatus)
+ {
+ do_start(pos);
+ cardWorkState->last_state = cardWorkState->current_state;
+ cardWorkState->current_state = CARDWORKSTATUS_WORKING;
+ }
+ }
+ }
+ else
+ {
+ cardWorkState->errcode = RC_QRCODE_TIMEOUT;
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ }
+ break;
+ case CARDWORKSTATUS_WORKING:
+ ret = do_work(pos, &CARD);
+ if(ret)
+ {
+ show_error(pos,"Ïû·Ñʧ°Ü",ret);
+ ret = do_stop(pos, &CARD);
+ if(ret)
+ {
+ cardWorkState->errcode = ret;
+ }
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ break;
+ }
+ cardWorkState->last_state = cardWorkState->current_state;
+ cardWorkState->pause_tick = sp_get_ticker();
+ break;
+ case CARDWORKSTATUS_STOPPING:
+ if(cardWorkState->last_state == CARDWORKSTATUS_NONE
+ || cardWorkState->last_state == CARDWORKSTATUS_READY)
+ {
+ disp_hint_info(pos,"È¡ÏûË¢Âë!", DELAY_TIME2s);
+ pos->paymode = PAYMODE_INIT;
+ pos->sysconf.work_mode = 0;
+ }
+ else
+ {
+ if(cardWorkState->last_state != CARDWORKSTATUS_PAUSE)
+ do_pause(pos);
+ ret = do_stop(pos, &CARD);
+ if(ret)
+ {
+ cardWorkState->errcode = ret;
+ cardWorkState->current_state = CARDWORKSTATUS_ERROR;
+ break;
+ }
+ }
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ cardWorkState->last_state = cardWorkState->current_state;
+ break;
+ case CARDWORKSTATUS_ERROR:
+ do_error(pos,cardWorkState->errcode);
+ cardWorkState->current_state = CARDWORKSTATUS_NONE;
+ cardWorkState->last_state = cardWorkState->current_state;
+ break;
+ default:
+ Delay_ms(DELAY_TIME200ms);
+ break;
+ }
+}
diff --git a/supwisdom/sp_consume.h b/supwisdom/sp_consume.h
new file mode 100644
index 0000000..e6ba62c
--- /dev/null
+++ b/supwisdom/sp_consume.h
@@ -0,0 +1,12 @@
+#ifndef CONSUME_H_
+#define CONSUME_H_
+
+#include "sp_config.h"
+
+void sp_card_handle(sp_pos_t* pos, sp_cardworkstate_t* cardWorkState);
+void sp_test_card_state(sp_pos_t* pos, sp_cardworkstate_t* cardWorkState, uint32 tick);
+void sp_qrcode_handle(sp_pos_t* pos, sp_cardworkstate_t* cardWorkState);
+void sp_confirm_paymode(sp_pos_t* pos, sp_cardworkstate_t* cardWorkState);
+
+#endif
+
diff --git a/supwisdom/sp_data.c b/supwisdom/sp_data.c
new file mode 100644
index 0000000..020b476
--- /dev/null
+++ b/supwisdom/sp_data.c
@@ -0,0 +1,366 @@
+#include "sp_data.h"
+#include "sp_util.h"
+#include "sp_flash.h"
+#include "sp_constant.h"
+#include "sp_display.h"
+
+#define record_behalf_len 25
+#define record_below_len 7
+
+//Ñ»·¼Ç¼ÿһ±ÊÁ÷Ë®¼Ç¼µÄµØÖ·
+static uint16 sp_write_last_record(sp_pos_t* pos)
+{
+ uint8 crc[2];
+ uint8 buff[sizeof(sp_last_transdtl_t)];
+ MEMCLEAR(buff, sizeof(buff));
+
+ pos->last_transdtl.this_offset += sizeof(sp_last_transdtl_t);
+ if(pos->last_transdtl.this_offset >= DEF_FLASH_PageSize)
+ {
+ sp_flash_erase(ADDR_LAST_TRANSNO);
+ pos->last_transdtl.this_offset = 0;
+ }
+ sp_protocol_crc((uint8*)&pos->last_transdtl, sizeof(buff)-2, pos->last_transdtl.crc);
+ sp_flash_write(pos->last_transdtl.this_offset+ADDR_LAST_TRANSNO,
+ (uint8*)&pos->last_transdtl, sizeof(buff));
+
+ sp_flash_read(pos->last_transdtl.this_offset+ADDR_LAST_TRANSNO, buff, sizeof(buff));
+ sp_protocol_crc(buff, sizeof(buff)-2, crc);
+ if(MEMCMP(pos->last_transdtl.crc,crc,2)!=0)
+ {
+ pos->load_para_status = RC_FLASH_ERR;
+ return RC_FLASH_ERR;
+ }
+ return 0;
+}
+
+static uint16 sp_write_behalf_record(sp_pos_t* pos, sp_transdtl_t* record)
+{
+ uint8 buf[record_behalf_len];
+ MEMCLEAR(buf, sizeof(buf));
+
+ pos->last_transdtl.transaddr += sizeof(sp_transdtl_t);
+ if(pos->last_transdtl.transaddr % DEF_FLASH_PageSize == 0)
+ {
+ if(pos->last_transdtl.transaddr >= ADDR_TRANSDTL_END)
+ {
+ pos->last_transdtl.transaddr = ADDR_TRANSDTL_BEGIN;
+ }
+ sp_flash_erase(pos->last_transdtl.transaddr);
+ }
+ sp_flash_write(pos->last_transdtl.transaddr, (uint8*)record, sizeof(buf));
+ return 0;
+}
+
+static uint16 sp_write_below_record(sp_pos_t* pos, sp_transdtl_t* record)
+{
+ uint8 crc[2];
+ uint8 buff[sizeof(sp_transdtl_t)];
+ MEMCLEAR(crc, sizeof(crc));
+ MEMCLEAR(buff, sizeof(buff));
+
+ sp_protocol_crc((uint8*)record, sizeof(buff)-2, record->crc);
+ sp_flash_write(pos->last_transdtl.transaddr+record_behalf_len,
+ (uint8*)record+record_behalf_len, record_below_len);
+ sp_flash_read(pos->last_transdtl.transaddr, buff, sizeof(buff));
+ sp_protocol_crc(buff, sizeof(buff)-2, crc);
+ if(MEMCMP(record->crc, crc, 2) != 0)
+ {
+ pos->load_para_status = RC_FLASH_ERR;
+ return RC_FLASH_ERR;
+ }
+ return 0;
+}
+
+//Ïû·Ñ³õʼ»¯ºó´æ´¢Éϰ벿·ÖÁ÷Ë®£¬·ÀÖ¹Ïû·Ñʧ°ÜÎÞÁ÷Ë®ÐÅÏ¢
+uint16 sp_prepare_behalf_transdtl(sp_pos_t* pos, sp_card_t* card, sp_transdtl_t* record)
+{
+ uint8 ret = 0;
+ uint8 ctime[6];
+ MEMCLEAR(ctime, sizeof(ctime));
+
+ sp_get_bcdtime(ctime);
+ memcpy(record->devphyid, pos->devphyid, sizeof(pos->devphyid));
+ memcpy(record->transdate, ctime, 3);
+ memcpy(record->transtime, ctime+3, 3);
+ memcpy(record->billno, card->billno, sizeof(card->billno));
+ memcpy(record->cardphyid, card->cardphyid, sizeof(card->cardphyid));
+ if(pos->paymode == PAYMODE_QRCODE)
+ {
+ record->transway = 2;
+ }
+ else
+ {
+ record->transway = 1;
+ }
+ ret = sp_write_behalf_record(pos, record);
+ if(ret)
+ return ret;
+ return sp_write_last_record(pos);
+}
+
+//ÈôÏû·Ñ³É¹¦£¬´æ´¢Ï°벿·ÖÁ÷Ë®ÐÅÏ¢
+uint16 sp_prepare_below_transdtl(sp_pos_t* pos, sp_card_t* card, sp_transdtl_t* record)
+{
+ uint8 buff[record_behalf_len];
+ MEMCLEAR(buff, sizeof(buff));
+
+ record->amount = pos->purchase.paid_sum;
+ if(pos->paymode == PAYMODE_QRCODE)
+ {
+ record->paidAmount = card->qrcode.paidAmount;
+ }
+ else
+ {
+ record->paidAmount = 0;
+ }
+ record->flowsensors = pos->purchase.paid_num;
+ record->transtatus = 1;
+ sp_flash_read(pos->last_transdtl.transaddr, buff, sizeof(buff));
+ MEMCPY(record, buff, sizeof(buff));
+ return sp_write_below_record(pos, record);
+}
+
+//Ñ»·´æ´¢Ã¿Ò»±ÊδÉÏ´«Á÷Ë®¼Ç¼µÄµØÖ·
+uint16 sp_write_unconfirm_record(sp_pos_t* pos)
+{
+ uint8 crc[2];
+ uint8 buff[sizeof(sp_unconfirm_transdtl_t)];
+ MEMCLEAR(buff, sizeof(buff));
+
+ pos->unconfirm_transdtl.this_offset += sizeof(buff);
+ if(pos->unconfirm_transdtl.this_offset >= DEF_FLASH_PageSize)
+ {
+ sp_flash_erase(ADDR_UNCONFIRM_TRANSNO);
+ pos->unconfirm_transdtl.this_offset = 0;
+ }
+ sp_protocol_crc((uint8*)&pos->unconfirm_transdtl, sizeof(buff)-2,
+ pos->unconfirm_transdtl.crc);
+ sp_flash_write(pos->unconfirm_transdtl.this_offset+ADDR_UNCONFIRM_TRANSNO,
+ (uint8*)&pos->unconfirm_transdtl, sizeof(buff));
+
+ sp_flash_read(pos->unconfirm_transdtl.this_offset+ADDR_UNCONFIRM_TRANSNO, buff,
+ sizeof(buff));
+ sp_protocol_crc(buff, sizeof(buff)-2, crc);
+ if(MEMCMP(pos->unconfirm_transdtl.crc, crc, 2) !=0)
+ {
+ pos->load_para_status = RC_FLASH_ERR;
+ return RC_FLASH_ERR;
+ }
+ return 0;
+}
+
+static uint16 sp_init_last_transdtl_ptr(sp_last_transdtl_t* record)
+{
+ record->transaddr = ADDR_TRANSDTL_BEGIN -sizeof(sp_transdtl_t);
+ record->this_offset = 0;
+ sp_protocol_crc((uint8*)record,sizeof(sp_last_transdtl_t) -2,record->crc);
+ return sp_flash_page_write(ADDR_LAST_TRANSNO,(uint8*)record,sizeof(sp_last_transdtl_t));
+}
+
+static uint16 sp_init_unconfirm_transdtl_ptr(sp_unconfirm_transdtl_t* record)
+{
+ record->transaddr = ADDR_TRANSDTL_BEGIN;
+ record->this_offset = 0;
+ sp_protocol_crc((uint8*)record,sizeof(sp_unconfirm_transdtl_t) -2,record->crc);
+ return sp_flash_page_write(ADDR_UNCONFIRM_TRANSNO,(uint8*)record,
+ sizeof(sp_unconfirm_transdtl_t));
+}
+
+static uint8 sp_load_last_transdtl_ptr(sp_pos_t* pos)
+{
+ uint8 crc[2];
+ sp_flash_page_read(ADDR_LAST_TRANSNO,(uint8*)&pos->last_transdtl,
+ sizeof(sp_last_transdtl_t));
+ sp_protocol_crc((uint8*)&pos->last_transdtl,sizeof(sp_last_transdtl_t) -2,crc);
+ if(MEMCMP(pos->last_transdtl.crc,crc,2) != 0)
+ {
+ sp_init_last_transdtl_ptr(&pos->last_transdtl);
+ }
+ return 0;
+}
+static uint8 sp_load_unconfirm_transdtl_ptr(sp_pos_t* pos)
+{
+ uint8 crc[2];
+ sp_flash_page_read(ADDR_UNCONFIRM_TRANSNO,(uint8*)&pos->unconfirm_transdtl,
+ sizeof(sp_unconfirm_transdtl_t));
+ sp_protocol_crc((uint8*)&pos->unconfirm_transdtl,sizeof(sp_unconfirm_transdtl_t) -2,crc);
+ if(MEMCMP(pos->unconfirm_transdtl.crc,crc,2) != 0)
+ {
+ sp_init_unconfirm_transdtl_ptr(&pos->unconfirm_transdtl);
+ }
+ return 0;
+}
+
+static uint16 sp_parse_config(sp_pos_t* pos, sp_config_t* config)
+{
+ pos->sysconf.dev_offline_maxhour = config->offline_work_hour;
+ if(pos->sysconf.dev_offline_maxhour == 0)
+ {
+ pos->sysconf.dev_offline_maxhour = DEV_OFFLINE_DEFAULT_HOUR;
+ }
+ pos->sysconf.flowsensor_unit = config->flowsensor_unit;
+ pos->deviceno = config->deviceno;
+ pos->devlogin.login_flag = config->login_flag;
+ MEMCPY(pos->devphyid,config->devphyid,4);
+ return 0;
+}
+static uint16 sp_read_config(sp_pos_t* pos, sp_config_t* config)
+{
+ uint8 crc[2];
+ sp_flash_read(ADDR_CONFIG_PARA,(uint8*)config,sizeof(sp_config_t));
+ sp_protocol_crc((uint8*)config,sizeof(sp_config_t) -2,crc);
+ if(memcmp(config->crc,crc,2) != 0)
+ {
+ return RC_CONFPARA_CRC_ERR;
+ }
+ sp_parse_config(pos, config);
+ return 0;
+}
+
+uint16 sp_clear_transdtl(sp_pos_t* pos)
+{
+ uint32 i;
+ uint16 ret = sp_flash_erase(ADDR_LAST_TRANSNO);
+ ret |= sp_flash_erase(ADDR_UNCONFIRM_TRANSNO);
+ for(i = ADDR_TRANSDTL_BEGIN; i < ADDR_TRANSDTL_END; i += DEF_FLASH_PageSize)
+ {
+ ret |= sp_flash_erase(i);
+ }
+ return ret;
+}
+
+static uint16 sp_init_device(sp_pos_t* pos)
+{
+ uint16 ret;
+ disp_hint_info_two(pos,"É豸³õʼ»¯","Çå¿ÕÁ÷Ë®",0);
+ ret |= sp_clear_transdtl(pos);
+ return ret;
+}
+
+void sp_reset_factory(sp_pos_t* pos)
+{
+ uint16 ret;
+ disp_hint_info_two(pos,"»Ö¸´³ö³§ÖÐ","ÇëÉÔµÈ...",0);
+ ret = sp_flash_erase(ADDR_CONFIG_PARA);
+ ret |=sp_clear_transdtl(pos);
+ if(!ret)
+ {
+ disp_hint_info_two(pos,"³õʼ»¯³É¹¦","µÈ´ýÖØÆô",0);
+ }
+ else
+ {
+ disp_hint_info_two(pos,"³õʼ»¯Ê§°Ü","µÈ´ýÖØÆô",0);
+ }
+ sp_reset();
+}
+
+uint16 sp_load_config(sp_pos_t* pos)
+{
+ uint16 ret;
+ sp_config_t config;
+ MEMCLEAR(&config,sizeof config);
+ ret |= sp_read_config(pos, &config);
+ if(ret)
+ {
+ sp_config_init(pos);
+ sp_init_device(pos);
+ }
+ ret |= sp_load_last_transdtl_ptr(pos);
+ ret |= sp_load_unconfirm_transdtl_ptr(pos);
+ return ret;
+}
+
+uint16 sp_save_config(sp_pos_t* pos, sp_config_t* config)
+{
+ uint8 buffer[sizeof(sp_config_t)];
+ uint8 crc[2];
+ sp_protocol_crc((uint8*)config,sizeof(sp_config_t)-2,config->crc);
+ sp_flash_erase(ADDR_CONFIG_PARA);
+ sp_flash_write(ADDR_CONFIG_PARA,(uint8*)config,sizeof(sp_config_t));
+ sp_flash_read(ADDR_CONFIG_PARA,buffer,sizeof buffer);
+ sp_protocol_crc(buffer,sizeof(buffer)-2,crc);
+ if(memcmp(config->crc,crc,2) != 0)
+ {
+ return RC_CONFPARA_CRC_ERR;
+ }
+ sp_parse_config(pos, config);
+ return 0;
+}
+
+uint16 sp_save_deviceno(sp_pos_t* pos, uint8 deviceno)
+{
+ uint16 ret;
+ sp_config_t config;
+ MEMCLEAR(&config, sizeof config);
+ ret = sp_read_config(pos, &config);
+ if(ret)
+ {
+ return ret;
+ }
+ config.deviceno = deviceno;
+ return sp_save_config(pos, &config);
+}
+uint16 sp_save_devphyid(sp_pos_t* pos, uint8 devphyid[4])
+{
+ uint16 ret;
+ sp_config_t config;
+ MEMCLEAR(&config, sizeof config);
+ ret = sp_read_config(pos, &config);
+ if(ret)
+ {
+ return ret;
+ }
+ MEMCPY(config.devphyid,devphyid,4);
+ return sp_save_config(pos, &config);
+}
+uint16 sp_save_login_info(sp_pos_t* pos, uint8 flag, uint8 unit, uint8 offline_maxhour)
+{
+ uint16 ret;
+ sp_config_t config;
+ MEMCLEAR(&config, sizeof config);
+ ret = sp_read_config(pos, &config);
+ if(ret)
+ {
+ return ret;
+ }
+ config.login_flag = flag;
+ config.flowsensor_unit = unit;
+ config.offline_work_hour = offline_maxhour;
+ return sp_save_config(pos, &config);
+}
+
+uint16 sp_save_heartbeat_info(sp_pos_t* pos, uint8 flag)
+{
+ uint16 ret;
+ sp_config_t config;
+ MEMCLEAR(&config, sizeof config);
+ ret = sp_read_config(pos, &config);
+ if(ret)
+ {
+ return ret;
+ }
+ config.login_flag = flag;
+ return sp_save_config(pos, &config);
+
+}
+
+uint16 sp_config_init(sp_pos_t* pos)
+{
+ uint16 ret = 0;
+ uint8 crc[2];
+ sp_config_t config;
+ MEMCLEAR(&config, sizeof(config));
+ disp_hint_info(pos,"É豸²ÎÊý³õʼ»¯", DELAY_TIME2s);
+ sp_protocol_crc((uint8*)&config,sizeof(sp_config_t)-2,config.crc);
+ sp_flash_erase(ADDR_CONFIG_PARA);
+ sp_flash_write(ADDR_CONFIG_PARA,(uint8*)&config,sizeof(sp_config_t));
+ sp_flash_read(ADDR_CONFIG_PARA,(uint8*)&config,sizeof(config));
+ sp_protocol_crc((uint8*)&config,sizeof(sp_config_t)-2,crc);
+ if(memcmp(config.crc,crc,2) != 0)
+ {
+ return RC_CONFPARA_CRC_ERR;
+ }
+ ret = sp_flash_erase(ADDR_CONFIG_PARA);
+ return ret;
+}
diff --git a/supwisdom/sp_data.h b/supwisdom/sp_data.h
new file mode 100644
index 0000000..1ed4942
--- /dev/null
+++ b/supwisdom/sp_data.h
@@ -0,0 +1,30 @@
+#ifndef _SP_DATA_H_
+#define _SP_DATA_H_
+
+#include "sp_config.h"
+#include "sp_communicate.h"
+
+//Á÷Ë®´¦Àí
+uint16 sp_prepare_behalf_transdtl(sp_pos_t* pos, sp_card_t* card, sp_transdtl_t* record);
+uint16 sp_prepare_below_transdtl(sp_pos_t* pos, sp_card_t* card, sp_transdtl_t* record);
+uint16 sp_read_lastrecord(const sp_pos_t* pos, sp_transdtl_t* dtl);
+uint16 sp_confirm_record(const sp_pos_t* pos, sp_transdtl_t* dtl);
+uint16 sp_query_record(const sp_pos_t* pos, uint8 refno[16], sp_transdtl_t* dtl);
+uint16 sp_clear_transdtl(sp_pos_t* pos);
+uint16 sp_write_unconfirm_record(sp_pos_t* pos);
+
+//ϵͳ²ÎÊýÉèÖÃ
+void sp_reset_factory(sp_pos_t* pos);
+uint16 sp_load_config(sp_pos_t* pos);
+uint16 sp_save_config(sp_pos_t* pos, sp_config_t* config);
+uint16 sp_save_deviceno(sp_pos_t* pos, uint8 deviceno);
+uint16 sp_save_devphyid(sp_pos_t* pos, uint8 devphyid[4]);
+uint16 sp_config_init(sp_pos_t* pos);
+uint16 sp_save_login_info(sp_pos_t* pos, uint8 flag, uint8 unit, uint8 offline_maxhour);
+uint16 sp_save_heartbeat_info(sp_pos_t* pos, uint8 flag);
+
+//É豸ÊÖ¶¯²Ù×÷½Ó¿Ú
+uint8 sp_confirm_login(sp_protocol_response_t* resp, sp_pos_t* pos);
+
+#endif
+
diff --git a/supwisdom/sp_des.c b/supwisdom/sp_des.c
new file mode 100644
index 0000000..5d19916
--- /dev/null
+++ b/supwisdom/sp_des.c
@@ -0,0 +1,39 @@
+#include "string.h"
+#include "../icc_apdu_lib/des.h"
+
+#include "sp_des.h"
+
+static des_context desctx;
+static des3_context des3ctx;
+
+uint8 single_des_set_keys(uint8 key[8])
+{
+ return des_set_key(&desctx, key);
+}
+
+void single_des_encrypt(uint8 src[8], uint8 dest[8])
+{
+ des_encrypt(&desctx, src, dest);
+}
+
+void single_des_decrypt(uint8 src[8], uint8 dest[8])
+{
+ des_decrypt(&desctx, src, dest);
+}
+
+uint8 triple_des_set_keys(uint8 key[16])
+{
+ return des3_set_2keys(&des3ctx, key, key+8);
+}
+
+void triple_des_encrypt(uint8 src[8], uint8 dest[8])
+{
+ des3_encrypt(&des3ctx, src, dest);
+}
+
+void triple_des_decrypt(uint8 src[8], uint8 dest[8])
+{
+ des3_decrypt(&des3ctx, src, dest);
+}
+
+
diff --git a/supwisdom/sp_des.h b/supwisdom/sp_des.h
new file mode 100644
index 0000000..bc8a7c7
--- /dev/null
+++ b/supwisdom/sp_des.h
@@ -0,0 +1,27 @@
+#ifndef _SP_DES_H_
+#define _SP_DES_H_
+
+#include "../config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+uint8 single_des_set_keys(uint8 key[8]);
+
+void single_des_encrypt(uint8 src[8], uint8 dest[8]);
+
+void single_des_decrypt(uint8 src[8], uint8 dest[8]);
+
+uint8 triple_des_set_keys(uint8 key[16]);
+
+void triple_des_encrypt(uint8 src[8], uint8 dest[8]);
+
+void triple_des_decrypt(uint8 src[8], uint8 dest[8]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/supwisdom/sp_display.c b/supwisdom/sp_display.c
new file mode 100644
index 0000000..fb0417c
--- /dev/null
+++ b/supwisdom/sp_display.c
@@ -0,0 +1,356 @@
+#include "glcd.h"
+#include "../zk/gb2312_16.h"
+#include "../libqr/qrencode.h"
+#include "sp_util.h"
+#include "sp_constant.h"
+#include "sp_display.h"
+
+#define GLCD_TITLE_X 0
+#define GLCD_TITLE_Y 0
+#define GLCD_TITLE_LINE 8
+#define GLCD_CONTENT_Y_ONE 0x10
+#define GLCD_CONTENT_Y_TWO 0x20
+#define GLCD_CONTENT_Y_THREE 0x30
+#define GLCD_BUTTOM_Y 56
+#define GLCD_LINE_LENGTH 0x10
+
+static char line_buff[17];
+
+/********************************************************************************************************
+* º¯Êý(Name) : void Show_Money(uint32 money)
+* ¹¦ÄÜ(Function) : ÏÔʾ½ð¶î
+* ²ÎÊý(Parameter) : money--¿¨Óà¶î(µ¥Î»:Ôª)
+* ·µ»Ø(Return) : ÎÞ
+**********************************************************************************************************/
+void show_money(sp_pos_t* pos, uint32 money)
+{
+ char msg[32];
+ sprintf(msg," %.02f Ԫ",money/100.0f);
+ disp_hint_info_two(pos,"ÀÛ¼ÆË®·Ñ:",msg,0);
+}
+
+void glcd_tiny_init(void)
+{
+ uint8 retry;
+ glcd_tiny_set_font(Font5x7,5,7,32,127);
+ glcd_clear_buffer();
+ glcd_write();
+ for(retry=0; retry<3; retry++)
+ {
+ if(gb2312_16_verify() == 0)
+ {
+ break;
+ }
+ }
+ glcd_write();
+}
+static void show_title(void)
+{
+ uint8 ctime[7];
+ glcd_tiny_set_font(Font5x7,5,7,32,127);
+ glcd_clear_buffer();
+ sp_get_bcdtime(ctime);
+ sprintf(line_buff, "%02x-%02x-%02x %02x:%02x:%02x",
+ ctime[0],ctime[1],ctime[2],
+ ctime[3],ctime[4],ctime[5]);
+ glcd_draw_string_xy(0, 0, line_buff);
+ glcd_draw_line(0, GLCD_TITLE_LINE, 127, 8, BLACK);
+}
+
+static void show_bottom(sp_pos_t* pos)
+{
+ sprintf(line_buff,"%02d:%02x%02x%02x%02x",pos->deviceno, pos->devphyid[0],
+ pos->devphyid[1], pos->devphyid[2], pos->devphyid[3]);
+ glcd_draw_string_xy(0, GLCD_BUTTOM_Y, line_buff);
+}
+
+static char last_qrcode_url[32]= {0};
+void show_home_qrcode(char* qrcode_url)
+{
+ uint8 i,j;
+ if(MEMCMP(qrcode_url,last_qrcode_url,(int)strlen(qrcode_url)) != 0)
+ {
+ sprintf(last_qrcode_url,"%s",qrcode_url);
+ //¶þάÂëÉú³ÉµãÕó
+ QRencode(last_qrcode_url, NULL);
+ }
+ //¶þάÂëµãÕóÏÔʾ
+ for(i=0; i<MAX_MODULESIZE*2; i++)
+ {
+ for(j=0; j<MAX_MODULESIZE*2; j++)
+ {
+ uint8_t pixel = m_byModuleData[i/2][j/2];
+
+ glcd_set_pixel(j+70, 12+i, pixel);
+ glcd_set_pixel(j+70, 12+i+1, pixel);
+ j ++;
+ glcd_set_pixel(j+70, 12+i, pixel);
+ glcd_set_pixel(j+70, 12+i+1, pixel);
+ }
+ i ++;
+ }
+ glcd_write();
+
+}
+static uint8 last_ctime[6];
+void show_home(sp_pos_t* pos)
+{
+ uint8 ctime[6];
+ sp_get_bcdtime(ctime);
+ if(MEMCMP(ctime,last_ctime,6) != 0)
+ {
+ MEMCPY(last_ctime,ctime,6);
+ disp_hint_info_two(pos,"F°æ±¾",PRO_VERSION,0);
+ /*
+ if(pos->sysconf.register_flag)
+ {
+ if(pos->dynamic.ws_client_stat)
+ {
+ show_home_qrcode(pos->dynamic.qrcode_url);
+ }
+ }
+ */
+ }
+}
+
+void show_set_devno(sp_pos_t* pos, uint8 devno)
+{
+ char msg[32];
+ sprintf(msg,"»úºÅ=%d",devno);
+ disp_hint_info_two(pos, "ÉèÖûúºÅ³É¹¦",msg,DELAY_TIME1s);
+}
+void show_set_devphyid(sp_pos_t* pos, uint8 devphyid[4])
+{
+ char msg[32];
+ sprintf(msg,"ID=%02x%02x%02x%02x",
+ devphyid[0],devphyid[1],devphyid[2],devphyid[3]);
+ disp_hint_info_two(pos,"ÉèÖÃÎïÀíID³É¹¦",msg,DELAY_TIME1s);
+}
+void show_set_dev_offline_maxhour(sp_pos_t* pos, uint16 maxhour)
+{
+ char msg[32];
+ sprintf(msg,"ÍÑ»ú¹¤×÷ʱ¼ä=%d",maxhour);
+ disp_hint_info_two(pos, "ÉèÖÃÍÑ»ú¹¤×÷ʱ¼ä³É¹¦",msg,DELAY_TIME1s);
+}
+
+void show_manage_passwd(sp_pos_t* pos, const char* hint,uint8 passwd[],uint8 len)
+{
+ char msg[32];
+ switch(len)
+ {
+ case 0:
+ sprintf(msg,"");
+ break;
+ case 1:
+ sprintf(msg,"%d",passwd[0]);
+ break;
+ case 2:
+ sprintf(msg,"%d%d",passwd[0],passwd[1]);
+ break;
+ case 3:
+ sprintf(msg,"%d%d%d",passwd[0],passwd[1],passwd[2]);
+ break;
+ case 4:
+ sprintf(msg,"%d%d%d%d",passwd[0],passwd[1],passwd[2],passwd[3]);
+ break;
+ case 5:
+ sprintf(msg,"%d%d%d%d%d",passwd[0],passwd[1],passwd[2],passwd[3],passwd[4]);
+ break;
+ case 6:
+ sprintf(msg,"%d%d%d%d%d%d",passwd[0],passwd[1],passwd[2],passwd[3],passwd[4],passwd[5]);
+ break;
+ default:
+ sprintf(msg,"");
+ }
+ disp_hint_info_two(pos,hint,msg,0);
+}
+
+void show_error(sp_pos_t* pos, const char* hint, uint16 errcode)
+{
+ char msg[32];
+ switch(errcode)
+ {
+ case RC_PSAM_ERR:
+ sprintf(msg,"%s", "SAM¸´Î»Ê§°Ü");
+ break;
+ case RC_CARD_LOGIN:
+ sprintf(msg,"%s", "ÑéÖ¤ÃØÔ¿Ê§°Ü");
+ break;
+ case RC_CARD_READ:
+ sprintf(msg,"%s", "¶Á¿¨Ê§°Ü");
+ break;
+ case RC_CARD_WRITE:
+ sprintf(msg,"%s", "д¿¨Ê§°Ü");
+ break;
+ case RC_FLASH_ERR:
+ sprintf(msg,"%s", "FLASHÒì³£");
+ break;
+ case RC_HARDWARE_ERR:
+ sprintf(msg,"%s", "¹Ì¼þÒì³£");
+ break;
+ case RC_FLASH_NO_RIGHT:
+ sprintf(msg,"%s", "FLASHÏÞÖÆ");
+ break;
+ case RC_CARD_NORIGHT:
+ sprintf(msg,"%s", "¿¨ÎÞȨÏÞ");
+ break;
+ case RC_CARD_EXPIRED:
+ sprintf(msg,"%s", "¿¨ÒѹýÆÚ");
+ break;
+ case RC_CARD_LOST:
+ sprintf(msg,"%s", "¿¨ÒÑËø¶¨");
+ break;
+ case RC_CARDNO_EXCEPT:
+ sprintf(msg,"%s", "¿¨Òì³£");
+ break;
+ case RC_CARD_TIMEOUT:
+ sprintf(msg,"%s", "ʹÓÃÌ«¾Ã");
+ break;
+ case RC_CARDBAL_EXCEPT:
+ sprintf(msg,"%s", "Óà¶îÒì³£");
+ break;
+ case RC_CARDBAL_LACK:
+ sprintf(msg,"%s", "ÇëÁª»úÏû·Ñ");
+ break;
+ case RC_DEVPHYID_NOTSET:
+ sprintf(msg,"%s", "δÉèÖûúºÅ");
+ break;
+ case RC_FEERATE_NOTSET:
+ sprintf(msg,"%s", "δÉèÖ÷ÑÂÊ");
+ break;
+ case RC_DEV_OFFLINE_ERROR:
+ sprintf(msg,"%s", "É豸ÍÑ»úÌ«¾Ã");
+ break;
+ case RC_TRANSDTL_FULL:
+ sprintf(msg,"%s", "Á÷Ë®ÒÑÂú");
+ break;
+ case RC_FILE09_CRC_ERR:
+ sprintf(msg,"%s", "09CRC´íÎó");
+ break;
+ case RC_FILE10_CRC_ERR:
+ sprintf(msg,"%s", "10CRC´íÎó");
+ break;
+ case RC_CARD_INVALID:
+ sprintf(msg,"%s", "ÎÞЧ¿¨");
+ break;
+ case RC_FEENUM_ERROR:
+ sprintf(msg,"%s", "·ÑÂʸöÊý´íÎó");
+ break;
+ case RC_NOTSUPPORT:
+ sprintf(msg,"%s", "²»Ö§³Ö");
+ break;
+ case RC_NOT_SAME_CARD:
+ sprintf(msg,"%s", "²»Í¬¿¨");
+ break;
+ case RC_MODE_NOT_SUPPORT:
+ sprintf(msg,"%s", "ģʽ²»Ö§³Ö");
+ break;
+ case RC_UPDPROG_ERR:
+ sprintf(msg,"%s", "Éý¼¶Ê§°Ü");
+ break;
+ case RC_CONFPARA_CRC_ERR:
+ sprintf(msg,"%s", "ÅäÖÃCRC´íÎó");
+ break;
+ case RC_TRANSDTL_NO_ERR:
+ sprintf(msg,"%s", "Á÷Ë®ºÅÒì³£");
+ break;
+ case RC_DEVICENO_OUT:
+ sprintf(msg,"%s", "»úºÅ¹ý´ó");
+ break;
+ case RC_QRCODE_FAILURE:
+ sprintf(msg,"%s", "¶þάÂë»ñȡʧ°Ü");
+ break;
+ case RC_QRCODE_TIMEOUT:
+ sprintf(msg,"%s", "¶þάÂ볬ʱ");
+ break;
+ case RC_QRCODE_QUERY_FAIL:
+ sprintf(msg,"%s", "¶þάÂëÈÏ֤ʧ°Ü");
+ break;
+ case RC_DEV_NOT_LOGIN:
+ sprintf(msg,"%s", "É豸δǩµ½");
+ break;
+ case RC_DEV_FAULT:
+ sprintf(msg,"%s", "É豸ÒÉËÆ¹ÊÕÏ");
+ break;
+ case RC_DEV_NOSET_FLOWSENSOR_UNIT:
+ sprintf(msg,"%s", "Á÷Á¿¼ÆË㵥λδÉèÖÃ");
+ break;
+ case RC_CARD_AUTHENTICATION:
+ sprintf(msg,"%s", "¿¨ÈÏ֤ʧ°Ü");
+ break;
+ default:
+ sprintf(msg,"´íÎóÂë=0x%04x",errcode);
+ }
+ disp_hint_info_two(pos,hint,msg,DELAY_TIME3s);
+}
+
+void disp_hint_info_three(sp_pos_t* pos,const char* msg1,const char* msg2,const char* msg3,uint32 ms)
+{
+ show_title();
+ show_bottom(pos);
+
+ snprintf(line_buff,sizeof line_buff,"%s ",msg1);
+ gb2312_16_draw_str(0, GLCD_CONTENT_Y_ONE, line_buff);
+ snprintf(line_buff,sizeof line_buff,"%s ",msg2);
+ gb2312_16_draw_str(0, GLCD_CONTENT_Y_TWO, line_buff);
+ snprintf(line_buff,sizeof line_buff,"%s ",msg3);
+ gb2312_16_draw_str(0, GLCD_CONTENT_Y_THREE, line_buff);
+
+ glcd_write();
+ if(ms > 0)
+ {
+ Delay_ms(ms);
+ }
+}
+
+void disp_hint_info_two(sp_pos_t* pos,const char* msg1,const char* msg2,uint32 ms)
+{
+ show_title();
+ show_bottom(pos);
+
+ snprintf(line_buff,sizeof line_buff,"%s ",msg1);
+ gb2312_16_draw_str(0, GLCD_CONTENT_Y_ONE, line_buff);
+ snprintf(line_buff,sizeof line_buff,"%s ",msg2);
+ gb2312_16_draw_str(0, GLCD_CONTENT_Y_TWO, line_buff);
+
+ glcd_write();
+ if(ms > 0)
+ {
+ Delay_ms(ms);
+ }
+}
+void disp_hint_info(sp_pos_t* pos,const char* msg1,uint32 ms)
+{
+ show_title();
+ show_bottom(pos);
+
+ snprintf(line_buff,sizeof line_buff,"%s ",msg1);
+ gb2312_16_draw_str(0, GLCD_CONTENT_Y_ONE, line_buff);
+ snprintf(line_buff,sizeof line_buff," ");
+ gb2312_16_draw_str(0, GLCD_CONTENT_Y_TWO, line_buff);
+
+ glcd_write();
+ if(ms > 0)
+ {
+ Delay_ms(ms);
+ }
+}
+void disp_server_errmsg(sp_pos_t* pos,const char* hint,uint8 data[],uint16 len)
+{
+ uint8 strlen;
+ char errmsg[64];
+ strlen = data[0];
+ //command+canid+excmd+flag+retcode+len+crc
+ if((strlen +8) != len)
+ {
+ disp_hint_info_two(pos,hint,"ÇëÇó³¬Ê±",DELAY_TIME3s);
+ return;
+ }
+ if(strlen > 32)
+ {
+ strlen = 32;
+ }
+ snprintf(errmsg,strlen+1,"%s",data +1);
+ disp_hint_info_two(pos,hint,errmsg,DELAY_TIME3s);
+}
+
diff --git a/supwisdom/sp_display.h b/supwisdom/sp_display.h
new file mode 100644
index 0000000..3160248
--- /dev/null
+++ b/supwisdom/sp_display.h
@@ -0,0 +1,36 @@
+#ifndef _SP_DISPLAY_H_
+#define _SP_DISPLAY_H_
+
+#include "sp_config.h"
+
+/*******************************************************************************************************
+* º¯Êý(Name) : void Show_Error(uint32 errcode)
+* ¹¦ÄÜ(Function) : ÏÔʾ´íÎó´úÂë
+* ²ÎÊý(Parameter) : errcode -- ´íÎó´úºÅ
+* ·µ»Ø(Return) : ÎÞ
+********************************************************************************************************/
+void glcd_tiny_init(void);
+
+/*******************************************************************************************************
+* º¯Êý(Name) : void Show_Pass(void)
+* ¹¦ÄÜ(Function) : ÏÔʾPASS
+* ²ÎÊý(Parameter) : NULL
+* ·µ»Ø(Return) : ÎÞ
+********************************************************************************************************/
+ void show_set_devno(sp_pos_t* pos, uint8 devno);
+ void show_set_devphyid(sp_pos_t* pos, uint8 devphyid[4]);
+ void show_set_dev_offline_maxhour(sp_pos_t* pos, uint16 maxhour);
+ void show_error(sp_pos_t* pos, const char* hint,uint16 code);
+ void show_home(sp_pos_t* pos);
+ void show_money(sp_pos_t* pos, uint32 money);
+ void show_manage_passwd(sp_pos_t* pos, const char* hint,uint8 passwd[],uint8 len);
+ void show_home_qrcode(char* qrcode_url);
+
+ void disp_hint_info(sp_pos_t* pos, const char* msg1,uint32 ms);
+ void disp_hint_info_two(sp_pos_t* pos, const char* msg1,const char* msg2,uint32 ms);
+ void disp_hint_info_three(sp_pos_t* pos, const char* msg1,const char* msg2,
+ const char* msg3,uint32 ms);
+ void disp_server_errmsg(sp_pos_t* pos, const char* hint,uint8 data[],uint16 len);
+
+
+#endif
diff --git a/supwisdom/sp_flash.c b/supwisdom/sp_flash.c
new file mode 100644
index 0000000..0788aed
--- /dev/null
+++ b/supwisdom/sp_flash.c
@@ -0,0 +1,123 @@
+#include "sp_constant.h"
+#include "sp_util.h"
+
+#include "sp_flash.h"
+
+uint16 sp_flash_read(uint32 addr,uint8 buf[],uint32 len)
+{
+ return HW_Flash_Read(addr,len,buf);
+}
+uint16 sp_flash_write(uint32 addr,uint8 buf[],uint32 len)
+{
+ if(addr < DEF_IAP_BASE_ADDR)
+ {
+ return RC_FLASH_NO_RIGHT;
+ }
+ return HW_Flash_NotEraseWrite(addr,len,buf);
+}
+uint16 sp_flash_erase(uint32 addr)
+{
+ if(addr < DEF_IAP_BASE_ADDR)
+ {
+ return RC_FLASH_NO_RIGHT;
+ }
+ return HW_Flash_PageErase(addr / FLASH_PAGE_SIZE);
+}
+
+/**
+**¶ÁȡһҳÊý¾Ý,È«FF±íʾÎÞÊý¾Ý
+**@param len > 128 error
+**@return ·µ»Ø0±íʾ²éÕÒÊý¾Ý³É¹¦
+**@return ·µ»Ø·Ç0±íʾÎÞÓÐЧÊý¾Ý
+**/
+uint16 sp_flash_page_read(uint32 addr,uint8 buf[],uint32 len)
+{
+ uint32 i;
+ uint32 offset = 0;
+ uint8 temp[128];
+
+ if(len > sizeof(temp))
+ {
+ return 1;
+ }
+
+ while(1)
+ {
+ i = 0;
+ sp_flash_read(addr +offset,temp, len);
+ while(i < len)
+ {
+ if(0xFF == temp[i])
+ {
+ ++i;
+ }
+ else
+ {
+ break;
+ }
+ }
+ if(len == i)
+ {
+ if(0 == offset)
+ {
+ //ÎÞÊý¾Ý
+ return 1;
+ }
+ else
+ {
+ sp_flash_read(addr +offset -len,buf, len);
+ return 0;
+ }
+ }
+ offset += len;
+ if(DEF_FLASH_PageSize < (offset +len)) // ³¬¹ýµ±Ò³Î´ÕÒµ½·µ»Ø1
+ {
+ return 1;
+ }
+ }
+}
+/**
+**дһҳÊý¾Ý
+**@param len > 32 error
+**@return ·µ»Ø0±íʾ¼Ç¼Êý¾Ý³É¹¦
+**@return ·µ»Ø·Ç0±íʾдFLASHʧ°Ü
+**/
+uint16 sp_flash_page_write(uint32 addr,uint8 buf[],uint32 len)
+{
+ uint32 i;
+ uint32 offset = 0;
+ uint8 temp[64];
+
+ if(len > 64)
+ {
+ return 1;
+ }
+ while(1)
+ {
+ i = 0;
+ sp_flash_read(addr +offset,temp, len);
+ while(i < len)
+ {
+ if(0xFF == temp[i])
+ {
+ ++i;
+ }
+ else
+ {
+ break;
+ }
+ }
+ if(DEF_FLASH_PageSize < (offset +len)) // ³¬¹ýµ±Ò³±íʾÒÑдÂú,²Á³ýÖØÐ´
+ {
+ sp_flash_erase(addr);
+ return sp_flash_write(addr,buf, len);
+ }
+ if(len == i)
+ {
+ //ÎÞÊý¾Ý
+ return sp_flash_write(addr +offset,buf, len);
+ }
+ offset += len;
+ }
+}
+
diff --git a/supwisdom/sp_flash.h b/supwisdom/sp_flash.h
new file mode 100644
index 0000000..f01517d
--- /dev/null
+++ b/supwisdom/sp_flash.h
@@ -0,0 +1,63 @@
+#ifndef _SP_FLASH_H_
+#define _SP_FLASH_H_
+
+#include "../sys_hw/Prj_FlashCfg.H"
+#include "sp_config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////EEPROM ¿Õ¼ä/////////////////////////////
+///////////////////FLASH ¿Õ¼ä////////////////////////////////////////////////////
+
+#if 0
+#define ADDR_FLASH_BEGIN 0x17000 // base addr
+#define ADDR_CONFIG_PARA 0x17000 //ÅäÖòÎÊý
+
+#define ADDR_TRANSDTL_PTR 0x18000 //Á÷ˮָÕë
+#define ADDR_TRANSDTL_BEGIN 0x200000 //Á÷Ë®Æðʼ
+#define ADDR_TRANSDTL_END 0x350000 //Á÷Ë®½áÊø
+#define ADDR_MAX 0x400000
+#endif
+//###############################################################
+/*********Ô¶³ÌÉý¼¶Îļþ´æ´¢100Ò³*********************/
+/*********×¢ÒâÉý¼¶µØÖ·ÓëBOOTÉý¼¶µØÖ·±£³ÖÒ»ÖÂ**/
+#define DEF_IAP_BASE_ADDR (DEF_FLASH_IAP_AppCodeStartAdd)
+#define DEF_IapMarkAddr ( DEF_IAP_BASE_ADDR + 1 * DEF_FLASH_PageSize ) //IAPÉý¼¶±ê¼ÇµØÖ·
+#define DEF_EraMarkAddr ( DEF_IAP_BASE_ADDR + 2 * DEF_FLASH_PageSize ) //²Á³ýFLASH±ê¼Ç
+#define DEF_IapDataAddr ( DEF_IAP_BASE_ADDR + 3 * DEF_FLASH_PageSize ) //IAPÊý¾ÝÇøÆðʼµØÖ·
+
+#define DEF_FLASH_codeStartAdd (DEF_IapDataAddr)
+
+#define ADDR_UPGRADE_UPINFO (ADDR_FLASH_END + DEF_FLASH_PageSize *1)
+#define ADDR_KEY_PARA (ADDR_UPGRADE_UPINFO + DEF_FLASH_PageSize *1)
+
+#define ADDR_UPGRADE_BEGIN (DEF_FLASH_codeStartAdd)
+#define ADDR_UPGRADE_END (DEF_FLASH_IAP_AppCodeEndAdd -DEF_FLASH_PageSize)
+
+#define ADDR_APPLICATION_BASE 0x130000 //base addr
+#define ADDR_APP_VERSION (ADDR_APPLICATION_BASE) //°æ±¾±êʶ
+
+#define ADDR_CONFIG_PARA (ADDR_APP_VERSION +DEF_FLASH_PageSize *1)//ÅäÖòÎÊý
+
+#define ADDR_LAST_TRANSNO (ADDR_CONFIG_PARA +DEF_FLASH_PageSize *10)
+#define ADDR_UNCONFIRM_TRANSNO (ADDR_LAST_TRANSNO +DEF_FLASH_PageSize *1)
+#define ADDR_TRANSDTL_BEGIN (ADDR_UNCONFIRM_TRANSNO +DEF_FLASH_PageSize *1)
+#define ADDR_TRANSDTL_END (ADDR_TRANSDTL_BEGIN +DEF_FLASH_PageSize *100)
+#define ADDR_FLASH_END (ADDR_TRANSDTL_END)
+#define ADDR_MAX 0x400000
+
+//#########################################
+
+uint16 sp_flash_read(uint32 addr,uint8 buf[],uint32 len);
+uint16 sp_flash_write(uint32 addr,uint8 buf[],uint32 len);
+uint16 sp_flash_erase(uint32 addr);
+uint16 sp_flash_page_read(uint32 addr,uint8 buf[],uint32 len);
+uint16 sp_flash_page_write(uint32 addr,uint8 buf[],uint32 len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/supwisdom/sp_menu.c b/supwisdom/sp_menu.c
new file mode 100644
index 0000000..4447d52
--- /dev/null
+++ b/supwisdom/sp_menu.c
@@ -0,0 +1,655 @@
+#include "sp_menu.h"
+#include "sp_util.h"
+#include "sp_data.h"
+#include "stdlib.h"
+#include "stdio.h"
+#include "sp_constant.h"
+#include "sp_communicate.h"
+#include "sp_display.h"
+#include "sp_upgrade.h"
+#include "../nec_hardware.h"
+
+typedef void(*menu_func_t)(sp_pos_t* pos);
+typedef struct
+{
+ char* hit;
+ menu_func_t func;
+} menu_t;
+
+static void sp_show_syspara(sp_pos_t* pos)
+{
+ uint32 ticker;
+ uint8 keycode;
+ uint8 key_press = 1;
+ uint8 max_cnt = 0;
+ uint8 offset = 0;
+ uint8 unconfirm_transnum;
+ char syspara[9][17];
+
+ MEMCLEAR(syspara, sizeof(syspara));
+ sprintf(syspara[offset++], "É豸״̬:");
+ if(pos->devlogin.login_flag == 1)
+ {
+ sprintf(syspara[offset++], "ÒÑÇ©µ½");
+ }
+ else if(pos->devlogin.login_flag == 0)
+ {
+ sprintf(syspara[offset++], "δǩµ½");
+ }
+ else if(pos->devlogin.login_flag == 2)
+ {
+ sprintf(syspara[offset++], "ÒÑ×¢Ïú");
+ }
+ sprintf(syspara[offset++], "Á´Â·×´Ì¬:");
+ if(pos->link_stat)
+ {
+ sprintf(syspara[offset++], "ÁªÍø");
+ }
+ else
+ {
+ sprintf(syspara[offset++], "ÖжÏ");
+ }
+ sprintf(syspara[offset++], "δÉÏ´«Á÷Ë®:");
+ if(pos->unconfirm_transdtl.transaddr <= pos->last_transdtl.transaddr)
+ {
+ if(pos->unconfirm_transdtl.transaddr == pos->last_transdtl.transaddr)
+ {
+ unconfirm_transnum = 1;
+ }
+ else
+ {
+ unconfirm_transnum = ((pos->last_transdtl.transaddr -
+ pos->unconfirm_transdtl.transaddr)/sizeof(sp_transdtl_t));
+ }
+ }
+ else
+ {
+ unconfirm_transnum = 0;
+ }
+ sprintf(syspara[offset++], "%d±Ê", unconfirm_transnum);
+ sprintf(syspara[offset++], "Ïû·ÑÀàÐÍ:");
+ sprintf(syspara[offset++], "¼ÇÕËÏû·Ñ");
+
+ max_cnt = sizeof(syspara)/sizeof(syspara[0])/2;
+ offset = 0;
+ ticker = sp_get_ticker();
+ while(sp_get_ticker()-ticker <= DELAY_TIME60s)
+ {
+ keycode = sp_get_key();
+ if(keycode != SP_KEY_NONE)
+ {
+ key_press = 1;
+ switch(keycode)
+ {
+ case SP_KEY_0:
+ if(offset < max_cnt-1)
+ {
+ offset++;
+ }
+ break;
+ case SP_KEY_1:
+ case SP_KEY_2:
+ case SP_KEY_3:
+ case SP_KEY_4:
+ case SP_KEY_5:
+ case SP_KEY_6:
+ case SP_KEY_7:
+ case SP_KEY_8:
+ case SP_KEY_9:
+ offset = keycode -SP_KEY_0;
+ if(offset >= max_cnt)
+ {
+ offset = max_cnt -1;
+ }
+ break;
+ case SP_KEY_CLEAR:
+ return;
+ }
+ }
+ if(key_press)
+ {
+ disp_hint_info_two(pos, syspara[2*offset],syspara[2*offset+1],0);
+ key_press = 0;
+ ticker = sp_get_ticker();
+ }
+ }
+}
+
+static uint8 sp_link_test(sp_pos_t* pos)
+{
+ uint8 ret;
+ sp_protocol_request_t req;
+ sp_protocol_response_t resp;
+ MEMCLEAR(&req, sizeof(req));
+ MEMCLEAR(&resp, sizeof(resp));
+
+ disp_hint_info_two(pos, "ÕýÔÚÁ´Â·¼ì²â", "ÇëÉÔµÈ.....", 0);
+ sp_protocol_req_init(&req, SP_CMD_FACTORY_LINK_TEST);
+ req.data[0] = 0;
+ req.data[1] = 0x55;
+ req.data[2] = 0xAA;
+ req.datalen += 3;
+ ret = sp_comm_call(pos, &req, &resp, DELAY_TIME3s);
+ if(!ret)
+ {
+ if(resp.data[0] == 0x55 && resp.data[1] == 0xAA)
+ {
+ if(sp_check_time_valid(resp.data +2))
+ {
+ disp_hint_info_two(pos, "Á´Â·¼ì²â³É¹¦","ʱÖÓ²»ºÏ·¨", DELAY_TIME3s);
+ return ret;
+ }
+ sp_set_bcdtime(resp.data +2);
+ disp_hint_info_two(pos, "Á´Â·¼ì²â³É¹¦","ÒÑͬ²½Ê±ÖÓ", DELAY_TIME3s);
+ return ret;
+ }
+ disp_hint_info_two(pos, "Á´Â·¼ì²âʧ°Ü","ÊÕµ½´íÎó°ü", DELAY_TIME3s);
+ return 1;
+ }
+ disp_hint_info_two(pos, "Á´Â·¼ì²âʧ°Ü","Çë¼ì²âÏß·", DELAY_TIME3s);
+ return ret;
+}
+
+static void show_keyboard_test(sp_pos_t* pos, uint8 offset)
+{
+ char msg[]= {"0123456789C"};
+ char temp[17];
+ snprintf(temp,offset+1,"%s",msg);
+ disp_hint_info_three(pos, "¼üÅÌÒÀ´ÎÊäÈë","0123456789C",temp,0);
+}
+
+static uint8 sp_keyboard_test(sp_pos_t* pos)
+{
+ uint8 kcode;
+ uint32 tick;
+ uint8 offset = 0;
+ uint8 keybuf[12]= {SP_KEY_0,SP_KEY_1,SP_KEY_2,SP_KEY_3,
+ SP_KEY_4,SP_KEY_5,SP_KEY_6,SP_KEY_7,
+ SP_KEY_8,SP_KEY_9,SP_KEY_CLEAR,SP_KEY_ENTER
+ };
+ show_keyboard_test(pos, offset);
+ tick = sp_get_ticker();
+ while((sp_get_ticker()-tick) < DELAY_TIME60s)
+ {
+ sp_feed_dog();
+ kcode = sp_get_key();
+ if(kcode != SP_KEY_NONE)
+ {
+ tick = sp_get_ticker();
+ switch(kcode)
+ {
+ case SP_KEY_0:
+ if(keybuf[offset] == SP_KEY_0)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_1:
+ if(keybuf[offset] == SP_KEY_1)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_2:
+ if(keybuf[offset] == SP_KEY_2)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_3:
+ if(keybuf[offset] == SP_KEY_3)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_4:
+ if(keybuf[offset] == SP_KEY_4)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_5:
+ if(keybuf[offset] == SP_KEY_5)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_6:
+ if(keybuf[offset] == SP_KEY_6)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_7:
+ if(keybuf[offset] == SP_KEY_7)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_8:
+ if(keybuf[offset] == SP_KEY_8)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_9:
+ if(keybuf[offset] == SP_KEY_9)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_CLEAR:
+ if(offset == 0)
+ {
+ disp_hint_info(pos, "È¡Ïû°´¼ü¼ì²â",DELAY_TIME2s);
+ return 1;
+ }
+ if(keybuf[offset] == SP_KEY_CLEAR)
+ {
+ ++offset;
+ show_keyboard_test(pos, offset);
+ }
+ break;
+ case SP_KEY_ENTER:
+ if(keybuf[offset] == SP_KEY_ENTER)
+ {
+ disp_hint_info_two(pos, "¼üÅ̼ì²âÕýÈ·","¼üÅÌУ׼Õý³£",DELAY_TIME3s);
+ return 0;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ return 1;
+
+}
+
+static void sp_factory_check(sp_pos_t* pos)
+{
+ sp_link_test(pos);
+ sp_keyboard_test(pos);
+}
+
+static void sp_set_devtime(sp_pos_t* pos)
+{
+ uint32 ticker;
+ uint8 kcode;
+ uint8 key_press = 1;
+ uint8 ctime[6];
+ uint8 offset;
+ char str[13];
+ char msg[17];
+
+ MEMCLEAR(str,sizeof str);
+ sp_get_bcdtime(ctime);
+ offset = 10;
+ sp_hex_to_str(ctime,5,str);
+ ticker = sp_get_ticker();
+ while(sp_get_ticker() -ticker < DELAY_TIME60s)
+ {
+ kcode = sp_get_key();
+ if(kcode != SP_KEY_NONE)
+ {
+ key_press = 1;
+ switch(kcode)
+ {
+ case SP_KEY_0:
+ case SP_KEY_1:
+ case SP_KEY_2:
+ case SP_KEY_3:
+ case SP_KEY_4:
+ case SP_KEY_5:
+ case SP_KEY_6:
+ case SP_KEY_7:
+ case SP_KEY_8:
+ case SP_KEY_9:
+ if(offset < 10)
+ {
+ str[offset++] = '0' + (kcode- SP_KEY_0);
+ }
+ break;
+ case SP_KEY_ENTER:
+ if(offset >= 10)
+ {
+ MEMCLEAR(ctime,sizeof ctime);
+ sp_str_to_bcd(str,10,ctime);
+ if(sp_check_time_valid(ctime))
+ {
+ disp_hint_info_two(pos,"ÉèÖÃʱ¼äʧ°Ü","ʱ¼ä²»ºÏ·¨", DELAY_TIME3s);
+ }
+ else
+ {
+ sp_set_bcdtime(ctime);
+ disp_hint_info_two(pos,"ÉèÖÃʱ¼ä³É¹¦"," ", DELAY_TIME2s);
+ return;
+ }
+ }
+ break;
+ case SP_KEY_CLEAR:
+ if(offset == 0)
+ {
+ return;
+ }
+ offset--;
+ str[offset] = 0;
+ break;
+ }
+ }
+ if(key_press)
+ {
+ sprintf(msg,"%s",str);
+ disp_hint_info_two(pos,"ÉèÖÃʱ¼ä(ymdHm)",msg,0);
+ ticker = sp_get_ticker();
+ key_press = 0;
+ }
+ }
+}
+
+static void sp_manual_login(sp_pos_t* pos)
+{
+ uint16 ret;
+ uint32 tick;
+ sp_protocol_response_t resp;
+ MEMCLEAR(&resp, sizeof(resp));
+ disp_hint_info_two(pos,"ÕýÔڵǼ","ÇëÉÔµÈ...",0);
+ sp_async_equipment_login(pos);
+ tick = sp_get_ticker();
+ while(sp_get_ticker() - tick < DELAY_TIME3s*2)
+ {
+ MEMCLEAR(&resp, sizeof(resp));
+ usart_read((u8*)&resp, sizeof(resp));
+ if(resp.excmd == SP_CMD_LOGIN)
+ {
+ ret = sp_confirm_login(&resp, pos);
+ break;
+ }
+ else
+ {
+ ret = RC_DEV_LOGIN_FAIL;
+ }
+ }
+ if(ret)
+ {
+ char msg[32];
+ sprintf(msg,"´íÎóÂë=%d",ret);
+ disp_hint_info_two(pos,"Ç©µ½Ê§°Ü",msg,DELAY_TIME3s);
+ }
+ else
+ {
+ disp_hint_info(pos,"Ç©µ½³É¹¦",DELAY_TIME3s);
+ }
+}
+
+static void sp_set_devphyid(sp_pos_t* pos)
+{
+ uint32 ticker;
+ uint8 kcode;
+ uint16 ret = 0;
+ uint8 key_press = 1;
+ char msg[17];
+ uint8 devphyid[4];
+ uint8 offset;
+ char str[9];
+ MEMCPY(devphyid,pos->devphyid,sizeof(pos->devphyid));
+ MEMCLEAR(str,sizeof str);
+
+ ticker = sp_get_ticker();
+ offset = 8;
+ sp_hex_to_str(devphyid,4,str);
+ while(sp_get_ticker() -ticker < DELAY_TIME60s)
+ {
+ kcode = sp_get_key();
+ if(kcode != SP_KEY_NONE)
+ {
+ key_press = 1;
+ switch(kcode)
+ {
+ case SP_KEY_0:
+ case SP_KEY_1:
+ case SP_KEY_2:
+ case SP_KEY_3:
+ case SP_KEY_4:
+ case SP_KEY_5:
+ case SP_KEY_6:
+ case SP_KEY_7:
+ case SP_KEY_8:
+ case SP_KEY_9:
+ if(offset < 8)
+ {
+ str[offset++] = '0' +(kcode -SP_KEY_0);
+ }
+ break;
+ case SP_KEY_ENTER:
+ if(offset >= 8)
+ {
+ sp_str_to_hex(str,8,devphyid);
+ if(0 != MEMCMP(pos->devphyid,devphyid,4))
+ {
+ ret = sp_save_devphyid(pos, devphyid);
+ }
+ if(!ret)
+ {
+ MEMCPY(pos->devphyid,devphyid,4);
+ sprintf(msg,"ID: %02x%02x%02x%02x",devphyid[0],devphyid[1],devphyid[2],devphyid[3]);
+ disp_hint_info_two(pos,"ÉèÖÃÎïÀíID³É¹¦",msg, DELAY_TIME2s);
+ }
+ else
+ {
+ show_error(pos,"±£´æÎïÀíIDʧ°Ü",ret);
+ }
+ return;
+ }
+ break;
+ case SP_KEY_CLEAR:
+ if(offset > 0)
+ {
+ offset--;
+ str[offset] = 0;
+ }
+ else
+ {
+ return;
+ }
+ break;
+ }
+ }
+ if(key_press)
+ {
+ sprintf(msg,"%s",str);
+ disp_hint_info_two(pos,"ÉèÖÃÎïÀíID:",msg,0);
+ ticker = sp_get_ticker();
+ key_press = 0;
+ }
+ }
+ return;
+}
+static void sp_set_deviceno(sp_pos_t* pos)
+{
+ uint32 ticker;
+ uint8 kcode;
+ uint16 ret = 0;
+ uint8 key_press = 1;
+ uint16 tempno;
+ uint8 deviceno = pos->deviceno;
+ char msg[17];
+ char temp[17];
+ ticker = sp_get_ticker();
+ while(sp_get_ticker() -ticker < DELAY_TIME60s)
+ {
+ kcode = sp_get_key();
+ if(kcode != SP_KEY_NONE)
+ {
+ key_press = 1;
+ switch(kcode)
+ {
+ case SP_KEY_0:
+ case SP_KEY_1:
+ case SP_KEY_2:
+ case SP_KEY_3:
+ case SP_KEY_4:
+ case SP_KEY_5:
+ case SP_KEY_6:
+ case SP_KEY_7:
+ case SP_KEY_8:
+ case SP_KEY_9:
+ tempno = (uint16)deviceno;
+ tempno *=10;
+ tempno += (kcode-SP_KEY_0);
+ if(tempno > 0 && tempno < DEV_MAX_DEVICENO)
+ {
+ deviceno = (uint8)tempno;
+ }
+ break;
+ case SP_KEY_ENTER:
+ if(deviceno > 0 && deviceno <= DEV_MAX_DEVICENO)
+ {
+ if(pos->deviceno != deviceno)
+ {
+ ret = sp_save_deviceno(pos,deviceno);
+ }
+ if(!ret)
+ {
+ pos->deviceno = deviceno;
+ sprintf(msg,"»úºÅ: %d",deviceno);
+ disp_hint_info_two(pos,"ÉèÖûúºÅ³É¹¦",msg, DELAY_TIME2s);
+ }
+ else
+ {
+ show_error(pos,"±£´æ»úºÅʧ°Ü",ret);
+ }
+ return;
+ }
+ else
+ {
+ sprintf(msg,"·¶Î§(1-%d)",DEV_MAX_DEVICENO);
+ disp_hint_info_two(pos,"»úºÅ´íÎó",msg, DELAY_TIME3s);
+ }
+ case SP_KEY_CLEAR:
+ if(deviceno == 0)
+ {
+ return;
+ }
+ deviceno = 0;
+ break;
+ }
+ }
+ if(key_press)
+ {
+ sprintf(temp,"ÉèÖûúºÅ(1-%d)",DEV_MAX_DEVICENO);
+ sprintf(msg,"%d",deviceno);
+ disp_hint_info_two(pos,temp,msg,0);
+ ticker = sp_get_ticker();
+ key_press = 0;
+ }
+ }
+ return;
+}
+
+static void clear_transdtl(sp_pos_t* pos)
+{
+ if(0 == sp_check_passwd(pos,"Çå¿ÕÁ÷Ë®ÃÜÂë:","\x9\x1\x4\x3\x8\x7"))
+ {
+ disp_hint_info_two(pos,"Çå¿ÕÁ÷Ë®","ÇëÉÔµÈ...",0);
+ sp_clear_transdtl(pos);
+ }
+}
+
+static void manual_upgrade(sp_pos_t* pos)
+{
+ if(0 == sp_check_passwd(pos, "ÔÚÏßÉý¼¶ÃÜÂë:","\x9\x1\x4\x3\x8\x7"))
+ {
+ sp_manual_upgrade(pos);
+ }
+}
+
+static void reset_factory(sp_pos_t* pos)
+{
+ if(0 == sp_check_passwd(pos, "»Ö¸´³ö³§ÃÜÂë:","\x9\x1\x4\x3\x8\x7"))
+ {
+ sp_reset_factory(pos);
+ }
+}
+
+void sp_menu_options(sp_pos_t* pos)
+{
+ uint32 ticker = 0;
+ uint8 keycode;
+ uint8 page;
+ uint8 max_cnt;
+ uint8 key_press = 1;
+
+ menu_t menus[] =
+ {
+ {"1.²é¿´²ÎÊý", sp_show_syspara},
+ {"2.¹¤³§²âÊÔ", sp_factory_check},
+ {"3.ÉèÖÃʱ¼ä", sp_set_devtime},
+ {"4.ÊÖ¶¯µÇ¼", sp_manual_login},
+ {"5.ÉèÖÃÎïÀíid", sp_set_devphyid},
+ {"6.ÉèÖûúºÅ", sp_set_deviceno},
+ {"7.Çå¿ÕÁ÷Ë®", clear_transdtl},
+ {"8.ÔÚÏßÉý¼¶", manual_upgrade},
+ {"9.»Ö¸´³ö³§", reset_factory}
+ };
+ max_cnt = sizeof(menus)/sizeof(menu_t)/3;
+ page = 0;
+ ticker = sp_get_ticker();
+ while(sp_get_ticker()-ticker <= DELAY_TIME60s*5)
+ {
+ sp_feed_dog();
+ keycode = sp_get_key();
+ if(keycode != SP_KEY_NONE)
+ {
+ key_press = 1;
+ switch(keycode)
+ {
+ case SP_KEY_0:
+ if(page < (max_cnt-1))
+ {
+ page++;
+ }
+ break;
+ case SP_KEY_1:
+ case SP_KEY_2:
+ case SP_KEY_3:
+ case SP_KEY_4:
+ case SP_KEY_5:
+ case SP_KEY_6:
+ case SP_KEY_7:
+ case SP_KEY_8:
+ case SP_KEY_9:
+ if(menus[keycode-SP_KEY_1].func != NULL)
+ {
+ menus[keycode-SP_KEY_1].func(pos);
+ }
+ break;
+ case SP_KEY_CLEAR:
+ if(page == 0)
+ {
+ return;
+ }
+ page--;
+ break;
+ default:
+ break;
+ }
+ }
+ if(key_press)
+ {
+ disp_hint_info_three(pos, menus[page*3].hit, menus[page*3+1].hit, menus[page*3+2].hit, 0);
+ key_press = 0;
+ ticker = sp_get_ticker();
+ }
+ }
+}
diff --git a/supwisdom/sp_menu.h b/supwisdom/sp_menu.h
new file mode 100644
index 0000000..75f8f32
--- /dev/null
+++ b/supwisdom/sp_menu.h
@@ -0,0 +1,8 @@
+#ifdef _SP_MENU_H_
+#define _SP_MENU_H_
+
+#include "sp_config.h"
+
+void sp_menu_options(sp_pos_t* pos);
+
+#endif
diff --git a/supwisdom/sp_msgpack.c b/supwisdom/sp_msgpack.c
new file mode 100644
index 0000000..d1258a9
--- /dev/null
+++ b/supwisdom/sp_msgpack.c
@@ -0,0 +1,87 @@
+#include "string.h"
+#include "sp_msgpack.h"
+
+int32 sp_pack_init(cw_pack_context* pack,uint8* buf,uint16 len)
+{
+ memset(buf,0,len);
+ return cw_pack_context_init(pack,buf,len,0);
+}
+
+uint16 sp_pack_length(cw_pack_context* pack)
+{
+ if(pack->current != NULL && pack->start != NULL)
+ {
+ return (pack->current -pack->start);
+ }
+ return 256;
+}
+void sp_pack_put_str(cw_pack_context* pack,const char* parakey,const char* paraval)
+{
+ cw_pack_str(pack,parakey,strlen(parakey));
+ cw_pack_str(pack,paraval,strlen(paraval));
+}
+void sp_pack_put_int(cw_pack_context* pack,const char* parakey,const int paraval)
+{
+ cw_pack_str(pack,parakey,strlen(parakey));
+ cw_pack_signed(pack,paraval);
+}
+void sp_pack_put_bin(cw_pack_context* pack,const char* parakey,const uint8* paraval,
+ const uint16 len)
+{
+ cw_pack_str(pack,parakey,strlen(parakey));
+ cw_pack_bin(pack,paraval,len);
+}
+int32 sp_unpack_init(cw_unpack_context* unpack,uint8* buf,uint16 len)
+{
+ cw_unpack_context_init(unpack,buf,len,0);
+ return unpack->return_code;
+}
+
+uint8 sp_unpack_map_size(cw_unpack_context* unpack)
+{
+ cw_unpack_next(unpack);
+ if(unpack->item.type == CWP_ITEM_MAP)
+ {
+ return (uint8)unpack->item.as.map.size;
+ }
+ return 0;
+}
+
+uint8 sp_unpack_value(cw_unpack_context* unpack,unpack_field_t* field)
+{
+ cw_unpack_next(unpack);
+ if(unpack->item.type == CWP_ITEM_STR)
+ {
+ field->key = unpack->item.as.str.start;
+ cw_unpack_next(unpack);
+ if(unpack->item.type == CWP_ITEM_STR)
+ {
+ field->val.strval = unpack->item.as.str.start;
+ field->strlen = unpack->item.as.str.length;
+ return 0;
+ }
+ else if(unpack->item.type == CWP_ITEM_POSITIVE_INTEGER)
+ {
+ field->val.intval= (int32)unpack->item.as.i64;
+ field->strlen = 0;
+ return 0;
+ }
+ else if(unpack->item.type == CWP_ITEM_BIN)
+ {
+ field->val.binval = unpack->item.as.str.start;
+ field->strlen = unpack->item.as.str.length;
+ return 0;
+ }
+ else
+ {
+ field->strlen = 0;
+ field->val.intval = 0;
+ return 1;
+ }
+ }
+ return 1;
+}
+
+
+
+
diff --git a/supwisdom/sp_msgpack.h b/supwisdom/sp_msgpack.h
new file mode 100644
index 0000000..c07a021
--- /dev/null
+++ b/supwisdom/sp_msgpack.h
@@ -0,0 +1,40 @@
+#ifndef _SP_MSGPACK_H_
+#define _SP_MSGPACK_H_
+
+
+#include "../msgpack/cwpack.h"
+#include "sp_config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ const char* key;
+ union
+ {
+ int32 intval;
+ const char* strval;
+ const uint8* binval;
+ } val;
+ int32 strlen;
+} unpack_field_t;
+
+int32 sp_pack_init(cw_pack_context* pack,uint8* buf,uint16 len);
+void sp_pack_put_str(cw_pack_context* pack,const char* parakey,const char* paraval);
+void sp_pack_put_int(cw_pack_context* pack,const char* parakey,const int paraval);
+void sp_pack_put_bin(cw_pack_context* pack,const char* parakey,const uint8* paraval,
+ const uint16 len);
+uint16 sp_pack_length(cw_pack_context* pack);
+
+int32 sp_unpack_init(cw_unpack_context* unpack,uint8* buf,uint16 len);
+uint8 sp_unpack_map_size(cw_unpack_context* unpack);
+uint8 sp_unpack_value(cw_unpack_context* unpack,unpack_field_t* field);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/supwisdom/sp_upgrade.c b/supwisdom/sp_upgrade.c
new file mode 100644
index 0000000..6f2fdb8
--- /dev/null
+++ b/supwisdom/sp_upgrade.c
@@ -0,0 +1,416 @@
+#include "sp_msgpack.h"
+#include "sp_flash.h"
+#include "sp_util.h"
+#include "sp_display.h"
+#include "sp_communicate.h"
+#include "sp_upgrade.h"
+
+extern uint16 crc_table[];
+
+#pragma pack(push)
+#pragma pack(1)
+typedef struct
+{
+ uint32 file_size;
+ uint8 file_crc[2];
+ uint8 file_md5[16];
+} sp_upgrade_info_t;
+#pragma pack(pop)
+
+/*
+**************************************************************************************************************
+* CRC У Ñé
+* Ãè Êö: УÑéÒ»´®charÊý¾ÝµÄCRC
+*
+* Êä Èë: CPU_CHAR *str - ҪУÑéÊý¾ÝµÄÖ¸Õë
+* CPU_INT16U size - ҪУÑéÊý¾ÝµÄ³¤¶È
+* CPU_INT08U mode - УÑéµÄģʽ
+* 1: Ϊ¸Ã´®Êý¾ÝÔö¼ÓCRCУÑé ͬʱ·µ»ØÐ£ÑéµÄCRCÖµ
+* 0: ¸Ã´®Êý¾ÝÊÇ·ñͨ¹ýУÑé ·µ»ØÐ£ÑéµÄCRCÖµ
+* ·µ »Ø:
+*
+* ×¢ Òâ:
+*
+**************************************************************************************************************
+*/
+//CRCʹÓÃ
+typedef struct
+{
+ uint8 L;
+ uint8 H;
+} INT_08BIT_2;
+
+typedef union
+{
+ uint16 Int16Bit;
+ INT_08BIT_2 Int08Bit;
+} INT_16BIT_08BIT;
+
+uint16 AH_CRC_Verify(uint8 str[], uint16 size, uint8 mode)
+{
+ uint32 i;
+ INT_16BIT_08BIT crc;
+ INT_16BIT_08BIT y;
+
+ crc.Int16Bit = 0;
+ for(i = 0 ; i < size ; i++)
+ {
+ y.Int16Bit = crc_table[ str[ i ] ^ crc.Int08Bit.H ];
+ y.Int08Bit.H ^= crc.Int08Bit.L;
+ crc.Int16Bit = y.Int16Bit;
+ }
+ if(mode == 1)
+ {
+ str[ i++ ] = y.Int08Bit.H ;
+ str[ i ] = y.Int08Bit.L ;
+ }
+ return(crc.Int16Bit);
+}
+
+static uint16 update_upgrade_mark(uint32 CheckSum, uint32 size)
+{
+ uint16 ret,i;
+ uint8 buff[18] = { 0x5a,0x4b,0x3c,0x2d,0x1e,0x0f } ;
+
+ //дÉý¼¶Êý¾Ý³É¹¦Ð´ÈëFLASH±ê¼Ç, ºÍУÑéÂë, ÓÐЧ´úÂ볤¶ÈдÈëÊý¾ÝFLASH
+ memcpy(buff+6, (unsigned char*)&(CheckSum), 4) ; //УÑéºÍ
+ memcpy(buff+10,(unsigned char*)&(size) ,4) ; //Êý¾Ý³¤¶È
+ AH_CRC_Verify(buff, 14, 1);
+
+ for(i = 0; i<5; i++)
+ {
+ ret = sp_flash_erase(DEF_IapMarkAddr);
+ if(ret)
+ {
+ continue;
+ }
+ ret = sp_flash_write(DEF_IapMarkAddr, buff, 16);
+ if(!ret)
+ {
+ break;
+ }
+ }
+ if(i >= 5)
+ {
+ return 1;
+ }
+ return 0;
+}
+/**********************************************************************************************
+º¯ÊýÃû³Æ: U32 APP_IapDataSumCheck( U32 staaddr, U32 len, U08 mode )
+º¯Êý×÷ÓÃ: ¶Á³öFLASHÖеÄÊý¾Ý£¬²¢ÐγÉУÑé
+º¯ÊýÊäÈë: staaddr - ¿ªÊ¼µØÖ·
+ len - Êý¾Ý³¤¶È
+ mode - УÑéģʽ 0 È¡·´ºÍУÑé 1 ÆÕͨºÍУÑé
+º¯ÊýÊä³ö: ÎÞ
+º¯Êý·µ»ØÖµ: 0 ³É¹¦ ÆäËûʧ°Ü
+**********************************************************************************************/
+uint32 do_APP_IapDataSumCheck(uint32 staaddr, uint32 len, uint8 mode)
+{
+ uint32 Sum;
+ uint32 app_len, checksize, size;
+ uint16 rcode, i;
+ uint8 buffer[1024];//IAP_MAXLEN
+
+ app_len = len;
+ checksize = 0;
+ Sum = 0;
+ while(checksize < app_len)
+ {
+ if(len < 1024)
+ {
+ size = len;
+ }
+ else
+ {
+ size = 1024;
+ }
+
+ for(i=0; i<5; i++)
+ {
+ rcode = sp_flash_read((staaddr + checksize), buffer, size);
+ if(!rcode)
+ {
+ break;
+ }
+ }
+
+ if(mode == 0)
+ {
+ for(i = 0; i < size; i++)
+ {
+ Sum += ((~buffer[i]) & 0xFF); //еÄÊÇÈ¡·´ºÍ
+ }
+ }
+ else
+ {
+ for(i = 0; i < size; i++)
+ {
+ Sum += buffer[i]; //ÀϵÄÊÇÖ±½ÓºÍ
+ }
+ }
+ checksize += size;
+ len -= size;
+ }
+
+ return (Sum);
+}
+static uint8 get_file_info(sp_pos_t* pos, sp_upgrade_info_t* upgradeinfo)
+{
+ uint8 ret;
+ uint8 size;
+ char temp[32];
+ sp_protocol_request_t req;
+ sp_protocol_response_t resp;
+ cw_pack_context pack;
+ cw_unpack_context unpack;
+ unpack_field_t field;
+
+ sp_flash_read(ADDR_UPGRADE_UPINFO,(uint8*)upgradeinfo,sizeof(sp_upgrade_info_t));
+
+ /*¶ÁÈ¡Îļþ³¤¶ÈºÍCRC*/
+ sp_protocol_req_init(&req,SP_CMD_UPGRADE);
+ sp_pack_init(&pack,req.data,sizeof(req.data));
+ cw_pack_map_size(&pack,5);
+
+ sp_pack_put_bin(&pack,PK_BIN_DEVPHYID, pos->devphyid, sizeof(pos->devphyid));
+ sp_pack_put_int(&pack,PK_INT_SEQNO ,0xFFFF);
+ sp_pack_put_str(&pack,PK_STR_DEVTYPE, DEV_TYPE);
+ sp_pack_put_str(&pack,PK_STR_VERSION, PRO_VERSION);
+ sp_pack_put_bin(&pack,PK_BIN_SOFT_MD5,upgradeinfo->file_md5,16);
+
+ req.datalen += sp_pack_length(&pack);
+ ret = sp_comm_call(pos, &req, &resp, COMM_WAIT_TIME);
+ if(!ret)
+ {
+ sp_unpack_init(&unpack,resp.data,resp.datalen);
+ //erase
+ sp_flash_erase(ADDR_UPGRADE_UPINFO);
+ size = sp_unpack_map_size(&unpack);
+ while(size-- > 0)
+ {
+ sp_unpack_value(&unpack,&field);
+ // 4 byte file_length,2 crc
+ if(IS_KEY(PK_INT_FILESIZE,field.key))
+ {
+ upgradeinfo->file_size = (uint32)field.val.intval;
+ }
+ else if(IS_KEY(PK_BIN_FILECRC,field.key))
+ {
+ if(field.strlen != 2)
+ {
+ sprintf(temp,"CRC³¤¶È=%d",field.strlen);
+ disp_hint_info_two(pos, "Éý¼¶Ê§°Ü",temp,DELAY_TIME3s);
+ return 1;
+ }
+ MEMCPY(upgradeinfo->file_crc,field.val.binval,field.strlen);
+ }
+ else if(IS_KEY(PK_BIN_SOFT_MD5,field.key))
+ {
+ MEMCPY(upgradeinfo->file_md5,field.val.binval,field.strlen);
+ }
+ }
+ }
+ else
+ {
+ disp_server_errmsg(pos, "Éý¼¶Ê§°Ü",resp.data,resp.datalen);
+ }
+ return ret;
+}
+static uint8 download_file(sp_pos_t* pos)
+{
+ uint8 ret;
+ uint8 timeout_trycnt = 0;
+ uint8 sameseq_trycnt = 0;
+ uint8 data_len = 0;
+ uint16 seqno = 0;
+ uint16 resp_seqno = 0;
+ uint32 offset = 0;
+ uint8 endflag = 0;
+ uint8 size;
+ char temp[32];
+ uint8 buf[128];
+ sp_protocol_request_t req;
+ sp_protocol_response_t resp;
+ cw_pack_context pack;
+ cw_unpack_context unpack;
+ unpack_field_t field;
+
+ for(offset = ADDR_UPGRADE_BEGIN; offset < ADDR_UPGRADE_END; offset +=DEF_FLASH_PageSize)
+ {
+ sp_flash_erase(offset);
+ }
+ offset = 0;
+ while(1)
+ {
+ sp_feed_dog();
+ sp_protocol_req_init(&req,SP_CMD_UPGRADE);
+ sp_pack_init(&pack,req.data,sizeof(req.data));
+ cw_pack_map_size(&pack,2);
+
+ sp_pack_put_bin(&pack,PK_BIN_DEVPHYID, pos->devphyid, sizeof(pos->devphyid));
+ sp_pack_put_int(&pack,PK_INT_SEQNO,seqno);
+
+ req.datalen += sp_pack_length(&pack);
+ ret = sp_comm_call(pos, &req,&resp, COMM_WAIT_TIME);
+ if(!ret)
+ {
+ timeout_trycnt = 0;//success reset
+ sp_unpack_init(&unpack,resp.data,resp.datalen);
+ size = sp_unpack_map_size(&unpack);
+ while(size-- > 0)
+ {
+ sp_unpack_value(&unpack,&field);
+ if(IS_KEY(PK_INT_SEQNO,field.key))
+ {
+ resp_seqno = (uint32)field.val.intval;
+ }
+ else if(IS_KEY(PK_INT_FLAG,field.key))
+ {
+ if(0 == MEMCMP("end",field.val.strval,field.strlen))
+ {
+ // ÎļþÏÂÔØÍê³É
+ endflag = 1;
+ }
+ }
+ else if(IS_KEY(PK_BIN_FILEDATA,field.key))
+ {
+ data_len = field.strlen;
+ if(data_len > sizeof(buf))
+ {
+ sprintf(temp,"´íÎ󳤶È=%d",data_len);
+ disp_hint_info_two(pos, "Éý¼¶Ê§°Ü",temp,DELAY_TIME3s);
+ return 1;
+ }
+ MEMCLEAR(buf,sizeof buf);
+ MEMCPY(buf,field.val.binval,data_len);
+ }
+ }
+
+ if(resp_seqno != seqno +1)
+ {
+ if(10 < sameseq_trycnt)
+ {
+ return 1;
+ }
+ ++sameseq_trycnt;
+ continue;
+ }
+ sameseq_trycnt = 0;
+
+ ++seqno;
+ snprintf(temp,sizeof temp,"seqno = %04d",seqno);
+ disp_hint_info_two(pos, "ÕýÔÚÉý¼¶...",temp,0);
+
+ sp_flash_write(ADDR_UPGRADE_BEGIN+offset,buf,data_len);
+ if(endflag)
+ {
+ return 0;
+ }
+
+ offset += (uint32)data_len;
+ if(ADDR_UPGRADE_BEGIN + offset >= ADDR_UPGRADE_END)
+ {
+ disp_hint_info(pos, "ÏÂÔØÎļþ¹ý´ó",DELAY_TIME3s);
+ return 1;
+ }
+ }
+ else
+ {
+ if(3 < timeout_trycnt)
+ {
+ disp_hint_info(pos, "ÏÂÔØÎļþ³¬Ê±",DELAY_TIME3s);
+ return 1;
+ }
+ Delay_ms(DELAY_TIME1s);
+ ++timeout_trycnt;
+ }
+ }
+}
+static uint8 check_file_and_upgrade(sp_pos_t* pos, sp_upgrade_info_t* upgradeinfo)
+{
+ uint16 ret;
+ uint8 crc[2];
+ uint8 temp_crc[2];
+ uint8 buf[128];
+ uint32 sumcrc;
+
+ uint32 page_index = 0;
+ uint32 page_num = (upgradeinfo->file_size-1)/sizeof(buf) + 1;
+ while(1)
+ {
+ if(page_num == page_index +1)
+ {
+ sp_flash_read(ADDR_UPGRADE_BEGIN +page_index*sizeof(buf),buf,
+ sizeof buf);
+ memcpy(temp_crc,crc,2);
+ if(upgradeinfo->file_size%sizeof(buf) == 0)
+ {
+ sp_protocol_crc_init(buf,sizeof(buf),temp_crc,crc);
+ }
+ else
+ {
+ sp_protocol_crc_init(buf,upgradeinfo->file_size%sizeof(buf),temp_crc,crc);
+ }
+ if(0 == MEMCMP(upgradeinfo->file_crc,crc,2))
+ {
+ sp_flash_write(ADDR_UPGRADE_UPINFO,(uint8*)upgradeinfo,sizeof(sp_upgrade_info_t));
+
+ sumcrc = do_APP_IapDataSumCheck(ADDR_UPGRADE_BEGIN,upgradeinfo->file_size,0);
+ /*Éý¼¶ºó,boot »á²Á³ý¸ÃÒ³¼Ç¼ */
+ //¸üбê־λÖÃλ
+ ret = update_upgrade_mark(sumcrc,upgradeinfo->file_size);
+ if(ret)
+ {
+ disp_hint_info_two(pos, "Éý¼¶Ê§°Ü","¸üбê־ʧ°Ü",DELAY_TIME2s);
+ return 1;
+ }
+ else
+ {
+ disp_hint_info_two(pos, "ÕýÔÚÉý¼¶","ÇëÎð¶Ïµç",DELAY_TIME2s);
+ sp_reset();
+ return 0;
+ }
+ }
+ else
+ {
+ disp_hint_info(pos, "ÎļþУÑé´íÎó",DELAY_TIME3s);
+ return 1;
+ }
+ }
+ else
+ {
+ sp_flash_read(ADDR_UPGRADE_BEGIN+page_index*sizeof(buf),buf,sizeof buf);
+ if(0 == page_index)
+ {
+ sp_protocol_crc(buf,sizeof buf,crc);
+ }
+ else
+ {
+ memcpy(temp_crc,crc,2);
+ sp_protocol_crc_init(buf,sizeof buf,temp_crc,crc);
+ }
+ ++page_index;
+ }
+ }
+}
+void sp_manual_upgrade(sp_pos_t* pos)
+{
+ uint8 ret;
+ sp_upgrade_info_t upgradeinfo;
+
+ disp_hint_info_two(pos, "ÕýÔÚÉý¼¶..","Îð¶Ïµç!!",0);
+ MEMCLEAR(&upgradeinfo,sizeof upgradeinfo);
+ ret = get_file_info(pos, &upgradeinfo);
+ if(ret)
+ {
+ return;
+ }
+ ret = download_file(pos);
+ if(ret)
+ {
+ return;
+ }
+ check_file_and_upgrade(pos, &upgradeinfo);
+}
+
diff --git a/supwisdom/sp_upgrade.h b/supwisdom/sp_upgrade.h
new file mode 100644
index 0000000..2cd8160
--- /dev/null
+++ b/supwisdom/sp_upgrade.h
@@ -0,0 +1,14 @@
+#ifndef _SP_UPGRADE_H_
+#define _SP_UPGRADE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void sp_manual_upgrade(sp_pos_t* pos);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/supwisdom/sp_util.c b/supwisdom/sp_util.c
new file mode 100644
index 0000000..df70b13
--- /dev/null
+++ b/supwisdom/sp_util.c
@@ -0,0 +1,530 @@
+#include "../sys_hw/keypad.h"
+#include "../sys_hw/drv_adc.h"
+#include "sp_display.h"
+
+#include "sp_util.h"
+
+uint16 crc_table[] =
+{
+ 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
+ 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
+ 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
+ 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
+ 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
+ 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
+ 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
+ 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
+ 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
+ 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
+ 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
+ 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
+ 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
+ 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
+ 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
+ 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
+ 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
+ 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
+ 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
+ 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
+ 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
+ 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
+ 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
+ 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
+ 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
+ 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
+ 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
+ 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
+ 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
+ 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
+ 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
+ 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
+};
+
+void sp_protocol_crc(const uint8* buf, uint16 len, uint8 crc[2])
+{
+ //uint16 accnum = 0xc78c;
+ uint8 temp_crc[2];
+ temp_crc[0] = 0xc7;
+ temp_crc[1] = 0x8c;
+ sp_protocol_crc_init(buf,len,temp_crc,crc);
+}
+
+void sp_protocol_crc_init(const uint8* buf, uint16 len,uint8 init[2], uint8 crc[2])
+{
+ uint16 accnum = (uint16)init[0]<<8 |(uint16)init[1];
+ uint16 i;
+ for(i = 0; i < len; ++i)
+ {
+ accnum = (accnum << 8) ^ crc_table[((accnum >> 8)
+ ^ buf[i]) & 0xFF];
+ }
+ crc[0] = (uint8)((accnum >> 8) & 0xFF);
+ crc[1] = (uint8)(accnum & 0xFF);
+}
+
+void sp_key_calibrate(void)
+{
+ calibrate_key(0);
+}
+
+uint8 sp_key_init(void)
+{
+ adc_init();
+ return keypad_init();
+}
+uint8 sp_get_key(void)
+{
+ uint8 key = keypad_get_key();
+ switch(key)
+ {
+ case KEY_NONE:
+ return SP_KEY_NONE;
+ case KEY_DIG0:
+ return SP_KEY_0;
+ case KEY_DIG1:
+ return SP_KEY_1;
+ case KEY_DIG2:
+ return SP_KEY_2;
+ case KEY_DIG3:
+ return SP_KEY_3;
+ case KEY_DIG4:
+ return SP_KEY_4;
+ case KEY_DIG5:
+ return SP_KEY_5;
+ case KEY_DIG6:
+ return SP_KEY_6;
+ case KEY_DIG7:
+ return SP_KEY_7;
+ case KEY_DIG8:
+ return SP_KEY_8;
+ case KEY_DIG9:
+ return SP_KEY_9;
+ case KEY_ENTER:
+ return SP_KEY_ENTER;
+ case KEY_CANCEL:
+ return SP_KEY_CLEAR;
+ default:
+ return SP_KEY_NONE;
+ }
+}
+void sp_reset(void)
+{
+ while(1);
+}
+void sp_bcd_to_str(const uint8* bcd, uint8 bcd_len, char* str)
+{
+ uint8 i;
+ uint16 j;
+ for(i = 0; i < bcd_len; ++i)
+ {
+ j = i << 1;
+ str[j] = ((bcd[i] >> 4) & 0x0F) + 0x30;
+ str[j + 1] = (bcd[i] & 0x0F) + 0x30;
+ }
+ str[i << 1] = 0;
+}
+void sp_str_to_bcd(const char* str, uint8 str_len, uint8* bcd)
+{
+ uint8 i,j;
+ for(i = 0; i < str_len; i += 2)
+ {
+ j = i/2;
+ bcd[j] = (((str[i]-0x30) & 0x0F) <<4) | ((str[i+1]-0x30) & 0x0F);
+ }
+}
+static uint8 charTohex(char ch)
+{
+ if(ch >= '0' && ch <= '9')
+ {
+ return (ch -'0');
+ }
+ if(ch >= 'a' && ch <= 'f')
+ {
+ return (ch -'a' +10);
+ }
+ if(ch >= 'A' && ch <= 'F')
+ {
+ return (ch -'A' +10);
+ }
+ return 0;
+}
+void sp_str_to_hex(const char* str,const uint16 len,uint8* hex)
+{
+ uint8 t,temp;
+ uint16 i;
+ for(i = 0; i < len; i += 2)
+ {
+ temp = charTohex(str[i]);
+ t = temp << 4;
+ temp = charTohex(str[i+1]);
+ t += temp;
+ hex[i/2] = t;
+ }
+}
+
+static char hexToCharTable[]= {"0123456789ABCDEF"};
+void sp_hex_to_str(const uint8* hex,const uint8 len,char* str)
+{
+ uint8 i,j;
+ for(i = 0; i < len; i++)
+ {
+ j = i << 1;
+ str[j] = hexToCharTable[(hex[i] >> 4) &0x0F];
+ str[j +1] = hexToCharTable[hex[i] &0x0F];
+ }
+ str[i << 1] = 0;
+}
+
+void sp_get_bcdtime(uint8 ctime[6])
+{
+ _SystemTime time;
+ memset(&time,0,sizeof time);
+ rtc_get_time(&time); //bcd
+ ctime[0] = time.year;
+ ctime[1] = time.month;
+ ctime[2] = time.day;
+ ctime[3] = time.hour;
+ ctime[4] = time.minute;
+ ctime[5] = time.second;
+}
+void sp_set_bcdtime(uint8 ctime[6])
+{
+ _SystemTime time;
+ memset(&time,0,sizeof time);
+ time.year = ctime[0];
+ time.month = ctime[1];
+ time.day = ctime[2];
+ time.hour = ctime[3];
+ time.minute = ctime[4];
+ time.second = ctime[5];
+
+ rtc_set_time(&time);
+}
+uint8 sp_check_time_valid(uint8 ctime[6])
+{
+ if(BCD2Dec(ctime[0]) < 18)
+ return 1;
+ if(BCD2Dec(ctime[1]) > 12)
+ return 1;
+ if(BCD2Dec(ctime[2]) > 31)
+ return 1;
+ if(BCD2Dec(ctime[3]) > 23)
+ return 1;
+ if(BCD2Dec(ctime[4]) > 59)
+ return 1;
+ if(BCD2Dec(ctime[5]) > 59)
+ return 1;
+
+ return 0;
+}
+uint8 sp_crc_sum(uint8 buf[],uint8 len)
+{
+ uint8 i;
+ uint8 sum = 0;
+ //¼ÆËãУÑéºÍ
+ for(i = 0; i < len; i++)
+ {
+ sum = sum + buf[i];
+ }
+ return sum;
+}
+
+int8 isFF(uint8 buf[],uint16 len)
+{
+ uint16 i;
+ for(i = 0; i < len; i++)
+ {
+ if(0xFF != buf[i])
+ {
+ return -1;
+ }
+ }
+ return 0;
+}
+
+//ms
+uint32 sp_get_ticker(void)
+{
+ return timer_get_ticker();
+}
+
+void Delay_ms(uint32 ms)
+{
+ uint32 t = sp_get_ticker();
+ while(sp_get_ticker() - t < ms);
+}
+void sp_valve_on(void)
+{
+ valve_sta_set(valve_state_on);
+ valve_ctrl();
+}
+void sp_valve_off(void)
+{
+ valve_sta_set(valve_state_off);
+ valve_ctrl();
+}
+uint8 sp_valve_state(void)
+{
+ return valve_sta_get();
+}
+
+int16 get_2byte_int(uint8 value_str[2])
+{
+ int32 r = 0, t = 0;
+ t = value_str[0];
+ r = t << 8;
+ r |= value_str[1];
+ return (int16)r;
+}
+int32 get_3byte_int(uint8 value_str[3])
+{
+ int32 r = 0, t = 0;
+ t = value_str[0];
+ r = t << 16;
+ t = value_str[1];
+ r |= t << 8;
+ r |= value_str[2];
+ return r;
+}
+int32 get_4byte_int(uint8 value_str[4])
+{
+ int32 r = 0, t = 0;
+ t = value_str[0];
+ r = t << 24;
+ t = value_str[1];
+ r |= t << 16;
+ t = value_str[2];
+ r |= t << 8;
+ r |= value_str[3];
+ return r;
+}
+void set_2byte_int(uint8 value_str[2], int num)
+{
+ value_str[0] = (num >> 8) & 0xFF;
+ value_str[1] = num & 0xFF;
+}
+void set_3byte_int(uint8 value_str[3], int num)
+{
+ value_str[0] = (num >> 16) & 0xFF;
+ value_str[1] = (num >> 8) & 0xFF;
+ value_str[2] = num & 0xFF;
+}
+void set_4byte_int(uint8 value_str[4], int num)
+{
+ value_str[0] = (num >> 24) & 0xFF;
+ value_str[1] = (num >> 16) & 0xFF;
+ value_str[2] = (num >> 8) & 0xFF;
+ value_str[3] = num & 0xFF;
+}
+
+//»ñµÃµ¥×Ö½ÚÖÐijһλµÄÖµ
+int32 Get1Bit(uint8 buf, int n)
+{
+ return (buf >> n) & 0x01;
+}
+
+int16 get_2byte_int_le(uint8 value_str[2])
+{
+ int32 r = 0, t = 0;
+ t = value_str[1];
+ r = t << 8;
+ r |= value_str[0];
+ return (int16)r;
+}
+//С×Ö½ÚÐò
+int32 get_3byte_int_le(uint8 value_str[3])
+{
+ int32 r = 0, t = 0;
+ t = value_str[2];
+ r = t << 16;
+ t = value_str[1];
+ r |= t << 8;
+ r |= value_str[0];
+ return r;
+}
+//С×Ö½ÚÐò
+int32 get_4byte_int_le(uint8 value_str[4])
+{
+ int32 r = 0, t = 0;
+ t = value_str[3];
+ r = t << 24;
+ t = value_str[2];
+ r |= t << 16;
+ t = value_str[1];
+ r |= t << 8;
+ r |= value_str[0];
+ return r;
+}
+
+void set_2byte_int_le(uint8 value_str[2], int num)
+{
+ value_str[1] = (num >> 8) & 0xFF;
+ value_str[0] = num & 0xFF;
+}
+
+void set_3byte_int_le(uint8 value_str[3], int num)
+{
+ value_str[2] = (num >> 16) & 0xFF;
+ value_str[1] = (num >> 8) & 0xFF;
+ value_str[0] = num & 0xFF;
+}
+
+/*¼ÆËã´Óbcd starttime µ½ÏÖÔÚµÄÃëÊý*/
+uint32 diff_time(uint8 starttime[6])
+{
+ uint8 ctime[6];
+ uint32 start_second;
+ uint32 end_second;
+
+ sp_get_bcdtime(ctime);
+ start_second = format_time_covert_secs(starttime);
+ end_second = format_time_covert_secs(ctime);
+ if(end_second < start_second)
+ {
+ return 0;
+ }
+ return (end_second - start_second);
+}
+
+void mycpy(void* dest, const void* src, uint32 len)
+{
+ char* tmp_dest = (char*)dest;
+ char* tmp_src = (char*)src;
+ while(len--)
+ {
+ *tmp_dest = *tmp_src++;
+ tmp_dest++;
+ }
+}
+
+void sp_bcd2asc(const uint8 bcdbuf[], uint8 bcdlen, uint8* ascstr)
+{
+ uint8 i;
+ uint8 lch, hch;
+ for(i = 0; i < bcdlen; i++)
+ {
+ hch = (bcdbuf[i] & 0x0F);
+ lch = (bcdbuf[i] & 0xF0);
+ lch = lch >> 4;
+ ascstr[2 * i] = lch + '0';
+ ascstr[2 * i + 1] = hch + '0';
+ }
+ ascstr[2*i] = 0;
+}
+int32 sp_atoi(const char* src)
+{
+ int i = 0;
+ while(*src != 0)
+ {
+ i = i * 10 + *src - '0';
+ src++;
+ }
+ return i;
+}
+/**
+**2000.0.0:0.0.0ʱ¼äΪ»ùÊý
+**/
+static int MINUTE_SECS = 60;
+static int HOUR_SECS = 3600;
+static int DAY_SECS = 24*3600;
+static int YEAR_SECS = 365*24*3600;
+static int FOURYEAR_SECS = (365*3+366)*24*3600;
+static int norMoth[] = {0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+static int leapMoth[] = {0,31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+/*time: string(yyyyMMddHHmmss) to int */
+int format_time_covert_secs(uint8 ctime[6])
+{
+ int secs;
+ int i;
+ int remain;
+ int year = BCD2Dec(ctime[0]);
+ int month = BCD2Dec(ctime[1]);
+ int day = BCD2Dec(ctime[2]);
+ int hour = BCD2Dec(ctime[3]);
+ int minute = BCD2Dec(ctime[4]);
+ int second = BCD2Dec(ctime[5]);
+
+ secs = year/4 *FOURYEAR_SECS;
+ remain = year%4;
+ secs += remain*YEAR_SECS;
+
+ if(remain == 0)
+ {
+ for(i = 0; i < month; ++i)
+ {
+ secs += leapMoth[i] *DAY_SECS;
+ }
+ }
+ else
+ {
+ for(i = 0; i < month; ++i)
+ {
+ secs += norMoth[i] *DAY_SECS;
+ }
+ }
+ secs += day*DAY_SECS;
+ secs += hour *HOUR_SECS;
+ secs += minute*MINUTE_SECS;
+ secs += second;
+ return secs;
+}
+
+uint8 sp_check_passwd(sp_pos_t* pos,const char* hint,uint8 passwd[6])
+{
+ uint8 temp[6];
+ uint8 offset = 0;
+ uint8 kcode;
+ uint32 ticker = sp_get_ticker();
+
+ show_manage_passwd(pos,hint,temp,offset);
+ while(sp_get_ticker() -ticker < DELAY_TIME60s)
+ {
+ sp_feed_dog();
+ kcode = sp_get_key();
+ if(kcode != SP_KEY_NONE)
+ {
+ switch(kcode)
+ {
+ case SP_KEY_0:
+ case SP_KEY_1:
+ case SP_KEY_2:
+ case SP_KEY_3:
+ case SP_KEY_4:
+ case SP_KEY_5:
+ case SP_KEY_6:
+ case SP_KEY_7:
+ case SP_KEY_8:
+ case SP_KEY_9:
+ if(offset < 6)
+ {
+ temp[offset++] = (uint8)(kcode-SP_KEY_0);
+ show_manage_passwd(pos,hint,temp,offset);
+ }
+ if(offset >= 6)
+ {
+ if(0 == MEMCMP(temp,passwd,6))
+ {
+ return 0;
+ }
+ else
+ {
+ disp_hint_info_two(pos,hint,"ÃÜÂë´íÎó",DELAY_TIME2s);
+ MEMCLEAR(temp, sizeof temp);
+ offset = 0;
+ }
+ }
+ break;
+ case SP_KEY_CLEAR:
+ if(offset == 0)
+ {
+ return 1;
+ }
+ --offset;
+ temp[offset] = 0;
+ show_manage_passwd(pos,hint,temp,offset);
+ break;
+ }
+ }
+ }
+ return 1;
+}
diff --git a/supwisdom/sp_util.h b/supwisdom/sp_util.h
new file mode 100644
index 0000000..d54b929
--- /dev/null
+++ b/supwisdom/sp_util.h
@@ -0,0 +1,70 @@
+#ifndef _SP_UTIL_H_
+#define _SP_UTIL_H_
+
+#include "string.h"
+#include "stdlib.h"
+#include "stdio.h"
+#include "sp_config.h"
+
+#define DELAY_TIME100ms 100
+#define DELAY_TIME200ms 200
+#define DELAY_TIME1s 1000
+#define DELAY_TIME2s 2000
+#define DELAY_TIME3s 3000
+#define DELAY_TIME15s 15000
+#define DELAY_TIME60s 60000
+#define COMM_WAIT_TIME 5000
+
+#define STR_COPY_N(x,y,z) do{snprintf(x,z+1,"%s",y);}while(0);
+#define MEMCLEAR(x,z) memset(x,0,z)
+#define MEMCMP(x,y,z) memcmp(x,y,z)
+#define MEMCPY(x,y,z) memcpy(x,y,z)
+#define IS_KEY(expect,val) (strncmp(expect,val,strlen(expect)) == 0)
+
+#define Dec2BCD(x) (((x) / 10) * 16 + (x) % 10)
+#define BCD2Dec(x) (((x) / 16) * 10 + (x) % 16)
+
+void sp_get_bcdtime(uint8 ctime[6]);
+void sp_set_bcdtime(uint8 ctime[6]);
+uint8 sp_check_time_valid(uint8 ctime[6]);
+uint8 sp_crc_sum(uint8 buf[],uint8 len);
+uint32 sp_get_ticker(void);
+void Delay_ms(uint32 ms);
+void sp_valve_on(void);
+void sp_valve_off(void);
+uint8 sp_valve_state(void);
+int16 get_2byte_int(uint8 value_str[2]);
+int32 get_3byte_int(uint8 value_str[3]);
+int32 get_4byte_int(uint8 value_str[4]);
+void set_2byte_int(uint8 value_str[2], int num);
+void set_3byte_int(uint8 value_str[3], int num);
+void set_4byte_int(uint8 value_str[4], int num);
+//»ñµÃµ¥×Ö½ÚÖÐijһλµÄÖµ
+int32 Get1Bit(uint8 buf, int n);
+int16 get_2byte_int_le(uint8 value_str[2]);
+//С×Ö½ÚÐò
+int32 get_3byte_int_le(uint8 value_str[3]);
+//С×Ö½ÚÐò
+int32 get_4byte_int_le(uint8 value_str[4]);
+void set_2byte_int_le(uint8 value_str[2], int num);
+void set_3byte_int_le(uint8 value_str[3], int num);
+/*¼ÆËã´Óstarttime µ½ÏÖÔÚµÄÃëÊý*/
+uint32 diff_time(uint8 starttime[6]);
+void mycpy(void* dest, const void* src, uint32 len);
+int32 sp_atoi(const char* src);
+void sp_bcd2asc(const uint8 bcdbuf[], uint8 bcdlen, uint8* ascstr);
+int format_time_covert_secs(uint8 ctime[6]);
+void sp_protocol_crc(const uint8* buf, uint16 len, uint8 crc[2]);
+void sp_protocol_crc_init(const uint8* buf, uint16 len,uint8 init[2], uint8 crc[2]);
+uint8 sp_get_key(void);
+uint8 sp_key_init(void);
+void sp_key_calibrate(void);
+void sp_reset(void);
+void sp_bcd_to_str(const uint8* bcd, uint8 bcd_len, char* str);
+void sp_str_to_bcd(const char* str, uint8 str_len, uint8* bcd);
+void sp_str_to_hex(const char* str,const uint16 len,uint8* hex);
+void sp_hex_to_str(const uint8* hex,const uint8 len,char* str);
+uint8 sp_check_passwd(sp_pos_t* pos,const char* hint,uint8 passwd[6]);
+int8 isFF(uint8 buf[],uint16 len);
+
+#endif
diff --git a/sys_hw/Crc.c b/sys_hw/Crc.c
new file mode 100644
index 0000000..1797439
--- /dev/null
+++ b/sys_hw/Crc.c
@@ -0,0 +1,83 @@
+#include "crc.h"
+
+static u16 const crc_table[] =
+{
+ //CRCTB1: ;?256??
+ 0x00000,0x01021,0x02042,0x03063,
+ 0x04084,0x050a5,0x060c6,0x070e7,
+ 0x08108,0x09129,0x0a14a,0x0b16b,
+ 0x0c18c,0x0d1ad,0x0e1ce,0x0f1ef,
+ 0x01231,0x00210,0x03273,0x02252,
+ 0x052b5,0x04294,0x072f7,0x062d6,
+ 0x09339,0x08318,0x0b37b,0x0a35a,
+ 0x0d3bd,0x0c39c,0x0f3ff,0x0e3de,
+ 0x02462,0x03443,0x00420,0x01401,
+ 0x064e6,0x074c7,0x044a4,0x05485,
+ 0x0a56a,0x0b54b,0x08528,0x09509,
+ 0x0e5ee,0x0f5cf,0x0c5ac,0x0d58d,
+ 0x03653,0x02672,0x01611,0x00630,
+ 0x076d7,0x066f6,0x05695,0x046b4,
+ 0x0b75b,0x0a77a,0x09719,0x08738,
+ 0x0f7df,0x0e7fe,0x0d79d,0x0c7bc,
+ 0x048c4,0x058e5,0x06886,0x078a7,
+ 0x00840,0x01861,0x02802,0x03823,
+ 0x0c9cc,0x0d9ed,0x0e98e,0x0f9af,
+ 0x08948,0x09969,0x0a90a,0x0b92b,
+ 0x05af5,0x04ad4,0x07ab7,0x06a96,
+ 0x01a71,0x00a50,0x03a33,0x02a12,
+ 0x0dbfd,0x0cbdc,0x0fbbf,0x0eb9e,
+ 0x09b79,0x08b58,0x0bb3b,0x0ab1a,
+ 0x06ca6,0x07c87,0x04ce4,0x05cc5,
+ 0x02c22,0x03c03,0x00c60,0x01c41,
+ 0x0edae,0x0fd8f,0x0cdec,0x0ddcd,
+ 0x0ad2a,0x0bd0b,0x08d68,0x09d49,
+ 0x07e97,0x06eb6,0x05ed5,0x04ef4,
+ 0x03e13,0x02e32,0x01e51,0x00e70,
+ 0x0ff9f,0x0efbe,0x0dfdd,0x0cffc,
+ 0x0bf1b,0x0af3a,0x09f59,0x08f78,
+ //CRCTB2: ;?256??
+ 0x09188,0x081a9,0x0b1ca,0x0a1eb,
+ 0x0d10c,0x0c12d,0x0f14e,0x0e16f,
+ 0x01080,0x000a1,0x030c2,0x020e3,
+ 0x05004,0x04025,0x07046,0x06067,
+ 0x083b9,0x09398,0x0a3fb,0x0b3da,
+ 0x0c33d,0x0d31c,0x0e37f,0x0f35e,
+ 0x002b1,0x01290,0x022f3,0x032d2,
+ 0x04235,0x05214,0x06277,0x07256,
+ 0x0b5ea,0x0a5cb,0x095a8,0x08589,
+ 0x0f56e,0x0e54f,0x0d52c,0x0c50d,
+ 0x034e2,0x024c3,0x014a0,0x00481,
+ 0x07466,0x06447,0x05424,0x04405,
+ 0x0a7db,0x0b7fa,0x08799,0x097b8,
+ 0x0e75f,0x0f77e,0x0c71d,0x0d73c,
+ 0x026d3,0x036f2,0x00691,0x016b0,
+ 0x06657,0x07676,0x04615,0x05634,
+ 0x0d94c,0x0c96d,0x0f90e,0x0e92f,
+ 0x099c8,0x089e9,0x0b98a,0x0a9ab,
+ 0x05844,0x04865,0x07806,0x06827,
+ 0x018c0,0x008e1,0x03882,0x028a3,
+ 0x0cb7d,0x0db5c,0x0eb3f,0x0fb1e,
+ 0x08bf9,0x09bd8,0x0abbb,0x0bb9a,
+ 0x04a75,0x05a54,0x06a37,0x07a16,
+ 0x00af1,0x01ad0,0x02ab3,0x03a92,
+ 0x0fd2e,0x0ed0f,0x0dd6c,0x0cd4d,
+ 0x0bdaa,0x0ad8b,0x09de8,0x08dc9,
+ 0x07c26,0x06c07,0x05c64,0x04c45,
+ 0x03ca2,0x02c83,0x01ce0,0x00cc1,
+ 0x0ef1f,0x0ff3e,0x0cf5d,0x0df7c,
+ 0x0af9b,0x0bfba,0x08fd9,0x09ff8,
+ 0x06e17,0x07e36,0x04e55,0x05e74,
+ 0x02e93,0x03eb2,0x00ed1,0x01ef0
+};
+
+u16 calcCRC( u8 *pBuffer, u16 BufferLength)
+{
+ u16 crc_reg = 0;
+
+ while (BufferLength--)
+ {
+ crc_reg = (crc_reg << 8) ^ crc_table[(crc_reg>>8) ^ *pBuffer++];
+ }
+
+ return crc_reg;
+}
diff --git a/sys_hw/Crc.h b/sys_hw/Crc.h
new file mode 100644
index 0000000..d385121
--- /dev/null
+++ b/sys_hw/Crc.h
@@ -0,0 +1,8 @@
+#ifndef __crc_h__
+#define __crc_h__
+
+#include "stm32f10x.h"
+
+extern u16 calcCRC( u8 *pBuffer, u16 BufferLength);
+
+#endif /* __crc_h__ */
diff --git a/sys_hw/Prj_FlashCfg.H b/sys_hw/Prj_FlashCfg.H
new file mode 100644
index 0000000..7c9beee
--- /dev/null
+++ b/sys_hw/Prj_FlashCfg.H
@@ -0,0 +1,1036 @@
+/*
+**************************************************************************************************************
+* FLASH Åä Öà ÎÄ ¼þ ¶¨ Òå
+*
+* Ãè Êö£ºFLASHÅäÖã»ÔÚʵ¼ÊÓ¦ÓÃÖУ¬×¢ÒâËùÑ¡ÐͺŵľßÌåÅäÖá£Èç¹û²»ÄÜÕý³£µÄÅäÖ㬲ο¼¾ßÌåµÄ²ÎÊýÏîÏÞÖÆ¡£
+*
+* Ãû ³Æ£ºPrj_FlashCfg.H
+*
+* °æ ±¾£ºV3.1
+*
+* ×÷ ÕߣºÕŽø
+*
+* ʱ ÆÚ£º2010/07/03
+*
+* Copyright (c) 2008-2009 Brand-NEW C.A.P Electronics Technology CO.,LTD
+**************************************************************************************************************
+*/
+
+#ifndef __Prj_FlashCfg_H__
+#define __Prj_FlashCfg_H__
+
+/*
+**************************************************************************************************************
+* Keil ²Ëµ¥ÅäÖÿªÊ¼
+**************************************************************************************************************
+*/
+
+//-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
+
+// <e>FLASHÅäÖà ©ï©ï©ï °æ±¾: V3.2 (2010/07/03) ©ï©ï©ï
+// =============================
+// <i> Enable or disable FLASHÅäÖÃ
+#define FLASH_CFG_ENABLE 1
+//
+//=============================================>> (1) <<======================================================
+// <e>1. FLASHÓ²¼þÅäÖÃ
+// <i> Enable or disable FLASHÓ²¼þÅäÖÃ
+#define FLASH_HW_CFG_ENABLE 1
+// ============================
+//
+// <s.15>FLASHÐͺÅ
+// <i> ¶¨ÒåËùʹÓõÄFLASHÐͺţ¬ÏÔʾÖÕ¶ËÐÅϢʱʹÓá£
+// <i> È磺AT45DB161D ÒªÇóСÓÚ15×Ö½Ú
+// <i> ĬÈÏ: "AT45DB161D"
+#define DEF_FLASH_NAME "W25X32"
+//
+// <o>FLASHÊÙÃü <5000=> 5000´Î <10000=> 1Íò´Î <20000=> 2Íò´Î
+// <30000=> 3Íò´Î <40000=> 4Íò´Î <50000=> 5Íò´Î
+// <60000=> 6Íò´Î <70000=> 7Íò´Î <80000=> 8Íò´Î
+// <90000=> 9Íò´Î <100000=> 10Íò´Î<10=> 10´Î
+// <i> ¶¨ÒåFLASHµÄÓÐЧÊÙÃü£¬Ó¦ÓÃÖÐÒÔ´ËÀ´½øÐÐÊÙÃü¼ÆËã
+// <i> ĬÈÏ: 50000
+#define DEF_FLASH_LimTimes 80000
+//
+// <o>FLASH×ÜÒ³Êý(Ò³) <1024-8192:1><#/1>
+// <i> ¶¨ÒåFLASHоƬµÄ×ÜÒ³Êý
+// <i> ĬÈÏ: 4096
+#define DEF_FLASH_Pages 1024
+//
+// <o>FLASHÒ³´óС(×Ö½Ú) <256-4096:1><#/1>
+// <i> ¶¨ÒåFLASHÒ»Ò³µÄ×Ö½ÚÊý
+// <i> ĬÈÏ: 528
+#define DEF_FLASH_PageSize 4096
+// </e>
+
+//=============================================>> (2) <<======================================================
+// <e>2. ºº×Ö¿âÅäÖÃ
+#define FLASH_GB1624_ENABLE 1
+
+//=============>> ºº×Ö¿âÇøÓò
+//=================>> 16*16×Ö¿â
+// <e>01. 16*16ºº×Ö¿â
+#define DEF_FLASH_GB1616_ENABLE 1
+
+#define DEF_FLASH_GB1616PageSize ( 67 ) //ÕâÀï¹Ì¶¨Öµ ×Ö¿â
+#define DEF_FLASH_GB1616StartAdd ( 0x00000000ul )
+//×ֿ⿪ʼµØÖ·
+#define DEF_FLASH_GB1616EndAdd ( DEF_FLASH_GB1616StartAdd + ( DEF_FLASH_GB1616PageSize * DEF_FLASH_PageSize * DEF_FLASH_GB1616_ENABLE ) )
+//×Ö¿â½áÊøµØÖ· ²»°üÀ¨´ËµØÖ·
+//=============>> ͼÐÎͼ±ê×Ö¿âÇøÓò
+#define DEF_FLASH_PhotoLibPageSize ( 5 ) //ÕâÀï¹Ì¶¨Öµ ͼÐÎͼ±ê
+#define DEF_FLASH_PhotoLibStartAdd ( DEF_FLASH_GB1616EndAdd )
+//ͼÐÎͼ±ê¿â¿ªÊ¼µØÖ·
+#define DEF_FLASH_PhotoLibEndAdd ( DEF_FLASH_PhotoLibStartAdd + ( DEF_FLASH_PhotoLibPageSize * DEF_FLASH_PageSize * DEF_FLASH_GB1616_ENABLE ) )
+//ͼÐÎͼ±ê¿â½áÊøµØÖ·
+// </e>
+
+//=================>> 24*24×Ö¿â
+// <e>02. 24*24ºº×Ö¿â
+#define DEF_FLASH_GB2424_ENABLE 1
+
+#define DEF_FLASH_GB2424PageSize ( 75 ) //24*24×Ö¿â
+
+#define DEF_FLASH_GB2424StartAdd ( DEF_FLASH_PhotoLibEndAdd )
+//×ֿ⿪ʼµØÖ·
+#define DEF_FLASH_GB2424EndAdd ( DEF_FLASH_GB2424StartAdd + ( DEF_FLASH_GB2424PageSize * DEF_FLASH_PageSize * DEF_FLASH_GB2424_ENABLE ) )
+// </e>
+
+
+// </e>
+
+//=============================================>> (3) <<======================================================
+// <e>3. IAPÉý¼¶¿Õ¼äÅäÖÃ
+#define FLASH_IAP_AppCode_ENABLE 1
+#define DEF_FLASH_IAP_AppCodeStartAdd ( DEF_FLASH_GB2424EndAdd )
+//Ó¦ÓôúÂë´æ´¢¿ªÊ¼µØÖ·
+//=====================
+//
+// <o>Éý¼¶´æ´¢Ó¦ÓôúÂë¿Õ¼ä´óС(Ò³) <3-1000:1><#/1>
+// <i>ĬÈÏ£º504
+#define DEF_FLASH_IAP_AppCodePageSize 128
+
+
+#define DEF_FLASH_IAP_AppCodeEndAdd ( DEF_FLASH_IAP_AppCodeStartAdd + \
+ ( DEF_FLASH_IAP_AppCodePageSize * \
+ DEF_FLASH_PageSize )*FLASH_IAP_AppCode_ENABLE )
+//Ó¦ÓôúÂë´æ´¢½áÊøµØÖ·
+// </e>
+
+//=============================================>> (4) <<======================================================
+// <e>4. FLASHÓû§ÎļþÅäÖÃ
+// <i> Enable or disable FLASH½»Ò׼ǼÅäÖÃ
+#define FLASH_UseFile_CFG_ENABLE 1
+
+#define DefCfg_UseFileStaAdd ( DEF_FLASH_IAP_AppCodeEndAdd )
+//FLASH½»Ò׼Ǽ´æ´¢µÄ¿ªÊ¼µØÖ·
+// ============================
+// <e>01. FLASHÓû§Îļþ01Çø
+#define DefCfg_UseFileBlock01_Sta 1
+// ============================
+// <o>Óû§ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_UseFile01_DirPageSize 4
+// ============================
+#define DefCfg_UseFile01_StaAdd ( DefCfg_UseFileStaAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_UseFile01_EndAdd ( DefCfg_UseFile01_StaAdd + \
+ ( DefCfg_UseFile01_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_UseFileBlock01_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// </e>
+// ============================
+// <e>02. FLASHÓû§Îļþ02Çø
+#define DefCfg_UseFileBlock02_Sta 1
+// ============================
+// <o>Óû§ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_UseFile02_DirPageSize 4
+// ============================
+#define DefCfg_UseFile02_StaAdd ( DefCfg_UseFile01_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_UseFile02_EndAdd ( DefCfg_UseFile02_StaAdd + \
+ ( DefCfg_UseFile02_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_UseFileBlock02_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// </e>
+// ============================
+// <e>03. FLASHÓû§Îļþ03Çø
+#define DefCfg_UseFileBlock03_Sta 1
+// ============================
+// <o>Óû§ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_UseFile03_DirPageSize 4
+// ============================
+#define DefCfg_UseFile03_StaAdd ( DefCfg_UseFile02_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_UseFile03_EndAdd ( DefCfg_UseFile03_StaAdd + \
+ ( DefCfg_UseFile03_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_UseFileBlock03_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// </e>
+// ============================
+// <e>04. FLASHÓû§Îļþ04Çø
+#define DefCfg_UseFileBlock04_Sta 1
+// ============================
+// <o>Óû§ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_UseFile04_DirPageSize 4
+// ============================
+#define DefCfg_UseFile04_StaAdd ( DefCfg_UseFile03_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_UseFile04_EndAdd ( DefCfg_UseFile04_StaAdd + \
+ ( DefCfg_UseFile04_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_UseFileBlock04_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// </e>
+// ============================
+// <e>05. FLASHÓû§Îļþ05Çø
+#define DefCfg_UseFileBlock05_Sta 1
+// ============================
+// <o>Óû§ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_UseFile05_DirPageSize 4
+// ============================
+#define DefCfg_UseFile05_StaAdd ( DefCfg_UseFile04_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_UseFile05_EndAdd ( DefCfg_UseFile05_StaAdd + \
+ ( DefCfg_UseFile05_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_UseFileBlock05_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// </e>
+// ============================
+// <e>06. FLASHÓû§Îļþ06Çø
+#define DefCfg_UseFileBlock06_Sta 1
+// ============================
+// <o>Óû§ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_UseFile06_DirPageSize 2
+// ============================
+#define DefCfg_UseFile06_StaAdd ( DefCfg_UseFile05_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_UseFile06_EndAdd ( DefCfg_UseFile06_StaAdd + \
+ ( DefCfg_UseFile06_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_UseFileBlock06_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// </e>
+// ============================
+// <e>07. FLASHÓû§Îļþ07Çø
+#define DefCfg_UseFileBlock07_Sta 1
+// ============================
+// <o>Óû§ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_UseFile07_DirPageSize 2
+// ============================
+#define DefCfg_UseFile07_StaAdd ( DefCfg_UseFile06_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_UseFile07_EndAdd ( DefCfg_UseFile07_StaAdd + \
+ ( DefCfg_UseFile07_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_UseFileBlock07_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// </e>
+// ============================
+// <e>08. FLASHÓû§Îļþ08Çø
+#define DefCfg_UseFileBlock08_Sta 0
+// ============================
+// <o>Óû§ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_UseFile08_DirPageSize 1
+// ============================
+#define DefCfg_UseFile08_StaAdd ( DefCfg_UseFile07_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_UseFile08_EndAdd ( DefCfg_UseFile08_StaAdd + \
+ ( DefCfg_UseFile08_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_UseFileBlock08_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// </e>
+// ============================
+// <e>09. FLASHÓû§Îļþ09Çø
+#define DefCfg_UseFileBlock09_Sta 0
+// ============================
+// <o>Óû§ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_UseFile09_DirPageSize 1
+// ============================
+#define DefCfg_UseFile09_StaAdd ( DefCfg_UseFile08_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_UseFile09_EndAdd ( DefCfg_UseFile09_StaAdd + \
+ ( DefCfg_UseFile09_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_UseFileBlock09_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// </e>
+// ============================
+// <e>10. FLASHÓû§Îļþ10Çø
+#define DefCfg_UseFileBlock10_Sta 0
+// ============================
+// <o>Óû§ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_UseFile10_DirPageSize 1
+// ============================
+#define DefCfg_UseFile10_StaAdd ( DefCfg_UseFile09_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_UseFile10_EndAdd ( DefCfg_UseFile10_StaAdd + \
+ ( DefCfg_UseFile10_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_UseFileBlock10_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// </e>
+
+
+#define DefCfg_UseFileEndAdd ( DefCfg_UseFile10_EndAdd )
+//FLASH½»Ò׼Ǽ´æ´¢µÄ½áÊøµØÖ·
+// </e>
+
+//=============================================>> (5) <<======================================================
+// <e>5. FLASH½»Ò׼ǼÅäÖÃ
+// <i> Enable or disable FLASH½»Ò׼ǼÅäÖÃ
+#define FLASH_Log_CFG_ENABLE 1
+
+#define DefCfg_LogFileStaAdd ( DefCfg_UseFileEndAdd )
+//FLASH½»Ò׼Ǽ´æ´¢µÄ¿ªÊ¼µØÖ·
+// ============================
+// <e>01. FLASH½»Ò׼Ǽ01Çø
+#define DefCfg_LogBlock01_Sta 1
+// ============================
+// <o>¼Ç¼Ŀ¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile01_DirPageSize 36
+// <o>¼Ç¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile01_PageSize 400
+// <o>¼Ç¼ÎļþÔ¤Áô´óС(Ò³) <1-10:1><#/1>
+#define DefCfg_LogFile01_PageRVS 2
+// <o>ÿһÌõ¼Ç¼³¤¶È,°üÀ¨CRC(×Ö½Ú) <3-300:1><#/1>
+#define DefCfg_LogFile01_RecLength 91
+// ============================
+#define DefCfg_LogDirFile01_StaAdd ( DefCfg_LogFileStaAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogDirFile01_EndAdd ( DefCfg_LogDirFile01_StaAdd + \
+ ( DefCfg_LogFile01_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock01_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// ============================
+#define DefCfg_LogFile01_StaAdd ( DefCfg_LogDirFile01_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogFile01_EndAdd ( DefCfg_LogFile01_StaAdd + \
+ ( DefCfg_LogFile01_PageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock01_Sta ) ) //¼Ç¼½áÊøµØÖ·
+#if( DefCfg_LogBlock01_Sta )
+#if( DefCfg_LogFile01_PageSize <= DefCfg_LogFile01_PageRVS )
+#error "1:·ÖÅäµÄ¼Ç¼×Ü´óС±ØÐë´óÓÚÔ¤Áô¼Ç¼´óС"
+#endif
+#endif
+// </e>
+
+// <e>02. FLASH½»Ò׼Ǽ02Çø
+#define DefCfg_LogBlock02_Sta 0
+// ============================
+// <o>¼Ç¼Ŀ¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile02_DirPageSize 256
+// <o>¼Ç¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile02_PageSize 1200
+// <o>¼Ç¼ÎļþÔ¤Áô´óС(Ò³) <1-10:1><#/1>
+#define DefCfg_LogFile02_PageRVS 10
+// <o>ÿһÌõ¼Ç¼³¤¶È,°üÀ¨CRC(×Ö½Ú) <3-300:1><#/1>
+#define DefCfg_LogFile02_RecLength 70
+// ============================
+#define DefCfg_LogDirFile02_StaAdd ( DefCfg_LogFile01_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogDirFile02_EndAdd ( DefCfg_LogDirFile02_StaAdd + \
+ ( DefCfg_LogFile02_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock02_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// ============================
+#define DefCfg_LogFile02_StaAdd ( DefCfg_LogDirFile02_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogFile02_EndAdd ( DefCfg_LogFile02_StaAdd + \
+ ( DefCfg_LogFile02_PageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock02_Sta ) ) //¼Ç¼½áÊøµØÖ·
+#if( DefCfg_LogBlock02_Sta )
+#if( DefCfg_LogFile02_PageSize <= DefCfg_LogFile02_PageRVS )
+#error "2:·ÖÅäµÄ¼Ç¼×Ü´óС±ØÐë´óÓÚÔ¤Áô¼Ç¼´óС"
+#endif
+#endif
+// </e>
+
+// <e>03. FLASH½»Ò׼Ǽ03Çø
+#define DefCfg_LogBlock03_Sta 0
+// ============================
+// <o>¼Ç¼Ŀ¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile03_DirPageSize 10
+// <o>¼Ç¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile03_PageSize 20
+// <o>¼Ç¼ÎļþÔ¤Áô´óС(Ò³) <1-10:1><#/1>
+#define DefCfg_LogFile03_PageRVS 3
+// <o>ÿһÌõ¼Ç¼³¤¶È,°üÀ¨CRC(×Ö½Ú) <3-300:1><#/1>
+#define DefCfg_LogFile03_RecLength 70
+// ============================
+#define DefCfg_LogDirFile03_StaAdd ( DefCfg_LogFile02_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogDirFile03_EndAdd ( DefCfg_LogDirFile03_StaAdd + \
+ ( DefCfg_LogFile03_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock03_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// ============================
+#define DefCfg_LogFile03_StaAdd ( DefCfg_LogDirFile03_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogFile03_EndAdd ( DefCfg_LogFile03_StaAdd + \
+ ( DefCfg_LogFile03_PageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock03_Sta ) ) //¼Ç¼½áÊøµØÖ·
+#if( DefCfg_LogBlock03_Sta )
+#if( DefCfg_LogFile03_PageSize <= DefCfg_LogFile03_PageRVS )
+#error "3:·ÖÅäµÄ¼Ç¼×Ü´óС±ØÐë´óÓÚÔ¤Áô¼Ç¼´óС"
+#endif
+#endif
+// </e>
+
+// <e>04. FLASH½»Ò׼Ǽ04Çø
+#define DefCfg_LogBlock04_Sta 0
+// ============================
+// <o>¼Ç¼Ŀ¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile04_DirPageSize 10
+// <o>¼Ç¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile04_PageSize 20
+// <o>¼Ç¼ÎļþÔ¤Áô´óС(Ò³) <1-10:1><#/1>
+#define DefCfg_LogFile04_PageRVS 3
+// <o>ÿһÌõ¼Ç¼³¤¶È,°üÀ¨CRC(×Ö½Ú) <3-300:1><#/1>
+#define DefCfg_LogFile04_RecLength 70
+// ============================
+#define DefCfg_LogDirFile04_StaAdd ( DefCfg_LogFile03_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogDirFile04_EndAdd ( DefCfg_LogDirFile04_StaAdd + \
+ ( DefCfg_LogFile04_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock04_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// ============================
+#define DefCfg_LogFile04_StaAdd ( DefCfg_LogDirFile04_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogFile04_EndAdd ( DefCfg_LogFile04_StaAdd + \
+ ( DefCfg_LogFile04_PageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock04_Sta ) ) //¼Ç¼½áÊøµØÖ·
+#if( DefCfg_LogBlock04_Sta )
+#if( DefCfg_LogFile04_PageSize <= DefCfg_LogFile04_PageRVS )
+#error "4:·ÖÅäµÄ¼Ç¼×Ü´óС±ØÐë´óÓÚÔ¤Áô¼Ç¼´óС"
+#endif
+#endif
+// </e>
+
+// <e>05. FLASH½»Ò׼Ǽ05Çø
+#define DefCfg_LogBlock05_Sta 0
+// ============================
+// <o>¼Ç¼Ŀ¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile05_DirPageSize 10
+// <o>¼Ç¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile05_PageSize 20
+// <o>¼Ç¼ÎļþÔ¤Áô´óС(Ò³) <1-10:1><#/1>
+#define DefCfg_LogFile05_PageRVS 3
+// <o>ÿһÌõ¼Ç¼³¤¶È,°üÀ¨CRC(×Ö½Ú) <3-300:1><#/1>
+#define DefCfg_LogFile05_RecLength 70
+// ============================
+#define DefCfg_LogDirFile05_StaAdd ( DefCfg_LogFile04_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogDirFile05_EndAdd ( DefCfg_LogDirFile05_StaAdd + \
+ ( DefCfg_LogFile05_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock05_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// ============================
+#define DefCfg_LogFile05_StaAdd ( DefCfg_LogDirFile05_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogFile05_EndAdd ( DefCfg_LogFile05_StaAdd + \
+ ( DefCfg_LogFile05_PageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock05_Sta ) ) //¼Ç¼½áÊøµØÖ·
+#if( DefCfg_LogBlock05_Sta )
+#if( DefCfg_LogFile05_PageSize <= DefCfg_LogFile05_PageRVS )
+#error "5:·ÖÅäµÄ¼Ç¼×Ü´óС±ØÐë´óÓÚÔ¤Áô¼Ç¼´óС"
+#endif
+#endif
+// </e>
+
+// <e>06. FLASH½»Ò׼Ǽ06Çø
+#define DefCfg_LogBlock06_Sta 0
+// ============================
+// <o>¼Ç¼Ŀ¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile06_DirPageSize 6
+// <o>¼Ç¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile06_PageSize 5
+// <o>¼Ç¼ÎļþÔ¤Áô´óС(Ò³) <1-10:1><#/1>
+#define DefCfg_LogFile06_PageRVS 3
+// <o>ÿһÌõ¼Ç¼³¤¶È,°üÀ¨CRC(×Ö½Ú) <3-300:1><#/1>
+#define DefCfg_LogFile06_RecLength 130
+// ============================
+#define DefCfg_LogDirFile06_StaAdd ( DefCfg_LogFile05_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogDirFile06_EndAdd ( DefCfg_LogDirFile06_StaAdd + \
+ ( DefCfg_LogFile06_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock06_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// ============================
+#define DefCfg_LogFile06_StaAdd ( DefCfg_LogDirFile06_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogFile06_EndAdd ( DefCfg_LogFile06_StaAdd + \
+ ( DefCfg_LogFile06_PageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock06_Sta ) ) //¼Ç¼½áÊøµØÖ·
+#if( DefCfg_LogBlock06_Sta )
+#if( DefCfg_LogFile06_PageSize <= DefCfg_LogFile06_PageRVS )
+#error "6:·ÖÅäµÄ¼Ç¼×Ü´óС±ØÐë´óÓÚÔ¤Áô¼Ç¼´óС"
+#endif
+#endif
+// </e>
+
+// <e>07. FLASH½»Ò׼Ǽ07Çø
+#define DefCfg_LogBlock07_Sta 0
+// ============================
+// <o>¼Ç¼Ŀ¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile07_DirPageSize 5
+// <o>¼Ç¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile07_PageSize 6
+// <o>¼Ç¼ÎļþÔ¤Áô´óС(Ò³) <1-10:1><#/1>
+#define DefCfg_LogFile07_PageRVS 3
+// <o>ÿһÌõ¼Ç¼³¤¶È,°üÀ¨CRC(×Ö½Ú) <3-300:1><#/1>
+#define DefCfg_LogFile07_RecLength 140
+// ============================
+#define DefCfg_LogDirFile07_StaAdd ( DefCfg_LogFile06_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogDirFile07_EndAdd ( DefCfg_LogDirFile07_StaAdd + \
+ ( DefCfg_LogFile07_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock07_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// ============================
+#define DefCfg_LogFile07_StaAdd ( DefCfg_LogDirFile07_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogFile07_EndAdd ( DefCfg_LogFile07_StaAdd + \
+ ( DefCfg_LogFile07_PageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock07_Sta ) ) //¼Ç¼½áÊøµØÖ·
+#if( DefCfg_LogBlock07_Sta )
+#if( DefCfg_LogFile07_PageSize <= DefCfg_LogFile07_PageRVS )
+#error "7:·ÖÅäµÄ¼Ç¼×Ü´óС±ØÐë´óÓÚÔ¤Áô¼Ç¼´óС"
+#endif
+#endif
+// </e>
+
+// <e>08. FLASH½»Ò׼Ǽ08Çø
+#define DefCfg_LogBlock08_Sta 0
+// ============================
+// <o>¼Ç¼Ŀ¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile08_DirPageSize 5
+// <o>¼Ç¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile08_PageSize 10
+// <o>¼Ç¼ÎļþÔ¤Áô´óС(Ò³) <1-10:1><#/1>
+#define DefCfg_LogFile08_PageRVS 4
+// <o>ÿһÌõ¼Ç¼³¤¶È,°üÀ¨CRC(×Ö½Ú) <3-300:1><#/1>
+#define DefCfg_LogFile08_RecLength 250
+// ============================
+#define DefCfg_LogDirFile08_StaAdd ( DefCfg_LogFile07_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogDirFile08_EndAdd ( DefCfg_LogDirFile08_StaAdd + \
+ ( DefCfg_LogFile08_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock08_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// ============================
+#define DefCfg_LogFile08_StaAdd ( DefCfg_LogDirFile08_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogFile08_EndAdd ( DefCfg_LogFile08_StaAdd + \
+ ( DefCfg_LogFile08_PageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock08_Sta ) ) //¼Ç¼½áÊøµØÖ·
+#if( DefCfg_LogBlock08_Sta )
+#if( DefCfg_LogFile08_PageSize <= DefCfg_LogFile08_PageRVS )
+#error "8:·ÖÅäµÄ¼Ç¼×Ü´óС±ØÐë´óÓÚÔ¤Áô¼Ç¼´óС"
+#endif
+#endif
+// </e>
+
+// <e>09. FLASH½»Ò׼Ǽ09Çø
+#define DefCfg_LogBlock09_Sta 0
+// ============================
+// <o>¼Ç¼Ŀ¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile09_DirPageSize 3
+// <o>¼Ç¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile09_PageSize 10
+// <o>¼Ç¼ÎļþÔ¤Áô´óС(Ò³) <1-10:1><#/1>
+#define DefCfg_LogFile09_PageRVS 4
+// <o>ÿһÌõ¼Ç¼³¤¶È,°üÀ¨CRC(×Ö½Ú) <3-300:1><#/1>
+#define DefCfg_LogFile09_RecLength 280
+// ============================
+#define DefCfg_LogDirFile09_StaAdd ( DefCfg_LogFile08_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogDirFile09_EndAdd ( DefCfg_LogDirFile09_StaAdd + \
+ ( DefCfg_LogFile09_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock09_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// ============================
+#define DefCfg_LogFile09_StaAdd ( DefCfg_LogDirFile09_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogFile09_EndAdd ( DefCfg_LogFile09_StaAdd + \
+ ( DefCfg_LogFile09_PageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock09_Sta ) ) //¼Ç¼½áÊøµØÖ·
+#if( DefCfg_LogBlock09_Sta )
+#if( DefCfg_LogFile09_PageSize <= DefCfg_LogFile09_PageRVS )
+#error "9:·ÖÅäµÄ¼Ç¼×Ü´óС±ØÐë´óÓÚÔ¤Áô¼Ç¼´óС"
+#endif
+#endif
+// </e>
+
+// <e>10. FLASH½»Ò׼Ǽ10Çø
+#define DefCfg_LogBlock10_Sta 0
+// ============================
+// <o>¼Ç¼Ŀ¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile10_DirPageSize 3
+// <o>¼Ç¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_LogFile10_PageSize 10
+// <o>¼Ç¼ÎļþÔ¤Áô´óС(Ò³) <1-10:1><#/1>
+#define DefCfg_LogFile10_PageRVS 3
+// <o>ÿһÌõ¼Ç¼³¤¶È,°üÀ¨CRC(×Ö½Ú) <3-300:1><#/1>
+#define DefCfg_LogFile10_RecLength 300
+// ============================
+#define DefCfg_LogDirFile10_StaAdd ( DefCfg_LogFile09_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogDirFile10_EndAdd ( DefCfg_LogDirFile10_StaAdd + \
+ ( DefCfg_LogFile10_DirPageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock10_Sta ) ) //¼Ç¼½áÊøµØÖ·
+// ============================
+#define DefCfg_LogFile10_StaAdd ( DefCfg_LogDirFile10_EndAdd ) //¼Ç¼¿ªÊ¼µØÖ·
+#define DefCfg_LogFile10_EndAdd ( DefCfg_LogFile10_StaAdd + \
+ ( DefCfg_LogFile10_PageSize * \
+ DEF_FLASH_PageSize * \
+ DefCfg_LogBlock10_Sta ) ) //¼Ç¼½áÊøµØÖ·
+#if( DefCfg_LogBlock10_Sta )
+#if( DefCfg_LogFile10_PageSize <= DefCfg_LogFile10_PageRVS )
+#error "10:·ÖÅäµÄ¼Ç¼×Ü´óС±ØÐë´óÓÚÔ¤Áô¼Ç¼´óС"
+#endif
+#endif
+// </e>
+#define DefCfg_LogFileEndAdd ( DefCfg_LogFile10_EndAdd )
+//FLASH½»Ò׼Ǽ´æ´¢µÄ½áÊøµØÖ·
+// </e>
+
+//=============================================>> (6) <<======================================================
+// <e>6. FLASHºÚÃûµ¥ÇøÅäÖÃ
+// <i> Enable or disable ºÚÃûµ¥ÇøÅäÖÃ
+#define BLACKLIST_CFG_ENABLE 1
+
+#define BLACKLIST_START_ADDRESS ( DefCfg_LogFileEndAdd )
+//ºÚÃûµ¥´æ´¢¿ªÊ¼µØÖ·
+#define FLASH_PAGE_SIZE ( DEF_FLASH_PageSize )
+
+//<e>1. µÚÒ»ºÚÃûµ¥ÇøÅäÖÃ
+// <i> Enable or disable ºÚÃûµ¥Çø¿éÅäÖã¨Ã¿¿éºÚÃûµ¥Çø°üº¬ÓжàÉÙ¿éFLASH¿é£©
+#define BLACKLIST1_CFG_ENABLE 1
+
+
+// <o>ºÚÃûµ¥Ä¿Â¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_BlkFile01_DirPageSize 20
+
+#define DefCfg_BlackFile01_StaAdd ( BLACKLIST_START_ADDRESS ) //ºÚÃû1µ¥¿ªÊ¼µØÖ·
+#define DefCfg_BlackFile01_EndAdd DefCfg_BlackFile01_StaAdd + ( FLASH_PAGE_SIZE * \
+ BLACKLIST1_CFG_ENABLE * \
+ DefCfg_BlkFile01_DirPageSize )
+//ºÚÃû1µ¥½áÊøµØÖ·
+#define BLACKLIST1_START_ADDRESS DefCfg_BlackFile01_EndAdd
+
+//
+// <o>ÿ¸öºÚÃûµ¥¿é°üº¬Flash¿éÒ³Êý <1=> 1Ò³ <2=> 2Ò³ <3=> 3Ò³ <4=> 4Ò³
+// <5=> 5ҳ <6=> 6ҳ <7=> 7ҳ
+// <i> ¶¨ÒåFLASHµÄÓÐЧÊÙÃü£¬Ó¦ÓÃÖÐÒÔ´ËÀ´½øÐÐÊÙÃü¼ÆËã
+// <i> ĬÈÏ: 10
+#define BLACKLIST1_PAGE_SIZE 1
+
+// <o>ºÚÃûµ¥ÇøËù·ÖÅäµÄºÚÃûµ¥¿éÊý <6-1000:2><#/1>
+// <i>ºÚÃûµ¥ÇøËù·ÖÅäµÄ´óС
+// <i>ĬÈÏ£º800
+#define BLACKLIST1_SECTION_SIZE 210
+
+// <o>ÿ¸öºÚÃûµ¥µÄ³¤¶È <3=> 3×Ö½Ú <4=> 4×Ö½Ú <5=> 5×Ö½Ú
+// <6=> 6×Ö½Ú <8=> 8×Ö½Ú
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º6
+#define BLACKLIST1_LENGTH 4
+
+// <o>ºÚÃûµ¥±È½Ï³¤¶È <3=> 3×Ö½Ú <4=> 4×Ö½Ú <5=> 5×Ö½Ú
+// <6=> 6×Ö½Ú <7=> 7×Ö½Ú <8=> 8×Ö½Ú
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º6
+#define BLACKLIST1_COMPARE_LENGTH 4
+
+// <o>ºÚÃûµ¥¶ÔÆë·½·¨ <0=> ×ó¶ÔÆë <1=> ÓÒ¶ÔÆë
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º1
+#define BLACKLIST1_FLUSH_METHOD 1
+
+// </e>
+
+
+//<e>2. µÚ¶þºÚÃûµ¥ÇøÅäÖÃ
+// <i> Enable or disable ºÚÃûµ¥Çø¿éÅäÖã¨Ã¿¿éºÚÃûµ¥Çø°üº¬ÓжàÉÙ¿éFLASH¿é£©
+#define BLACKLIST2_CFG_ENABLE 1
+
+
+//
+// <o>ºÚÃûµ¥Ä¿Â¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_BlkFile02_DirPageSize 6
+
+#define DefCfg_BlackFile02_StaAdd DefCfg_BlackFile01_EndAdd + ( FLASH_PAGE_SIZE * \
+ BLACKLIST1_CFG_ENABLE * \
+ BLACKLIST1_PAGE_SIZE * \
+ BLACKLIST1_SECTION_SIZE )
+//ºÚÃû1µ¥¿ªÊ¼µØÖ·
+#define DefCfg_BlackFile02_EndAdd DefCfg_BlackFile02_StaAdd + ( FLASH_PAGE_SIZE * \
+ BLACKLIST2_CFG_ENABLE * \
+ DefCfg_BlkFile02_DirPageSize )
+//ºÚÃû1µ¥½áÊøµØÖ·
+#define BLACKLIST2_START_ADDRESS DefCfg_BlackFile02_EndAdd
+
+
+
+// <o>ÿ¸öºÚÃûµ¥¿é°üº¬Flash¿éÊýÁ¿ <1=> 1Ò³ <2=> 2Ò³ <3=> 3Ò³ <4=> 4Ò³
+// <5=> 5ҳ <6=> 6ҳ <7=> 7ҳ
+// <i> ¶¨ÒåFLASHµÄÓÐЧÊÙÃü£¬Ó¦ÓÃÖÐÒÔ´ËÀ´½øÐÐÊÙÃü¼ÆËã
+// <i> ĬÈÏ: 10
+#define BLACKLIST2_PAGE_SIZE 1
+
+// <o>ºÚÃûµ¥ÇøËù·ÖÅäµÄºÚÃûµ¥¿éÊý <6-1000:2><#/1>
+// <i>ºÚÃûµ¥ÇøËù·ÖÅäµÄ´óС
+// <i>ĬÈÏ£º6
+#define BLACKLIST2_SECTION_SIZE 10
+
+// <o>ÿ¸öºÚÃûµ¥µÄ³¤¶È <2=> 2×Ö½Ú <3=> 3×Ö½Ú <4=> 4×Ö½Ú <5=> 5×Ö½Ú
+// <6=> 6×Ö½Ú <7=> 7×Ö½Ú <8=> 8×Ö½Ú
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º6
+#define BLACKLIST2_LENGTH 2
+
+// <o>ºÚÃûµ¥±È½Ï³¤¶È <2=> 2×Ö½Ú <3=> 3×Ö½Ú <4=> 4×Ö½Ú <5=> 5×Ö½Ú
+// <6=> 6×Ö½Ú <7=> 7×Ö½Ú <8=> 8×Ö½Ú
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º6
+#define BLACKLIST2_COMPARE_LENGTH 2
+
+// <o>ºÚÃûµ¥¶ÔÆë·½·¨ <0=> ×ó¶ÔÆë <1=> ÓÒ¶ÔÆë
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º1
+#define BLACKLIST2_FLUSH_METHOD 1
+
+// </e>
+
+//<e>3. µÚÈýºÚÃûµ¥ÇøÅäÖÃ
+// <i> Enable or disable ºÚÃûµ¥Çø¿éÅäÖã¨Ã¿¿éºÚÃûµ¥Çø°üº¬ÓжàÉÙ¿éFLASH¿é£©
+#define BLACKLIST3_CFG_ENABLE 0
+
+//
+// <o>ºÚÃûµ¥Ä¿Â¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_BlkFile03_DirPageSize 3
+
+#define DefCfg_BlackFile03_StaAdd DefCfg_BlackFile02_EndAdd + ( FLASH_PAGE_SIZE * \
+ BLACKLIST2_CFG_ENABLE * \
+ BLACKLIST2_PAGE_SIZE * \
+ BLACKLIST2_SECTION_SIZE )
+//ºÚÃû1µ¥¿ªÊ¼µØÖ·
+#define DefCfg_BlackFile03_EndAdd DefCfg_BlackFile03_StaAdd + ( FLASH_PAGE_SIZE * \
+ BLACKLIST3_CFG_ENABLE * \
+ DefCfg_BlkFile03_DirPageSize )
+//ºÚÃû1µ¥½áÊøµØÖ·
+#define BLACKLIST3_START_ADDRESS DefCfg_BlackFile03_EndAdd
+
+// <o>ÿ¸öºÚÃûµ¥¿é°üº¬Flash¿éÊýÁ¿ <4=> 4¿é <5=> 5¿é <6=> 6¿é <7=> 7¿é
+// <8=> 8¿é <9=> 9¿é <10=> 10¿é
+// <i> ¶¨ÒåFLASHµÄÓÐЧÊÙÃü£¬Ó¦ÓÃÖÐÒÔ´ËÀ´½øÐÐÊÙÃü¼ÆËã
+// <i> ĬÈÏ: 10
+#define BLACKLIST3_PAGE_SIZE 10
+
+// <o>ºÚÃûµ¥ÇøËù·ÖÅäµÄºÚÃûµ¥¿é´óС <6-1000:2><#/1>
+// <i>ºÚÃûµ¥ÇøËù·ÖÅäµÄ´óС
+// <i>ĬÈÏ£º6
+#define BLACKLIST3_SECTION_SIZE 8
+
+// <o>ÿ¸öºÚÃûµ¥µÄ³¤¶È <3=> 3×Ö½Ú <4=> 4×Ö½Ú <5=> 5×Ö½Ú
+// <6=> 6×Ö½Ú <7=> 7×Ö½Ú <8=> 8×Ö½Ú
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º6
+#define BLACKLIST3_LENGTH 4
+
+// <o>ºÚÃûµ¥±È½Ï³¤¶È <3=> 3×Ö½Ú <4=> 4×Ö½Ú <5=> 5×Ö½Ú
+// <6=> 6×Ö½Ú <7=> 7×Ö½Ú <8=> 8×Ö½Ú
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º6
+#define BLACKLIST3_COMPARE_LENGTH 4
+
+// <o>ºÚÃûµ¥¶ÔÆë·½·¨ <0=> ×ó¶ÔÆë <1=> ÓÒ¶ÔÆë
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º1
+#define BLACKLIST3_FLUSH_METHOD 1
+
+// </e>
+
+//<e>4. µÚËĺÚÃûµ¥ÇøÅäÖÃ
+// <i> Enable or disable ºÚÃûµ¥Çø¿éÅäÖã¨Ã¿¿éºÚÃûµ¥Çø°üº¬ÓжàÉÙ¿éFLASH¿é£©
+#define BLACKLIST4_CFG_ENABLE 0
+
+//
+// <o>ºÚÃûµ¥Ä¿Â¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_BlkFile04_DirPageSize 3
+
+#define DefCfg_BlackFile04_StaAdd DefCfg_BlackFile03_EndAdd + ( FLASH_PAGE_SIZE * \
+ BLACKLIST3_CFG_ENABLE * \
+ BLACKLIST3_PAGE_SIZE * \
+ BLACKLIST3_SECTION_SIZE )
+//ºÚÃû1µ¥¿ªÊ¼µØÖ·
+#define DefCfg_BlackFile04_EndAdd DefCfg_BlackFile04_StaAdd + ( FLASH_PAGE_SIZE * \
+ BLACKLIST4_CFG_ENABLE * \
+ DefCfg_BlkFile04_DirPageSize )
+//ºÚÃû1µ¥½áÊøµØÖ·
+#define BLACKLIST4_START_ADDRESS DefCfg_BlackFile04_EndAdd
+
+// <o>ÿ¸öºÚÃûµ¥¿é°üº¬Flash¿éÊýÁ¿ <4=> 4¿é <5=> 5¿é <6=> 6¿é <7=> 7¿é
+// <8=> 8¿é <9=> 9¿é <10=> 10¿é
+// <i> ¶¨ÒåFLASHµÄÓÐЧÊÙÃü£¬Ó¦ÓÃÖÐÒÔ´ËÀ´½øÐÐÊÙÃü¼ÆËã
+// <i> ĬÈÏ: 10
+#define BLACKLIST4_PAGE_SIZE 10
+
+// <o>ºÚÃûµ¥ÇøËù·ÖÅäµÄºÚÃûµ¥¿é´óС <6-1000:2><#/1>
+// <i>ºÚÃûµ¥ÇøËù·ÖÅäµÄ´óС
+// <i>ĬÈÏ£º6
+#define BLACKLIST4_SECTION_SIZE 8
+
+// <o>ÿ¸öºÚÃûµ¥µÄ³¤¶È <3=> 3×Ö½Ú <4=> 4×Ö½Ú <5=> 5×Ö½Ú
+// <6=> 6×Ö½Ú <7=> 7×Ö½Ú <8=> 8×Ö½Ú
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º6
+#define BLACKLIST4_LENGTH 4
+
+// <o>ºÚÃûµ¥±È½Ï³¤¶È <3=> 3×Ö½Ú <4=> 4×Ö½Ú <5=> 5×Ö½Ú
+// <6=> 6×Ö½Ú <7=> 7×Ö½Ú <8=> 8×Ö½Ú
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º6
+#define BLACKLIST4_COMPARE_LENGTH 4
+
+// <o>ºÚÃûµ¥¶ÔÆë·½·¨ <0=> ×ó¶ÔÆë <1=> ÓÒ¶ÔÆë
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º1
+#define BLACKLIST4_FLUSH_METHOD 1
+
+// </e>
+
+//<e>5. µÚÎåºÚÃûµ¥ÇøÅäÖÃ
+// <i> Enable or disable ºÚÃûµ¥Çø¿éÅäÖã¨Ã¿¿éºÚÃûµ¥Çø°üº¬ÓжàÉÙ¿éFLASH¿é£©
+#define BLACKLIST5_CFG_ENABLE 0
+
+//
+// <o>ºÚÃûµ¥Ä¿Â¼ÎļþËù·ÖÅäµÄ×Ü´óС(Ò³) <1-8196:1><#/1>
+#define DefCfg_BlkFile05_DirPageSize 3
+
+#define DefCfg_BlackFile05_StaAdd DefCfg_BlackFile04_EndAdd + ( FLASH_PAGE_SIZE * \
+ BLACKLIST4_CFG_ENABLE * \
+ BLACKLIST4_PAGE_SIZE * \
+ BLACKLIST4_SECTION_SIZE )
+//ºÚÃû1µ¥¿ªÊ¼µØÖ·
+#define DefCfg_BlackFile05_EndAdd DefCfg_BlackFile05_StaAdd + ( FLASH_PAGE_SIZE * \
+ BLACKLIST5_CFG_ENABLE * \
+ DefCfg_BlkFile05_DirPageSize )
+//ºÚÃû1µ¥½áÊøµØÖ·
+#define BLACKLIST5_START_ADDRESS DefCfg_BlackFile05_EndAdd
+
+// <o>ÿ¸öºÚÃûµ¥¿é°üº¬Flash¿éÊýÁ¿ <2=> 2¿é <4=> 4¿é <6=> 6¿é
+// <8=> 8¿é <10=> 10¿é <12=> 12¿é
+// <14=> 14¿é <16=> 16¿é <18=> 18¿é
+// <20=> 20¿é
+// <4096=> 4096Bytes <65536=> 64KBytes
+// <i> ¶¨ÒåFLASHµÄÓÐЧÊÙÃü£¬Ó¦ÓÃÖÐÒÔ´ËÀ´½øÐÐÊÙÃü¼ÆËã
+// <i> ĬÈÏ: 10
+#define BLACKLIST5_PAGE_SIZE 10
+
+// <o>ºÚÃûµ¥ÇøËù·ÖÅäµÄºÚÃûµ¥¿é´óС <6-1000:2><#/1>
+// <i>ºÚÃûµ¥ÇøËù·ÖÅäµÄ´óС
+// <i>ĬÈÏ£º6
+#define BLACKLIST5_SECTION_SIZE 8
+
+// <o>ÿ¸öºÚÃûµ¥µÄ³¤¶È <3=> 3×Ö½Ú <4=> 4×Ö½Ú <5=> 5×Ö½Ú
+// <6=> 6×Ö½Ú <7=> 7×Ö½Ú <8=> 8×Ö½Ú
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º6
+#define BLACKLIST5_LENGTH 4
+
+// <o>ºÚÃûµ¥±È½Ï³¤¶È <3=> 3×Ö½Ú <4=> 4×Ö½Ú <5=> 5×Ö½Ú
+// <6=> 6×Ö½Ú <7=> 7×Ö½Ú <8=> 8×Ö½Ú
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º6
+#define BLACKLIST5_COMPARE_LENGTH 4
+
+// <o>ºÚÃûµ¥¶ÔÆë·½·¨ <0=> ×ó¶ÔÆë <1=> ÓÒ¶ÔÆë
+// <i>ºÚÃûµ¥ÇøÊýÁ¿£¬À´Ó¦Óü¸¸öºÚÃûµ¥
+// <i>ĬÈÏ£º1
+#define BLACKLIST5_FLUSH_METHOD 1
+
+// </e>
+
+#define BLACKLIST_END_ADDRESS DefCfg_BlackFile05_EndAdd + ( FLASH_PAGE_SIZE * \
+ BLACKLIST5_CFG_ENABLE * \
+ BLACKLIST5_PAGE_SIZE * \
+ BLACKLIST5_SECTION_SIZE )
+
+//ºÚÃûµ¥´æ´¢½áÊøµØÖ·
+
+
+
+// </e>
+
+//=============================================>> (7) <<======================================================
+
+//=============================================>> (end) <<====================================================
+
+// </e>
+//------------- <<< end of configuration section >>> -----------------------
+
+/*
+**************************************************************************************************************
+* Keil ²Ëµ¥ÅäÖýáÊø
+**************************************************************************************************************
+*/
+
+/*
+**************************************************************************************************************
+* ¸¨ Öú Åä ÖÃ
+**************************************************************************************************************
+*/
+//========>>FLASH Ê£Óà
+#define DEF_FLASH_ResStartAdd ( BLACKLIST_END_ADDRESS )
+//Ê£ÓàFLASH¿Õ¼äµÄ¿ªÊ¼µØÖ·
+#define DEF_FLASH_ResEndAdd ( DEF_FLASH_Pages * DEF_FLASH_PageSize )
+//Ê£ÓàFLASH¿Õ¼äµÄ½áÊøµØÖ·
+#define DEF_FLASH_ResSize ( DEF_FLASH_ResEndAdd - DEF_FLASH_ResStartAdd )
+//Óû§¿ÉÒÔʹÓÃ×Ö½ÚÊý
+
+
+//========>>×î´ó¼Ç¼³¤¶È
+#define DEF_FLASH_MaxRecLength ( DefCfg_LogFile01_RecLength * DefCfg_LogBlock01_Sta )
+
+#if( DEF_FLASH_MaxRecLength < ( DefCfg_LogFile02_RecLength * DefCfg_LogBlock02_Sta ) )
+#undef DEF_FLASH_MaxRecLength
+#define DEF_FLASH_MaxRecLength ( DefCfg_LogFile02_RecLength * DefCfg_LogBlock02_Sta )
+#endif
+
+#if( DEF_FLASH_MaxRecLength < ( DefCfg_LogFile03_RecLength * DefCfg_LogBlock03_Sta ) )
+#undef DEF_FLASH_MaxRecLength
+#define DEF_FLASH_MaxRecLength ( DefCfg_LogFile03_RecLength * DefCfg_LogBlock03_Sta )
+#endif
+
+#if( DEF_FLASH_MaxRecLength < ( DefCfg_LogFile04_RecLength * DefCfg_LogBlock04_Sta ) )
+#undef DEF_FLASH_MaxRecLength
+#define DEF_FLASH_MaxRecLength ( DefCfg_LogFile04_RecLength * DefCfg_LogBlock04_Sta )
+#endif
+
+#if( DEF_FLASH_MaxRecLength < ( DefCfg_LogFile05_RecLength * DefCfg_LogBlock05_Sta ) )
+#undef DEF_FLASH_MaxRecLength
+#define DEF_FLASH_MaxRecLength ( DefCfg_LogFile05_RecLength * DefCfg_LogBlock05_Sta )
+#endif
+
+#if( DEF_FLASH_MaxRecLength < ( DefCfg_LogFile06_RecLength * DefCfg_LogBlock06_Sta ) )
+#undef DEF_FLASH_MaxRecLength
+#define DEF_FLASH_MaxRecLength ( DefCfg_LogFile06_RecLength * DefCfg_LogBlock06_Sta )
+#endif
+
+#if( DEF_FLASH_MaxRecLength < ( DefCfg_LogFile07_RecLength * DefCfg_LogBlock07_Sta ) )
+#undef DEF_FLASH_MaxRecLength
+#define DEF_FLASH_MaxRecLength ( DefCfg_LogFile07_RecLength * DefCfg_LogBlock07_Sta )
+#endif
+
+#if( DEF_FLASH_MaxRecLength < ( DefCfg_LogFile08_RecLength * DefCfg_LogBlock08_Sta ) )
+#undef DEF_FLASH_MaxRecLength
+#define DEF_FLASH_MaxRecLength ( DefCfg_LogFile08_RecLength * DefCfg_LogBlock08_Sta )
+#endif
+
+#if( DEF_FLASH_MaxRecLength < ( DefCfg_LogFile09_RecLength * DefCfg_LogBlock09_Sta ) )
+#undef DEF_FLASH_MaxRecLength
+#define DEF_FLASH_MaxRecLength ( DefCfg_LogFile09_RecLength * DefCfg_LogBlock09_Sta )
+#endif
+
+#if( DEF_FLASH_MaxRecLength < ( DefCfg_LogFile10_RecLength * DefCfg_LogBlock10_Sta ) )
+#undef DEF_FLASH_MaxRecLength
+#define DEF_FLASH_MaxRecLength ( DefCfg_LogFile10_RecLength * DefCfg_LogBlock10_Sta )
+#endif
+
+//========>>×î´óºÚÃûµ¥»º³åÇø³¤¶È
+#define DEF_FLASH_MaxBlkBufSize ( BLACKLIST1_CFG_ENABLE * BLACKLIST1_PAGE_SIZE * DEF_FLASH_PageSize )
+
+#if( DEF_FLASH_MaxBlkBufSize < ( BLACKLIST2_CFG_ENABLE * BLACKLIST2_PAGE_SIZE * DEF_FLASH_PageSize ) )
+#undef DEF_FLASH_MaxBlkBufSize
+#define DEF_FLASH_MaxBlkBufSize ( BLACKLIST2_CFG_ENABLE * BLACKLIST2_PAGE_SIZE * DEF_FLASH_PageSize )
+#endif
+
+#if( DEF_FLASH_MaxBlkBufSize < ( BLACKLIST3_CFG_ENABLE * BLACKLIST3_PAGE_SIZE * DEF_FLASH_PageSize ) )
+#undef DEF_FLASH_MaxBlkBufSize
+#define DEF_FLASH_MaxBlkBufSize ( BLACKLIST3_CFG_ENABLE * BLACKLIST3_PAGE_SIZE * DEF_FLASH_PageSize )
+#endif
+
+#if( DEF_FLASH_MaxBlkBufSize < ( BLACKLIST4_CFG_ENABLE * BLACKLIST4_PAGE_SIZE * DEF_FLASH_PageSize ) )
+#undef DEF_FLASH_MaxBlkBufSize
+#define DEF_FLASH_MaxBlkBufSize ( BLACKLIST4_CFG_ENABLE * BLACKLIST4_PAGE_SIZE * DEF_FLASH_PageSize )
+#endif
+
+#if( DEF_FLASH_MaxBlkBufSize < ( BLACKLIST5_CFG_ENABLE * BLACKLIST5_PAGE_SIZE * DEF_FLASH_PageSize ) )
+#undef DEF_FLASH_MaxBlkBufSize
+#define DEF_FLASH_MaxBlkBufSize ( BLACKLIST5_CFG_ENABLE * BLACKLIST5_PAGE_SIZE * DEF_FLASH_PageSize )
+#endif
+
+//========>>ÿ¿é¼ÇÂ¼Çø×î´æ´¢¼Ç¼ÊýÁ¿ ÀíÂÛÁ¿´óÖµ
+#define DEF_Rec01_MaxRecNum ( ( DefCfg_LogFile01_PageSize * DEF_FLASH_PageSize )/DefCfg_LogFile01_RecLength )
+#define DEF_Rec02_MaxRecNum ( ( DefCfg_LogFile02_PageSize * DEF_FLASH_PageSize )/DefCfg_LogFile02_RecLength )
+#define DEF_Rec03_MaxRecNum ( ( DefCfg_LogFile03_PageSize * DEF_FLASH_PageSize )/DefCfg_LogFile03_RecLength )
+#define DEF_Rec04_MaxRecNum ( ( DefCfg_LogFile04_PageSize * DEF_FLASH_PageSize )/DefCfg_LogFile04_RecLength )
+#define DEF_Rec05_MaxRecNum ( ( DefCfg_LogFile05_PageSize * DEF_FLASH_PageSize )/DefCfg_LogFile05_RecLength )
+#define DEF_Rec06_MaxRecNum ( ( DefCfg_LogFile06_PageSize * DEF_FLASH_PageSize )/DefCfg_LogFile06_RecLength )
+#define DEF_Rec07_MaxRecNum ( ( DefCfg_LogFile07_PageSize * DEF_FLASH_PageSize )/DefCfg_LogFile07_RecLength )
+#define DEF_Rec08_MaxRecNum ( ( DefCfg_LogFile08_PageSize * DEF_FLASH_PageSize )/DefCfg_LogFile08_RecLength )
+#define DEF_Rec09_MaxRecNum ( ( DefCfg_LogFile09_PageSize * DEF_FLASH_PageSize )/DefCfg_LogFile09_RecLength )
+#define DEF_Rec10_MaxRecNum ( ( DefCfg_LogFile10_PageSize * DEF_FLASH_PageSize )/DefCfg_LogFile10_RecLength )
+
+
+
+
+
+//=========>>¿Õ¼äÓÃÊÇʹÓÃÍê
+#if( DEF_FLASH_ResStartAdd > DEF_FLASH_Pages * DEF_FLASH_PageSize )
+#error "FLASH·ÖÅä¿Õ¼ä³¬ÏÞ"
+#endif
+
+
+/*
+**************************************************************************************************************
+* ¶Ô²¿·ÖÅäÖÃÐÅÏ¢½øÐмì²â
+*
+* ×¢ Ò⣺ ¶ÔÅäÖÃÐÅÏ¢½øÐмì²âÖ»ÊǼòµ¥µÄ¼ì²â£¬²»ÒªÍêÈ«ÒÀÀµ´Ë¼ì²â¡£ÓÐЩ´íÎóÊDz»Äܼì²âµ½µÄ£¬½øÐÐÅäÖÃÊ±Ó¦ÌØ±ðÁôÒâ¡£
+*
+**************************************************************************************************************
+*/
+
+//======================================>> ºÚÃûµ¥ÅäÖüì²â
+#if( ( BLACKLIST1_SECTION_SIZE % 2 ) != 0 )
+#error "µÚÒ»ºÚÃûµ¥Çø¿éÊý²»ÊÇżÊý£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+#if( ( BLACKLIST2_SECTION_SIZE % 2 ) != 0 )
+#error "µÚ¶þºÚÃûµ¥Çø¿éÊý²»ÊÇżÊý£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+#if( ( BLACKLIST3_SECTION_SIZE % 2 ) != 0 )
+#error "µÚÈýºÚÃûµ¥Çø¿éÊý²»ÊÇżÊý£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+#if( ( BLACKLIST4_SECTION_SIZE % 2 ) != 0 )
+#error "µÚËĺÚÃûµ¥Çø¿éÊý²»ÊÇżÊý£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+#if( ( BLACKLIST5_SECTION_SIZE % 2 ) != 0 )
+#error "µÚÎåºÚÃûµ¥Çø¿éÊý²»ÊÇżÊý£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+
+#if( ( ( FLASH_PAGE_SIZE * BLACKLIST1_PAGE_SIZE ) % BLACKLIST1_LENGTH ) != 0 )
+#error "µÚÒ»ºÚÃûµ¥ÇøÃ¿¿é²»ÄÜ´æÕûÊý¸öºÚÃûµ¥£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+#if( ( ( FLASH_PAGE_SIZE * BLACKLIST2_PAGE_SIZE ) % BLACKLIST2_LENGTH ) != 0 )
+#error "µÚ¶þºÚÃûµ¥ÇøÃ¿¿é²»ÄÜ´æÕûÊý¸öºÚÃûµ¥£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+#if( ( ( FLASH_PAGE_SIZE * BLACKLIST3_PAGE_SIZE ) % BLACKLIST3_LENGTH ) != 0 )
+#error "µÚÈýºÚÃûµ¥ÇøÃ¿¿é²»ÄÜ´æÕûÊý¸öºÚÃûµ¥£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+#if( ( ( FLASH_PAGE_SIZE * BLACKLIST4_PAGE_SIZE ) % BLACKLIST5_LENGTH ) != 0 )
+#error "µÚËĺÚÃûµ¥ÇøÃ¿¿é²»ÄÜ´æÕûÊý¸öºÚÃûµ¥£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+#if( ( ( FLASH_PAGE_SIZE * BLACKLIST5_PAGE_SIZE ) % BLACKLIST5_LENGTH ) != 0 )
+#error "µÚÎåºÚÃûµ¥ÇøÃ¿¿é²»ÄÜ´æÕûÊý¸öºÚÃûµ¥£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+
+
+#if( BLACKLIST1_COMPARE_LENGTH > BLACKLIST1_LENGTH )
+#error "µÚÒ»ºÚÃûµ¥ÇøºÚÃûµ¥±È½Ï³¤¶È±ÈºÚÃûµ¥³¤¶È´ó£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+#if( BLACKLIST2_COMPARE_LENGTH > BLACKLIST2_LENGTH )
+#error "µÚ¶þºÚÃûµ¥ÇøºÚÃûµ¥±È½Ï³¤¶È±ÈºÚÃûµ¥³¤¶È´ó£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+#if( BLACKLIST3_COMPARE_LENGTH > BLACKLIST3_LENGTH )
+#error "µÚÈýºÚÃûµ¥ÇøºÚÃûµ¥±È½Ï³¤¶È±ÈºÚÃûµ¥³¤¶È´ó£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+#if( BLACKLIST4_COMPARE_LENGTH > BLACKLIST4_LENGTH )
+#error "µÚËĺÚÃûµ¥ÇøºÚÃûµ¥±È½Ï³¤¶È±ÈºÚÃûµ¥³¤¶È´ó£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+#if( BLACKLIST5_COMPARE_LENGTH > BLACKLIST5_LENGTH )
+#error "µÚÎåºÚÃûµ¥ÇøºÚÃûµ¥±È½Ï³¤¶È±ÈºÚÃûµ¥³¤¶È´ó£¡Çëµ÷ÕûºÚÃûµ¥ÅäÖÃ"
+#endif
+
+
+
+
+#endif
+
diff --git a/sys_hw/data_tools.c b/sys_hw/data_tools.c
new file mode 100644
index 0000000..6ca8143
--- /dev/null
+++ b/sys_hw/data_tools.c
@@ -0,0 +1,247 @@
+#include "data_tools.h"
+
+u8 int2array(u32 val, void* dest, u8 len)
+{
+ u8 index = 0;
+
+ if(len>4) return 1;
+
+ for(index=0;index<len;index++)
+ *((u8 *)dest+index) = (u32)val>>((len-1-index)<<3);
+
+ return 0;
+}
+
+u8 array2int(void* src, void* pval, u8 len)
+{
+ u8 index = 0;
+
+ if(len>4) return 1;
+
+ for(index=0;index<len;index++)
+ {
+ *((u8*)pval+len-1-index) = *((u8 *)src+index);
+ }
+ return 0;
+}
+
+u8 mem_test(void* src, u8 val, int count)
+{
+ if(!count) return 0;
+
+ while(count--){
+ if(*(char *)src != val) return 1;
+ src = (char *)src +1;
+ }
+ return 0;
+}
+
+u8 mem_reverse(void* src, int count)
+{
+ u8 temp;
+ int i;
+ u8* pbuff = (u8 *)src;
+
+ if(!count) return 0;
+
+ for(i=0;i<count/2;i++)
+ {
+ temp = *(pbuff + i);
+ *(pbuff + i) = *(pbuff + count - 1 -i);
+ *(pbuff + count - 1 -i) = temp;
+ }
+ return 0;
+}
+
+/**********************************************
+bcdÊý¾Ýת»»ÎªhexÊý¾Ý
+***********************************************/
+void bcd2hex(void* bcd, u32 len)
+{
+ u32 i;
+ u8* pbuff = (u8 *)bcd;
+
+ for(i=0;i<len;i++)
+ {
+ *pbuff=((*pbuff)/16)*10+(*pbuff)%16;
+ pbuff++;
+ }
+}
+
+/*********************************************
+hexÊý¾Ýת»»Îªbcd
+**********************************************/
+void hex2bcd(void* hex, u32 len)
+{
+ u32 i;
+ u8* pbuff = (u8 *)hex;
+
+ for(i=0;i<len;i++)
+ {
+ *pbuff =(*pbuff/10)*16+(*pbuff)%10 ;
+ pbuff++ ;
+ }
+}
+
+static int char2bin(u8 c, u8* bin)
+{
+ if((c>='0') && (c<='9'))
+ {
+ *bin = c - '0';
+ }
+ else if((c>='a') && (c<='f'))
+ {
+ *bin = c - 'a' + 0x0A;
+ }
+ else if((c>='A') && (c<='F'))
+ {
+ *bin = c - 'A' + 0x0A;
+ }
+ else
+ {
+ return 1;
+ }
+ return 0;
+}
+
+int hex2bin(u8* in_buff, u8* out_buf, u32 len)
+{
+ u32 i;
+ u8 temp[2];
+
+ if(len&0x01) return 1;
+ for(i=0;i<len;)
+ {
+ char2bin(*(in_buff + i), &temp[0]);
+ char2bin(*(in_buff + i + 1), &temp[1]);
+ *(out_buf+(i>>1)) = (temp[0]<<4) + temp[1];
+ i += 2;
+ }
+ return 0;
+}
+
+int get_repetition_count(unsigned char* src, unsigned int src_left)
+{
+ unsigned int count = 0;
+ unsigned int i = 0;
+
+ while(i < src_left)
+ {
+ if(*src == *(src+i))
+ {
+ if(count<127)
+ {
+ count++;
+ }
+
+ }
+ else
+ {
+ break;
+ }
+ i ++;
+ }
+ return count;
+}
+
+int get_non_repetition_count(unsigned char* src, unsigned int src_left)
+{
+ unsigned int count = 0;
+
+ while(count < src_left)
+ {
+ if(get_repetition_count(src+count, src_left-count)<3)
+ {
+ if(count<127)
+ {
+ count++;
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+ return count;
+
+}
+
+/*
+ rle½âѹËõ
+*/
+int rle_decode(unsigned char *in_buf, int in_sz, unsigned char *out_buf, int out_buf_sz)
+{
+ unsigned char *src = in_buf;
+ int i;
+ int dec_sz = 0;
+
+ while(src < (in_buf + in_sz))
+ {
+ unsigned char sign = *src++;
+ int count = sign & 0x7F;
+ if((dec_sz + count) > out_buf_sz) /*Êä³ö»º³åÇø¿Õ¼ä²»¹»ÁË*/
+ {
+ return -1;
+ }
+ if((sign & 0x80) == 0x80) /*Á¬ÐøÖظ´Êý¾Ý±êÖ¾*/
+ {
+ for(i = 0; i < count; i++)
+ {
+ out_buf[dec_sz++] = *src;
+ }
+ src++;
+ }
+ else
+ {
+ for(i = 0; i < count; i++)
+ {
+ out_buf[dec_sz++] = *src++;
+ }
+ }
+ }
+
+ return dec_sz;
+}
+
+/*
+ rleѹËõ
+*/
+int rle_encode(unsigned char *in_buf, int in_sz, unsigned char *out_buf, int out_buf_sz)
+{
+ unsigned char *src = in_buf;
+ int i;
+ int enc_sz = 0;
+ int src_left = in_sz;
+
+ while(src_left > 0)
+ {
+ int count = get_repetition_count(src, src_left);
+
+ if(count>2) /*ÊÇ·ñÁ¬ÐøÈý¸ö×Ö½ÚÊý¾ÝÏàͬ£¿*/
+ {
+ if((enc_sz + 2) > out_buf_sz) /*Êä³ö»º³åÇø¿Õ¼ä²»¹»ÁË*/
+ {
+ return -1;
+ }
+ out_buf[enc_sz++] = count | 0x80;
+ out_buf[enc_sz++] = *src;
+ src += count;
+ src_left -= count;
+ }
+ else
+ {
+ count = get_non_repetition_count(src, src_left);
+ if((enc_sz + count + 1) > out_buf_sz) /*Êä³ö»º³åÇø¿Õ¼ä²»¹»ÁË*/
+ {
+ return -1;
+ }
+ out_buf[enc_sz++] = count;
+ for(i = 0; i < count; i++) /*Öð¸ö¸´ÖÆÕâЩÊý¾Ý*/
+ {
+ out_buf[enc_sz++] = *src++;;
+ }
+ src_left -= count;
+ }
+ }
+ return enc_sz;
+}
diff --git a/sys_hw/data_tools.h b/sys_hw/data_tools.h
new file mode 100644
index 0000000..018dc0d
--- /dev/null
+++ b/sys_hw/data_tools.h
@@ -0,0 +1,20 @@
+#ifndef __data_tools_h__
+#define __data_tools_h__
+
+#include "stm32f10x.h"
+
+extern u8 int2array(u32 val, void * dest, u8 len);
+extern u8 array2int(void * src, void* pval, u8 len);
+
+extern u8 mem_reverse(void * src, int count);
+extern u8 mem_test(void * src, u8 val, int count);
+
+extern void hex2bcd(void* hex, u32 len);
+extern void bcd2hex(void* bcd, u32 len);
+extern int hex2bin(u8* in_buff, u8* out_buf, u32 len);
+
+extern int rle_encode(unsigned char *in_buf, int in_sz, unsigned char *out_buf, int out_buf_sz);
+extern int rle_decode(unsigned char *in_buf, int in_sz, unsigned char *out_buf, int out_buf_sz);
+
+#endif /* __data_tools_h__ */
+
diff --git a/sys_hw/drv_adc.c b/sys_hw/drv_adc.c
new file mode 100644
index 0000000..ad54096
--- /dev/null
+++ b/sys_hw/drv_adc.c
@@ -0,0 +1,321 @@
+#include "drv_adc.h"
+#include "stm32f10x.h"
+#include "keypad.h"
+#include "string.h"
+#include "../supwisdom/sp_util.h"
+#include "../supwisdom/sp_flash.h"
+
+//#include "mifare_one_hw_lib.h"
+#include "timer.h"
+#include "data_tools.h"
+//#include "crc.h"
+//#include "dbg.h"
+
+#define PDDThreshod_Votage 80
+#define PDDThreshod_ADCVal (PDDThreshod_Votage*4095L/713L)
+
+#define Reset_Votage 74 //TPS54160Í£Ö¹¹¤×÷µçѹ7.1V
+#define Reset_ADCVal (Reset_Votage*4095L/713L)
+
+
+typedef void (*adc_timer_tick_t)(void);
+
+volatile uint8_t adc_timer;
+volatile uint8_t ch_idx;
+volatile uint16_t adc_val_vdd=4095;
+volatile uint16_t adc_val;
+dac_para_t dac_para = {890, 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, 0}; //dacÊä³öµçѹĬÈÏ3.3V
+adc_timer_tick_t p_adc_timer_tick = 0;
+volatile uint16_t adc_buff[ADC_MAX_CH_NUM];
+static const uint8_t adc_ch_tbl[ADC_MAX_CH_NUM] =
+{
+ ADC_Channel_9, //key_adc1,pb1
+ ADC_Channel_4, //key_adc2,pa4
+ ADC_Channel_1, //key_adc3,pa1
+ ADC_Channel_8, //key_adc4,pb0
+ ADC_Channel_3, //key_adc5,pa3
+ ADC_Channel_0, //key_adc6,pa0
+ ADC_Channel_15, //key_adc7,pc5
+ ADC_Channel_2, //key_adc8,pa2
+ ADC_Channel_13, //key_adc9,pc3
+ ADC_Channel_11, //key_adc10,pc1
+ ADC_Channel_10, //key_adc11,pc0
+ ADC_Channel_12, //key_adc12,pc2
+ ADC_Channel_6, //vcc_adc_in,pa6
+ ADC_Channel_14, //fa_adc_in,pc4
+ ADC_Channel_7 //hall_adc_in,pa7
+};
+
+void adc_timer_tick(void);
+static void timer4_init(void);
+
+static void adc_gpio_init(void)
+{
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |
+ RCC_APB2Periph_GPIOB |
+ RCC_APB2Periph_GPIOC, ENABLE);
+
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
+
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 |
+ GPIO_Pin_1 |
+ GPIO_Pin_2 |
+ GPIO_Pin_3 |
+ GPIO_Pin_4 |
+ GPIO_Pin_6 |
+ GPIO_Pin_7;
+ GPIO_Init(GPIOA, &GPIO_InitStructure);
+
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 |
+ GPIO_Pin_1;
+ GPIO_Init(GPIOB, &GPIO_InitStructure);
+
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 |
+ GPIO_Pin_1 |
+ GPIO_Pin_2 |
+ GPIO_Pin_3 |
+ GPIO_Pin_4 |
+ GPIO_Pin_5;
+ GPIO_Init(GPIOC, &GPIO_InitStructure);
+}
+
+static void adc_channels_init(void)
+{
+ ADC_InitTypeDef ADC_InitStructure;
+
+ RCC_ADCCLKConfig(RCC_PCLK2_Div6);
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
+
+ ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
+ ADC_InitStructure.ADC_ScanConvMode = DISABLE;
+ ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
+ ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
+ ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
+ ADC_InitStructure.ADC_NbrOfChannel = 1;
+ ADC_Init(ADC1, &ADC_InitStructure);
+ ADC1->CR2 |= 0x0010000;
+
+ //key adc 1 - 12
+ ch_idx = 0;
+ ADC_RegularChannelConfig(ADC1, adc_ch_tbl[ch_idx], 1,
+ ADC_SampleTime_239Cycles5);
+ ADC_Cmd(ADC1, ENABLE);
+
+ ADC_ResetCalibration(ADC1);
+ while(ADC_GetResetCalibrationStatus(ADC1));
+
+ ADC_StartCalibration(ADC1);
+ while(ADC_GetCalibrationStatus(ADC1));
+ ADC_SoftwareStartConvCmd(ADC1, ENABLE);
+ p_adc_timer_tick = adc_timer_tick;
+}
+
+static void adc_dma_init(void)
+{
+}
+
+static void adc_nvic_init(void)
+{
+
+}
+
+static void dac_init(void)
+{
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
+
+ DAC_DeInit();
+
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
+
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
+ GPIO_Init(GPIOA, &GPIO_InitStructure);
+
+
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
+
+ DAC->CR |= 0x00010000;
+ DAC_SetChannel2Data(DAC_Align_12b_R, dac_para.val[0]);
+}
+/**
+**У׼°´¼ü
+**/
+void calibrate_key(uint8 cache_enable)
+{
+ const uint8 len = sizeof(dac_para) +2;
+ uint8 buf[len];
+ if(cache_enable)
+ {
+ uint8 crc[2];
+ sp_flash_read(ADDR_KEY_PARA,buf,len);
+ sp_protocol_crc(buf ,len -2,crc);
+ if(memcmp(buf +len -2,crc,2) == 0)
+ {
+ memcpy((uint8*)&dac_para,buf,sizeof(dac_para));
+ return;
+ }
+ }
+ dac_para_auto_set();
+ memcpy(buf,(uint8*)&dac_para,sizeof(dac_para));
+ sp_protocol_crc(buf,len -2,buf +len -2);
+ sp_flash_erase(ADDR_KEY_PARA);
+ sp_flash_write(ADDR_KEY_PARA,buf,len);
+}
+
+void adc_init(void)
+{
+ timer4_init();
+ dac_init();
+ adc_gpio_init();
+ adc_nvic_init();
+ adc_dma_init();
+ adc_channels_init();
+ calibrate_key(1);
+}
+
+uint16_t adc_get_val(uint8_t ch)
+{
+ if(ch<ADC_MAX_CH_NUM)
+ {
+ return adc_buff[ch];
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+void adc_timer_tick(void)
+{
+ adc_timer ++;
+ if(adc_timer>=8)
+ {
+ adc_timer = 0;
+ }
+ if(adc_timer==0)
+ {
+ adc_buff[ch_idx] = ADC_GetConversionValue(ADC1);
+ ch_idx ++;
+ if(ch_idx >= ADC_MAX_CH_NUM)
+ {
+ keypad_scan();
+ ch_idx = 0;
+ }
+
+ if(ch_idx < 12)
+ {
+ DAC_SetChannel2Data(DAC_Align_12b_R, dac_para.val[ch_idx]);
+ }
+ }
+ else if(adc_timer == 7)
+ {
+ ADC_RegularChannelConfig(ADC1, adc_ch_tbl[ch_idx], 1,
+ ADC_SampleTime_239Cycles5);
+ ADC_SoftwareStartConvCmd(ADC1, ENABLE);
+ }
+}
+
+void adc_timer_task(void)
+{
+ if(p_adc_timer_tick)
+ {
+ //ÒѾ³õʼ»¯Íê³É
+ p_adc_timer_tick();
+ }
+}
+
+void dac_para_auto_set(void)
+{
+ uint8_t i;
+ uint16_t dac_val = 4095;
+ uint8_t adj_flags[12];
+
+ p_adc_timer_tick = 0;
+ delay_ms(10);
+ memset(adj_flags, 1, sizeof(adj_flags));
+ while((dac_val*3300ul*66/40950) > 2000) //ÔË·ÅÊä³ö²»µÍÓÚ2V
+ {
+ for(i=0; i<12; i++)
+ {
+ if(adj_flags[i])
+ {
+ dac_para.val[i] = dac_val;
+ }
+ DAC_SetChannel2Data(DAC_Align_12b_R, dac_val);
+ delay_ms(6);
+ ADC_RegularChannelConfig(ADC1, adc_ch_tbl[i], 1, ADC_SampleTime_239Cycles5);
+ ADC_SoftwareStartConvCmd(ADC1, ENABLE);
+ delay_ms(2);
+ if(ADC_GetConversionValue(ADC1) < 300ul)
+ {
+ adj_flags[i] = 0;
+ }
+ else
+ {
+ adj_flags[i] = 1;
+ }
+ }
+
+ if(mem_test(adj_flags, 0, sizeof(adj_flags)) == 0)
+ {
+ break;
+ }
+ dac_val -= 124;
+ }
+ p_adc_timer_tick = adc_timer_tick;
+
+}
+
+static void timer4_init(void)
+{
+ uint16_t PrescalerValue = 0;
+ TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
+ TIM_OCInitTypeDef TIM_OCInitStructure;
+
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ /* TIM4 clock enable */
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
+
+ /* GPIOA and GPIOB clock enable */
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO, ENABLE);
+
+ /*GPIOB Configuration: TIM4 channel3 and 4 */
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_Init(GPIOB, &GPIO_InitStructure);
+
+ PrescalerValue = (uint16_t)(SystemCoreClock / 72000000) - 1;
+ /* Time base configuration */
+ TIM_TimeBaseStructure.TIM_Period = 719;
+ TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
+ TIM_TimeBaseStructure.TIM_ClockDivision = 0;
+ TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
+
+ TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
+
+ /* PWM1 Mode configuration: Channel1 */
+ TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
+ TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
+ TIM_OCInitStructure.TIM_Pulse = 359;
+ TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
+ TIM_OC3Init(TIM4, &TIM_OCInitStructure);
+ TIM_OC3PreloadConfig(TIM4, TIM_OCPreload_Enable);
+
+ /* PWM1 Mode configuration: Channel2 */
+ TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
+ TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
+ TIM_OCInitStructure.TIM_Pulse = 359;
+ TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
+ TIM_OC4Init(TIM4, &TIM_OCInitStructure);
+ TIM_OC4PreloadConfig(TIM4, TIM_OCPreload_Enable);
+
+ TIM_ARRPreloadConfig(TIM4, ENABLE);
+
+ /* TIM4 enable counter */
+ TIM_Cmd(TIM4, ENABLE);
+}
diff --git a/sys_hw/drv_adc.h b/sys_hw/drv_adc.h
new file mode 100644
index 0000000..9de4c5d
--- /dev/null
+++ b/sys_hw/drv_adc.h
@@ -0,0 +1,29 @@
+#ifndef __adc_h__
+#define __adc_h__
+
+#include "stm32f10x.h"
+
+#define ADC_MAX_CH_NUM (15u)
+
+#pragma pack(push)
+#pragma pack(1)
+
+typedef struct
+{
+ volatile uint16_t val[12];
+ uint16_t crc;
+} dac_para_t;
+
+#pragma pack(pop)
+
+extern dac_para_t dac_para;
+
+extern volatile uint16_t adc_buff[ADC_MAX_CH_NUM];
+
+extern void adc_init(void);
+extern void adc_timer_task(void);
+extern uint16_t adc_get_val(uint8_t ch);
+extern void dac_para_auto_set(void);
+extern void calibrate_key(uint8_t force);
+
+#endif
diff --git a/sys_hw/drv_usart.h b/sys_hw/drv_usart.h
new file mode 100644
index 0000000..8cb22df
--- /dev/null
+++ b/sys_hw/drv_usart.h
@@ -0,0 +1,15 @@
+#ifndef __drv_usart_h__
+#define __drv_usart_h__
+
+#include "../../st_fw_lib/stm32f10x.h"
+#include "string.h"
+
+#define G401_UART5_FW_VER (0x0001)
+
+extern void usart_init(void);
+extern void usart_send(u8* buf, u8 len);
+extern u16 usart_read(u8* dest, u16 sz);
+extern void usart_isr_proc(void);
+extern void ComOverTimeProceed(void);
+
+#endif
diff --git a/sys_hw/keypad.c b/sys_hw/keypad.c
new file mode 100644
index 0000000..5599c40
--- /dev/null
+++ b/sys_hw/keypad.c
@@ -0,0 +1,195 @@
+#include "keypad.h"
+#include "string.h"
+#include "../supwisdom/sp_util.h"
+#include "drv_adc.h"
+//#include "timer.h"
+//#include "Include_All.H"
+//#include "glcd.h"
+//#include "dbg.h"
+
+#define __key_dbg_en__ 0
+#if(__key_dbg_en__)
+#define key_dbg(...) dbg(__VA_ARGS__)
+#else
+#define key_dbg(...)
+#endif
+
+#define KEY_DOWN_THRESHOLD 300u
+#define KEY_UP_THRESHOLD 100u
+
+struct key_sta_t
+{
+ volatile uint16_t adc_val_pre;
+ volatile uint16_t adc_val_last;
+ volatile uint16_t adc_val_now;
+ volatile uint16_t down_timer;
+ volatile uint8_t adc_chg_cnt;
+ volatile uint8_t is_pressed;
+ volatile uint8_t is_pressed_long;
+ volatile uint8_t long_pressed_timer;
+};
+
+struct
+{
+ volatile uint8_t is_inited;
+ volatile uint8_t lock;
+ volatile uint16_t key_value;
+ struct key_sta_t key_sta[MAX_KEY_NUM];
+} keypad;
+
+uint8_t keypad_init(void)
+{
+ uint8_t i;
+
+ keypad.is_inited = 0;
+ memset(&keypad, 0, sizeof(keypad));
+ Delay_ms(500);
+ for(i=0; i<MAX_KEY_NUM; i++)
+ {
+ keypad.key_sta[i].adc_val_pre = adc_get_val(i);
+ }
+ keypad.is_inited = 1;
+ return 0;
+}
+
+__weak void keypad_cb_on_preesed(uint8_t key_val)
+{
+
+}
+
+uint8_t keypad_get_key(void)
+{
+ if(keypad.key_value != KEY_NONE)
+ {
+ uint8_t temp = keypad.key_value;
+
+ keypad.key_value = KEY_NONE;
+ keypad_cb_on_preesed(temp);
+ return temp;
+ }
+ return KEY_NONE;
+}
+
+void keypad_scan(void)
+{
+ uint8_t i;
+ uint16_t max_delt = 0;
+ uint8_t key_idx = MAX_KEY_NUM;
+
+ key_dbg("\r\nsys_tick:%u\r\n", sys_timer_tick);
+ for(i=0; i<MAX_KEY_NUM; i++)
+ {
+ keypad.key_sta[i].adc_val_now = adc_get_val(i);
+ if(keypad.key_sta[i].adc_val_pre == 0)
+ {
+ keypad.key_sta[i].adc_val_pre = adc_get_val(i);
+ return;
+ }
+ if(keypad.key_sta[i].adc_val_last == 0)
+ {
+ keypad.key_sta[i].adc_val_last = adc_get_val(i);
+ return;
+ }
+
+ if(keypad.key_sta[i].down_timer)
+ {
+ keypad.key_sta[i].down_timer --;
+ if(!keypad.key_sta[i].down_timer)
+ {
+ keypad.key_sta[i].is_pressed = 0;
+ keypad.key_value = i+1;
+ keypad.key_sta[i].adc_val_last = keypad.key_sta[i].adc_val_now;
+ keypad.key_sta[i].adc_val_pre = keypad.key_sta[i].adc_val_now;
+ keypad.lock = 0;
+ }
+ }
+
+ if((keypad.key_sta[i].adc_val_now > keypad.key_sta[i].adc_val_last)&&(!keypad.key_sta[i].is_pressed)&&(!keypad.lock))
+ {
+ uint16_t temp_delt = keypad.key_sta[i].adc_val_now - keypad.key_sta[i].adc_val_last;
+
+ if(temp_delt > KEY_DOWN_THRESHOLD)
+ {
+ if(keypad.key_sta[i].adc_chg_cnt<10)
+ {
+ keypad.key_sta[i].adc_chg_cnt ++;
+ }
+
+ if(temp_delt>max_delt)
+ {
+ max_delt = temp_delt;
+ key_idx = i;
+ }
+ else
+ {
+ keypad.key_sta[i].adc_chg_cnt = 0;
+ }
+ }
+ else
+ {
+ keypad.key_sta[i].adc_val_last = keypad.key_sta[i].adc_val_pre;
+ keypad.key_sta[i].adc_val_pre = keypad.key_sta[i].adc_val_now;
+ keypad.key_sta[i].adc_chg_cnt = 0;
+ keypad.key_sta[i].is_pressed_long = 0;
+ }
+ }
+ else
+ {
+ if(keypad.key_sta[i].is_pressed)
+ {
+ if(keypad.key_sta[i].adc_val_now < keypad.key_sta[i].adc_val_pre)
+ {
+ if((keypad.key_sta[i].adc_val_pre - keypad.key_sta[i].adc_val_now) > KEY_UP_THRESHOLD)
+ {
+ keypad.key_sta[i].adc_chg_cnt ++;
+ }
+ }
+ else
+ {
+ keypad.key_sta[i].adc_chg_cnt = 0;
+ }
+
+ if(keypad.key_sta[i].adc_chg_cnt > 1)
+ {
+ keypad.key_value = i+1;
+ keypad.key_sta[i].adc_val_last = keypad.key_sta[i].adc_val_pre;
+ keypad.key_sta[i].adc_val_pre = keypad.key_sta[i].adc_val_now;
+ keypad.key_sta[i].adc_chg_cnt = 0;
+ keypad.key_sta[i].is_pressed = 0;
+ keypad.key_sta[i].down_timer = 0;
+ keypad.key_sta[i].is_pressed_long = 0;
+ keypad.lock = 0;
+ }
+ }
+ else
+ {
+ keypad.key_sta[i].adc_val_last = keypad.key_sta[i].adc_val_pre;
+ keypad.key_sta[i].adc_val_pre = keypad.key_sta[i].adc_val_now;
+ keypad.key_sta[i].adc_chg_cnt = 0;
+ keypad.key_sta[i].is_pressed_long = 0;
+ }
+ }
+ key_dbg("%02u:%4hu,%4hu,%4hu,%4hu,%4hhu,%4hhu,%4hhu,%4hhu\r\n", i,
+ keypad.key_sta[i].adc_val_pre,
+ keypad.key_sta[i].adc_val_last,
+ keypad.key_sta[i].adc_val_now,
+ keypad.key_sta[i].down_timer,
+ keypad.key_sta[i].adc_chg_cnt,
+ keypad.key_sta[i].is_pressed,
+ keypad.key_sta[i].is_pressed_long,
+ keypad.key_sta[i].long_pressed_timer);
+ }
+
+ if(key_idx<MAX_KEY_NUM)
+ {
+ if(keypad.key_sta[key_idx].adc_chg_cnt>0)
+ {
+ keypad.key_sta[key_idx].is_pressed = 1;
+ keypad.key_sta[key_idx].down_timer = 9; //°´¼üɨÃèÖÜÆÚ112ms£¬112*9ԼΪ1008ms
+ keypad.key_sta[key_idx].adc_chg_cnt = 0;
+ keypad.lock = 1;
+
+ keypad.key_sta[key_idx].adc_val_pre = keypad.key_sta[key_idx].adc_val_now;
+ }
+ }
+}
diff --git a/sys_hw/keypad.h b/sys_hw/keypad.h
new file mode 100644
index 0000000..65fd08f
--- /dev/null
+++ b/sys_hw/keypad.h
@@ -0,0 +1,27 @@
+#ifndef __keypad_h__
+#define __keypad_h__
+
+#include "stdint.h"
+
+#define MAX_KEY_NUM (12u)
+
+#define KEY_NONE ( 0u) //空é²ç¶æ??
+#define KEY_DIG0 (10u) //æ°åé?0
+#define KEY_DIG1 ( 1u) //æ°åé?1
+#define KEY_DIG2 ( 2u) //æ°åé?2
+#define KEY_DIG3 ( 3u) //æ°åé?3
+#define KEY_DIG4 ( 4u) //æ°åé?4
+#define KEY_DIG5 ( 5u) //æ°åé?5
+#define KEY_DIG6 ( 6u) //æ°åé?6
+#define KEY_DIG7 ( 7u) //æ°åé?7
+#define KEY_DIG8 ( 8u) //æ°åé?8
+#define KEY_DIG9 ( 9u) //æ°åé?9
+#define KEY_ENTER (12u) //确认é?
+#define KEY_CANCEL (11u) //åæ¶é?
+
+extern uint8_t keypad_init(void);
+extern uint8_t keypad_get_key(void);
+extern void keypad_scan(void);
+extern void keypad_cb_on_preesed(uint8_t key_val);
+
+#endif
diff --git a/sys_hw/rtc.c b/sys_hw/rtc.c
new file mode 100644
index 0000000..61f263c
--- /dev/null
+++ b/sys_hw/rtc.c
@@ -0,0 +1,165 @@
+#include "rtc.h"
+#include "time.h"
+#include "data_tools.h"
+#include "string.h"
+#include "timer.h"
+
+uint32_t CrystalStartErrFlag;
+
+static uint8_t rtc_wait_flag(uint32_t* reg, uint32_t mask, uint32_t flag, uint32_t timeout)
+{
+ uint32_t t = timeout/100;
+
+ while(((*reg)&mask) != flag)
+ {
+ delay_ms(100);
+ t --;
+ if(t == 0)
+ return 1;
+ }
+
+ return 0;
+}
+
+uint32_t rtc_get_counter(void)
+{
+ return (uint32_t)((RTC->CNTH << 16) | RTC->CNTL);
+}
+
+static uint8_t rtc_set_counter(uint32_t cnt)
+{
+ PWR->CR |= PWR_CR_DBP; // ʹÄÜ·ÃÎÊRTC, BDC ¼Ä´æÆ÷
+ RTC->CRL |=RTC_CRL_CNF; // ÉèÖÃRTCÅäÖñê¼Ç,ÔÊÐíÅäÖÃ
+ RTC->CNTH = (cnt>>16)&0xffff;
+ RTC->CNTL = cnt&0xffff ;
+ RTC->CRL &= ~RTC_CRL_CNF; // ÉèÖÃRTCÅäÖñê¼Ç,²»ÔÊÐíÅäÖÃ
+ if(rtc_wait_flag((uint32_t*)&RTC->CRL, RTC_FLAG_RTOFF, RTC_FLAG_RTOFF, 4000ul)) //µÈ´ýÅäÖÃÍê³É
+ {
+ PWR->CR &= ~PWR_CR_DBP; // ²»ÔÊÐíÅäÖÃRTC¡¢BDC¼Ä´æÆ÷
+ return 1;
+ }
+ PWR->CR &= ~PWR_CR_DBP; // ²»ÔÊÐíÅäÖÃRTC¡¢BDC¼Ä´æÆ÷
+ return 0;
+}
+
+void rtc_init(void)
+{
+ CrystalStartErrFlag = 0;
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
+
+ //RTCÊ×´ÎÉϵç»òʱÖÓ¶ªÊ§
+ if(BKP_ReadBackupRegister(BKP_DR1) != 0x5A5A)
+ {
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP, ENABLE);
+ PWR_BackupAccessCmd(ENABLE);
+ BKP_DeInit();
+ RCC_LSEConfig(RCC_LSE_ON);
+
+ //²ÎÕÕstm32f10x datasheet£¬LES startup time
+ //tsu(lse) = 3S (Typ)
+ //´Ë´¦µÈ´ýLSEÆðÕñÑÓʱԼ4S
+ if(rtc_wait_flag((uint32_t*)&RCC->BDCR, 0x02, 0x02, 4000ul))
+ CrystalStartErrFlag = 1;
+
+ if(!CrystalStartErrFlag)
+ {
+ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
+ RCC_RTCCLKCmd(ENABLE);
+ /* Clear RSF flag */
+ RTC->CRL &= (u16)~RTC_FLAG_RSF;
+ /* Loop until RSF flag is set */
+ if(rtc_wait_flag((uint32_t*)&RTC->CRL, RTC_FLAG_RSF, RTC_FLAG_RSF, 4000ul))
+ CrystalStartErrFlag = 1;
+
+ //rtc wait for last task
+ if(rtc_wait_flag((uint32_t*)&RTC->CRL, RTC_FLAG_RTOFF, RTC_FLAG_RTOFF, 4000ul))
+ CrystalStartErrFlag = 1;
+
+ RTC_SetPrescaler(32767);
+ //rtc wait for last task
+ if(rtc_wait_flag((uint32_t*)&RTC->CRL, RTC_FLAG_RTOFF, RTC_FLAG_RTOFF, 4000ul))
+ CrystalStartErrFlag = 1;
+
+ BKP_WriteBackupRegister(BKP_DR1, 0x5A5A);
+ }
+ PWR_BackupAccessCmd(DISABLE);
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP, DISABLE);
+ }
+ else
+ {
+ /* Clear RSF flag */
+ RTC->CRL &= (u16)~RTC_FLAG_RSF;
+ /* Loop until RSF flag is set */
+ if(rtc_wait_flag((uint32_t*)&RTC->CRL, RTC_FLAG_RSF, RTC_FLAG_RSF, 4000ul))
+ CrystalStartErrFlag = 1;
+ else
+ {
+ //0x386D4380ul 2000Äê1ÔÂ1ÈÕÃëÊý
+ if(rtc_get_counter()<0x386D4380ul)
+ {
+ rtc_set_counter(0x386D4380ul);
+ }
+
+// rtc_get_time(&SystemTime);
+ }
+ }
+}
+
+uint32_t rtc_mk_time(_SystemTime* t)
+{
+ struct tm temp_time;
+ _SystemTime temp_time_hex;
+
+ memcpy(&temp_time_hex, t, sizeof(_SystemTime));
+ bcd2hex(&temp_time_hex, sizeof(temp_time_hex));
+ temp_time.tm_year = temp_time_hex.year+100; //´Ó1900Ä꿪ʼ
+ temp_time.tm_mon = temp_time_hex.month-1;
+ temp_time.tm_mday = temp_time_hex.day;
+ temp_time.tm_wday = temp_time_hex.week;
+ temp_time.tm_hour = temp_time_hex.hour;
+ temp_time.tm_min = temp_time_hex.minute;
+ temp_time.tm_sec = temp_time_hex.second;
+
+ return mktime(&temp_time);
+}
+
+uint8_t rtc_set_time(_SystemTime* t)
+{
+ uint8_t ret = 0;
+ time_t seconds = rtc_mk_time(t);
+
+ ret = rtc_set_counter(seconds);
+
+ return ret;
+}
+
+uint8_t rtc_get_time(_SystemTime* t)
+{
+ struct tm* temp_time;
+ _SystemTime temp_time_bcd;
+ time_t seconds = rtc_get_counter();
+
+ temp_time = localtime(&seconds);
+ if(temp_time->tm_year<100)
+ temp_time_bcd.year = 0;
+ else
+ temp_time_bcd.year = temp_time->tm_year - 100;
+
+ temp_time_bcd.month = temp_time->tm_mon+1;
+ temp_time_bcd.day = temp_time->tm_mday;
+ temp_time_bcd.week = temp_time->tm_wday;
+ temp_time_bcd.hour = temp_time->tm_hour;
+ temp_time_bcd.minute = temp_time->tm_min;
+ temp_time_bcd.second = temp_time->tm_sec;
+ hex2bcd(&temp_time_bcd, sizeof(temp_time_bcd));
+ memcpy(t, &temp_time_bcd, sizeof(temp_time_bcd));
+ return 0;
+}
+
+uint32_t rtc_time_diff(void* t1, void* t2)
+{
+ uint32_t t1_sec = rtc_mk_time((_SystemTime*)t1);
+ uint32_t t2_sec = rtc_mk_time((_SystemTime*)t2);
+
+ return (t1_sec-t2_sec);
+}
diff --git a/sys_hw/rtc.h b/sys_hw/rtc.h
new file mode 100644
index 0000000..c62efc3
--- /dev/null
+++ b/sys_hw/rtc.h
@@ -0,0 +1,27 @@
+#ifndef __rtc_h__
+#define __rtc_h__
+
+#include "stm32f10x.h"
+
+//ϵͳʱ¼ä½á¹¹
+typedef struct
+{
+ uint8_t year; //Äê
+ uint8_t month; //ÔÂ
+ uint8_t day; //ÈÕ
+ uint8_t week; //ÐÇÆÚ
+ uint8_t hour; //ʱ
+ uint8_t minute; //·Ö
+ uint8_t second; //Ãë
+}_SystemTime ;
+
+//extern _SystemTime SystemTime,SystemTimeBak;
+
+extern void rtc_init(void);
+extern uint8_t rtc_set_time(_SystemTime* t);
+extern uint8_t rtc_get_time(_SystemTime* t);
+//extern uint32_t rtc_mk_time(_SystemTime* t);
+//extern uint32_t rtc_time_diff(void* t1, void* t2);
+//extern uint32_t rtc_get_counter(void);
+
+#endif
diff --git a/sys_hw/timer.c b/sys_hw/timer.c
new file mode 100644
index 0000000..b66ec32
--- /dev/null
+++ b/sys_hw/timer.c
@@ -0,0 +1,43 @@
+#include "timer.h"
+#include "icc_apdu_lib_v02.h"
+#include "HW_CAN_LIB.H"
+#include "drv_adc.h"
+#include "drv_valve.h"
+#include "drv_flowsensor.h"
+#include "drv_usart.h"
+
+//static vu32 timertick = 0;
+vu32 timertick = 0;
+
+void SysTick_cfg(void)
+{
+ SysTick_Config(SystemCoreClock/1000ul);
+}
+
+void TimerTick(void)
+{
+
+ update_sam_ticker();
+
+ adc_timer_task();
+
+ ComOverTimeProceed();
+ hw_can_sta_proc();
+
+ timertick++;
+
+ flowsensor_update_count();
+
+ valve_timer_dec();
+}
+
+u32 timer_get_ticker(void)
+{
+ return timertick;
+}
+void delay_ms(u32 t)
+{
+ u32 temp = timertick;
+
+ while((timertick - temp) < t);
+}
diff --git a/sys_hw/timer.h b/sys_hw/timer.h
new file mode 100644
index 0000000..072bdba
--- /dev/null
+++ b/sys_hw/timer.h
@@ -0,0 +1,11 @@
+#ifndef __timer_h__
+#define __timer_h__
+
+#include "stm32f10x.h"
+
+//extern void SysTick_cfg(void);
+extern void TimerTick(void);
+extern u32 timer_get_ticker(void);
+extern void delay_ms(u32 t);
+
+#endif
diff --git a/zk/gb2312_16.c b/zk/gb2312_16.c
new file mode 100644
index 0000000..579a90a
--- /dev/null
+++ b/zk/gb2312_16.c
@@ -0,0 +1,227 @@
+#include "glcd.h"
+//#include "timer.h"
+#include "../nec_hardware.h"
+#include "gb2312_16.h"
+#include "string.h"
+#include "stdio.h"
+
+uint8_t gb2312_16x16_draw_char(uint8_t x, uint8_t y, uint8_t buf[32])
+{
+ uint8_t i,j;
+
+ for(i=0;i<16;i++)
+ {
+ for(j=0;j<2;j++)
+ {
+ uint8_t dat,bit;
+
+ dat = buf[2*i+j];
+
+ if(glcd_get_reverse_sta())
+ dat = ~dat;
+
+ for(bit=0;bit<8;bit++)
+ {
+ if (dat & (0x80>>bit))
+ {
+ glcd_set_pixel(x+j*8+bit, y+i, BLACK);
+ }
+ else
+ {
+ glcd_set_pixel(x+j*8+bit, y+i,WHITE);
+ }
+ }
+ }
+ }
+
+ return 16;
+}
+
+void gb2312_16x16_get_data(uint8_t xy[2], uint8_t buf[32])
+{
+ uint32_t offset;
+
+ if((xy[0]<0xa1) || (xy[1])<0xa1)
+ return;
+
+ offset = (94*(xy[0] - 0xa1) + (xy[1] - 0xa1))*32ul;
+
+ HW_Flash_Read(offset+256, 32, buf);
+}
+
+uint8_t gb2312_16x8_draw_char(uint8_t x, uint8_t y, uint8_t buf[16])
+{
+ uint8_t i;
+
+ for(i=0;i<16;i++)
+ {
+ uint8_t dat,bit;
+
+ dat = buf[i];
+
+ if(glcd_get_reverse_sta())
+ dat = ~dat;
+ for(bit=0;bit<8;bit++)
+ {
+ if (dat & (0x80>>bit))
+ {
+ glcd_set_pixel(x+bit, y+i, BLACK);
+ }
+ else
+ {
+ glcd_set_pixel(x+bit, y+i,WHITE);
+ }
+ }
+ }
+
+ return 8;
+}
+
+void gb2312_16x8_get_data(uint8_t c, uint8_t buf[16])
+{
+ uint32_t offset;
+
+ offset = c*16ul + 0x43000;
+
+ HW_Flash_Read(offset, 16, buf);
+}
+
+void gb2312_16x16_test(void)
+{
+ uint32_t i,j;
+
+ HW_Flash_Init();
+ glcd_init();
+ glcd_clear();
+
+ for(i=0xa1;i<0xfe;i++)
+ {
+ uint8_t xy[2];
+
+ xy[0] = i;
+ for(j=0xa1;j<0xfe;j++)
+ {
+ uint8_t buf[32];
+
+ xy[1] = j;
+
+ gb2312_16x16_get_data(xy, buf);
+ gb2312_16x16_draw_char(0, 0, buf);
+ glcd_write();
+ delay_ms(100);
+ }
+ }
+}
+
+
+void gb2312_16x8_test(void)
+{
+ uint32_t i;
+
+ HW_Flash_Init();
+ glcd_init();
+ glcd_clear();
+
+ for(i=0;i<256;i++)
+ {
+ uint8_t buf[32];
+
+ gb2312_16x8_get_data(i, buf);
+ gb2312_16x8_draw_char(0, 0, buf);
+ glcd_write();
+ delay_ms(50);
+ }
+}
+
+uint8_t gb2312_16_get_ver(uint8_t ver[3])
+{
+ uint8_t temp_buff[20];
+
+ if(HW_Flash_Read(0, sizeof(temp_buff), temp_buff))
+ return 1;
+
+ if(memcmp(temp_buff, sk_font_id, 9))
+ return 2;
+
+ memcpy(ver, temp_buff+9, 3);
+ ver[0] -= '0';
+ ver[1] -= '0';
+
+ return 0;
+}
+
+void gb2312_16_draw_str(uint8_t x, uint8_t y, char* s)
+{
+ uint8_t i=0,j=0;
+
+ while(*s)
+ {
+ uint8_t buf[32];
+
+#if 1
+ if(x>=GLCD_LCD_WIDTH || y>=GLCD_LCD_HEIGHT)
+ return ;
+#else
+ if(x+i >= GLCD_LCD_WIDTH)
+ {
+ j += 16; //»»ÐÐ
+ i = 0; //»Ø³µ
+ }
+ if(y+j >= GLCD_LCD_HEIGHT)
+ {
+ j = 0;
+ i = 0;
+ }
+#endif
+ if((uint8_t)(*s)<128)
+ {
+ gb2312_16x8_get_data((uint8_t)*s, buf);
+ i += gb2312_16x8_draw_char(x+i, y+j, buf);
+ }
+ else
+ {
+ gb2312_16x16_get_data((uint8_t *)s, buf);
+ i += gb2312_16x16_draw_char(x+i, y+j, buf);
+ s ++;
+ }
+ s ++;
+ }
+}
+
+uint8_t gb2312_16_verify(void)
+{
+ const uint8_t font_01[32] =
+ {
+ 0x01, 0x00, 0x01, 0x00, 0x01, 0x08, 0x01, 0x10, 0x7D, 0x20, 0x05, 0xC0, 0x05, 0x40, 0x09, 0x20,
+ 0x09, 0x20, 0x11, 0x10, 0x11, 0x18, 0x21, 0x0E, 0xC1, 0x04, 0x01, 0x00, 0x05, 0x00, 0x02, 0x00
+ };
+ const uint8_t font_02[32] =
+ {
+ 0x10, 0x00, 0x10, 0x20, 0x10, 0x10, 0xFD, 0xFE, 0x11, 0x04, 0x10, 0x50, 0x14, 0x8C, 0x19, 0x04,
+ 0x30, 0x00, 0xD1, 0xFC, 0x10, 0x20, 0x10, 0x20, 0x10, 0x20, 0x10, 0x20, 0x53, 0xFE, 0x20, 0x00
+ };
+ const uint8_t font_03[16] =
+ {
+ 0x00, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
+ };
+ const uint8_t font_04[16] =
+ {
+ 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
+ };
+ uint8_t buf[32];
+
+ gb2312_16x16_get_data("ˮ", buf);
+ if(memcmp(buf, font_01, sizeof(font_01)))
+ return 1;
+ gb2312_16x16_get_data("¿Ø", buf);
+ if(memcmp(buf, font_02, sizeof(font_02)))
+ return 2;
+ gb2312_16x8_get_data('A', buf);
+ if(memcmp(buf, font_03, sizeof(font_03)))
+ return 3;
+ gb2312_16x8_get_data('B', buf);
+ if(memcmp(buf, font_04, sizeof(font_04)))
+ return 4;
+
+ return 0;
+}
diff --git a/zk/gb2312_16.h b/zk/gb2312_16.h
new file mode 100644
index 0000000..d41d8d9
--- /dev/null
+++ b/zk/gb2312_16.h
@@ -0,0 +1,15 @@
+#ifndef __gb2312_16_h__
+#define __gb2312_16_h__
+
+#include "stdint.h"
+#include "glcd.h"
+
+#define sk_font_id (char*)"sk_zk_16_v"
+
+extern uint8_t gb2312_16x8_draw_char(uint8_t x, uint8_t y, uint8_t buf[16]);
+extern uint8_t gb2312_16x16_draw_char(uint8_t x, uint8_t y, uint8_t buf[32]);
+extern void gb2312_16_draw_str(uint8_t x, uint8_t y, char* s);
+extern uint8_t gb2312_16_verify(void);
+extern uint8_t gb2312_16_get_ver(uint8_t ver[3]);
+
+#endif
diff --git a/zk/sk_zk_16_10A.hex b/zk/sk_zk_16_10A.hex
new file mode 100644
index 0000000..c5876eb
--- /dev/null
+++ b/zk/sk_zk_16_10A.hex
@@ -0,0 +1,8709 @@
+:20000000736B5F7A6B5F31365F313041002020202020202020202020202020202020202097
+:200020002020202020202020202020202020202020202020202020202020202020202020C0
+:200040002020202020202020202020202020202020202020202020202020202020202020A0
+:20006000202020202020202020202020202020202020202020202020202020202020202080
+:20008000202020202020202020202020202020202020202020202020202020202020202060
+:2000A000202020202020202020202020202020202020202020202020202020202020202040
+:2000C000202020202020202020202020202020202020202020202020202020202020202020
+:2000E000202020202020202020202020202020202020202020202020202020202020202000
+:200100000000000000000000000000000000000000000000000000000000000000000000DF
+:2001200000000000000000000000000000000000000000000000600030001000000000001F
+:200140000000000000000000000000000000000000000000300048004800300000000000AF
+:2001600000000000000000000000030007800780030000000000000000000000000000006B
+:200180000000000000007FFE000000000000000000000000000000000000000000000000E2
+:2001A000000008200820044004400280028001000000000000000000000000000000000062
+:2001C0000000000000000C600C600000000000000000000000000000000000000000000047
+:2001E00000000000000000000240024004800480090009001200240000000000000000002B
+:20020000040004000400080008001FF8200840100010082004400280010000C00040000034
+:200220000000000000000000000000000000FFFE00000000000000000000000000000000C1
+:2002400000000000000000000000000000003F0440F8000000000000000000000000000023
+:2002600002800280028002800280028002800280028002800280028002800280028002805E
+:20028000000000000000000000000000631863180000000000000000000000000000000068
+:2002A0000000000200040008000C000C000000000000000000000000000000000000000018
+:2002C00000006000600020004000800000000000000000000000000000000000000000007E
+:2002E0000000004400880110019801980000000000000000000000000000000000000000EF
+:200300000000019801980088011002200000000000000000000000000000000000000000F0
+:20032000000000040008001000100010001000100010001000100010001000080004000005
+:2003400000004000200010001000100010001000100010001000100010002000400000003D
+:20036000000000020004000800100020004000800040002000100008000400020000000001
+:20038000000080004000200010000800040002000400080010002000400080000000000063
+:2003A0000008001200240048009001200240048002400120009000480024001200080004C3
+:2003C000200090004800240012000900048002400480090012002400480090002000400025
+:2003E000000001C00100010001000100010001000100010001000100010001000000000030
+:200400000000010001000100010001000100010001000100010001000100070000000000C9
+:20042000000007C0044005C0050005000500050005000500050005000500070000000000B8
+:20044000000001C00140014001400140014001400140014001400740044007C00000000040
+:20046000000000FE00840088008800900090009000900090009000880088008400FE0000F8
+:200480000000FE00420022002200120012001200120012001200220022004200FE000000E8
+:2004A000000000FE00FC00F800F000F000E000E000E000E000F000F000F800FC00FE000018
+:2004C0000000FE007E003E001E001E000E000E000E000E001E001E003E007E00FE000000F8
+:2004E0000000000000000100010001000FE001000100010000000FE0000000000000000018
+:200500000000000000001010082004400280010002800440082010100000000000000000BE
+:2005200000000000000000000000010000001FF000000100000000000000000000000000AA
+:2005400000000000000000000300030000000000000003000300000000000000000000008F
+:2005600000000100028002800440044008200820101010102008200820084004400400005E
+:2005800000004004400420082008200810101010082008200440044002800280010000003E
+:2005A00000007FFC200410040800040002000100020004000800100420047FFC00000000B8
+:2005C00000003FF8101010101010101010101010101010101010101010101010783C0000B0
+:2005E0000000200820082008200820082008200820082008200820081010082007C0000034
+:20060000000007C00820101020082008200820082008200820082008200820082008000013
+:2006200000000780180020002000400040007F8040004000400020002000180007800000BD
+:2006400000000000000018301830000000000000000000001830183000000000000000007A
+:2006600000000000000000020004000800100020004000804100A20014000800000000007D
+:20068000000001000100010001000100010001000100010001000100010001001FF000003E
+:2006A0000240024002400240024002400480048004800480048009000900090009000900ED
+:2006C00000000004000800100020004000800100020004000800100020007FFC0000000064
+:2006E0000000000000000780186020102010400840084008000000000000000000000000C3
+:200700000000000007801860201020104008430843084008201020101860078000000000F5
+:20072000000000C001000100010001000100010001000100010001000100010006000000E7
+:20074000006000900080010001000780094009400A400A40078002000200040024001800AF
+:20076000000000000000000000007FFC00007FFC00007FFC00000000000000000000000008
+:20078000000000001870208841044104420422081C3000007FFC00007FFC000000000000ED
+:2007A000000000000000000000003804470800F03804470800F00000000000000000000043
+:2007C000000000000000000038784084410281028102410242043C3800000000000000005F
+:2007E00000000000000000003C7E4280410081008100410042803C7E00000000000000007D
+:20080000001000200020004000407FFC0080010002007FFC0400040008001000100020003F
+:20082000000004180460058006001C006400840064001C000600058004600418000000001E
+:20084000000030400C40034000C00070004C0042004C007000C003400C4030400000000060
+:20086000001800600180060018006000800060009800660019800660019800600018000013
+:2008800030000C00030000C00030000C0002000C003200CC03300CC033000C0030000000A3
+:2008A00000000000000000003C78428481028102810242843C7800000000000000000000BB
+:2008C000000000003030303000000000000000000000000000000300030000000000000052
+:2008E000000000000000030003000000000000000000000000003030303000000000000032
+:200900000000010003800540092011100100010001000100038004400440044003800000EE
+:20092000000003800440044004400380010001003FF80100010001000100010001000000A6
+:200940000000000030004800480030000000000000000000000000000000000000000000A7
+:2009600000000100010001000200020002000400000000000000000000000000000000006A
+:2009800000000220022002200440044004400880000000000000000000000000000000009D
+:2009A000200053F4240C0804080410001000100010001000100008040804040803F0000011
+:2009C00001000FE8111821082108210011000F0001E0011001082108210831102FE00100C5
+:2009E0000000400227E4181810082004200420042004200420041008181827E440020000F5
+:200A0000001000200FE810582048408040804100410042004200240814100FE010002000EA
+:200A200001C0022002200200020002003FE00200020002003A0046004204450438F8000047
+:200A4000000830104820484048804900320004000800118C2252425282520252018C0000B5
+:200A60000780084008C004000200030004800840084005800200010004800840084007809F
+:200A800060802140310031002918292429242924252425242524252423182300A17E4100A9
+:200AA000010001000280028002800440FC7E4004301808200820119016501830200800009D
+:200AC0000100010003800380038007C0FFFE3FF81FF00FE00FE01FF01EF018302008000016
+:200AE000000007C01830200820084004400440044004400420082008183007C000000000E4
+:200B0000000007C01FF03FF83FF87FFC7FFC7FFC7FFC7FFC3FF83FF81FF007C000000000E6
+:200B2000000007C0183027C8282850145014501450145014282827C8183007C00000000025
+:200B400001000280044008201010200840048002400420081010082004400280010000001D
+:200B60000100038007C00FE01FF03FF87FFCFFFE7FFC3FF81FF00FE007C003800100000082
+:200B800000007FFC400440044004400440044004400440044004400440047FFC0000000073
+:200BA00000007FFC7FFC7FFC7FFC7FFC7FFC7FFC7FFC7FFC7FFC7FFC7FFC7FFC00000000F6
+:200BC0000000010002800440044008200820101010102008200840044004FFFE00000000A5
+:200BE00000000100038007C007C00FE00FE01FF01FF03FF83FF87FFC7FFCFFFE0000000086
+:200C00000000430423081010082004400280610C628C044008201010230843048002000079
+:200C20000000000000000000000000200038FFFE0038002000000000000000000000000007
+:200C40000000000000000000000008003800FFFE3800080000000000000000000000000017
+:200C6000010001000380038007C0010001000100010001000100010001000100010001009A
+:200C80000100010001000100010001000100010001000100010007C003800380010001007A
+:200CA00000000000FFFCFFFCFFFCFFFC0000000000000000FFFCFFFCFFFCFFFC000000005C
+:200CC000000001000000010003000100010001000100010001000100010001000380000083
+:200CE00000000440000004400CC0044004400440044004400440044004400EE00000000092
+:200D000000001110000011103330111011101110111011101110111011103BB80000000033
+:200D2000000020000000271C62082208220821102110211020A020A020A0204070400000AF
+:200D40000000000000003838101010101010082008200440044002800280010001000000E5
+:200D600000000008000071C82098208820881108110811080A080A080A080408041C00007D
+:200D8000000000240000E3A4416C412441242224222422241424142414240824087E000005
+:200DA000000000540000E3D441FC41544154225422542254145414541454085408FE0000C5
+:200DC0000000400000004E1CC40844084210411040A0404040A0411042084404EE0E00008F
+:200DE00000000000000038381010082004400280010002800440082010102008701C0000B2
+:200E00000000000000000000000000000000000000000000000000000000000000000000D2
+:200E20000000000000000000000000000000000000000000000000000000000000000000B2
+:200E4000000000000000000000000000000000000000000000000000000000000000000092
+:200E6000000000000000000000000000000000000000000000000000000000000000000072
+:200E8000000000000000000000000000000000000000000000000000000000000000000052
+:200EA000000000000000000000000000000000000000000000000000000000000000000032
+:200EC0000000020006000A00020002000200020002000200020002000200020002400000AA
+:200EE00000000F001080108000800080008001000600080010001000108010801F90000045
+:200F000000000F001080108000800080010006000100008000801080108010800F100000CB
+:200F200000000300050005000500090009000900110011001FC00100010001000108010076
+:200F400000001F801000100010001000100017001880108000800080108010800F10000024
+:200F600000000F001080108010801000100017001880108010801080108010800F100000F4
+:200F800000001FC01040104000800100010001000200020002000200020002000208000039
+:200FA00000000F001080108010801080090006000900108010801080108010800F100000DB
+:200FC00000000F001080108010801080108011800E80008000801080108010800F10000044
+:200FE000000023C06420A420242024202420242024202420242024202420242023C8000033
+:20100000000020806180A2802080208020802080208020802080208020802080209000003D
+:20102000000023C06420A420202020202020204021802200240024002420242027E40000C7
+:20104000000023C06420A420202020202040218020402020202024202420242023C4000051
+:20106000000020C06140A14021402240224022402440244027F02040204020402048000020
+:20108000000027E06400A40024002400240025C026202420202020202420242023C4000077
+:2010A000000023C06420A42024202400240025C026202420242024202420242023C4000013
+:2010C000000027F06410A4102020204020402040208020802080208020802080208400000D
+:2010E000000023C06420A420242024202240218022402420242024202420242023C400009D
+:20110000000023C06420A420242024202420246023A02020202024202420242023C400005E
+:20112000000038E04510451005100510051019102110411041104110451045107CE4000057
+:201140000000400481028102810281028102810281028102810281028102810240040000E3
+:2011600000004004878288428842804280428042808283028402884288428FC24004000012
+:201180000000400487828842884280428082830280828042804288428842878240040000BE
+:2011A0000000418482828282828284828482888288828FE280828082808280824004000081
+:2011C000000040048FC28802880288028B828C4288428042804288428842878240040000D2
+:2011E00000004004878288428842880288028B828C428842884288428842878240040000AA
+:20120000000040048FE288228822804280828082808281028102810281028102400400002A
+:201220000000400487828842884288428842878288428842884288428842878240040000F1
+:20124000000040048782884288428842884288C287428042804288428842878240040000A1
+:201260000000400488E2891289128912891289128912891289128912891288E24004000004
+:201280000000400488228822882288228822882288228822882288228822882240040000CE
+:2012A0000000400491E29212921290129012902290C2910292029212921293F240040000AF
+:2012C0000000400491E2921292129012902290C29022901290129212921291E24004000074
+:2012E00000004004906290A290A290A2912291229222922293FA902290229022400400006D
+:201300000000400493F292029202920292E293129212901290129212921291E24004000048
+:201320000000400491E2921292129202920292E29312921292129212921291E24004000026
+:201340000000400493F29212921290229042904290429082908290829082908240040000B6
+:201360000000400491E2921292129212921291E29212921292129212921291E240040000C8
+:201380000000400491E29212921292129212923291D2901290129212921291E2400400009C
+:2013A000000040049C72A28AA28A828A828A848A888A908AA08AA28AA28ABE72400400003B
+:2013C00007C0183020084104410481028102810281028102410441042008183007C00000FC
+:2013E00007C01830200847C4444480428042818282028402444447C42008183007C00000C8
+:2014000007C01830200847C44444804280C2830280C28042444447C42008183007C00000AB
+:2014200007C0183020084304450485028502890289028FC2410441042008183007C00000AF
+:2014400007C01830200847C444048402840287C280428042444447C42008183007C000005F
+:2014600007C01830200847C444448402840287C284428442444447C42008183007C00000F7
+:2014800007C01830200847C4444480428082808281028102410441042008183007C00000F5
+:2014A00007C01830200847C4444484428442838284428442444447C42008183007C000007B
+:2014C00007C01830200847C444448442844287C280428042444447C42008183007C000001F
+:2014E00007C0183020084BE44A248A228A228A228A228A224A244BE42008183007C00000E8
+:201500000000000000000000000000000000000000000000000000000000000000000000CB
+:201520000000000000000000000000000000000000000000000000000000000000000000AB
+:201540000000200840048002800280028012BFFA8002800280028002800240042008000058
+:2015600000002008400480229FF280028002800280028012BFFA8002800240042008000009
+:201580000000200840249FF28002800280428FE2800280028012BFFA8002400420080000BA
+:2015A0000000200840048002BFFAA44AA44AA44AA44AA44ABFFA80028002400420080000B5
+:2015C0000000200840249FF28202820282229FF28422842284228422BFFA400420080000F4
+:2015E000000020084004820281028012BFFA80028002844284228812901240042008000015
+:20160000000020084204820282028212827A8382BE02820282028222822241E42008000062
+:201620000000200840848482848284828482848288428822901AA0128002400420080000E2
+:20164000000020084204820282429FE28242824282428442844A884A903A4004200800006B
+:20166000000020084104810281028112BFFA8102810281028102810281024004200800002D
+:2016800000000000000000000000000000000000000000000000000000000000000000004A
+:2016A00000000000000000000000000000000000000000000000000000000000000000002A
+:2016C0000000038001000100010001000100010001000100010001000100010003800000F8
+:2016E00000000EE00440044004400440044004400440044004400440044004400EE00000DE
+:2017000000003BB81110111011101110111011101110111011101110111011103BB8000057
+:201720000000771C220822082208211021102110211020A020A020A020A0204070400000C4
+:201740000000701C200810101010082008200820044004400440028002800100010000004B
+:20176000000071DC20882088208811081108110811080A080A080A080A080408041C00004C
+:201780000000E3FE412441244124222422242224222414241424142414240824087E00008F
+:2017A0000000E3FE41544154415422542254225422541454145414541454085408FE0000AF
+:2017C0000000EE0E440442084208411040A0404040A040A04110411042084404EE0E000090
+:2017E0000000701C200810100820044002800100028002800440082010102008701C0000E2
+:201800000000E0EE4044208411040A040A0404040A040A041104110420844044E0EE00005D
+:201820000000E0FE4054209411140A140A1404140A140A141114111420944054E0FE00005D
+:20184000000000000000000000000000000000000000000000000000000000000000000088
+:20186000000000000000000000000000000000000000000000000000000000000000000068
+:201880000000000000000000100010001000100010001000100010001000000010000000A8
+:2018A0000000000000000000000002400240024004800480048000000000000000000000D6
+:2018C000000000000440044004783FC004400440044004783FC004400440044000000000F2
+:2018E0000000383810100820044002800280010001000FE001000100010001000380000070
+:201900000000180424082410242024402480190002000460089010902090409000900060D8
+:2019200000000F0010801080108010800B0004001C002270412040A0404421A41E180000DB
+:201940001000100010002000200040000000000000000000000000000000000000000000D7
+:20196000000C00100020004000400080008000800080008000800040004000200010000CEF
+:2019800060001000080004000400020002000200020002000200040004000800100060003B
+:2019A00000000000010001002108111009200540010002800440082010100000000000005E
+:2019C00000000000010001000100010001001FF001000100010001000100000000000000EE
+:2019E000000000000000000000000000000000000000000000003000300010002000000057
+:201A000000000000000000000000000000001FF000000000000000000000000000000000B7
+:201A2000000000000000000000000000000000000000000000000000300030000000000046
+:201A400000000000000400080010002000400080010002000400080010002000000000004B
+:201A6000000007C008201010101010101010101010101010101010101010082007C0000048
+:201A80000000010003000500010001000100010001000100010001000100010007C000006C
+:201AA000000007C00820101010100010001000E00300040008001000101010101FF0000089
+:201AC00000000FE01010101000100020004001800040002000100010101010200FC0000047
+:201AE000000001800280028002800480048008800880108020803FF00080008003E0000085
+:201B000000001FF0100010001000100017C018201010001000100010101010200FC00000F8
+:201B2000000007C00820101010101000100017C018201010101010101010082007C00000D8
+:201B400000001FF010101010002000200040008000800100010001000200020002000000AD
+:201B6000000007C00820101010101010082007C008201010101010101010082007C0000090
+:201B8000000007C008201010101010101010083007D00010001010101010082007C0000078
+:201BA000000000000000000000000000000000000000300030000000300030000000000065
+:201BC000000000000000000000000000000000003000300000003000300010002000000015
+:201BE0000000000C003000C003000C003000400030000C00030000C00030000C000000002F
+:201C00000000000000000000000000001FF0000000001FF0000000000000000000000000A6
+:201C20000000600018000600018000600018000400180060018006001800600000000000B2
+:201C4000000000000000180024004200420004000800080008000800080000000800000090
+:201C6000000007C01820201046904988488848884888499046902064180807F000000000D4
+:201C800000000100028002800440044008200FE0101010102008701C0000000000000000AC
+:201CA00000007FE020102010201020203FC020202010201020107FE00000000000000000C7
+:201CC00000000FE01010200820002000200020002000200810100FE00000000000000000F6
+:201CE00000007FE02010200820082008200820082008200820107FE00000000000000000AE
+:201D000000007FFC20042004200020203FE020202000200420047FFC00000000000000005E
+:201D200000007FFC20042004200020203FE020202000200020007000000000000000000051
+:201D400000001FD02030401040004000400040384010401020101FE00000000000000000ED
+:201D60000000701C20082008200820083FF82008200820082008701C0000000000000000D4
+:201D8000000003800100010001000100010001000100010001000380000000000000000034
+:201DA00000000380010001000100010001000100010005000500020000000000000000008D
+:201DC000000071C021002200240038002400220021002080204070700000000000000000EC
+:201DE000000070002000200020002000200020002000200820087FF80000000000000000CC
+:201E00000000C006600C50144824444442844104400440044004E00E000000000000000073
+:201E20000000601C3008280824082208210820882048202820187008000000000000000037
+:201E4000000007C008201010200820082008200820081010082007C000000000000000009C
+:201E600000007FC020202010201020203FC020002000200020007000000000000000000054
+:201E8000000007C008201010200820082008200820081190086007C000300000000000006B
+:201EA00000007FC020202010201020203FC02400220021002080707000000000000000001D
+:201EC00000000FE810182008200010000FE000100008200830102FE000000000000000000D
+:201EE00000007FFC4104010001000100010001000100010001000380000000000000000097
+:201F00000000701C2008200820082008200820082008200810100FE00000000000000000E6
+:201F20000000701C20081010101008200820044004400280028001000000000000000000D0
+:201F40000000E38E410441044104228822882288145014500820082000000000000000002B
+:201F60000000701C101008200440028001000280044008201010701C00000000000000002C
+:201F80000000701C20081010082004400280010001000100010003800000000000000000F8
+:201FA00000003FF82010202000400080010002000400080810083FF8000000000000000054
+:201FC0000000000E00080008000800080008000800080008000800080008000E000000008D
+:201FE000000040002000100008000400020001000080004000200010000800040000000066
+:202000000000E00020002000200020002000200020002000200020002000E00000000000A0
+:202020000100028002800440044008200000000000000000000000000000000000000000EB
+:20204000000000000000000000000000000000000000000000000000000000007FFC000005
+:202060000000002000200010001000080008000400000000000000000000000000000000EC
+:2020800000000000000000000F80104000400F4010C0104010500FA00000000000000000A3
+:2020A000000008000800080008000BC00C200810081008100C200BC00000000000000000CA
+:2020C0000000000000000000000007C00820100010001010082007C00000000000000000E2
+:2020E0000000002000200020002007A00860102010201020086007A00000000000000000B2
+:20210000000000000000000000000F80104010401FC0100010200FC00000000000000000A2
+:202120000000010002800280020002000F80020002000200020002000200020002000000F7
+:20214000000000000000000007A00860102010201020086007A000200020084007800000C2
+:20216000000008000800080008000BC00C2008200820082008200820000000000000000080
+:20218000000001000100000001000100010001000100010001000100000000000000000035
+:2021A000000001000100000001000100010001000100010001000100050005000200000009
+:2021C00000000800080008000800088009000A000D0008800840082000000000000000003F
+:2021E000000003000100010001000100010001000100010001400180000000000000000012
+:20220000000000000000000000001AC00D20092009200920092009300000000000000000DA
+:20222000000000000000000000001B000C80088008800880088008C000000000000000000F
+:20224000000000000000000000000700088010401040104008800700000000000000000070
+:20226000000000000000000000001B800C400820082008200C400B80080008000800000010
+:20228000000000000000000003A00460082008200820046003A00020002000200030000028
+:2022A00000000000000000000000058002800200020002000200020000000000000000000D
+:2022C000000000000000000000000780084008000780004008400780000000000000000091
+:2022E00000000200020002000F8002000200020002000200028001000000000000000000BC
+:20230000000000000000000000000C40044004400440044004C0036000000000000000003A
+:202320000000000000000000000008200820044004400280028001000000000000000000C0
+:20234000000000000000000000001110092009200AA00AA00440044000000000000000002E
+:20236000000000000000000000000820044002800100028004400820000000000000000080
+:202380000000000000000000000008200440044002800100010002000200040008000000F9
+:2023A000000000000000000000000FC0084000800100020004400FC0000000000000000070
+:2023C000000400080008000800080008001000200010000800080008000800080004000065
+:2023E0000000010001000100010001000100010001000100010001000100010001000000CF
+:202400004000200020002000200020001000080010002000200020002000200040000000D4
+:20242000FFFE0000000000000000000000000000000000000000000000000000000000009F
+:202440000000000000000400042025C01E00048007E00C901488230822082510182000C02C
+:2024600004000400046047803C00044004401FF0244842844284410422841C08003000001F
+:202480000000000000000000000010001820101010081018101011000A0006000000000053
+:2024A00000000000000020203010200820042004200C20082100220014000C000000000075
+:2024C000000000000F8001800200000011C00E200020002000400080010002000C000000DC
+:2024E00000000F8000400180000021E01E100010001000100020002000C003000C0000001E
+:20250000000000000000070000800100000003C01C8001000300048008801040203800001C
+:2025200000000F0000800100000003C03C800100020003800480048008801040203C0000CA
+:202540000000000000000400041004083F04040807E004100C0814083408153008C0000094
+:2025600000000400041007883C04041805C006200C1014082408640835100CE00400000068
+:202580000000020002000220021043C83C440454044C044008400880108022804100000049
+:2025A00000100408042404100408878078A00890088808841094110C21004500820000003B
+:2025C00002000200026003801D0000E003801C40004003E0002010001000080007C0000004
+:2025E0000400040804C407123A0801C407003880008007C000402000200010000F800000BE
+:2026000000000100008000800100020004000800100008000400020001000080008000008B
+:202620000000020801040122021004080800100020001000080004000200010001000000F2
+:2026400000000080104010402040207827C0404040404040504050402040208001000000DA
+:2026600000080084105210482044207027C040404040404050405040204020800100000098
+:202680000000000010000FE0008003000400000020002000200010100FF80000000000002D
+:2026A0000000000010080FE4008203100408000420002000200010100FF8000000000000E3
+:2026C00000000400023002C03F0001000080004001E00820100010001000080007E00000DA
+:2026E00000000408020402D23F0801040080004001E00820100010001000080007E00000C0
+:20270000000018000C00080008000800080008000800080008100820084009800600000046
+:20272000000018100C080824081008080800080008000800081008200840098006000000D2
+:2027400000000300010001007FF801000700098009800980068000800100010002000C0044
+:2027600003080104011201087FF401000700098009800980068000800100010002000C0001
+:20278000000000801040084008400BFC7C40084008400840094008800800080007F0000066
+:2027A000000800841052084808440BF07C40084008400840094008800800080007F0000028
+:2027C000000010000F8001000200041008F81F002200440004000400020001F000000000C3
+:2027E000000810240F9201080200041008F81F002200440004000400020001F0000000005D
+:2028000000000400040047003C0009E0083008401000100012002200210840FC000000000B
+:2028200000080404041247083C0409E0083008401000100012002200210840FC00000000C1
+:20284000000002000200028003C07E00040007C004200C10081000100020002000C003007B
+:20286000000004080404051207887C0408000BC00C201810101000100020002000C00300C4
+:20288000000000000000000000000000000000C01F20081000100010002000400180000020
+:2028A00000000000000001E00610780820080008000800080010002000C00700000000006A
+:2028C00000080004001203C80C24F01040100010001000100020004001800E000000000070
+:2028E000000000000000000800FC7FC02100020004000400040004000400020001F000006B
+:20290000000000000000000800FC7FC02108020404120408040404000400020001F0000020
+:202920000000000002000100010001300160018006000800100010001000080007E0000053
+:202940000008000402120108010401300160018006000800100010001000080007E0000009
+:20296000000000000C20041007087C182440084008401040104023E0445004480384000076
+:20298000000020001000101C13E820102020200040004A004A005200510860FC4000000035
+:2029A0000000020001002100110017F01908110431044A044A74448C44944A6230000000E0
+:2029C000000010000800080008601E9069100A100C101810281048F0A918292418C2000092
+:2029E00000000000000007C0193021084204420442044404440828081010002000C0000008
+:202A00000000208010401050107827C02040204040404840484053C054706448438400005D
+:202A20000008208410521048107427C02040204040404840484053C054706448438400002B
+:202A4000000C20921052104C107027C02040204040404840484053C05470644843840000F9
+:202A60000000000002003E2004200830082810241020202020402040204010800F00000007
+:202A80000008000402123E2804240830082810241020202020402040204010800F000000BD
+:202AA000000C001202123E2C04200830082810241020202020402040204010800F0000008B
+:202AC00000000200018000C0010002000200010000E003980484088C789026800100000067
+:202AE00000080204019200C8010402000200010000E003980484088C78902680010000001D
+:202B0000000C0212019200CC010002000200010000E003980484088C7890268001000000EA
+:202B2000000000000000000007000880104060200018000600000000000000000000000018
+:202B40000000000800040012070808841040602000180006000000000000000000000000CE
+:202B6000000000180024002407180880104060200018000600000000000000000000000060
+:202B80000000207017C010401040204027F8204040404840484051C052706248418400007D
+:202BA000000820E4175210481044204027F8204040404840484051C0527062484184000043
+:202BC000000020EC17521052104C204027F0204040404840484051C0527062484184000019
+:202BE00000000100010001F03F00010001E01F000100010001001D0023C021301E08000028
+:202C00000000000013800C80008001000110011002101A1027A044704828304400800100D6
+:202C2000000008000400049007C87C04040C1C102400240024101C100810081807F0000092
+:202C4000000001001080108010801FC01120291045084208450848103010002000C000001E
+:202C6000020002000200020023C01E000410040844C83F08040804080408040803F00000B5
+:202C8000000000000200010000800080033024481F88020802080170010000800080004025
+:202CA000000002000180004006400980103011C87E04080408880470020002000100008052
+:202CC00000000000000001000080008011E012901488148818881A88119010E00100020052
+:202CE000000000801040104010F81144224424442444244428442A44315810E000800300E3
+:202D000000000000000002000100013001C001000100010001000FC0113011080E00000083
+:202D200000000200010001000110013801C00100010001001F0021C0413042083C04000086
+:202D400000001C0002000200040008001000100010E01310140818080008003000C00300DD
+:202D600000001000088009400A200A201220142014201820084000400080008001000200C1
+:202D8000000000400FA0002000400080010002F007080804100403840444042803F0000054
+:202DA00000000800082008500E8879080A100C1008101810281028126814180808000000E8
+:202DC000000003C01C4000800100020004E00F1018082008000800100010006001800000FD
+:202DE0000000000008000400040007003CF007080C081408240834100C2004C000000000F1
+:202E000000001000080008004F0038000BE00C18080418042804480468081810086000005C
+:202E20000000000003801C8000800100010003F00F0812042204446438940088007000003F
+:202E400000000FC00080010003E006100810139024A003C00200040018382644418800005E
+:202E600000000200010001E01F000108020C03D0046008C0114002400240020001F8000069
+:202E800000000200010001000100020002000280034002400422042204240424041800006A
+:202EA000000000000000000000000000000000000000000000000000000000000000000012
+:202EC0000000000000000000000000000000000000000000000000000000000000000000F2
+:202EE0000000000000000000000000000000000000000000000000000000000000000000D2
+:202F00000000000000000000000000000000000000000000000000000000000000000000B1
+:202F2000000000000000000000000000000000000000000000000000000000000000000091
+:202F4000000000000000000000000000000000000000000000000000000000000000000071
+:202F6000000000000000000000000000000000000000000000000000000000000000000051
+:202F8000000000000000000000000000000000000000000000000000000000000000000031
+:202FA000000000000000000000000000000000000000000000000000000000000000000011
+:202FC0000000000000000000000000000000000000000000000000000000000000000000F1
+:202FE0000000000000000000000000000000000000000000000000000000000000000000D1
+:2030000000000000000000001FF0001002600180010001000100010002000400080000009C
+:20302000000000003FF800080010002002C00100010001000100020002000400080000004B
+:20304000000000000000004000400080010003000500090011000100010001000100000049
+:20306000000000400040008000800100030005000900110021000100010001000100010087
+:20308000000000000000010011101FF8101010101020002000400040008003000C00000058
+:2030A00000000000010021083FFC2008200820100010002000200040008003000C0000000C
+:2030C00000000000000000201FF0010001000100010001103FF80000000000000000000075
+:2030E00000000000000000103FF80100010001000100010001087FFC000000000000000000
+:20310000000000000100010001103FF803000500090011002100010005000200000000001A
+:20312000000000800080008000887FFC00800180028004800880108020804280010000008A
+:2031400000000200020002203FF002200220022004200420082008201040214040800000AB
+:2031600000080204021202083FE40220022002200420042008200820104021404080000091
+:20318000000008000800040004E03F000200010001703F8000800040004000200020000085
+:2031A000000808040812040804E43F000200010001703F800080004000400020002000003B
+:2031C000000002000200021003F8041004200820104020400080010002000C00300000000F
+:2031E000000802040212020803E4042004200840104020800080010002000C00300000007D
+:2032000000000800080008100FF810802080410001000200020004000800100020000000CD
+:2032200000080804081208080FF4108020804100010002000200040008001000200000009B
+:2032400000000000000000101FF8001000100010002000201FF000000000000000000000C8
+:20326000000800040012000800243FF000200020002000403FE00000000000000000000016
+:203280000000004004400440044004487FFC04400440044004400440008000800100000006
+:2032A00000080004009208880884088008887FFC0880088008800880090001000200000095
+:2032C00000000000180004000200300808100420004000800100020024001800000000005D
+:2032E000000800040012180804040200300808100420004000800100020024001800000013
+:203300000000000000003FE00020004000400080010003000480084010302010000000002E
+:2033200000080004001200083FE400200040004000800100038004400820101820080000E4
+:203340000000040004000400040007E07C2004400480040004000400042003F000000000EF
+:2033600000080004041204080404040007E07C200440048004000400042003F000000000A9
+:203380000000000000202010101008100C200420004000400080010002000C003000000016
+:2033A0000008000400120048402420201020184008400080008001000200040018006000B4
+:2033C00000000400042007F0042008200840104024800280010002800400180060000000C5
+:2033E0000008080408520FE80844104010802080490005000200050008003000C00000004F
+:203400000000002001F01F00010001087FFC010001000200020004000400080010000000D1
+:2034200000080004005203E83E0402000210FFF802000200040004000800080010002000AA
+:203440000000000000000000040003102110182008200040004000800100060018000000A5
+:20346000000000000400021021101110082008200040008001000200040008003000000095
+:20348000000800040812042842242220104010400080010002000400080010006000000093
+:2034A000000000201FF00000000000087FFC01000100020002000400040008001000200014
+:2034C0000008000400923FC8000400000010FFF802000200040004000800080010002000F0
+:2034E0000000000004000400040004000600050004C0044004000400040004000000000099
+:20350000000804040412040804040600050004800460042004000400040004000400000046
+:20352000000001000100010001087FFC0100010001000100020002000400040008000000EC
+:20354000000000000000000000201FF000000000000000087FFC00000000000000000000B9
+:20356000000000101FF8001000200C2002400140008000C001300210040008003000000086
+:2035800002000180008000001FC00080010003000540093011102100010001000100000002
+:2035A00000000000002000200020004000400080008001000100020004000800100000000B
+:2035C0000000000000000000044004200810081008081008100C20044000000000000000AB
+:2035E0000008000400120008044404200810081008081008100C2004400000000000000061
+:203600000000000C00120012044C04200810081008081008100C200440000000000000002E
+:2036200000000000080008000840086009800E00080008000800082007F0000000000000FC
+:2036400000080004001220082004210021802600380020002000200020801FC00000000001
+:203660000000000C00122012200C210021802600380020002000200020801FC000000000CF
+:203680000000000000207FF0002000400040008000800100020004000800100020000000BC
+:2036A00000080004001200487FE400400080008001000100020004000800100020000000C1
+:2036C0000000000C001200527FEC004000800080010001000200040008001000200000008F
+:2036E0000000000000000000000018002400430000C00030000E000000000000000000004D
+:203700000008000400120008000418002400430000C00030000E0000000000000000000002
+:203720000000000C00120012000C18002400430000C00030000E00000000000000000000D0
+:20374000000001000100010001087FFC010001000920091011082108010005000200000054
+:203760000008010401120108010401087FFC0100010009200910110821080500020000000A
+:20378000000C01120112010C010001087FFC010001000920091011082108050002000000D8
+:2037A00000000000000000103FF800100020002006400180008000400040000000000000AB
+:2037C000000000000E000180006000201C00030000C000401C00038000600020000000009C
+:2037E00000000200020002000200040004000400040008400820101010F83F0810080000BA
+:203800000000000000200010002004200240018000800160022004000800100060000000F2
+:203820000000004003E03E000200020803FC7E000200020002000200021001F8000000008B
+:20384000000000000000000000000800040005F83E08021001200100008000800040002085
+:203860000000100008000800040005F87E08021001200100008000800040004000200000CD
+:203880000000000000000000000000200FF0002000200020004000483FFC000000000000E6
+:2038A0000000000000101FF80010001000100020002000247FFE00000000000000000000D0
+:2038C0000000000000201FF0002000201FE0002000201FE00020000000000000000000001B
+:2038E000000000103FF80010001000103FF00010001000103FF000100000000000000000B3
+:20390000000000400FE0000000103FF80010001000200020004000800100060018000000F2
+:20392000000000400440044004400440044004400440048000800100010002000400080057
+:203940000000000000000000048004800480048004840888089010A020C0400000000000D7
+:20396000000000000000200010001010102010401080110012001400180000000000000098
+:203980000000000010201FF01020102010201020104010401FE01000000000000000000079
+:2039A0000000000010201FF010201020002000400040008001000200040000000000000041
+:2039C0000000000020103FF8201020100010002000200040004000800100020004000000C9
+:2039E00000000100010001401FE009000900090009087FFC010001000100010001000000D9
+:203A00000000000000001FE00040028001000100010001087FFC000000000000000000005E
+:203A20000000000000101FF8001000107FF800200020004000400080010002000400000081
+:203A400000000000100008040608021000200040008001000200240018000000000000000B
+:203A600000080204021222283FF420202020002000400040008001000200040008000000F8
+:203A8000000000000100010001200FF001200120022002200220054008800000000000008F
+:203AA0000000000004000400044007E008801080210001000200040008000000000000008B
+:203AC0000000000000000000000000000000000000000000000000000000000000000000E6
+:203AE0000000000000000000000000000000000000000000000000000000000000000000C6
+:203B00000000000000000000000000000000000000000000000000000000000000000000A5
+:203B2000000000000000000000000000000000000000000000000000000000000000000085
+:203B4000000000000000000000000000000000000000000000000000000000000000000065
+:203B6000000000000000000000000000000000000000000000000000000000000000000045
+:203B8000000000000000000000000000000000000000000000000000000000000000000025
+:203BA000000000000000000000000000000000000000000000000000000000000000000005
+:203BC00000000100028002800440044008200FE0101010102008701C00000000000000004D
+:203BE00000007FE020102010201020203FC020202010201020107FE0000000000000000068
+:203C000000007FF8200820082000200020002000200020002000700000000000000000008D
+:203C2000000001000280028004400440082010101010200820087FFC0000000000000000C4
+:203C400000007FF820082008200020403FC020402000200820087FF80000000000000000D7
+:203C600000003FF82010202000400080010002000400080810083FF8000000000000000077
+:203C80000000701C20082008200820083FF82008200820082008701C000000000000000095
+:203CA000000007C008201010200828282FE8282820081010082007C00000000000000000DF
+:203CC0000000038001000100010001000100010001000100010003800000000000000000D5
+:203CE000000071C021002200240028003800240022002100208070E0000000000000000075
+:203D000000000100028002800440044008200820101010102008701C0000000000000000D2
+:203D20000000600C301830182828282824482448228822882108701C000000000000000006
+:203D40000000601C300828082408220821082088204820282018700C0000000000000000F4
+:203D600000001FF8100810080000042007E004200000100810081FF8000000000000000086
+:203D8000000007C008201010200820082008200820081010082007C000000000000000003D
+:203DA00000007FFC200820082008200820082008200820082008701C000000000000000094
+:203DC00000007FE020102008200820103FE0200020002000200070000000000000000000C5
+:203DE00000007FF82008100808000400020004000800100820087FF800000000000000003B
+:203E000000007FFC4104410401000100010001000100010001000380000000000000000013
+:203E20000000004006A0090001000100010001000100010001000380000000000000000009
+:203E40000000038001000FE0111021082108210811100FE0010003800000000000000000BF
+:203E60000000701C101008200440028001000280044008201010701C00000000000000000D
+:203E800000004384210811101110111011100FE00100010001000380000000000000000039
+:203EA000000007C00820101020082008200820081010482444447C7C000000000000000047
+:203EC0000000000000000000000000000000000000000000000000000000000000000000E2
+:203EE0000000000000000000000000000000000000000000000000000000000000000000C2
+:203F00000000000000000000000000000000000000000000000000000000000000000000A1
+:203F2000000000000000000000000000000000000000000000000000000000000000000081
+:203F4000000000000000000000000000000000000000000000000000000000000000000061
+:203F6000000000000000000000000000000000000000000000000000000000000000000041
+:203F8000000000000000000000000000000000000000000000000000000000000000000021
+:203FA000000000000000000000000000000000000000000000000000000000000000000001
+:203FC000000000000000074008C01040104010401040104008D00720000000000000000043
+:203FE000000007800840084008800F0008C00820082008200C400B800800080008000000E4
+:204000000000000000000C1012202220014001400180018001800100010001000100000007
+:204020000000038004400200010002800440082008200820044003800000000000000000B1
+:20404000000000000000038004400400020001800200040004400380000000000000000045
+:2040600000000200044004C0030002000400080008000800040003C00020002003C000004B
+:2040800000000000000001C00A2014200420042004200420042004200020002000200000C9
+:2040A0000000038004400820082008200FE008200820082004400380000000000000000093
+:2040C000000000000000030001000100010001000100010001000140018000000000000014
+:2040E0000000000000001830084008800D000A000900088008401C7000000000000000002C
+:2041000004000A0002000100010001000300028002800450045008200000000000000000B5
+:2041200000000000000008400840084008400840084008400CD00B20080008000800000068
+:2041400000000000000018200810042004200420024002400280010000000000000000009C
+:204160000000040008000780080008000780040008000800080007C00020022001C000002F
+:20418000000000000000078008401020102010201020102008400780000000000000000091
+:2041A0000000000000001FF8244004400440044004400440085010200000000000000000A8
+:2041C000000000000000078008401020102010201020182014401380100010001000000001
+:2041E00000000000000007F0084010201020102010201020084007800000000000000000C1
+:2042000000000000000007C009000100010001000100010001400080000000000000000008
+:204220000000000000000840142004200420042004200420042003C0000000000000000067
+:2042400000000100010007C0092011101110111011101110092007C00100010001000000D4
+:20426000000008101420042002400280010001000280048008400850102000000000000032
+:204280000000010001001140292009200920092009200920092007C00100010001000000C2
+:2042A00000000000000004400820111011101110111011100AA004400000000000000000FF
+:2042C0000000000000000000000000000000000000000000000000000000000000000000DE
+:2042E0000000000000000000000000000000000000000000000000000000000000000000BE
+:2043000000000000000000000000000000000000000000000000000000000000000000009D
+:2043200000000000000000000000000000000000000000000000000000000000000000007D
+:2043400000000000000000000000000000000000000000000000000000000000000000005D
+:2043600000000000000000000000000000000000000000000000000000000000000000003D
+:2043800000000000000000000000000000000000000000000000000000000000000000001D
+:2043A00000000000000000000000000000000000000000000FF0300C400200000000000080
+:2043C00000004000300E0FF000000000000000000000000000000000000000000000000060
+:2043E000000000000000000000000000000000001FF82008200440044002000000000000D4
+:20440000000040024002200420041FF80000000000000000000000000000000000000000B9
+:20442000000000000000000000000000000003C01C386006000000000000000000000000FF
+:204440000000000000000000000000000000700E0E700180000000000000000000000000DF
+:204460000000000000000000010007C00830300C400007C018386006000000000000000043
+:204480000000000000000000700E0E7003804002301C0E6001800000000000000000000020
+:2044A000000000000000000000000000000000001FFE0002000200020000000000000000D9
+:2044C0000000000000004000400040007FF0000000000000000000000000000000000000AD
+:2044E00000000000000000000000000000001FFE1FFE000600060000000000000000000076
+:20450000000000000000000000000000180018001FFE1FFE00000000000000000000000031
+:2045200000000000000000000000000000000000000000000000000000000000000000007B
+:2045400000000000000000000000000000000000000000000000000000000000000000005B
+:2045600000000000000000000000000000000000FFFEFE7EF00EC002800000000000000082
+:204580000000000000008000C002F006FFFEFFFE00000000000000000000000000000000E9
+:2045A000000000000000000000000000000000000000000001807E7C8002000000000000FE
+:2045C0000000000064321BCC0000000000000000000000000000000000000000000000005E
+:2045E0000000010001000100010001000100010001000100010001000100010001000100AC
+:2046000000000000000000000000000000000000000000000000000000000000000000009A
+:204620000000800080008000800080008000800080008000800080008000800080008000FA
+:2046400040008000800040008000800040004000800080008000400040008000800040001A
+:2046600000000000000000000000000000000000000000000000000000000000000000003A
+:2046800000000000000000000000000000000000000000000000000000000000000000001A
+:2046A0000000000000000000000000000000000000000000000000000000000000000000FA
+:2046C0000000000000000000000000000000000000000000000000000000000000000000DA
+:2046E0000000000000000000000000000000000000000000000000000000000000000000BA
+:20470000000000000000000000000000000000000000000000000000000000000000000099
+:20472000000000000000000000000000000000000000000000000000000000000000000079
+:20474000000000000000000000000000000000000000000000000000000000000000000059
+:20476000000000000000000000000000000000000000000000000000000000000000000039
+:2047800000000100028002800440044008200FE0101010102008701C000000000000000081
+:2047A00000007FF820082008200020003FE020102008200820107FE00000000000000000C4
+:2047C00000007FE020102008200820103FE020102008200820107FE000000000000000009C
+:2047E00000007FF820082008200020002000200020002000200070000000000000000000A2
+:2048000000001FF8041004100410041004100810081010103FF8200800000000000000006E
+:2048200000007FF820082008200020203FE020202000200820087FF800000000000000000B
+:20484000082000007FF82008200820203FE020202000200820087FF80000000000000000E3
+:2048600000003398492409200540038005400920092011101110638C000000000000000047
+:20488000000017E0181010080008001001E000102008200810100FE0000000000000000079
+:2048A0000000700C20082018202820C823082408280830082008601C000000000000000089
+:2048C0000440744C23882018202820C823082408280830082008601C00000000000000005E
+:2048E000000070602080210022003C0022002100208020402020703800000000000000009E
+:2049000000001FF00820082008200820082008200820082028201070000000000000000080
+:204920000000701C200830182828282824482448228821082008701C00000000000000007C
+:204940000000701C2008200820083FF82008200820082008701C00000000000000000000F0
+:20496000000007C008201010200820082008200820081010082007C0000000000000000051
+:2049800000007FF02020202020202020202020202020202020207070000000000000000088
+:2049A00000007FE020102008200820103FE0200020002000200070000000000000000000D9
+:2049C00000000FD01030201020002000200020002000200810100FE00000000000000000B1
+:2049E00000007FFC4104410401000100010001000100010001000380000000000000000028
+:204A000000001C1C0808080804100410022001400080010012000C00000000000000000014
+:204A20000000038001001FF0210841044104410421081FF00100038000000000000000002F
+:204A40000000701C101008200440028001000280044008201010701C000000000000000021
+:204A6000000038381010101010101010101010101010101010103FF8000400040000000067
+:204A8000000038381010101010101010083007D000100010001000380000000000000000AF
+:204AA0000000739C2108210821082108210821082108210821087FFC0000000000000000FB
+:204AC0000000739C2108210821082108210821082108210821087FFC0004000400000000D3
+:204AE00000003E0024000400040007F0040804040404040404080FF0000000000000000026
+:204B00000000701C2008200820083F08208820482048204820887F1C000000000000000027
+:204B200000001C000800080008000FE0081008080808080808101FE00000000000000000F3
+:204B400000002FE0301020080004000401FC000400041008081007E00000000000000000BA
+:204B6000000071F022082404240424043C04240424042404220871F00000000000000000EF
+:204B8000000003FC040808080808040803F80088030804080808381C0000000000000000E0
+:204BA0000000000000000000000000000000000000000000000000000000000000000000F5
+:204BC0000000000000000000000000000000000000000000000000000000000000000000D5
+:204BE0000000000000000000000000000000000000000000000000000000000000000000B5
+:204C0000000000000000000000000000000000000000000000000000000000000000000094
+:204C2000000000000000000000000000000000000000000000000000000000000000000074
+:204C4000000000000000000000000000000000000000000000000000000000000000000054
+:204C6000000000000000000000000000000000000000000000000000000000000000000034
+:204C8000000000000000000000000000000000000000000000000000000000000000000014
+:204CA0000000000000000000000000000000000000000000000000000000000000000000F4
+:204CC0000000000000000000000000000000000000000000000000000000000000000000D4
+:204CE0000000000000000000000000000000000000000000000000000000000000000000B4
+:204D0000000000000000000000000000000000000000000000000000000000000000000093
+:204D2000000000000000000000000000000000000000000000000000000000000000000073
+:204D4000000000000000000000000000000000000000000000000000000000000000000053
+:204D6000000000000000000000000000000000000000000000000000000000000000000033
+:204D80000000000000000780084000400F4010C01040104008D00720000000000000000046
+:204DA000002007C00800100017801840102010201020102008400780000000000000000076
+:204DC0000000000000001F800840084008400F800840084008401F80000000000000000056
+:204DE0000000000000001FE008200800080008000800080008001C00000000000000000040
+:204E000000000000000007F002200220022002200420042008201FF0101000000000000074
+:204E200000000000000007800840102010201FE010001000082007C0000000000000000035
+:204E400000000480000007800840102010201FE010001000082007C0000000000000000091
+:204E6000000000000000339809200920054007C009200920111023880000000000000000EB
+:204E80000000000000000BC00C200820002001C000200020082007C00000000000000000E3
+:204EA00000000000000038701020106010A01120122014201820307000000000000000008B
+:204EC00000000480030038701020106010A0112012201420182030700000000000000000E4
+:204EE0000000000000001C600880088009000E000900088008901C6000000000000000006A
+:204F00000000000000000FF004200420042004200420142008700000000000000000000032
+:204F2000000000000000383810101830145012901290111010103838000000000000000040
+:204F40000000000000001C700820082008200FE00820082008201C7000000000000000005A
+:204F60000000000000000380044008200820082008200820044003800000000000000000DB
+:204F80000000000000001FE008400840084008400840084008401CE000000000000000001E
+:204FA0000000000000000B801C4008200820082008200C400B800800080008001C0000005F
+:204FC000000000000000078008401040100010001000102008400780000000000000000083
+:204FE0000000000000001FF0111001000100010001000100010003800000000000000000F8
+:205000000000000000001C7008200820044004400480028001000100020014000800000006
+:2050200000000100010001000D601390111011101110111013900D60010001000380000044
+:205040000000000000001C7008200440028001000280044008201C7000000000000000005B
+:205060000000000000001C7008200820082008200820082008201FF000100000000000006D
+:205080000000000000001CE008400840084007C000400040004000E00000000000000000D5
+:2050A0000000000000003BB811101110111011101110111011103FF80000000000000000DF
+:2050C0000000000000003BB811101110111011101110111011103FF80008000000000000B7
+:2050E0000000000000003C002800080008000FC00820082008201FC0000000000000000016
+:2051000000000000000038381010101010101F101090109010903F38000000000000000039
+:205120000000000000001C000800080008000FC00820082008201FC0000000000000000015
+:20514000000000000000078008400020002001E00020082008400780000000000000000048
+:2051600000000000000038C01120121012101E1012101210112038C0000000000000000027
+:2051800000000000000003F004200420042003E0012002200A2004700000000000000000EC
+:2051A0000000000000000000000000000000000000000000000000000000000000000000EF
+:2051C0000000000000000000000000000000000000000000000000000000000000000000CF
+:2051E0000000000000000000000000000000000000000000000000000000000000000000AF
+:2052000000000000000000000000000000000000000000000000000000000000000000008E
+:2052200000000000000000000000000000000000000000000000000000000000000000006E
+:2052400000000000000000000000000000000000000000000000000000000000000000004E
+:2052600000000000000000000000000000000000000000000000000000000000000000002E
+:2052800000000000000000000000000000000000000000000000000000000000000000000E
+:2052A0000000000000000000000000000000000000000000000000000000000000000000EE
+:2052C0000000000000000000000000000000000000000000000000000000000000000000CE
+:2052E0000000000000000000000000000000000000000000000000000000000000000000AE
+:2053000000000000000000000000000000000000000000000000000000000000000000008D
+:2053200000000000000000000000000000000000000000000000000000000000000000006D
+:2053400000000000000000003C00000000003800440044004400440044003A00000000004B
+:2053600000000000000000000800180000003800440044004400440044003A000000000047
+:2053800000000000000000002400180000003800440044004400440044003A00000000000B
+:2053A00000000000000000001000000000003800440044004400440044003A000000000017
+:2053C00000000000000000003C00000000003C00420042007C00400022001C0000000000D7
+:2053E00000000000000004000800080000003C00420042007C00400022001C0000000000DF
+:2054000000000000000000002C00180000003C00420042007C00400022001C00000000008E
+:2054200000000000000000001000100000003C00420042007C00400022001C000000000092
+:2054400000000000000000007800000000001000100010001000100010003800000000003C
+:2054600000000000000008001000100000001000100010001000100010003800000000006C
+:2054800000000000000000002800100000001000100010001000100010003800000000003C
+:2054A000000000000000200020001000000010001000100010001000100038000000000004
+:2054C00000000000000000003C00000000003C00420042004200420066003C0000000000AA
+:2054E00000000000000000000C00080000003C0042004200420042006600180000000000D6
+:2055000000000000000000002400180000003C00420042004200420066003C000000000069
+:2055200000000000000000001000000000003C00420042004200420066003C000000000075
+:2055400000000000000000003C00000000004400440044004400440026003A00000000005B
+:20556000000000000000040008001800C4004400440044004400440026003A00000000008F
+:20558000000000000000000034001800C4004400440044004400440026003A000000000047
+:2055A000000000000000000010000000C4004400440044004400440026003A000000000063
+:2055C0000000000000003C0024002400C4004400440044004400440026003A0000000000CF
+:2055E000000000000800180024002400C4004400440044004400440026003A0000000000CB
+:20560000000000002400180024002400C4004400440044004400440026003A00000000008E
+:2056200000000000100010002C002400C4004400440044004400440026003A000000000082
+:20564000000000000000000024002400C4004400440044004400440026003A00000000008A
+:2056600000000000000018003800440000003C00420042007C00400022001C0000000000DC
+:2056800000000000000000000000000000003C00440044004400440044003A000000000040
+:2056A00000000000000008000800100000007E004A004A004A004A004A00DB0000000000FF
+:2056C0000000000000000000080010000C00740042004200420042004200E7000000000001
+:2056E0000000000000000000340018000C00740042004200420042004200E70000000000AD
+:205700000000000000001000100008000C00740042004200420042004200E70000000000B0
+:2057200000000000000000000000000000003C0044004400440044003C00440044007800E1
+:20574000000000000000000000000000000000000000000000000000000000000000000049
+:20576000000000000000000000000000000000000000000000000000000000000000000029
+:20578000000000000000000000000000000000000000000000000000000000000000000009
+:2057A0000000000000000000000000000000000000000000000000000000000000000000E9
+:2057C00000000800080010003FF800080008000800080008000800080010011000A0004039
+:2057E00000000400040008001FF8000800080010011000A0004000A003100C103000000072
+:2058000000000000000000003FF82008200820082008200820082008000000000000000039
+:20582000000000003FF810001000100010001000100010001000100010000FFC0000000086
+:2058400000000400040008001FF801080108010801080208020804080810111020A00040A4
+:20586000000001000100010001007FFC0100010002000200040008201FF000080000000060
+:20588000000000003FC000400080010003F8000800080008000800080010011000A0004024
+:2058A000000001000900090011001FF80108010801080208020804080408081010502020AE
+:2058C0000000000002200220044004400880088011000880088004400440022002200000FF
+:2058E000000000007FFC02000200040008001FF000100010001000100010002000A00040BE
+:20590000000000003FFC1000100010001000100010001000100020002000400080000000CC
+:2059200000000020042004200420042004200420086009A00E200020002000200020002090
+:2059400000000080008000800100010002000400020001000100008000800040004000003B
+:20596000000000007FFC0100010001000100010001000100010001000100010001000000A0
+:205980000000010001001110111011101110111011101FF00100010001007FFC00000000B2
+:2059A000000000400080010002000440088011000300050009001100010001000100010021
+:2059C000000000001FF80008000800081FF810001000100010001000200020004000800031
+:2059E000000000000FE00820082008200A20092008A008200820082008200FE000000000B6
+:205A0000000000003FF0041004100410041004100420052004C004000400040004000400D2
+:205A200000000200020002007FFC0400040004000FF00010001000200020004002800100B7
+:205A40000000010001000100010002000200020004000400084010203FF000080000000085
+:205A6000000010080810042002400080010001000100010001000100010001000100010006
+:205A8000000000007FFC0100010001000F001000200020002000200810100FE000000000D2
+:205AA00000000100010001007FFC010001000F001000200020002000200810100FE00000B0
+:205AC000000000000840084008407FFC084008400840088008800900080007F00000000083
+:205AE000000000007FFC0900090011001FF801080108010802080208041008101020000066
+:205B0000000000001C0004000400040002000200020001000100008000400020001800005D
+:205B200000000200020004200420084008401F8001000200044008201FF00010000000005C
+:205B40000000000000001FF0001000200420024001400080008001400220040008000000F0
+:205B600000003FE0082008200820104010401FF8000800080008001000100020004000003F
+:205B8000000008000800080008001000100010001FF8000800080008001000100020000046
+:205BA000000002000200020002007FFC02800280028004800480048008801080607C00005C
+:205BC0000000000001000100010002000200040004000800100020003FF800000000000047
+:205BE00000000000048004800480048004800480048004800480088008841084607C00007D
+:205C0000000001000100010001000100010001000100010001000100010001000100010075
+:205C2000000000100010001008200420024001400080008001400220041018006000000076
+:205C4000000000000000000810081008100810081008200820783F88000800000000000035
+:205C6000000000000000000000000000000000000000000000000000000000000000000024
+:205C8000000000000000000000000000000000000000000000000000000000000000000004
+:205CA0000000000000000000000000000000000000000000000000000000000000000000E4
+:205CC0000000000000000000000000000000000000000000000000000000000000000000C4
+:205CE0000000000000000000000000000000000000000000000000000000000000000000A4
+:205D0000000000000000000000000000000000000000000000000000000000000000000083
+:205D2000000000000000000000000000000000000000000000000000000000000000000063
+:205D4000000000000000000000000000000000000000000000000000000000000000000043
+:205D6000000000000000000000000000000000000000000000000000000000000000000023
+:205D8000000000000000000000000000000000000000000000000000000000000000000003
+:205DA0000000000000000000000000000000000000000000000000000000000000000000E3
+:205DC0000000000000000000000000000000000000000000000000000000000000000000C3
+:205DE0000000000000000000000000000000000000000000000000000000000000000000A3
+:205E0000000000000000000000000000000000000000000000000000000000000000000082
+:205E2000000000000000000000000000000000000000000000000000000000000000000062
+:205E4000000000000000000000000000000000000000000000000000000000000000000042
+:205E6000000000000000000000000000000000000000000000000000000000000000000022
+:205E8000000000000000000000000000000000000000000000000000000000000000000002
+:205EA0000000000000000000000000000000000000000000000000000000000000000000E2
+:205EC0000000000000000000000000000000000000000000000000000000000000000000C2
+:205EE0000000000000000000000000000000000000000000000000000000000000000000A2
+:205F0000000000000000000000000000000000000000000000000000000000000000000081
+:205F2000000000000000000000000000000000000000000000000000000000000000000061
+:205F4000000000000000000000000000000000000000000000000000000000000000000041
+:205F60000000000000000000000000000000FFFF0000000000000000000000000000000023
+:205F80000000000000000000000000000000FFFFFFFF000000000000000000000000000005
+:205FA0000100010001000100010001000100010001000100010001000100010001000100D1
+:205FC0000180018001800180018001800180018001800180018001800180018001800180B1
+:205FE0000000000000000000000000000000E38E0000000000000000000000000000000030
+:206000000000000000000000000000000000E38EE38E00000000000000000000000000009E
+:20602000010001000100000000000000010001000100000000000000010001000100000057
+:206040000180018001800000000000000180018001800000000000000180018001800000B7
+:206060000000000000000000000000000000CCCC0000000000000000000000000000000088
+:20608000000000000000000000000000CCCCCCCC00000000000000000000000000000000D0
+:2060A0000100010000000000010001000000000001000100000000000100010000000000D8
+:2060C0000180018000000000018001800000000001800180000000000180018000000000B8
+:2060E000000000000000000000000000000001FF0100010001000100010001000100010098
+:20610000000000000000000000000000000001FF01FF010001000100010001000100010078
+:20612000000000000000000000000000000001FF0180018001800180018001800180018057
+:20614000000000000000000000000000000001FF01FF0180018001800180018001800180B8
+:206160000000000000000000000000000000FF000100010001000100010001000100010018
+:206180000000000000000000000000000000FF00FF000100010001000100010001000100FA
+:2061A0000000000000000000000000000000FF800180018001800180018001800180018058
+:2061C0000000000000000000000000000000FF80FF8001800180018001800180018001803A
+:2061E000010001000100010001000100010001FF0000000000000000000000000000000098
+:20620000010001000100010001000100010001FF01FF000000000000000000000000000077
+:20622000018001800180018001800180018001FF00000000000000000000000000000000D7
+:20624000018001800180018001800180018001FF01FF0000000000000000000000000000B7
+:206260000100010001000100010001000100FF000000000000000000000000000000000018
+:206280000100010001000100010001000100FF00FF000000000000000000000000000000F9
+:2062A0000180018001800180018001800180FF8000000000000000000000000000000000D8
+:2062C0000180018001800180018001800180FF80FF80000000000000000000000000000039
+:2062E000010001000100010001000100010001FF010001000100010001000100010001008F
+:20630000010001000100010001000100010001FF01FF01000100010001000100010001006F
+:20632000018001800180018001800180018001FF01000100010001000100010001000100CE
+:20634000010001000100010001000100010001FF018001800180018001800180018001802E
+:20636000018001800180018001800180018001FF018001800180018001800180018001808E
+:20638000018001800180018001800180018001FF01FF01000100010001000100010001006F
+:2063A000010001000100010001000100010001FF01FF01800180018001800180018001804F
+:2063C000018001800180018001800180018001FF01FF0180018001800180018001800180AF
+:2063E0000100010001000100010001000100FF00010001000100010001000100010001008F
+:206400000100010001000100010001000100FF00FF00010001000100010001000100010070
+:206420000180018001800180018001800180FF0001000100010001000100010001000100CE
+:206440000100010001000100010001000100FF00018001800180018001800180018001802E
+:206460000180018001800180018001800180FF80018001800180018001800180018001800E
+:206480000180018001800180018001800180FF80FF000100010001000100010001000100F0
+:2064A0000100010001000100010001000100FF00FF800180018001800180018001800180D0
+:2064C0000180018001800180018001800180FF80FF800180018001800180018001800180B0
+:2064E0000000000000000000000000000000FFFF0100010001000100010001000100010096
+:206500000000000000000000000000000000FFFFFF00010001000100010001000100010077
+:206520000000000000000000000000000000FFFF01FF010001000100010001000100010056
+:206540000000000000000000000000000000FFFFFFFF010001000100010001000100010038
+:206560000000000000000000000000000000FFFF0180018001800180018001800180018015
+:206580000000000000000000000000000000FFFFFF800180018001800180018001800180F7
+:2065A0000000000000000000000000000000FFFF01FF018001800180018001800180018056
+:2065C0000000000000000000000000000000FFFFFFFF018001800180018001800180018038
+:2065E0000100010001000100010001000100FFFF0000000000000000000000000000000096
+:206600000100010001000100010001000100FFFFFE00000000000000000000000000000077
+:206620000100010001000100010001000100FFFF00FF000000000000000000000000000056
+:206640000100010001000100010001000100FFFFFFFF000000000000000000000000000037
+:206660000180018001800180018001800180FFFF0000000000000000000000000000000095
+:206680000180018001800180018001800180FFFFFF00000000000000000000000000000076
+:2066A0000180018001800180018001800180FFFF00FF000000000000000000000000000056
+:2066C0000180018001800180018001800180FFFFFFFF000000000000000000000000000037
+:2066E0000100010001000100010001000100FFFF010001000100010001000100010001008D
+:206700000100010001000100010001000100FFFFFF0001000100010001000100010001006E
+:206720000100010001000100010001000100FFFF01FF01000100010001000100010001004D
+:206740000100010001000100010001000100FFFFFFFF01000100010001000100010001002F
+:206760000180018001800180018001800180FFFF010001000100010001000100010001008C
+:206780000100010001000100010001000100FFFF01800180018001800180018001800180EC
+:2067A0000180018001800180018001800180FFFF018001800180018001800180018001804C
+:2067C0000180018001800180018001800180FFFFFF0001000100010001000100010001002E
+:2067E0000180018001800180018001800180FFFF01FF01000100010001000100010001000D
+:206800000100010001000100010001000100FFFFFF8001800180018001800180018001806D
+:206820000100010001000100010001000100FFFF01FF0180018001800180018001800180CC
+:206840000180018001800180018001800180FFFFFFFF0100010001000100010001000100AE
+:206860000100010001000100010001000100FFFFFFFF01800180018001800180018001808E
+:206880000180018001800180018001800180FFFFFF8001800180018001800180018001806D
+:2068A0000180018001800180018001800180FFFF01FF0180018001800180018001800180CC
+:2068C0000180018001800180018001800180FFFFFFFF0180018001800180018001800180AE
+:2068E000000000000000000000000000000000000000000000000000000000000000000098
+:20690000000000000000000000000000000000000000000000000000000000000000000077
+:20692000000000000000000000000000000000000000000000000000000000000000000057
+:20694000000000000000000000000000000000000000000000000000000000000000000037
+:20696000000000000000000000000000000000000000000000000000000000000000000017
+:206980000000000000000000000000000000000000000000000000000000000000000000F7
+:2069A0000000000000000000000000000000000000000000000000000000000000000000D7
+:2069C0000000000000000000000000000000000000000000000000000000000000000000B7
+:2069E000000000000000000000000000000000000000000000000000000000000000000097
+:206A0000000000000000000000000000000000000000000000000000000000000000000076
+:206A2000000000000000000000000000000000000000000000000000000000000000000056
+:206A4000000000000000000000000000000000000000000000000000000000000000000036
+:206A6000000000000000000000000000000000000000000000000000000000000000000016
+:206A80000000000000000000000000000000000000000000000000000000000000000000F6
+:206AA0000000000000000000000000000000000000000000000000000000000000000000D6
+:206AC0000000000000000000000000000000000000000000000000000000000000000000B6
+:206AE000000000000000000000000000000000000000000000000000000000000000000096
+:206B0000000000000000000000000000000000000000000000000000000000000000000075
+:206B2000000000000000000000000000000000000000000000000000000000000000000055
+:206B4000000000000000000000000000000000000000000000000000000000000000000035
+:206B6000000000000000000000000000000000000000000000000000000000000000000015
+:206B80000000000000000000000000000000000000000000000000000000000000000000F5
+:206BA0000000000000000000000000000000000000000000000000000000000000000000D5
+:206BC0000000000000000000000000000000000000000000000000000000000000000000B5
+:206BE000000000000000000000000000000000000000000000000000000000000000000095
+:206C0000000000000000000000000000000000000000000000000000000000000000000074
+:206C2000000000000000000000000000000000000000000000000000000000000000000054
+:206C4000000000000000000000000000000000000000000000000000000000000000000034
+:206C6000000000000000000000000000000000000000000000000000000000000000000014
+:206C80000000000000000000000000000000000000000000000000000000000000000000F4
+:206CA0000000000000000000000000000000000000000000000000000000000000000000D4
+:206CC0000000000000000000000000000000000000000000000000000000000000000000B4
+:206CE000000000000000000000000000000000000000000000000000000000000000000094
+:206D0000000000000000000000000000000000000000000000000000000000000000000073
+:206D2000000000000000000000000000000000000000000000000000000000000000000053
+:206D4000000000000000000000000000000000000000000000000000000000000000000033
+:206D6000000000000000000000000000000000000000000000000000000000000000000013
+:206D80000000000000000000000000000000000000000000000000000000000000000000F3
+:206DA0000000000000000000000000000000000000000000000000000000000000000000D3
+:206DC0000000000000000000000000000000000000000000000000000000000000000000B3
+:206DE000000000000000000000000000000000000000000000000000000000000000000093
+:206E0000000000000000000000000000000000000000000000000000000000000000000072
+:206E2000000000000000000000000000000000000000000000000000000000000000000052
+:206E4000000000000000000000000000000000000000000000000000000000000000000032
+:206E6000000000000000000000000000000000000000000000000000000000000000000012
+:206E80000000000000000000000000000000000000000000000000000000000000000000F2
+:206EA0000000000000000000000000000000000000000000000000000000000000000000D2
+:206EC0000000000000000000000000000000000000000000000000000000000000000000B2
+:206EE000000000000000000000000000000000000000000000000000000000000000000092
+:206F0000000000000000000000000000000000000000000000000000000000000000000071
+:206F2000000000000000000000000000000000000000000000000000000000000000000051
+:206F4000000000000000000000000000000000000000000000000000000000000000000031
+:206F6000000000000000000000000000000000000000000000000000000000000000000011
+:206F80000000000000000000000000000000000000000000000000000000000000000000F1
+:206FA0000000000000000000000000000000000000000000000000000000000000000000D1
+:206FC0000000000000000000000000000000000000000000000000000000000000000000B1
+:206FE000000000000000000000000000000000000000000000000000000000000000000091
+:20700000000000000000000000000000000000000000000000000000000000000000000070
+:20702000000000000000000000000000000000000000000000000000000000000000000050
+:20704000000000000000000000000000000000000000000000000000000000000000000030
+:20706000000000000000000000000000000000000000000000000000000000000000000010
+:207080000000000000000000000000000000000000000000000000000000000000000000F0
+:2070A0000000000000000000000000000000000000000000000000000000000000000000D0
+:2070C0000000000000000000000000000000000000000000000000000000000000000000B0
+:2070E000000000000000000000000000000000000000000000000000000000000000000090
+:2071000000000000000000000000000000000000000000000000000000000000000000006F
+:2071200000000000000000000000000000000000000000000000000000000000000000004F
+:2071400000000000000000000000000000000000000000000000000000000000000000002F
+:2071600000000000000000000000000000000000000000000000000000000000000000000F
+:207180000000000000000000000000000000000000000000000000000000000000000000EF
+:2071A0000000000000000000000000000000000000000000000000000000000000000000CF
+:2071C0000000000000000000000000000000000000000000000000000000000000000000AF
+:2071E00000000000000000000000000000000000000000000000000000000000000000008F
+:2072000000000000000000000000000000000000000000000000000000000000000000006E
+:2072200000000000000000000000000000000000000000000000000000000000000000004E
+:2072400000000000000000000000000000000000000000000000000000000000000000002E
+:2072600000000000000000000000000000000000000000000000000000000000000000000E
+:207280000000000000000000000000000000000000000000000000000000000000000000EE
+:2072A0000000000000000000000000000000000000000000000000000000000000000000CE
+:2072C0000000000000000000000000000000000000000000000000000000000000000000AE
+:2072E00000000000000000000000000000000000000000000000000000000000000000008E
+:2073000000000000000000000000000000000000000000000000000000000000000000006D
+:2073200000000000000000000000000000000000000000000000000000000000000000004D
+:2073400000000000000000000000000000000000000000000000000000000000000000002D
+:2073600000000000000000000000000000000000000000000000000000000000000000000D
+:207380000000000000000000000000000000000000000000000000000000000000000000ED
+:2073A0000000000000000000000000000000000000000000000000000000000000000000CD
+:2073C0000000000000000000000000000000000000000000000000000000000000000000AD
+:2073E00000000000000000000000000000000000000000000000000000000000000000008D
+:2074000000000000000000000000000000000000000000000000000000000000000000006C
+:2074200000000000000000000000000000000000000000000000000000000000000000004C
+:2074400000000000000000000000000000000000000000000000000000000000000000002C
+:2074600000000000000000000000000000000000000000000000000000000000000000000C
+:207480000000000000000000000000000000000000000000000000000000000000000000EC
+:2074A0000000000000000000000000000000000000000000000000000000000000000000CC
+:2074C0000000000000000000000000000000000000000000000000000000000000000000AC
+:2074E00000000000000000000000000000000000000000000000000000000000000000008C
+:2075000000000000000000000000000000000000000000000000000000000000000000006B
+:2075200000000000000000000000000000000000000000000000000000000000000000004B
+:2075400000000000000000000000000000000000000000000000000000000000000000002B
+:2075600000000000000000000000000000000000000000000000000000000000000000000B
+:207580000000000000000000000000000000000000000000000000000000000000000000EB
+:2075A0000000000000000000000000000000000000000000000000000000000000000000CB
+:2075C0000000000000000000000000000000000000000000000000000000000000000000AB
+:2075E00000000000000000000000000000000000000000000000000000000000000000008B
+:2076000000000000000000000000000000000000000000000000000000000000000000006A
+:2076200000000000000000000000000000000000000000000000000000000000000000004A
+:2076400000000000000000000000000000000000000000000000000000000000000000002A
+:2076600000000000000000000000000000000000000000000000000000000000000000000A
+:207680000000000000000000000000000000000000000000000000000000000000000000EA
+:2076A0000000000000000000000000000000000000000000000000000000000000000000CA
+:2076C0000000000000000000000000000000000000000000000000000000000000000000AA
+:2076E00000000000000000000000000000000000000000000000000000000000000000008A
+:20770000000000000000000000000000000000000000000000000000000000000000000069
+:20772000000000000000000000000000000000000000000000000000000000000000000049
+:20774000000000000000000000000000000000000000000000000000000000000000000029
+:20776000000000000000000000000000000000000000000000000000000000000000000009
+:207780000000000000000000000000000000000000000000000000000000000000000000E9
+:2077A0000000000000000000000000000000000000000000000000000000000000000000C9
+:2077C0000000000000000000000000000000000000000000000000000000000000000000A9
+:2077E000000000000000000000000000000000000000000000000000000000000000000089
+:20780000000000000000000000000000000000000000000000000000000000000000000068
+:20782000000000000000000000000000000000000000000000000000000000000000000048
+:20784000000000000000000000000000000000000000000000000000000000000000000028
+:20786000000000000000000000000000000000000000000000000000000000000000000008
+:207880000000000000000000000000000000000000000000000000000000000000000000E8
+:2078A0000000000000000000000000000000000000000000000000000000000000000000C8
+:2078C0000000000000000000000000000000000000000000000000000000000000000000A8
+:2078E000000000000000000000000000000000000000000000000000000000000000000088
+:20790000000000000000000000000000000000000000000000000000000000000000000067
+:20792000000000000000000000000000000000000000000000000000000000000000000047
+:20794000000000000000000000000000000000000000000000000000000000000000000027
+:20796000000000000000000000000000000000000000000000000000000000000000000007
+:207980000000000000000000000000000000000000000000000000000000000000000000E7
+:2079A0000000000000000000000000000000000000000000000000000000000000000000C7
+:2079C0000000000000000000000000000000000000000000000000000000000000000000A7
+:2079E000000000000000000000000000000000000000000000000000000000000000000087
+:207A0000000000000000000000000000000000000000000000000000000000000000000066
+:207A2000000000000000000000000000000000000000000000000000000000000000000046
+:207A4000000000000000000000000000000000000000000000000000000000000000000026
+:207A6000000000000000000000000000000000000000000000000000000000000000000006
+:207A80000000000000000000000000000000000000000000000000000000000000000000E6
+:207AA0000000000000000000000000000000000000000000000000000000000000000000C6
+:207AC0000000000000000000000000000000000000000000000000000000000000000000A6
+:207AE000000000000000000000000000000000000000000000000000000000000000000086
+:207B0000000000000000000000000000000000000000000000000000000000000000000065
+:207B2000000000000000000000000000000000000000000000000000000000000000000045
+:207B4000000000000000000000000000000000000000000000000000000000000000000025
+:207B6000000000000000000000000000000000000000000000000000000000000000000005
+:207B80000000000000000000000000000000000000000000000000000000000000000000E5
+:207BA0000000000000000000000000000000000000000000000000000000000000000000C5
+:207BC0000000000000000000000000000000000000000000000000000000000000000000A5
+:207BE000000000000000000000000000000000000000000000000000000000000000000085
+:207C0000000000000000000000000000000000000000000000000000000000000000000064
+:207C2000000000000000000000000000000000000000000000000000000000000000000044
+:207C4000000000000000000000000000000000000000000000000000000000000000000024
+:207C6000000000000000000000000000000000000000000000000000000000000000000004
+:207C80000000000000000000000000000000000000000000000000000000000000000000E4
+:207CA0000000000000000000000000000000000000000000000000000000000000000000C4
+:207CC0000000000000000000000000000000000000000000000000000000000000000000A4
+:207CE000000000000000000000000000000000000000000000000000000000000000000084
+:207D0000000000000000000000000000000000000000000000000000000000000000000063
+:207D2000000000000000000000000000000000000000000000000000000000000000000043
+:207D4000000000000000000000000000000000000000000000000000000000000000000023
+:207D6000000000000000000000000000000000000000000000000000000000000000000003
+:207D80000000000000000000000000000000000000000000000000000000000000000000E3
+:207DA0000000000000000000000000000000000000000000000000000000000000000000C3
+:207DC0000000000000000000000000000000000000000000000000000000000000000000A3
+:207DE000000000000000000000000000000000000000000000000000000000000000000083
+:207E0000000000000000000000000000000000000000000000000000000000000000000062
+:207E2000000000000000000000000000000000000000000000000000000000000000000042
+:207E4000000000000000000000000000000000000000000000000000000000000000000022
+:207E6000000000000000000000000000000000000000000000000000000000000000000002
+:207E80000000000000000000000000000000000000000000000000000000000000000000E2
+:207EA0000000000000000000000000000000000000000000000000000000000000000000C2
+:207EC0000000000000000000000000000000000000000000000000000000000000000000A2
+:207EE000000000000000000000000000000000000000000000000000000000000000000082
+:207F0000000000000000000000000000000000000000000000000000000000000000000061
+:207F2000000000000000000000000000000000000000000000000000000000000000000041
+:207F4000000000000000000000000000000000000000000000000000000000000000000021
+:207F6000000000000000000000000000000000000000000000000000000000000000000001
+:207F80000000000000000000000000000000000000000000000000000000000000000000E1
+:207FA0000000000000000000000000000000000000000000000000000000000000000000C1
+:207FC0000000000000000000000000000000000000000000000000000000000000000000A1
+:207FE000000000000000000000000000000000000000000000000000000000000000000081
+:20800000000000000000000000000000000000000000000000000000000000000000000060
+:20802000000000000000000000000000000000000000000000000000000000000000000040
+:20804000000000000000000000000000000000000000000000000000000000000000000020
+:20806000000000000000000000000000000000000000000000000000000000000000000000
+:208080000000000000000000000000000000000000000000000000000000000000000000E0
+:2080A0000000000000000000000000000000000000000000000000000000000000000000C0
+:2080C0000000000000000000000000000000000000000000000000000000000000000000A0
+:2080E000000000000000000000000000000000000000000000000000000000000000000080
+:2081000000000000000000000000000000000000000000000000000000000000000000005F
+:2081200000000000000000000000000000000000000000000000000000000000000000003F
+:2081400000000000000000000000000000000000000000000000000000000000000000001F
+:208160000000000000000000000000000000000000000000000000000000000000000000FF
+:208180000000000000000000000000000000000000000000000000000000000000000000DF
+:2081A0000000000000000000000000000000000000000000000000000000000000000000BF
+:2081C00000000000000000000000000000000000000000000000000000000000000000009F
+:2081E00000000000000000000000000000000000000000000000000000000000000000007F
+:2082000000000000000000000000000000000000000000000000000000000000000000005E
+:2082200000000000000000000000000000000000000000000000000000000000000000003E
+:2082400000000000000000000000000000000000000000000000000000000000000000001E
+:208260000000000000000000000000000000000000000000000000000000000000000000FE
+:208280000000000000000000000000000000000000000000000000000000000000000000DE
+:2082A0000000000000000000000000000000000000000000000000000000000000000000BE
+:2082C00000000000000000000000000000000000000000000000000000000000000000009E
+:2082E00000000000000000000000000000000000000000000000000000000000000000007E
+:2083000000000000000000000000000000000000000000000000000000000000000000005D
+:2083200000000000000000000000000000000000000000000000000000000000000000003D
+:2083400000000000000000000000000000000000000000000000000000000000000000001D
+:208360000000000000000000000000000000000000000000000000000000000000000000FD
+:208380000000000000000000000000000000000000000000000000000000000000000000DD
+:2083A0000000000000000000000000000000000000000000000000000000000000000000BD
+:2083C00000000000000000000000000000000000000000000000000000000000000000009D
+:2083E00000000000000000000000000000000000000000000000000000000000000000007D
+:2084000000000000000000000000000000000000000000000000000000000000000000005C
+:2084200000000000000000000000000000000000000000000000000000000000000000003C
+:2084400000000000000000000000000000000000000000000000000000000000000000001C
+:208460000000000000000000000000000000000000000000000000000000000000000000FC
+:208480000000000000000000000000000000000000000000000000000000000000000000DC
+:2084A0000000000000000000000000000000000000000000000000000000000000000000BC
+:2084C00000000000000000000000000000000000000000000000000000000000000000009C
+:2084E00000000000000000000000000000000000000000000000000000000000000000007C
+:2085000000000000000000000000000000000000000000000000000000000000000000005B
+:2085200000000000000000000000000000000000000000000000000000000000000000003B
+:2085400000000000000000000000000000000000000000000000000000000000000000001B
+:208560000000000000000000000000000000000000000000000000000000000000000000FB
+:208580000000000000000000000000000000000000000000000000000000000000000000DB
+:2085A0000000000000000000000000000000000000000000000000000000000000000000BB
+:2085C00000000000000000000000000000000000000000000000000000000000000000009B
+:2085E00000000000000000000000000000000000000000000000000000000000000000007B
+:2086000000000000000000000000000000000000000000000000000000000000000000005A
+:2086200000000000000000000000000000000000000000000000000000000000000000003A
+:2086400000000000000000000000000000000000000000000000000000000000000000001A
+:208660000000000000000000000000000000000000000000000000000000000000000000FA
+:208680000000000000000000000000000000000000000000000000000000000000000000DA
+:2086A0000000000000000000000000000000000000000000000000000000000000000000BA
+:2086C00000000000000000000000000000000000000000000000000000000000000000009A
+:2086E00000000000000000000000000000000000000000000000000000000000000000007A
+:20870000000000000000000000000000000000000000000000000000000000000000000059
+:20872000000000000000000000000000000000000000000000000000000000000000000039
+:20874000000000000000000000000000000000000000000000000000000000000000000019
+:208760000000000000000000000000000000000000000000000000000000000000000000F9
+:208780000000000000000000000000000000000000000000000000000000000000000000D9
+:2087A0000000000000000000000000000000000000000000000000000000000000000000B9
+:2087C000000000000000000000000000000000000000000000000000000000000000000099
+:2087E000000000000000000000000000000000000000000000000000000000000000000079
+:20880000000000000000000000000000000000000000000000000000000000000000000058
+:20882000000000000000000000000000000000000000000000000000000000000000000038
+:20884000000000000000000000000000000000000000000000000000000000000000000018
+:208860000000000000000000000000000000000000000000000000000000000000000000F8
+:208880000000000000000000000000000000000000000000000000000000000000000000D8
+:2088A0000000000000000000000000000000000000000000000000000000000000000000B8
+:2088C000000000000000000000000000000000000000000000000000000000000000000098
+:2088E000000000000000000000000000000000000000000000000000000000000000000078
+:20890000000000000000000000000000000000000000000000000000000000000000000057
+:20892000000000000000000000000000000000000000000000000000000000000000000037
+:20894000000000000000000000000000000000000000000000000000000000000000000017
+:208960000000000000000000000000000000000000000000000000000000000000000000F7
+:208980000000000000000000000000000000000000000000000000000000000000000000D7
+:2089A0000000000000000000000000000000000000000000000000000000000000000000B7
+:2089C000000000000000000000000000000000000000000000000000000000000000000097
+:2089E000000000000000000000000000000000000000000000000000000000000000000077
+:208A0000000000000000000000000000000000000000000000000000000000000000000056
+:208A2000000000000000000000000000000000000000000000000000000000000000000036
+:208A4000000000000000000000000000000000000000000000000000000000000000000016
+:208A60000000000000000000000000000000000000000000000000000000000000000000F6
+:208A80000000000000000000000000000000000000000000000000000000000000000000D6
+:208AA0000000000000000000000000000000000000000000000000000000000000000000B6
+:208AC000000000000000000000000000000000000000000000000000000000000000000096
+:208AE000000000000000000000000000000000000000000000000000000000000000000076
+:208B0000000000000000000000000000000000000000000000000000000000000000000055
+:208B2000000000000000000000000000000000000000000000000000000000000000000035
+:208B4000000000000000000000000000000000000000000000000000000000000000000015
+:208B60000000000000000000000000000000000000000000000000000000000000000000F5
+:208B80000000000000000000000000000000000000000000000000000000000000000000D5
+:208BA0000000000000000000000000000000000000000000000000000000000000000000B5
+:208BC000000000000000000000000000000000000000000000000000000000000000000095
+:208BE000000000000000000000000000000000000000000000000000000000000000000075
+:208C0000000000000000000000000000000000000000000000000000000000000000000054
+:208C2000000000000000000000000000000000000000000000000000000000000000000034
+:208C4000000000000000000000000000000000000000000000000000000000000000000014
+:208C60000000000000000000000000000000000000000000000000000000000000000000F4
+:208C80000000000000000000000000000000000000000000000000000000000000000000D4
+:208CA0000000000000000000000000000000000000000000000000000000000000000000B4
+:208CC000000000000000000000000000000000000000000000000000000000000000000094
+:208CE000000000000000000000000000000000000000000000000000000000000000000074
+:208D0000000000000000000000000000000000000000000000000000000000000000000053
+:208D2000000000000000000000000000000000000000000000000000000000000000000033
+:208D4000000000000000000000000000000000000000000000000000000000000000000013
+:208D60000000000000000000000000000000000000000000000000000000000000000000F3
+:208D80000000000000000000000000000000000000000000000000000000000000000000D3
+:208DA0000000000000000000000000000000000000000000000000000000000000000000B3
+:208DC000000000000000000000000000000000000000000000000000000000000000000093
+:208DE000000000000000000000000000000000000000000000000000000000000000000073
+:208E0000000000000000000000000000000000000000000000000000000000000000000052
+:208E2000000000000000000000000000000000000000000000000000000000000000000032
+:208E4000000000000000000000000000000000000000000000000000000000000000000012
+:208E60000000000000000000000000000000000000000000000000000000000000000000F2
+:208E80000000000000000000000000000000000000000000000000000000000000000000D2
+:208EA0000000000000000000000000000000000000000000000000000000000000000000B2
+:208EC000000000000000000000000000000000000000000000000000000000000000000092
+:208EE000000000000000000000000000000000000000000000000000000000000000000072
+:208F0000000000000000000000000000000000000000000000000000000000000000000051
+:208F2000000000000000000000000000000000000000000000000000000000000000000031
+:208F4000000000000000000000000000000000000000000000000000000000000000000011
+:208F60000000000000000000000000000000000000000000000000000000000000000000F1
+:208F80000000000000000000000000000000000000000000000000000000000000000000D1
+:208FA0000000000000000000000000000000000000000000000000000000000000000000B1
+:208FC000000000000000000000000000000000000000000000000000000000000000000091
+:208FE000000000000000000000000000000000000000000000000000000000000000000071
+:20900000000000000000000000000000000000000000000000000000000000000000000050
+:20902000000000000000000000000000000000000000000000000000000000000000000030
+:20904000000000000000000000000000000000000000000000000000000000000000000010
+:209060000000000000000000000000000000000000000000000000000000000000000000F0
+:209080000000000000000000000000000000000000000000000000000000000000000000D0
+:2090A0000000000000000000000000000000000000000000000000000000000000000000B0
+:2090C000000000000000000000000000000000000000000000000000000000000000000090
+:2090E000000000000000000000000000000000000000000000000000000000000000000070
+:2091000000000000000000000000000000000000000000000000000000000000000000004F
+:2091200000000000000000000000000000000000000000000000000000000000000000002F
+:2091400000000000000000000000000000000000000000000000000000000000000000000F
+:209160000000000000000000000000000000000000000000000000000000000000000000EF
+:209180000000000000000000000000000000000000000000000000000000000000000000CF
+:2091A0000000000000000000000000000000000000000000000000000000000000000000AF
+:2091C00000000000000000000000000000000000000000000000000000000000000000008F
+:2091E00000000000000000000000000000000000000000000000000000000000000000006F
+:2092000000000000000000000000000000000000000000000000000000000000000000004E
+:2092200000000000000000000000000000000000000000000000000000000000000000002E
+:2092400000000000000000000000000000000000000000000000000000000000000000000E
+:209260000000000000000000000000000000000000000000000000000000000000000000EE
+:209280000000000000000000000000000000000000000000000000000000000000000000CE
+:2092A0000000000000000000000000000000000000000000000000000000000000000000AE
+:2092C00000000000000000000000000000000000000000000000000000000000000000008E
+:2092E00000000000000000000000000000000000000000000000000000000000000000006E
+:2093000000000000000000000000000000000000000000000000000000000000000000004D
+:2093200000000000000000000000000000000000000000000000000000000000000000002D
+:2093400000000000000000000000000000000000000000000000000000000000000000000D
+:209360000000000000000000000000000000000000000000000000000000000000000000ED
+:209380000000000000000000000000000000000000000000000000000000000000000000CD
+:2093A0000000000000000000000000000000000000000000000000000000000000000000AD
+:2093C00000000000000000000000000000000000000000000000000000000000000000008D
+:2093E00000000000000000000000000000000000000000000000000000000000000000006D
+:2094000000000000000000000000000000000000000000000000000000000000000000004C
+:2094200000000000000000000000000000000000000000000000000000000000000000002C
+:2094400000000000000000000000000000000000000000000000000000000000000000000C
+:209460000000000000000000000000000000000000000000000000000000000000000000EC
+:209480000000000000000000000000000000000000000000000000000000000000000000CC
+:2094A0000000000000000000000000000000000000000000000000000000000000000000AC
+:2094C00000000000000000000000000000000000000000000000000000000000000000008C
+:2094E00000000000000000000000000000000000000000000000000000000000000000006C
+:2095000000000000000000000000000000000000000000000000000000000000000000004B
+:2095200000000000000000000000000000000000000000000000000000000000000000002B
+:2095400000000000000000000000000000000000000000000000000000000000000000000B
+:209560000000000000000000000000000000000000000000000000000000000000000000EB
+:209580000000000000000000000000000000000000000000000000000000000000000000CB
+:2095A0000000000000000000000000000000000000000000000000000000000000000000AB
+:2095C00000000000000000000000000000000000000000000000000000000000000000008B
+:2095E00000000000000000000000000000000000000000000000000000000000000000006B
+:2096000000000000000000000000000000000000000000000000000000000000000000004A
+:2096200000000000000000000000000000000000000000000000000000000000000000002A
+:2096400000000000000000000000000000000000000000000000000000000000000000000A
+:209660000000000000000000000000000000000000000000000000000000000000000000EA
+:209680000000000000000000000000000000000000000000000000000000000000000000CA
+:2096A0000000000000000000000000000000000000000000000000000000000000000000AA
+:2096C00000000000000000000000000000000000000000000000000000000000000000008A
+:2096E00000000000000000000000000000000000000000000000000000000000000000006A
+:20970000000000000000000000000000000000000000000000000000000000000000000049
+:20972000000000000000000000000000000000000000000000000000000000000000000029
+:20974000000000000000000000000000000000000000000000000000000000000000000009
+:209760000000000000000000000000000000000000000000000000000000000000000000E9
+:209780000000000000000000000000000000000000000000000000000000000000000000C9
+:2097A0000000000000000000000000000000000000000000000000000000000000000000A9
+:2097C000000000000000000000000000000000000000000000000000000000000000000089
+:2097E000000000000000000000000000000000000000000000000000000000000000000069
+:20980000000000000000000000000000000000000000000000000000000000000000000048
+:20982000000000000000000000000000000000000000000000000000000000000000000028
+:20984000000000000000000000000000000000000000000000000000000000000000000008
+:209860000000000000000000000000000000000000000000000000000000000000000000E8
+:209880000000000000000000000000000000000000000000000000000000000000000000C8
+:2098A0000000000000000000000000000000000000000000000000000000000000000000A8
+:2098C000000000000000000000000000000000000000000000000000000000000000000088
+:2098E000000000000000000000000000000000000000000000000000000000000000000068
+:20990000000000000000000000000000000000000000000000000000000000000000000047
+:20992000000000000000000000000000000000000000000000000000000000000000000027
+:20994000000000000000000000000000000000000000000000000000000000000000000007
+:209960000000000000000000000000000000000000000000000000000000000000000000E7
+:209980000000000000000000000000000000000000000000000000000000000000000000C7
+:2099A0000000000000000000000000000000000000000000000000000000000000000000A7
+:2099C000000000000000000000000000000000000000000000000000000000000000000087
+:2099E000000000000000000000000000000000000000000000000000000000000000000067
+:209A0000000000000000000000000000000000000000000000000000000000000000000046
+:209A2000000000000000000000000000000000000000000000000000000000000000000026
+:209A4000000000000000000000000000000000000000000000000000000000000000000006
+:209A60000000000000000000000000000000000000000000000000000000000000000000E6
+:209A80000000000000000000000000000000000000000000000000000000000000000000C6
+:209AA0000000000000000000000000000000000000000000000000000000000000000000A6
+:209AC000000000000000000000000000000000000000000000000000000000000000000086
+:209AE000000000000000000000000000000000000000000000000000000000000000000066
+:209B0000000000000000000000000000000000000000000000000000000000000000000045
+:209B2000000000000000000000000000000000000000000000000000000000000000000025
+:209B4000000000000000000000000000000000000000000000000000000000000000000005
+:209B60000000000000000000000000000000000000000000000000000000000000000000E5
+:209B80000000000000000000000000000000000000000000000000000000000000000000C5
+:209BA0000000000000000000000000000000000000000000000000000000000000000000A5
+:209BC000000000000000000000000000000000000000000000000000000000000000000085
+:209BE000000000000000000000000000000000000000000000000000000000000000000065
+:209C0000000000000000000000000000000000000000000000000000000000000000000044
+:209C2000000000000000000000000000000000000000000000000000000000000000000024
+:209C4000000000000000000000000000000000000000000000000000000000000000000004
+:209C60000000000000000000000000000000000000000000000000000000000000000000E4
+:209C80000000000000000000000000000000000000000000000000000000000000000000C4
+:209CA0000000000000000000000000000000000000000000000000000000000000000000A4
+:209CC000000000000000000000000000000000000000000000000000000000000000000084
+:209CE000000000000000000000000000000000000000000000000000000000000000000064
+:209D0000000000000000000000000000000000000000000000000000000000000000000043
+:209D2000000000000000000000000000000000000000000000000000000000000000000023
+:209D4000000000000000000000000000000000000000000000000000000000000000000003
+:209D60000000000000000000000000000000000000000000000000000000000000000000E3
+:209D80000000000000000000000000000000000000000000000000000000000000000000C3
+:209DA0000000000000000000000000000000000000000000000000000000000000000000A3
+:209DC000000000000000000000000000000000000000000000000000000000000000000083
+:209DE000000000000000000000000000000000000000000000000000000000000000000063
+:209E0000000000000000000000000000000000000000000000000000000000000000000042
+:209E2000000000000000000000000000000000000000000000000000000000000000000022
+:209E4000000000000000000000000000000000000000000000000000000000000000000002
+:209E60000000000000000000000000000000000000000000000000000000000000000000E2
+:209E80000000000000000000000000000000000000000000000000000000000000000000C2
+:209EA0000000000000000000000000000000000000000000000000000000000000000000A2
+:209EC000000000000000000000000000000000000000000000000000000000000000000082
+:209EE000000000000000000000000000000000000000000000000000000000000000000062
+:209F0000000000000000000000000000000000000000000000000000000000000000000041
+:209F2000000000000000000000000000000000000000000000000000000000000000000021
+:209F4000000000000000000000000000000000000000000000000000000000000000000001
+:209F60000000000000000000000000000000000000000000000000000000000000000000E1
+:209F80000000000000000000000000000000000000000000000000000000000000000000C1
+:209FA0000000000000000000000000000000000000000000000000000000000000000000A1
+:209FC000000000000000000000000000000000000000000000000000000000000000000081
+:209FE000000000000000000000000000000000000000000000000000000000000000000061
+:20A00000000000000000000000000000000000000000000000000000000000000000000040
+:20A02000000000000000000000000000000000000000000000000000000000000000000020
+:20A04000000000000000000000000000000000000000000000000000000000000000000000
+:20A060000000000000000000000000000000000000000000000000000000000000000000E0
+:20A080000000000000000000000000000000000000000000000000000000000000000000C0
+:20A0A0000000000000000000000000000000000000000000000000000000000000000000A0
+:20A0C000000000000000000000000000000000000000000000000000000000000000000080
+:20A0E000000000000000000000000000000000000000000000000000000000000000000060
+:20A1000000000000000000000000000000000000000000000000000000000000000000003F
+:20A1200000000000000000000000000000000000000000000000000000000000000000001F
+:20A140000000000000000000000000000000000000000000000000000000000000000000FF
+:20A160000000000000000000000000000000000000000000000000000000000000000000DF
+:20A180000000000000000000000000000000000000000000000000000000000000000000BF
+:20A1A00000000000000000000000000000000000000000000000000000000000000000009F
+:20A1C00000000000000000000000000000000000000000000000000000000000000000007F
+:20A1E00000000000000000000000000000000000000000000000000000000000000000005F
+:20A2000000000000000000000000000000000000000000000000000000000000000000003E
+:20A2200000000000000000000000000000000000000000000000000000000000000000001E
+:20A240000000000000000000000000000000000000000000000000000000000000000000FE
+:20A260000000000000000000000000000000000000000000000000000000000000000000DE
+:20A280000000000000000000000000000000000000000000000000000000000000000000BE
+:20A2A00000000000000000000000000000000000000000000000000000000000000000009E
+:20A2C00000000000000000000000000000000000000000000000000000000000000000007E
+:20A2E00000000000000000000000000000000000000000000000000000000000000000005E
+:20A3000000000000000000000000000000000000000000000000000000000000000000003D
+:20A3200000000000000000000000000000000000000000000000000000000000000000001D
+:20A340000000000000000000000000000000000000000000000000000000000000000000FD
+:20A360000000000000000000000000000000000000000000000000000000000000000000DD
+:20A380000000000000000000000000000000000000000000000000000000000000000000BD
+:20A3A00000000000000000000000000000000000000000000000000000000000000000009D
+:20A3C00000000000000000000000000000000000000000000000000000000000000000007D
+:20A3E00000000000000000000000000000000000000000000000000000000000000000005D
+:20A4000000000000000000000000000000000000000000000000000000000000000000003C
+:20A4200000000000000000000000000000000000000000000000000000000000000000001C
+:20A440000000000000000000000000000000000000000000000000000000000000000000FC
+:20A460000000000000000000000000000000000000000000000000000000000000000000DC
+:20A480000000000000000000000000000000000000000000000000000000000000000000BC
+:20A4A00000000000000000000000000000000000000000000000000000000000000000009C
+:20A4C00000000000000000000000000000000000000000000000000000000000000000007C
+:20A4E00000000000000000000000000000000000000000000000000000000000000000005C
+:20A5000000000000000000000000000000000000000000000000000000000000000000003B
+:20A5200000000000000000000000000000000000000000000000000000000000000000001B
+:20A540000000000000000000000000000000000000000000000000000000000000000000FB
+:20A560000000000000000000000000000000000000000000000000000000000000000000DB
+:20A580000000000000000000000000000000000000000000000000000000000000000000BB
+:20A5A00000000000000000000000000000000000000000000000000000000000000000009B
+:20A5C00000000000000000000000000000000000000000000000000000000000000000007B
+:20A5E00000000000000000000000000000000000000000000000000000000000000000005B
+:20A6000000000000000000000000000000000000000000000000000000000000000000003A
+:20A6200000000000000000000000000000000000000000000000000000000000000000001A
+:20A640000000000000000000000000000000000000000000000000000000000000000000FA
+:20A660000000000000000000000000000000000000000000000000000000000000000000DA
+:20A680000000000000000000000000000000000000000000000000000000000000000000BA
+:20A6A00000000000000000000000000000000000000000000000000000000000000000009A
+:20A6C00000000000000000000000000000000000000000000000000000000000000000007A
+:20A6E00000000000000000000000000000000000000000000000000000000000000000005A
+:20A70000000000000000000000000000000000000000000000000000000000000000000039
+:20A72000000000000000000000000000000000000000000000000000000000000000000019
+:20A740000000000000000000000000000000000000000000000000000000000000000000F9
+:20A760000000000000000000000000000000000000000000000000000000000000000000D9
+:20A780000000000000000000000000000000000000000000000000000000000000000000B9
+:20A7A000000000000000000000000000000000000000000000000000000000000000000099
+:20A7C000000000000000000000000000000000000000000000000000000000000000000079
+:20A7E000000000000000000000000000000000000000000000000000000000000000000059
+:20A80000000000000000000000000000000000000000000000000000000000000000000038
+:20A82000000000000000000000000000000000000000000000000000000000000000000018
+:20A840000000000000000000000000000000000000000000000000000000000000000000F8
+:20A860000000000000000000000000000000000000000000000000000000000000000000D8
+:20A880000000000000000000000000000000000000000000000000000000000000000000B8
+:20A8A000000000000000000000000000000000000000000000000000000000000000000098
+:20A8C000000000000000000000000000000000000000000000000000000000000000000078
+:20A8E000000000000000000000000000000000000000000000000000000000000000000058
+:20A90000000000000000000000000000000000000000000000000000000000000000000037
+:20A92000000000000000000000000000000000000000000000000000000000000000000017
+:20A940000000000000000000000000000000000000000000000000000000000000000000F7
+:20A960000000000000000000000000000000000000000000000000000000000000000000D7
+:20A980000000000000000000000000000000000000000000000000000000000000000000B7
+:20A9A000000000000000000000000000000000000000000000000000000000000000000097
+:20A9C000000000000000000000000000000000000000000000000000000000000000000077
+:20A9E000000000000000000000000000000000000000000000000000000000000000000057
+:20AA0000000000000000000000000000000000000000000000000000000000000000000036
+:20AA2000000000000000000000000000000000000000000000000000000000000000000016
+:20AA40000000000000000000000000000000000000000000000000000000000000000000F6
+:20AA60000000000000000000000000000000000000000000000000000000000000000000D6
+:20AA80000000000000000000000000000000000000000000000000000000000000000000B6
+:20AAA000000000000000000000000000000000000000000000000000000000000000000096
+:20AAC000000000000000000000000000000000000000000000000000000000000000000076
+:20AAE000000000000000000000000000000000000000000000000000000000000000000056
+:20AB0000000000000000000000000000000000000000000000000000000000000000000035
+:20AB2000000000000000000000000000000000000000000000000000000000000000000015
+:20AB40000000000000000000000000000000000000000000000000000000000000000000F5
+:20AB60000000000000000000000000000000000000000000000000000000000000000000D5
+:20AB80000000000000000000000000000000000000000000000000000000000000000000B5
+:20ABA000000000000000000000000000000000000000000000000000000000000000000095
+:20ABC000000000000000000000000000000000000000000000000000000000000000000075
+:20ABE000000000000000000000000000000000000000000000000000000000000000000055
+:20AC0000000000000000000000000000000000000000000000000000000000000000000034
+:20AC2000000000000000000000000000000000000000000000000000000000000000000014
+:20AC40000000000000000000000000000000000000000000000000000000000000000000F4
+:20AC60000000000000000000000000000000000000000000000000000000000000000000D4
+:20AC80000000000000000000000000000000000000000000000000000000000000000000B4
+:20ACA000000000000000000000000000000000000000000000000000000000000000000094
+:20ACC000000000000000000000000000000000000000000000000000000000000000000074
+:20ACE000000000000000000000000000000000000000000000000000000000000000000054
+:20AD0000000000000000000000000000000000000000000000000000000000000000000033
+:20AD2000000000000000000000000000000000000000000000000000000000000000000013
+:20AD40000000000000000000000000000000000000000000000000000000000000000000F3
+:20AD60000000000000000000000000000000000000000000000000000000000000000000D3
+:20AD80000000000000000000000000000000000000000000000000000000000000000000B3
+:20ADA000000000000000000000000000000000000000000000000000000000000000000093
+:20ADC000000000000000000000000000000000000000000000000000000000000000000073
+:20ADE000000000000000000000000000000000000000000000000000000000000000000053
+:20AE0000000000000000000000000000000000000000000000000000000000000000000032
+:20AE2000000000000000000000000000000000000000000000000000000000000000000012
+:20AE40000000000000000000000000000000000000000000000000000000000000000000F2
+:20AE60000000000000000000000000000000000000000000000000000000000000000000D2
+:20AE80000000000000000000000000000000000000000000000000000000000000000000B2
+:20AEA000000000000000000000000000000000000000000000000000000000000000000092
+:20AEC000000000000000000000000000000000000000000000000000000000000000000072
+:20AEE000000000000000000000000000000000000000000000000000000000000000000052
+:20AF0000000000000000000000000000000000000000000000000000000000000000000031
+:20AF2000000000000000000000000000000000000000000000000000000000000000000011
+:20AF40000000000000000000000000000000000000000000000000000000000000000000F1
+:20AF60000000000000000000000000000000000000000000000000000000000000000000D1
+:20AF80000000000000000000000000000000000000000000000000000000000000000000B1
+:20AFA000000000000000000000000000000000000000000000000000000000000000000091
+:20AFC000000000000000000000000000000000000000000000000000000000000000000071
+:20AFE000000000000000000000000000000000000000000000000000000000000000000051
+:20B00000000000000000000000000000000000000000000000000000000000000000000030
+:20B02000000000000000000000000000000000000000000000000000000000000000000010
+:20B040000000000000000000000000000000000000000000000000000000000000000000F0
+:20B060000000000000000000000000000000000000000000000000000000000000000000D0
+:20B080000000000000000000000000000000000000000000000000000000000000000000B0
+:20B0A000000000000000000000000000000000000000000000000000000000000000000090
+:20B0C000000000000000000000000000000000000000000000000000000000000000000070
+:20B0E000000000000000000000000000000000000000000000000000000000000000000050
+:20B1000000000000000000000000000000000000000000000000000000000000000000002F
+:20B1200000000000000000000000000000000000000000000000000000000000000000000F
+:20B140000000F77E9504950496749654955495549554F55497740404040404040414040809
+:20B1600000007BFE48085008600853E84A284A284A286BE85008400840084008402840107A
+:20B1800010401068108411FE1084FD0011FC1220142013FE10201C50E088410606040000DA
+:20B1A00010401040108811FCFC04108014FC19203020D7FE1020106010501088510E26042B
+:20B1C00001100110F9108FFE891088008910891088A0F8A0884000A001100218040E0804F3
+:20B1E00000800088F10493FE9104920093FC9440F84097FE804000A001100208040E0804D1
+:20B20000010000807FFE00001FF0101010101FF01210053808E0184068300A1E0C08080057
+:20B220001040124422447A444BFC48004BF8780848084BF84A087A004A02420201FE000004
+:20B24000010000803FFE2000A3F8620823F820006FBEA8A22FBE20402444444447FC840451
+:20B260000420FFFE042023F8120813F80208E3F8240027FC2C4434A42D1437E4201400083D
+:20B28000401C43E0782053FE507090A8FD26126010402BFE28904590407080D807040000A0
+:20B2A00004400440FFFE04400440082008300420044002800100028004400830300EC00436
+:20B2C00001FCFD0411FC110421FC20007BFE6808A8082BFE28082888384828482028001027
+:20B2E00000F83F90121009203FFE220242003FFC040007F00C200B4010C063308C0E3004BB
+:20B3000002107910492057FE6000611051084A0448006FF855284528452845285FFE40004C
+:20B3200028402820FFFE2904382010207C4055FE54487C881050FE2010501188160C10044F
+:20B3400008000FFC10002FF800007FF8081004107FD040900810FFD0190A060A0D067082C2
+:20B36000020001003FFE2004440806000400FFFE0820082008400680010006C01838E010F1
+:20B380001080188017FC212032106488BFF6249027F02490249027F024822082207E00001E
+:20B3A00010401020102013FEFE04104014401BFE3088D110119010601058118E56042000E2
+:20B3C000004000207BFC4910489048A07FFE480049F8490879F84908010801F80108000059
+:20B3E0000080108410841FFC00003FFE20002FFC208020803FFE2080208040808080008005
+:20B40000004078204BFE4A044C8878C048804BFC78884908489048604850488C6906920460
+:20B42000020001003FFC220804407FFC0C8003801E6001207FFE03400D30710E01040100B5
+:20B4400000403C20242027FE3C0024F024903C90249024902490249044925492890E0200F2
+:20B460001FF810081FF810081FF80000060038FC208420842884309420880080008000803D
+:20B48000010001001FF011101110FFFE0280044008303FFED294129012901290FFFE0000D8
+:20B4A00000007C7C4444444444444444444447C440044004400440047FFC400440040000CE
+:20B4C000082008307F2008403E7E08C8FF48104810281E28121022102228424E8B8404003B
+:20B4E00010407E6010447EFE1088FF8811503E30243024585C8E89042888244466664222D1
+:20B5000010007DDC44447C4446647D541154FE4428CC45549264FE441044104411541088EE
+:20B520004000307823C00040F840084013FC144038A056A0949011101108120612041400AF
+:20B5400012101A1817D0221027BE6224AFE42414241427882488249428942BA631440000FB
+:20B5600002003FF82108292825483FF823882568292801007FFE028004400830300EC0046D
+:20B580002040208027FC2554B4E4AFF4A4C42564265420402FFE204020A023102C0E20002F
+:20B5A0004080210027F806A885C857F814C825A826A82488DFFE40C041204610580E000024
+:20B5C00004400440FFFE044004401FF01110111011101FF010001004100410060FFC000084
+:20B5E000200223C22242224AFA4A23CA290A310A67CAA14A214A224222422442A94A408469
+:20B600001000100010101090FC90109018903090D1101108110812081204540628040000ED
+:20B6200000400060F940894089408940892089208A20FA108A1004080408080610042000DC
+:20B640000000FBFE8A228A228A228A228BFE8A02FA008A00820002000202020201FE00001D
+:20B6600020403F7E4850448885083FFC2084208420843FFC20002002200220021FFE0000B7
+:20B68000000000400460064004400440044008200820101010102008400E8004000000006A
+:20B6A000010000801FFE1000900057FC54441444344457FC940024002402440243FE800059
+:20B6C00000003FF821082108210821083FF820082000200020002004200420061FFC000047
+:20B6E000108010901088FC8013FE108014FC18883148D150113012201250148E5B04200025
+:20B7000000407C504448444847FE7C4010FC10845C8850C851505D207250C48C0906020423
+:20B72000240024FCFEA424A43CA410A47CFC548054807C801080FE8210821082107E1000D9
+:20B74000100011FC11241124FD24112415FC19003100D100110011001102110250FE20002A
+:20B76000100010007DFC11247D2411241124FDFC39003500570055009102110210FE100019
+:20B78000100011FC110411241124FD24112411241124112414501850E08840860104020017
+:20B7A0003FF801007FFE695415280000247CFF44247C7F44497C7F440844FF840894090890
+:20B7C0003FFC244424443FFC210401003FF801000100FFFE0200042008103FF81010000032
+:20B7E00004200810142C2244018002600C1E3FF4D11011101FF01000100410040FFC0000D3
+:20B800000200020004003FF820082008200820083FF820082008200820083FF82008000013
+:20B82000102010201040FDFC110431043904350455FC5104910411041104110411FC110403
+:20B840000000FFFE030002001FF01010101010101FF0101010101010101010101FF0101099
+:20B86000100013FC1294FE94129413FC14401BFC3040D04017FE10801108120457FE200484
+:20B8800010001BFE10403040208063FCA204220423FC22042204220423FC220422040000F8
+:20B8A00000403E60224022802AFE2B882A882A882A5008501420122023502288410E0204BD
+:20B8C000060078FE0810087C3E100810087C7F10081008FE10101010201040108010001059
+:20B8E0000C20704011FC1124FD2411FC3924354455FC50A0912017FE10201020102010205F
+:20B900000000FA7E21102FD024902490FA90237C21102190229022903490C81030FE0000DE
+:20B920000100F97E2110211021102510FD7E25102910211021103A10C21004FE0800100046
+:20B940002100223C27A4FCA426A42DA634C06FFEA4A2269425942488289828A6B2C4410055
+:20B96000200023FC22002200FA0023FC2B0832886290A250222024602498290EB6044000A7
+:20B98000080010F83C88248834882C882506FE0025FC34882C90246024604490550E8A0428
+:20B9A000100029FE2420244042FC4284BCA414A414A414A424A424A42450548C8B040000A9
+:20B9C000101C11E011001100FD0011FC3984354855485230921012301448108E11040000D2
+:20B9E000001C49E0490049007F0041FC418879884950495049204A304A504488890E0204D2
+:20BA0000104010401060FCA0111015081A0635F8D08810881088110811081208542820106F
+:20BA2000104010401248FD4C115013FC184010403040D7FE10401040104010405040204036
+:20BA4000084008401448134C225077FCA040204020402FFE20402040204020402040000009
+:20BA6000401020C8FB3E158455941594FD7E25482548757E2548252849A84918900800003E
+:20BA80000100211019180D20094001083FFC0100010001047FFE0100010001000100010000
+:20BAA0000200020002207FF002200220223024282424442688240820102020A04040000019
+:20BAC00010201020112420A420A849FCF0201020202043FEF820002000201C20E02000208B
+:20BAE0000800087EFF44084808487E5008480844FF42084208421052104C204040400040B8
+:20BB000004003FBE04243FA804287FA4043208AC10A02FF84888088808A80890008000805D
+:20BB20001100111E111217D2FD1411143BD83518511457D29112121A121414101810101034
+:20BB40001040102013FCFC90106033FE3A44542053FC9040107810881088110812281410E9
+:20BB6000004078204BFE488878504BFE4A4448207BFC488048F8488848884908A9289210EA
+:20BB80001100111E27D221124914F11417D821144112F7F20112011A3214C2100410081005
+:20BBA0002040204027FC2040FBF8208077FE6920A258ADF6204027FC204020402040204011
+:20BBC00000407C2013FC1108109023FE3E426420A7FC248024F824883D0825082250042085
+:20BBE0001020102010207FFE5220522053FE7E20522053FE142012201F20F220402000206B
+:20BC0000104010203DFC20884050BBFE12441020FDFE10401078108814881928121000008A
+:20BC20001080184017FC2210212467FEA484284827FC210021F82108220822282410000067
+:20BC40004080204037FC2108009007FEE884204027FC208020F82108290832082428081034
+:20BC600004400440FFFE144010001FF8200820085F8810881F881028101210020FFE0000D5
+:20BC8000008078C0490049FC7A044C0449E44924792449E44904491C490A490248FE9800FE
+:20BCA00008000C0008081FFC100820085FC8904810481FC810081028101210020FFE000036
+:20BCC00001007FFE10001BF0321063F0A0402FFE20E023502D4C03100CA078600C1C08086E
+:20BCE00000047F0401043F240124FFA4042424A415240E241524E4A4448404041414080869
+:20BD00000440FFFE0450444837FE204083F8724853F8124823F8E2483FFE2110211020305F
+:20BD20001FF801007FFE41041D7001001C7008001FF820085F8810A81F9210020FFE000059
+:20BD400010001BF812082208320863F8A0402FFE20E0216021502258244E28442040000030
+:20BD600010001BF8120823F87040AFFE20E02150224E244401003FFC01000100FFFE00008A
+:20BD80001080108020803EFC25044A0451E49124112411E4110C11001502190210FE0000B0
+:20BDA000020001007FFE400480083FF80100010001001FF801400120013001207FFE0000B5
+:20BDC00011001100110011FCFE04120417E41A243224D3E4121412081202120251FE2000EE
+:20BDE00011FC11041104FD141108150019FC3184D1481148113011101138114E5184210091
+:20BE00001FF010101FF010101FF004407FFC0440FFFE04400920355EC38409201110030021
+:20BE200008400C601040237ED48218822942CC2212322622CA0212022202C2021414080888
+:20BE400020403C40244048FC7C84D5F456947C9454F454847C9400881C82E082007E000065
+:20BE600023FC22042BFC2A04B3FCA090A7FCA0902FFE32482D5448E25150864801400080F4
+:20BE8000100017FE1020FC201040304038C054D051489244144610421040104010401040FA
+:20BEA00000207E4011FC1124112421FC3D246544A5FC24A0252027FE3C2024202020002037
+:20BEC000044004407C7C04403C7804407C7E044004400100088028842812681207F0000044
+:20BEE000010002003FF821083FF8210821083FF822080C80FFFE00800080008000800080EC
+:20BF00000440044004400444044E7C5804600440044004400C403442E4424442043E000007
+:20BF200004407C7C04403C7804407C7E054002007FFC04800FF800807FFE008000800080C5
+:20BF4000048004987CE004841C84E47C40001FF010101FF0101010101FF010101050102060
+:20BF600000001FF0101010101110111011101110111011101110028004601818600800000D
+:20BF8000200021FC3D04210441047D24A1242124FD2421242124245028483184260600029C
+:20BFA0000880084017FE121031185190112017FE100013F812081208120813F8120800007C
+:20BFC000040045FC2904112431244924892419242924492489440850088C09065202240014
+:20BFE00008000FF0082014202240418002400C30301EDFF411101FF0111011101FF010107B
+:20C00000040007F00C201240018006607FFE09100FF009100FF001002884281267F20000D3
+:20C020001040102013FC100015045888505097FE100011FC19042504210441FC81040000E9
+:20C04000202010201020FFFE0A240A2012F836885A8896501250122012501248128615045A
+:20C06000020002007FFE0440092011182FE6C10409200820FFFE0820102010202020402059
+:20C0800004200420FFFE042001007FFC038005400520091011082FF64104810001000100AF
+:20C0A000010001000100FFFE0380034005400520091011182FEEC104010001000100000029
+:20C0C00020403E7E50904908890801047FFE05400520092011182FEE41048100010001005F
+:20C0E000010021083FF800003E7822483E48227822483E482278224842884AA8851000005A
+:20C10000100013BC22A422A44BBCFAA412A422A443BCFAA404A434A4CAA4115420880000FB
+:20C1200000047FFE01800F60F11C01063FF821083FF821083FF821082108410841288010EF
+:20C14000FFFE020004000FF03410C41007F001007D0C05B0094009201118210EC5040200FA
+:20C1600000207A224A224BFE48007B9E1292139E5E925292539E52927C92C4A20AAA114472
+:20C1800042082188311027FC01100110F1101FFC11101110121012101410281047FE800063
+:20C1A000000027FC100013F8020803F8700017FC144417FC144417FC1000280047FE000066
+:20C1C00002001FF0189014501FF000003FF821083FF821083FF80000FFFE082008201020BF
+:20C1E000208020802080208020803E8E20F02080208020802080248228823082207E000023
+:20C200003F00213E21223F240824FFA808247FA240A25EA252B25EAC40A07FA040A00020CB
+:20C22000204020403EFE51208A1001F87E00020003F07E00020003FEFE000204020401FC03
+:20C2400010201820202043FE92241A2032F86288A28822502250222022502488250E2A0422
+:20C2600000207EFC08843CFC088408847EFC00007FFE040008001FF8280848080FF8080897
+:20C280000440FFFE044008003FF82448238824483FF8208020983EE020802682387E20008C
+:20C2A0000440FFFE0440086049302A207F7E49445DC45B286B28691049104D284A460084B2
+:20C2C00020802080208C3EF0208024822882317E01000100FFFE01000100010001000100A1
+:20C2E000208020983EE020842684387C0000FFFE10401F4C3270544008423042C03E00001E
+:20C30000208020803E8C20F020822482287E320001200920284428824B120C10F7F0000023
+:20C3200000FC7F00010001003FF821082108210821082108210821282110010001000100D6
+:20C34000010000803FFE2000244024402444274E247024402440244045424E42843E0000C1
+:20C36000008000401FFE100097FC544457FC144437FC50009FFE1110211021104210841071
+:20C3800020001BFC08042084208420842FF42084218422842C8420842284210420142008E1
+:20C3A0000000082049302B201C7E7F4449C459445D286F28491049104928494849864304A4
+:20C3C000082049202A7E7F4449A45D186B28494643040820FFFE0820082010201020202081
+:20C3E00004000210019801100C20082028502848288449064A040C0818082FF8C0000000DD
+:20C4000000407C2045FE440044847C48400041FE7C206420A5FEA420BC20A4200020002047
+:20C4200000407C2045FE44887C5043FE7C2065FE7C20A42001003FF801000100FFFE00006E
+:20C440003C2025FE3C8821FE7C20A5FE3C2000201FF010101FF010101FF0101010501020A2
+:20C4600000204F10297C29480F280810E8FE2F102D102D7C35102710201050008FFE000044
+:20C4800002207A204A2C53B0522062A253224A1E4840684053FC4040404040404FFE400088
+:20C4A000488048FEFE904910797C13547D7C55547D7C11101110FD5011301128114E110413
+:20C4C000408020803080208007F80088F088108811081108120814701020280047FE0000A8
+:20C4E0001080184023FC22044A04FBFC120023FC7B54035405FC3554C5540954110C000056
+:20C5000000007C3C45C054405430542055FC5408541054205440288025804640843E000024
+:20C52000010000801FFC10041FFC100010001FFE192229222FFE292249224922892A080460
+:20C5400008000FFE184017FC344467FCA444244427FC24402240218020C02130220E2C0415
+:20C56000020001807FFE024012501A4C224642449FF004200420024001800660181EE008A5
+:20C58000020001800100FFFE01000100010001400120011001180110010001000100010076
+:20C5A00020901088FEFE008446C62AA8FE8012FE10907C90117E21102210421084100810AB
+:20C5C00022101188FD7E40042B462934FD28117E11087D0811BE1108200820084008000031
+:20C5E000201010087D7E09044AA62B94FD3E12081788FC3E100811C82708220840088008F4
+:20C600000080404027F8240807F80400E7F826A827F82AA82AA832A8221850008FFE00006B
+:20C62000100011FC10001000FC0013FE3820342055285124922614221022102010A01040C2
+:20C6400008040F86080C7F9848A04E48780C4910472440464F0849104922510290FEA00026
+:20C6600000007BFE48904BFC7A944BFC480049FC78004BFE4820492849A44A26ACA4904029
+:20C68000010001003FFC01001FF801007FFE030006880C8C3850C82009100A0E0C040800E5
+:20C6A00049202A207F3E49485DC86B30492847C608803FF051101FF011101FF00000FFFEE7
+:20C6C000082049202A207F7E49445DA45B18691849264B44000029042882681207F00000BA
+:20C6E00000043F042124212421243F24292408247F2409241124110421042704421C8008F8
+:20C7000001003FFE2080A7F864482528248827F86488A16026183A6623804208420881F85D
+:20C7200011041106110C11087BD0110433863B4C555055649546110C1118112011401100E5
+:20C740000010201813D4FC1007FE08904A902A902AF0129012902A8A4AEA87060002000098
+:20C760004200227E2A100BA08A7C5FC422542A544AD452D4C154411042284C46718200003C
+:20C780004040202027FE8404403801C0110011FC21102110C7FE40004010410842044C043F
+:20C7A000010000803FFE40044FE8080008000FF808400840FFFE04400E301818200C400876
+:20C7C0001040102013FEFE02123815C0190031FCD110111017FE11101108120C540420007C
+:20C7E00000700F80080008000FFC0840084008400840FFFE042006100C08180C3006400416
+:20C8000000404040204020480F4C0258226022602450C4504848484650446140408000003C
+:20C82000100013FE1020FC20102033FE3A22562252229252128A130A12021212120A1204DB
+:20C8400000007FFE010001003FFC210421042104228422442434282420042014200800007F
+:20C8600000103FF80100FFFE01003FF80108FFFE01083FF80388054009203118C10E0104DF
+:20C880002104208420483DFE44884888A088208823FE208820882488290831082208000807
+:20C8A000100013FE14201420582053FC5244924412641A942694230442044204821402088B
+:20C8C000010000801FFE10009FFC5040504017F8344854A894A82518260824084428841095
+:20C8E00010100818061004207FFC0420042004207FFE04200420042008200820102020202E
+:20C9000000200020FC2011FE112211247D2011FC128812881A50F42044500888110E02049F
+:20C9200004400440FFFE0440204017FE4444344827F815101510E4A0244028B0290E32041F
+:20C94000203C27C02248F95027FE20E02950324E6FFCA248224823F822482248A3F8420830
+:20C96000204022482244FA4023FE2040288030F8E08821502150222024502988A60640005F
+:20C98000202020203E20202043FC7C20A07020B0FCA8212821FC2222282030202020002078
+:20C9A00020401040104007FE84445440544017F825082490E490246028602898310E2604E9
+:20C9C0002050204827FC204023F8FA4823F8224823F822582FFE2210219021102050202094
+:20C9E000082008207F2008207F7C412482247E2404240B241C44E84408840894290810002C
+:20CA0000104817FE1040FBFC124417FC1A4433FCD244100817FE11081088100850282010B8
+:20CA20001010101020203EFE40827C82908210FEFE82108210821282148218FE10820000E4
+:20CA400020403F7E485084882040108093FC42044A04120413FC2204E204220423FC220466
+:20CA600008400C6008801BFC120432043204520493FC120412041204120413FC120400007F
+:20CA8000010002001FF810081FF810081FF8110801003FFC210421042104211421080100FB
+:20CAA000082010203E4022FC32842A84FE8422FC32842E842A842284228442FC4A8484008C
+:20CAC000002078204BFE48207BFE4A044C0049F8781048204BFE482048204820A8A0904010
+:20CAE000002878244BFE482049FC792449FC492449FC792448104BFE49104910A850902050
+:20CB0000421022102F900210823E5FD250522F9221124212C3A25E22422242424A4A4484BC
+:20CB200040402040208083FC4A044A041204120423FCE204220422042204220423FC22044C
+:20CB40000000FD1008A0486048984B0848007C08050804903450C4200450288E130400004F
+:20CB600010201028102413FEFC2013FE16221BFE3222D22213FE122212221222522A2224D3
+:20CB800002000200020002000200030002C002300218020802000200020002000200020064
+:20CBA00000500048FFFE904097FC9444944497FC9444F44497FC0444044404540448000063
+:20CBC000202018201020FE200420083012283424582294221220102010201020102010204F
+:20CBE0002040208023F82208FA0823F8220023FC220422043BFCE04047FE004000400040EA
+:20CC000000047FFE0180010001000100036005300918110C210841000100010001000000CC
+:20CC2000020003000200FFFE0480048008801FF8288848888888088808A8089000800080E1
+:20CC40000080008008F8088008807FFE008008800888108C6090002000C0070078000000C4
+:20CC600020403F7E4890A52817FE104083FC4A44527C13C4224C2FFEE10820882028201037
+:20CC80001000087E7F42224412441448FFD8004400423F422142215A21443F4021400040E4
+:20CCA0002040204027FE3080A8A0A920A3FC222426242A2432242224223420282020202097
+:20CCC0002040202027FE2504F9D0226835902B0862F6A4002BFC20402250224CA54440800F
+:20CCE00048402BFC104033F848408FFE08001BF82A084BF88A080BF80A08120852282210F8
+:20CD0000084008503F480840FFFC104008487F4C082815303230D2221152188A1104000059
+:20CD20000000101010101010FDFE1010383034303450505050909110121010101050102035
+:20CD400000400040004000407FFE00C0014001400240044008401040604000400140008055
+:20CD600000087E0842084A084AFE4A184A184A284A284A48084814881208230842288010DC
+:20CD8000003C7FC048844A444908795048404FFE78E048D0495049487A4C4A464444004017
+:20CDA000001C7FE04484464445687D28104013FC5CE050E051505D487246C4440040004003
+:20CDC000000001F87E000010111008A001007FFE0180034005200918310EC1040100010075
+:20CDE0000F00F808110C49902A2024440806FF8808141C261A0429884910886009800800E8
+:20CE00000440FFFE044004403FF822081110082001007FFE038005400930111C6108010089
+:20CE20000440FFFE044010001EF822885450A82017D82006DFF80100112019182508420073
+:20CE400008000F7C28483E305428094472C00D303FEECA2009200FE808900A600C3008109C
+:20CE600004000C2011F03F100200FFFC044009203218CC6E31840618186003807C000000FA
+:20CE80003FFC01000100FFFE024004200910310EDFF411101FF01110010801FC7E080000EA
+:20CEA00000407F501048104E3FF02240424E65F0942008280830103021D24E0A8006000208
+:20CEC000210021062FB83220AB20A53EAFA42124212421A423242D24214421442184210455
+:20CEE0002080211023F83088A880AFFEA1202210248C3B262C402188263020C02700200023
+:20CF0000102010301020142015265924512491241124292425242524412441FC810400041C
+:20CF20000820FFFE08200A20030006800C601018EFEE0820082008A00848080807F0000031
+:20CF4000082010203C50248835062E0424F8FC88248834882CB8249024844484547C88006C
+:20CF60000100010002800440083010182FEE482408200820082008E008400808080C07F835
+:20CF80002040104010A0011082084C0E4BF4121012102210E250222022002204220421FC88
+:20CFA0000440FFFE045004281FFE502057A8752C17A874A85790551097AA204A20844000CD
+:20CFC00021F8210821F8F80023BC22A42AA433BC6040A7FE206020D02148224EAC4440409E
+:20CFE00010101090949054FC5890FD1031FE36005AFC5684528492FC1200150018FE1000C2
+:20D00000105013FE1050FBFE12523BFE365253FE500091FC110411FC1104110411FC110485
+:20D020000240FFFE02403FFC22443FFC22443FFC00001FF810081FF810081FF81008000065
+:20D0400004400440FFFE044004401FF010101FF010101FF00100FFFE010001000100010054
+:20D0600000003FFE20042F8428942A942A942A942A942A942A944204450488D49088000069
+:20D08000204020403EFE491085087FFC01003FF82108210823A8255009203118C10E010423
+:20D0A00010041FC41444245435546554A554255425542554229422442464285430080000AB
+:20D0C0003C7824482448244824482448FFFE24482448244824482488448855288A10000044
+:20D0E000400227C224428452455255521552255225522552C552410242824242444A480443
+:20D1000000003FFC200420043FFC200027F8200020003FFE2200221024084FFC4008800002
+:20D120000108788C48504BFE4B2A7AAE127253FE5C0051FC510451FC5D04E10401FC0104FC
+:20D14000101C13E01020FC2013FE102014A01B2E3222D22213AE1222122213FE5202200030
+:20D1600000001FF808100A10091005A00520044002400180018002400C30300EC00400007B
+:20D1800004400440FFFE0440024002007FFE04000840104037FC50401040104017FE1000E1
+:20D1A000042004207FFE042005200280046019182FF6C10009400D2011102118451002003D
+:20D1C0000100010001007FFE05400930310EDFF410101FF0101010101FF000007FFE000044
+:20D1E00000200020FDFE207020A8212E42247CF86488A4F8248824883CF8240023FE00001A
+:20D200002110211027FEF910204020A0291032486C46A3F820402250224C2444A140408015
+:20D22000020001007FFE48049EF822905460A82017D8200EDFF4014011202118451002006C
+:20D2400004000640042008101FEE62240220042008A011402108210821083FF8200800009C
+:20D260000820063004407FFC01003FF80200FFFE040008000FF81080208040809FFE0000BA
+:20D2800000802060180013FE04040038F3C01040105E17E01040144218421042003C00002F
+:20D2A000101C11E01100FD00110015FE19103110D130111811161212121014105810201062
+:20D2C00008400840284C2F7028402F42F842413E0100FFFE038005400930310EC104010015
+:20D2E00006083808D0084A082BFE1418681808281428E4480C883508C40804082828101030
+:20D30000110011F01220FFF81248124813F818A230A2D31E1C401030119010605030201039
+:20D3200010401040109011F8FE48108017FE1910364ED884132010C813101060518026001B
+:20D34000110810CC10507DFC552455FC55247D2451FC182014201FFEF42040200020002091
+:20D360002080208021F83D1047FC4924A12421FC20522092234E2030289030402030001008
+:20D38000410021F8321027FC0A440244F3FC20A02122223E24C0202029803060201000005B
+:20D3A0002040202023FE42004AFCFAA412FC22A47AA402FC022035FCC420082013FE000026
+:20D3C000204020203BFE210840887890A3FE2200FA002200220022002A00340024000800CE
+:20D3E000010000807FFE0810062024443FFE200020002000200020004000400080000000AC
+:20D4000010000BFC4004444442844FE449244FE449244FE441045FF4410441044114400831
+:20D420001000087EFF1000207F7E55425D5241527F5222523E5222103E280026FF4200007D
+:20D4400000001FF010101FF0101010101FF000003FF820083FF8200820083FF820080000FA
+:20D46000480029FC110431FC4904890419FC28004BFE8A020BFE0A020A0213FE520220006B
+:20D48000100013F810101020FC40108411FE1054105416A41924E244408401040214000876
+:20D4A00001001120093009447FFE400480001FF000007FFE02000440082013F03E18101000
+:20D4C00011100D1809207FFE40048FE808200FE001003FF821082108212821100100010088
+:20D4E000080008100820084009800E000800FFFE0A0009000880084009300A1C0C080800A2
+:20D5000010401A48114C215027FE7404A00023F8200027FE20802190220827FC2208000026
+:20D5200000003DF8241024203C40248025FC24543C542494252426444484551C8A080000BF
+:20D5400000003FFE200020002000200020002000200020002000200040004000800000004E
+:20D560000820083049202A201C7E7F4441C45D485528552855105D104128414845864204C2
+:20D58000100013F810107C20544054FE7D52545254927CA25522124214821104161410089D
+:20D5A0000000F3F8920893F8920893F8900097FC9404F40497FC0404040407FC04040000D5
+:20D5C00010001BFC120433FC220463FCA204200027FE240227FE2402240227FE240200008D
+:20D5E000080009FC08447E4408440854FE8809FC48844E84488448FC4884A8009FFE00001E
+:20D60000102010201020FC2010A810A615221A243064D02810101020104011805600200048
+:20D62000200020203E2020A040A87D26A1222220FC62202420082410286031802E00000077
+:20D640000800087C7F4408443E44227C3E4422443E7C0844FF440844088408940908000059
+:20D660000100011EF7D2911297D2945E97D29452F7DE911287D2011201120122012A0144EA
+:20D680004200223C2FA402249FA458BC2FA428A42FBC4224C2245FA44224424442944208B5
+:20D6A00008881110222011103FF821083FF821083FF80100FFFE038005600910110E21041C
+:20D6C0000040F040904092509348924694449848904CF0489010002000400180060018000A
+:20D6E0001020102014201428592451229222142010242824240824104060418086001800A3
+:20D70000020002007FFC04000480088010803FFC00800080FFFE0080008000800080008032
+:20D72000102010201020FE2010201520193C11203120D12011201120112017FE50002000F6
+:20D74000221021182FD0F22024BE2FC4284437A464A8A7A82490279024A824A6A5C44480A8
+:20D7600028003F0448243F2408243F24290C2B040FF000801FF800807FFE008002800100E6
+:20D7800010001A0022FE4222922213A22E226222A22222A2232222422042209C2108200006
+:20D7A000441022102F900210853E4FA420242FE428942F94C8984F88489848A44AC6490426
+:20D7C0002100213E2122F7E42124212873A86B64A522A9222122213A21242120212000201C
+:20D7E00000003FFC2100210021003FF82008200820083FF821002100210021003FFE0000E4
+:20D8000000003FFC200020002FF820003FFE25002508249C24A02440452046188406000082
+:20D820000100010011201910210C410681040000010001003FFC010001000100FFFE000056
+:20D840001FF810081FF810081FF800003FFC20002FF820003FFE249044604520861C040809
+:20D8600010401040104013FE5A445448904010A010A010A01120112011221222121E140080
+:20D88000400027FC24080000880049E0512011202120E1202120212222222222241E000016
+:20D8A000004078404BFE48805100614052404BFC48406850524842444446484241404080DF
+:20D8C0001020102010507C8811161024FEC0111810605D8C501850605380B0008FFE0000C1
+:20D8E000200818081008FC0805FE0808148816483868544896081408100810081028101039
+:20D90000112410A813FEFA0210F8108814F8180031FCD02011FC102013FE102050A020405E
+:20D920000C80708010FE1082FD243120322058B054A891A4112412221422102010A01040FF
+:20D9400020202028202427FEFC20242427A624A424A83CA8E4904792092A084A11840000C6
+:20D96000204027C824B02324F918220875F46802A3F8A20823F82000211020A027FE200079
+:20D9800000A0009000803FFE208020803E88228C2248225022202A604492410A860600028F
+:20D9A00000001FF01010101010101FF000007FFC010001001FF8010001000100FFFE000055
+:20D9C00000783F800104FFFE0920792C09300922393ECB8007600D30311CC108010000005F
+:20D9E0000DF8710811081108FD0811F830003BFC5440504093FC10401040104017FE10003A
+:20DA0000100013FC2040C840127C3240D24012401FFE1000010028842892681207F0000016
+:20DA20004040274801300524921853F054081BF622102210C3F04000421041205FFE0000DC
+:20DA40004020302820240FFE0420E420242427A62494249424982C9234AA2AC609021000AD
+:20DA600000001FF8002000C4790C0FF0092017D0111021082FE841068104010005000200E2
+:20DA8000000047F02410241007F00000E7F8208027F0208020802FFC200050008FFE0000F2
+:20DAA0000020F9FC092449FC4924492441FC7C0007FE3440C47C040404042814100800002F
+:20DAC0000C0071FE10201024FD2610A430A8382055FE5020902010201020102010201020FD
+:20DAE0000100018079004BFE4A004C004BF0481048207840488041000202020201FE000089
+:20DB0000008000401FFE1400940057BC5A2412243FA452249224252424BC48249024200041
+:20DB20001040104013FCFC40104017FE1410181037FED010111010D0109010105050202093
+:20DB400000003F2021203F2021243F380020FFA0042424242724241C54004C0083FE00002F
+:20DB60000000204010401240824C4A744BC41644124412542248E2402242220221FE0000BF
+:20DB8000400023F832082208020803F8E208224022202410240C28082000580087FE0000A2
+:20DBA0000000782009200924793E47E44124412479240924090C09000902090228FE100097
+:20DBC0000020782009202924293C29E42B243D2405240524352CC5200502150208FE000039
+:20DBE0000010FE10441044107C90449E44907C904490449046907C90C49007FE04000400A6
+:20DC00000100010011F811001100FFFE010021082108228822482428282820083FF8000078
+:20DC200008800CFC198411083290346050C0934014FE1102128414481050102010C01700D7
+:20DC400000001FF81008100810081FF81108110010801080204020204018400E800400003A
+:20DC6000010001003FFC01000100FFFE024012501A4812442446444288400840114020801B
+:20DC8000100013DCFC44126411547D54444444CC45542A64284411542888460081FE000094
+:20DCA00000781F801000100010001FFE1040104011C010601058204820404040804000406F
+:20DCC000100011FC1504150459045104510491FC110428902488258441064202840200002E
+:20DCE000020001007FFC020007400C2010103FF8049004800480088008841084207C4000BA
+:20DD000000404040204037FC244404441444144417FC2444E04020402040204020402040D5
+:20DD20000100010001003FF821082108210821083FF8210801000110010801FC7F08000006
+:20DD4000008010841FFC010400803FFE20044FF000007FFE008010901888108C22884100AB
+:20DD6000010000803FFE2204424802207FFE0248024C0450046008C00B441044203C40003F
+:20DD8000202020202020F82023FE22222A22322263FEA222222222222222A3FE40000000D4
+:20DDA000FF02289228922892FE92ABDAAAB6AE92C2928292FE9282928292FF1282120000BA
+:20DDC0000040F840AFFCA840A840ABFCF880A880AFFEA908FAFE8A4804480808102820101D
+:20DDE00000407C4047FE444045F87C40104013FE5C885088517E51485E48E2080428001014
+:20DE00000C0071FE112211227DFA112239FE3502557A514A914A117A124A1202140A18048F
+:20DE20000E207820082408ACFF701C202A202850488E0B04000009082884281447F00000BA
+:20DE400010401F7E28904508BFFC01001FF802007FFE04101FFE0A10111021104050002031
+:20DE600008800880109017F820906090A0902110211021102210221224122812301E00005C
+:20DE800010001BFC22444A44FBF4124423FC4204FAF4029402943AF4C494040408141008E1
+:20DEA0000010F0D0971091109152FFD493589350F59095A899289128F144914401860104F4
+:20DEC00000103FF8021002100210021002103FF0041004100410041004147FFE000000008D
+:20DEE00002001FF010101FF010101FF010101FF001200110FFFE028004400830101C6008C3
+:20DF00001000080008047EFE042408241224342458249424124410441084111412080000CE
+:20DF20000100010021042104210421043FFC2104010021042104210421043FFC20040000F7
+:20DF4000200027FE2400F7E4240474046DDEA544A55425CC2444254428E42B043014200847
+:20DF600000003FFE20083F8820082F7E290829482F28203831282A0847885C2880100000E1
+:20DF800000887C8847FE448844247DFE102853FE5C2050FC518456FC5884E08400FC0084C9
+:20DFA000200820083BC82248427E7BCAA24A224AFBCA2252225222522A6233AA2644000053
+:20DFC00010A010903E9025FE499092907EFC029002907EFC0290029002907EFE00800080BB
+:20DFE00040202F2029500A488A865C781A20292029FC2D204AA8C8A449224A2248A0484029
+:20E000000080F88089409120A210A7EC9880908097F8D080A2A08290848C8884928081003F
+:20E0200008200820FEFE1C302A6849A608203FF80110010011F811001900270041FE0000BD
+:20E040000020FE2011241124212421243DFC6524A4202524252425243D2425FC2104000086
+:20E060001020182415FE242420285DFEA420244025FC268424FC248425842EFC2484000000
+:20E0800001007FFC02001FF0149012501130FFFE1020FEFC10207CFC54946CCC56A4F9FECC
+:20E0A0002080204027FEF860209823E0288833FC6002A3FC224423FC22442244A3FC420412
+:20E0C00020103F10211042107F7CC9547F54495449547F7C491049144912491E85F202002D
+:20E0E00010201820102020203E202230622852269424142008201420232040C0803E00004D
+:20E100001020122212221222FBFE10001BFE10403080D3FE125212521252125252562202E4
+:20E120001004108410841084108410841084108410841084108410841084208420044000D3
+:20E14000020001007FFE482410102FE80040084008401FFC014002400C403040C1400080F1
+:20E1600010401078108811F0FC2013FE3880354456A85130967010A8132E1C2410A0104012
+:20E180001040184817FC204020806084AFFE2080210823FC2008211020A02040202000008A
+:20E1A000080010F83C88248834882C88250EFE00240034FC2C842484248444FC548488004A
+:20E1C00000200224FA248A248BFC88008FFE88408880FBFC8A94029402940294028402085A
+:20E1E000010001001FF0111011101FF001003FF82108210821083FF82108010001000100A7
+:20E20000010000801FFE10809140522014183BEE5224922012A022402204420441FC8000D3
+:20E22000010000807FFE4022091812067FF8110813E814481A881108128814081FF81008BE
+:20E240002040202023FCF908A890AFFEA800A9FCA924A9FCA924B9FC202021FC202023FE1A
+:20E26000010000803FFE2080208020803FFC218021C022A0229024882486488450808080DD
+:20E28000100009FC0804200427C42444244427F420142FD4201420542024200420142008C0
+:20E2A000080208021412131221D24092BF12211221122512221220822082208A1F84000007
+:20E2C00001000180F10493FE92449448985090409040F0A090A081100118020C040E080466
+:20E2E00010801080108015FC5904524852409440104010A028A0251045104208840E1804B6
+:20E300002000203C27C0F84027FE22482A483FFE6248A24820402FFE20402040A7FC400060
+:20E320000000207C23C03C4043FE41487D4813FE11487D48114813FE1040144019FC1000F1
+:20E34000001001F83F0001007FFE09200920FFFE092009207FFC0100010001003FFC00009D
+:20E36000010001003FFC01001FF80200FFFE042008183FEEC8240FE0082008200FE00000BE
+:20E380001040104017FCF84013F8388037FE511052089DFE110811F81108110811F81108CE
+:20E3A0000040FE2029FE2800FEFCAA84AAFCAA00AEF8C2108220FFFE8220FE2082A00040FF
+:20E3C00000007FF840004FF040005FF8491048A04B604C1C48085FF0501050105FF090100E
+:20E3E0004080204027FE000093F8520853F8200023F82020C0404FFE40404040414040809F
+:20E4000008200820102013FE24207C200924112421247D2401FC0C20F02240220022001E66
+:20E4200001007FFC01003FF802007FFE0C2837E6C42417F07C7C54547C7C14141E1E62E229
+:20E44000F720552833245320953E11E024203F246424BF1824103F30244A248A3F0620026E
+:20E4600010401840107C20404BF8FA0813F822084208FBF8004007FE1840E0400040004014
+:20E48000010000841FFE112091205120552635F8552095202520252025A24622581E800006
+:20E4A00004400440FFFE0440410031FC29080A5014401040E0A020A021102218240E2804ED
+:20E4C0000104FCC8209027FE208840887908C9104A524FBC49084A947C6247FE4042000059
+:20E4E00004402460249025FE2490BF90A4FCA490A490A4FCA490B690C49000FE0080008006
+:20E5000000400C20F1FE10001084FE48100013FE10207C2045FE442044207C20442000209E
+:20E52000082004407FFE0820082012503CF0082014503EF8000029082884681407F0000002
+:20E54000410031FC15440A40144070B0110E1204FFFE08000FE00A20092011221622181E19
+:20E56000400023FC3004200403F40004F00411E411241124112411E41524181410080000EF
+:20E580000440044004400440244627582460244024402440244027423842E042003E00002B
+:20E5A000080208027F22082208227F224922492249225D222A2229224882888A080408006A
+:20E5C0000000F9F88908A9F8A908A9F8A900A9FCAA54AC542094212452444884891400087A
+:20E5E00001004100250025FE2A440A481440104020C0E0A0412042104408180E6004000044
+:20E600000000FD0848CC489079FC4904490479FC480048204C947A82CA8A0A88087808008B
+:20E62000044004407FFE14401FF8124826484D88314806283A1001882894281647F400001E
+:20E64000040008007FFC440444044FE4484456446184418442444C24402440047FFC400443
+:20E6600008000C0008041FFE112429244624834404C408E410B4612402040C04701400080B
+:20E68000084008400840084008400840084008A014A0129012902108230C420684040800B2
+:20E6A0000000084008400840084008400840086014901298230C21064204FFFE000000005B
+:20E6C000008040802FFC310027F801003FFE221027E8D8846FFE408041404230441C5808C4
+:20E6E000100011F8950855085908FDF831083908550855F8510891081108110817FE100044
+:20E700000048FF48284828FCFE48AA48ABFEAA00CEFC8284FE8482FC8284FE8482FC0084F1
+:20E7200020403E7E48A08410208010FEFD0012801CFC152025FE242024504448548E8904E1
+:20E7400010001BF8320822086208A3F8224820402248227C22402240254028C0303E0000DC
+:20E76000004078204BFE4A9449287A2411FC51245DFC502053FE52225FFEE02000200020DE
+:20E7800020803EFE49209FF010101FF010101FF010101FF00200FFFE0A50342ECFF400108A
+:20E7A000020001007FFE4422091031081FF011101FF001003FF821083FF801000100010047
+:20E7C00020202222222223FEF94021202BFE36206A20A3FC222023FC22202220A3FE420066
+:20E7E0000080108410841FFC090008801FFE30805FFC90801FFC108010801FFE1000100015
+:20E8000010401C44144427FC22406224A7FE2A2023FC222023FC2220222423FE2200220089
+:20E820007880488048FC49047A084DFE4900497C794449444954494849424A42AA7E940061
+:20E84000010000801FFE910050885FFC12203220553098C820802FFE208040804080808000
+:20E860001040102097FE54885888FE8811543A223422502057FE90201020102010201020F5
+:20E880004080204027FE00008A105210552818C420402040EFFE2040204020402040204051
+:20E8A0007EF8224812280A28134820807FFC042004200A5011087FFE01000100010001005A
+:20E8C0001010101010101010FDFE10103810351054905090901010101010101010501020BC
+:20E8E000030002007FFC040004000BF818101020302057FE902010201020102010A0104050
+:20E900000040004000400044FFFE0040104008400C400440044000400040004001400080C9
+:20E920000104FC8823FE2040204023FC408078806FFEA90029FC2A203C20282437FE000034
+:20E9400021FC210421FC2104F9FC200027FE324063FEA25423D4224823D82C66A0444040DE
+:20E96000110810881090FDFE102011FC14401BFE3080D10013FC14201020102057FE200008
+:20E98000100011101110FBFC111011101FFE100033F8D208120813F81208120853F82208EC
+:20E9A000204020402248234CFA4822482B5834D468E2A04027FC204020402040AFFE40002D
+:20E9C000109010903C9021FC40907C9093FE1000FDFC1104110411FC1104150419FC110409
+:20E9E0002110211027FEF9102150204028A03110E3EE2C0023F8220822082208A3F8420832
+:20EA000000004080308010800FFC00800080E080214021202218240C280850028FFC000072
+:20EA200010401F7E28902508458802400C30300ECFF400000FF00810081008100FF008105A
+:20EA400001001FFE122092205FFC52A01140322054189BEE200027F02410441087F0041085
+:20EA60001000100013FE1020FE201020142018203020D020102010201020102050A020402B
+:20EA800001000100010001000100FFFE01000280028002400440042008101018200E400413
+:20EAA00000001FF01010101010101FF0111001047FFE0380054009203118C10E0104010026
+:20EAC00000007FFE0200020007FC040808080C10131061200040018006001800E000000017
+:20EAE0001080188017FC208027F86080AFFE212022582646395420E02158264820C0000014
+:20EB000008207F300828FFFE00207F2049287F2C49287F1812107F90122AFFCA120661025D
+:20EB2000091009107FFE091009107FFE410481081FF01110111011101150112001000100A3
+:20EB400000207E20102010403E48228445FE6402980009FC110411042104410481FC0104EF
+:20EB6000110019201110110821FC3F005080908010801040104010241014100C100600001B
+:20EB800008A00C9010FC374050221012100C1FF01010111011101110129004600818101026
+:20EBA00008900C8810BE37C050409024121411087FFE0290049808603820CA180C0E08046E
+:20EBC0001040184013FC28404C40884017FE1010301057FE101011101110101010501020E6
+:20EBE0000040404023F820480FFE0048E3F82040225021E02150264C214450808FFE00002A
+:20EC00000200042008101FF800080FF0081008100FF00000090828842896681207F000007D
+:20EC20000020FE20442045FE7D224624442044207C50445046505C90E4920512050E060096
+:20EC4000100011F81108FD08110815F8190811083108D1F810001000100017FE5000200066
+:20EC600000000FF008100A10099008D00890FFFE08100810101010102010205040200000ED
+:20EC80000820063004403FF821083FF8210821083FF821080100FFFE010001000100010087
+:20ECA0002200143E7F22492449287F30492849247F220822FFA2082A08240820082000209A
+:20ECC0001208111810A0FFFC124417FC1A443244D3FC1040104017FE1040104050402040F5
+:20ECE000000079F849084908790849F8490849087908490849F84800480048004BFE9800D1
+:20ED000000001FF01010101010101FF010101010101010101FF0000000000000FFFE0000E9
+:20ED200010001FFC20005FF800007FF0021012D00B1004903A5012900B0A050A1886E062EF
+:20ED400010001BF812082208220873F8A2082208220823F82208220020002FFE20000000E5
+:20ED60001208110811101BFC562453FCD224122413FC102017FE10201020102010201020EF
+:20ED8000408020802288029094E0509051082684208024B0C4C0494041204218440E580496
+:20EDA00040002E0C327022100410E4502F5E215021502950257E2A0035002880107E00009D
+:20EDC0000208F90C08900BFC7A4443FC42444244FBFC4A4408400FFE084008405040204022
+:20EDE00000007FFC0108110011F81100290047FE81001FF0111011101FF0010801FE7E048B
+:20EE00000080109008980C9008A000803FFC000400041FFC0004000400043FFC00040000C5
+:20EE20001020102012261124FEA810B015FE18023002D1FE10021002100211FE50002000BC
+:20EE40000100111009203FFE200440080FE0082008200FE00440044408440844103C6000C0
+:20EE600004407FFE044020001BF81020884069FC48A410A41124E244244428842128221073
+:20EE80001000102012241124FEA810B03BFE3402540251FE90021002100213FE1002100064
+:20EEA00000003FF80208020802080208020802080408040808080808100820F0402000001F
+:20EEC0001020104011F81108FD4811281508191031FED0821492149217F21002500A200466
+:20EEE000001C7DE04404444645247CA85440118E5D02510251DE51025D02E1FE0102000092
+:20EF000010041FC41204220434146894AFD4229422142FD422142214220423C42E14200825
+:20EF2000020004001FF0101014101310125010201FFC04040404444444447FC4002800100D
+:20EF40002040104017FCF8400BFC10401FFE20887088A9FE21482228242828083028201044
+:20EF600000001FF010101FF0100410040FFC00200020FFFE082004200620042000A000406D
+:20EF800000047F840804122421247FA42524042404247FA40424042405840E04701420086D
+:20EFA0000C1C71E010021242FD2411283040399C5504550491DC11041104110411FC110453
+:20EFC00020402040207C204033F8AA08ABF8A20823F8204020402FFE2040204020402040C3
+:20EFE000021041202FFC2080010003F0E21023F0221023F0221023F0221050008FFE000041
+:20F000004100210029FC0A44124814C060A02110260E3FFC1248124812481248FFFE0000E8
+:20F020001040184027FE50409BFC3294229463FCA0002FFE200025442522250A28F82000F5
+:20F0400013F81A0823F84A088BF8100013FE3010501097FE1010111011101110105010202A
+:20F060001080108020807CFC4504450446047C8444444464442444047C0444284010000060
+:20F0800000007BA44CA84A924B147A0C15F610045DF85108510851F85D08E09007FE000053
+:20F0A0001000100011FE101054105410581090101010181024102210401040508020000003
+:20F0C00000803E9002A42448145008201FF8200E4FE4882008200FE00000082004407FFC26
+:20F0E00020803EFC28A0451085103FF80100FFFE002000207FFC04200220022000A000404C
+:20F100000024F7A898B095129314F20895EE9804F3F0921093F09000F21091248FFE0000A1
+:20F120003E904460282C17D0600E8FE408200FE00440FFFE00000FC008420842103E6000D8
+:20F1400000FEFE44024442482448145008480C441442124222424054804800400040004005
+:20F16000200021F8210821F8FD0821F8200027FE202021203D3CE120012002A0047E080069
+:20F1800008180C7C1BA0122022206220A3FE22202220222022102252228A234622220000B0
+:20F1A000408027FC211000A087FC5444544417FC244425F42514C5F444044404441444082E
+:20F1C000404020403040204007FC0444E44427FC24442444244427FC240450008FFE000089
+:20F1E00000400E6070401040107EFE881088108811887E504250422042207E50018E0604F9
+:20F20000104010403F7E28904508850801003FF8210821083FF82108210821083FF8200864
+:20F22000044084404844304452488A500A401CA028A048A0891009100A101208540E280428
+:20F240000080208011F8111082A0544050B0134E2C4023FCE0402250224824442944208051
+:20F260007EFC224412240A14122429440C801FFC10803FFC50801FFC108010801FFE10000D
+:20F280002040302023FE2108F8902BFE2A222A224AFA722212FA2A8A2EFA4A8A820202060B
+:20F2A0001000103C13E0FA20122012201BFE12203220D21012101210128A134A522620022B
+:20F2C000010000803FFE2000203827C02440244027FE24402440242045124E4A844600005F
+:20F2E0000020112011201124FD3E11E4172411241124113411281D203102C10200FE0000D3
+:20F30000044004407FFE05403FFC042002403FFE21045FF811101110111011701120010033
+:20F3200010401F7E28A045109FF800881FF8108010801FFC018402840C94708800800080AF
+:20F34000020001007FFE081004207FFE410481081FF01110111011101150112001000100A0
+:20F360000810042002407FFC010401043FFC210021003FFE0302050209141108210041002C
+:20F3800002104110212027F8004807F8E44027FC20C4214422442C54204850008FFE0000A8
+:20F3A0000080204027FC42084910F7FE1444204043F8F248024802481A48E25800400040D5
+:20F3C00008007EFE08103E20227C3E4422543E5422543E542254FF282424224642820000F2
+:20F3E0001040102013FEFE2012201220163E1A203220D2FC128412841484148458FC2084F8
+:20F400000040204017FC108003F8820853F8120813F8220823F8E2082FFE211022082408D1
+:20F4200000A0FCA013FC12A422A422A47BFC6AA4AAA42AA42FFE2800389029082204040224
+:20F440000100010001F8010001101FF81010101010101FF010100110288824444444000048
+:20F460000240024002401FF8124812481FF81248124812487FFE042006100C18180C2008AF
+:20F480001040FE2011FE7D041000FEFC00207C2044A07CBC44A07CA045604520561E4800C6
+:20F4A0001080108010807DF010901D90F0D0512A120A550621001FF8010001007FFE000079
+:20F4C0000100010001003FF8210821083FF82108210821083FF821080102010200FE00008A
+:20F4E00008000C001BFE122222227222A22223FE222222222222222223FE22022000000079
+:20F50000100010001FFC200420045FF4911411141FF4111411141FF410140004002800107B
+:20F52000010000803FFE20802080208020FC2080208027F824082408440847F88408000043
+:20F540002080204027FE3420AC20A420A43E2420242025FC250425042904290431FC00003E
+:20F56000081004207FFE02801FF8148818781FF810081FF80100FFFE02C00C30300EC004C9
+:20F580004080204027FE040480004BFC484010401240227CE240254024C02860301E20002E
+:20F5A0007F78414841487F484048528652007F7C524452287FA840105228A146C1840000A1
+:20F5C0000000FDFE1122112221FE3D2265FEA502257A254A254A3E7A22022402040A0804A9
+:20F5E000000003FC7C044404441444244424444444847D04440400040004003C00080000B7
+:20F6000000507E484A487EFE4A904B907EFE42905E9052FE5E90429042904AFE84800000A7
+:20F62000400027FC344425F40444144417F4240425F4E514251425F429146804301420088A
+:20F6400000003FF8000800080008002800C803080C0838081008000800080038001000009C
+:20F6600010401040107CFC4013F8120817F81A0833F8D040104017FE10401040504020409C
+:20F6800000001FF01010101010101FF0111001003FFC21042104210421042114210801009C
+:20F6A0001040104020403EFE20827D0252029042FE221012101212021402180A1004000003
+:20F6C00043FC2244324423F40244E3F4220422F4229422942AF432942404040408141008EB
+:20F6E00000207D20452045FC452046207C2013FE50205C205050505050885C8CE106020456
+:20F7000004201C18626C03801D60E3DE0C2434C003000DFC32080C10326001801E00E0006B
+:20F720000048F94827FE214821482178790069FEA8202BFE286028B039282A24242200206A
+:20F740001048114813FE7D4855485578550055FC7C2013FE14701EA8E4A401260224042022
+:20F7600040402240324023F804400440E84027FC204020A02110220C240850008FFE0000BF
+:20F78000024882486FFE42480248E278220023FE204027FE20E02950324824460844004009
+:20F7A0001FF00420024001803E7C1448083014487FFE40020FF008100F1008F008107FFE27
+:20F7C00000007FFE010001000100010001000100010001000100010001000500020000009A
+:20F7E00000007C0447FE44207C204420442044207C204420442044207C20442040A0004030
+:20F8000000007FFE44204420442044204420442044207C2044200020002000A0004000008F
+:20F820001000100021FE3E2040207C2090201020FE201020102012201420182010A0004043
+:20F84000000003FEFC40108011FC1104112411241124112411241124105051882606000214
+:20F86000000007E0052024A42664252427E420043E7C02407E7C12441244224422444244BE
+:20F880002040202023FE3A04400079FCA0202020FD20213C212025202AA03260243E0000F6
+:20F8A000020001003FFE200440081FF001001100110011F0110029002500430081FC00004A
+:20F8C0004000200013FE00100010F010101010101010101010101210141018501020000019
+:20F8E000001003F83D00010001003FF801000100FFFE01000320061008081FFC0808000013
+:20F90000020002007FFC04000880088010801FF8008008A00C901888108C22840180008006
+:20F92000040004000BF014206240018003800C60321EC10400C008800600018000E000407A
+:20F940000440FFFE04403FF801007FFE01001FF011101FF011101FF001003FF80100FFFEC7
+:20F9600021102FFE211033F8A840AFFEA04023F8224823F8224823F8204027FC20402FFE23
+:20F98000002000207E20002000FCFF2410241024242422244F44FA444084011402080000A0
+:20F9A0001040104013FEFC40108030A0392055FC50209120112812241426102210A0104054
+:20F9C00010001FFE140235FA24026402A5FA250A250A250A25FA250A2402240A2404000033
+:20F9E000200023FC220433FCAA04AA04A2F422942294229422F4220422042214220800009D
+:20FA0000008080806FFE21001140124024482FFC2040C2504348424C4446484451404080AC
+:20FA2000400027FC240404048DF44C0455F4151415142514E5F424042404240424142408D9
+:20FA40001100321C47C4444447C44444444477DC000008400840084010441044203C40002A
+:20FA6000101011101090FC901010151018903090D01E17F010101010101010105010201067
+:20FA80000040084004400640124008400C400440007EFFC00040004000400040004000406D
+:20FAA000004078404BFC5040604057FE484048404A406A7852404640454048C0503E400093
+:20FAC00000007FFE000000001FF01010101010101FF00020103008200440FFFE0000000062
+:20FAE000000047FC200023F002100210E3F0200022102110212027FC200050008FFE0000B5
+:20FB0000010000801FFE100097FC500053F81208320853F890001208211020A05FFE8000F2
+:20FB20000800083E7EA209240A28FFB0082810243F226122BF22213A21243F2021200020C0
+:20FB400008000FFC0888FF482C504A3088CE2B041FF010101FF010101FF010101FF0101084
+:20FB600001003FFC01001FF801007FFE00001FF01110FFFE111010901FFE00100050002028
+:20FB80001020502051FC7C2053FE9002152418A03220D12017FE1040108811041202140289
+:20FBA000004088404840304033FC4A448A441A441BFC2A4448508848087C17C4520420009A
+:20FBC0000040404033FC204007FE0104E4A822A0222027FE20202050288831042206040452
+:20FBE0001040104013FA1044FC4817FE102010C011FC170411041DFCE104410401FC010429
+:20FC0000004078444BF4484848507FFE4840488079F84B084D0849F87908490841F8010846
+:20FC200000207C2445FE4424542857FE5420544054FC5584568410FC2884248446FC8484D3
+:20FC400000001040104010401040FE4010403BFC34405440504090401040104017FE100072
+:20FC6000202020103BFE224842487BFEA2482278FA0022FC224422282A103410242808C68A
+:20FC800000203C20242024203C2025FC242024203C20242024202420442057FE88000000F2
+:20FCA000010000803FFE222022202FFC222023E0200027F82210212020C04130460E98049F
+:20FCC0004080204027FE0490949057FC549024F0240025F8C51048A0484050B0630E4C0495
+:20FCE00010401020101010FEFE822482248244FE44823480088014802500410082000400C6
+:20FD00004020212421240124FDFC08008BFE482053FE525212521E52E2520252020A02047F
+:20FD2000200023FE20003E0050F89088FE88108810F81008190424882488405083FE000000
+:20FD4000208023383A28422843A87A46A200227CFBC4222822A823102E28324E228400006F
+:20FD600006F83888208820883C88210E22003DFC210820902C503020E0502088230E2C0449
+:20FD80000400440E65705540564044407F7E4C48564855486448448844887F0802080008E0
+:20FDA00020002778444844489748F4462480447CF744042404283710CC2804440484040051
+:20FDC000214021B0212023FEFA2026202BFE2220222023FE3A20E220422003FE02000000A0
+:20FDE00010400C6004801FF010101010101010101FF004400440044408440844103C200051
+:20FE00000040FC4088409040A04090408840884088A0A8A09110811082088406980400003C
+:20FE2000001000107C10041005FE441024101910089014D02490221042108010005000209A
+:20FE4000242022302FA02020277EF54427A420282FA821283A90E7105A2802460A840500CE
+:20FE600000400040F8408FFC88408A488A488A488A48FBF88A48804000420042003E0000E8
+:20FE800001087C9047FE445045FC7D54119C11745D0451FC500851FE5C88E0880028001057
+:20FEA00010400860FF4000407EFE42887F8800887E5004500F20F820085008882B0E100498
+:20FEC00011FE10201040FEFC1084548454A454A47CA410A410A41230144819861602000060
+:20FEE00000007FFC410441045FF441044924492449244FE44104411441F440047FFC400419
+:20FF00001020102020203DFC40207C2091241124FD2411FC1020122014221822101E0000F4
+:20FF200000FC3F80208020803FFE2080208027F8240827F8240827F84408440847F8840831
+:20FF4000403C27C0244007FC044005F8E50825F8250825F8290829F8310850008FFE0000DA
+:20FF600027BE20A22524FB18231824A428C237FC6084A4A82328219022A82446B984400081
+:20FF8000008000F8F10893109CA0904092C0917E9686F10C92D884B000600180060018002A
+:20FFA000010001F8020804100B2010C003000C8071FE02040D083090006001800E007000F6
+:20FFC000010001007FFE028002400420081C3028DFFE0820042006200420002000A00040CB
+:20FFE000200021F021102110F910221E244020402FFE20E03950E24844460844004000402B
+:020000040001F9
+:20000000100020F87C8844887C8845067E204420FDFE0C70147014A825264624942008204F
+:2000200007C00440044004400840083C310001007FFC038005400930310EC10401000000EE
+:2000400000007CF04490449044907D10110E1240584057FE50E055505A4EE44408400040A0
+:20006000084010203C2025FE35042E482440FC48245C34602C40244024444446543C880044
+:2000800000043E0422242224222423A448240824FFA41C242A242904490488240814080866
+:2000A0002040204027FE3080A9F8AA20A7FE280021F8210821F8210821F821082128211033
+:2000C000004078404BFC508049F84B086DF8510841F84108411801007FFC01000100FFFE69
+:2000E000201020D02718F914A910AFFEA910A954F994A318291025323D52C58A02040000BC
+:20010000201020D027142114A910AFFEA914A956A994AB18AD10B928C948010A070A02045C
+:2001200008101820ECFC2AC428A4FEA4288C28803AFE6402AC0235FA2302A302410A00043B
+:20014000102019A8162422243FFE6220A22422A6232C26282A102230224A2E8A240400006C
+:20016000100008FE7F9051201EFE228254820C9212923E92E29222AA22243E422182000098
+:20018000412021203120222402260628EA30226022A02220222022202A223222221E0000CC
+:2001A000200030D023902094F8942FFE2890489450D45198529030A828CA4E868902000053
+:2001C00000003FFC0240224812480A500A6002407FFE0000090828842816681207F00000EF
+:2001E00000003FFE2000200027F024102410241024102450242044044404840483FC00004C
+:20020000200023FE2200FA0022F822482A4832486248A268245024402442A842503E0000A7
+:2002200047F8240827F8040807F80200E3FC24842CC4252427F42004200C50008FFE00001F
+:20024000778054BE54A277A400287F300028FFA410221F22013A0124012005200220002087
+:200260002070239820943C9047FE4890A09020D421942298209020AA28CA328621020000BC
+:200280001FF81088108817F81088114812281FF800000100288828844816481407F00000B8
+:2002A00000007FFE020004003FFC244424442444244424442444244424442454240800009C
+:2002C00004400440044004400440044004400440044004400840084210421042203E4000A2
+:2002E00000007FFE081008100FF0081008100FF00810081008FEFF9000100010001000101E
+:200300000400060008000FFE11042088448006A004900888108C208840800080028001006C
+:20032000200023FE21083F0845F84908910811F81108110E13F8140818081008000800003D
+:2003400040002FFE2210021093F05210521023F022102210CFFE4010401040104010000021
+:20036000000000103FF80000000000000000000000000000000000047FFE000000000000B5
+:2003800000280024FFFE00203FA000207FE000203FA020A024A024A024920A12118A6086FC
+:2003A00002002240223022107FFE2400040007E00C200A200A20114020804160861C1808F5
+:2003C0003FFC244424443FFC0000200418440844784408440844084408440A040C140808E1
+:2003E00020803EFE28A0451092A0109010FE2F806084A0882050206021A22E12200A200626
+:2004000010801CD01898109030FE378050909098109010B0106010621192160A1006000008
+:20042000003001F87E000400030002107FF8002000400180060008003000580087FE000089
+:20044000100009FC080422C422A424F42F84349424A424C427542454243424142004200CB9
+:2004600020401040104000408BFC48405040104017FE2040E08020802108220427FC200442
+:2004800000200020F820202021FC20202020F82023FE2040204020903908C3FC0104000079
+:2004A0000440FFFE0440440033F824908FFE51C052B01C8EE7FC248827F8248827F82408A5
+:2004C000100011F011107D105510551055905550557055505D10111211121212120E140094
+:2004E00000F83F00091005247FFE03400D203118DFFE111011101FF0111011101FF01010AE
+:200500000E00F1FE52223422FF3238AA54A69222FE6692AA9332FE2292229222FEAA00447A
+:200520001008148813087ABE10083A9C512A92881108FFFE0100028004401830601C000888
+:2005400001F0FD101110111021103D9065506550A51025103D10251222120212040E080023
+:20056000200020F83C88208840887C88A0C820A8FCA82088208A210A290A320A2406000021
+:2005800040407E40807E7E845348FE284A107F28034604401F8002200FF0011009201310B1
+:2005A00000000FE00820082008200A20092008A008A00820082208221022201E4000000005
+:2005C000100013FE1020144059FC51045124912411241124192425542448408C81040604BB
+:2005E00000783F80200020003FF0281028102420242022402180218042604C1CB0080000F7
+:20060000000843FC2200320023F80208E30822902250242024502888230450008FFC0000A1
+:2006200004200420FFFE0460400031F891086108490809381110E1002104210420FC20008C
+:2006400000007C3C45E05500550055FC558855485548555055202A202A504488890612045C
+:20066000000048FC288410841884288444840C84149424884480848204820882287E100072
+:200680000000201C21E03F004500490081FC1184114811481130112016501A8E15040000F3
+:2006A000403C27C020800840884057FC5008101020202040E08021002600290020FE2000AE
+:2006C00000801060102017FE1080FC80108010FC108416841884E1044104020404280810FF
+:2006E00004200420FFFE042005200080FFFE0400040007F0041008100810101020A040404C
+:20070000020001000080FFFE0200020003F00210041004100810081010102090C060000008
+:2007200000403C20241027FE3C402440247C24443C442444248444844484550489140208BC
+:20074000010000803FFC20043FFC208020403FFE2200220023F82208440844088850102018
+:2007600000807C40484053FE50806080508048F849084908690852084208440848284010E1
+:2007800010401030102011FEFC402440247C2444484428441884148425044228841000008F
+:2007A00008800C60182417FE20805080908410FE10841104110412041244142818100000D4
+:2007C00040802060304027FE00400040F07C104410841084108415041904123804100000B4
+:2007E00000402030302027FE4840F040107C20444044F884008400843904C2140408000025
+:20080000104008600840FEFE208420843D44264824282430241024304448448E950408007E
+:2008200004400440FFFE044004407C7C044004407C7C04400440FC7E044004400440044021
+:200840000440044004407C7E0440044004407C7C044004400440FC7E0440044004400440B8
+:2008600001200120F120973E91209120973C91209120F1209F3E81200120012001200120A6
+:200880000000FFC000400048005000600060005000480040002000220012000A00060000C5
+:2008A00000003DFC252425243D24252425FC25043D002500250025004502550288FE0000A9
+:2008C00000007FFE424042405E7C424042405E7C424042407E7C4240424042407FFE0000DE
+:2008E0004120212031202F3E01200120F73E2120212021202F3E21202920312021200120B4
+:200900000040F05090489048904097FE9040904090A0F0A0912001100218040E08040000E8
+:2009200000203C2027FE24203C2025FC252425243D242524252425344528542088200020CE
+:20094000010000803FFE2100292029102FFC210021F82210231024A0484050B0A30E0C045F
+:2009600041202120212007F88928492857F815202520E7FC212422242224242C282020201E
+:2009800002403FF802483FF822403FFE0442084A1FF4681009100910091002C00C3830100A
+:2009A00004400440FFFE0440044008200C10080817E62224422004200420082010A02040B1
+:2009C0000020FE1028902888FE88AB06AA04AEF8C2488248FE4882888288FF28821000000F
+:2009E00000200120F9A089108A188A0E8C048BF88888F88888880108010802080428081037
+:200A000010001FFC20005FF880007FF00210111010903F50C9100908110A110A6506020254
+:200A200008800C800840102010302018400E9FE40420042004200420082010A020404000D9
+:200A40002020212021A041104910F208140623F0F890409000901910E110421004500820B3
+:200A600010801060104017FE1108FF0811081090109016601860E0604090010802060C0479
+:200A8000081008107EFE18301C582A944B1288100100091809A0124004200810300EC004E0
+:200AA00001202120112011108210520854061BF02090E09020902110211022102450202019
+:200AC00010101098949054905908FD08320637FC5888548850889088110811081250142001
+:200AE000010001007FFE02800440082010103FFED11411101FF01110111011101FF0101085
+:200B000009300DA0092012101208240E6804B7F82088208820882108210822382C1000005D
+:200B200004200420081010083FF6C2100410085010206100088848A44826883407E00000AC
+:200B4000204023F820403150AFFEA910A00023F8220822482248224820B0230C2C04000081
+:200B60002108111009207FFC05400930310EC4443FF804400440FFFE0000082008181008A6
+:200B80000100010001083FFC010001103FF8010001000104FFFE01000100010001000100BD
+:200BA000080808087F080808087EFF880808084808287F28080808080F0878282010000033
+:200BC000200023F82208FA08222833286AA86A486248A2A8231A240A24062806200220004C
+:200BE000108010F810887D5056205450558E56247DFC102015FC1E20F7FE402000200020F4
+:200C0000208020FC2088A988AA50AC20A8DCAB48A840ABFCB840EBFC804007FE004000404F
+:200C2000208020803DF8419042607890A34E2040FBF8204023F820402BFC3040204000406E
+:200C400000001FF810081048146812481148108810881148126A242A282640068002000075
+:200C6000010000801FFE100097F85408552814A834485448A4A829282A2A480A5006A0024F
+:200C8000104010FC108815505A2050D853261DFC102011FC282027FE40204020802000209D
+:200CA000020043F0252020C00120069CE08027F0208027F020802FF8208050808FFC000027
+:200CC000000047F82008290809100910111013FC2104E0042FF4200420042004202820100A
+:200CE0002040307C248842485230E04826A642F8FA2002F802203BFCE220052008FE000068
+:200D0000800043F8620842080328E2A82248224822A822A8230A2A0A340A24060802000074
+:200D200001007FFC01003FF801000200FFFE042009103FEEC10401003FF801000100010095
+:200D400000001FF0101010101FD0105014901290111012902448286A500A400680020000CC
+:200D60000890089017FC1094309437FC5490949017FE10921092111A11141210121014107C
+:200D800000007FFC0080018003200D18190C610401001FF01010101010101FF01010000066
+:200DA0000100010001003FFC0100010001007FFE010002800240042008301018200E4004BA
+:200DC0000A20FFB008207F20497E7F4449A47F2849280428FF9010101F2821C62504420070
+:200DE00000403C40244027FC3C402440244027FE3C40244024A024A0451055088A06040495
+:200E0000100C20F05702555455545500777C55085510571075FE1410241024104450842053
+:200E200020402040204023FCF8402040284037FE6040A04020A020A021102108A20E4C04E4
+:200E400010A010A013FC10A4FCA413FC1AA012A033FED0A210A2112A1124122054202020A9
+:200E6000100011FEFE0020FC2084508450FCFE0011FE11221DFEF122112211FE11021000A2
+:200E8000200023FE2000F9FCA904A904A9FCA800ABFEAA22ABFEBA22222223FE22022000B2
+:200EA00020003FF84000BFE000007FF0001009103FD009503FD029103FEA092A116661027E
+:200EC00020403F7E485044888910081017FE10103210511091901090101010101050102077
+:200EE000108018D0108C108820802FFC6080A08020802140212022302218240E280400004F
+:200F0000107C1FC01488324C225067FCA008203020402FFE204020402040214020800000D1
+:200F20003CFC2484248424943C88248024FC3CC424C424A824A8249044A854CE888400009B
+:200F4000203C17C0100804888A50480053F0102020402FFEE0402040204020402140208057
+:200F60002040102013FE00008908489050A017FE200023F8E2082208220823F822080000A4
+:200F8000200013FE1000FDFC0504090411FC30005BFE9622122213FE1222122213FE1202E1
+:200FA000409030D02094FD140B7E0D1011103510D5101928152813281144114611841100A0
+:200FC000044004407FF8044804483FF8244824403FFC04440444085408481040204040000C
+:200FE000012001107FFE01001FF8110811081FF8110811081FF811081108110811281010F4
+:20100000100013FC1040FC40104014401BFE3060D06010A010A0112011221222541E20001E
+:20102000102010281024FFFE202029FC4924FD2409FC09243D24C9FC092409240924092C10
+:201040001080184017FE348824C86488A57E250827482528252825082908292831100000B6
+:2010600008200C10384CC488030006C01830EFEE010001000FE0110809100920FFFE000025
+:2010800004201818666401800660781E00680F8008000FFC0840104010402040C040004023
+:2010A00000203C28242427FE3C2025FC252425FC3D24252425FC2524252445245534892858
+:2010C000004078204BFE4A447A644A444AFE4B444A647A544A544A444A444A44AA54944880
+:2010E000010000803FFE24102610241025FE2C103510249024D024904410441084500420F4
+:20110000010000803FFE241027FE2C903490245024A02FFC29442AA4288449444A34880853
+:201120000420042004207FA004200430FFAC0426242427A02420242054204C2087FE0000FB
+:2011400000027FC200123F92209220923F9200127FD244527FD2445244427FCA4044000001
+:20116000FFFE04407FFC44447FFC12002BFC4C009BF8324853F8910013FC150810F0170EF1
+:201180000010F8108BF48814AFFEA890A890AA90AAF0AA90AA88228A53EA4E0688020000F8
+:2011A00008000FFC10002FF848080FF808080FF8040007F80C10126021800660181E600445
+:2011C000105018481FFC104027F8244877F8A44827F8244820102FFE211021102050202004
+:2011E00008100C101010101027FE301054109210111011901110101010101050102000005D
+:20120000010002001FF010101FF010001FF010101FF001000100FFFE01000100010001003C
+:20122000044006200C18180C2024483004200440024001800180024004201818200EC0040C
+:2012400001003DFE250027FC3D0425FC250425FC3C8024FC2488255026204450548E8B0416
+:20126000040007E0082010403FF05010101011101110111011101290024004301818601020
+:20128000020001007FFE4004BFF800001FF010101FF000003FF821083FF821083FF8200876
+:2012A000004040403040204000400060F050104C10481040104012401440184010400040DC
+:2012C0000108790849084A0852FE660852084A884A484A486A0852084208420842284210B7
+:2012E00010001000100011FCFE0412042204240444FC240418040804140423FC42048000BE
+:201300002050304827FC40404BF8F24823F84248FBF8024800101BFEE0900090005000204A
+:2013200001080188F108920892FE96089A0892889248F268924882080208020802280210B6
+:2013400001200FFCF12097F8940897F8940897F8F20097FC8E44144404A4051407F4000CF4
+:20136000000407FEF08093F89208938892789208F3F89024007E07A8003C00600192060E01
+:201380004080304027FE00400048F088111013F0102410481190163018C811060604000060
+:2013A000004000607C40044004FE04887D88428840504050442048605090630E4C04000063
+:2013C000200027BE2488FCA827A874A86CBEA788A4182518249825A826AA244A21862000ED
+:2013E000100011FE20203C20403E7D2091201120FDFE10021002100210021402180A1004A6
+:20140000082004487FFC010001103FF801000104FFFE00003FF8244824482448FFFE000019
+:2014200040002F7C291009108F504950597E1F1028102A28C9284B484C8A490A460E000066
+:2014400000003FFC0100010001000100FFFE01000100010001000100010001000100000048
+:201460000820082008200820FFFE08200820082008200FE008200820082008200FE0082089
+:20148000100011FC1020FC20102030203BFE34205420502090201020102010201020102052
+:2014A0001084108410841084FDFE10843884348454FC508490841084108410FC10841000C9
+:2014C00020403F7E2850448885083FFC010001000100FFFE010001000100010001000100DD
+:2014E00000003C0025FC242024203C20242027FE3C20242024202420442044205420882036
+:201500000800080008FE7E1008100810FF1008FE48104F10481048104810B8008FFE0000DE
+:20152000005000483FFC20403F4820482F3029204F32404A800609082884281667F00000FE
+:201540000C08F1FC10201420FE20302030205BFE54209020102010201020102010201020CB
+:2015600000407C6004400440FEFE24883D8826883C50245027203C30E458048E070404001C
+:201580001040007C7EC82530FE4801867CF844207DFC44007DFC1124FD241154108813069D
+:2015A00000003FFC20042044286424442284210422C424642834301420042014200800001B
+:2015C00000047F044124632455245524492449245524552463244124410447144208000004
+:2015E000200021FE3F02210A418A7D52A1222122FD52214A218A210229023102210A01048A
+:201600002000300020FE3F10481088107F10081049104910491049104F1078FE000000003D
+:2016200000003C0027FE24203C202420242024203C20242024204420442057FE8800000054
+:20164000100013FE2202220A4A8AFA4A123222124232FA4A028A030A1A02E202020A020426
+:201660000100210821083FF800003FF820282C282248218822482428282820082028201054
+:201680004120212027FC012091205FFC5120221027E84A2ED3E442004208420841F8000068
+:2016A0001000100013FCFC4010403040384034405440504090401040104017FE100010004A
+:2016C00010401F7E289045087FFE042007E000003FFC200427E4242427E420042014200853
+:2016E00001001FF010101FF010101FF011100204FFFE08201110210EDFF40100010001000A
+:2017000002000100FFFE00000FE008200FE000007FFC40044FE4482448244FE4401440082A
+:201720000100FFFE10101FF000007FFC50145FF400001FF010101FF010101FF0101010307D
+:201740000820043002407FFC010001001FF801000100FFFE00002890244846664444000000
+:2017600011041088109093FE54205820FDFC3020382057FE500052A49252125214521000A5
+:201780001040102013FEFC0011F8150819F83000D3FC120412F4129412F412045214220818
+:2017A000204020203BFC200041F87908A1F82000FBFC220422F4229422F42A043214220822
+:2017C0000C40702013FE1000FEF8108838F8340053FE520292F2129212F21202120A120403
+:2017E0001100190011001FFC210041000100FFFE00001FF01010101010101FF01010000095
+:2018000000007FFC00101F9010901F9010900004FFFE00101F9010901F9010900050002080
+:2018200000207F2002407A7E4A847B280220FFA002207A204A204A507A48028C0B06040454
+:201840002200217E24022482FCFA258A2E523472648EA7FA248A248A24FA2402A40A440407
+:2018600002000240022002007FFC021002180110012000C0008003400C247014000C0000E4
+:201880000820084018F824C822A84088FEA8009000FC7C04440445F444047C0444140008EF
+:2018A0000080788048F849887A88485048204850788E4B044DF8490849084908A9F891083E
+:2018C000008000401FFE1200920053FC5400180033F05020904010801102220223FE400041
+:2018E000080404047F8448A43F2408243F2408247FA400243F24210421043F142108000057
+:2019000004400440FFFE044007C001001FF0111011101FF00100FFFE0100010001000100D4
+:201920000440FFFE04401FF010101FF010101FF008000FFC11043284D4441FE41014000890
+:201940001080108011F8FD0812903450382054D8570691F8110811081108110811F8110843
+:201960001020102010507C505488550656FA54007C0011F8190815081F08E5F80108000030
+:20198000200017FC020443E444444A84410446C4783447C44444444447C440044014400890
+:2019A00000007BFC480051F8510861F850004FFE4D126CA255FA444244424442444A4404AC
+:2019C0001080108020FC3D0441887E5090201050FC8E130411F811081508190811F80000D9
+:2019E000010001000280024004200918110E61040100010001000100010001000100000051
+:201A00000400040007F00C201220624001800660181EEFF408100810081008100FF0000068
+:201A20001040104020A020904908F20E15F420004000F9F8010801081908E10801F80000D6
+:201A4000100011F81108FD0811F81108390835F85184514C913011101148118E110410004E
+:201A600000007DFC4504450445FC45047D0411FC51205D245118511051085D48E18601041D
+:201A800010881088FE8810887DFE10881088FC8813FE3888348856889488110811081208F6
+:201AA00000007FFE01001FF811081FF8110811081FF809000500020005801860E01E000805
+:201AC000010000803FFE20802FF820883FFE208820882FF82088214042204410880C1008BA
+:201AE00004207FFC01001FF80100FFFE44223FFC01003FFC0100FFFE02800460181C6008D4
+:201B0000200027FE202023FEFA22222223FE2222222223FE3D20E0A0006000D0030E0C04C7
+:201B20000020FE20442044247CA644A444A87D20442044204E50F448044804860484050003
+:201B4000200023FE2020FC2021FC712469FCA924A1FC2220212020C020C023302C0E200473
+:201B600000003FFC01000100010001000100010001000100010001000100FFFE0000000022
+:201B8000010001800100FD0013FE1308150819081090149018602060C190060E380400007E
+:201BA000002000207F2008200BFC08240824084409440E44F0844084010402780410000009
+:201BC000044004403FFC044004407FFE0440082011102108C10611501128212805000200D6
+:201BE00002400220FFFE049004E40B84347CC4403FFC04407FFE00400820101860080000D1
+:201C0000100019101110211037FC6110A110211021102FFE212023102218240C2808200027
+:201C2000080010FC3E0422043E04227C3E4022407E7C06040A0412042204C2040A2804100E
+:201C40000000044006400440082008101018220E430402000420081011F83F181010000019
+:201C6000010000803FFC20044FF8081008100FF0081000001FF81008100810081FF8000080
+:201C800000003FF8000800081FF81000100010001FF8000800080008000800080050002007
+:201CA000000001F8FD08110811081188114811281D283108C208020A040A080A100600003F
+:201CC00000003FF8010001007FFC010001107D2005C0094009201118210EC1040500020046
+:201CE000209020902090FC9023FC209028903090E09027FE2000211021082206A4024000E4
+:201D00003FF8010001007FFE00001FF01010111011101110111012800440083010182010F4
+:201D200000000420042004207FFC0420042004200420FFFE044006200C100818100C200845
+:201D40001040104020403E8040FE7D0292421042FE82109211FA100A10021402180A10043D
+:201D6000080008000FFC080412042304420404840444082413F41C24000400240014000832
+:201D800021001100110003FC8A044C045084108411042224E7F42014200420042028201091
+:201DA00004400440FFFE044014401FFC100420044FC48844084408440FC400040014000849
+:201DC00005004500290013FE32024C0289F219122912491289F20902080208045014200899
+:201DE000103C13C012001200FE0013FE1200120012FC1E84F2844484048408FC108400005F
+:201E0000104010401080FEFC110432443844548454A4911413F410141004101410080000A1
+:201E200000807CC0448054FE550255025642544254A2551211FA281224024402801400084A
+:201E4000204020403C7E448485487630546055A0547E5484754446280410282010C0030024
+:201E600001007FFC01001FF010101FF001003FFC08200440FFFE01003FFC010001000100C3
+:201E800004400440FFFE244030202020FDFE2420242049FC49043104110429FC4504840078
+:201EA00000400040F84088408FFE8840884088408BFCFA048A048204020403FC0204000019
+:201EC00010401F7E28904508940013FEFE2012FC16A41AA4F2A452B412A81220522023FEAC
+:201EE00008400C401040104427FE30406040A04023FC220422042204220423FC2204000099
+:201F000020401040104000408FFE48405040104013F82208E20822082208220823F82208AA
+:201F200000007E3C05D009501150155019503150D150514811481164125612FA5450200049
+:201F400010201820102011FEFC2024202420242045FC490429041104290447FC8504000029
+:201F600010201020FF2010FC7E2000207EFC428842887E50445028200E50F18E0E04000071
+:201F8000010001000100FFFE01000100010001001FF010101010101010101FF0101000007F
+:201FA000010001001FF8110811081FF8010801FC3F0800003FF8244824482448FFFE0000FA
+:201FC0001FF010101F10111011107FFE40040FF008100FF008100FF00810081008500820C3
+:201FE00008400C2019182108410002800440082010182FF6C814081008100FF00810000074
+:202000003CF02490249024903D10260E24003DFC248824882450245044205450888E010437
+:202020001040106010401040FEFE108810887D8846504450442044207C50418E0604000078
+:2020400000007EFE401040205EFC5284529452945694509452945494582890C603020000E1
+:2020600000007FFC410441045FF4410441044FE44824482448244FE4482440047FFC400465
+:20208000010000803FFC20043FFC2280244027FE2C4037FC244027FC4440444087FE040043
+:2020A00000040F847404042404247FA4042404243F2421242124210421043F042114000897
+:2020C000001001F81E4012401240122012201220122012101290225022A8432842068004F6
+:2020E00000043F04210421243F24292408247FA448A454A452A4628440844294410800008D
+:2021000001003FFE200440083FFC02000FF00C900A507FFE08203FF8C22E022404A0084005
+:2021200010401040104013FCFC40104017FE18403040D04013FC10401040104057FE2000B3
+:20214000410821082108FBE8090811082FE8690CB10A2BEA2908210821E82F082008200891
+:2021600000783F800100FFFE010009207928093C092009243926C93C01000100010000005D
+:20218000100010FC1084FE84108410FC1420182031FED0221022104210421082510A2204F7
+:2021A000200027FC22083110A8A0A840A0B0234E2C44204027FC204020402FFE2000000080
+:2021C0001040102013FEFA04100031F83908550851F8910011FC11041104110411FC110451
+:2021E00008200430062004487FFC010001000100FFFE01000280044008201030201C4008E3
+:20220000020001003FFE20044FE8082008200FE0080008000FF00810081008100FF0081076
+:2022200000003FFE200440003E08000800FE7F0812481228120822282212420281FE00003B
+:20224000000001FC7D0405244524452429241124292425544650449080920112020E04001A
+:2022600020803EFC51208A1001007FFE40041FE010201FE010001FF0101010101FF01010FB
+:202280002040202020207DFE450448F8A088208820F8208020FC2484288430FC2084000092
+:2022A000409047FE7C90539C929413DCFD2011FC132055FC552055FC55205D2071FE010023
+:2022C000200023F822482FFE3248AA48ABF8A00023F8224822482248224820B023082C048F
+:2022E00041102FFE011097BC54A457BC124023FC26202BFCE22023FC222023FE220000006D
+:2023000000001FF01110FFFE11101FF000001FF0101011101110111012900460181C60082C
+:202320000100211019180D10092001047FFE0440044004400440084208421042203E4000DE
+:20234000010000803FFE20002000200020002000200020002000200040004000800000009F
+:202360000000490026FC262019200120E3FC252029202120212025FE220050008FFE000041
+:2023800000400080FBF82248224823F8FA48224823F820A828B4313CC1220222041E180082
+:2023A000100011FC11047D24112411241124FF24112428502450269244924112820E0400F2
+:2023C000010001003FFC010001000100FFFE010001007FFC0100010001000100FFFE000042
+:2023E00000207E20102011FC202020203DFE6400A420242025FC24203C20242027FE000091
+:20240000080008000BFC480448044804480449FC4804480448040804100413FC20004000BD
+:2024200008000FE0102010403FF8510891081FF8110811081FF801000102010200FE000097
+:2024400020001BFC490441044FE441045FF4410441044FE4410441045FF44004401440086E
+:2024600010401040FE40204029F848484848FE48084808481E88E88A088A090A090E0A0019
+:20248000020004003FF821083FF8210821083FF80280029004A804FC08841082607E00005A
+:2024A000408020FE3084210803FEE2002200227C2244224422442A5C32482442083E1000D0
+:2024C00000803E9002A024481450082037D0C10E01047FFC0100024004200818300CC00437
+:2024E00020402040204023FCFC40204077FE68006840A04023FC2040204020402FFE200010
+:20250000100011FE1100FD00110011FC39043504550451FC910011001100110011FE100071
+:20252000008078FC49084A104BFE7A00120012F85A88528852A852905A82E482087E1000AD
+:2025400001001FF011101FF00100FFFE00001FF01010111011101110129004401838601005
+:20256000040404040A04112420E45FA4802400247FA408240924108427C47C942008000006
+:20258000200021FCFD0421FC2104510451FCFC00111011D21D1CF11011521392111E100098
+:2025A000408020402FFE012082184488512013F0109021882250E6203A102288230E2204C7
+:2025C000100011FC1104FDFC1104390435FC50005120912611B811201120112211A2111E95
+:2025E000200021FC3D04210441047DFCA02023FEFA222252224A228622022A02320A220443
+:202600001000087C7F4400483E4822503E4800443F4202420442075A7C440440144008404D
+:2026200000007FFC40045FF44104410441044FE44144412441245FF4400440047FFC40049D
+:2026400000001FF011101FF011101FF001000100FFFE038005400930310EC1040100010005
+:2026600001007FFE11101FF011101FF001007FFE07C01930628E045018206A180C060800D6
+:20268000401020103010201007FE00100210E11021902110201020502020580087FE000093
+:2026A00000400040F0A09118920E9C0493F89000F3F8920882080208020803F802080000DE
+:2026C00000407C20442075FE5440FE4882887DF044207C4445887C10442844C44F06440468
+:2026E0000040FC2007FE08401080110813F81810F02450481190163010485184260400006B
+:202700002100110011FE020097F85288524812082FFE2288E248220823FE2008202820106D
+:2027200010001FF820005FF000007FF0041002103FD008901F1002500C8A730A0C867042EF
+:2027400002000180FFFE01000220043008601FC8091C02300C6070E003180C0C7004000099
+:20276000020001007FFE400281043FF801001FF001007FFC01001FF0101010101FF01010D0
+:202780000040F8200BFE48404840488449F87C10042234C4C7080410042814C60B0200001B
+:2027A0000000FE4828482848FEFEAA48AA48AA48CE788248FE4882488248FE7882480000F7
+:2027C0003E400440FF4022FE3EC823483E3027103A28C2C6000029042886681407F000008A
+:2027E0002200223E22222224FFA82230222822243E2222222222223A3E242220002000201C
+:2028000010201020FDFE10207C2044FC7C2044207DFE1022FE221022102A10241020102084
+:2028200001000100028006400930311ECFE80020004000801FF0101010101FF01010000031
+:20284000200013F81010082088405442554A14D224E22552E64A254A248227FE2402000015
+:20286000010000803FFE24447FF804401FF804407FFC04400B2010D8220E418400C0008015
+:2028800000103FF800300040118049244D344944438445445934451442047FFC400400003A
+:2028A000002000280024F7FE9420942097E4942497D89658F6508BDA0A2A104620820000E8
+:2028C00000003FFE24444630081810083FF8010001007FFE010001000100010001000100E9
+:2028E00010201020FE5010887D0647FC7C4446647D54114CFED4116412441154108810008A
+:202900002028202427FEF42027A82C2C37982690E69A2BAA280630402524250AA8FA4000F9
+:20292000100011F81108FDF8110815F8180033FCD020102017FE102010201020502020208E
+:2029400000001FF810081FF810081FF800003FFC01000100FFFE01000100010001000100C3
+:202960002028202427FE242037A0AC28A7A8A490279A2826280231442522250A28F80000F0
+:20298000200023F8220833F8AA08ABF8A00027FC204020402FFE2040204020402040000022
+:2029A00011FC1104110415FC1504590451FC900013FC1020282427FE40204020802000204C
+:2029C000200013FC0040804048404840104017FE2040E04020402040204020402040204093
+:2029E0002000100017FC0208820849104910111010A020A0E04020A02118260E2804000044
+:202A0000010001007FFE02800240042009301118210E5FF40110021002100410085010209A
+:202A2000108010401040FBFE1000300039F03510511051109110111212121212140E1000BF
+:202A4000084010203C0025FC34002CF02490FC90249034902C90249024924512550E8A002F
+:202A6000204027FC200023F8FA0823F8200027FE288A21DC36A0E15046A8012606A4004081
+:202A800000400FFEF00093F8920893F8900097FE9802F7FC91888EF003500CAE03240CC000
+:202AA000020001007FFC08200FE000007FFE4004BFF80600091073200CC073B00C8E730457
+:202AC00001007FFE00000FF008100FF000007FFE40040FE001001FF001003FFA010200FE67
+:202AE0000800083E7F2208240824FFA812281224532252A292A2223A22244A20842000200B
+:202B0000100011FC10081010FC202420242027FE44206420182008201420262044A0804031
+:202B20001008101CFDE010207C3C11E01020FE20103E3BE03420562054229022101E1000B4
+:202B40001FF01010101010101FF00000FFFE080008001FF0081000100010011000A00040B2
+:202B600020401040124003FC8A404C40504017FE10002000E3FC22042204220423FC220493
+:202B8000000007FEF80488048BE48A248A248A248A24FBE48A24800400040024001400082C
+:202BA00000007BFC4A044BFC4A044BFC49004BFE7A2246220A52028A03FA000200140008DB
+:202BC00004200420FFFE1420180017FE300833C852489248124813C81248100810281010A9
+:202BE00004400440FFFE0440444037FEA008500853C812481248E3C82248200820282010CF
+:202C000010401020102013FEFC401044388835F05022504490881310102810C41306100404
+:202C2000001000F83F00010001047FFE038005400540092011102118410E81040100010064
+:202C4000000007007800087C08447F44084418441C442A442B444A44887C0844080008008F
+:202C600008000C001BFE1008300827C86448A448244827C8244820082008202820100000C1
+:202C800001000280044008201018202EDFF4000000001FF01010101010101FF0101000005E
+:202CA000010002800440083037DEC0040FE008200FE000001FF0129012901290FFFE000044
+:202CC0000C803080D0FC548829485250882014D0270ECDF815082508C50805F8150808003E
+:202CE000100009FC4A0441044FF441044244478441244644588443645C2440044014400881
+:202D0000200017FE1008000888084BC852481248224823C8E2482008200820082028201058
+:202D2000200017FE1442844247FA4C420C4215F215122512E51225F22402240227FE24021B
+:202D4000101010107EFC10101010FEFE28482848ACCCAACAAB4A2A4A48484888A8A8111077
+:202D6000200019FC1104FDFC050409FC150039FE562296221A52128A13FA1202100A10042F
+:202D8000102010407FFC52C418A424A43E8C6880A8FE3E0228023EFA280228023F0A2004E3
+:202DA00008007F7C09440944117C254442000FF00810089008900890094002300C1C300884
+:202DC000000007FCF654955C956497FC9444904097FCF0409FFE00000524049208920000C8
+:202DE0003FF821082928254825883FF8010001003FF80100FFFE0000488444428442000082
+:202E0000010000841FFE100097F8540857F8140837F854849488245024202510460E8404BE
+:202E200010001BF822084BF88A08120823F86240A248225C222022102258228E2704220046
+:202E400000008BF85208220853F88A080A081BF82A404A448A280A300A501288530E22040A
+:202E6000200023F822083208ABF8AA08A20823F82244224C223022202290230E2204000028
+:202E800000800040FFFE900093F8920893F8900093F8F010902000200020002000A000402A
+:202EA000020001047FFE00000FF008100FF000001FF80030004000800080048002800100EA
+:202EC0002090209023FC2090F89027FE702069FCA124A1FC212421FC200020882106260246
+:202EE000220033DE4440588097C0255E67C4A54427C421042FE4210422842454282820007F
+:202F0000200027FC20003000ABF8AA08A20823F82208220823F8200020002FFE2000000008
+:202F200002007FFC040009001FF00100FFFE01003F7C028834880850142022584286010425
+:202F400001100110F9108FFE89108910891089108910FFFE890001900308020C0406080476
+:202F6000109010D8109014901BFC509050905090909017FE28202490410842048404000086
+:202F80001000100011FEFE209220922092209220FE2092201020142012201E20E3FE000097
+:202FA0004020204020FC0EC484A454A4548C248024FE2602D80243FA40024002400A00048C
+:202FC00020001110111089104BFC51101110111021102FFEE12021102208220C24042804D0
+:202FE000010000803FFE2204430802007FFE02000480048009001110220844FC0F880000EE
+:2030000000107E18021002103E202020202020407E4022400288028403FE028414000800D5
+:2030200010001000200425FE4420F820082010202020FC20402000201C20E02447FE0000F4
+:2030400002000378F20895FE94009C8094FC9520F62097FE842004500448048C048605045F
+:2030600010001BF0101020102FFE6200A3FC224024402FFE204020A021202218240E2804CB
+:2030800089004978310823FE52808E801AFC2B204A208BFE0A500A500A981288530E2204E1
+:2030A000001007D0F09091109110911091D097109110F1109110811001120112050E0200AF
+:2030C0003FFC20002FF828082FF828082FF820002FF8203020C02FFC40804080828001009B
+:2030E00010001BF8101027FE29006900A9FC29402A402FFE28A028902118220E2404000020
+:20310000007C1F80100010001FFC10001000100017F824082408240847F84408840800007F
+:203120000000003CFFC088488A4C8948895088408FFEF8408840004000400040014000806E
+:20314000000801FC7F00111009180D100524FFFE0100010001000100090005000200000052
+:20316000080008000FFC1244224444440884310406383810010028842892281247F00000D1
+:203180000100F93C212427E42124213CF92427A424A424BC2FA434A4C444004400940108E3
+:2031A000010001007FFC01003FF800007FFE44448448244C2450145014600440FFFE00008C
+:2031C00004400440FFFE0440080008FC08847FFC088408843EFC228422843E842114020874
+:2031E0000800087C0844FF44087C084408447E44427C4244424442447E444244029401089F
+:203200002100211E211227D2F91EA912A912AB92AA9EFA92229233A228223C42C88A0104DC
+:2032200008788BD052502250525092500A501A502A504A488A480A581454146C5846200071
+:203240001100111E95125BD25112FD1E11123BD23652525E525293D210221022104A108419
+:203260004200223C222402248FBC522412242FBC28A428A4C8A448A44FC4404440944108BC
+:203280000000F83C0BD00A500A507A5042504250FA484A480A480A540A742AD6144408001B
+:2032A000010001F001003FFC210821E02F0821F8200027C02440244424444446483C90008D
+:2032C00000400078F04097FE948494F097809488F478940084F0049004920912090E1200C0
+:2032E00010401030101010FE7E821082148218FE3080D08010801100110012005400280092
+:2033000000007FFC04000400042007F008200820082008201FE0082000207FFE00000000AB
+:2033200020401020102003FE42022A022A0213FE12002200E2002200220024002400280055
+:20334000010000C000401FFC1004100410041FFC10001000100010002000200040008000BA
+:2033600004400440FFFE044008000C800890189828A048C009800A8408840886087C08001B
+:20338000012001A079284B304B604DA44924491C4840784047FC004000400040004000401E
+:2033A00008800C88109C30E0538090841084107C110001007FFE010001000100010001009A
+:2033C000080089F8510821E8512897FE1C0229F8290849F8890809F80908110851282110DD
+:2033E000200013F8120883C8424847FE140413F8120823F82208E3F8220822082228221041
+:203400000000FFFE00000FE0492449244FE44924492449244FE4482440047FFC40040000CA
+:203420001004140412041024FFA412241324122414240C24182435246504831401080000CA
+:2034400008800C800888108C109830B050E090C0118012801480108410841084107C000025
+:203460004000201C33E02020002007FEF0201020102011FC11041104150419FC110400006E
+:203480001040108013FCFE4412443BFC364453FC5060906810A810B4113C1222141E1000BE
+:2034A00010001BFC220452049AF4129422946294A29422F422942204220423FC22042000D6
+:2034C000100013FE102010205840546094D010C8114C124614441040104010401040000096
+:2034E0004140212021200BFE8A2056205BFC1220222023FCE2202220222023FE22000000ED
+:20350000200027FE20202020FC40204020E020D021482A463444E8400040004000400040E1
+:2035200000800080FC8005FE85044A48284010401840186024A024904118860E38040000C8
+:2035400000007DFE1020102010607C6010B010A811241D2662220422082000200020002022
+:20356000100013FC10001000FDF83908350855F85108910811F81000100017FE100000000C
+:20358000400027FC3040204000800080E1A022902488288C20882080208050008FFE0000A0
+:2035A000203833C02088424C4950FBFC108017FE208078F801881950E2200258048E090458
+:2035C0001080108011F8FD10122017F812481A483248DFFE104010A01090110E5604200028
+:2035E000008000801FF810881FF800801FF810881FF80080008029042892481207F0000087
+:2036000001000100F1F8921094209BF892489248F24892488FFE00A00110020C04060804AC
+:20362000010000841FFE110093F0542057FC144834485488AFFE20C021204210440E9804CB
+:20364000111009203FF801007FFE04200FF0310EC614192066C019A06698188C628801008A
+:203660002100210021F022202C40B3F8A248A24822482FFE304028A048904118860E18041A
+:203680002100110013F0022094405BF85248124822482FFEE04020A020A02110220E2C04F0
+:2036A000020001003FFE400440081FF0110011001FF0101010101FF0110011001FF8000076
+:2036C00008000C0019FC100422044304FE04040408040A0411047F842104002800100000A7
+:2036E00004400440FFFE044001007FFC080008000FF800000920092009221122111E21006E
+:203700002110211027FE2110B040AFFEA200220023FC200022482248244A244A2846200013
+:20372000044004407FFC04400440FFFE01001FF011101FF0111011101FF0082010186008B8
+:203740000110FD1023FC211027FE20407BF86A48ABF82A482A482BF8380029100208040424
+:203760002040208021FCF904A9FCA904A9FCA800FBFCA020302029FC3C20E82003FE0000FF
+:2037800020403F7E509089287FFC0820FFFE01001FF011101FF011101FF0044008303010AF
+:2037A000020004001FF010101FF010101FF000007FFC010001003FFC01000100FFFE0000DF
+:2037C00000003FF8230822082FE828282FE828282FE820082FE821082FEA410A5FF68002D5
+:2037E00020802080210033F8AA08ABF8A20823F8200027FC204023F8204020402FFE200058
+:203800001040108013FC16041BFC520453FC900013FC30402BFC2440444447FE80000000FC
+:203820001FF810081FF810081FF8010011100D300540FFFE0240044008423042C03E000032
+:20384000200023F82208FBF8AA08ABF8A848AA4CA950AFFEB910211021122212240E280074
+:2038600020402040244C3248A950A160AFFE20A020A021202120222022222422281E2000C3
+:203880008108410867FE4148002007FEE100210021FC200022482A483248224A044A0806E6
+:2038A0000200020002047FFE04400440044C0C700A400AA010A011102218240E48040000B0
+:2038C000100013FE1244FC8013FC10801520192033FCD020102017FE102010205020202074
+:2038E000100013FE9644584051FCFE4028A028A029FC282028202BFE4C20482080200020A8
+:2039000021103558255057E0983E2FA46464AFA4221424142FD822082A8832542A262444EA
+:2039200021002100210037FEA940A940A248234822D02460246028903088230E2C042000DD
+:20394000100011FC11047D0455745554555455547D545174195415041F04E5FC01040000CB
+:2039600000007FFC400440044FE4482448244824482448244FE44004400440047FFC00007B
+:203980001000667842486E484248424E7E80007C7E040848082808100E30F0C80706000048
+:2039A0002100210021FE3200ABF8A508A948212827FE21082148212821FE2008202820102B
+:2039C00008207EFC08207EFC08207EFC08201FF800081FF800081FF82484241243F2000071
+:2039E000010001103FF801000100091009100810FFFE081008101010101020104010000045
+:203A000001007FFC01001FF011101FF011101FF001087FFC000409002888282467E40000E2
+:203A2000010001007BFE4A004DF84908794849284FFE49084948792849FE000800280010A2
+:203A400000207C20442057FE544054FC5584568454FC5084508428FC24844684849400882C
+:203A60000C20712211221122FFFE3122304058FE55049288145010201040108013001C00F5
+:203A80000100010002800440082010186FEE800400003FF802000420081011F83F18101038
+:203AA0001040104010A014901908520655F85800900417FE28802490450843FC81040000DE
+:203AC000200013FC1200020042002A002A000A0012001200720012001200120013FE100016
+:203AE0004040304027FE00400040E3FC2040204027FC2044204424442854304820400040AB
+:203B00000200420033FE140003F80288E24822082FFE228822482A0833FE2008002800103F
+:203B200010401040206020904888F10612F820004000FBFE004000801888E10403FE000441
+:203B400004200420FFFE04207FFE4204BFF8050009001FF001000100FFFE01000100010063
+:203B600001F03F0021003FFC20802080284430343FFC101010101FF0101010101FF01010B0
+:203B80002000303C21D02110FDFE2510254A2586490268FC108410FC2884448484FC008466
+:203BA000004000807BF8024803F8FE48224823F820A048A844B4FD3C052202220C1E00006C
+:203BC000200017FE1484808047FC51001140124027FC2040E0402FFE204020402040204091
+:203BE000200013FC120483FC4A044A0413FC102024202424E7B82420242025222622241EA2
+:203C000010500848FE8492A67F2410507C501088FE86117C7E48444844487C784448000064
+:203C20002000103C13C0004088404FFE50401040204023F8E20822082208220823F82208E8
+:203C400008400C4018401048324C22486250A44020A020A0211021102208240E2804200018
+:203C60000100018001000110111811201140110022800280044004200830101C200840009C
+:203C80000440FFFE044004404400285010482FFE4840984028A048908918090E2A04140020
+:203CA0000040005000487FFC004000403E40224C22483E30002002540C94730C0C040000C8
+:203CC00000A000907FFE00803E8822483E5000200E54718C000449084884C81407F0000086
+:203CE0001FF801007FFE41041D7801001A7021003FF851009FF811001FF811001FFC100026
+:203D000008800C8C18F033805084107C00001FF01010111011101110128004600838301060
+:203D2000200011FC11040104FDFC0820102033FE5A2296221252128A12021202120A12042C
+:203D40000100010001003FF80100010001047FFE010011081108110811081FF81008000011
+:203D6000100017FC11081108FD10111E1102118415841A483250C4300458088E130424006C
+:203D8000082008207FFC08200FE008200FE00820FFFE082011183FEEC10401007FFC000046
+:203DA000100010F81088FE881088108838883488548850889108110A120A120A1406100057
+:203DC0000040F840ABFCA8A0A910AA08FFFEA808ABC8AA48AA48FBC88A48800800280010B8
+:203DE0000C50704013FC1092FD12160E313039C4550450FC500091F8110811F8110811F8B3
+:203E00000C0071FC11041104FD0411043904350455FC5000909010881104110612021402C4
+:203E200020403F7E289045088A207FFC08200FE008200FE008200820FFFE04401830600CC8
+:203E40003CF02490249024903C902490249024903C90249024902492451255128A0E0000F2
+:203E6000200020F020907E9044904890A0902090209020902090251229123212240E0000D0
+:203E8000410020C030402FFE01200120E528252429263124222022A0244050008FFE0000E3
+:203EA000421024102F9008A08FBE58E41FA422283FA82428C790489048A850CE6284010028
+:203EC000400021F03110211001100110F1101110111011101110111215121A12120E0400DE
+:203EE00000200040FDF80588494829482928111019FC2804240445F4800400040014000826
+:203F0000100011FE11101110FD10257C2544254449442944117C11102910451085FE000007
+:203F2000104017FC204023F84840F7FE100023F84208FA480248024818A0E09001080208A0
+:203F4000000021F8210841F84800FBFE110811F821087DF80108013E1BC8E00800080008C2
+:203F600001000104FFFE0100010001087FFC000000001FF01010101010101FF0101000001A
+:203F8000100013FC1088FE88109010A038BC34C45548512891101210122814CE1B04100084
+:203FA00010201020FEFE10207EFC52A452A452A456AC1820347052A8912E162410201020E8
+:203FC000200021F8FD0821F8200053FE5108FDF8110811F83D08D1FE17081008100810082E
+:203FE00020403F7E509089087E4809FE7E4808487FFE18002CFC2A8448FC888408FC088405
+:20400000088008401FF830805FF810801FF810801FFC01007FFE03400520191C61080100DB
+:2040200000003FE0042004200440044004F80A500A100920112010C0212042188C0E30048E
+:20404000040004000FE0084010802FF000100FF000100FF0010028842892681207F000007C
+:20406000010000801FFE1200920853FC544038405FFE904010A010A021102218440E8804C5
+:20408000200013FC1108010889104910513C118412882248E43024302848318E26040000F6
+:2040A00000003E7C224422443E44224422443E4422442444225427487A402040004000405D
+:2040C0002020201021FEF94029402D7C4B9049104BFE351011102A282A24444688840000ED
+:2040E000100013F8208824884490F89010BE21447D44414802281A10E4300848118E060417
+:204100001080104013FCFD1010A0144019B0160E3114D11011101110111012105210241071
+:2041200000000FE008200820082008200820082008200820082210221022201E4000000044
+:204140000100210811300A9872482430180E6FF408100FF008100FF00810081008500820DD
+:2041600000003FF00010001000103FF0201020002000200020002004200420061FFC000078
+:204180000440FFFE044024443E0444247F24C9247F2449247F24402400240F047814000816
+:2041A000102010201020FDFE1020142019FC3108D0881090106010601090110E56042000B1
+:2041C00004407C7C04407C3E1FF011101FF011101FF004407FFC0440FFFE06401830601038
+:2041E00000F01F0001007FFC03800560191E6FC400400080FFFE010001000100050002001B
+:2042000010401860104817FC2040304063F86208A110211020A0204020A02118220E2C047B
+:2042200010001EFC228854508C60282010102FEE4004BFFC010009201110210845040200D7
+:2042400008020402FFD2011232120E12199220D2D11211121112111221022102411E8104F3
+:204260000000207C27C0204037FEA8E0A958A2462DF0202020402FFE20402040214020800A
+:204280004080204027FE011088A0484051B0160E11102110E11021102210221024102810AF
+:2042A000020001003FFE21025FF40280044008207FFE00100F9008900F90089000500020EF
+:2042C000010000803FFE480448000F78088808887F4808502C202A204B508A88290612043E
+:2042E00040202020302020200020F3FE10201020102010201020122014201820102000209F
+:20430000400021FC3004200400040004F1FC110011001100110011041504190610FC000056
+:2043200000007DFC442045207D20452045FE7C204060506048A054A0652242220C1E000019
+:2043400000001FF0001000101FF01000100810080FF80100088848844814881007F0000090
+:204360000000F9FC880090009000A7FE904088408A50AA48944484468844804081408080A8
+:20438000102010201020FDFC2420242025F84488488828881050105028204450818E0604EE
+:2043A00020203220222443244AA8FA2013FE22704268FAA402A403201A20E20003FE0000E1
+:2043C000100011FC200424044404F80449FC110021007D0001000D04F104410600FC0000F2
+:2043E00001007FFC01000FE000001FF010101FF00840FFFE10007E78124822484A788400BE
+:204400000000110011001100FBDC11543154395455545154915412541254155C108010000B
+:204420000100010001007FFC012011300D200940FFFE03000280044008201018200EC0041E
+:2044400008400C40184817FC30406044AFFE20402040204827FC2040204020442FFE2000D8
+:20446000020001003FFE40045FE8010002000F2072B004C019C066B0188E608405000200D9
+:204480000800080008007F7C09440944094409441144114411442144217C45448240000089
+:2044A000044004407FFE044001003FF811200D3009407FFE0280024004200818300EC0043D
+:2044C000100011FE7E20104092FC548418A4FEA410A418A424A422504248808603020000CC
+:2044E0000000FFFE04403FF824483FF800001FF01010111011101110129004601838601049
+:2045000000003FF82108210821083FF82108210821083FF8210801000100010001000100D2
+:20452000100011FE21223D2241227DFE91221122FD2211FE102010201420182010200020AC
+:2045400010001FBC1484248427BC6484A40027BC2444242827A824102438244E25840000B0
+:204560000C40702013FE1202FCF8104039883650506051B0966811A81626102411401080F6
+:2045800008400C4018A011103218640EA9142110211021102110221022102410241028106D
+:2045A000080008007F7C094409441144157C620001007FFC038005400930310EC10401008C
+:2045C00008007F7C11441144257C42000FE000200420042007FC00043FF40004002800107E
+:2045E0002040202023FE2204F9F828402888494C4ED04930526834A429264A2480A00040F0
+:204600000000FE1E11E010201E20222023FE6220942004200820082010202020C0200020A2
+:20462000048024C0248024FE254026202430041000003FF82488248824882488FFFE000055
+:2046400008000BFC4908491048A0484048B0490E0A0409003FF8010001000100FFFE000094
+:204660000100114019201118210C4504820001000100FFFE0280024004200818100E600405
+:2046800010401F7E28A04510844004207FFC020002007FFE012000C001420622781A000648
+:2046A000200013FC1004400447E44424442447E44424442447E440044004400440144008EA
+:2046C00008200440FFFE00003E0822483E4822483E4822482A28241048884444C666822233
+:2046E000082004407FFC04401FF804487FFE04483FF80C480C6014502448444E84440440FE
+:20470000010000801FF8100810081FF8100017F8140817F8240827F82408442884100000F9
+:204720000000FBF80A080A084BF82A08120813F812462A582E204A108258028E07040200CF
+:20474000100811FC10201020FC202420242427FE2420442028201020282044208420002077
+:2047600020283024202423FE4A20FBE41226222443D4FB58034835DAC42A084600820000EF
+:2047800008200820FFFE0820092001003FF8210821083FF821000108010401FE7F04000009
+:2047A0001040104010A0FD10120E380035F850005088924C11481150102017FE1000000002
+:2047C00001000100FFFE01003FF82108292825483FF80100038005400930310EC10401007D
+:2047E00000100018FC1423FE221042107BF4CA164BD44B544B487DDA452A444A0886100248
+:2048000000400040FEA010A01110220C25F67C006488A64C254825503D10242423FE00006E
+:20482000104010401040FBFE108013E018A0112033FED020112811A41226142250A0204056
+:20484000100010401040FCA0111013E8140618003084D24411481110102017FE50002000C5
+:2048600020403F7E28904508900009FC200427E4242427E42424242427E4200420142008E4
+:2048800008400C4018A01110320C6426ABF420002110249822D022A020202FFE20000000F6
+:2048A000081004207FFE00003F0421243F2421243F04251422087FFC02040404081430088C
+:2048C0000020402820242FFE08202FE42826282C4BA8CAA84A90539252AA204641820000B9
+:2048E0000440FFFE044005407FFE020004000BF8181028204FFE0840084008400940088002
+:2049000020A020A022BE22A0FAC0229072886888A000A3FC22A422A422A422A42FFE20007B
+:204920000880488049FE49204A1048100300048018606FDC01001FF009200540FFFE000000
+:2049400000407C50444C4448447E7DC01040107E5DC05024502850305E50F092010A00048A
+:2049600000607C584450447855C05440547C57C054485450102028502492470A84040000AC
+:204980001FF01010101011101110111011101110129002800480048408843086C07C000075
+:2049A00020202020277C392441FE7A24A77C2120F97C252023FE21202AA03460281E000076
+:2049C00020403F7E489095280840FFFE00003F0421243F2421243F24212421242514220860
+:2049E00010401A401340324023FC6440A44028402FFE20402040204020402040204020406C
+:204A0000102010202DF8242865FEA8282FF8222022F832202DFC24202A2031A020FC000019
+:204A2000080010FC3E84228432A42AA422A4FEA422A432202A502250225242924A8E850045
+:204A4000080408041424122421247FA48024112449A42524152412240784780400140008C7
+:204A60002040205020483E4045FC4840804013FE10401044102812321452198A16060000A1
+:204A8000420022062FB80220842056205A3E1FA422242224DFA442244244424442844204A1
+:204AA000802040285F24112095FE5520152035FE35205524C4284C104A32514A61064002F4
+:204AC000440022FC200404048DF44D14551415F425142514E5F424042404240424142408CD
+:204AE000004078400BF8104817FE20487BF808404BFC4840284017FC2840464081FE000074
+:204B000010001FFE100037FC244467FCA4442FFE200027FC244427FC244427FC20002FFE9F
+:204B2000081004207FFC01003FF801007FFE04000400FFFE08200E4001C003300C187010F5
+:204B4000088008FC09088B086C90482008C80B081FFEE8084908088808C808880828081048
+:204B60000880488028FC29080A902860C840098001187DA0054009201118610E0504020096
+:204B80002000100013FC0040884048405040104010402040E040204020402FFE2000000089
+:204BA000FBFE080009FC792441FC412479FC08004BFEE92449FC692489FC500027FE000011
+:204BC00004400440FFFE0440088088F849086E90486019902FFEC81049100910085008206D
+:204BE00004002440147E0C840D48143065200540FFFE0380054009203118C10E01040100BC
+:204C00000440447E2484148405681650242044400500FFFE0100028004400830300EC004B0
+:204C2000411021103110211007FC0110E11021102FFE2110211021102A10321024100810C2
+:204C400000007FFE400047E04400441047F844404440444048404840504040007FFE0000B0
+:204C6000048024F81D08169064600780FFFE04803FF8248828F830083FF820083FF8200804
+:204C8000008078F8491052A0504060B0534E48404BF86840524043FC404040404040404054
+:204CA00004200420FFFE052010801FFC30805FF890801FF810801FFC000028882666444442
+:204CC00010001100113E11E4FD2411243BE4352851285598955019181124114615821200EC
+:204CE00000A07C9011FE1110231025FC7D1065FCA510251025FE24003D54212A022A00005D
+:204D0000090008841FFE308050809FFC10801FFC108010841FFE1000288824446666422282
+:204D200000403C2027FE24803CD0250C260425083C88245024204450448855068A040000B5
+:204D40000200010001807FFE08200C18100C20200830046002C0018003400430181C6008B8
+:204D60000800043E7FA40028222821B040A8A22412220C2204320A2C112061200020002015
+:204D80002080108013FC00808090406451A4161C20002FFCC1204122422242224C1E400078
+:204DA000001CF9E0082048204BFE486048907C8805963690C49004900510291012100010D8
+:204DC000200823FC20402040FBFE28A0289049084A9674901090289025104110821004109A
+:204DE00007FC0288F15097FC9524952497FC9008978896FEF58897A80428050805880698E2
+:204E0000100010441124FCA813FE120415F819083148D148116810A010A21122561E2000CC
+:204E2000204020203C2023FE40007C88A0842114FA902090206020602890330E2C04000055
+:204E4000201C21E020203C2053FE90507E88110416961090289024904490411082100410AA
+:204E60001080188010FC2F8030906062A1A22E1A20042FFC2120212022222422281E0000A1
+:204E80000100791E49124BD2791249124FD2491279124A124A524FF648504810A810901090
+:204EA00088804840304427FE511091080A041D14291048A088A0084010A05118260E180496
+:204EC000040007F8041008201FFC308450841FFC108410841FFC108410842084209440884A
+:204EE0002040202023FE7C0045108908020422142510209020602460289033082C06000045
+:204F00002108320827C8445057DEF47417D4211447D4F21403881A88E49404940AA611448B
+:204F200010801060202023FE4400FC90090C120420107C90005000200C507088010E0604FC
+:204F400014842484491424943F9424943F9424943F9404147FD40E14150424C444940408A1
+:204F6000082008207F200A7EFFC4084410C43E48C42808280F10F810082808C82B061004C9
+:204F80000020FE2428FC2828FE30ABFEAA40AAFCCF088210FFFE82108210FE10825000206A
+:204FA000203C23C02040FC4023FE50A05110FA0E149410901C90F0901110111012101410A0
+:204FC00010401020FDFE2000509050889104FA94109010903C60D06010901108120E14045E
+:204FE000000400047C8444844484448444844484449C7DE444844004000400040004000464
+:20500000020001007FFE4424191869060FF8110021007FFE00001FF0101010101FF01010D4
+:20502000100011FC110411FCFD0411FC148019FE3222D6221252138A13FE1002500A20048A
+:205040001040102013FCFD08109017FE140018803080DFFE1110131010E01050518C260433
+:20506000208024883E9C20E024822882327E24001FF0101010101FF0101010101FF0101019
+:205080000C207020102413FEFE201020382035FC5400500091FC11041104110411FC1104A6
+:2050A0001100191E210047C09900111E2FE86008A10827C82108210821C8272820100000E7
+:2050C0007C40444048A05090610852064D1049104910691051104110421042104410401085
+:2050E000082008207FA80824FFFE282024207FA8642CBF1824103F102438244A3F862002C2
+:205100000820082008207F2008FE0822FFA210221022142222224F22FA42404E008400000A
+:2051200004200420FFFE0420042000003FF802080208020802080228021002000200020041
+:205140000000102010201020FDFE1020302039FC5400540091FC11041104110411FC110479
+:205160000100010001007FFC0380034005200918110E610401000000488844448444000000
+:20518000204027FE2040FBF8204827FE284833F86040A040227C2240234024C0A43E48001E
+:2051A000004077FC504057F8704857FE504857F870485240527C5240754054C0083E10049C
+:2051C00021FC110411FCFD0401FC888048FE5122522254521A8AE20203FA00020014000814
+:2051E00020401040104007FE88404840504017FC100023F8E20822082208220823F82208DF
+:2052000010201020202023FE4820F02011FC20004000F9FC010401041904E1FC01040000EA
+:20522000200021FC7C4488447E444A9C7F084A904AFE7F104A104BFE4A1042104A10841088
+:20524000100019F811081108FD0825F825082508490829F811081908250847FE84000000DD
+:205260000040005000487FFE0040124012487F4C12481230122022502290430A8206000259
+:2052800004200420FFFE14201048FDFE10487DFE1000FEFC388434FC5284908410FC1084EF
+:2052A000042004207FFE04200520010002C00430180EE424042004200820082010202020B3
+:2052C0001FF8110811081FF8110811081FF81188024004301A4E62440240044008401040EA
+:2052E00011101910111027FC21106110AFFE200023F82208220823F82208220823F822088E
+:2053000001000100028002400430181C642804200420042004200820082010202020000083
+:20532000010000801FFE104090A05110520C1D1631105110911011102210221044108810A9
+:205340004020202830242FFE002004A0E4A82FEC24A824A8249024902CAA344A28860100B6
+:2053600000003FFC200420043FFC208020802FF8288828882FF8288848884FF8880800002A
+:205380000100010001003FF8210821082108210821082108210821082138211001000100FF
+:2053A00010401F7E28A0451084403E4023FC22443E44224422443E44224442844AA8851099
+:2053C00000701F801000100010001FFE1040104010401040104020402040404080400040A1
+:2053E00001000100028004400830300ECFF4010001003FF80100092005200540FFFE0000E2
+:20540000010001000280044008201218218EC08400001FF00020002000400040008001002F
+:205420004040204027F800488FFE504857F810402040E7F820402FFE204020402040204015
+:205440004110311027BCF9180BB6155421106800B3FC280027FE20202128222624A420400E
+:2054600008004BFC488848904860499E070404400F8002100FF8010811201118250802001D
+:20548000202020403DFC210441FC7D0491FC1020FDFE112211221122152A19241020002033
+:2054A00008000C001BF81208220831105110511090A010A0104010E01198130E1C04100064
+:2054C000011081104FFE611041F00040E3F8224823F8204027FC20402BF830402FFE0000F8
+:2054E00001104110211037FC211001100110F7FE11101110121012101410280047FE000087
+:205500002400241CFEE024803C8010807CFE54907C9010901090FE9011101110121010109D
+:205520007FFC04402450145014600440FFFE00001FF0101010101FF0101010101FF0101052
+:20554000081008107EFE1C302A58499488123FF800000000FFFE0920111021084508020064
+:205560004000203C33C02200020003FEE22022202220222022202220242050008FFE00000A
+:20558000200023F822082A082BF8B248A220A2102498244E3464292048C048608020000084
+:2055A000400027F8200887F8500857F810002FFE2804E3F02210212020C020A0231C2C087C
+:2055C00000001FF8100810081FF810801080104026202198408E84040300018000800000A4
+:2055E00000207E200220042009FC14242324C1247F240844084408840E84F1144208000096
+:20560000090209027FE2091200123FD2091209127FD209120912090211021112210A410467
+:2056200010201020FEFE102010207EFC428442847EFC2850285029522A525C928B0E0000C0
+:20564000042004207FFE04201FE00040008003400C30300EDFF401000100010001007FFC93
+:2056600000407BFC48404BFC48407FFE48004BF87A084BF84A084BF87A084A08422802106A
+:2056800000000FF008100FF008100FF0081000007E7E42427E7E424242427E7E42420000C1
+:2056A000204020203DFE44004800FCFC54847C8454FC54107C10009404921912E0500020CE
+:2056C000020001087FFC000000001FF0101010101FF0010009301918310C410805000200EE
+:2056E0001040102013FE1000180055FC5504910411FC1020112811241226142210A0104099
+:20570000102011FE942054FC5820FDFE300038FC548452FC508490FC108410841094108885
+:20572000100013FE942055FC5924FF2431FC3924552451FC9240114010801160121E1404E7
+:20574000100011FC200820104830F0C81306200241FCF820002000201820E3FE00000000BB
+:2057600004200420042004247FFE042004200424FFFE042004200820082010202020400063
+:2057800014407F40147E7F4861A8BD1025283D440282FFFE00001FF000001FF010101FF02B
+:2057A0001FF010101FF010101FF00100FFFE00001FF010101FF009201918610C050802006A
+:2057C00001FE7C20084019FC2504C3040124FD2411241124112410501E48E08603020000CB
+:2057E0001040FE4010787C901020FEFC00247DFE44247CFC44207C204420442054A048409A
+:205800000040202023FC21082090FBFC200021F8210821F8210839F8E09040920112020EDF
+:2058200012201220FFA01220207E3F4441C481483D28252825103D100128014E058402000D
+:20584000204020203DFC208840507BFEA00021F8F90821F8210825F828923112220E000078
+:2058600010001BF820104020904018B0330C6C06A7FC204020402040204020402FFE20005C
+:20588000010000801FFE100097F85010502030D053089C0417FC2040204040405FFE8000D0
+:2058A000202011FE10207CFC002045FE240024FC288428FC1C84E0FC0084008400940088DA
+:2058C000020001007FFC0420FFFE00001FF010101FF010101FF00440044008420842103E52
+:2058E000020001003FFC042002407FFE00001FF0101010101FF00440044008443044C03CE5
+:20590000010041F82210322027F8084820482FFE20482048C7F84040404040404140408075
+:20592000100013FC120416045AF4529492941294129432F42A942A04420442048214020834
+:20594000020001007FFE482410187FF602107FFE04101FF008003FF0C81008100FF00810CE
+:2059600020D0271021102110F9142FD6235833B06550A51829283128214C2146A1844100D8
+:20598000020001007FFE40041220221042081FC0024002400440044208421042203E0000AE
+:2059A000080408041044124422447C442444084413443C5C006403441C0460040004000425
+:2059C000008000807C8010F8111011107D101220142010501C5060880108020604040800B9
+:2059E0000440044004407C7C044004407C7C0440044004407C7C04400440FFFE000000001A
+:205A000002000200044007E008400840108020C041400120022004100818300EC00400005D
+:205A2000020007E008401080214042300C0C3104C9100B20128004400830301EC004000061
+:205A400002000200020002207FF0022002200420042004200820082410242026403C0000B5
+:205A600040002FFE2120012097FC5524152425242524263CC40447FC440447FC4404000040
+:205A800000007FFE40005F7C51105F50515051FE5F10542852285728594A904A8086000007
+:205AA00008400A600A40FF7E08444A842AC42D481C282B2849108810082808C82B06100423
+:205AC000000023FC2204220422042204220423FC2204220422042204220423FC22040000C7
+:205AE00002000700387C20042004200420043E7C200420042004200420043FFC200400008C
+:205B0000060038F820083CF820083FF800003FF821083FF821083FF802003FF80408381808
+:205B2000104010401F40226052588A4C04480B4030FEC0001FF01010101010101FF0101041
+:205B400010200828FF24002400207FFE425042507E5008502C502A904A9289122A0E1000C2
+:205B6000008000401FFE1100910051F01220322054209840204020A021104208440E88041C
+:205B800048804880FE8049FE7A421152FCE295FAFC4210E210D2FD5212421042104A1004AF
+:205BA000108010C01080FDFC1104120415E419243124D12411E41004100410045014200894
+:205BC000080089F851082108510891F809081908290849F8890809080908110857FE2000F3
+:205BE000010000841FFE100093F85208520833F85208920813F81208220822084FFE80004F
+:205C00003FF8200820083FF8208020803FFC2080208027F824082408440847F8840800007D
+:205C20000040F840088048FC49044A0448F47C9404943494C4F404040404141408080000D9
+:205C400004200420FFFE142010001FFC2104292445449FF403840544093411242114010892
+:205C60003FF8200820083FF8200820003FFC20042FC4284428442FC428444804401480086D
+:205C8000000003F8FA088A088A088BF88A088A088A08FBF88A08820802081FFE0000000074
+:205CA000200020FE20803E80508090FC1084FE84108418FC148422802280408080FE000014
+:205CC0002410121809100920FFFE0440092011102FE8410681003FF801000100010001007F
+:205CE000400023F822080A088A084BF8520812082208E3F822082208220822082FFE2000CA
+:205D00007F0022FC3E0822C83E3022483F86C2383FC0011819A061400530190E61040100EB
+:205D2000100011FC11001100FD0011FC150419043104D1FC110011001100110051FE20002F
+:205D4000100013FC1204FA0413FC122016201BFE3220D22013FC13041504150459FC21046A
+:205D600000003FFC2000200020003FF02010201020103FF02010200020003FFE20000000CD
+:205D800000000FF008100FF008100FF008100FF008100810FFFE040006200C1010182008FC
+:205DA00000007DFE4500450045007DFC110411045D0451FC510051005D007100C1FE000019
+:205DC00000007DFC450445047DFC5520112051FE5D20512051FC52845E84E28404FC088465
+:205DE000100011FE21023D0241FE7D10911011FEFD101110117E1142114216421A7E1442FD
+:205E000010001BF8120823F8320863F8A20823F8220822082FFE21102388260C3808000001
+:205E2000080008000FFC1004100420044FC48844084408440FC408440004004400280010E5
+:205E4000200023F8220833F8AA08ABF8A20823F8220822082FFE211021082204240400006F
+:205E6000110411FE11001500150059FC51049104110411FC290425004500410481FE010006
+:205E800000023F82208220923F92221222123FD2221222122F922892488248828F8A00040D
+:205EA00011FE11021102FDFE100011FE1502190231FED102110211FE11021102510A210497
+:205EC00000207E4042F842C87EA800887EA842907EFE42027E0243FA420242024A0A440459
+:205EE000100011FC11041104FDFC240025FC250449FC6904110429FC2504450481140108F8
+:205F000010801890149822A027FC6080AFFE212023D8262E3A2422A02248220821F80000CE
+:205F20001110092005403FF80200FFFE042008103FE8C8260FE008200FE008200FE0082006
+:205F40000110111809203FFC01000200FFFE04200FD8144E244485400490041003F000006E
+:205F6000100011FC2104210445FCF80009FC110421FC7D0401040DFCF10441040114010863
+:205F8000200027FE2408FE48258E27D235126548A54827C82908290C2A143212A4224000E0
+:205FA00013DE125213DE1252FFDE11201BFE3620D3FC122013FC122013FE10885070278E5A
+:205FC000208020802080FBF82088208828883088E7FE2080214021202210240EB8044000AF
+:205FE00027FC24042404FFFC24002C2035246524A5FC2420262226222A222BFEB202400003
+:2060000010001BFC1204320423FC6220A2A422A422FC22A4222025242524252429FC310405
+:20602000007C7F88110808903FFC24443FFC00003E0822FE3E0822483E2828082C2832100C
+:206040002208118C08907FFC400400001FF010101110111011101110028004840886307C2B
+:2060600000808080408037F820880088208820882FFEC080414041204218440E480450009A
+:2060800040802080308027F80088E08820882FFE20802140214021202A203210240C08089D
+:2060A0002080308021FC41084A10FBFC152421244124F9FC010001001D02E10200FE0000FF
+:2060C000108010C0108410FEFD041104128414641044161C1864E3844104002400140008AC
+:2060E00004400440FFFE044004403FF820682F8821083FF823882548292831083FF82008BC
+:206100001040104020403EFC40847D0492841064FE041014102410C41004140418141008D8
+:2061200000003FFE2202430444103FF80400090009101FF8010001047FFE01000100010069
+:2061400000003FF802080208FFFE040804083FF8040808001FF81808280848088FF8080846
+:2061600010801080110813FE549454C85504568454F8548855505E20F0504088010606043A
+:2061800008800CC00988123C17E631145208950419F81110129014A01060119816060000DA
+:2061A000404020902108FBFC000408908D084A8450F851081990E26000600098030E0C04EB
+:2061C000408020802110027887885210520C150429F82108E31024A020602098230E2C0432
+:2061E0007F3E11221122FFE4112411287F28102420223F226122A13A21243F20212000204A
+:206200000040F850088849FC4804488849047C8004FC15882650C4200450298E16040000A0
+:2062200000800040F7FE9504910091F893109490F060919E860401F80108010801F8010819
+:2062400002000200F2009FBC92A492A492A492A492A4F2A494A404A408BC0AA411200000C6
+:206260000100010001FC0100010001007FFE01000100014001300118010C010801000100FA
+:2062800001000100F9FC8A088B088C90886088908B0EFFFC8A0802080208020803F802087D
+:2062A00000007FFE0420042004200420FFFE04200420042008200820102020204020000048
+:2062C00022202220222623B8FA2022A22B1E304063FCA204220423FC22042204A3FC420405
+:2062E0002210221023DE2210FA922312724E6880A3FCA204220423FC2204220423FC220483
+:20630000100092F892889288FE880088FE8802887E88408842884508590AE20A4406000013
+:20632000200027BE24882788B4A8ACA8A7BE24182418251825A826A8244A208A2306200037
+:2063400000047F040844084408440844FF440844084408440844084408040814080800008F
+:206360002110211027FE211021F0F91021F021102FFE229022C83A8CE308420407FE020042
+:20638000222022207FA022203EFC22243E242224FFA454245A2453246244FF54408800001F
+:2063A000208020C0208021FCF904224824502040204024A038A0E1104118020E04040800FF
+:2063C00000807C80108011FE210421483A406C40A84028A028A0291039102A08240E080484
+:2063E00000F83F0001003FF80200FFFE04000FF018106FF088100FF0081008100FF00810C7
+:20640000010000803FFE20802FF820883FFE20882FF8288024C822D824A058984A8E8104A4
+:20642000202023FE222033FCAA24ABFEA22423FC2220232422E824B02528262E28A42040FA
+:2064400020402020ABFEAA2072FCFA2463FE72246AFCAB20A2A8A47024A82B2628A03040C2
+:206460001000100011FC1020FE201020142018203020D02010201020102017FE50002000B0
+:20648000104010201020FDFE1000100014F018903090D0901090111011125212240E0000EB
+:2064A000020001000104FFFE000007E004200420042004200420082208221022603E000018
+:2064C00010801040104017FE1400580050F09090109010902890251045124212840E080039
+:2064E000020002103FD8022002407FFE0100020007FC1A00E7F80208000800080050002007
+:206500001040104011F8FC48105013FE1440188031FCD6401840107C100410045014200856
+:206520001040104413F41448185457FE504050FC9140164028782408440840088050002040
+:20654000010011001FF821007FFE101010101FF004407C7E04403C7C0440FC7E04400440A5
+:20656000200023FE20042004F9E4212421242124212421E43D24E0044004000400140008F3
+:2065800004400440FFFE044000007FFC00101F90109010901F901090001000900050002059
+:2065A0001000100013FE1004FC0411E439243524552451E490041004100410041014100831
+:2065C000100011FC1124FDFC1124312439FC542053FE906010B01128162E1024102010202B
+:2065E00000200020FDFC1020102023FE38506888A9FC28042BFC2A943A942A9427FE000002
+:2066000000007EFE52107E2052FE52827E921092FE921892349252929028104611820000A3
+:206620000608788808480848FE0818881C482A48280E48788B8808080808080808080808D7
+:20664000010001007FFC01003FF000003FFE400480080FC00840084008441044603C0000E9
+:2066600000800040FFFE888088C0889089188BE08848F88C891082300448008403040C0067
+:2066800000007FFE000800081F8810881088108810881F881088000800480028001000009F
+:2066A000200013F8120883F842084BF8110011FC22442C44C2A4431443F440044014000805
+:2066C000010001007FFC010001001FF0101010101FF014500440044008420842103E2000EF
+:2066E0000804060404047FA4102422247F2426240CA419E43324C60409043184C114000885
+:20670000020001003FFE4404440807F00C201240218006703FFEC814081008100FF00810B9
+:20672000400021FC312421FC0124E12421FC202027FE206020B0292832262424002000205D
+:206740000100110011F81100FFFE00001FF010101FF0101010101FF01010101010501020B3
+:2067600000400040027CFA408A408FFE88008BF88A088BF8FA088A0883F802080228021015
+:2067800000001FF010101FF010101FF0110814981860111801003FF801000100FFFE0000EF
+:2067A00000001FF010101FF010101FF0110814901860101C010848804884C81207F000009D
+:2067C00010801040102013FCFC00100011F01110111015101910E21042120412040E080087
+:2067E00000800060F8408FFE880089F0891089108910F9108910021202120412040E08002E
+:20680000020001007FFE400284440820101020081FF0010001000100010001007FFC0000EF
+:2068200000007DF011101190115015501A12E212040E0900008008802814281267F2000051
+:2068400000407F4002400440084008400B400C401840E8404840084008422842103E00003A
+:20686000100010201010FDFE11041050148C19043000D1FC102010201020102053FE20005D
+:20688000100013FE12001208FF0C128816501A203230D248124812841304120053FE200060
+:2068A000000000003FF8200820082008200820082008200820083FF82008200800000000DA
+:2068C0000800080008FC7E84088408840A840C8418846884088408FC080028001000000014
+:2068E000020001003FFE204440403E7C00407EF8140814D014202450258A440283FE0000E6
+:20690000102010201020FE2011FE30203820542055FC910411041104110411FC1104100047
+:2069200000003EF8228822883EF8228801200110FFFE0280028004400820101C60080000BA
+:2069400001007FFE481210087FFC10081FF810801488148817F81084188428842FFC480473
+:20696000042004207FFE042005200100FFFE010001001FF01010101010101FF0101000006B
+:206980000020FE2028A028FCFEA0AB20ABFEAE00C20082FCFE8482848284FEFC828400003F
+:2069A000010000803FFE210021003FFC224024402FFC244020403FFE20404040404080408A
+:2069C0004040302023FEFA200A2012FC16403A505A9096FE1210121012FE1210121014105A
+:2069E000020002007FFE042008101FF8200EDFF4040004100FF804100010001000A000408F
+:206A00002080208027FE2120F91023F824062BF82100210023F83908C008000800280010B9
+:206A20001040104013FEFCA01110120E11F4180037FED08010F8100810081008502820102E
+:206A4000004078404BFE489049087BFE140410005DFE5080508050F85C08E0080028001064
+:206A6000004078404BFE48A079184BF64C0448007BFE488049F848884808A8089050002031
+:206A800020802080208023F8F8882088208820882FFE20803940E1204218020E04040800C2
+:206AA00020403E7E28A04510904013F858485448504817FE104010A010901108120E1404E8
+:206AC0001080188010C011202218240E6BF4A00020082FFC21002120221024F82F98201028
+:206AE00020802080208037F8A888A888A0882FFE208021402140212022102218240E280465
+:206B0000020001007FFE4444BFF8044000001FF0111011101110129002840484187C60005C
+:206B200008400840FF40087E7E84012800207E200020FF2008504A504A88888C29061204BB
+:206B400000007FFE400040005FF8408040804FF84080408040805FFC400040007FFE000082
+:206B600020403E7E50A089107FFE40005FF8410041005FF8410041007FFC40007FFE0000C9
+:206B8000840047FC284010403040484088401BFC28404840884008400840104057FE200092
+:206BA0000000100013FE1200FEFC12203A2036FC52205220922013FE1200120013FE1000FE
+:206BC0000020FE1011FE1100110021003D0025006500A500250025003D00260022000400F6
+:206BE00000007BFE4A004AFC4A207A204A204AFC7A204A204A204BFC7A004A0043FE00001E
+:206C00000040002079FE490049004900790049004900490049007A0002000400180000008D
+:206C2000400023F832082A080A08120813F820A020A0C0A04120412042224422581E000074
+:206C400000103FF800000004FFFE0400040008081FFC000800080010011000A000400000A8
+:206C600004000400FFFE08800880148C1550292042108C0E1FFC124812481248FFFE00009F
+:206C80000080208420843FFC0400040025FC2404240425FC24042404080409FC10042000C2
+:206CA000020001007FFE4822101021FC11047D2411241124FD241154285224924512820EF0
+:206CC00004400440FFFE04407C9004642428181817EE210441003FF8010002C00C3030101A
+:206CE000010001007FFC0240052009103FEEC1043FF8010001001FF0010001007FFC0000E0
+:206D0000080810087E484A287EA84A484A487E0E14781508168827C8240A440A83FE00000A
+:206D20001080190017F0349027F06490A49027F0254021502154227C22422442283E000070
+:206D4000202021FC21243DFC44204BFE800021FC21042124212425242850318C26040000B7
+:206D60002040208023F822483248ABF8AA48A24823F820A020A82134213E2222241E200098
+:206D8000204013F81248824843F8104017FE100023F82208C248424842604090410C4604D2
+:206DA00000201020102013FEFE22122213FE122212221FFE3222C2200020002000200020A2
+:206DC00000001FF010101FF010101FF02040204020443E4C2070204026423842203E000068
+:206DE000100013FC1204FE24122413FC16741A6C32A4D2A4132412241224122453FC22044D
+:206E00007FFC4104410441045FF44304438445444564493449245104410440047FFC40040E
+:206E20001000103C13C0FC40104017FE184010403040D3F8120812081208120853F82208C2
+:206E4000102010101010FDFE11001100150019003100D100110011001200520024000000CB
+:206E6000010000803FFE22002FBE20242FA828A82FA420222FA2252A23A45E204A208420D2
+:206E800010000BFC400450644B84408463F4548444845BE44A244A244BE44004401440082F
+:206EA00000401020102017FE1000FC08110811081088109010D01C90E020002007FE0000EE
+:206EC00010801060102011FEFC001008150C18883088D04810501050105017FE5000200029
+:206EE0000104010477E45104511457D455545554555457D4511473844544094401140108D2
+:206F00001090109013FE7C905490549057FE7C0055F81108190815F81F08E50801F80108D1
+:206F2000009078904BFE4890789048904BFE480079F84908490849F849084908A9F89108F7
+:206F400020201020FFFE0020442029FCFD24112411FCFC6010B010A8212E2224442080204B
+:206F600002200210F2109FFE92009204924493449644FA448228022802000AFE040000006F
+:206F8000042004207FFE042005203FFC111009100920FFFE054009201118210E410401003C
+:206FA000010001003FFC01000930052003407FFE0180034005200918310EC1040100010065
+:206FC000082008207F3C08483EFC2B442A443E5408541C541A542A54482888460882090024
+:206FE00008400840FFFE0840048024FC24A02510261004001FF0129012901290FFFE0000F3
+:20700000082008207EFE1C701A682AA649248A200400FFFE08201F4000E00718780C0000A4
+:20702000100011081088FC9013FE10003800340055FC500090001000100017FE10001000F0
+:207040001008120C1108FC9017FE10001800100033FCD00010001000100017FE5000200054
+:2070600020403F7E489085080440247E24902488050800003FF8244824482448FFFE0000C3
+:20708000200017FC010441045FF441045FF455545FF4438445445934411441044014400879
+:2070A000002010300820044000807FFC0000000000003FF8000000000000FFFE00000000D5
+:2070C000440022FE2002044297FA544217FA255A24EA27FAC4E24552464A4442444A4404D5
+:2070E0004200317E2502042207FEE42225FE25AA257225FE24722CAA34A62522042A0404D8
+:207100002090229022BEFAB022C820842BF832086248A248224822A820A22122A61E4000C7
+:207120000480248024FE24A0251806101FF010101110111011101110128404841886607CA3
+:207140002210221E2FA222443FBEAAA2AAA2AFAA222A272A26AA2A2A3208221422222242BF
+:2071600000902290329E22A04AC8F08413F822084248FA48024800A038A2E122021E0400C9
+:207180002000220C2108289028A4B3FEA000A000200023FC30004800480447FE800000003B
+:2071A000212011201520057E8540559015082508200027F8C5284528452845285FFE0000E1
+:2071C00000400020FBF82208220823F8FA08220823F82288225022203A10C28E03040200A5
+:2071E0001200110013DEFE52125433D83A58565453D292121312129A1354125010101010DB
+:207200008840488033F82208520893F81A082A082BF84A848A480A500A201298530E2204D8
+:20722000010000803FFE2400227C2F4429482F4829502F4828442A442B5C5D484940804034
+:207240001000087E7E4442447E48424842507E484044484244424A5A52446040404000407A
+:207260001000087C7E4442447E44427C42447E44407C48444C445484608441140608000073
+:207280002080104013F882084BF84A08120813F81280224CE250222022102298230E2204F8
+:2072A0001090109013FEFC90109013FE1A443040D04013FC10441084108411045228241014
+:2072C00004200420FFFE042000007FFE420402003FF002100210041004100810105020204D
+:2072E000010000803FFE2002488408800FF81080208000847FFE00800080008000800080A2
+:20730000020002087FFC020802100220FFFE018002000C3034C0C7000404040403FC000022
+:2073200008800C84188617EC308820906FFEA040228023102D3831C42104210620FC000048
+:2073400020403040204423F6FC48245027FE24204840288011982AE024844484807C000070
+:207360000040FE4028FC2888FF50AA20AA50AA88CF0682F8FE8882888288FEF8828800008D
+:207380001080108011F815081690586050605090930E15FC31082908450841F8810800008E
+:2073A0002110111017FE8110511057FE14042080208027F8C08841084108420844284810C0
+:2073C00022202220FFA022203EFC08247F24492449247F240824FF44084408940908080052
+:2073E000003001F81F001080108010803FFC108008800C901888308C2486428401000000D9
+:207400001FF801007FFE41041D7001001D7001003FF8210821083FF8210821083FF8200805
+:20742000200021FC3C2023FE42247DB8A02021B8FC0021FC212421FC2924312421FC000024
+:207440000440FFFE04403FF801007FFE4104A950152800003FF821083FF821083FF8200858
+:2074600000007FFC04000FF03810C8100FF00810FEFE102020203E7C62C4A3443E7C224404
+:207480001FF811081FF811081FF8020004200FC0012006100FF8008808A0089812880100D7
+:2074A00010001BF8124823F8224863F8A0002FBE2AAA2AAA2FBE2AAA2AAA2FBE28A20000EE
+:2074C0000100022004100FF800101040109025087FFC248801003FF8010001007FFE000063
+:2074E000000023F8204027FEF444235820402B58300063FCA24423FC22442244A3FC420411
+:2075000000403C40244024403DFC2444244424443C44244424442444448454848914020877
+:207520002108111009207FFE03800D603118C1040100FFFE0100028004400830300EC0045E
+:20754000200013FC12048A044A0453FC12041204220423FCE2042204220423FC22040000D3
+:207560001040104013FCFC40104017FE3910350C528454F8911016A010601198160E100467
+:20758000100013FE1252FA5213FE3840342053FE50409040107C1084108411041214140881
+:2075A00000808080414061205218148E284420402FF8C0104010412040C0406040400000A9
+:2075C00000003FFE20002FF828882FF8288828882FF8288840804FFC40808080BFFE000091
+:2075E00007847C0404247FA40E2415242504C41401087FFE038005400930310EC10401003D
+:207600007F040824FFA41C242A2449248814088810801FFC208000807FFE00800080008029
+:207620000640384008FC7EA419242E44C8940B0804801960E95E07800560191801080300DB
+:2076400020403F7E52A08910FFFE0440139014501FF002003FF824882FC82048202820106F
+:2076600008008BFC5244224453FC924412442BFC2A4448408BFC08401040104057FE200003
+:20768000020001047FFE06601188124814281FF801003FFC244428242FF420142014200817
+:2076A0002080104017FE000082A85268129823F8204027FCC484451445F4440444144408D3
+:2076C000000003FCFA44224423FC2244FA4423FC2244204023FC3840C04000400FFE00007B
+:2076E000010001007FFC038005400930310EDFE4008001007FFE0100010001000500020002
+:207700003FF82108210821083FF8210821083FF8010001003FF8010001000100FFFE0000BE
+:20772000200021FC3D24452449FCFD24552455FC7C20542055FC7C2000201C20E3FE0000D8
+:20774000104008400840FE400440044008401C402A404A4088400840084008420842083EB9
+:2077600004207FFE042004243F04042404247FA40C240E24152425A44524840404140408ED
+:2077800004207FFE042002003FF802100C50302010207EFC12241224224422444A948508E0
+:2077A00001000100FFFE01003FF8210821083FF8210809000500020005800860101C60084F
+:2077C0007FFE044004403FF8244824483FF80100FFFE0180034005201918610E01040100D1
+:2077E0000000FFFE000000007EFC428442C462A452B45AA45284428442844EBC4488000004
+:2078000000003FFE200020002FFC2100210021F82108210822082208440848289010000063
+:2078200000103F90201020103F7E281228122F1229122922292251225542A24E4084000008
+:207840000000FE3C11C01120212021207D2465FEA420252825243D262622242208A0004033
+:2078600000003FFE2000208020802FF8208820882088210821082208420844388810000072
+:20788000000203823C02042204227FA20C220C221622152225A2452284020412040A04040B
+:2078A00010001FFE109027FC34946494A7FC244420402FFE20E021D8234E264428402040E4
+:2078C00010021BE21102211221D26252A25224522A9232922112210222022202240A2804CA
+:2078E000108419C41604321422146FD4A314269426D42A942A1432042204223C22080000F3
+:20790000010000801FFE10C09704511451141FD433145594A55429143114410441148108D3
+:2079200002000100010000007FFC00200030102008400C400440048000800104FFFE00006A
+:2079400010401020902055FE5408180CFE08310839105490569052A09020100017FE1000FB
+:20796000200013FE1220822042204BFC0A24122412242444E444248428842904321424083C
+:20798000010001001FF001107FFE01101FF001001110092003C005401920611C0508020010
+:2079A00001000100010001007FFC01040104010401040204020404040404080410282010A4
+:2079C00000400020FBFE208021542124F95421FC202023FE2A423292C2F20212020A02041F
+:2079E0000000F7FC9444944497FC9444944497FCF440904087FC0040004000401FFE0000AA
+:207A000010001FFE1090209027FE6492A49224922492256A252A26462482240A24040000E6
+:207A20000108FE8C444844507FFE442044207C2047FE44204E20F420445004480486050414
+:207A400004400440FFFE0440410037FC21400240E7F820402FFE2040204050408FFE0000FD
+:207A60004080208037FC210001400240F7F8124010401FFE104010401040280047FE0000C4
+:207A8000204020203BFE428843FEFA5023FC2254FBFE225423FC22D02D5835562A540050C5
+:207AA00000803FFE242022403FFC22402FF822483FFE22482FF8266026504A4E524482407B
+:207AC0002080208020C03120A910AA88A446284027FC20082010212020C02060204000007C
+:207AE0004040284025FC0440904050A050A02DFC242025FEC420442044204A2051FE000094
+:207B0000020001007FFE40049110190C31085FF8110811081108110811281110010001008B
+:207B20000840086014401340217E5EC880C81148494829282A1021900E2870CE070400003C
+:207B400000203C20245024883D06260425F824043C862644256825482510440057FE88005B
+:207B6000202020203AFC212041507850A37C2110F91021FE2110251029103280247E00004A
+:207B8000020001007FFE0440145014482446C44404400000090828842892681207F00000C3
+:207BA0001040104413FE1440548058F05120912013FE3120282825244122422284A0004058
+:207BC0000040204033FC20404840F9F01090209041FEF810009000941912E21200500020BB
+:207BE0001040102095F855085908FDF83108390855F855405124912811101158118E1104FD
+:207C0000008040402FFE3000200013F81208220823F8C04044504648444C484651444080E8
+:207C200023F8104880484A8C128AE10A22282D100100FFFE038005400930310EC104010021
+:207C400023F0909052984A941492E1502620311009207FFE038005400930310EC10401001F
+:207C6000020001001FE010201FE0102010201FE0121012301140108010401430380E100441
+:207C80000004FFFE044004447FFE444444444644496448945094610442044014400800008C
+:207CA000100013FEFC90209023FE52925292FE92129212D21F2AF34612021202120A12048A
+:207CC0001FF010101FF010101FF00000FFFE11101FF011101FF001001FF80100FFFE0000C4
+:207CE000004000207BFE4800480049FC7904490449FC4820492879240226042200A0004023
+:207D000001007FFC00000FE008200FE000047FFE400487C80440044008421042603E00000B
+:207D200040802060302023FE0000F1FC1104110411FC1124102015281924122604A400406F
+:207D40002080208027FCF4C823302BF836162BF46210A3F0204022502348244CA9444080C4
+:207D60000060FF804A1E4A527A524A524A527A524A524ADA4F54F8500890089009100A1042
+:207D80001080188017FE28C8352C6210A7FE2A1433F0221023F022502348244C294820803A
+:207DA000010000841FFE1000900057F8501030205040904010402040204040404140808011
+:207DC0002040204023FC24A02910B3F8A616ABF0221023F0324029504A4C44448140008036
+:207DE00001007FFE4004BEF812480A2812C8210806C01930E68E19C00618386003803C00AB
+:207E0000400027FC3008201000A00040E040204020402040204023C02080580087FE0000B7
+:207E2000408020802FFC0548923057F81A1623F0221023F0C04042504448584441444080D2
+:207E400000007FFC001800600180010001000100010001000100010001000100050002009E
+:207E600013FC124413FCFE4413FC108018F811903260D050118E17F81108110851F82108F8
+:207E8000204020403BFC20A045147BF8A51621F0FD10211021F020402A4832442544008013
+:207EA00001003FFE20003F7829282518292832982160265839862E60218C4E3041C09E00EE
+:207EC000080808884A482C481808FF081C882A482A4E49F8480888080808080808080808E6
+:207EE0000004FF84080411241FA41124212452248A2404240424080410042014C0080000ED
+:207F00007FC408241FA420A4D9240624191460887FFE0288048C0C503420C5100E0E0404EF
+:207F20007FC4080408240FA4112411242A244A24040408143008C010244C22262222400085
+:207F4000010009200D18112C2174C1C003000D0071000FF80108020802080408182860101E
+:207F600004904490289013FC309048908FFE180029F84908890809F80908110851F82108F5
+:207F800001100110F910211027BE2110FB3823B8235825543594C916111001100110011071
+:207FA0001020102010201020FDFE10201060387034B054A8512892261424102010201020E5
+:207FC00000207D2410A813FE10B021283E266928ABDE2C482AA839BE2928220804080808BC
+:207FE0003FF80100FFFE81043D7001003D700820FEFE08201C702AA828AE4924082008202F
+:2080000001000980090049FE4A204A104C10490449FE492449244924492409FC090400000C
+:208020000800087E144413442948445084487F44014202421452084C0C400440044000401A
+:2080400021243CA844B04BFEFC6855A654207D0855FE56487D6800BE1C88E108020800082F
+:2080600042102210221002108F7C4210563027382AD84A54D2964310421042104210421053
+:2080800000804FFE200027FC15E4152425E427FC2000C7F840005FFE44504448494C508869
+:2080A000083C0BC0104037FE5040904013FC10000FF0081008900890089001600618380611
+:2080C000020001007FFE08200420024001800660381ECFF408100810081008100FF008101B
+:2080E000204020402060F8A0209021482A26340061F8A0082010201020A02040A03040106A
+:208100000040F84020A020A021102148FA26242023F8201022203940C0C000600020000063
+:208120000440FFFE044005403FF80100FFFE0820141027ECCC20124061800660181E6004C2
+:208140001FF801007FFE41041D7001001D70028004601A1EE1081FE0004002800100010060
+:20816000082008204E6048504888FF460024522052FC52086A1046604E20721000100000F6
+:208180001040104020403CA040907D4E92241020FDFC1008101010A01040142018301020A5
+:2081A00008400C4018C0112032906448A86E204427FC20082010212020C0206020400000BE
+:2081C000002044202850FC50108811467A24102011FCFC0410082090206040308020000035
+:2081E0000040404023F830402FFE01B02308248429F8C3104CA0404040B0430E1C040000C2
+:2082000000083FFC00081FF800083FF80108019009100920128002400420081C300840004D
+:20822000004078404BFC504057FE612051104A8C48F0691052A0444040A043184C0E400462
+:208240001020102010501048548455465624540057FC54085D10E0A0404000300010000069
+:20826000100011FE2820244042FC508488A47EA404A408A430A410B4084808840304000004
+:2082800000001FF81008100810081FF8110801003FFC010402040204040408041028201086
+:2082A000010001000280024004200918308EC0141FF80010002004400280018000C0008053
+:2082C0004180263E2412051285A256AA1444200027FC2444C44447FC4444444447FC44041C
+:2082E00000407C2013FE1040109011087BFC10041150115011501D50E2520252044E08008B
+:2083000010C0133E1212FA9212D23B223646500053FC9224122413FC1224122413FC1204A4
+:2083200000407C2013FE1040109021083BFC28046950A9502950395029522252044E0800D7
+:20834000204023BE22123E924A525292832A224421FC2124212425FC2924312421FC0000BE
+:20836000060038FC2044284424442A8432A821101FF8110811081FF8110811081FF8100811
+:208380001004080404047FA40124212412240A24042406240A2411042184411480080000AD
+:2083A000010000801FFE100097BC5414151435A4564C908017FC144427FC244447FC8404DF
+:2083C0002080104017FE0040808049104BF8100812501250E250225024522452284E2000BA
+:2083E000100010C0131EFE1212523A523652525252D2935A12541090109011101610101022
+:208400000400030001800100FFFE0000000004800640042008100818100C200C4008000020
+:2084200002000240022002207FFE02800290029004A004C00880098012822082407E000024
+:2084400002400224FFFE02A004C418FC23007FFC08200FE008200FE00824FFFE0020002004
+:20846000008000A00098F8908FFC88A088A488A888B0F920896002A002220422081E000061
+:2084800020403F7E285044884508822002107FFE0480049008A008C011822682C07E0000FC
+:2084A00001007FFE4824311001007BF84A905460519E4EF44A406BFC544049F8404047FED3
+:2084C000008078F849085290506060D0530E48F04A406BFC544043F8404040404FFE4000B3
+:2084E000022002107FFC0280049004E009841684217C41001FF8010001000100FFFE0000B7
+:20850000108010A010981090FBFE10A014A818AC30A8D1301120126012A21422581E2000AE
+:2085200000A07C90489057FE60A050A048A4492449286930516042A042224422481E40000C
+:20854000102010A41068FDFE107038A835265040504097FE10901190106010D8170610028C
+:208560001110091809207FFE038005400930110E22047FFE04200840048003000CE0701CE5
+:208580001040124C114810D0FBFE10D015481AC63080D7FE1108131010E01058518C2604BE
+:2085A00020403E7E48908508111009207FFE0960311EC2047FFC04200E4001800E60701891
+:2085C000200017FC140407FC8400540017FE142027FE262226AAC6224AAA4A22522A4204E5
+:2085E00000007BFE48205020602055FC4D244524455445946D0455144508440047FE40001D
+:2086000004200420FFFE052000801FF8100810081FF81008100010002000200040008000DA
+:208620000080008000FE008000801FFC100410041FFC10041000100010002000200040001A
+:20864000080008FE0E2008407EFC428442A47EA440A440A440A4403040484186860200005B
+:20866000010000803FFE2080204027F82408240827F82408240024004800480090002000F2
+:2086800010401020102415FE15045904510491FC1104110019002500220042008400080067
+:2086A0002040207C2040F7FE244427F82C44347C6400A44025FC244428442884B09441084C
+:2086C0000100010401FE01003FFC2044286424C4228421042284246428243FFC20040000DD
+:2086E000010001F801003FFE21042FF0210420FC21002FF8210821082208420844288810AB
+:20870000040007E008401FF871081FF811081FF80000FFFE00000FF008100FF008100FF025
+:2087200008207EFC1C702AA8CA2601003FFC24403FF824483FF828402F5048644E44883CE6
+:2087400003F0FC10101013F0201038106FFEA8442A68295028D039482A4E24440140008001
+:208760003FF801007FFE410415500A283C8024F83D5012205CD8530650F85C88E0F80088B8
+:208780000080788048FC49884A487C50502010585D8653FC510851085D08E1F801080000EB
+:2087A00000807C8044FC54885548565054205450548E55FC52881088288846F88488000027
+:2087C000010000803FFE224022403FFC22443FFC204028402F4C28704A424C42883E000080
+:2087E00040202720253C052495485728121022282A462BFCCA444A444B445C7C4044000062
+:20880000200013F80008FDF804080BFE10403A485550916010D011481646104011401080ED
+:2088200000003FF000101FF00010FFFE011011300940058003400D30711C21080500020080
+:208840000040F840884097FCA040904088408FFE8840A84094448444844487FC840480009D
+:20886000F720552833243520D1FE15200C243224C9A8101064301850628A040A1806E002A7
+:2088800000207C10041024FE2482248224823EFE028002801A80E280030015000A000000A6
+:2088A0001FF01010101010101FF01010000000003FF820082008200820083FF820080000E4
+:2088C000100010FC20843E8440847CFC90001000FDFE110211021102150219FE11020000C5
+:2088E00010001BF812083208220863F8A208200027FC240424042404240427FC24040000A4
+:20890000204010401080FEFE2100220C3CF0248024CC24B024A02490448844A694C408802A
+:208920003FFC20043FFC210025FC2D0033FC250429FC390429FC288029FC4A8848708B8EDF
+:208940003FFC20043FFC249022A03FFE21C022B02C8C22803FFC2420442043C08C383010D3
+:2089600000402248315020404BFCF8E01150224C4080F7FE011001903860C098030C0C0814
+:20898000010001F801003FFE210421F02F00210820F8200022882A542A52521A41F0800018
+:2089A0003FF820005FF000007FF000103F9000901F900090FFF02490170A148A64460C02DA
+:2089C0001040184013F828484FFE904813F8304053FC9040104017FE104010401040104010
+:2089E000020001007FFE4100222817D004801110224847C40120FFFE010001000100010049
+:208A0000208010F8108007FE848454F81780248824F82400C44049244D0A550A60F80000C3
+:208A2000200033F8200821F84808FFFE104022484150F0E00150024E3444C0400140008068
+:208A4000020001007FFE04401450144824464442810001002108210821083FF82008000046
+:208A6000020001007FFE04401450144C244644440FF001001FF801007FFE010005000200DF
+:208A8000010000807FFE024012501A48224442400FF0002000407FFC00800080028001008D
+:208AA000408020402FFE0120952855241924212020802FFEC0C041A04298448E588440801E
+:208AC00003003C7C2244224432642A542E5C2A5426447A542448044008403040C040004013
+:208AE00006407840084008400A40FF40084008407E4042404240424442447E46423C0000BF
+:208B000010401020101013FEFE0011FC1504190431FCD020112811241226142250A020401A
+:208B200000800080F9FCA908AA90AC60F850A988AE06A9F8A908F908890801F80108000036
+:208B4000104010401040FCA01090150E1A0415003138D1C0110011001104110450FC2000E1
+:208B600010201020FE502050208851069284FC88109C16E03880D08410841086107C1000CA
+:208B800010401840104030A02118620EA5042910213821C0210021042104210420F8200080
+:208BA00001000100028004400830101C6808084008E009800E0008080808080C07F800001F
+:208BC0004040204020C000A089104A0855061100213021C0E10021002104210420FC000044
+:208BE0001040104020A020904508FA0E0C0411002108F93041C001001904E10600FC00009B
+:208C00004040204030A0209001080206E5042110213821C0210025002904310420FC0000CB
+:208C200004400440FFFE044004403FF824483FF8020007F808103420C240018006007800DF
+:208C4000100011FC11247DFC552455FC54487CF05428104419FE16241CA8E52402A20040A5
+:208C600000003FFC2244224422443FFC220003FC06080C081210612000C003000C00F000A7
+:208C8000000047FC2524252407FC0100E1F822082510209020202040208053008FFE0000F3
+:208CA000200023FE3A52225243FE7880908011FCFD041288104810501420184011800600A7
+:208CC00020403F7E48904508BFFC224422443FFC220007FC08083410026001800E00F00036
+:208CE000F9FC092409FC492449FC484040887DF00440148825FCC4200528292412A4004089
+:208D0000200011FC1124FDFC0924112435FC58209BFE147010B010A811241222142010208B
+:208D200004400440FFFE0440450021F8A1104AA0484010A01318EFF62210221023F0221080
+:208D40000100410023F82208851050A0504010B0230E2E04E3F822082208220823F82208B6
+:208D60000080F88008FC498849504A2048307C48058604FC3484C484048414FC0884000038
+:208D80002080308020F841884A90F86010602090410CFBFE050801083908C1F801080000F1
+:208DA000100011F810081088FC882488248824FE2802480233FA1802240246028414000823
+:208DC000010000803FFE241024103F7E241024102E302D58345864964514841004100000DE
+:208DE0000000FBF82008210821082108F90821FE2002200223FA3802C00200040014000840
+:208E00000000FDF810081088108820883C8864FCA404240425F424043C0424042028001078
+:208E2000100013F8100810887C885490551055FC7C0450041BF414041E04E41400080000AC
+:208E400000003FE0002008200820082008200FFC000400047FF40004000400340008000069
+:208E60003E7C224422443E7C00001FE00020082008200FFC00047FE40004001400080000B1
+:208E800000800040F7FE9510951097BE951097B89778F554955289920910111021100000C5
+:208EA000000003F8780849084908490849084BFC490478044BF4000400040004001400087C
+:208EC000100013FC1244124413FCFE44124413FC1244104013FC1C40E040004007FE00009B
+:208EE00000003FFE0004048802C012800880088000843FFE014003300618180C6004000066
+:208F0000010001003FFC01001FF801007FFE040007F00610092010C001200610380E0004F3
+:208F2000008000883FFC008000807FFE048C0290128009007FFE0140022004300818301040
+:208F4000400027FE30802080008000F8F108110811081108120812281410280047FE80003B
+:208F60000080786048404BC8784C48484B50496079504948494C4A464C448840A940108016
+:208F80000110F7FE9110911097FEF09097FE9492F4929552952A9646F4829402840A04040F
+:208FA00021F8210821F83D0845F8480083FC229423FC200021F8209028603090230E0000D6
+:208FC000020001007FFE145014482444444405401FF0111011101FF0010801F87E0C000828
+:208FE000411021102FFE0110800057FE512017FC2524252425B4C64C448444044414440827
+:209000000440FFFC04401FF011101FF000003FF824483FF800000FE0044003801C70E00E84
+:209020001FF010101FF010101FF000007FFC44447FFC00001FF00420024001800660781C55
+:2090400021F8210821F83108A9F8A800A7FE249227FE200021F82090206021B02E0E20001D
+:2090600023F8120813F8020883F8500017FC252427FC2000C3F8411040A04060419C460885
+:2090800043F8220833F8220803F8E00027FC24A427FC200023F8211028A0304021B00E0E9C
+:2090A00004200420FFFE042005200080FFFE10001000100010001000100010001FFC00001A
+:2090C00004200420FFFE04202440102097FE4900490011001100E100210023FE21002000E6
+:2090E00002000100FFFE100010001FFC00001FF010101FF010101FF0101010101FF0101059
+:20910000000021FC11041104FDFC4120412041FE4120412041207D100112014A0186010276
+:2091200020802040202037FEAA00AA00A20022002200220022002200220023FE2000200097
+:2091400004207FFE0420024002207FFC04200810344EC4443FFE04400840084010402040E4
+:209160000890889057FE2090509088901BFC2A444A448A440BFC0A440A44124453FC2204F3
+:2091800004400440FFFE044000003FF8023001407FFE01840288048008803080C2800100D1
+:2091A0002090209023FE3C9040907C0091FC1124FD2411FC11241124152419FC1104000059
+:2091C000000001F87E000200020003F83E000200020003FCFE0002000202020201FE0000D1
+:2091E00000001FF80010022001407FFE0184028802800480088010802080408082800100D8
+:20920000204021803D1E211241527D52A1522152FD5221D2215A205428903090211000100D
+:20922000000003803C7C2244224422442244224422442A44745C24480840104060400000AD
+:2092400004400440FFFE044000A000903FFE2080208420482050206020A043124C0A80044D
+:209260003FFC20042FF420042FF400041FF810081FF8100810081FF8100810081FF8100835
+:20928000200023FC2204FAF4AA04AAF4A800A9F8A908A9F8B90821F82108210821F8210826
+:2092A0000C20F04011FC4B042D0431FCC904190425FCCC5014502450C4920492290E120064
+:2092C000060038FC242422242F44725420881FF010101110111011101290044018306020A5
+:2092E000010001800100030002400460084010802080010002100408087C1FC6000400003E
+:209300000080F8C02080208421FE2110FA10231024A020A0204038A0C110060E1804000087
+:20932000108010C010801080FDFE111032903C9054505060902010501088130E1C041000B6
+:209340001100110011FE1200FBF815083948352857FE51489128110811FE1008102810109D
+:209360000040FE4028FE2880FFFCAAC4AAA4AAA4CFFE82C4FEA482A482FEFE0482140008A1
+:209380001FF001007FFE49228544092010001FF820005FF01210FFFE10903FF800100060E7
+:2093A0001110111017FE151059F0511051F09040104017FE28E0295042484C46B042004042
+:2093C000200011F0111081104212540E100017F822102110E0A0204020A02118260E200451
+:2093E0003FFC208420843FFC200027FC2404240427FC2404240447FC4404440487FC04044B
+:209400001108110817FE1108FDF8250825F8284048444FFE30E011502A48444E88440040EB
+:209420002108209023FC3C4040407BFCA04023FCFC40204027FE204020A02890310E2604C0
+:20944000100010003FFC20004FF08A1009100810FFFE1110109010101FFE0010005000200C
+:20946000082004407FFC01001FF8010001007FFE010001003FFC028004400830301CC0081F
+:209480000040004078404BF8484048407FFE48C048E0495049507A48444E08440040004042
+:2094A000020001007FFE4004844025F83C40044007FCFCE024D02548264E44448440044003
+:2094C000202030202020FDFC24202420242047FE4460287010B018A82D2649248220002074
+:2094E000100019FC11241124FDFC250025FC25844BFC6A8412FC1A84268444FC888400001E
+:2095000010000BFC0804200420042004200420042004200420042004200420042014200840
+:2095200010000BFC080440044104448444A4541454146404442443E44004400440144008E4
+:209540000A00090011BC1104340424046404A404240424042404240424042414240800007A
+:2095600004200420FFFE042000007CF8448844F844887C8844F844887D08450842280410DE
+:209580000420FFFE04207FFE40040FF000007FFC0610191862B00CC073A00C98728E01046A
+:2095A000209027FE2090F7FE240471F86800A7FEA180264821B0266821AE2E2420A0204064
+:2095C00000007CFC448444FC7C8444FC44847D04011402083FF8244824482448FFFE0000EB
+:2095E000200021F820103C2041FE7C20902010A0FC4011FC115411541554195417FE00006D
+:209600008BF848103020204057FE90401140308057F895481548154815481FFE50002000C9
+:20962000082008207EFE08301C682AAECB240C2007F808100C203240018003000C007000FA
+:209640000FF00020004000807FFE00800080028001001FF81248124812481248FFFE0000AF
+:2096600000407840484C4A48795048444FFE48E078E0495049504A487C46484440400040D8
+:209680000010FC1052945154FC58D4FED730DD30C5588554FD9485108510FD80827E0000BB
+:2096A00000803FFE24203F7C24302E6835A6242021402F7E21402F7C41405F7E814001406B
+:2096C00000803FFE241024103F7C2E3835542492249022A03FFE21C042A04C98B0860080F5
+:2096E00040402048344C334802500FFEE0C020E021502248244C2848204050008FFE000090
+:2097000040202824352626A404A801FEE0602C7024A824A4252626242C2034202BFE0000FF
+:2097200000807CC0048005FE7D044128422040B07CA80524052606240420042028A01040A8
+:2097400001002108110809100920FFFE058005400940092011201118210E410481000100FB
+:209760000C807044102610A4FE84108830883A94569252A294A210C0108413841C7C10006A
+:2097800000783F901218099009201FF01010111011101110111012940284048608FC100019
+:2097A0002080104010480108890849105114152215222542E9402184210423042CFC2000D2
+:2097C00001003FFE22245548149427F603040C8030800FF808880FF8089000883FFC00085F
+:2097E000020001003FFE42244950294848A40B341FE0E00041001108110811081FF800000C
+:209800003FFE20044FF008100FF008100FF004007FFE09083FF6C91409100970092001001A
+:209820001020104011FCFD0411FC390435FC502053FE922212221222122212261020102076
+:2098400000007BFC4A044A047BFC4A244A204BFE7A204A204A204A127A524A8A03060202E6
+:209860001020104021FC210445FCFD0409FC102021FC7D2401240D24F124412C00200020D9
+:209880003FF820082FE820082FE810001FE030405FF012101FF0028004820882107E2000D4
+:2098A000040004000FF0102020405FF8110811081FF812480240044004420842103E200093
+:2098C000102010203F2022FC44247F24492449247F441444149415082402440283FE0000F9
+:2098E0001080108010F8F9102A202BFC2A442A444BFC2AA410A028A02D224922821E0400FF
+:20990000200037FE204040804BFCF294129422F44294FA9402F402941A94E3FC02040000C6
+:2099200000007FFE020004003FFC2444244427C42444244427C4244424443FFC20040000C4
+:209940000820082008207FFE082008203FF8210821083FF82108210821083FF82008000028
+:20996000108810881088FBFE10881488180013FE3222D22213FE1222122213FE5202200083
+:2099800000907090509057FE5090709053FC52447244524453FC52447244524403FC0204BB
+:2099A0000440FFFE044008203040D5FC590469FC990425FCCD5414502452C492150E0A00BB
+:2099C0000C20F02010201128FDA4112232223A205422542290041008101010601180160091
+:2099E000401020102F10095489545F52199229162F142908C9084F10402040C04700000088
+:209A0000010000803FFE2080208020802FF8288828882FF82888288848884FF888080000F3
+:209A2000202020202020FC28252425A2252445264A242828180814102620444080800100B1
+:209A40000820FFFE08203FF8244824483FF800803FFC2088288C2650246041A44E14800893
+:209A600000087FFC0100010001081108119012A022400440042008301018200E4004000050
+:209A800000003FF0201020103FF0210021003FFC208020802040204024242814300C2004A7
+:209AA000100013FC12041204FFFC122016201BFE3220D22012101210120A128A5306220222
+:209AC00000003FF824482448244824482448244824482448244824482448FFFE00000000AE
+:209AE000204020607F4040407EFEB2C82B482248FF4832282A3022103FA802280A4604845E
+:209B00002400227E20023442AC22A5FAA412249224622422245224922502240A240400009B
+:209B2000100009FC4804410441044FE4492449244FE4410441245FF44014400440144008C9
+:209B400000FC7C844484448444FC7C844484448444FC7C84008401040104020404140008B5
+:209B6000200023FE2204FDF8A908A9F8A908A9F8F840A02033FE28903C88C90C020604045B
+:209B8000004000807BF84A084A884A484A484A184A007BFC00041FF40004000400140008EC
+:209BA00010401040207C3C8440887D8892501020FC4011FC168410841084148418FC10847F
+:209BC0000400040007F80810102024404280010006001FF8E808080808080FF808080000CB
+:209BE000010002800440082010182FEEC0043EF82288228822883E8822B8209000800080E9
+:209C00004FFC288434A422AC029404A4E84020A023182CC6233028CC3718206001800E00AF
+:209C20001110111017FEF91013F812081BF83208D3F8104017FE104010A01098510E2604F1
+:209C400004207FFE04201FF011101FF00400FFFE082017D82106CFE001001FF801000700F2
+:209C600004400440FFFE05403FFC24203FFC2E7035AC24A43FFE220027F84C0857F8A4084C
+:209C80002090209027FC2090FBF8220873F86A08A3F8A04027FE204020A02098210E2604C6
+:209CA000011079104FFC49107BF84A084BF84A087BF848404FFE484048A04918AA0E9404A3
+:209CC00000803FFE241024103F7E2E383554259224103FFE220027F84C08540867F88408AF
+:209CE00001003FFE24203FFC26302D6834A625202FF820802FFC20805FFE408082800100EB
+:209D000000803FFE24102F7C26382D56349421002FF828882FF828884FFA41528666183E11
+:209D2000204020402040FBFE204020402BFC304060C0A16021502248244E3844A040404069
+:209D40000100010001007FFE010001003FF801000380034005200918310EC1040100010037
+:209D6000042004207FFE04201FF010101FF010101FF00100FFFE028004400820101C60080D
+:209D80003FF8292825483FF801003FFC0100FFFE28882666444401001FF80100FFFE000083
+:209DA00000207F2049286B245D247FFE08207F2008200F20F0500050AA88950E96040000C9
+:209DC00020401040104087FE5040504017FC204020C02160E1502248244E204420402040D9
+:209DE0002120112017FE812043F8520813F8120823F82040E7FE204020A02090210E2604F8
+:209E0000020001007FFE4444BFF804401FF010101FF010101FF001007FF806801860601CE0
+:209E200000007BFE48405040608051FC49044904490469FC510441044104410441FC410472
+:209E40004110211037FE211001F0E11021F02110204027FE20E02950324824460844004088
+:209E60000200042008101FF80008110011003FF841000100FFFE01000100010001000100E8
+:209E8000082008207FFE08200FE0082008200FE00100FFFE038005401930610E010401001B
+:209EA000100011F81108FD48112811081FFE3208D2481228120813FE10085008202800103B
+:209EC00008200820282028203E204BFE48208E203820E8204820082008200BFE08000800B4
+:209EE00002000100FFFE000000003FF82108210821083FF82108210821083FF8200800009F
+:209F00002000300021F8FD88254825282BFE49084948322812282BFE4C08880800280010B5
+:209F200000001FF01010121011101110FFFE10101210111011101FFC001000100050002062
+:209F400004407FFE04401FF010101FF010101FF002007FFE0D203118CFEE010401007FFC5C
+:209F600004407FFC04401FF010101FF010101FF00400FFFE08103FE8C8260FE008200FE03D
+:209F80000440FFFE04401FF010101FF010101FF00200FFFE09101FE82926C924096001000A
+:209FA0000440FFFE04401FF0121011101FF00400FFFE092011182FEEC224042008A0104049
+:209FC00004407FFE04401FF0121011101FF00200FFFE04200910310EC9A409501350010076
+:209FE0000100010001007FFE0100038003400540052009101118610E0104010001000000F8
+:20A0000000001FF81008100810081FF81008100810081FF81008100810081FF810080000F4
+:20A020000040F04093FC90409040F7FE909093089C44F04093FC90409040F04097FE0000CD
+:20A0400010801080508051047DFE5210951015101890F0A050601060109013181C0E1004B3
+:20A060000C2071FC110411FCFD0431FC38A45522561A58E0970C10701786101810E017000D
+:20A08000010002C00C3077EE00040FF008100FF000000FF800803FF800807FFE0080018086
+:20A0A00007DEF2529254925497D4925892549FD49252F2529452045A085411502090000024
+:20A0C00000400040F8408BFC8A448A448A448A64FA948A948304020402040214020800008A
+:20A0E000202020203E2021FE41227D22A1222152FD4A218A2102210221022902310A210445
+:20A1000000007E7E124412487E48125012487E44124212422252224C42408A4004400040F5
+:20A12000200027DE21522154FFD44958495849544FD2315212522A5E24544450895010904B
+:20A1400010201020202027FE4622FA220A221252224A7E8E030A0E02F2024202020A020447
+:20A1600010001FFC20002FF84000BFF000103F900890091009D01048104A204641460082F4
+:20A1800000103FF80410041004200424047E0404040408040804100410442028C0100000DA
+:20A1A000100011F81088FC90249024A024BC44844884288410841904250442148408080006
+:20A1C0000008FF08080808087FFE550855085548552855285528550851085728421000007E
+:20A1E00001000100FFFE0280044008301FEE600480003FFC010009201918610C85080200DF
+:20A2000001000104FFFE010002003FFC242422442FF421043FFC2104210421142108000024
+:20A220000FF8088808880FF8088808880FF8010001003FFC02040204040408043028C01044
+:20A2400000A00090F91009FE8B204B202DFC1120192029FC25204520812001FE01000100A4
+:20A2600001007FFE01003FFC21047FFE92941EF004203FFC04207FFE0C843468C630040E1A
+:20A280001080108017FC1080FC58106215B2180E37FCD1201120112012221222541E2000C8
+:20A2A0000080784048204BFE780048104A944A647A644A644A944A944B04ABFC9204000085
+:20A2C00020802040204037FEA800A810A31422A422642264229423142204220423FC200088
+:20A2E000200017FC020421043FF4210421042FE4292429242924296429242104211420082D
+:20A3000010400840087E804043FC4A040BFC120413FC2040E04027FE204020402040204081
+:20A320000000FBFC8A048A048BFC8A048A808A88FA9C8AE08280028004820482087E1000B3
+:20A34000200023FC20403E24452848909040104017FE1088119014601850118C06040000C6
+:20A360000100010001003FFC210421042184224422242414281430042004200420142008B8
+:20A3800021103118211027D0F11E57E45564555457D453142394554855088914112201401B
+:20A3A00020403040244C4270FF444246007C7E0042407E4C42707E40424442464A3C440052
+:20A3C0002000200021FEFD02250225FE250045404948295C116011402A424242843E080099
+:20A3E0001FF801007FFE491465481120040038F820083CF820083FF8044004421842E03E9C
+:20A4000010601B9C1204120423BC22046204A3FC22A420A02120212222222422281E000005
+:20A42000200013FC120402048BFC4A005280128012842498E4E0248228822882307E2000BE
+:20A4400000003FF8200820083FF820082400242024F02780240024004404440483FC00009C
+:20A460001000108412641224FE0412041A043204D204124412881308123450C223020000C2
+:20A4800009000980110413FE220434486840A25023482248244424462844214020800000B4
+:20A4A0007FFC400044205FF8442041005FFC420047F04C10541067F0441040047FFE000081
+:20A4C0000010781448144FFE78104BD048104BE87A284AA84AA84AA8488A494A6A249420EA
+:20A4E00002104110212027FC00400040E248224823F8208020802100220050008FFE000006
+:20A50000200017BC1084808447BC5420142017BC208424A42294C2944CE4408442944108A7
+:20A520000440FFFE04407FFC010009F00900FFFE10001FF810001FFC2924249444940008E4
+:20A540001020102010201020FE3E10201420182031FCD104110411041104110451FC2000A0
+:20A5600008000FFC1080108020804FF88880088008800880FFFE00800080008000800080A4
+:20A580000000FBFC220423FC225042507BFC6A50ABFE2AA42AA83A90249004A808CE10846D
+:20A5A0002208220827BCF20827BE2308349460A0AFFE214023FC20402FFE2040A040404018
+:20A5C0001080108010C0FD201110124E1C4433F8D01010A010601524150A1D0A50F820007B
+:20A5E00001000100028004400930108E6FE400200040028001002888289628124FF000009F
+:20A600002080304023F82208FBF82A082A082BF84A844A4E32582A204A1042888306020082
+:20A620000040FE2028F82888FE88AAF8AA88AAF8CE8082A4FE98829082A8FECE82840000D8
+:20A64000020004001FF0101012101150112010001FFC00040004FFF40004000400280010AB
+:20A6600000003FF8200820083FF820802088209C3EA024C024A068904888508EA284810045
+:20A68000100011FC11041104FDFC1104190411FC3020D02013FC10201020102057FE2000E7
+:20A6A0007FFC08200FE008200FE008207FFC00207FFC44882490186024602690450E8204A8
+:20A6C0000420FFFE24207DFC44487DFE40207CFC44207FE0004000807FFE008002800100BA
+:20A6E000004000400040F27C9240924097FE90409464F444944484A40514060C0FFC0404B5
+:20A7000023FC21083DF8410841F8F90E23F82008FBFC226421A82090295832262CC4000031
+:20A72000202021FC3D0421FC41047DFC910411FCFC2013FE106010B014A819261220002054
+:20A74000200013FC1204020483FC4A044A0413FC10402040E3FC2040204020402FFE200088
+:20A760000800090011FE1204344032505248944411441080000029042892681207F00000FE
+:20A780001040102013FE1204FC00100039FC342054205020902010201020102010A0104059
+:20A7A000004044202BFE12023404480088001BFE28204820882008200820082050A0204077
+:20A7C0000800897E4E0C6830491027FE28124F145410DFDC44504C504A505370629E410070
+:20A7E000020001043FFE20044008000000007FFC0100010001000100010001000500020021
+:20A800001040102013FE1204FE08100014001BFE3020D020102010201020102050A02040FE
+:20A820004080204027FE04048800480057FE104010402040E0402040204020402140208065
+:20A840000080108010801FFC20802080408000807FFE008000800080008000800080000040
+:20A86000100013F810881088FC88108814881BF83108D10811081108110811085FFE2000CF
+:20A88000100011F820483E4840487C48904811F8FC881088108810881488188813FC0000ED
+:20A8A000000011F81048104824487C48084811F820887C88008800881C88E3FE0000000015
+:20A8C0000040784048404BFE4A447C4848A4492679284B104D10490849084946AB84110038
+:20A8E00040402040208007FE848455085180134423582520E52029103110214821862104D2
+:20A900000200030002043FFE2204450805100CB818A028404820883009180A0E1C080800FE
+:20A9200000003FFC01001FF8010001007FFC082008200820FFFE08201020102020204020AA
+:20A940001000100011FCFE84128412842288224844502450142008201650248CC1060604BD
+:20A96000100010FC7E442244222814100C283246C1003FF801080208020804080828101008
+:20A980000800080009FC7E881248225014200C50328EC004010008842892281247F0000004
+:20A9A00002000200020004000400FFFE0820082010400C40038001C002300C18300CC00802
+:20A9C000001C03E07A44492848004BFC78804FFE488049FC79884A50023004CE0B040000BA
+:20A9E000010001F801003FFE210421E02F1021F0200027FC24003FFE2400440047FC8000DA
+:20AA0000008000401FFE1000900053FC5200120032005FFEA2002200220043FC4200800090
+:20AA2000200027DE2252FA5422542FD83258225467D2A2522252245A24542950B090401012
+:20AA400027FC204027FE3444AF5CA040A35C204027FE208027FC24A424A424A424A4240C54
+:20AA6000200023FEA820ABFE6A22FDAC602071AC6800A3FEA040A3FC22942294229422087E
+:20AA80008108610847FE01080108E04027FE2080208021FC21042B04350421FC010400001C
+:20AAA000002007B0F12C91289FFE9120912891AC9328F51081100132014A050602020000C7
+:20AAC00000407F404040627E528455284C2048204C205220526060507E88030E0C04000089
+:20AAE00000207E4040F844C864A854A84898488054FC5404620443F440047E04001400085D
+:20AB000000007EF8408864885488550E480049FC548854906450402040507D8E06040000C6
+:20AB200004207FFE042010FCFEA410FC7CA410FCFE2031FE3922552A513E91EA110A110409
+:20AB4000000003FEFA088A0C8A888A508A508A208A30FA488A4402860304020003FE000090
+:20AB6000000013F81A48124833F822486248A3F8204027FC2444245424FC278424142408A2
+:20AB8000200017FE14080408851054905460142024502450E488250C2608240027FE2400D7
+:20ABA000021002187A104FA04A7C4A444AC44B444E7C7A444A44424402440A7C044400004F
+:20ABC00000107C104490449044907C90109010905C905108510855085A04640688040000C2
+:20ABE00006007CFE54925492549254FE5480528252825282517E508050409030100E000470
+:20AC00001020103010407DFC550455045504550455FC550455045D04110411FC11041000EC
+:20AC200020402040208023FCB204AA04AA04220423FC2204220422042204220423FC200041
+:20AC400000007EFC08207EFC08200820FEFE00003FF8210821083FF8200220021FFE00006B
+:20AC6000102010301040FDFC110411041504190431FCD10411041104110411FC51042000F8
+:20AC80001000112011201120FB3E112015201920173C3120D1201F3E112011205120212033
+:20ACA000084049FC492449247DFC4124414479FC48A449204FFE48204820482088200020B3
+:20ACC000112019202120573C99203120673CA120212021202F3E2120212021202120212094
+:20ACE0004080273E2108013E87C85108513E11082FC8217EE1082208220824082808200820
+:20AD00004000203C23C00A1C8AE052A052A212A422A82290C2904490448848A850C6408450
+:20AD2000129011107EFE3AB855569290FFFE0420081037EEC1040FF001001FF801000300D7
+:20AD4000403827C02248015087FC50E01158264623FC2244C24443FC4244424443FC4204F6
+:20AD6000020004001FF012101110FFFE12102110215040209FF8124812481248FFFE0000B8
+:20AD800008003E7822482A8E7F0032FC2A484A3085C63FFC04000FF03810C8100FF008107A
+:20ADA00000207920492049107A104A084C0E4BF4789048904890491079104A1044500820F3
+:20ADC00000207E24552654A454A857FE7C20542057FE542054207C20442000200020002040
+:20ADE00008040804490429A42A247FA4082408240924FFA408241024100420044014800814
+:20AE00001000143C97C055005900FDFC11881188FF481150113022202250448E89040200A4
+:20AE2000003001F81F00100010001FFC104010401040FFFE0000004000300018000C000806
+:20AE4000010000803FFE2140213021203FFC21402148224C2250246044C24942903E000079
+:20AE6000020001003FFC082004407FFE410400803FFC020003F004100410081030500020D6
+:20AE800010401020FFFE1084FC4811FE1142FC2413FE3840347C5044908410841114120827
+:20AEA00000403C402648254C25503C4027FC24403C40244027FE24404440444054408840B2
+:20AEC000221022102210F2102FBC22942A9432946294A2A424B424C82882A882507E000013
+:20AEE00001000180F9008BFC8A048FE48A248A248A24FBE48A1482080202020201FE000037
+:20AF0000100410043F2421244124BD24252425243D24212427242204208420941F88000073
+:20AF20001100110415FE15041A0453F45514991411F41104291425084502410280FE0000B8
+:20AF4000408030801080FDFC06040A0411E43524592499F4150811001102110210FE100016
+:20AF600000807CC0448044FC45047DF4529410945E9450F45094508850825E82E07E0000CB
+:20AF80002100110012000BF88C0854085BE81228222823E8E20822182202220221FE2000FD
+:20AFA000000007FE782048204860487048A848A449267A2244200820002000200FFE00006C
+:20AFC00000003DFE241024203C20244024C83D442646244424402440444057FE8800000094
+:20AFE0001040102013FE1000FD0810CC109013FE100011FC1D04E104410401FC01040000B4
+:20B0000004407C7C04403C7C04407C7E064001007FFE0300048808503820CA100C0E0804B7
+:20B0200000407C2045FE5400550854CC545057FE540055FC11042904250445FC8104000051
+:20B0400000807C4045FC48005108509048A04FFE4800680053F842084208420843F842085F
+:20B060000000FEFC28042804FE04AA04AAFCAA80C6808280FE8082828282FE82827E0000B0
+:20B0800010001FF81408340827E86488A7E826A826A826A82AA82AAA2AEA32862082000029
+:20B0A0002040104017FE004088404FFC544414442444E4442444245424482040204020408C
+:20B0C00000400040F7FC9150915097FE911093F8F2489248824802A80090010C0206040445
+:20B0E00000800440082010102FEEC224042008A03040DFF81248124812481248FFFE0000C9
+:20B100000000FBFC20202020222441247928C8204BFE4820482078204820402000200020CB
+:20B12000100013FE1020FE24112C15A818B03020D7FE102010201020102010205020202015
+:20B14000010000847FFE00000FF008100FF000003FF8003000C000800280290824444222B1
+:20B160004104210427C8011087C0500417C4144827D020022482C30441C84E3040C0000086
+:20B1800008000808FF8C08107F2000487F0C41107F2042442206140C0798F820404000008D
+:20B1A0000420FFFE0420450031F0232004C0F3381C4613F8104013F8104017FE284047FED8
+:20B1C0001000139E1292FE92139E3A9236925292539E9292129214A214A21ACA1104100023
+:20B1E00000007BDE2252225222523BDE6A526A52AA522BDE2A522A523A522C52256A0884E7
+:20B2000010403EFC492081F8431024E00118F6461BF8104013F8104017FC1040284047FE48
+:20B22000008078844FF648887BF048044BE67A284BF048044A26494448E84F10A820904048
+:20B2400000003E7C224422443E7C224422443E7C224422442244224442844A94850800005F
+:20B2600000107720557C556477545554554C5540777E5502550255FA5502B91413080000C2
+:20B280002080208027FCF88027F820802FFE31106648BBF6204027F820402040A0404040A8
+:20B2A00000000108FC90202027FE209044907A926A94A898289028902890389027FE0000B1
+:20B2C000000017FE102010201040FC4010D011481244144610441C40E0404FFE0000000067
+:20B2E0000110FD10211021102110211E7DD06510A5102510251025103D522592210E0000D3
+:20B300001FF801007FFE55540B2801403E2022FC3E4821FE3E2062FC6220BE2020200020DE
+:20B32000122012201220FE201220122617B81A203220D2201220122012A21322521E2000C5
+:20B34000102010201020FDFE11241528192031FCD1081188125012201450548E2B0400000F
+:20B3600000103EFE22443E2821FE3E1052FE52109E1000103FF80208020804080828101031
+:20B3800000007EFC10207EFC10201020FEFE200020883E9C20E0208024823882207E0000ED
+:20B3A000011001107D105510551055DE7D1055105510551055107D1245520192010E0000F8
+:20B3C00000400080F3F8924893F89248924893F8F08091408FFE0040004000400040004010
+:20B3E00000203C4025FC252425243DFC2524252425FC3C6024A027FE2420442054208820C9
+:20B4000000801FFE1040104097FC5448144037F8550895102490246028604890530EAC0492
+:20B42000008000803FFC2084208820802FF02410222022202140208021404230440E98044C
+:20B4400000007FFC44404440444044404440444444444846503C600040007FFE0000000096
+:20B46000010000841FFE100090045FFE506010D833465C4293F812082208220843F88208BC
+:20B4800010201F1029FE29046946AF24282828FE2F102D102D7E35103710251024100010D5
+:20B4A00000003FF8200820083FF824402440244C277024402440244445444646843C0000FA
+:20B4C0003C4025FC3C8820507DFCA4203FFE24207FFE00001FF000001FF010101FF01010F3
+:20B4E00020403E7E2890450884801FF810081FF810001FFC29242FFC292449244934880877
+:20B500001080184017FC2404340467FCA40027FC269426942BFC2A942A9432942284220CF5
+:20B5200000401040104010441FFE1000100010001FF01010101010102010201040108010DB
+:20B540000040F82009FC490449FC490049007DFE05AA15AA25FEC6AA06AA16AA0C860000EC
+:20B560000000FEFC2884FE84AA84FECC00D47CA400B4FED410CC5486950651022202000069
+:20B580004FFE2120212087FC552457FC100027FC20002FFEC0404450444C4844414040801C
+:20B5A0000000FE1C28E8FEA8AAA8AAA8AAA8FEA800A87CA800A4FEB45524913C5226240417
+:20B5C0007FFE02403FFC224422443FFC00001FF800000000FFFE01001110210845040200C0
+:20B5E000221022902A90F71E2FD22A523A626A64AF542AD42A482A482A54AA664AC4000030
+:20B6000049402A407F7E49C85D486B3049304ACE1FF010101FF010101FF010101FF00000BC
+:20B62000200021102098F8A023FE211029103110E7FE21102110211022102210A4104810B5
+:20B64000080008FE4E20484048FCFE8400A408A44AA44AA484A4085010482086C3020000B1
+:20B6600008400C2010102FEE4424052008C01FF010101110111011101290046008303020A4
+:20B6800000000FF00810081008100FF0081000007EFC42844284428442847EFC428400007A
+:20B6A0000020FE2045FC45247DFC452445FC7C0047FE444044FC7E44C40404040414040844
+:20B6C00000780FC0080008000FFC0840084008400840FFFE040006000C001800300040004D
+:20B6E000200027FC20402040FA48224C2148215027FE20402C403040C040004000400000DC
+:20B7000004400440FFFE044004403FFC111009180D200940FFFE0100010001000100010027
+:20B7200004400440FFFE0440404037FC2048844C62485150104027FEE04020402040204055
+:20B740007FFC01002110111809100D2009400100FFFE01000100010001000100010001007F
+:20B7600010181BE0104030405FFE9040104017FC100007E00420042008220822101E200075
+:20B78000020022FE14407F401478144814481448FF4814A814A82488248A24AA44CA8486D5
+:20B7A0000000400037FE20400248014CF150104017FE10401040104014401840104000404B
+:20B7C0003FFC200420043FFC241022202FFC222022203FFE22202220442044208820102025
+:20B7E00020202020202023FEFA242228222022F822882A883250C45004200850088E130489
+:20B8000020401248124402408BFE4880508010F8110821902250E22024302848218E2604D2
+:20B82000080009FE08207F404AFC48847EA442A464A454A448A454505248A0868102000025
+:20B84000404023FE8A444A4013F8151064A0284030B0250C7FFE0820044003800C60701CDE
+:20B860000020FE20102011FE21242128792069FCA988294829503A202A502488090E1204F7
+:20B880001020104021FC7D2445FC45247D2445FC446044687CA844B6013E02220C1E0000E3
+:20B8A00040402040308023F802080208F20813F812081208120813F81208280047FE800064
+:20B8C00010201020924053FE5502FF021102390235FE5502510251029102110211FE110247
+:20B8E000080404047F842124122412247FA4002400243F242124212421043F042114000883
+:20B9000008200820082008207F2008300A280C261822682008200820082008202820102072
+:20B920001020102820243DFE40207DFC912411FCFD24112411FC1124112415241924110C25
+:20B94000044006400C400840104018603050504C904610421040104010401040104000002D
+:20B9600008200820FFFE08280924FFFE01001FF011101FF0111011101FF0111011501120DC
+:20B98000042004207FFE14201FFC11242FF441041FF411141FF411141FF411141154112CAC
+:20B9A00008400840FFFE0A4001007FFC08200440FFFE00001FF01010101010101FF010102D
+:20B9C0000440FFFE045084485FFE204097FC544457FC14442444E7FC244424442454244874
+:20B9E0001028102413FE1020FFFE1222122213FE122212221FFEE2224222022A0204000005
+:20BA00000820082008207F20082018301C282B2629224820482088200820082008200820A7
+:20BA200000007FFC41045FF441044FE449244FE449244FE449244924496440047FFC4004B1
+:20BA4000082004407FFC044024481450FFFE00001FF0101010101FF0101010101FF0101021
+:20BA60002040104810440FFE904057FC544427FC24442444C7FC4444444444444454444880
+:20BA8000020841102FFE311025140318EFFE200023F82208220823F82A08320823F8020861
+:20BAA00003F87A084BF84A084BF879104FFC49104FFE49507B5804E61950064C01400080E5
+:20BAC00043F8220823F8920853F8512037FC21202FFE4250CD5E50E44350464C41480080D0
+:20BAE0002200227C7F4422443E44227C3E4422442244FF7C00442484228443148108000002
+:20BB0000222022207F20227E22443E8822203E202220FF200050245022884288810606046C
+:20BB2000100017FE10901090FC9013FC3A94369452945294931C1204120413FC1204100091
+:20BB40000050004800403FFE224023C422263FE4222822384B104A9052AA92CA860602025B
+:20BB600001007FFC01003FF001107FFE01103FF00200FFFE04200820064001800660381883
+:20BB80000000010001000100010001FE7F00010001000100010001040104010400F8000018
+:20BBA00000808FFE60802FF000901FFE20902FF02104DFFE42104420424041804670580CE8
+:20BBC000404027FC20E00150964C504010A02110264C2250C16040E043584C44414040808D
+:20BBE00010800880409C20E007841084107C200001007FFE034005201918610E01040100FA
+:20BC00000200420022FC22248A244FA452241224222422A4E3442244208421142208000093
+:20BC2000082008207FFC082008200FE008200FE008200820FFFE08400C2018103018401062
+:20BC40001088108811FEFC88308838F8548850F89088108813FE10001088108411061202ED
+:20BC6000010001003FF8010002C00C383010FFFE00101F10111011101F1011100050002006
+:20BC80000840084008400BFE48404E4048404BFC490848884E90F060006001901E0E00046E
+:20BCA000002000207C2055FC542054207FFE54205420542055FC7C204420402003FE0000E4
+:20BCC0001020102013FC54505488550857FE540455E455245D24F1E44124000400140008DE
+:20BCE000004078204BFE4908789048604890490E7E9448904890489048904910B9109210BD
+:20BD0000020001007FFE04200240018002400C30742E042404200820082010202020002070
+:20BD200020801080FDFE2100228823FE3C8824F8248824F8248847FE5488890C02040000DC
+:20BD40002008103C11C0FD000900110011FE3110591095101110111011101210121014105E
+:20BD60001000087E00447F480248045008501C482A444A448842084208540848084008407C
+:20BD80000040F8400BFC48A0489049084BFE7C0405E415242524C5E40404141408080000F6
+:20BDA0000800080008F87E0808080808FEF8088048804E844884487C4800A8009FFE000098
+:20BDC0000100210821083FF8000800003FF0001000103FF0200020082008200C1FF80000A0
+:20BDE000100018081FFC1000200020005FE080C00180030006000C04180410060FFC000052
+:20BE0000010001800100028004400830311EC184111019F81100110011001104FFFE000096
+:20BE2000010000C000801FFC100410041FFC1000100017FC14042404240447FC84040000FD
+:20BE4000080008FC7F2408247F240824FF44085C08880100FFFE028004400830300EC00403
+:20BE60000100FD00217E211221D2471279126912A922292229A229223842284420940108D1
+:20BE80003E7C224422443E7C01100108FFFC06C01830E00E3EFC2288228822883EF80000E3
+:20BEA000080008001FFE100020004FF800001FF00010001000100010000A000A0006000273
+:20BEC0000200420033F82400080017E0E040208021082208240827F02000580087FE00007D
+:20BEE000010000847FFE0220041008F81F1004200420FFFE0420042008200820102020208E
+:20BF00004200220023FC040097F8580057F0101010102010E0102010200A200A2006200240
+:20BF200020801040104007FC880048085008121022102110E1202120204020403FFE2000AA
+:20BF400041002180310021FE02000200E5F8201020202040208021022A02320221FC0000BE
+:20BF60001080108010FEFD041108161018001040339ED202120213DE1202120253FE2202A4
+:20BF80002080208020C031202910A208A7F6A800200023F822082208220823F8220800000A
+:20BFA0004080208021400120821854065BF01000200027F8C40844084408440847F84408D6
+:20BFC000010001003FFC0240042018107FFE488288841FF8208000807FFE0080008000800F
+:20BFE0001000103C11E0FC2010201420182017FE3020D02010201020102010205020202077
+:20C000001000101C20E03E2040207C2091FE1020FE20102010201020102014201820102051
+:20C02000100010F820883E8840887C8891061000FDF8110811081108150819F81108000080
+:20C04000001000F83F00010001000104FFFE0100010001000100010001000100010000008D
+:20C060000000403C37C0204000400040EFFE20402040204020402040204050008FFE000063
+:20C0800020403E7E28904508830804800860101E2FE4C01012100920092000407FFC0000C8
+:20C0A00008080C3C0BC01040104030445FFE904010401040104010401040104010400000EC
+:20C0C000820841106FFE412007F80128EFFE2128212827F821202B30352C2926112401204F
+:20C0E00010401060FF40107E7E8042807F7C42087E104A200840FF4408840886087C080085
+:20C100000020FE209220D650BA88FF061040FE2010201EFCE0082A08551055108020000086
+:20C1200020A020903C9020FC43807880A0BC23C0FC442048203020602892330A2006000216
+:20C140001088108820883C8843FE7C8890881088FCF8108810881088148818F8108800004E
+:20C16000081006180420FFFE00003E0822483E48224822483E48224822482A082428001076
+:20C180004210221027BC02108FBE5210152828C6200027F8C40847F84408440847F84408DF
+:20C1A000004023F8124813F8004007FEE00023F0221023F0220023F8220823F850008FFEE3
+:20C1C000208010901088008083FC4880488017FE10802088E050206021A22612200A2006B0
+:20C1E000402029FC352425FC002003FEE0002CF8248824F8248024F8248834F82A0011FE82
+:20C200000800080E7F701040287E7E4808880E8879080A0809001FF8010001007FFE0000FD
+:20C22000010021083FF80000244024407E7C248425283C20242024503C48248E2504020071
+:20C2400008000C0008001FFC100821104120810002800280044004400830301EC0080000A2
+:20C260002120112012207FBE14247F481510FFD015107F1016283528554894441486150473
+:20C280001040104010E0FE901108120E39F4351055105110915011241104110410FC1000B3
+:20C2A00000400040F84088A089108A0E8FF48A108A10FA108A5082200204020401FC000027
+:20C2C00000403C2025FE26043C9024C8248625043E0025FC242024202420442057FE88007E
+:20C2E0001020083004407FFC01001FF8010001007FFE02400240044404440846103C2000B2
+:20C300002040204027FE2048FA4C215027FE200023FC22043AF4E29442F4020403FC0204AA
+:20C320000840FFFE084001003FF809200540FFFE00003FF8200827C8244827C820083FF8C5
+:20C34000000079F80908090879F8404043FC42447A440A440BFC084008480844287E13C420
+:20C36000204020402040FCA02118220E2DF431106110A110215021202104A10440FC00005C
+:20C3800011F8104011F8FC4013FC3842343E500057BC92101FBC12101FFE12101312120E7E
+:20C3A00020D02710391041524134FFD821102310FB902550292821282944314421820100AA
+:20C3C00010200820FFA0003E3E2022203EFE0084FF448148BD28A510BD308148858E8204D3
+:20C3E0001040104012441948555053FC920413FC1204120413FC12041204121412080000A6
+:20C40000200023FC2040FC4027FE70A06910A208AD162110211021102210221024102010CB
+:20C42000014079204BFE4A204E207BFC4A204A207BFC4A204A204BFE7A004D2444920892C7
+:20C4400000F83F80010001047FFE034006200818342EC424042008200820102060200000AB
+:20C4600010381BC0108020802FFE61A0A318260E29142110211022102210241028100000DD
+:20C48000000001FE7C4010401040104010FC1044100416043804C0040004004400280010E3
+:20C4A00024202420FF2424A43C6810FC7E8452847EFC10841084FEFC108410841094108881
+:20C4C00023F8204023F8F84027FC2042287E30006F7CA4103F7C24103F7E2410A612441E9A
+:20C4E000200021DC3C44E0642A5415542AC440CCFD542A6428442954288A480287FE000031
+:20C5000010201020112454A654A855FC550455FC550455045DFCF104410401140108000032
+:20C5200008400C481A4C115033FC3204520493FC1204120413FC12041204121412080000A7
+:20C54000010000807FFE44449830600801FC7E401040107810081C08E008000800500020F6
+:20C560001000100013FC104410441E44F04410441044128414841904110402140408000024
+:20C5800004200420FFFE042004200800087C7F4409440944114411442144477C824400008D
+:20C5A00000000FF00810081008100FF00810081008100FF00810081008107FFE0000000029
+:20C5C0002040204020403040A9FCA840A040204027FE204020802088210423FE20040000C7
+:20C5E000010000803FFE22220C103008100011FC1E44F04410441244148418841128021009
+:20C60000204020403E40208040FE7CA4A1282020FC202020205020502888310E2604000080
+:20C6200010001BF8100823F8200873F8A00027FE28022BF42110212020C021B02E0E0000A4
+:20C64000020001003FFC0820043004407FFE010001003FFC010011201918210C4508020063
+:20C6600001003FFC02003FF80200FFFE042008F03F08C1063FF8034005200918310EC10458
+:20C6800000007EFE08103E7C08107EFE010002800C60311EC0840FF0002000400080000057
+:20C6A00011101110FFD011101F7E04123F9224923F9204123FA204223FA2044E07447880AA
+:20C6C00004400440FFFE044000F81F00100010001FFE10401040104020402040404080404D
+:20C6E000104010601090F94E17F410A01A4812A833F8D04017FC14A415F414145404240CFD
+:20C70000010002800D60309EDFF40240119012501FF002003FF824482FE8202820282010B8
+:20C72000020001007FFE480489F8480839F828080BFE1C0429F8C89048600890090E0A04F4
+:20C740004080204020200020890049005108150425022902C90051084108410840F80000D7
+:20C76000010001003FF801001FF00100FFFE00001FF010101FF010101FF010101050102055
+:20C78000200021FCFE08201050205050908CFD0413FE10201C20F0201020102017FE1000E7
+:20C7A00008001FFC10002FFC40003FF000103FD0009003100CD070301FD0020A020A7FF6F2
+:20C7C000100019FE1020284068FCAE8428A428A428A428A42AA42C202850208C210422004F
+:20C7E0000C0073DE42524A524BD24A524A524BD25A126A9A12D4135022104010801000006F
+:20C80000404023FC20400BFC884057FC500013F8220823F8E20823F8220822082228221082
+:20C820001440FF40147E7E8842D0BB302A283A4E06843FF801003FFC01007FFE0100030077
+:20C84000004003FC784049F848404FFE780049F8490849F8790849F8010801080128011072
+:20C860003FFC20005FF080007FF004103F9004103F9004087FE8108A1F8A10861F861082D6
+:20C880002040204027FC3040ABF8A040AFFE200023F8220823F8220823F8220822282210AA
+:20C8A000000003FE2040208021FC3D04212421242524292431242050008803060C02000095
+:20C8C000004047FC304023F8004007FEF00013F8120813F8120813F816081A081228021034
+:20C8E000010000803FFE2080208020803FFE214021402120222022104418480E90040000A0
+:20C9000000800040784017FE100013F87A08120813F8104012501A486444044409400080FB
+:20C92000020001007FFE400210201010220842003FF8020804080408080810102050402020
+:20C9400000200E20F020102410A4FEA830B039205460945010501088108811041206140445
+:20C96000000010F01F0010001000100010081FFC10401040104010401044FFFE00000000A4
+:20C980000000077E3844204420483F50244824442442244224422F5AF044004000400040B8
+:20C9A00000500048F84827FE2040224479482150206020D021483A46C44000400140008024
+:20C9C000014001300110FFFE010021181120094005C009201118610E010401000500020090
+:20C9E00000007FFC410441044104410441044284424444244834501460047FFC40040000AC
+:20CA0000082004200440FFFE04803FF8248824882888287830083FF8200820083FF8200808
+:20CA2000400027FC24440444844454445444144424A42494E51426042404240427FC240455
+:20CA4000084008407E7C0888091008FCFF04080428FC2F04280429FC280458008FFE0000D7
+:20CA600000007FFC402040304820464041404080414042204430481850107FFC00000000AA
+:20CA8000100011F811087D08550855F8550855087D0855F81108190815081FFEE400000051
+:20CAA0000440044004403FFC24442444244424443FFC24442444244424443FFC2004000095
+:20CAC000100020FE7C8044847C8444C87CA844904490FCA80CA814C42484448094FE080056
+:20CAE0001FFC100410041FFC100410401444144427FC20442842284248424FFE8802000008
+:20CB00000000F9FE090049044984494849287D10051805283524C5440584290011FE0000FF
+:20CB2000200013FC82004BF8120813F8620023FC21007FFE038005400930310EC1040100B7
+:20CB40000000FF80227E22443E44224422443E282228229027103A28C24602840200020075
+:20CB6000FF0022FC3E8822483E5023203E50E38C0200FFFE04200820044003800C60701C90
+:20CB8000080008FC2E2028FCFEA400A410FC522052FE6AA246AA42FE42824E8A7284000035
+:20CBA000100013F011407D5E11E41154FF4811C851485D5451D25662B0408C0003FC00001C
+:20CBC0000100010001003FFC01000100010001007FFE02000600082010103FF810100000EF
+:20CBE0007FFC4004492445445FF442047FFC44444FBC74944584442443E440047FFC400476
+:20CC00002200FF7E22107720557C774428547F544854FE5448547E2848247F4240820000B2
+:20CC20001000100011FCFE84108830883888344854505050902010201050118E160410006C
+:20CC40000090FE902BFE2890FC40AC60AC90AD08AEF6C420FC2085F88420FC2085FE000038
+:20CC6000010002001FF010101FF010101FF00100011C7DE0054009201118210EC504020038
+:20CC800001000100028004400830101C3FF84100010001101FF80100010001047FFE000043
+:20CCA000008000401FFE104090A05110520814063BF85040904027F8204020444FFE8000FF
+:20CCC000020012200A407FF80200FFFC05801860E79C01001FF001007FFC0100050002004E
+:20CCE00001000120011001107FFE01000280028002400440042008201010200EC00400008A
+:20CD000011100D1809203FFC01000200FFFE0C2018182FFEC214021004100810105020202C
+:20CD2000002000207E20022043FE2422142208220C221442124222824082011C02080400A3
+:20CD40002040304020407DF850489048FE4811FE544054A054A054905D18610E020404001B
+:20CD600010401040144017F8184850485088908817FE10A02920251042104408880E10043D
+:20CD800001003FFE22002FBCA4A464A42ABC7140A7FC24A42554264444A44514861404082C
+:20CDA0000800087C08447F44084408440844FF4410441244214427D4794820400040004006
+:20CDC00000102420247C7E6424542444FF4C00403E7E220222023EFA220222023E0A220420
+:20CDE0002020202023FEFA442060609071FEAB10A51029FC211021FC2110211021FE2100F0
+:20CE0000008000FC7C88111013FC21243D2465FCA524252425FC3D24222422240414080813
+:20CE20000100111011282148018006801840EFFC08800FF808800FF8088008800FFC0800A3
+:20CE4000200013F81088F8880FFE108817F828887100A9FC22842484288420FC208420003B
+:20CE600000847E461228FEFE121012107E7C101020103E1062FEA21022103E102210001084
+:20CE8000084008501F48114833FE2A40646094A00890110E26044000288824446666422236
+:20CEA0002210221023D82C54B490AAFEA510A22822482484290652484D2445B688920000C7
+:20CEC000010001003FF8210821083FF8210821082108FFFE20082008200820082028201000
+:20CEE0002080108083F048901110611222122D0E0100FFFE038005400930311CC10801009E
+:20CF00001000FF1C52E876A824A87EA824A87EA824A8FFA828A86AA4A524313C22260404D3
+:20CF200020802FFE22A823B8F910211027FC211027FC21103FFEE35845200958138E0104B9
+:20CF4000104017FE100013BCFAA413BC189013FC3090D3FC109017FE11241318558E2104BD
+:20CF600000800040FFFE94A497BC911097FC911097FC9110FFFE9140032405580B8E010470
+:20CF800040402040304020400040007CE040204020402040204020402840304027FE000028
+:20CFA0002040204021FE3C2044284812806A218623FC20A020A0212029223222241E00001E
+:20CFC000104010501048FC4013FE1060146018A030A0D0A01120112012221422581E2000BE
+:20CFE0001100110020FC23884850F0201054218C47FEF920012001201A22E222041E00008D
+:20D00000084008407EFC094002007FFC08001FF02810CFF0000009002884281247F200000A
+:20D0200010801080FFF8109012901990F0D05168122A540A28060110288864CCC444800034
+:20D04000000001F83F000100010001000100FFFE010001000100010001003FFC0000000057
+:20D060001000180817FC300020006000A000200020002000200020042FFE2000200000000C
+:20D080000100018001000100010001000280028004800440086008301018200E4004000004
+:20D0A0003FF801081108110812082208040808F01220010808C428862814281047F0000056
+:20D0C0000800087CFF24082408A47EA409240824FF24092409240D240A4408440894090859
+:20D0E00008000C3C1BC010403040304050409FFE1040104010401040104017FE10000000F3
+:20D10000404020401840104000400040F04010A010A010A01090111015081A0812060404A7
+:20D1200000003FFC010401040104090409041904310402040204040408043038C0100000E1
+:20D140001000180E11F0FC2024202420242027FE4820482030201020282045FE840000002C
+:20D160000800080011FC122424247D240924112421247A4402440C44F08441040228041081
+:20D18000100013F811081110FD101120153C19043104D1041204120412041404582820107A
+:20D1A00010001BF81108210831106110A13C21142104220422042204240824482828201097
+:20D1C00000001FF010101010101010101FF0101010101010101010101FF0101000000000E2
+:20D1E0000040005000487FFE08400850085808507F300820086010A413142C0C40040000EC
+:20D2000004400440FFFE04407FFC08200FE0082008200FE008200820FFFE002000200020C7
+:20D220000440FFFE064005403FFE44244910128C244808301FEE6824082008200FE00820E2
+:20D24000044004407FFE044004407FFE410481003FFC0180034005200918310EC1040100B4
+:20D260000010FE1000107C1044FE7C920092FE92AAFE9292FE1092149212921E96E2000036
+:20D280002040202023FE2204AC90B108A244A4A02110220C35FE2908450841F881080000B6
+:20D2A0004080204027FE040481205218128824C021202218CFF642104210421043F04210DD
+:20D2C000020001007FFE44448D301918229004400830300ECFE40820082008200FE00820AA
+:20D2E00010201020202820244FFEF1201120212447A4F118011002301A4AE48A0806000255
+:20D3000000007FFE4004800807E004200420042004200420082008221022201EC0000000A7
+:20D32000000011FC10081030FDFE106414A01B20106033FED06010B010A8112E56242020E8
+:20D340001FF0002001407FFE03040D08310003000100FFFE038005401930E10E010401008C
+:20D360000100010001003FFC2104228424642924310422842244243428242004201420086A
+:20D3800004400440FFFE044010001000FF7C12441244224434440C44127C2144418081001A
+:20D3A000200023FE2040FBFEAA44AD50A888FFFEA040A3FC32A42AA43EA4CAA402AC00009A
+:20D3C00017F8184017FE284427786040A73820002FFE208027FC24A424A424A424942408FB
+:20D3E00003FCF8200FFE1422112810A4182017FE3040D3FC12A412A412A452A422AC000074
+:20D40000100010001800107EFE422242224222422242244214420842147E23424242800075
+:20D420003FFC20002FF820003FFE250824904460461E84287FFE00200420042000A00040B3
+:20D4400007207C20012049A02A2000207FA00220042007A07C20042204221422081E000045
+:20D4600020401040104080804FFE408809081110121021A0E06020502088230C2C040000CB
+:20D480000C0006000200010003000280028004400420082008101008200E400480000000BE
+:20D4A000200013FC1200FBF80A0013F812CC36B05ACE968813FE1408148818881028101058
+:20D4C000104010401080FEFE208429204820FE20082008500E50F8880888090409060A0495
+:20D4E00000007BF848005000500067FC51204920492049206920522242224422481E400055
+:20D50000044004407FFE044001102988282847E010000C14280AA2AAA5A4A4A43D1C0000F1
+:20D520000020F9242124212421FC2000FBFE204023FE22522A523252C2520252024A02043F
+:20D54000210820883C5021FC41047D04A10421FCFC5020502050249228923112260E0000B6
+:20D56000100009FC080420042FF4210421042FF42104210421043FFC200420042014200888
+:20D58000440022FC20040404840457F45484248427F44484C48447F4440444044414440810
+:20D5A000042004207FFE042005200200FFFE040008001FF82808480888080FF80808000014
+:20D5C0007EFC020402043EFC208020803EFC0204224412240A14121CE2E44244141408089F
+:20D5E000251025182FD0F510251E2FF4202437E46494A79424882788249424A6A5C44480B3
+:20D60000400027FE20A008A088A057FC54A414A424A424A4E51C26042404240427FC2404BC
+:20D6200004400440FFFE0440044078204BFE5088605053FE4A006A0052004400440048004D
+:20D6400000007BF84A484A487BF84A484A484BF8780048A84A944A924A824C88A8789000E7
+:20D66000200021FC3D24452449FCFD24552455FC7C0054207C9402921A82E484007C00005F
+:20D68000020001007FFE44421FF804401FF804407FFE042009183FFEC10401007FFC00008E
+:20D6A00001007FFE4444BFF004403FF804407FFC08303FEEC9240920092002C00C38301091
+:20D6C000000000007FFC00000000000000003FF8000000000000000000007FFE000000001B
+:20D6E0000200044008201FF00A2004047FFE082010182FEEC0040FE0000000003FF80000A7
+:20D7000001000100028004600918310EC12411300D200940FFFE0100010001000100010023
+:20D7200024402460FF402440247EFF8400C47F4842287E2842107E10422842284A46448492
+:20D740000FE0024001801E7800007CFC24481930654CFFFE038005401930610E0104010020
+:20D7600003F00110F0E0931897BC90A4971893249CC2FFFE90C001600258044E08440040F9
+:20D78000010001007FFC010019200D3009407FFE1100111010B810C0106012381C1010000F
+:20D7A000100017FC12481130FCA0106014D81B4E3FFCD248124813F81040104457FE200275
+:20D7C0000000F9FC08A84850482048D84B267C2005FC152425FCC420042415FE08020000F3
+:20D7E0001000100011FC1004FE041004140418FC3004D0041004100411FC500020000000F9
+:20D80000202020A0232E2222FBAE2A222BFE2A2248204BFC310828904C604898830E0C043C
+:20D8200000007EFC10207EFC10201020FEFE0110009024A02444258246121C1063F000001D
+:20D840000400040007F0082010403FF05110111011101FF010001004100410040FFC000019
+:20D86000400027FC20440244928454845114160820402240E27C2240224022402FFE200097
+:20D88000010001007FFC038005601910610C0820FEFE08201C702A68C8A80B260820082032
+:20D8A00012101918112027FC3654655CA56427FC240423F8220823F82208220823F8220829
+:20D8C000042004207FFE0420204010500A484B462A4414481048F050202020C023002C00EB
+:20D8E0000020FC2020202020212821243A226A206C24A82428082810382028C023000C00C5
+:20D90000002018200640018002600C30311001007FFE0100092009101108210805000200FF
+:20D92000210412040C241A2431A4452404247FA404242624352464A484841404081400089E
+:20D94000204010401040015041482A440A42144010442044E0082010202020C023002C00A0
+:20D96000102010202020252845A4F922122224204024FC2800100C20F0404180060018006B
+:20D9800010801BFC1294226432946204A3FC240826062BFC231024A0284021B02E0E0000FE
+:20D9A00000400040F0A09110920895F6984097FC9040F04093F88208020803F80208000002
+:20D9C000104010403E4424FE7E8883483E48023002303ECE0304000048884444C66682220D
+:20D9E00020403F7E2890450888000BFE482049FC49244924492449241134112820204020F5
+:20DA0000000007FE7890489048904BFC7A944A944A944A947B1C4A040204020403FC020464
+:20DA20000000FBBC22A422A422A422A4FFFE22A422A422A424A43CA4C6C4095410880000A1
+:20DA4000042004207FFE04200520010001FC010001003FF82008200820083FF820080000AA
+:20DA60000800080808107F2008C01C041A082A102860498288040808081008600B80080091
+:20DA800001000100010001000100210421042104210421042104210421047FFC20040000BA
+:20DAA00000023B822A922A922A922A92FFF22A922A922A922A924A924A82BA82958E0004CB
+:20DAC0001040102013FC120417FC5A0053DC5244934412D42A4C24D42544444489541088DE
+:20DAE0002008100C1010FE200448088C12103420584094841306120C103010C01700100030
+:20DB0000200013FC1004400441044104410441044284424444245824400440044014400816
+:20DB20000080F880888097FC9080A48892908AA08FFE8880A940912082108408980680005F
+:20DB4000104017FE1000FBFC120416F41A9413FC3000D1F8110811F8110811F8500027FECA
+:20DB600000407CFC450857FE55445592557C5500557C5500557C1200227C4A44847C044428
+:20DB8000790848904FFE48407BFC48404BFE4A4879504FFE48004BFC4A044A04ABFC900005
+:20DBA000082004407FFC01001FF001007FFC11100920FFFE00001FF0101010101FF010102D
+:20DBC0002000104010400040804054445444144424442444E4442444244427FC24040000EA
+:20DBE000010000803FFC20043FFC20002F7C21042924251C23142524594441048514020887
+:20DC00002108309027FE40404BF8F84017FE22484150F7FE000003F81A08E20803F80208EA
+:20DC20002080204027FE2108FC9023FC2254228C23F422943A94E2F442940204021402085A
+:20DC400009000D80090411FE124034405BFC904410441044108410841104110412141408E5
+:20DC6000010000807FFC042002403FF8224824283FE82448244827C8244824082028201057
+:20DC8000111009207FFE40040FE008200FE000001FF011101110111012900460181C60085F
+:20DCA0000040004000807BFC4A044A044AF47A944A944A944A944AF47A0402040214020889
+:20DCC00000000100010001000100010001F801000100010001000100010001047FFE0000BE
+:20DCE0000100211011180D2009403FFC200427E424242424242427E424242404201420083A
+:20DD00001110091805207FFE40048FE008200FE00100FFFE06880C503430C50E0E04040020
+:20DD2000102010201124FCA410A839FC350455FC5104910411FC11041104110411141108C3
+:20DD4000102012241126FDAC10A811FE1502190231FED102110211FE11021102510A2104BA
+:20DD60000E20792208A408A87DFC19041D042BFC2904490449FC890409040904091409080C
+:20DD80001080108017FC1488185050E453345C0E97FC11202920252042224222841E080063
+:20DDA00004400440FFFE044010001FF81008200844080208018801080008000800500020CB
+:20DDC000080008000FFC1004100420044404820401040184010400040004004800280010F7
+:20DDE000100008FC7F2422241424FF44009400083E0022FC22843E84228422843EFC22841F
+:20DE000001000100012009100D0C090811002108410C01180030006001800E00700000006D
+:20DE200000400448FB4C89508BFC8A048A048BFC8A04FA048BFC8A0402040204021402083F
+:20DE400000007F7E114411481148215025484244BF4221422142215A3F44214000400040B4
+:20DE6000100011FC204420444884F0841114220841FCF904010401041904E1FC01040000EB
+:20DE800002007FFE048008603118CFE60130FFFE03000FF03810CFF0081008100FF008109B
+:20DEA00000207C20445044885506560454F8540055FE542054A810A42926462484A000405D
+:20DEC00010401030102011FE7D045688548054887CB054C0108014841E84E484007800007A
+:20DEE00000F87F00010001000100FFFE010001003FF820082008200820083FF82008000073
+:20DF000001000280044008303FEEC10401007FFC010001001FF01010101010101FF01010F4
+:20DF2000084008407E400840087EFFC424842448A628A510A510242824284444548689042F
+:20DF400027FC211021F0F91021F0291C37F06010AFBE24A22314210822982466A984400022
+:20DF6000080810083F0821083FFE21083F08214821287F2805280908110821084528021004
+:20DF8000200027FE21483128A998A94EA7F820082FBE2082252422142508289620642000DE
+:20DFA0002040104012400A7C8A4052405FFE10402244E24424482850202020C023002C00F1
+:20DFC000204010401040FC40044008400BFC10403840D440104010401040104017FE100031
+:20DFE000400021F03110211001100110E20E25F8210821082090209028603090230E0C04F4
+:20E0000000207C20102011FC112421243DFC6524A524252425FC25243C202420202000204F
+:20E02000010001003FF82108210821083FF82108210821083FF82108010001000100010016
+:20E0400000200020FBFE8A228A228BFE8A228A228A22FBFE8A22002000200020002000205D
+:20E0600008400C40184017FC3444344457FC9444144417FC1444144010401040104000007F
+:20E08000020004000FF008100FF008140FF6081408187FFE0070019006101810605000207B
+:20E0A000400027FE24040120811856085040104027FC2040C0E04158464E584440404040EF
+:20E0C000200031FC21002100FDF8290029FE49A04AA432A812902A902A8844AE84C40880EB
+:20E0E00000201020102021FC4524F92409FC112421247DFC00201C20E02000200020002049
+:20E10000202010201020FDFC0524092411FC3924552495FC11241020102010201020102077
+:20E1200020401040104087FE4C44544810C010C020C020C0E140214222422442383E00000A
+:20E14000020001007FFE410481001FF0111011101FF0111011101FF01110010001000100A4
+:20E160002040202021FEFA222A2429FC2924492449FC2924112429FC45248420002000205E
+:20E18000082008207FFE08200FE008200FE008200820FFFE10001140122014101FF8000069
+:20E1A00004F82508249024602450248805041FF010101FF0101010101FF010101050102098
+:20E1C0002040204027FC3080ABF8AA08A3F8220823F8220823F822082FFE2110220C240454
+:20E1E00040802080211003F8808057FE5120121024483986C62040C8473040C043004C008C
+:20E200000100FFFE010001007FFC00003FF8210821083FF82008200040004000800000007B
+:20E22000008010C0108010881FFC2080208040889FFC008000800080008000847FFE0000A7
+:20E2400008FC08A448A448FC7EA448A488FC7E2009FC082408240E44F844408401140208E0
+:20E2600010201120512051207DFE922012201A2035FCD02010201020102017FE10000000EC
+:20E28000000007203C200420042004247FFE04200420042008200820102020204020000082
+:20E2A000200031F82108410849F8F84013FC224443FCFA4403FC00401842E042003E00003F
+:20E2C00001000910090811146164018006003FF8C8080FF808080FF8080808080FF8080846
+:20E2E00000A000903FFE208020803E48225022224AD2450E9FF8124812481248FFFE000024
+:20E3000003827C020402FFD21512755215923552D4D20E12151224C24482840A04040000D8
+:20E3200000203C20252025203DFC2620242024203DFC242024202420442057FE880000008A
+:20E3400000003FF80830046002C0010006C0183CE10801001FF80100010001007FFE00008C
+:20E3600008000BFE482048204BFE4A224A224A224A225222522A122420204020802000203D
+:20E3800001000900090011001FF82100410001007FFE01000280024004200830101C2008ED
+:20E3A0008100497E35102510557E955215523552555295521552115A1254A4104810101001
+:20E3C000208010C01080FDFE210022203CA024BC24E427A424A424AC44A25482887E0000F6
+:20E3E000000023F8120813F8820843F8500010A010A024A422A8E2B020A020A02FFE200077
+:20E400004040204033FC2040004007FEF008100817FE110810881088140818081028001056
+:20E4200000003FFC2004200420043FFC20002000200020002000200020004000400080001A
+:20E4400000007FF0001003D07C1004103F90249024903F902410048A07CA7C6620420000ED
+:20E46000010001000100010001000100FFFE01000100010001000100010001000100000091
+:20E480000000FFFE020002000400040007F80C080C08140824084408840807F80408000021
+:20E4A000104010401060FC901118120E1DF410003000D1F8110811081108110851F8200090
+:20E4C000001000107C10441047FE44107C104510449044907C1000100010001000500020EE
+:20E4E00008400C40084018401040304057FE904010401040104010401040104010400000D3
+:20E500000200030004800A403130DFEC10201FE010201FE0121011A01040143018101000FF
+:20E5200000202020202020203DFC45244924A12421FC2124202024282824303E23C4000098
+:20E54000010000803FFE2804468804800880068004807FFE008001400220041018186010D9
+:20E56000400021F83108210801080108F10811F8100010901088108815041906120404009A
+:20E580000100010001003FF82108210821083FF82108090005000200050008E0301EC00457
+:20E5A0000800080008001FF8110021004100FFFE028002800440044008201010600E8004F6
+:20E5C00008400C401BFE104037FC6444A44427FC24442240218020802170221E2C0400004C
+:20E5E0003FF8200820083FF82090289824A03FFC218021C022A02498288E508440808080A4
+:20E600000020F820082049FC4924492449247FFC022003201AA0E24002600298150E080447
+:20E620001020183010201048FC8425FE2484440044FC288418841484228442FC8084000043
+:20E6400000A0009800907FFC0080008000803E800840084008400B201C227012200A000448
+:20E6600000001FF80000000000007FFE01000100112011102108410C8104010005000200AF
+:20E6800001000100010001000100FFFE010001000100010001000100010001007FFC0000F5
+:20E6A00000001210121012101210FFFE12101210121013F01210100010081FFC0000000007
+:20E6C000104010201020FDFE1020302039FC552451249124112411341128102010201020F4
+:20E6E0000100FFFE01001FF811081FF801003FF80108FFFE01083FF801080900050002003D
+:20E700001020102810241020FBFE1020182017E03110D11011501188110A16065002200010
+:20E72000100CFEF010807CFE111052102490FFFE00001FF000001FF000001FF010101FF035
+:20E740000000420C227022400FC0027EE35026502A50229022902B10241050008FFE000055
+:20E76000084008407DF008900D9038D0094A2A0A150401103FF802100210041008501020B7
+:20E7800000000FF008100FF008100FF00000FFFE0100090009F809001500230040FE0000C5
+:20E7A000004003F4F04897FE902090D093F49D0691FCF00093F8020803F8020803F80208FF
+:20E7C00002200220F3FE9528994497FE904092489248F2489254855208E200401FFE000013
+:20E7E000403823C0204000400FFE0040E04023F822082208220823F8200050008FFE000000
+:20E8000008400C401840104030442FFE6040A040204020402040204020442FFE200000006A
+:20E820000840084017FC104020406FFEA010201027FE2010221021902110201020502020EF
+:20E840000DFC7088105054203858FD861020382035FC502053FE9020102010201020000016
+:20E860002080208020803DFE45204A20A3FC25242124212421242124292C302020200020AD
+:20E88000000000F83F002100210021003FFC2080208020802040204024242814300C20041F
+:20E8A00002000100FFFE010001001FF811081108110811081108110811281110010001004D
+:20E8C0002040204023FC3040A840A7FEA010201027FE2010221021102010205020200000E4
+:20E8E000020001003FFE200440083FFC040008201FF0011001003FF801000100FFFE0000AE
+:20E90000200019FC1104FD240524092411242924552496541450109010921112120E140054
+:20E92000002040282024302427FE0020E02027E0212021102110210A29CA3606200200004C
+:20E94000088008800880488049FE49084A88488848885850685048200850098E0E0408007C
+:20E96000000001F87F00010001007FFC010001000100FFFE01000100010001000500020097
+:20E9800008100420FFFE010002001FF0101010101FF010101FF0101010101FF0101000003F
+:20E9A000010000803FFE20044028002000207FFE00200820042006200420002000A000409A
+:20E9C000010001007FFE01001FFC02007FFE0210041005FE0A1011102190C11000500020C7
+:20E9E000203C27C02084FA48215027FE2C04300063F8A11020A0204020A0231CAC084000D9
+:20EA0000090008801FFC10803FF850809FF810801FFC00001FF81008100810081FF81008E3
+:20EA200000F87F902218119009207FFE400480081FE008200440024001800660181C600852
+:20EA4000010000801FFE128094B8548856B8148837F8508097F81210212020C043309C0EC6
+:20EA6000082004403FF821083FF8210821083FF80000FFFE00001FF0101010101FF010108F
+:20EA80000440FFFE044000207DFC0840108811FC50045D50515051505D52F252024E0400E1
+:20EAA000100011FE1100FD08110C3148392855105518912811441184110011FE1000100075
+:20EAC0001040102013FEFC40108031083BFC54045148914811481148124A124A14461000CB
+:20EAE00000200120FD2021FC22203C2047FE4460A87018B010A8112822264C2480200020CB
+:20EB0000100011FC1008FC901060102015FE18243028D020102010201020102050A02040ED
+:20EB200020402040FCA0211843F65400FC0453D412541FD4F25413D4125412541344128C45
+:20EB40000800080008FC0E8808880888FF4808482C502A3049204950888829061204000027
+:20EB6000100011FC280424484330FE1011FEFE14101010107E10421042107E50422000009C
+:20EB800044002400247C8744444444441FA8242824284D10D49054A8644C4486550448005B
+:20EBA0000040FC2007FE28801090110853FC5C045148514851485D48724AC24A044A080650
+:20EBC00002000210020C3FF6021402100210FFFC020402040204020402480228021000000B
+:20EBE0000020F8208BFCA820ABFEA824A928ACE0AAA0AA20A7FE20202050508849068A049E
+:20EC000010400840FE4000407DF844487C4800C87E6804581E88E88A088A090A2906120011
+:20EC200010200820FF2024F83C2800A87E480468084A7E8A09062A125088444CC4440000EE
+:20EC40000420FFFE04201FF812481FF801203FF801407FFE03001FF068100FF008100FF031
+:20EC60001FF010101FF010101FF002003FF80220FFFE03000FF03810CFF008100FF0081097
+:20EC800003FC7A944A944BFC48404BFC78484FFE486049FC4F0479FC0104010401FC0000AA
+:20ECA0003FFC224422443FFC01101FF80120FFFE02000FF03810CFF0081008100FF008107D
+:20ECC00000001FF812481FF810001FFC110421045FF411141FF4112401F47E2400140008D4
+:20ECE00000F81F0001007FFE038005601910E10C028405401930E54E03C00D2031180308F6
+:20ED0000040039F020103DF020103FF0000031902950311029902152290A318A210600004E
+:20ED20003FFC20043FFC20002FF8208027F8248827F820802FFC28A448F44B148804080C96
+:20ED40000100012001100100FFFE010003800540052009101118210EC1040100010000005C
+:20ED6000404020503048204007FC00C0E160215022482444284420402040580087FE00007B
+:20ED800010041004100413C4FC7E12843A8435245594514492441404180410041014100861
+:20EDA00001000100FFFE01003FF8210821083FF82308058005400930310EC104010001005F
+:20EDC00000A0009000903FFE20802080304828482450222020602092430A4C068002000005
+:20EDE000040025FC2488245024602490270E050400803FFC08100420042000407FFE000080
+:20EE000000003E7C2A283E102AFE3E1208143E1008507E2001003FFC010001007FFE000005
+:20EE2000010000803FFE2220222022203FFE2220222023E0222020002A4849265124800052
+:20EE4000082049302A201C20FF7E1C442B4448C40828FF28121034100C28324EC08400007E
+:20EE6000422022202FA0023E8FA45AD41A902A902F902210C7104AA8522842444246428412
+:20EE800010001000FEFC248424846884188414FC2200C000090828842896681447F0000060
+:20EEA0003F822082209220923F92221222125FD25252525252525252524293C2028A020416
+:20EEC0007FFE030004003FFC22442244225C22080400FFFE0810062001C00630180C600441
+:20EEE0002080204027FEF840249222E42A4834A4E9F2205020402FFE20402040A0404040B7
+:20EF000001007FFE00000FF008107FFE08100FF0010002880C503820C8180A0E0C04080079
+:20EF200000003FF8210821083FF8210821083FF8210821082108212A4112410280FE0000AE
+:20EF40000820082008204BFE4A224A224A224A224A224A224A22122E122420204020802046
+:20EF60001040104010A010A0FD10120E39F83440504051F8904010401040104017FE100001
+:20EF80002040204020A02110FA0E20042BF830402040E3F8204020402040AFFE40000000B9
+:20EFA0001FF801007FFE41041D7001001D70080008F87E881CF82A8828F8488808F8088808
+:20EFC00000007EFC0284028442842448144808480C50162013202250408881060204000041
+:20EFE00001000100FFFE05082950112029504540292812902AA8444008201018200E400452
+:20F0000041402130312023FE0220E6202BFC2220222023FC22202A20322023FE02000000B9
+:20F0200001000100010801107D2005C005400920092011101118210EC10401000500020075
+:20F04000003CF7C09040904097FEF248924897FEF2489248924897FEF040904087FC0000D9
+:20F060000C08710810901020FDF811083908350851F850A090A010A0112011221222141EC4
+:20F0800000400060F88089088A7C8FC488008920F92089208120022002220422081E100038
+:20F0A000003C77C45244512857FE740A5A0853BE728854A85B3E514872085408480810081E
+:20F0C000000045FE5420544055FC55045504552455245524552454204450848C05040000DD
+:20F0E00000383FD0121809203FFE200450201EFC222022A055FE882010202020402080201C
+:20F1000042082188311023F80208E208220823F822A820A020A0292031222222041E080013
+:20F1200000007DFE1020104021FC21043D246524A524252425243D502448208401060602A1
+:20F140002100113E12227FA2083E29222922293E3F220822084210421082208A41040000FF
+:20F160001008103C13C016205A20522053FE9020102018A825A425224222442080A000400D
+:20F18000220C2270FF4022403E40227E22483E4822482248FF480048248862888308000874
+:20F1A000248024862FF8F4A027A024BE2FA434A464A4AFE4212424A424A42844A04440846E
+:20F1C0000480048EFFF894A097A094BE94A497A4F4A49FE4952404A408A4102420440084AE
+:20F1E00000001FF8110811081FF8110811081FF800000100088848844816C81207F00000DA
+:20F2000002207F3008200820FF40184018402C802A804A88490489040BFE090208020800B6
+:20F2200000003FFC000400047FE4000400043FC4204420443FC420442004001400080000AE
+:20F24000000008200C3018201068224C7EF82450082010403EFC000000000004FFFE00008F
+:20F2600000007FFE084008401F401146215832604A408A400440044208423042C03E000028
+:20F2800000203E2021FC3C2421FE20243DFC2020FE2021FC282027FE5E20E42040200020ED
+:20F2A000010001003FF801000100FFFE002000207FFE0020082004200620042000A00040C3
+:20F2C00000007F7C410441747F0400047F74555455547F5455745554550455044314000817
+:20F2E00000007FFC4484448444844484448444844884487C5004600440047FFC4004000098
+:20F3000008000FFC0804100417F4300433E452249224122413E41224100410141008000085
+:20F320001108188810C82488340824086408A4082448248825142614242220C22302000038
+:20F34000100011FC20043E0444F4480480F41094109410F410041004140418141008000062
+:20F3600000003FF020102010201020103FF020102000200020002004200420061FFC000056
+:20F380001010109010D0FE901088110839043646546450C090801108120417FE1004100095
+:20F3A00008400840084014A022904308BFF808200FE008200FE00820083EFFE00020002052
+:20F3C0000840084008400840144012A02290C10E0200010048884884C816881207F0000078
+:20F3E00010002BFE2420244041FC510491241124212429244524FC50044800860302000092
+:20F4000042202120214007F800800080EFFC20802140212022102410200050008FFE000059
+:20F42000020001007FFE4104810801007FFC03800580054009201110210E410401000000F6
+:20F44000402020A030A020900110E1082208248620842080210021102A0837FC200800001B
+:20F46000400023FC3048203003FE0222F22213FE1222122213FE122216221A22122A0204B8
+:20F48000102010A0132EFE2213AE16221BFE102031FCD0841088105010201058518E2604CF
+:20F4A00010A0212C3D2425AC35242D2425FCFC0025FC34882C88245024204458548E890402
+:20F4C000211021182550FB9027DE23A4356429546214AFC82488230823142494A8264044DB
+:20F4E00002100210EFD0A23EAFA2AAD4AA90AF90EA10A7108AA80AA8122422460244028006
+:20F5000004400440FFFE0440054001003FF00110131012143612241208101090606000005D
+:20F52000001CFEE028202820FE20ABFEAA20AA60CE7082A882A8FF268224FE208220002069
+:20F5400011201918124C3448284060A0A118220E24042BF822082208220823F82208000010
+:20F5600001007FFC01003FF80100FFFE020004401F8004103FF801080920111065080200E7
+:20F58000008040802FFC2080008007F8E488248827F821A022982C88208050808FFE00007E
+:20F5A00000007FFC04403FF8244824483FF811100920FFFE038005400930310EC1040100F9
+:20F5C00010001FFE10A027FC34A464A4A7FC224821502FFE20E02150224C2446284420408B
+:20F5E0000000427C2444FF7C08444A444A7C7E441294108821007FF801000100FFFE000033
+:20F600004880249E21120FD28112511E55522552255E27D2C112411242224222444A488468
+:20F62000020001003FFE48044FF80840108013F83208520893F81208120813F8120800009C
+:20F640004000201C31E02100010001FEE11021502130211821162914321022100410000014
+:20F66000010001003FF80108FFFE01083FF801002108254825282528292849085108810856
+:20F680000020FF20284428FEFE02AA88AA84AB42CE7C8288FF488230FE3082488186000000
+:20F6A00008400840FFFE084000007EFC0000FEFE08104C986AD44A9689148A102850102006
+:20F6C00040407E7E4890BFF820103FF020103FF020103FF00840FFFE084010401040204075
+:20F6E0001FF0101010101FF0111001003FF8210821083FF821000108010401FE7F04000019
+:20F70000008078804BFC510063F8544053FE480049F8490869F8510841F8410841284110C9
+:20F720000020F82095FE9440A0F8C188AC8894F8948894F8D488A4A884908B0090FE80008C
+:20F74000003C13E01004224649A4F928104027FE4088F108031000A01860E090030C0C0400
+:20F760000020782049FE684068FCFD108AFE7900487C7B54496C7954494C4B445CFE0000DD
+:20F780000080FC4017FC1110211021103AA86C44A80028402FFE2840384028402040004060
+:20F7A00001002108210821083FF8040004000FF81010241042200240018006001800600090
+:20F7C0000C4073FC104013F8FE4813F832483BF8544453FE900011441522150A18F81000D1
+:20F7E0000420422021402FFC01000290ECA023402CE021582E482040214050808FFE00005C
+:20F800000084F84895FE9420A040A1A49C5894909738D456A590845084208B0090FE800061
+:20F82000010011081FF80100210421043FFC00003FF80000FFFE01000D203118C508020097
+:20F8400000207E2004200820102011281DA431245222922214221020102050A02040000011
+:20F8600011FC11041104FDFC100015FE19023122D1221122112211421050108851062202A8
+:20F88000204020403E7E50A089103FF802087FFE020802083FF80200040004000800300018
+:20F8A00004207FFE052000807FFC00000FF00810FFFE08100FF004400C201510660E04044B
+:20F8C00010201040108811FCFC0411083904324254F850889150122010501188160E1004D1
+:20F8E00001000110F20897FC91089190920C948499F8F11092908C9000600090010E060420
+:20F900001040182033FE22044400F97C1110227C4644FA44027C02443A44E27C02440000E2
+:20F9200000207D2410A410A811FC7D0411241124112411241D64615400880104060618024F
+:20F9400001003FF8010001007FFC420804801FC003000C201FF0011011201110251002006D
+:20F96000102012223D2420A841FC7D0491041124FD24112411241144145018881306000075
+:20F980000E1E70E0408040807C8044FE448844887C88408841084108420842088408080807
+:20F9A000200021FC210421FCFD0421FC200027BE20A22492228A3A92C4A20882028A010434
+:20F9C0001040184012401244225E72E4AF44224422442254224822422242220223FE000055
+:20F9E000020001003FFE2004400808000820087009800E00080008080808080C07F80000E1
+:20FA0000002020A020A020A4FCBE27E424A444A444A448B428A810A028824682847E000035
+:20FA20002110211027FE2110FD5020A02110220827FE280023F83A08C20803F8020800002D
+:20FA40000A108A1057DE22246FC89ABE1AA23FAA52AA972A1AAA12AA12142222A2424280F6
+:20FA6000101012101110FD1010FE1410181017103118D1241126114213001480507E200038
+:20FA80007DFC450445FC45047DFC5504100013DE5C42514A50C6514A5E52E042014A0084BC
+:20FAA00000207C2447E6446844B07CA8112612645DFC5104510451FC5D04F10401FC000045
+:20FAC00000403C60244024883D0427FE250424003DFC250425042504250445FC5504880088
+:20FAE000044004407FFE044002000410080810FC3F8800001FF01010101010101FF0101026
+:20FB00001040106010401080FC8811041BFE10003000D1FC110411041104110451FC2000C5
+:20FB20000100018002000410080811FC3F0800001FF010101010101010101FF0101000000B
+:20FB400002007FFC02003FF80200FFFE044009201118292EC74405C019206118050002007A
+:20FB60000020FF2028202820FEFEAA20AA20AA20CE508250FE5082C882A8FF2682040000FF
+:20FB800001000100010001007FFE0100010001000280024004200510089810CC208640047E
+:20FBA000010001007FFC0100028002400520089830060100048824842412641243F00000F4
+:20FBC00020801080108000808FFE40805080108021402120C22043104488488E500400006B
+:20FBE000100011FC11041144FD341124110417FE110413041D04F104420402040414080838
+:20FC0000205020682740F97E25C825482A7E32486548A57E294830482048207EA040404073
+:20FC20000100028004400A30310ECFE400401FF01010111011101110129004600830301081
+:20FC4000010000803FFE20A0AE9062FC239032906AFCA4902C902AFC5290609040FE808089
+:20FC6000405020482F4001FE92904B9056FC149026902A90CAFC50906090409040FE408057
+:20FC8000000011FC100010001000FC0013FE1040106010801C883104C27E07C602040000DE
+:20FCA000204027FE200023FCFA0422F472946BFCA000A1F8210821F8210821F8200027FEFD
+:20FCC000010000801FFE9088549054C0153032085C80949014A02940212042108C0E300479
+:20FCE00047FC20A027FC04A487FC48000BF8120813F8120823F8E04027FE204020402040A9
+:20FD000007FC40A037FC24A407FCE00023F8220823F8220823F8284037FE20400040004000
+:20FD200040402048324C225004A00110E20C244021482148225020A028903108220E0404B7
+:20FD4000000011F8110811081108FDF811081108110811081DF83108E00040000FFE00007B
+:20FD600000400C407158116010501C88734810401D48F17010601090130A10020FFE00009C
+:20FD8000200019FC1104FD04050409FC13043504590495FC15041000100017FE100010005E
+:20FDA0000040FA44224423FC220421003FFE69206924A9A82A503A5024902908120E240424
+:20FDC000100013FE1204FD10110C1244184017FE30C0D16011501248144E1044504020407D
+:20FDE0000000FFFC8A088A088A088910891088A088A0F84080A0813002180C0E300400005F
+:20FE00000100210821083FF80800FFFE08800888108814901540294022204418980E2004D9
+:20FE2000200013F8101000208840488051FC10942094E12426242044208423042C1420083C
+:20FE40000080204027FE2440FDF8244827FE244825F8244025F83D08C50809F8110800007D
+:20FE60001040102013FE1220FFFC12241BFE122433FCD22013FC15041504190451FC21044E
+:20FE8000010011100D1809243FFE20044FE8082008200FE001003FFC010001007FFE00005C
+:20FEA0000100092005407FFC40080FE008200FE001007FFC038005400930310EC104010088
+:20FEC0000020792448A84BFE7A044DF84908490879F84820482049FC48204820ABFE900038
+:20FEE000010000803FFC20802FF020903FFC20902FF020802FF0281048104FF088100000A7
+:20FF00001040102093FE56205BFCFE2433FE3A2457FC5220522093FC1504150419FC110430
+:20FF200010401848124C1148215027FC6404A5F425142514251425F4250424142408000074
+:20FF4000104020487A4C495078404BFC7A044AF4FA940A941A942AF44A948A042A14120813
+:20FF6000204010401248014889504FFC5404140425E42524E52425E4240424042414240882
+:20FF800010401248114C7D50104013F8FE0812E852A85EA852E852085228BA1087FE0000D5
+:20FFA00023F8103088C04BFE5094112462442194270801301140128024400830301EC004F0
+:20FFC0001080108011FE1102FA8211F21242184237FAD042124A13FA120A1002500A20045A
+:20FFE0004080208027FC008097FC51005FFE2210221025FEC41048904850501040504020A2
+:020000040002F8
+:20000000403E27C0204202229124500010C0231E22022202C3DE42024202420243FE4202A5
+:200020002080308021F821104AA04840F1B0264E4040FBFC004001483A44C4440940008050
+:200040000420FFFE042014201FFC28044FE4890411047FF40104111411141FF4001400081A
+:2000600020A020A020A0F8A622A471A868A0A0B0A1A826AC20A42120212222222C1E00007A
+:20008000014041402948255005600140E3602550294822442244243C200050008FFE0000C0
+:2000A0002100110013FC0204850453F45484108427F42084E494249427F420042014200833
+:2000C000010079004BFC4A04550461F452444BFC48446954515441F440044004401440083F
+:2000E000400820083008200807FE0008F0081108108810C81088100814081848102800102E
+:20010000020002007FFE04400FE03818CFEE08040FE00800FFFE0400082011F03F1800108A
+:200120001040104053FC50407C4097FE10101C1033FED01011101090109010101050102081
+:2001400004400440FFFE04407A4849504BFC78804BFC49107A4C4D4448D049488A4898C072
+:2001600004487B4C4A504FFC78804FFE49104BEC7D26492449F848084BE84808A82890101E
+:20018000010000841FFE910053F8551018A010C033305C8EA0642020210040C04060802002
+:2001A000111009203FFC0200FFFE052008903FEEC0040FE000000FE000001FF010101FF0F1
+:2001C0001108109010A0FBFC1044384437FC5240524093FE10C21142124A1444104010408E
+:2001E00000043F0421243F2421243F2420243FA44AA492A414A42484C884109463880100E1
+:2002000000007DFC450445FC45047D0411FC11005DFE52525492512252425882E31400082E
+:20022000208420483DFC202440247DFC91201120FDFE106210A210A2152A1A2410200020D8
+:20024000100011F81108FDF8110811F8180037FC50409240127C1240164015C0587E2000A7
+:2002600000003DFE24203C4024FC3C8400A4FEA408A428A42E30284858844C0083FE00006E
+:2002800000407C2047FE450844907FFE122212245DFC5124512451245D34E12800200020A3
+:2002A00000800044F7FE9108909097FE9444984893F8F248924882480268025000400040DA
+:2002C000104018401040204037FC60C0A0E0216021502248244E2BF42040204020400000E6
+:2002E000081008103E7C08107EFE083014482286DFF410101FF0101010101FF010100000D3
+:20030000004007FCF04097FE900493F8924893F8924897FEF04492780240054008C0103E07
+:20032000200023F8220833F8AA08ABF8A100210023FE2C922112262220422182260A200463
+:2003400022101110112007FC8044504417FC2440244027FEC0C241424642584A404440408B
+:20036000210212027F82049204927F92449244127FD20C52145225C244828402040A04047E
+:2003800000003FF8200820083FF8291029103FFE29102910291029F048004FFC8800000011
+:2003A00000003FFC01000100010001007FFE010001000280024004200818100E20044000F5
+:2003C000200017F8108000808FFE414051201218248E3884E08024C824A428A42280210024
+:2003E0002040204027FE2040FBF8220823F8220823F822083BF8E2080FFE0110020C0404C0
+:20040000000000003FF821082108210821083FF821082108210821083FF82008200800009F
+:200420000E88F0881088108811FEFE88108810887CF844884488448844887CF844880000D5
+:200440002000207C27C03040A840A7FEA0402040204023F8220822082208220823F800007E
+:200460000C00F3FC10401040FFFE10901088114E7E4445684554455246527D404480000095
+:2004800000A078A04BF84AA87AA84AA84BF87AA84AA84FFE4800492049904908AA08940096
+:2004A00010A010A010A0FCA010AC12B015A018B031A8D2AC1D24112012221222541E2000D2
+:2004C000040004000FF00C201240618002600D1E71081FFC01000920111821080500020012
+:2004E000400027FC3084208401040238741013F812081208120813F8120810002FFE400083
+:2005000000A078A048A44CA44AA87AB048A049B07AA84CA448A0492079224A22421E04007C
+:2005200000A078A048A04CA44AAE79B010A051A05EB054A850A451205D24E226043C080029
+:2005400000207C2044204420443E54205420542055FC550455041104290425FC450480000A
+:200560001020102021203D2041FC7920922013FEFC201020105012501488190E16040000F9
+:200580001040104010407C40547C54405440544055F855085D081108110811F811081000B0
+:2005A00000003FFE2000200020002FFC204020402040204020402040404041408080000032
+:2005C000000C79F049004900490049FE49104910791049104210021004100410081010003C
+:2005E000100013FC100814105420585851869602100029FC24202420402047FE800000002B
+:200600002000100017FE0020802048201020102020202020E02020202020202020A00040CD
+:200620000000F83C0BE01020102020207FFE0820482048202BFC10002800460081FE000062
+:2006400008400C200BFE100011F8310851F8900017FE140211FC10201020102010A010402A
+:2006600001007FFC00001FF010101FF000047FFE40049FF8008000800080048002800100DD
+:20068000010000803FFE20002E1C22E0222024FC28202420242035FE4C004A0091FE200086
+:2006A0001000100E1770FD10111012101A7E3790D09019101510127C13001480587E2000FD
+:2006C0000800130C3D70251035102D1027FEFC90249034902EBC250024804540553E8A0011
+:2006E000400027F82090006007F80448E7F82448244827F824482468245050008FFE000021
+:20070000200023FC2204FAF4220472046AF46A94A294A29422F4220422042204221422083A
+:200720000000FEFE28822882FEFEAA82AABAAAAACEAA82AAFEBA82828282FE82828A008415
+:200740000040F7FC911090A09FFEF00093F89248F3F8924893F89040F7FC90400FFE0000B3
+:2007600000007FFC400440045FF4400440044FE44824482448244FE44824400440144008A5
+:20078000200021FE3D02210241FA7D02A17A214AFD4A214A217A210225022902310A210456
+:2007A00000003F10211831302D442586210C7F98212021442106210C411845208240000076
+:2007C000020001003FF80820FFFE00001FF011101FF011101FF001003FF80100FFFE000015
+:2007E000100011FC1048FC3013FE3A22362253FE5222922213FE122212221222122A1224FB
+:20080000100011FE1044FC2811FE1122152219FE3122D12211FE112211221122512A212403
+:2008200020403E7E28A04510BFFC200420042FF4200427E42424242427E42004201420080F
+:200840001040102023FE20404440F888090413FE20947C90009000901D12E112020E04005F
+:20086000010000801FFE100097F8501058A017FC344457FC944427FC244424444454840816
+:20088000108018801160221835EE6804A78824A824A827A824A827A8248826A82510000016
+:2008A000100011F011101110FD101212100E180013F83110D09010A0104010B0530E2C0481
+:2008C000008010800C80048010800C8008800080FFFE00800140022004300818100C20085C
+:2008E0000078478020802FFC01E00290EFEC22402278240824082828201050008FFC0000F1
+:2009000007E0042004200420042004203C7C2424200420042004200420043FFC2004000029
+:2009200000F87F00010001047FFE03400520091C110827C004400440084008421042603E26
+:20094000020001007FFE424404200918314801207FFE01000280024004200818300EC0042A
+:2009600000007FFC440447E444444A84710442C44C3C711440844204418441047FFC4004D8
+:2009800010401840204053F89840104027FC6000A0402040227822402240254028FE300000
+:2009A000008040C0212022100DEC0040E04027F82040215022482C48214050808FFE00005F
+:2009C0004040204020A08110420855F61040204027FCC04042504248444C48444140408005
+:2009E0003FFC20043FFC2080208827F020A03FFE23002FF8340827F84408440887F8040839
+:200A0000000001000100010001087FFC0100010001000100010001000104FFFE0000000047
+:200A20000040004000407C40444047FC444044404440444044407C40444047FE000000005A
+:200A4000040007F0082010403FF85108910811081FF802A0029004980492088210FE2000AC
+:200A60004040224422440A448BFC500057FE108027FC24A4E4A424A424A424A424B4240851
+:200A800000007FFC408440845FF44184418442844484488450846084428441047FFC40049A
+:200AA000112011901110FDFE1310151011FE19103110D11011FE11101110111051FE2100C4
+:200AC00000001DFEF0201040FEFC388454A490A43CA424A424A42430464844868302000018
+:200AE00000007CF84A884AF8788848884EF84AA27A944A984AA84BCC4A884A00ADFE90001C
+:200B00001208118C10907DF855085508550855087DF85090189014901E92E512010E02003C
+:200B2000400034782248FB780A48104828787652B2542A482254226222402580287E20009B
+:200B4000400027F0241007F004100410E7F024882450242025102618240850008FFE000034
+:200B600000003FF802000200FFFE048008401020201C5FF89010101010101FF0101000009F
+:200B8000020002000200FFF8020022102210221022103FF0221002040204020601FC00001C
+:200BA0003F7821483F482A863F7C2A485F308A4811861FF010101FF010101FF010101030EC
+:200BC0001080108011FEFD0012201424113C19E43724D124113411281122110250FE2000B3
+:200BE0002000203C23C0F84020402040284037FEE04020402040204020422042A03E4000DF
+:200C000001083CCC249025FC3D042504250425FC3C5024502450445044925492890E0200DD
+:200C2000084010207C2065FE550445085440484C7E7002401A40E24002420A42043E0000F1
+:200C400000407820482053FE620450804880489848E068805080408440844084407C4000FD
+:200C60000040F840084048404BFC484048407C40044034A0C4A0051005102A0E1404000023
+:200C80000040F82008204BFE4A044A8848807C80049804E03480C48004822482187E00006D
+:200CA0002010279024FEFD102520763C6D64A4BCA4A424A426BC252424242424242C242493
+:200CC000001001F83E20123009A009400400FFFE042008201840068001C00630180C6004CF
+:200CE000100013FE1040FE4010401480188010FC3184D18412841484108410FC50842000F1
+:200D00000000003CF7C0904097FC9250925097FC9250F25092500FFE0040004007FC000090
+:200D2000108010601020FFFE12041090190C120431F0D020104010821102110250FE20000E
+:200D400000400040F04097FC904090409FFE90409040F04097FC8040004000401FFE000053
+:200D60001000102010207DFC5420542057FE54007C20502015FC1E20F420402003FE000029
+:200D800020401040104007FC804048404FFE104010402040E7FC2040204020402FFE20006B
+:200DA00010401840104011FCFC4024402BFE28002840284013FC10402840484087FE000099
+:200DC0000000FFFE0800080008000FE008200C200A200B200920104212421442183E1000DB
+:200DE000204010401040FFFE0440084017FC304054E098E01550124814461044104010402E
+:200E000000007FFC008003600D18710601027FFC0100010011F8110011001100FFFE00001F
+:200E2000082008200F2011201120213052288A240C2204220820102020204020802000204C
+:200E40000040FC2003FE02047900493C49A47AA402A48DB448A851203D22E222041E080051
+:200E60000100FFFE024012501A4C22447FF800081FF8100010001FFC0004000400280010F3
+:200E80002080104017FE08A08AA454A253F8100823F82200E3FC200420042004201420083A
+:200EA0000000F9F820002000200023FEF8902090209020903910C11002120412080E1000BE
+:200EC00000007DFE00200040FEFC288428A428A428A428A42AA44C3048488086030200007C
+:200EE00002000200020002207FF0022002200A20062002200520052408243026C01C0000F9
+:200F00001040102013FE1202140459F05000900017FC29202520252042228422081E1000C5
+:200F2000020001003FFE200440081FF000007FFC044004400440084008441044203C40002B
+:200F40000040FC2013FE12022504210039FC6A64AD6428A428B4292839202A222422081EA8
+:200F60001080108011F8FD1013FC124416441A4433FCD06010A010A011221122521E240065
+:200F80000080008079F84A104C204BFC7A444A444BFC4A4048A078A001220622381E000015
+:200FA0002040302043FEFA028C0489F88800F8008FFE89208920F92089228222041E080042
+:200FC0002080204027FE3404AA00A200A3BC24A424A42AB422A8212021222222241E2000A7
+:200FE000010000803FFE200448080E781248124832484A488478045008441044207C4000AD
+:201000002040302023FE2202FD04490049BC4AA454A42AA412AC2D2029224222841E080074
+:2010200000007FFE02000200021003F8021004100410041008100810101020E04040000004
+:20104000004078204BFE4A047C08490049DC49547A544D54489C4890491249126A1E940095
+:20106000200017FE1040004088404840504013FC2040E0402040204020402FFE20000000CF
+:2010800000087FFC010001000100010001083FFC01000100010001000104FFFE000000007F
+:2010A0000200010000800004FFFE100010001000100010001000100010003FFC10000000E1
+:2010C000100013FE1020FC2010203020382055FC54209020102010201020102013FE100075
+:2010E00000007FFC4004410451144A9C445444244A244A54519461044004401C4008000063
+:2011000010801860104027FE504098401040304053FC9040104010401040104017FE1000A6
+:20112000000003FC7C404440444044407C4045FC4440444044407C400040004007FE00009E
+:20114000100008FCFE8420FC208424FC2884311C00003FFC01001FF8010001007FFE00004E
+:2011600001000080FFFE10001000100010001FFC00000900288828842816481447F0000060
+:2011800002000100FFFE100010001FF802000200FFFE042008200E4001800660181C6008FA
+:2011A0000040005000483FFC20403F48284C28483F502930292026202552488A53048000BA
+:2011C000010021043FFC00807DFC1124FFFC3924552421FCFC544854305E2892449E8500F7
+:2011E000221032182A904AA0AFBE30642FA46024A7A424942494248824D428A43046208432
+:20120000040007F0082010403FFE5000900013F012101210125022242204420681FC000064
+:20122000010001007FFC010001003FF8010001007FFC01040104010401140108010001004C
+:201240004040204037FC204003F80040F04017FC10441044105410481040284047FE8000BC
+:20126000208020F82110FA2027FE72006BF86A88A288A2A82290248024822882307E200097
+:201280007FFC420442045FF442044FE442045FE442244224422442A4424440047FFC400451
+:2012A000010001A0F11093FE9310951095FE99109110F1FE91100110011001FE0100000023
+:2012C00021402120212033FEAA20A620ABFC2220222023FC22202220222023FE2200000017
+:2012E000008010800C8004847FFE0104010401840144022402240404084410282010000071
+:20130000400024502448087E9ED06550247C28505E50407CC05043505C50407E40400000F5
+:20132000210031A0211043FE4B10F51011FE21104110F9FE011001101910E1FE0100010035
+:2013400008400840FFFE084001007FFC01003FF8010001007FFC010401040114010800005F
+:2013600004400440FFFE04403FF001007FFC0560091C1508FFFE04200C4003800C70700C6A
+:2013800001F81F0001007FFE03400520191C61080400FFFE08200C4003800C603038C01015
+:2013A00008400C40084017FC104033FC3040504097FC1044104410441044105410481040D0
+:2013C00008400C400A401140114027FC3044508490A4109411141104120414281810000096
+:2013E00000003FF820083FF8200020F82F00210021F82F0021FC3F002104410440FC800005
+:201400001040104023FE24404440FBFC1040204043FEF84200420C42F04A40440040004033
+:201420000100010001003FF801000100FFFE03000380054005200918310EC104010001005C
+:2014400004400440FFFE04403F48210821083FFE20083E4820285F284408550864A88C10DF
+:20146000004008407C484BFC4840484048444FFE484048E049507A50444E0844004000407F
+:201480001FF0111011101FF0111011101FF00000FFFE1200111010A010401030161E1804DB
+:2014A00000003FF821083FF821083FF820081FF010101FF010101FF01010101010501020D0
+:2014C000000003F8F24893F8924893F890009FFE9288F28C925802200298070E0204000061
+:2014E0000C20704011FCFF24392455FC912411FC2050FC54285A489E30902912C21E00006D
+:2015000009000CC0104017FC2000341052185210911011201120102010401FFE10000000B3
+:20152000200017FC144487FC444457FC100013F8220823F8E20823F822082208222822108D
+:20154000400023FE322223FE022203FE700011FC110411FC110411FC15041904111401086B
+:2015600000087F0841087F0840FE7F08400840487FA844285508548864888408942808105F
+:201580007F0841087F08407E5E0840487F285608A5089428081001002888282447E400009A
+:2015A00000003FF80108010801080108010801080108013801100100010001007FFE0000EB
+:2015C000010000801FFC100093F0521053F0121033F0500097FC2524252425245FFE800057
+:2015E000400027F0241007F09410541017F020002FFCC92449244924492449245FFE4000D1
+:201600001040103010247FFE55085508548854907C501020142012501F58E28E010402008F
+:20162000020001000100FFFE082008200820044004400280010002800460181EE008000022
+:2016400010000BFC400440045FF4444447C4444447C4444444F45F4440444044405440082B
+:2016600020803060204047FE4810F1101110211040A0F8A0004000401CA0E118020E040425
+:2016800001000180790049FE4A524A524C924892492279224242044200820104061400089F
+:2016A0000C8070F011101220FDFC100431FC380455FC504091281524150A150A10F810004C
+:2016C00001007FFC0820044003800C7EF30404601F8004201FF80108092011186508020016
+:2016E00010000BFC08042004200427E424242424242427E4200420042004200420142008A5
+:20170000012001A0F110928895169BF8911097BC9084F2A49194028C0C9400A4029401087A
+:20172000084008201230221C44480FE000207DF8040824481428144824884408142808104D
+:201740000000048008401230648ECFC40020FFFE08000FE008200A20112015A218A2101EC0
+:20176000200824082208FAFE200820082E8832486248A2082208222822102580A87E40006E
+:20178000100011F8110811087DF85548544057FC7E44524412A413141E04E20402140208A8
+:2017A000200013F8120802088BF84840504017FC24442444E4A427142404240424142408E5
+:2017C000020001007FFE442218182FE4082008200FE001003FFC21042284244420142008D6
+:2017E00006403850084808480840FFFE084008480E283830C82008500992080A28061002D3
+:2018000010201020FE5010487E8643147E5042307E901050101EFEF010101010101010101D
+:2018200000407F404840484048407F604150414C7F4648424840484048407F40004000002E
+:20184000200023FC2204FBFC220023FE2A40328863FCA224222023FC24202420ABFE4000CE
+:201860002000107817800080808040804FFE108010802140E12022202210240C2808000046
+:2018800000007FFC010011101910111011102910292845244546818401000100FFFE0000BE
+:2018A00000800100FBF88A088A088A088A388A10FBFC8A0480040FF4000400040014000872
+:2018C000204020803DF8210841087D08A1282110FDFC2004200423F42004280430142008CE
+:2018E000010012201FF010201020102010A010401FFC000400047FF400040024001400083C
+:20190000200013FC1000000080004BFE4880108010FC2004E004200420042004201420088B
+:20192000400027FC3040224802480248E2482254255629642040284030402FFE00000000C9
+:2019400000003FFC20043FFC20003FFC222024102FF8209020803FFC40804080BFFE00002D
+:2019600000003FFC01000100010001007FFE0180028002800480088010822082C07E0000A8
+:2019800004400440FFFE044000003FF8020002007FFC02800480048408841086207C40003C
+:2019A000100013FC10401040FBF81088388837FE540051F8910811081108110811F8110845
+:2019C0007FF8020002003FF0041004100410FFFC00001FF01010101010101FF01010101068
+:2019E00000001FF01010101010101FF000003FF801000100FFFE028004400830301CC00821
+:201A000000001FF01110111011101110FFFE2110211022103FFE0210041008503020000097
+:201A2000004000503F480040FFFE00400440042027A02420242024102712380AE0060002C4
+:201A400000007FF8020002000200020002203FF004200420042004200424FFFE0000000001
+:201A6000100013FC10401040FDF8108814881BFE3000D00011F811081108110851F82000A8
+:201A8000080008001FF81100210021004104FFFE0100010001000100010001000100000083
+:201AA00010001FFC2A504A50BFFE0A507FFE101010103EFE2250549008FE101020104010DB
+:201AC0001000180813FC308020806080A08827FC2108210821082108210821082FFE200009
+:201AE00012001A0013FE34002BF86288A24822482FFE22882248224823FE200820282010A8
+:201B00000020104011FC11041104FD04111C110811FE10021C0233FAC0020002001400088B
+:201B200000800090008800803FFE20802088208820502060206020A023124C0A40068002DD
+:201B40001FF801007FFE41045D7001001D7008000FE0144023800D60711C0FE002200460F3
+:201B6000000007FCF88088808BF08910F9108FFE88008800FBF88A080208020803F8000094
+:201B800010801080508051FC7D5452549494149419243224D444108411041204142800100B
+:201BA00008000C0008000FFC1124112422244244844408841104220404040844302800107D
+:201BC000040007F00C101420624081800660191E61041FF002100210041008103050C02056
+:201BE000200027FC20803080ABF0A110A1102FFE200023F8220822082208220823F820000A
+:201C000043F822083208220803F80000E7FC2040204027FE204028A03110220C040608048B
+:201C20000420042004203FFC042004207FFE00000FF0081008100FF0081008100FF00810C3
+:201C400000007F7C444444445E7C52445E40444244427F3E4000288824446666C22200009A
+:201C60001000103C11C0FD00110031FE39105510551091101110111012101210141010107C
+:201C80000000FFFE044004407FFC4444444444444444483C5004600440047FFC40040000E5
+:201CA0000000FBFE2050205023FE22527A526A52AA522A922A8E2B023A022BFE2202000008
+:201CC0000040FE601040107E108420843D046688A4482450241024203C4025802E000000FA
+:201CE0000200020CF27092409FC0927EF34896C896489A489248F24892880288030802080B
+:201D0000004007FEF04093FC900093FC920493FC9108F0909FFE800003FC020403FC02043B
+:201D2000000007F0F11091109110929892889288F29094508420083008D8130E2C04000098
+:201D400021FC21043D0421FC41047DFC90801080FDFE114A124A1092132214C21B0A1004ED
+:201D6000100017FE509050907C9053FE56929A923292D292128E1302120213FE12021000E7
+:201D80000C88705010201050FEA813FE3880352053FC5524992411241124113411281020FE
+:201DA000010002001FF010101FF010101FF010101FF00000090028842892681207F00000A4
+:201DC0000820064001800E603210FFFE048008801FF8288848888888088808B80090008054
+:201DE00000F01F00092005407FFE038005401920611C0108000029082884681407F0000012
+:201E0000784048404BFE48D0794C4A444C4048A079584E46495448E049504A4CAC4490C0C1
+:201E20000200020003F8040804080C101210212000A000400080010002000C00700000002D
+:201E400021102110211037FCA910A110AFFE200023F82208220823F82208220823F800008C
+:201E60001020104011FC150459FC510451FC910421FC30802D482D26450A490880F8000083
+:201E800022082198206028902B4837FEA080A14023F836482A484A484268425080400040A5
+:201EA00040782F80248802508080512013C0211027F82048CFFE404040A043104C0E4004A3
+:201EC000204010401040007E848248844984124810282010E0202040208023002C000000D4
+:201EE00000003FFC20043FFC2888249020802490380C248027F828805FFE40804080808004
+:201F0000221027902490279EFCA427A472646114AFD4A21423882488249428A432C6210478
+:201F2000024002207FFC049004E4098436F8C1007FFE030804B01840E8300A0E0C040800EE
+:201F4000010000803FFE222022203FFC222023E020802FF82888288828A848904080808030
+:201F600000003FFC000408040404030401140064018406043804100400040024001400086B
+:201F80002060204021FC2104FDFC250429FC290449FC684010242AA22A8A42888478000044
+:201FA00001007FFC01003FF800001FF010101FF00440FFFE00001FF0101010101FF0000090
+:201FC000202021203D2021FC41207A20A02023FEFC9020902090211229123212240E00005A
+:201FE00040402240224007F89440584050401FFE21202120E120222022222422281E2000D0
+:20200000007C3F800220042008401F8003200C103FF8108C04A00890108820844284010007
+:2020200000207D2845244A24502063FC52044BFC4A046BFC502040204228422444A44040DB
+:20204000004000507E480248444025FE184008440C281430122022504192060A000600028E
+:202060001000180021FC4524F9240924112421FC7D24012401241D24E1FC01040000000008
+:202080000080F04097FE94429BFCF04093F89040F7FE904093F89208F208920883F8020800
+:2020A000100013FE102010207C2054305428542C7C265024142012201F20E2200020002086
+:2020C00000007FFE40004FF8488848884FF8488848884FF840804080408040807FFE0000B1
+:2020E0001FF00100FFFE89142548112000007DF844087DF840007DF840907C6040B0470EBC
+:2021000010401020FDFE222451FC502090FCFC2013FE10203DFCD104110411FC1104100003
+:20212000000007BEF482948297BE9400F40097BE942294229794F4149408041804660584D2
+:202140002040204023FCA840AA48A94CA948A950AFFEA840B8A0E8A08110020E04040800C1
+:2021600008400C40084017FC1048344C534892501FFE10A010A011101118120E140400001C
+:202180000840884057FC2040504094480A5019602FFE48A088A0091009101208540E280426
+:2021A00000047FFE01000100010001C0016001300120010001000100010001000100000021
+:2021C0003FFC20003FF822002FF028102FF028102FF0240027F02A2042404180867C18108C
+:2021E0007FFE02001FF010101FF010101FF010101FF008000FF00820164021800E70700EA2
+:2022000000007FFE44404440444044604450444C44487C4044400040004000400040000021
+:20222000200021A026302420FC3E27D22D5435106510A5282528252829442986A10441004C
+:202240002090271024107C20443E87D2FD542510FD102510252825282544354629840000F9
+:202260000100110011001FF81100210021007FFC044004400440084008421042203E400008
+:2022800008200C200820102010203222322252229222122212221222122217FE1202000099
+:2022A00020083C88244848507DFED42054207CFC542054207DFE00200E20F02000200020D2
+:2022C000103813C0204024404440F8404FFE104020407C40204000400E40F04040400040CC
+:2022E000005000483FFE204020403F48204C2F482928293029202F524092410A82040000C8
+:2023000009FC490848884850482048D80B061FF01010111011101110129004601830601016
+:202320002200321E23C05400980017DE21086108AFE8210821082108214823A8211000005E
+:20234000084010203DFE244034602C48248CFDF8241034202C282444249E45F65404880098
+:2023600020001BFC0804210421042FF4210423842344252425242904210421042014200815
+:202380004000200E2F70011082105450575E215022502A50CA7E44004B0050C0403E400032
+:2023A0000040F8200BFE080078404848408C4178FBD048200840088809044BFE2904100049
+:2023C0002208211027FEF8A02BF828A84FFE48A848A833F811A029B02AA844A688A400A088
+:2023E00000001FF010101FF010101FF00440044044482448145014600440FFFE00000000D7
+:2024000000407840484050A0511062086DF6500048884A4869505110402040404FFE4000E5
+:202420000000FFF812081248124812487E481248124812A81CA0E12201220222041E080019
+:2024400008200820FFA8102410207FFE552055207F5049507F504948494849444546428483
+:2024600000000FF008100FF0081008100FF008100810FFFE0240042008101FF8081000003D
+:2024800000203C4025FC25043DFC250425FC24243FA624A824B025282526462454A0884048
+:2024A00020402040207C3E8444884910A240219C2104210421DC25042904310421FC00004B
+:2024C000082004407FFC01003FF801007FFE010021FC12080490108061402230241C2808A0
+:2024E000020001003FFE210449080FF0090011007FFC04400440044008440846103C2000C0
+:202500000040784048FC50885110620050804B1C4A044A046BBC52044204420443FC420483
+:202520000000FBF8920893F8A208A20893F88A808A48AA50922082208210828E83048200CF
+:2025400010401850104C204823FC4840F84013FE20407C48003000221CD2E30A00060002B6
+:20256000100010FC10841084FE8418FC34843284528450FC908410841084108410FC108481
+:2025800000003FFE2400247C24443F44247C2E442D442D7C54445444647C84448440000087
+:2025A000202023FE20003BBC42A47BBCA08823FCF88823FE208827FE21242B583188210629
+:2025C00001F03F000100FFFE038005400930310ECFF4081008100FF0081008100FF000006C
+:2025E00020403F7E28504488890808FC08847E8418FC1C842A842AFC4884888408FC088467
+:2026000001007FFE12481E7804403FFC04403FF80440FFFE04880C503420C518060E0404DC
+:2026200042002200227C02448FC4427C564417442A442A7CF24422442244227C2244000032
+:20264000010001800310061808301FE00088030C0C781F900810002000C00700780000004F
+:20266000440027DC28447C44126411547D54104410CC7D541264104420442154408880004F
+:20268000210410881050FDFE0420082011FC38205420942013FE1020102010201020102048
+:2026A0004208211030A027FE0040E04023FC2040204027FE2040284030402040004000006E
+:2026C000100010FC1084FEFC388434FC5484508490FC0000010008842882281267F0000064
+:2026E00000400060F08097FE9402940295FA950A950AF50A950A05FA050A0402040A040474
+:20270000020001007FFC00001FF010101FF000003FF000600080FFFE00800480028001006A
+:20272000000003FEFC20104011FC110411241124112411241D24E134004801860602000009
+:20274000042004207FFC04200420FFFE042008101FE82826C8240FE00808080C07F80000E2
+:20276000210021F02220FFF8224872486BF8A880A1CC26F02170266821A62E2420A0204064
+:20278000110019F0122027FC34446444A7FC2488219C2E6023502CA823262C2420A0204010
+:2027A000020004003FFC2004200427E4242424242424242427E42424200420142008000092
+:2027C00008000FE010403FF851081FF81210051819A0E6C019A06690188E608402800100B1
+:2027E00004400440FFFE05403FF00110FFFE01103FF0010025082548292829285108810873
+:2028000000207C20112410A8102021FC3D046504A5FC2504250425FC3D042504211401085C
+:202820001FF801007FFE41041D7001001C70092005401FF010101FF010101FF01010103069
+:2028400008040904498429242A247F2441247F24412441247F244124410447144208000090
+:2028600000800088F3EC90909FFE9040908091F09220F4448FFE304000400040014000802B
+:202880003E7C22443E7C00007FFE04001FF81108110816C83830FEFE228822883EF822881E
+:2028A000102011243EA4206841FC7D04910411FCFD04110411FC110411041504191411083D
+:2028C000204010401244814849504BFC1204120423FC2204E20423FC220422042214220827
+:2028E000020001007FFE5124893005401FF010101FF0101010101FF0101010101050102088
+:20290000210810901060019888404BFE508011F8130825F8E10821F82108210821282110F5
+:20292000008078804BFC48404848483078D24B0A4FF6492079204A2002220422081E000088
+:20294000010001000100010009400D2019101118210C4106810401000100010005000200A8
+:20296000010001081FEC0110FFFE00C0010003F00C403080CFFC00800080008002800100B6
+:20298000104010201020FDFE100038883484510A510892901090106010601198160E1004CD
+:2029A000010021081110092001001FF810081FF8100810081FF81008100810081028101075
+:2029C00000800080F7F8908897FE908897F8908094C8F5A896B806A8048808880888000003
+:2029E00020803EFE50A04910820800F03F00010001007FFC0280024004200818300EC00472
+:202A00001020083008207F20147E124421C422446228142808100C10122820CEC30400006B
+:202A20002100213C27D4F91427D471146FD4A124A14827FE204020A02098210E2604200029
+:202A40000840084048486F5C486048404B445C44E07C00003FF8000000000000FFFE00009C
+:202A600000003E2022203E7E22443E8810203F20C9204920552063507F5001880D0E02044C
+:202A8000100011F811087DF8550855F8550055FC7F2455241954158C1FF4E40400140008FE
+:202AA00024202420FE2025FC3C2010207FFE52007E20102011FCFE201020102013FE10007A
+:202AC00020402040204023F8FC4820482248224C248A248A20882108210822282410000063
+:202AE000104010401040FDFC10401248155018E033FED04010A010901108120E54042000A4
+:202B00001140112013FE1220FFFC122013FC1A2013FE3000D3FC1088111E11025212340CEC
+:202B200000007F7E2244224822487F50024806440A420A421252224CC2400A4004400040C1
+:202B4000080808081448132821287E08888808487F0E08F84A084908890808082808100876
+:202B60000040784048404BF8484878484A484A4C7A4A4C8A4888488849084908AA289410C8
+:202B800044202420342C27B004220522E65E248023F82208220823F82A08320823F8000010
+:202BA00000003FFE200448080FFC080008001FFC080400247FF40004000400080028001043
+:202BC00020202028202423FEF82022A072A46AA467E8A2A8A290249224AA284A2086200281
+:202BE0002000207C3F44444404447F4404442444274424442444275CF84840400040000095
+:202C000020003EFC4444BE8C2B503E7C2A903E7E4B109FF011101FF0110801FC7E08000027
+:202C2000240027BC24942914BFA4AACCAAA82FBE2AC82F882AFE2A882A882A8831882008B8
+:202C400040002248224802488A484FFE524812481248E248227822002200220023FE20003E
+:202C6000400023FE22040080888048FC5100110021FC2004E00427F42004200420142008BB
+:202C8000010842083788248807FE0488E7C824A82FA8218822882A883488288812A8011057
+:202CA0003FFC200420043FFC2090249822A027F8240827F8240827F844084408842804101B
+:202CC00004400440FFFE1440080C7F70224014407F7E08487F4808482C884A88A9081208AD
+:202CE000042004207FFE0420042002000100099008884884480648148810081807F0000076
+:202D0000204020203DFC200840887C50902013FEFC20102011FC1020142018201020002018
+:202D200003403C402040207E20843EA82520242024202420245044484488850606040000DA
+:202D4000020001007FFC0000101008200440FFFE010001007FF801000100010001000100EE
+:202D60001000080E7F7022401440FF7E08480848FF4808482C482A884A8889082A08100801
+:202D8000203823E022003200AA00AA00A3FEA22022202220222022202420242028203020A5
+:202DA00002000100008000C0088008000810480848044806880408100810081007F0000073
+:202DC00008800C60184017FE300033F8500093F8100013F812081208120813F812080000CE
+:202DE000101020107F925552555455FE55105510551055FE55105F90F010001000100010C9
+:202E000000001FF810081FF810081FF8010011001FFC210021004FF8010001007FFE000008
+:202E2000000079FC490449FC790449FC4820492079FC49204A2049FC482048204BFE9800BA
+:202E4000840045FC290411FC310449FC9924292029FC4A208A200DFC0820102053FE2000E8
+:202E6000200023F8220833F8AA08ABF8A040224023FC2440284023F8204020402FFE200018
+:202E800000004408220C33081998111000207FFE000008400C2018103018400C8008000056
+:202EA00000047F841224122412241224FFA41224122412241224220422044214820800008C
+:202EC00000047F8412241224FFE41224122422242204411401083FFC01000100FFFE00002C
+:202EE00000047F86120C121012201208FFCC1218122012441286120C221022204240808014
+:202F000000007F3E1224122412281230FFA81224122212221222223A2224422082200220CB
+:202F200008001C0031FC400088000C001BFE302050209020102010201020102010A0104023
+:202F40000000FEFC288428FCFE84AAFCAA20AAA0AEFCC320FE2082FC8220FE2081FE000003
+:202F6000010001003FF80100FFFE1020083004403FF8010001007FFC0100010001000100B6
+:202F80000000010001007FFE018003400530191E610801001FF01010101010101FF010107A
+:202FA0002020212021203120ABFEAA20A420202021FC202020202020202027FE2000000025
+:202FC0002020302021202120FDFE252026204420482029FC102028202420442083FE0000C7
+:202FE00000001FF010101010101010101FF01450044004400440084208421042203E40007F
+:2030000000001020083024242244228421842284224424642824300420047FFC2004000078
+:203020000100790049FE49027A2249324AAA4A4A7AAA4B1A4A0A4BFA4A0A4802A8149008D1
+:20304000080008001FFC1004208448A4A5242224252428A430A43FE4202400040028001006
+:20306000400020102210012090A054A45444144424A424A4E5142514260427FC240400003E
+:2030800010A010901090FDFE2110231029FC4910511051FCA11029104510FDFE0500010075
+:2030A0001040145022787F4441443E3C22003E4C22703E442244263C2888244444440000D8
+:2030C000104018601040104827FC20C060E06160A15022502248244E284420402040000011
+:2030E0001100190031F823086A90AC6028982B4E28E429982660218C263020C027000000B6
+:20310000081004203FFC01001FF801007FFE0200040007F0091017F0211041101FFE0000E6
+:20312000100013FE1040FE401040104038FC34045404500490041004100410281010000014
+:2031400000400080F3F8920893F8920893F8920893F8F0809FFE814002200418080E10041F
+:20316000200021FC3C4023FE40E07D58A24621F8FC902090213C210429043204221404081C
+:2031800000F83F0001007FFE03C00D30310EC1041FF00220024004FC040408041028201087
+:2031A000202018201020FC2005FC09241124352459FC992415241124112411FC11041000A8
+:2031C000103C1BE0104023FE48D0F948124620447BF8009000901D3CE10402040428081007
+:2031E0002040207C204027FEFC4425F02444243C24903C90E69445980890089017FE2000F5
+:203200000040005000483FFE20402040204820483E502020206020A043124C0A80060002C8
+:203220003FFC01007FFE41041D7001001D7000007FFE02003FFC24442444244424542008E3
+:20324000010001F801003FFE210421F03F0421FC2000224032482A4C4A504240BFFE000055
+:203260000040007C0040F7FE948494F09784947C9400F490949006940998089017FE200052
+:20328000080013FE2020C04005FC090411242124C1240524092410502048C18606020000FB
+:2032A0001040184020A04118920E1DF430406040A7FC20402250234C2446284421402080D1
+:2032C00041002100310021FC02200220F420102017FE102010201020142018201020002055
+:2032E0000440FFFE044001007FFC08601FC003101C083FFC00083FF821083FF821083FF815
+:203300000000FF0828082848FEAAAAB2AA92AE92C2AA82AAFECA82828282FEFE828200001E
+:2033200008000C00127E11C421447E44884408447F2808284A1069304948B8861104020025
+:20334000100010FC10841084FC8414FC148414841484248424FC24004402440283FE0000D8
+:20336000010000803FFE200027F8211020A020402FFE20442040204020404040414080804D
+:2033800002000100FFFE02000CC03F200C103FF800081FF811081FF8110811081FF81008FD
+:2033A00020802080210033F8AAA8AAA8A2A822A822A822A822A822A822A82FFE200000008A
+:2033C00008007F7C1244224414440C7C720004400F8002100FF800881090108C2284010085
+:2033E000200033FE20242138F9204AA04A7E4C0049F8310811F829082DF8490881280110E4
+:203400001040104021F420444848FBFE1020204041F8FB08050801F83908C10801F801082C
+:203420001040184011FC20404BFEF12410A822A04120F7FE002000501848E0840104000010
+:20344000100011FCFE201020202028204820FDFE08200E203820C8200820082008200820E0
+:2034600000800040F3FC9404900893FC900093F89208F3F8920803F8020800000FFE000092
+:20348000020001003FFE40041FF800000FF008100FF0081008100FF008100000FFFE000037
+:2034A0000FF008100FF008100FF008107FFE040008101FF8000809002884281267F20000C7
+:2034C0002080108010FEFD00220021FE3C2425202520253C2520452045A0AA60121E040058
+:2034E0000100008000847FFE01000220042008401F8009000220041008083FFC100400007E
+:2035000000402240124013F804400040F7FC1120112012241224141C1000280047FE0000BA
+:20352000010000803FFE2400A74469283FFE2A906F90AABC2F902890407E5F908810001005
+:203540000080784048444FFE48407844488449F8481078204840488849047BFC49040000B0
+:2035600010801080210021FC4A04F5F41114211441F4F914011401F41804E00400140008F4
+:2035800024502450FE5024943D9412987E9052B07ED010901090FE9210921092108E0000B2
+:2035A00008400840FFFE084020207DFC450844887C5043FE7C2045FC44207C2044200020F6
+:2035C0000108108C0CC808907FFE40048FE8004000807FFE008000800080008002800100E2
+:2035E0000200010001003FFE2004200804400440044004200820082010101018200E400444
+:2036000000003FF801007FFE41041D7001001D7000003FF800081FF8000800083FF80008F0
+:2036200002000300020004003FF824882488248824882488248824882488FFFE00000000EB
+:2036400000207F20412041207FFC00247F244124492449244924492414442354C288000075
+:2036600000F83F0001007FFC01001FF0155015501FF001003FF80100FFFE24482224422460
+:20368000103C1BE0222052209BFE322062FCA28422FC2284228422FC2284248424FC2800A2
+:2036A000080008001FFC100420045FC4904410441FC4104410441FC410440004001400087A
+:2036C0000100410031FC2204040403E4E224222423E42224222423E42A24300420140008C2
+:2036E00000003FF800081FF8000800083FF800207FFE0020082004200620042000A00040FA
+:2037000000847C8404A424A424A424A424A43EA402A402A41AA4E2A4052415040A04000497
+:20372000012441B62124224802480490F890144812481224113611241000280047FE8000F3
+:203740000040FE40108010FE3D02260244F26492989208F21092109220F24002800A000470
+:20376000200017F011100110811049100FD0111011102110E108210A210A2106210200002B
+:20378000410421243124212401240124F1241124112411241124112415241A2412240404E8
+:2037A000400027F8310821080108F10817E81108110811081108110A150A190A1104000071
+:2037C00000104F902090211002100258E35426942A92231222122A50242050008FFE0000FC
+:2037E000400027F03110211001100FD0E110211021102114210C2104210050008FFE000038
+:2038000000003FFE20002080208020882FFC208020A02090209840904080BFFE0000000023
+:20382000100011FE1122FD22112211FE1522192231FED020102010201020102050202020D4
+:2038400000207E4008FC48A448947E840894188818FE280228024BFA8802080228141008E9
+:2038600000207C4054FC54C454A47CA4548C54807CFE1002100213F210021002100A100443
+:20388000000003FC78104910491049104BFE48307850485040900110021004500820000006
+:2038A0000000082004300640028001000100010001000100010001000100010001000000DA
+:2038C0000A4004247FFE04603FDC10200C2008201F7E10A0012002200C20712080E0000049
+:2038E00000003FFC00400840084010403FFE10C001400240044008401040204041400080A0
+:20390000100011FE10087C885488548855FE54987C28102814481E483488C1080228041014
+:20392000010021083FF800003FFC20802FF8208020803FFC20802FF840804080BFFE0000A5
+:20394000200037DE4200820027C0325E6244AFE4200427C424442444244427C424542008EC
+:20396000400027FE2440044095F85440544027FE24402440C7FC48404840504067FE400090
+:203980000040FE50488848FE49107D100BFE1910291029FE49108910091029FE11000000C8
+:2039A000000007FCF9208920892489268D248B288928F9308920012001201FFE00000000A0
+:2039C00000007FFE024002400248224C124812480A500A500A6002400244FFFE00000000D7
+:2039E000000043FC301021100110F11011FE103010501050109014901910121004500020F3
+:203A00007FFC010011F811001104FFFE08080FFC10003FFE00042924249444880028001089
+:203A2000000003FC0204FA448A448BFC8A448A448A448AA48A9CFB148A04020403FC020488
+:203A400010000BFC090441044FF4424445245FFC452447E4452447E4411440F44004400C2F
+:203A6000100013FE1222122256225AFA52229222125212522A8A2B0A4202420283FE02020B
+:203A8000408020802FFC01408230548E5FF4249027F04490C49047F040824082407E4000C7
+:203AA0000840084008407F500848084C0F44F84040001FF81248124812481248FFFE000074
+:203AC00000047FFE224812480A503FFE20002000200020002000200040004000800000004A
+:203AE0000000FDFE10881088208820887BFE6888A88828882888290839082208040808089A
+:203B00002000278E2178F908A908AA08AFAEA8A8F8A822A8313E29003E80EA60041E0800F2
+:203B200001002108210821083FF800007FFE040008001FF82808480888080FF8080800000B
+:203B40000000F81C13E0102020207920293C09204920492029FE10002800460081FE0000D1
+:203B6000020001007FFE000000001FF000001FF0000000001FF01010101010101FF0101009
+:203B80001000087E7F102220147C7F4444544854725444544854712846249846E1820000F9
+:203BA00020001BFC0804220423E424443A042CF428142EF428142FF420042004201420086E
+:203BC000010001100920094012800460191861800910091012A002400430181E6004000065
+:203BE000200011F01110811049104910120E14002000E3F8220822082208220823F8220824
+:203C0000010001007FFE028004400930310EDFF411101FF011101FF01114010400FC00008E
+:203C20001040104013FEFC4010A015581A4E3FFCD24813F8124813F810421042503E2000FB
+:203C4000000079F84908490879F84908490849F8794049404924492879104948018E01042F
+:203C600014001B7C220040009100197E21086108A2082E0822082208220822082228221079
+:203C80004080204027FE040483F8504013F8224823F82248C24843F8400041104108420869
+:203CA0001080108010FCFE88110813FC7D241124112411FCFF0011041104110610FC1000B6
+:203CC000000027FE240025F82508FDF8250825F8244027FE3C90E4604498050807FE00008B
+:203CE00004400440FFFE044017C01014F7DE14503452D7CE0000288824446666C2220000D4
+:203D000000003FFE21002140213021203FFC210021002280224024604438481C90080000D5
+:203D20000000FDFC11041124212421243D246524A5242564245024903C922512220E040019
+:203D40007FFC400044A0449049104BFC5B206DFC4920492049FC4920492049FE89000000B3
+:203D600000400020FFFE880089F88800880089F88800FBFC8A040204020403FC020400002E
+:203D8000010000803FFE041002203FFE2000206021802E1820E023062C18406043809C00FF
+:203DA0001040104010FC14845908521050C4931E1E0412042BBC2604420443FC82040000E3
+:203DC000020001007FFE40048FE808200FE008200FE004007FFC0820044003800C60701C14
+:203DE0004040202033FE2108009003FEF200120C1270138C127013861C1814600B80100089
+:203E00000000F840084048A04890490E4BF07C00048406443548C548041017FE08000000C7
+:203E20000040FE40204021F83D4845484548A9482BFE104010A020902118420E8C04000009
+:203E40000100010001001FF01110111011101110FFFE01000280024004200818300EC004C4
+:203E600001001FF01110FFFE028005607FFE0A10093008000FFC00043FF4000400140008F3
+:203E80000C207020102011FCFD2411243924352457FE5050905010881088110C12061404CB
+:203EA000100013F81010FE201040108039FC3454549450A491241244108411041014100840
+:203EC000100013F81010FC201040108015FE18523092D0921122162210421082531420082C
+:203EE0001210191011242FFE20407048A7FC204020442FFE20402040204020402040000089
+:203F0000010000801FFC900057F05060118033FC5094911412242444218446085828801094
+:203F20000820043002403FFC010001001FF8010001007FFE0100010001000100010001000A
+:203F400022101110112007FC8040504057FC104020402FFEE040204020402040204020405A
+:203F600000007DFC450449044904510449FC4504450445046904510441FC410440004000AC
+:203F800010001FFC20005FF000007FF0109009103FD002103FD002107FEA020A020602029C
+:203FA000080008C0173E1422342224226422A422242224A2252E2624242020202020000051
+:203FC000010000841FFE9208511057FE1040104037FC504090442FFE20404040404080406B
+:203FE000082004483FFC01001FF801047FFE034006200C18342EC4240820082010202020E1
+:20400000110810881090FDFE1020302039FC54205020902013FE102010201020102010200A
+:20402000421021202FFE004087F8504017FE208023C82050CF6041504248444E5944408028
+:20404000022044202FA02CBE0AA40FA4E2643FD424082788249428A632C251008FFE000034
+:2040600000007BFE48504BFE7A524A524BFE48807BFE4888490849D048204850A88C9304EF
+:204080001000103C13C01040FC40244027FE24404840284010A028A025104508820E0404F6
+:2040A000003C03C07C421224112811007DFC1220102013FE14201924612401FC01040000DF
+:2040C000101C13E010801244FD48111015FC1A20102037FED02012221222122253FE2202C4
+:2040E000040004380FC0F220017001840E64701C0000FFFE0440044008441044203C4000EA
+:204100000078478021082490022003F8E440204027FC20402248224823F850008FFE000093
+:20412000020001007FFE40440C30300CDFF811002100FFFE01002108210821083FF8200822
+:20414000401C27E03488224C01480210E3FC2220242023FC202022222A2233FE22020000CE
+:2041600010A010A010A012A47DA824B024A024B049A82EAC12A818A025224122821E04005D
+:2041800000800048F7FC900091109188920C95149110F11090A0804000A00118020E040470
+:2041A000007C7F88110C08C80890060038F8200820083EF82008200820083FF82008000064
+:2041C000044004407FFE044014401040247C7C84090410447E24202406047804202800102D
+:2041E0000000FFFE04403FF8244824483FF824080400FFFE08100E2001C00630180C600842
+:2042000013DC1244955454CC1154FEC4292029FC2B202DFC29202BFC5D20492081FE010071
+:20422000200027FE2252FA5223D462547258AA58A3D42252227223DA2E54205020502050B2
+:20424000004007FCF04093F8900097FE980493F89000F3F8920883F8011000A40FFE0000C2
+:2042600000007F7E224422443E48225022483E44224422422F42F254024802400240024000
+:2042800004200810342CC24401800660181EE0041FF00210021002100250022002000200BE
+:2042A00000007EFC52087E10526052107EFE10241020FE20102010201E20E02000A000400C
+:2042C000008040C0208031102108127C1786100423F8E20822082208220823F8220800004D
+:2042E0000100018011001908117C1788F90811081108114811281014100410060FFC0000C0
+:204300007FFE010002000FF00810091009100910091009100910099002400C30700C0004D9
+:204320001040102013FEFC9010A0157C1A4416A43398D248123012301248128E530422002B
+:2043400004400440044004444446244C244814501C501460044004400444FFFE00000000D2
+:2043600000400040F8408840884088408FFE88408840F84088408040004000400040004050
+:20438000020002003FF0221022103FF0221022103FF00100011000B001C40E24F014000CFB
+:2043A000004078204FFE48A078A0493E49244B747DAC49244924491849244924A942914229
+:2043C00002000100FFFE08800C8009FC110832885250951010A0104010A01110120E1404A1
+:2043E0004040202027FE09208920527C524416A82B982250E220223022502288230E2204E8
+:2044000000000000000000000000000000047FFE000000000000000000000000000000001B
+:2044200001007FFC01001FF800007FFE80043FF800001FF010101FF0082004407FFE000089
+:2044400000007FFC480048004FF8508060885FFC4140412042104418481040007FFE000052
+:20446000200021F82108F9F8200023FE290831F86108A1F82108210E27F82008A0084008BD
+:20448000204020203C2023FE40607860A0A420A8F99022902090208828A830C6208400007E
+:2044A000110018C010803FFE308050C4514E93301320153019101128114E1384110000003F
+:2044C00010081BFC1088108827FE20886088A7F82088208021002100220022002400000037
+:2044E00002000100FFFE010001000308048C0890186028404820882008100A0E1C0408003F
+:204500000000FEFE88208840BEFCA284A2A4A2A4BEA488A488A48850FE4800860302000060
+:2045200001007FFE01003FF8010801083FF8210021003FFC0104029404480830101C60084C
+:20454000404023F8224803F800400FFEE00023F822482248224820A0231850088FFE0000F5
+:204560000C40707C10841508FE50302030D05B20547E908411881250102010401180160031
+:20458000088008401068124822086210A110211020A020A0204020A02110220E2C042000AA
+:2045A00000203C2025FE24203DFE242225FE25203D2025FE2422245624504488550E8A04BE
+:2045C00020002DFC3008225022201DFE40227E2448A088BCFEA018A015602130420E840467
+:2045E0002000103C13C002008A004A0053FE122022202220C22044204420482050204020BD
+:20460000010000803FFE200440080FE0082008200FE0082008200FE0082008207FFE000036
+:204620002040304027FC2040FBF828482BF84A404BFC324410A428AC4D10890802060404D4
+:2046400008200FF010201FE00024FFFE49202A787F241CFE2A544892FFFE0810101060101E
+:204660001040104013FE1040FCA011103BFE340851E85128912811E810081008102810101B
+:204680001080104811687D4855085508551054907C9050A0184014401EA0E518020E040476
+:2046A0001040184017FC20A021106208AFFE200827C82448244827C824482008202820104D
+:2046C00000003FF000100010001020103FF02000200020002004200420063FFC0000000013
+:2046E0000000FFF0006000C00180030006000C001800300020006004400460063FFC000064
+:204700000100022004100FF8000808000FF8110021007FFE0280024004200818300EC0048B
+:204720000010241022102310221020102010211022102C303830706820C40107060200004B
+:2047400004400440FFFE044004401FF0006000800100060008001004200420061FFC0000D5
+:20476000104010C0133EFA221222122212221A223222D2A2132A1224102010205020202089
+:2047800000000FF008100FF008100FF004000FFC112462240444188463040C04701400083B
+:2047A00000001FF0101010101FF000003FF8210821083FF820002002200220021FFE000038
+:2047C000108010C0108010FE5500560055FC54085410542054405C84F104410600FC0000FF
+:2047E00008000DFC08041008101030205040908011001100120012041404140413FC1000DB
+:20480000100019F0211049108D10120E340053F89110111010A010A0104010B0111C16083C
+:20482000008078404BFC48907FFE480049F8490879F8490849F848444AA24A8AAC8A907045
+:20484000020043F0242024400FF814880488E7F82140216022542244243C50008FFE000072
+:204860002020242039FC24243FFE002421FC3E2049FC08207E200BFE1420222042208020CF
+:20488000010000801FFC100013E092205220541C180033E0D22012202140208043608C1C4A
+:2048A0000200018000807FFE0240024012501A481244244644440840084011402080000067
+:2048C00001007FFE010802900C60751C06083FFC224424342FF4342427E424242014200891
+:2048E00001003FFC08200440FFFE00001FF0121011101FF0000029082884681407F0000062
+:20490000100008787F4822481448FE861000327CDC882E48CD503420C45004882B0E100400
+:204920001000100013FC1004140852105220504090801100110012021202120211FC100029
+:204940000000042022302120112010400840048002800100028004400830300EC0040000D0
+:2049600000201030084004807FFC04200810300CC0041FF81248124812481248FFFE0000D8
+:20498000200012081110012087FE509011081604200023FCE2A422A422A422A427FE2000A7
+:2049A00041002100311C21E00104F10610FC100011FC110411FC1104150419FC11040000A8
+:2049C00041002080324822480208E2082110211020A020A0204024A02910320E240408006F
+:2049E0000080404037FC2408000003F0E210221023F0221023F022102A1032102FFE00000E
+:204A0000000043F82108309020600090E34E2C4423F8204020402FFE284030402040004041
+:204A200000001FF0101010101FF01008100C0FF8042004207FFE0420082008201020202034
+:204A40007EF812480A28121822281FF011101FF011101FF008207FFC0820FFFE1830600CF5
+:204A600000007EF81248122806181A28634800803FFC00200830046004400080FFFE0000E9
+:204A8000100011FC208820504860F090130E202441FCF820002003FE1820E0200020002066
+:204AA00008200820FFFE08203FF8210821082FE82108210822882468284820083FF8200862
+:204AC00004400440FFFE044004403CF8248828F82888248834F828882108210822282410C1
+:204AE00000007FFC4104410441045FF4410443044284464444244834502440047FFC4004E2
+:204B0000080008783E4822483E88228E3F0020FC20883E482230221042284A4E858400008F
+:204B2000010000803FFC082004200440FFFE00001FF0101010101FF0101010101FF010105F
+:204B400000007DFC4504490449FC51044904450445FC5504490441044204420444144808B6
+:204B6000200021FE21222122FD2225FE2522252249226952114A198A250245FE810201028C
+:204B80000040F84088A08890890C8A468C228820FBFC8808880800100010002000200040EB
+:204BA000100011FC21043D0441FC7D04910411FCFD401124112811101548198E110400002D
+:204BC0002000107C1780008484445248521017FC20402040CFFE40404040404047FC4000A7
+:204BE000020001007FFE40049FF001001FF0111011101FF0111011101FF00C203018C00874
+:204C00002080208020803DFE45044A4894401040104010A010A0111015081A0E140400004C
+:204C200000003FF8020802087FFE020802083FF802080200040004000800100020004000D5
+:204C400000047F04010401043F042004200421047F842104010401040104010405040204C8
+:204C6000008078F04910522067F8500853F848084BF8680051404524450A490A40F8400070
+:204C800000000EFC70844084408440847E844084408444845894E0884080008000800080E4
+:204CA00004200420FFFE042001001FF0111011101110FFFE0100028004400830101C2008C8
+:204CC000200027FE2562256AF56A256A71886A54A4A2A0802FFE2110232020E023182C085E
+:204CE0003EF822882AA82AA82AA82AB01448328C4300FFFE08201E4001C003300C1C700810
+:204D000001007FFE49204BFC5E206BFC4A204BFC4B0047F84488445847FE40029FCA800469
+:204D2000010000803FFC200022002108308C28C8249024902620442040405FFE8000000031
+:204D4000000027BE34A224AA46AA9208F51428224080F7FE0110021019A0E04001B0060C79
+:204D6000044004407FFE044004407FFE40049FF8010001001FF80140013001207FFE000025
+:204D800004400440FFFE044004407FFE410481001FF8110811081FF80110010801FC3F0805
+:204DA000044004407FFE04407FFE40048FE8082008200FE000001FF0101010101FF01010B5
+:204DC000042004207FFE042004207FFE40048108092009301140028004400820301CC008C7
+:204DE000100011FC11047D0455FC542055FC55247DFC1124192415FC1E22E422001E000011
+:204E000040002180367C244404440444E44424442544265424482040204050008FFE00008B
+:204E20000100FFFE10001FF000003FF820083FF8000077DC55547554555C71145294B466C4
+:204E400000003FF008100BA008B8128811082288445080203FF8244824482448FFFE000097
+:204E60007F0441067F0C41087F100824FF86000C7F0841107F2408062A084990A92010409B
+:204E8000200025FE382022401EFC00843EA408A47EA408A41CA42AA4CA30084C09840000B2
+:204EA0000000FDFE102011FC212421247DFC6524A52425FC26403D4024C02130060E1804FC
+:204EC0000040004078404BF84A484A487A484A484FFE4840484078A000900108060E1804A1
+:204EE00002100318F210922094BE97A2994292029422FF92941A0012000203820C0A00042F
+:204F0000100013FE1222FE22122213FE16221A2233FED2221222122214221422582A2004C4
+:204F200008000BFC12441244324433FC5244924413FC124412441444144414541848000072
+:204F4000004078204FFE4A504A487CFE4F484A7E7AC84FC8497E49484A486A7E9440000028
+:204F6000010000801FFE100097FC5444544417FC3444544497FC244428444844905420485E
+:204F800000803FFE20802FF820883FFE20882FF820802FF828882FF828884FF84888889854
+:204FA000020001007FFE10A0109025FE7910131011FC25107D1009FC09103110C1FE010064
+:204FC00000007DFC4404444844307DFC1124112451FC5D24512451FC51245D24E124012C75
+:204FE000100011FC100810507C2055FC552455FC7D24552411FC15241F24E524011401089B
+:2050000001800040F00093C09048904C974891509160F2509248044E044408400140008068
+:2050200020801040100007C0804450485750116012602250E448244E2844304021402080D6
+:2050400023FC1008109000608BFC4A44524413FC12442244E3FC22442244224422542248B2
+:205060000200018000801F00010801187DA0054009200920111011082106C100050002000F
+:205080001FF0022001401FF811081FF811081FF811081128021009002908281467F40000F2
+:2050A0003FF0026001803FF821083FF821083FF8210802007FF802080408080810282010B7
+:2050C00000001FFC1084108410841FFC1084108410841FFC108410842084208440948088BB
+:2050E00001000100010049244D34514465547DFC492455547FFC451441047FFC400400000A
+:20510000108018A01098209037FC6140A1402140214021402140224422442446283C2000FC
+:205120001080108021FE29086A90AC5028202850218E20040100088048944812C7F20000FE
+:2051400020802090208C3088A880A7FEA0A020A0212021202120222022222422241E2800D5
+:2051600002000240023002107FFE024002400240024004400440084208421042203E400016
+:2051800001000100010001003FF82108210821083FF821082108210821083FF8200800001F
+:2051A0000800087E08447F484948495049487F444942494249427F5A414400400040004011
+:2051C0001020102020203E2041FC7D2491241124FDFC112411241124152419FC110400000E
+:2051E00000A044902898108837FE48A008A018A028A04920892009220A221222541E280067
+:20520000404020402040004097FC544454441444244427FCE44424442444244427FC2404BD
+:205220004420222022200FBE844054BC570825102510257EC5104910491049105550422092
+:205240000000FFFE028002803FF8228824882488287830083FF82008200820083FF820082E
+:20526000010001007FFE020004000FF0181028104FF0881008100FF008100890087008200C
+:20528000020002000200FFFE0200020007F004100620092008C010C0212042188C0E3004AC
+:2052A000020002000200FFFE04000400080018002FF848088808080808080FF80808000085
+:2052C0001080188010802FFE20806100A10023FC220426042A043204220423FC2204000009
+:2052E000062078201020542039FEFD221122392235FE552251229122112211FE1102000043
+:20530000403823C0304027FE00E00150E24827FC20882090209C290431042204041408085B
+:2053200000003FF810080810081004200420024002400180018002400C30300EC0040000A0
+:20534000104018401040204025FC4644FC444844104410842484FE844504010402140408FC
+:20536000400027FC3040204000400FFEE040204020402040204021402080580087FE00002F
+:205380004410221022100F98842854245746159025082508E5004920491055186208000070
+:2053A00000003FFC0100010001000100FFFE0100010001000100010001000900050002009B
+:2053C00000003FF801000100FFFE01000100050002003FF02490249024902490FFFE000092
+:2053E000104010601090F90816F6380037C2525253D2925213D2125212521242124A12C42F
+:20540000020003F002003FFE22042FC0221021E02FF028102FF021003FF8414042308C0CB7
+:205420001FF811081FF811081FF801003FFC21442FE42024200C09002884281267F2000089
+:205440000A00323827C83A08253827C821083FF821082108FFFE00001020181020184010CC
+:20546000010001000280046008103FFEC10401003FFC0100114019301118211045000200B2
+:2054800001000280044008203FF8C00E3E0422483E48224822483E4822082A2824100000DC
+:2054A00040802080214002300DEE0000E78824A827A824A827A82488259850008FFE000013
+:2054C00008000FE0082010401FF83108510811081FF8110811081FF800000000FFFE00003E
+:2054E0002040204020A03318ADF6A000A784249427942494279424942484259424880000C8
+:205500004040204020A003188DF64000578414A427A424A4C7A444A444A4448446944508BD
+:205520002100110013F8021084204BF85248124823F82248E24823F8200020002FFE2000EA
+:2055400078004BF8524853F8624853F8484048404FFC6C44545447FC44044404441444088C
+:205560001FF800300460028001047FFE010C01080110010001000100010009000500020041
+:20558000100019FC11041104FDFC240027FC282048202BFE102018502C88490C8206040472
+:2055A0000000FFFE010001003FF831882948252831882948252821082108210821282010D3
+:2055C0000000080008040FFE080008000FFC0004000400247FF40004000400480030000070
+:2055E00010801080108010FE5480548055FC5484540454045DF4E4044004000400140008CF
+:2056000000083FFC01001FF8110811081FF801007FFC412441145FF4481440044014400821
+:20562000010000803FFE200440081FF0008000807FFC0080008000800080008002800100B3
+:20564000400023FC3040204003F8E088208827FE200021F821082108290831F821080000DD
+:2056600000007EFC0204020422441224122406040A14122462C40204020402040A14040812
+:2056800000007FFC01000100010001003FF8010001400120013001100100FFFE00000000B1
+:2056A00020202028202427FEF820202427A624A424A827A824903832C34A0C8A03040000A5
+:2056C000044004407FFE044000003FF801000100FFFE01000100010001000100050002003F
+:2056E0000800087EFFC4104810483F506148BF44214221423F42214A21442140254022402F
+:2057000000007FFE442044204420442047FE442044207C20442000200020002000A000402F
+:20572000000043F8224823F8024803F8E04027FC2444245425F42404241450088FFE0000E3
+:205740000040004078A049184EF648004BC44A544BD47A544BD402540244025402C800004F
+:20576000209020C8208C2144AA40ACA0A890A90EAA04ADF8B908E908090801F80108000043
+:205780000200220033DE6512951219122FD26112A51225D22512251A25D42F10201020105B
+:2057A000010002800C6037DCC0083E102A9036902A90225026200000290828A467E4000097
+:2057C000102014202240227E48840928142022207F20A220225022503E88210E06040000AC
+:2057E00008208A205128202450209EFE122012203250525092481388128451062202000000
+:2058000002000100FFFE042008103FF810101FF010101FF010101FF01010101010501020B8
+:20582000220811100020FFFE0A2011103FFE40048FE000000FE000001FF010101FF0101078
+:205840002020111011088204448050C01120121824063BF8E20822082208220823F822080F
+:20586000020001007FFE40049FF811101FF011101FF001003FF82148212821F82E282018DC
+:2058800021101188010CFA440C4008A0109035085A0699F815081108110811F811081000B0
+:2058A00000007DFE0420284010FCFE8414A410A410A410A410A41050104850862302000018
+:2058C0000080FCF8091053FC2524FDFC2848208C23502CA023302C6820A6A3244CA00040AF
+:2058E0000000F8000BFC49044908488848887C90045004603420C4500488290E1604000062
+:2059000010001EF8228834BA4882147E6FF00A10093008000FFC00047FF400040014000811
+:205920002404144414448654455454E417FC244424E4C554455446444844484450040000B9
+:2059400000003FFE240447E8082010401FF811081FF811480250024A044A183E60000000F9
+:2059600000001FF80000000000007FFE04400440044004400840084010422042403E0000C1
+:20598000200027FC2000200023F8FA08220823F8220822083A08E3F8420800000FFE00005A
+:2059A000010001003FF80100FFFE00001FF010101FF00304048808503820CA180C0E080427
+:2059C00000003FFC2180210027F0241027F02410241027F0208024A04698488C9288810038
+:2059E000103C17C0128CFD5011FC1480188017FE3080D1F8111012A014601890510E26045A
+:205A000010201020FDFC202023FE5000FDF8510811F81C6230A4D198169010AE10C41080A2
+:205A200000007FFC40044FE4400440245FF444844484449448945074600440047FFC40040A
+:205A40000FF0081008100FF000001FF8100811081108110811081288024004300818301015
+:205A60007FFC40044FE448244FE440044FE448244924492449244284444448247FFC4004F2
+:205A80000840484033FC304057FE880009F8190829F848C089460B280D100948518E2104FB
+:205AA000400027FE2440048085FC550415FC150425FC2420C4A844A449224A2250A0404095
+:205AC000208030F8210841F04810F7FE118022444CE8F330046818AEE3240C2000A00040C4
+:205AE000000047F83000200000000FFEF1201120112011221222141E1000280047FE000081
+:205B0000042004207FFE0420242020F83E882288428852888AB8049008821082207E40005C
+:205B20003FFE210027F8240827F8240827F8204022482CC420404A844A429A1201F0000041
+:205B4000100010F81E882288228864A8949008823082C27E090029082804681607F20000AA
+:205B60000080F8408FFE9404A000A3F8900088008FFEA92091208120822282228422881EB9
+:205B8000000000003FFC20042004200420043FFC20042004200420043FFC20040000000010
+:205BA00010401040104024FC24844904FA84104420247C2400040E04F004400400280010A4
+:205BC0000828082408207DFE09200924FF26091449184F5249AA49464802A8009FFC00001D
+:205BE00000007C3C45E0442044207C2013FE10205C505050508850885D04E10602040400D5
+:205C00001000107C1F441044207C3E44484488447F7C0844084408440A840C94090800009D
+:205C200000101FF8100010001FF8108010801080FFFE01001108110811083FF810080000BE
+:205C400004003FF8210825482FE8254829283FF82008FFFE08000FF80008000800500020B3
+:205C600007F004100410041007F004100410041007F0041008100810101020504020000093
+:205C80002208211020A033F8AA08AA08A208220823F820A020A02120212222222C1E2000B9
+:205CA000200013FC5004442442444FE4482448244FE4428442944494587440044014400815
+:205CC00008000800FEFC08007E00080009FEFE2018201C202A402A44488289FF0802080057
+:205CE000000000303FF800000000000CFFFE0300070006400C20181031F87F0C20080000B4
+:205D000000007F7E41447F4800487F5041484944494249424942555A14442240C3400040C0
+:205D2000080008040FFE10041004260441840084000400E40704380400040028001000003C
+:205D400079F84908490851F8600053FC4A044A444A446A44524442A44090410C46044000FD
+:205D6000020002000400041008081FFC0A480240024002400440044008421042203E400002
+:205D8000400023FC30002000000007FEE080212021102208247C2FCC2008580087FE0000B3
+:205DA00004400440FFFE044011F8210845F8F90811F82C0073FC02941E94E2940FFE00003B
+:205DC0000000FEFC28002800FE00AA00ABFEAA20CE208240FE4082848282FFFE82020000E5
+:205DE0001FF010101FF010101FF000007FFE41043FF0040009001FF001007FFC01000100AB
+:205E0000102008207F40227E12821542FF2200223E02221222223EC2220222023E0A22042F
+:205E20003FE004200420083C08041FF42024415480887FFC008000800080008002800100B9
+:205E400000007FFC408040804FF84888488848884888488848A84890408040807FFE00002B
+:205E60000000FBFE2220222022FC22A47AA46AA4AAA42AA42AB42AA83A202A2003FE000024
+:205E8000020002003FE0042004240824311C01007FFE010009200910110C21040500020010
+:205EA000084008507F4808480840FFFE084008487F4C08281C302B20C952088A09060802F6
+:205EC000084008507F48084C0848FFFE004000487E4C4228423042327E52418A0606000071
+:205EE000020001003FFE2104418801000110111012A01280224004200818300EC004000055
+:205F0000010000807FFE410480803FF8082004407FFC010001003FF80100010001000100E3
+:205F2000044004503F480440FFFE08407F44104424287F28043007307C52048A05040400DB
+:205F40007FFC010001001FF0111011101FF0111011101110FFFE1010101010101050102014
+:205F6000020002007FFE040004000840184017FC3040504090401040104017FE1000000050
+:205F800000400080FBFC8A048A048BFC8A048A048A04FBFC8A048204020403FC02040000E7
+:205FA0002108252827BCF94827BE21182BAA35466800A3F822082248224020A0A118460819
+:205FC00008007EFC108028807EFE08880E88F9080A081FF010101FF0101010101FF00000C5
+:205FE000082028A03EFC49207EFC14502692C50E1FF011101110111012C00430181860108D
+:2060000000207C1045FE550055105510551055FC55105510111029102A1042FE8400080092
+:2060200000207C1045FE45007D1045104510457C7D10451045104510451056FE4A00840031
+:206040000440FFFE04407FFC08401F582262D442083E3420FFFE0420042008201020202070
+:2060600001204FFC21202FF809280FF8E9282FF8200027F0241027F0241027F050008FFE32
+:206080001090109093FE54905BFEFE9233FE3A9257FE540051FC910411FC110411FC110496
+:2060A00002402248124C0A50FFFE042022482FE8210821083FF8210821083FF820080000A0
+:2060C0000440FFFE044043F02210A3F0500057BC14A427BCE0402FFE20E02150224E2C44A7
+:2060E000010001003FFC01001FF8110813880560191E6208018000C00600018000E00040A9
+:2061000000001FF8100810081FF8100810081FF801000100FFFE01000100010001000100D6
+:20612000200013F0121003F0800057381528273820802080CFFC41C042A04490588C408016
+:206140003FF00A100920044003801C60E11E1FF4111011101FF00120011001F87F1000006D
+:2061600001FC7904490449FC48007BDE12521FDE502053FE507050A85D28E22604240020C3
+:2061800001F0F110911091F097BC94A494A497BCF0409FFE00E001500248044E184400409F
+:2061A00040402240224003FC04400040EFFE200023F82208220823F8220850008FFE00007A
+:2061C000010002001FF0101010101FF0101010101FF0020403FEFE000204020401FC000001
+:2061E00020402040204028402840B040A7FCA040204020403040284048404FFE800000004F
+:2062000011F81108150819F857BC54A454A497BC104017FE28E029504648584680400040C6
+:2062200001007FFC01003FF80100FFFE00001FF0111011101110111012C004301818601073
+:20624000200023F82110FCA0204020A02B58304663F8A040204027FE20402040A04040403D
+:2062600000047F04412449244924492449244924492449241824142422044194810800003F
+:20628000200017F00220094088C05130560E108027F82080E0802FFC2080208020802080E5
+:2062A00000207C28442457FE542055245524552457E855281110291A2D2A4A468482000071
+:2062C000080008000FFE140027F84400040007F804000500008824842412641203F000004F
+:2062E0002208218C209023FEFA2222AA227223FE200021FC3904E1FC4104010401FC0104B6
+:206300002208211820A027FC3444AD54A4E4A7FC200023F8220823F82208220823F822087A
+:206320000830042002403FFC2914252425443FFC00000FF008100FF0081008100FF00810FD
+:206340000108F88C8850ABFEAB26AAAAAAAAABFEA800A9FCA90421FC210451044DFC8904A6
+:20636000108010801080FE8010801080148018803080D0801080108010821082507E200071
+:2063800000400040F7FE90E09150924894469BF89208F3F8920803F8000000000FFE0000C9
+:2063A0004040204027FE00E09150564C504023F8220823F8C20843F8400040004FFE0000B3
+:2063C000084008400840FF4008401C401A401B40294028404840884008420842083E08004A
+:2063E000082008201020FFA01020242024207F20242005A01E20E42444240426041C040042
+:20640000200427C43C54245444547D54A5542554FD542554211422942AC43444281400082B
+:2064200010000BFC0804200427F4249427F4249427F42084208420842084208420142008C4
+:206440000008FBFC888088408840FBFC88088810F820884088808900FA008D80887E000404
+:20646000100013BC12A4FEA412A43AA437FE52A452A492A412A412A414A414A41AB41148F7
+:206480001040102013FEFAA410903B08348050FE5140927C1040107C10401040104010402D
+:2064A000008000C0F88089FE8A808C8088FC88808880F88088FE0080008000800080008075
+:2064C000080008040FFE11001100210841FC01000100010801FC0100010001000100000007
+:2064E00010801080108415FE55405A405448907C10402848247C244040404040804000403A
+:20650000408020C03080210001FC0280F48010FC1080108010FC1080148018801080008013
+:206520001040102013FEFC88105013FE1A22122233FED22212FA128A12FA1202520A2204F6
+:20654000020001007FFE04200240018006E0F81E3FFC02003FF82248224822482248201884
+:20656000020001003FFE2004400001F03E000200023C0FC0F20002000204020401FC00003C
+:20658000020001003FFE200204601818640407F80A000BF8120003F802000200020002007C
+:2065A000104017FC104023F8204067FCA00023F8220822482248224820A021182608000000
+:2065C000010000807FFE444C9FF004401FF804407FFE091037EEC1040920111825100200F6
+:2065E000008071F8521057FE5A4872A453FE520072FC520052FC540074FC548408FC10845E
+:2066000000200E20F020103E1020FC2011FC1104FF04110411FC1000100210020FFE0000FA
+:2066200008000FE010403FFC6220A51838902FFC200027F0200027F020004FF848088FF8FA
+:206640001040104010409440547E5840FE40304039FC5504550451049104110411FC110456
+:20666000204010401040007E884048405040104013FC2204E20422042204220423FC22049A
+:206680000240022003F87E0001FCFF0000B803C47C34000C3FF8248824882488FFFE0000AE
+:2066A0001000100EFEF010802080288048FE7E8808880888FE88090809080A080C0808089C
+:2066C000100011FCFD04210421FC514851FEFD4811FE1D50F15651581248124E126414403D
+:2066E000010021083FF80000101CFEE01080288048FCFE9008901E90E890089009100A109C
+:206700003FF8200820083FF8222022202FFC22203FFE2508249C2460442045188E0E0404B7
+:206720000440FFFE044000A0FE9028FEFF90AAFEAA90AAFCCE9082FEFE0082AAFEAA012A8E
+:20674000108010A01098FC9013FC3880348057FE50409048106E10381072119A160E100462
+:2067600002000200020003FC0200020002003FF0201020102010201020103FF02010000090
+:206780001040105010481E48107E13C010407C48442C4438441044307C52018A06060002FB
+:2067A0000020202010201020FE3E04204420242029FC290411043D04C10401FC01040000A2
+:2067C0004110211027FE011091F0511011F0211021102FFEC49045084608440047FE000017
+:2067E0002040302023FE42049000F3FC204040408240F27C02403A40C54004C0083E000028
+:20680000104013FE1088FC5013FE100039FC350451FC510491FC102013FE102010201020A4
+:2068200001003FFC08200440FFFE00001FF010101FF010101FF00100FFFE01000100010045
+:206840001008080C7F082210FFA400467F0C41087F1041247F46080CFF88081008200840BA
+:20686000208017FC121001208FFE500017F8140827F82408E7F820402FFE20402040204043
+:206880000080F888088C089078A040C0408043FEF8A048A008900890088808A629C4108048
+:2068A000111009207FFE40040FE008200FE000003FF001003FF801007FFC010005000200DC
+:2068C00040402F44214401488F505860584028FE2F402160C15041504148414E45644240ED
+:2068E000102010201020FDFE1020302038205420552090A0104010601090110E1604100073
+:206900000080008000847FFE008010800880088004800300010002800460181E600400004E
+:206920001080108010887C9C54B054C0548057FE54A054A05C901090108810A611C410801F
+:2069400000807C88448C549054A054C057FE54A054A054A05490109028A846C6848400005E
+:206960001040184010442FFE30406440A440224022402140208020C02130261E2804000090
+:2069800000803C802488249C3CB024C0248027FE3CA024A024902490248844A655C48880F7
+:2069A00000803FFE2080AFFC62103FFE200067F8A40827F8240827F840805FFE80800080EE
+:2069C00000407BFC4908509057FE600053F84A084BF86A0853F840404FFE40404040404030
+:2069E000100013FC1044FC441084148419143208D40011FC11041104110411FC51042000AF
+:206A0000000003FC7884488448844884490479144A0849FC490449047904010401FC010488
+:206A2000104010501048FE4011FE1040144018483028D030102010701192160A50062002BA
+:206A4000200013FC108400848904490452141408200023FCE20422042204220423FC2204B7
+:206A60000800080008047E8408480828FF10081028282F28284428845800480087FE00006D
+:206A800001FC3C442444244424943D0826FC24843C8424FC0084288824446666C2220000B6
+:206AA0003FF824483FF8010001F801001FF010101FF010101FF001007FFC01000100010015
+:206AC000044004400448444C34502460044004601450E44C4448084008421042203E400000
+:206AE000104008403EFE23483E3040C841069FF001107FFC01103FF00100FFFE010001003F
+:206B000000003FFC0104010402040404087830100FF8080808080808080808080FF80808F4
+:206B20000080404027FE2490049007FEE490249024F028002AA83254245450008FFE0000D2
+:206B40000000103C11C01100FD00110011FE151019103110D1101110121012105410281079
+:206B6000080008FC0880FE8008FE1C90E91009102A1010001FF01010101010101FF0101057
+:206B8000104010407DF012503990D1C8124A65043FF8110811081FF8011001F87E0C000843
+:206BA00022182110FFD0211E42A457E490A4FFE4145417D43C48D7C814481454155214A2CD
+:206BC000010001083FEC011001207FFE0080030007F81C08E40807F80408040807F804081D
+:206BE0002040204020443DF440487BFEA0202040F9F82308250821F82108290831F8210811
+:206C000004207FFE042005203FFC2000222022203FFE222023E020084A4449269122000051
+:206C200000804060304017FC00100210F12010A01040104010A011101208280047FE800056
+:206C40004200227E22400FC08240527E5248234826482A48C2484248428842884B084408E3
+:206C60000040F84020A0211022282446F8802310202420443988C6100060018006003800EE
+:206C8000220822487FA822283E0822483E282228FF8E4A784908510840087F88000800003F
+:206CA000010001047FFE02000FF008100FF008100FF008100FF00810FFFE04401830600CFE
+:206CC0000000FFFE14407F405578554855487F48086808587E880888088A0EAAF0CA4086A6
+:206CE00000207E201024103E102020203C2065FCA5042504250425043D0425FC210400007C
+:206D00000040FC4023FC20404BF8FC800BFC2110FAE824462BFA20E03950E24C04480040CD
+:206D20000100010001FC010001001FF010101110111011101110111002C00430180C6008FC
+:206D40001020102020203E2040207C2091FE1020FE2010201020122014201820102000200E
+:206D600008400C40087E1840104033FC5204924412441244124412A41090110C1204140057
+:206D8000102010201020FBFE1224322838403460506050A090A0112011221222141E100024
+:206DA000010000801FFE108091405220541018CE33005C3090C0230C2C3040C04700B8007F
+:206DC000408020803140212002180426E87421802620207020C8230C2818306021800600FC
+:206DE0003FF801007FFE41045D7001001D7000003FF820002FF020003FFC44504620841CD3
+:206E0000100013FE1200FE0012FC16001BFE12C032A4D2A612981288148814A658C420808E
+:206E2000202020203DFC204041F87D0891F81108FDF8110811F8110817FE149019081204B9
+:206E40000080F880888097FCA10091408A408FFC8840A84097FE80408040804080408040D3
+:206E60000440FFFE044004403FF000607C8C05B005400920351CC2083FF0148812662244CB
+:206E80001080108011F81110FE2013FC14441BFE3044D04413FC1040104010405140208052
+:206EA000010079F849104A104BF8784848484FFE784848484BF848407840484001400080B1
+:206EC00010001BFE302048208C2018203220623EA22022202220222022202FFE20000000E4
+:206EE0000880888050F82110522097FC104417FE3044504493FC1040104050402140008073
+:206F0000040004400FE010403FF8410801087FFE010801083FF80108010009000500020081
+:206F2000200027FC20403040A840A840A27C2240224022402240224022402FFE20000000B7
+:206F4000082008207F7E08443EA82A283E101C282AC67FFC010011F0110011007FFC0000C4
+:206F6000100013F810101020FC4817CC155019603250D248144E194410C017FC50002000F3
+:206F800000007FFE0080008000800080108010FC10801080108010801080FFFE000000000B
+:206FA00000400060FF40084008FE48884F0849884A5048504A204C207050C18E0E04000083
+:206FC00010201020103E7C2055FC550455245524552455245D24112410501088110C1208F4
+:206FE000010000801FFE100090005FFC504032405240927C12402240224042405FFE8000E1
+:207000004200223E242208247FA408280828FFA408220C221222113A2124C02000200020FA
+:207020000000400027FE302020200020E2202220223C2220222022202A2032202FFE00000A
+:2070400004200420FFFE0420052000803FF80010002000C003000C0030004C0083FE0000EF
+:20706000102010201020FDFE1020102039FC3488548850509050102010701188160E100457
+:207080000100010001007FFE010001001FF80810042004200240018002400C30700E000434
+:2070A00000400040F8408FFE884088408BFC890889088890F8A0884000A00118020E0C0401
+:2070C000210021802100FBFEAA92AC92A892ABD2F892A092315229723D5EEA12021004001C
+:2070E0001000100010003F7C2444444484447F4408440C440A441144117C204440408000FA
+:2071000000207C20442047FE7C20442045FC45087C884490445044204450448E55048A0063
+:207120003C802488249C24E03C84248424FC3C0025FC2504250445FC4504550489FC01047F
+:2071400020401040104080404840484017FE104020402040E040204020402040204020403A
+:207160000200010000887FFC000800100020004000800100060018002800E70040FE0000A5
+:20718000100011FC210429044904F104110421FC4000F80000900088190CE20604040000A7
+:2071A0000000FEFC248424843C84248424843CFC2484240027483C64C442048205000400CD
+:2071C000010001007FFC02001FF0101010101FF010101FF010101FF010101010FFFE000037
+:2071E00010001020102013FEFC4011F8310839F8550851F8910811F81108110817FE1000C0
+:207200000040FE4011FC104020403DF8450849F8A90819F8110821F8210841088FFE00007D
+:20722000108010801080FDF81088148818883188D08810C810A81108110A120A5406280260
+:207240001040186017FC1040208033F86208A3F8220823F8220823F8220822082FFE200008
+:2072600010001BFC108030902108727CA7C42040204027FC2040204020402FFE20000000C5
+:2072800000201020102010201020FD20113C11201120112011201D20F12447FE0000000049
+:2072A0001100113811C01104FD0411FC140019FC3104D10411FC11041104110451FC200094
+:2072C00000800080008000800880088008FC0880088008800880088008800880FFFE0000E5
+:2072E00000107C104410441044107C90549E109050905E905090509056907890C7FE000017
+:2073000000001FF8100810081008100810081FF81008042006100C08180C300640040000C3
+:20732000200020383FC0200420041FFC000000001FF0101010101FF0101010101FF01010A6
+:207340001000101C23E022204A20FA2013FE22204220FA20021002121A92E30A0206000092
+:207360000100010001007FFE010001003FFC00000100088848C448864814881807F00000F2
+:20738000084008407EF808481E4868CA08AA2B061FF001003FF801007FFE0100050002004F
+:2073A000200028BE24A2FB2427A42A2832286FA4A2222222232224AA24A42820A02040200D
+:2073C00000007FFC02000420081013F83D10010001003FF8010001000100FFFE0000000063
+:2073E00000407F601040144022FE7F880A4808487F480850082008200F5078880106020426
+:207400003FF8244824483FF801007FFC02001FF010101FF010101FF010101FF01010FFFEEF
+:20742000100011F811087D0855085508550855F8550854005C9010C8118C110612041400DE
+:207440002020202021FC2020A820ABFEA810A810ABFEA910A890B8D0C0900010005000207C
+:207460002404340424243FA4442404247FA404243FA424A424A424A42484278405140408F3
+:2074800020003F00487C0844FF440C440A7C11006FF0081008100FF0081008100FF008107E
+:2074A00000200C20F120112811FCFE2030243BFE5420545090501088108811041206140411
+:2074C0000CA07090109011FEFD10131035FC3910551055FC91101110111011FE11001100DD
+:2074E000007C3F8020802FF82080210027F0241024902490249024902140423044188810E7
+:20750000020007F00810142032404980060019006110111012A0224004200810300EC004E8
+:20752000010000801FFE1040104097FC504010403FFE50109FFE221021102110405080209C
+:207540002150115017FE015048002FFE0C44104013F81248624822482268225020402040A9
+:20756000204010401080009089084A3C57C41000100023F8E20822082208220823F8220821
+:20758000020001007FFE442218186FF4044008201FF0011001001FF8010001007FFE00004F
+:2075A0000100010021083FFC210821082108210821083FF821080100010001000100010033
+:2075C000010001001FF0111011101FF01110010001003FF82448244824482448FFFE000042
+:2075E000010001003FF82108210821083FF8010001000A00490849844916481487F0000044
+:207600001020102020203DFC41247D2491241124FDFC10201020102010201420182010204C
+:20762000020001007FFC01003FF8210821083FF80100030C0CB03840C8200A180C0E080497
+:207640001080108020FC29084988F250102020504088FB46003000101840E0300018000839
+:2076600006207820082008207DFC09241D241B2429FC2924482088200820082008200820B4
+:2076800000203C20242024203DFC2524252425243D2425FC242024204420442054208820E4
+:2076A00001F03F000100FFFE01001FF011101FF011101FF001003FF801000100FFFE0000F5
+:2076C00008400C40184017FC344424446444A44427FC2444204020402040204020400000D0
+:2076E000010001000100028004400830300EC82408200820082014502248428C81080000C2
+:20770000010002000FF00810091008900810FFFE08100A1009900890101010102050402016
+:2077200000001FFC108413E41084108417F4100413E41224122413E42224200440148008BC
+:20774000080408840884088408C44CA44AA44A948894088408841084108420842084400409
+:20776000420422242224022492245B3456AC222422242224C224442444244824502440041E
+:2077800000404060308020FC01080210FFFC1004100411FC1004100414041BFC1004000087
+:2077A0000100791E09020D427B5E43904FF041107B9E0B420D220922090209025114210837
+:2077C000202030202020FC2041FC51249124FD2411FC11241D24F12411FC11041104100056
+:2077E00000103C10241024103DFE2410251024903CD0249024102410241044105450882071
+:207800003FF800081FF800083FF800007FFE41049FF011101110111011501120010001008B
+:2078200000003E7C224422443E7C224400000FC0084008400840084010421042203E400071
+:20784000202020203C2049FE89221124FD2005FC0544FD4805480530FE30024804860904E8
+:20786000020001007FFE4004810801003FF8210821083FF82108210821083FF82008000020
+:2078800000001FF8100810081FF8104020202FF8482E8FE4082008200FE000007FFE00002E
+:2078A00007E0F25E13C2525453C8527657C2785809E02824C9280EB0092856262020002059
+:2078C0000020F920212821FC21202220F82027FE207020A838A8C124022604240820002094
+:2078E000104010401140FDFC1240384037FE544050E091501148124E1444104010401040F9
+:207900001040114011407DFC5540564054407FFE54E010D011501D48E246044408400040EE
+:207920000100110011003FF821004100FFFE01000380054009201118210EC104010001007D
+:207940000840884453F42048505097FE0840188029FC4B048D0409FC0904110451FC2104B1
+:207960004080208037E8208C0090EFFE2040208023F82D08310825F82908310821F801082D
+:2079800040402240124003FC02400440F04027FE20E0215025482A4C32462444084000401D
+:2079A00000004FFC20802100030C0C90E3602C5020CC23442C402140208050008FFE0000B4
+:2079C0002040306020443E7E509050909110121010101010101010101010101010501020C4
+:2079E000104010601040144017FC5A485248924813F8124818502448207C47C48200000098
+:207A0000010001083FD80124FFFE03000FF03810CFF008100FF0001024882244426200003D
+:207A200010801060102011FEFC2010201420182031FCD020102010201020102053FE200001
+:207A400007FC740457FC540055FC742055FC552475FC542055FC552475F4490C09141108B2
+:207A600007FE0402F7FE940095FC942095FC9524F5FC94208BFE0A2A123E13CA2202020628
+:207A800002000180010000083FFC0100010001083FFC01000100010001047FFE0000000054
+:207AA000044004407FFE044005101FF801200140FFFE02000FF83408C7F8040807F80408D7
+:207AC000108010401020FBFE102038203420502051FC9020102010201020102017FE10006F
+:207AE00000203E202220222022FC3E24222422243E24222422442744F88401140208000064
+:207B000010401020103010207DFC5420542054207DFC5020182014201E20F42003FE0000F8
+:207B200000807C404420542055FE5504560854005400540010002800240047FE8400000006
+:207B40001020102021FE3C2041FC7C4093FE1048FC8810FE110812481028140818281010AF
+:207B6000208020803EFE51208A1001F07D1011101190115011501D10E2124212040E0800ED
+:207B800009000880104817FC20406040A040204827FC20402040204020442FFE20000000AD
+:207BA00020801040104007FE804048404840104013FC2040E0402040204020402FFE200064
+:207BC000200011F81108FD0805080908110839F85490949010901090111211121212140E22
+:207BE0000040F820082049FE4820482048207E2002FC02203220C220022014200BFE000035
+:207C00002000203C23D0FA50225022502A5032506250A2482448244824442846B04440400D
+:207C200000383FE02240224022402220222022202210221022084208420C4206820400000D
+:207C40001040104013FCFE44124417FC1A4433FCD04010441028103010D21712500A2006D6
+:207C6000010001003FF802000200FFFE040008200FF00020004002800100008000400000FC
+:207C80000040FC40104013FC204020403FFE68806880A9F82808281038A0284020200000B3
+:207CA000102010202020FEFC2040504091FEFE40108011FC3C08D088105010201010101064
+:207CC00013BC12A413BCFE2012A4119C1400191033FCD11017FE10001110510C22040000B9
+:207CE0000208F90C8890ABFEA890ABFCA894AFFEA894ABFCA990219852944C9688940090A3
+:207D000020403F7E50908A0807E008201FC00040FFFE0E2071400EA0719C0E88F280010006
+:207D200010401020102013FEFE2012203A20362052FC522092201220142014201BFE10004D
+:207D4000010000803FFE20002080208020802FFC208020802080208040805FFE800000001D
+:207D60000420442037FE24200C2035FC450004807FFE0300048808503820CA100C0E080420
+:207D8000088008C0088048802FFE290809080A101A10E9A04860089009080A0C0C04080088
+:207DA000204027FC211020A0F7FE20002BF8324863F8A24823F8204027FC2040AFFE40006D
+:207DC000082008200820882048206FFE4820082018202820C820082008200BFE080008004D
+:207DE00010A010901098908850805FFE10A010A031205120911012101208140E18041000F9
+:207E0000108010A01110FDFE13203D20352051FC5120912011FC11201120112011FE1100F2
+:207E200020A020903C9021FE41207B20A5FE2120FD2021FE212021202920312021FE01008F
+:207E40004040208033F82208020803F8E20023F822082208220823F8220850008FFE00000B
+:207E600008407F40087E3EC808487F301228224646849FF011101110111002C00C303010D4
+:207E80003E4022402440284024A022A035102918220E25043FF80100010001007FFE00001A
+:207EA000000027BC308422A841104AA8F44427BC4084F4A80328031034A8C84610840000E7
+:207EC0004080204037FE200001F80108E1F8200021F8201027FE28203020202000A000400C
+:207EE00002404320222433FE26200A2813FC12201228E3FC22202220222423FE2200000087
+:207F0000100013F81208FA08120813F8144018403240D27C1240134014C01460581E200016
+:207F20001020102010201224FA2412241A2433FCD020122412241224122413FC520420006D
+:207F40000200020003F802003FF020103FF020103FF021100100FFFE010001000100010000
+:207F6000010001FC01001FF810081FF810081FF80100FFFE038005400930310EC104010089
+:207F80000000FBFE2040208421882250F4E023302D7020A821283A26C424002001400080CB
+:207FA00008400840FFFE084001002108210821083FF801004104410441047FFC40040000AA
+:207FC0000020FF202820287CFE44AA84AA04AA44CE248224FE0482048204FE148208000028
+:207FE000000007FCF0C09188930C9C9095609250F57090A801E806A6182400A000400000C5
+:20800000081004207FFE01003FF801007FFE020007F80C0837F8C40807F8040807F80408CB
+:2080200010401040148014FE5902520294821042102210222802240244044014800800000B
+:2080400040402040204000408BF84A485248124823F82040C0504048407C4F8640040000AF
+:2080600010200C300444FFFE082008201228234C7EF804500810102024447EFE020400005A
+:208080004100210029FC0A48145070A01110121C14081FF01010101010101FF0101000008A
+:2080A0004100210023FC1458E84041A046185FF6101011101110111012C00430181C6008F2
+:2080C0002100110011FE0244144870A02110260C19087FFE0220062001C002300C1C300811
+:2080E0004210211021200FFE810851085210229424A42F78C108421045244FBE40820000F3
+:2081000020001124114402888C484A24512417FC24442444E7FC2444244427FC2404000093
+:2081200000407E600240048008FE088809880E883850C850082008500898090E2A04140085
+:208140000840284C2F7028402E42713E020004C01F0004103FF81108112021104508020043
+:2081600008000BF810081010302030405FFE9040104010401040104010401040114010800E
+:20818000100011FE920452085410FE2030203BFE54205420502090201020102010A010405D
+:2081A0004080204027FE0484904053F8111020A027FC2040E04023F82040204020402040B8
+:2081C00000003FF0002000400080010001000104FFFE010001000100010001000500020080
+:2081E0000100018002001FF8100810081FF81008100810081FF81008100810081FF81008C7
+:20820000204013FC104003F8804057FE500013F822082248E248424840A04110421C4C0809
+:20822000020001003FFC200440081FE00040008001007FFE0100010001000100050002004C
+:208240001F0814301AC414187F6414183EE001003FFE20040FF000003FFC0910330801008B
+:208260001040102013FEFA04100039FC3400500053FE902010A811241622102210A010404E
+:20828000004078204BFE4A027A0451F810001C0053FE502051285DA47226C42400A00040E3
+:2082A000010000803FFE200440000FF8000000007FFE008008900C88108C20884280010065
+:2082C0001040182013FE22024800F9FC1000200043FEF820012801241A22E42200A00040AB
+:2082E0000820042004401FF01010101010101FF000000100088828842816681207F0000084
+:2083000011101110211025104910F110113022B042A8FA6802283448C44408841106220485
+:208320002000207E7E44444488487F50014801447F4201420142015A7F44004000400040E3
+:20834000010001003FFC010001000100FFFE0100110011F8110011002900450083FE0000B4
+:2083600001007FFC01003FF80100FFFE024004200FF83106C1041FF802400430181C6008B9
+:20838000204023FC2040FBFC204027FE28A0311063F8AC46204027FC204020B0A10E460480
+:2083A0000C0071F8110811081108FDF831083908550851F8910811081108110817FE1000DF
+:2083C00000001FF01010101010101FF011100100090009F8090009001500230040FE8000EB
+:2083E000020001007FFC0820082008201450224842880100FFFE01000100010001000100EC
+:20840000208010C01080FDFE210022803CFC2520242025FE2420442044504488970608000D
+:20842000200011F81108FD08050809F811083908550895F8110811081108110817FE10001A
+:20844000400021F8310821080108E1F821082108210821F821082108290837FE2000000013
+:208460007C004BF84A085208620853F84A084A084A086BF852084208420842084FFE4000BE
+:20848000100019F811082508250879F80908110821087DF8010801080D0873FE0000000077
+:2084A0001020102020203E20403E7C2090201020FDFC110411041104150419FC1104000049
+:2084C00020403E7C48901FF010101FF01010FFFC0A203498CF0604400FE0010011202310EE
+:2084E00001200520F5FC952295E29E9E91F8921097FCF24493FC024403FC02440454084825
+:208500000020FE1029FE2800FE88AA88AB54AF24C2208220FFFE82208220FE2082200020AF
+:208520001FF010101FF010101FF00000FFFE22003EFC22883E5023203E50E28E03040200F3
+:208540003FFC224422443FFC044004407C7C04403C7804400440FC7E04400440044004404F
+:20856000082004407FFE02401FF81248147810081FF810081FF800207FFE042004A00040D0
+:20858000021041202FFC214007F80578E60827F8240827F820202FFC212050A08FFE0000DF
+:2085A00000807880490049FE4A407A404C7C484048404840787C4840004000400040004093
+:2085C000020003000200FFFE02000200040004000FF808801080108020804080BFFE0000BF
+:2085E0001080188010803FFE208060806100A1FC2220222024202820302027FE2000000063
+:20860000108010C01080FDFE114032403840547E54409040107E10401040104010401040E0
+:2086200012201A3012202FA0227E6268A2A82FA828A828A828902F9028AC28462184000034
+:2086400008800C80090013FE1280348850FC90801080108410FE1080108010801080108040
+:2086600001000100111011101110291025284544818001003FF8010001000100FFFE00004D
+:20868000020001803FFE21402690248824902A8812A420C04FFC408040808080BFFE0000D3
+:2086A0000000000000000000000000000000000000000000000000000000000000000000BA
+:2086C00000000000000000000000000000000000000000000000000000000000000000009A
+:2086E00000000000000000000000000000000000000000000000000000000000000000007A
+:20870000000000000000000000000000000000000000000000000000000000000000000059
+:20872000000000000000000000000000000000000000000000000000000000000000000039
+:2087400000003FF80000000000000000FFFE010001000100010001000100090005000200CF
+:2087600000007FFE0420042004200420042004200420082008201020102020204020000030
+:2087800000007FFE04400440044004400440044004400440084008421042203E40000000BA
+:2087A00000047FFE0100110011FC1100110011041FFE00040004000400040048003000003D
+:2087C00008200820082008200820FFFE08200820082008200820082008200FE008200000A5
+:2087E000111011101110111011101110FFFE111011101110111021102110411080100000EF
+:2088000000007FFE00800080018003E006B00C9C188630824080008000807FFE000000008C
+:2088200000087FFC000000101FF8101010101FF0101010101FF010100004FFFE00000000CF
+:2088400000003FF8003002C001107D1805600980094011202118450E83000104FFFE0000D0
+:208860007FFC00001FF0101010101FF000007FFC482444445FF441044104410441144008F1
+:2088800000007FFC010003200D187110110010FC7E08141025FE1410081014102250402077
+:2088A00000003FFC01003D78254825483D7801007FFE01003D78254825483D780100FFFE77
+:2088C00000000100010001000100010001000100010001000100010001000100010000008A
+:2088E00000003FF821083FF8210821083FF801007FFC412441145FF4481440044014400893
+:20890000008000C00080008000800080008001000100010002000200040018006000000014
+:208920000000100010001010103810C013001C001000100010001008100810080FF8000031
+:208940000000003001F87F0001000100011C07E079000100010001040104010600FC0000E1
+:20896000000000F87F000100010001007FFE0100010002800240042008101018200E400464
+:2089800000201820064001800660181860080820042004400280010002C00C30301EC00497
+:2089A00000781F80100010001FFE1000100017F014101410245024224402440283FE00002D
+:2089C000000000F03F002100210021003FFC2100208020802080204024402A243194208C46
+:2089E0000100030004003FFC30242834242422442184214422242434281C30143FFC200447
+:208A0000221024902F90211022102FD020102FD028502FD028502FD248524952888E0000E5
+:208A200021082088205023FEFC4025F8250825F8250825F8250825F84402440283FE000090
+:208A4000204020203DFC40207C40B4882DFC2404FEA834A82CA83EA804AA052A152A0A260C
+:208A6000020004003FF8244824483FF801003FF80100FFFE04403FF801007FFC010001007B
+:208A8000048024A014C024B41884687C7F2008FC3E2000FC3E8422483E301430164E798426
+:208AA0000000000000000000000004000300018000C00060004000000000000000000000CE
+:208AC00000003FFC0018006000803D7C2544252825103D18012C0144050002007FFE000074
+:208AE0007FFC0408081E0FE214AA6664052027E420043E7C02407E7C12441244224442446E
+:208B000008000C000800083809C81E08E808080808080878081008040804080607FC000031
+:208B20000840084008400A400F400840084049407F4041404140414441447F46413C00009E
+:208B400000103FF800000000000C7FFE042004200420042008200820102020204020000095
+:208B6000092009200920793C0920092001003FFC010001007FFE01000100010001000100B3
+:208B8000010001003FFC01007FFE400480081FF000400080FFFE0100010001000500020078
+:208BA000010001007FFC1110092009207FFE00003FF820082FE828282FE820083FF82008E4
+:208BC000200023DC2244FA44224423DC2200FBBC8A248A248BA48A18FA188A248A42028257
+:208BE00000003FFE20802080208020802080214021402120222022104418480E900400005B
+:208C000000003FFE210021002FFC224024402FFC244020402FFE20404040404080400000A8
+:208C20003FFE222022202FFC222022203FFE200027F02410241047F04410441087F0000092
+:208C400000007FFC412041107FFC466058186FEE49244FE049204FE0492041004100810059
+:208C600000007FFE51204A205FBE44225554551055105F105510442848449086A10400001F
+:208C800000007FFE4A004A067FB84A204E3E4A284E284A287FA84A4849485088A10800006B
+:208CA0003FFE20A020903FFE214022303FFE20802FFC292429E4292449E449248FFC000043
+:208CC0003FFE25202DF82B203DF8292029FC29002FF82888288828884948422084180810F8
+:208CE00000007FFC400040004000400040004000400040004000400040007FFC00000000BE
+:208D000000007FFC4000400047F0441044104410441047F04410400040007FFE4000000009
+:208D200000007FFE482048207F78482854285F28442847487C4A4486450040007FFE0000EF
+:208D40007FFC41004FE049204FE041007FF840004FE0492049204AA0444048207FFC000046
+:208D60007FFC40804FF848084FF848004FF84D2857F8552865286528441840007FFE0000D7
+:208D80000020FFFE882089FC8820BFFEA400A5FCA524BD24892489248850FE480086010432
+:208DA0000820082008207FA008200830FFA8082408267FA40820082008200FA0F020002041
+:208DC0000100010801FC010001007FFC400440047FC4404440447FC4400440047FFC4004B2
+:208DE00000080008008800880088008800880088008800880088000800080008002800104B
+:208E000000040204834442442444144408440844144416442244434482040004001400085E
+:208E20001002180210921FD22A924A928A92129212922492C49208923082C702020A000446
+:208E400000047F04020404240A2411A460A4BF2408240824082409A40E04F0044014000800
+:208E6000040404047FA40A24112420A45F2480247FA4082408241F24010401040514020886
+:208E80000404248424A424A43FA410241F241124212451248A2406040404181460080000F5
+:208EA00008044904490449247F2400247F24012401243F24202420242104260478142008FD
+:208EC00008040904FF84082408247F24492449247F2459241C242A0429044904881408086D
+:208EE000080408047FA40C2412242124FFA401243D24252425243D24210401040514020823
+:208F0000080409042A2428244C241324222445242524262424244A04118420D440880000CE
+:208F2000080404447FE44044A0943BD42A542A544A54ABD41A94124412842714C2080000FB
+:208F400011021102FFE211127BD24A524A527BD24A527BD24A524A524A524A424D4A988419
+:208F600000027FC20A127F924A924A927F9240923F1200127FD22412350244C2948A080495
+:208F800000047FC4621454947E9449F44A546A946A947E94489449545264A444C814000836
+:208FA0002402320222127FD2A4123F9224123F92241224123FD2001254824A428A4A00047B
+:208FC0001106FFE2151222127FD2A2123FD222123FD222123FD2109209020602198A608462
+:208FE00008047F0441247924472441247F2400247F2449247F244904FFC4221422084200E4
+:2090000000003FFC20042004200420042004200420042004200420042004203C2008000005
+:209020007FFC40044824444442845FF4420441045FF4480448044FF44004401440080000CB
+:20904000008000C001800100038003000500090011000100010001000100010001000100A2
+:2090600008000C001BFE102030203020502090201020102010201020102010A010400000E3
+:2090800008000C0019F011101110311051109110111011101110111012121212140E100030
+:2090A00008400C401840104437FE30445044504490441044108410841104110412141408E3
+:2090C0000800080017FC100020003000500093FC100010001000100010001FFE10000000B1
+:2090E0001100190413FE3200240067F8A810202020402080210021022202220221FE0000D9
+:2091000008400C601840108020903110512052209C40105010881104127E17C61002100067
+:2091200008040DFE18441044104432445344524494441084108411041148122814100000A5
+:2091400010001FFE1408340C25086490A4502420242024502448248C250827FE20000000E7
+:2091600012201A2012201220322423AE6238A220222022202220222022A22322221E00004B
+:2091800010001BFC1020322023206220A7FE2020206020A021202220242028A0204000004D
+:2091A00010001FFE1100110021F0311051109290125012501210125212921712120E000054
+:2091C0000900090011FC122032205420902017FE1020102010201020102010201020000063
+:2091E000110019101118313021406180A1042FFE21402140212021102118214E21842100F5
+:209200001080188011402130221C6408ABF0221022102210227022202208220821F8200048
+:20922000110018C0104437FE200061F06110A110211021102110221422142416280C0000BC
+:2092400008400C30082013FE1A023404500090001000100010001000100017FE10000000A8
+:2092600008000BF81000100427FE6080A0842FFE21082108231020E02050218826040000A1
+:2092800008800C8018FC108030806080AFFE208020C020B02098208C20882080208000003D
+:2092A000108018C01080248025FE25086688A48824502450242024502088230E2C042000DF
+:2092C00010401A40124813FC244024406844AFFE204020A020A0211021102208240E280490
+:2092E0001100190411FE320422046404ABE422242224222423E4222420042014200800003F
+:2093000009000D0019FC130825106890B04020A023182C8E20642020208020602020000011
+:2093200008800C441BFE1204340831005108911C113011C0110011041104110410FC000045
+:2093400010001BFC1204320423FC6200A2802288229C22E02280228224822482287E000055
+:2093600012001A001200223E3FA222A262A2A2A224A224A224A228A228BE33A2212000004A
+:2093800008400C40184417FE3040304853FC9000100013F812081208120813F81208000073
+:2093A00008000FFE1A10121033F022106210A3F02210221022102FFE20102010201000009F
+:2093C00010801880108027FC210063F8A208260827F82A08320823F82208220822282210E8
+:2093E0001080188017FE3120221865E6B804200027FC2100210021F8200820082028201038
+:2094000008000FF81A081208320823F86000A2482248224822482448244A284A3046000062
+:2094200008400C401A4813FC324024406044A7FE20E0216021502248244628442040000076
+:2094400009200DA009101218320E27FC6A08A3F82208220823F82208220822282210000044
+:209460001120192011201128292C25306520A33025282924212022222222241E2800000049
+:209480000880084017FC1210212060C0A0C023302C0C211021102110221022102410281018
+:2094A00010801860104027FC22206318A20C2514291020A020A0204020A02110220E2C0423
+:2094C00010401840104427FE248468C8A140214C2330252029102108216E21C421000000B6
+:2094E00008800CC01988123C37E622446248A7FC244028442FFE20402040204020400000DC
+:209500001040184017FC204027FC4080AFFE2110211023FE2290245028503010205020208F
+:2095200010001FFE10A834AC22A862B0A7FE240024002400240024002800280030000000B1
+:2095400010001FFE1000300027BC74A4A4A426B425AC25AC24A424A424A426B42528000060
+:2095600010401850104837FE20406448A24C2350226020D023482E4624442140208000007F
+:2095800010001BF81248224833F86248A24823F82040204027FC2040204020402FFE2000BA
+:2095A00008000FF81A08120833F86000A7FC204020442FFE20A020B02118220E2C04000018
+:2095C0001040184013F8224823F87248A3F820002FFE210023F82108200820082028201084
+:2095E000100817FC1090206027FC6444A44427FC2444244427FC24442444245424480000A3
+:2096000009000D901A0817FC3008220063F8A24024402FFE204020A021102218240C28085C
+:209620001080188017FC208037F86080AFFE211026483BF62040204027FC204020402040C0
+:20964000104010401FFC104023FC304067FCA00023F8220823F8220823F822082228221022
+:209660001110191017FE211021506040AFFE2080210023F826082A08220823F822080000F1
+:209680001120192031202F3E6120A1202F3C2120212021203F3E21202120212021200000B1
+:2096A0001080188010FC208037F86408A7F8240827F8208020802FFC208020802080208066
+:2096C0001100190031FC23086C90A860299E2E4428502FFC284028A0211022082C0600006B
+:2096E00010001BF8124823F832486248A3F820402FFE20C021602258244E2844204000006D
+:2097000010181BE0104027FC21606350A44E288421003FFE221021A0206021982E0C00001D
+:209720000840088017FC144437FC5444548497FC154412401FFE1040104010401040104060
+:2097400010001FFC1444244435F46444A5F4240425F42514251425F4290428143008000047
+:209760001080184417FE3404280863F8A20823F82208220023F82208220823F82208000060
+:2097800010801860104427FE24046910A30824042BF82040204020402040204027FC0000AE
+:2097A00010001BFC1204220423FC6220A22423FE2220222023FC25042504250429FC20005B
+:2097C00010401FFC104022482FFE6208A00023F822482248224822A822902118220C2408C5
+:2097E00010001FFE140025F8350865F8A50825F8244027FE249024602450258827FE0000A0
+:2098000014201C24142E27B0242265A2A65E208023F82208220823F82208220823F82208A7
+:2098200010001BFC120423FC320463FCA10023FC26442A4422A4231427F422042014000825
+:2098400010001BF8324823F822486248A3F820002FFE22442246222822302298270E2204D5
+:209860001180190433FE24A42B247184A66428942338249020482564254A250A28F8000079
+:2098800010401A48115027FE30E06158624EAD4421002FFE2110211020E021982E08000087
+:2098A00010401A48114C345027FE6804ABF82210221023F022A020A4212422242C1C000011
+:2098C0001080184013FE2404243863C0A20023FC222022242FFE21202198220C2404000022
+:2098E00010A018D010902EFE23907290AAFE2A9024902AFE2A903290209020FE2080000027
+:2099000012001BBC14A426A82A907510A20827FE280437FC204022502348224C25482080B3
+:2099200010401FFC104037FC200063F8A20823F821102FFE200023F8220823F822080000F1
+:20994000151015182FD02520653EAFC428A436A42AA82A882E90209020A8254622840000EA
+:2099600010001F7C12102A502FFE6518A5AA294E300027F8240827F8240827F8240800001F
+:209980001140192013FC224026406BFCA24023FC2240224023FC2000254824A428A40000FA
+:2099A0001020143012282FAC20286F7CA92029202F5022502B502AD032522A92250E000000
+:2099C0001080184017FC21102FFE6000A7F8244827F8244827F820402FFC20403FFE2000D1
+:2099E00017FC14A424A427FC7000AFFE200023F8220823F8214423282D10314E23842100E0
+:209A0000110019F8121027FE7490A548262425FE240025FC240025FC240029FC290431FC52
+:209A2000010001000280044008201018200EC0043FF8010001000100010001047FFE00005F
+:209A400001000100028004601818610E01107D2005C0054009200918110E610405000200F2
+:209A60000100010002800460081817EE600400001FF8008008A00C98188C108822800100B3
+:209A80000100010002800440082010182FEE40040210111809900DA0092000407FFC0000E8
+:209AA000100011F811082908250845F881081108110811F829082508450883FE00000000E9
+:209AC000010002C00C3077EE00003BB82AA83BB800003FFC22443FFC224422442254200824
+:209AE00002000100028004400930310EC1107D2005C00940092011102108C10E050402005C
+:209B000006000180024004201918210EC92405407FFC0380054009203118C10E010401003C
+:209B200004C006800C4008201010200E5FF4840008201FF0082000200020022001400080C0
+:209B40003EF822883E8820F822843EFC044004403FFC0440FFFE04200E101818200C40087D
+:209B6000220811107FFE44421FF804407FFE01001FF011101FF011101FF004400830301093
+:209B8000841044184814FEFE10107DD245527D5445D444087CC84718442A7C4600820000EC
+:209BA000440025FC29047DFC55547D5055FC55507DFE1164FD6C1250124814E618441000B3
+:209BC0000820FFFE0A2017BC54A45EBC55A05CA2F79E140827F6CC24122021C00E30700ED1
+:209BE0000000080008000FFC1004200440040004000400040004000400040014000800009A
+:209C0000100010001FFC22445FF482041FE412241FE412241FE4122412A4124400140008F7
+:209C2000100010001FFC21043FF440049FE400041FE400041FE410241FE410040014000855
+:209C4000080008001FFC10042FE440049FE410241FE400043FE422243FE422243FF40008A3
+:209C6000010002001FF01210119010A010001FFC000407D40448044008440844103C2000C1
+:209C800000003FF8200820083FF8220823C824482A4831482088210A420A44069802000097
+:209CA00000003E7C22442244224423C420043FFC244404400440084008421042203E400000
+:209CC00000000000000004000200010001000000FFFE00000000000000000000000000007F
+:209CE000020001807FFE08200C18120C632804101FF80A500240044404440844103C200060
+:209D0000020001087FFC08200FE000047FFE400480F01F00010001F83F000104010400FC13
+:209D2000010000807FFE04200918124E24240FF00220050C08B03840C8300A0E0C040800AE
+:209D400001007FFC00001FF000207FFC02880C903280C10003080C903860CA100C0E080405
+:209D600001000084FFFE08407DF009501C92694A2A06112007700CC03430C59E0E04040071
+:209D8000010000807FFE04401450244C444485403FF8228825482908228824682848201803
+:209DA00002000100FFFE02001CF010101EF010101FF0030C0CB03840C8200A180C0E0804C5
+:209DC00001007FFE00001FF8124813C810081FF800001FF800007FFE0890108820840180A1
+:209DE0000200FFFE20003FF800003FF820083FF802007A3C4FA47AB44AAC79244AA49C463B
+:209E000001007FFC10001FF800003FF820083FF80100711C57D4755C57D4711451D4B626CE
+:209E20000100FFFE20003FF800003FF820083FF802807FFC49247BB4492C7FE4492699427C
+:209E4000800040003000140004000400080008001000F00020002000200020002000000046
+:209E600000004FFE21002100110811FC120822082208C7F042104010401040145FFE000065
+:209E800000040FC40204221413941494049428942494C31441144204440408141008000066
+:209EA00000400240424023FC34402840004417FE11201120E120222222226422281E000093
+:209EC00004008408442864284F2824442E444DA254B2D52064404448448445FC44840000BE
+:209EE00040047FFE40048008000000000000000000000000000000000000000000000000D5
+:209F000000047FFE400480083FF804000A08131034A049C016C024A04890108E22840100F0
+:209F200000043FFE20045FF010101FF010101FF002000104FFFE08400C301818300C4008D3
+:209F4000000010000C000800000078000800080008000800080008000A000C000800000017
+:209F60004000200031FE202000200020F02013FE1020102010201020142018201020002035
+:209F80004000200033FC202000200020E02020202020202020202420282037FE20000000D1
+:209FA000402020203020202002220222E222222222222222222222222BFE32022000000054
+:209FC000400023FE320023040284E2482228221022282228224422862B04320023FE000077
+:209FE000400023FC32002200020003F8E2082208220823F8220022002A00320023FE000097
+:20A0000040202020302023FE0222F22212221252124A128E130A120216021A02120A0204DC
+:20A0200040202020302023FE00200020F020102011FC110411041104150419FC1104000000
+:20A04000400027FE300820080008E3C822482248224823C8224820082808304820280010CD
+:20A06000401C23E0322022200220F22013FE1220122012201210121216AA1B2A1224000091
+:20A08000400023FC308420840104F1041228141011FC110411041104150419FC1104000022
+:20A0A00040202020302021240124F12411FC112410201222122216221A2213FE02020000CE
+:20A0C0000040404030801110020807FCF004100013F812081208120816081A0813F8020830
+:20A0E000400023FE3200220002FC0220E22022FC2220222023FE22002A0033FE2200000027
+:20A100004040204037FC2040004003FCE0402FFE20E020E0215021482A46324424400040DC
+:20A1200040402040304023F800400040E7FC2040204023FC20402040284037FE20000000F5
+:20A140004020202037FE202000200020F3FE1000100011FC11041104150419FC110400001F
+:20A160004080208030802FFE0100E120212422A422A82420245028503088210802060404AA
+:20A1800040402240124013FC02400440F7FE10A010A010A010A010A415241924121C0400E5
+:20A1A0004004203E33C02200020003FEE200220022FC228422842A84348424FC0884100055
+:20A1C0004040204030A02110020E0404E3F82040204023FC20402040284037FE200000004F
+:20A1E000410021F83210242003F80048E0482FFE2048204823F820402840304021400080E3
+:20A20000400023FE3204244003FCE04020A0212023FC202020202BFE30202020002000208B
+:20A22000400037BE208200A20492F29212821082118A129214A2108214821B8E110400008A
+:20A240000020222411A61928102001FCF10411FC1104110411FC11041504190411140108C1
+:20A2600040402240324023FC0440F040104017FE100013F812081208120816081BF81208DE
+:20A280000000408028FE249003100510E910237E22902490289020902890351022FE000077
+:20A2A000408020D0310823FC00080200E3F8244028402FFE204020A029103208240E0804E7
+:20A2C00000009FE0648024BE04A4E7A424A424A427A4249824D82D9836A428A600C4008042
+:20A2E00040002FFE106000C00108E28C2C9032E023202D7020A8292432262C2400A00040FF
+:20A30000403827C030402FFE00C00160E2582446208027FE21102B9030602098030C0C0464
+:20A32000404021C0365C24440444E75C2444244427FC204020A028A03110220804060804DB
+:20A340004040204030A02110028EE4442BF8201020202080206825442D0A350A28F80000AA
+:20A360004100210031FC220802100480E33C2204220423BC220422042A0433FC2204000075
+:20A380004080304027FE01100110E11032A824442802204027FE28403040204000400040AC
+:20A3A0004110211037FE211001F0E11021F021102FFE2200229022882B08320023FE000060
+:20A3C000404020403FFE204007FC0444E55424E427FC20E8256029503248244608440040DB
+:20A3E0004040207C304023FE0244E3F02244223C220022FC22802BFE3480248008FC10005C
+:20A40000400033FC220403FC0204E3FC210023FC26442A4422A423142BF43004201400081F
+:20A42000400027BC34A427BC0000E3F8200020002FFE210023F82108280830082050002099
+:20A440004040204030A0211807F6E8002784248427A424A424A427A42CA4348424940588E8
+:20A46000401C23E43246212803FCE080208027FE208020F82188295032202450188E030447
+:20A480004080204037FC22080110F0A017FE100013F81208120813F816081A0813F80208DA
+:20A4A0004080204037FE2208011007FEE444204023F82248224822482A483258204000408A
+:20A4C00040402840347C228402A80F20E4502488250623FC21082108290831F82108000066
+:20A4E0004040202033FC220403FC0200E20023FC2354235425FC2D5435542954110C000092
+:20A500004110211037FE211003F80208E3F8220823F8204027FE204028A03110220E040408
+:20A5200040402248315027FE0404E80023F82208220823F8212021202A243224241C0800A3
+:20A5400047FC344427FC044407FCE1102208248628FC218822882450282030D0230E0C0499
+:20A560004208218C3110202007FE0110E20824042BFE22A822A822A82AA832A82FFE0000DB
+:20A580004008208C316825500524094AE18822F82C0021FC215421542954315427FE000060
+:20A5A0004040202037FE21040088E3FE222223FE222222FA228A2AFA328A2202020A020491
+:20A5C0004208311027FE000403C4E25423D422542354228827FC2884308421040228041056
+:20A5E00000008FFE6A504A501FFE0510E52A29CC310023F8220823F82A08320823F8020822
+:20A600004240222033FE262006200BFCE22023FC2220222023FE20002AA432522452000024
+:20A6200043FC2088306027FE00A40128E6602BFC2294230C22F422942AF4320422140208FF
+:20A64000020842082FCC220A0FBEE8882D882A882F882A882A882A9428943AA229420000FF
+:20A66000410021FC320827FE0A900328E3FE220022F8220022F82A0035FC250409FC100066
+:20A680004250225832B425140010EFFE25102DD425162DD425142DD8351A25D61E22004018
+:20A6A000000007E00420042004200420042004200420042004E0044004000400040004005B
+:20A6C0001FE0004000903D3805C00960151802065FF800000FF0081008500824080407FCD2
+:20A6E00000007F004200440044004800440042004100410041004A00440040004000000072
+:20A7000000007BFE489050906090509048904490449074904910411242124412480E4000C8
+:20A720000000781C48E0482050205020482045FE442074204820402040204020402040202A
+:20A7400001107D104910511067FC5110491049104FFE691051104110421042104410481063
+:20A7600000007BFC4A005200620053F853084A904A906A50542044604890530E4C0440006F
+:20A7800000407C404440487E5040504048404BF84A086A0852084208420843F84208400011
+:20A7A00000807C80450049FE5280548048FC44804480548048FE4080408040804080408045
+:20A7C000000078204BFE4A245228622053FC4A884A884A506A505220445044884B0E400478
+:20A7E00000007BFC4808501060205050498C4E0648046BF850404040404040404FFE40009D
+:20A800000080F840884097FEA080A10892108BE08848A89093208C508088830C9C048000FF
+:20A820007840484052785240624057FE484048406A48524844504020404041804E00400066
+:20A8400000007BF84A08520853F8620852084BF84840684053F840404040404047FE400007
+:20A860000000FFE0948094FCA7A4A4A494A897A8D4A8A49085D08EA880AE80C4808080809A
+:20A88000783C4BC0504057FE6150515049504FFE49506950515047FE4040404043FC400025
+:20A8A000004078804BF8524853F8624852484BF848A0692057FE402040204020402040200B
+:20A8C00078004BFC4A4453FC624453FC48004FFE4A406A44522842304210428E4304420083
+:20A8E000004078804BF8520853F8620853F848004BFC6840504043FC4040404047FE4000F8
+:20A90000004078804BF8524853F8624852484BF848C068D051504168427C4442483E4000BC
+:20A920007BF84A0853F8520863F8500049084A144F386A9457BE4000452444924892400020
+:20A9400000007F7E0844084808480850FFC80844084208420852084C084008400840084041
+:20A9600000007F7E08420844084808500848084408440F42F04200540048004000400040D5
+:20A980000800047E3F42204420442048205020482044204220424052404C8040004000401E
+:20A9A0001000087E0844FF4820482050204820442042204220423E5400480040004000400A
+:20A9C0000800107C3E44224822482A5024503F48014401421D42E1540148194006400040D4
+:20A9E0001000087E0842FFC4104810501F4811441142114221422152214C454082400040D0
+:20AA00000000FF7E084408487F48495049485544534251426142415A414445404240004061
+:20AA20000000FF7E0844084818481C502A502948C844084208420F72704C004000400040A9
+:20AA40000000123E12221224F3A412281228122412221222323A52A493201220002000200C
+:20AA60001400147E1444154495485548565054481444154216421852E04C00400040004066
+:20AA80000700787E48444844484848507F484844484248424542555A6B4445400440004024
+:20AAA0000800087E104424484248FF5001487E4442424242424242547E484240004000407A
+:20AAC0000800083E7FA20824492429282A28FFA408220C221222113A21A44120802000206B
+:20AAE00000007F7E1044104822487F50094808447F420842085A08440F407040004000409F
+:20AB00000400247E24423F44444884507FC80C44164215422542445A844404400440044067
+:20AB200008000C3E122421A4C0283F300028FFA4082210221232212C4F2071200020002079
+:20AB40002100123E0C24122469280828FFA4102214222422482A8A2411203FA000A000201C
+:20AB60001000103E3F2221244124BD2825243D22252225223D22012A01240520022000203B
+:20AB800000007F7E524410487F48105028487F44084208420F52F84C084008400840084017
+:20ABA0000000FFDE00127BD44A544A586B545AD24A524A524A524A5A4A544AD000100010DC
+:20ABC00000003E7E2244224422483E5000487F4408427F420842085A0F44F0400040004030
+:20ABE0000800283E28223F2448288830FFA800243F2221222122213A3F2421202020002001
+:20AC00002100123E0C2213246528FFA8082414223FA264A2A4BA24A426A025200420042068
+:20AC20000700787E514429442A487F500248044408420F42F842085A0844284010400040C7
+:20AC40000800107E7F4249447F48495049487F4414422442FFC2045A04440440044004406D
+:20AC600008000A7E2A442C484C4812502148C8442A422C424C42125A1144214040400040AD
+:20AC800000007F80403E5F2451285F2851305F2848247FA252224C3A4A2471207FA00020E7
+:20ACA0000000FFBE14227F245524552855247F2208227F220822082A0FA4F02000200020C4
+:20ACC00000007FBE08222F242828FFA840247F2240227FA200AAAAA4AAA000A001A0002098
+:20ACE0002200FFBE22223E2408287F3049287F2408227F2208227F2A08240F20F0200020B3
+:20AD000008007FBE22221424FFA800303F2821243F2221223F22042AFFA4042004200420AD
+:20AD20000780F83E49222A24FFA41C282A28C9A47F22492249227F2A492449207F20002042
+:20AD4000210012007FBE04227FA404247FA825241624FFE200223F2A212421203F200020F7
+:20AD60007C00283E3FA22AA439242AA878280BA47C220DA23632CD2C34A0C4200420042016
+:20AD80003E00083EFFA288A46B2408286B2808240022EEE2AAA2AAAAAAA4EEE000200020F6
+:20ADA0000800AA80FFBEAAA2FFA4AAA8FFA80024FFA200227F2241347F28222017A0F82007
+:20ADC000040006000FF00820104020807FFC800400041FFC0004000400043FFC00040000E9
+:20ADE000040004000FE0104020805FF8110811081108FFFE0280024004200818300EC004C3
+:20AE00000020FFA0102010201EFE12221222122212222242224242424A84849401080000EC
+:20AE20002020302040207E2082FC7A244A244A244A247A444A44024412840A9C0508000043
+:20AE400000207F2011201120117C252422247F24A124212421243F4421442094010800001E
+:20AE6000082004207FA0082010FC22247F24242409243224C4440B4412842114C208000093
+:20AE8000100010007F7C11441144257C4200FFFE00081F88108810881F88108800280010B7
+:20AEA00000207E2004200820FF7C0824282410247F245524552455245FC4F0540088000064
+:20AEC0007F2041205D2041205DFC00247E2442247E2442247E44424442847E94430800009C
+:20AEE000100010FE7E92129212FE2A92C49228FEFF20559055545542594AB54822380000FA
+:20AF00000D00317821083D78210821083FF801003FF008100420024001800660181C6008E3
+:20AF200002082FC8202A2B2CB048A788A49437A248429FF80410022001C003700C1E70040E
+:20AF40003E7C22443E7C22443F7C08801FFE10803FFCD0801FFE10000FF8021001E03E1EB3
+:20AF6000000078000800080010003C000400440048002800280010002800440083FE000020
+:20AF800000002004200420042004200420042004200420042004200420047FFC2004000062
+:20AFA00001000100010041245F3443444384454445244914511C651442047FFC400400000E
+:20AFC000010004A022443194294C22242C943FFC0000103011C01E00100410040FFC000089
+:20AFE0000100018001000100020002000400040008200810100820FC7F8620040000000024
+:20B0000002000320041008083FFC100804200420FFFE042004200420082008201020202023
+:20B020000200042008F01F080108FFFE044008201FF8311ED1141FF0111011101FF010108E
+:20B040000040F8200FFE104010502888C5FC00047D481148114811481D4AE24A02460400B7
+:20B0600008800C40082010182FEE44248420082008A011407FF8010001000100FFFE0000EB
+:20B0800000003FFC02402248124C1A4812507FFC010001003FF80100010001007FFE000073
+:20B0A00010A01890109E3FE030885090906011A2161A110601001FF8010001007FFE000052
+:20B0C0001040FE4001F87C4845487CC800687C58084A108AFE8611005FF8210001007FFEA1
+:20B0E0000800FF7808487F48494A7F8E49787F48083049487F8601007FFC01000100FFFE49
+:20B1000002000100FFFE112025FC7B2015FC7D20252009FC3120C1FE01007FFC0100FFFEC0
+:20B1200010001E0010FCFF4481487E2824105A10A5287E46C5807C0001003FF80100FFFEFD
+:20B14000000013FE10201020FC20102017FE10201020162018206020802000A0004000004F
+:20B16000100011FC10001000FE0011FE1080108010FC16041804E004400400480030000083
+:20B18000108010C0108011FE1100FA0015F81010102010401C803080C102010200FE0000E8
+:20B1A0000000120412441244FE44124412441244124412443A44C4440444080410040000EF
+:20B1C0000040102013FE1200FE00120012001200120012001E00E200440004000800100024
+:20B1E000000011FC10041004FE04100411FC11001100110011001D02E102410201FE00006F
+:20B20000000011FC110411041104FF0411FC11041100110011001F00F102410200FE000037
+:20B22000000013FE12401240FE4013FC12441244124412441A44E4844484093812100000C3
+:20B24000100811FC11001100FD0011FE1110111011101D103210C2100410041008101000A7
+:20B26000000813FC12001200FE0013F812881288125012501A20E4200458088E110400004D
+:20B28000110811081108110813FEFD081108110811F8110815081908E10841F80108000077
+:20B2A00010A0109810901084FFFE10A010A810AC112815301920E26044A20922101E0000A9
+:20B2C000104010401040107EFE401040104011FC110413041D04E10441FC0104010400008C
+:20B2E00010401040107E10407DFC11041104110411FC15041900E1004200020004000800A8
+:20B30000100811FC11001100FD0011FE1120112011301D2CF22642240420082010200000F4
+:20B32000200823FC22202220FA2023FE222022202220222022503A92E74A42260022000006
+:20B340000040102011FE12041208FC801088109C10B010C016801884E0844086007C000016
+:20B36000100013FC12041204FFFC120412801288129C12E01E80E28444840484087C1000BD
+:20B38000100011F8110811481128FD2813FE1108114811281D28E3FE410800080028001059
+:20B3A0002110219021102210FA7C249427D42094211422A43DA4E6C4004400940108000004
+:20B3C000100017FE109010907C90109414961294129812901C90E090409000900FFE000033
+:20B3E000100013FE104010401088FD0413FE1144104013FC10401C40E040404007FE0000DD
+:20B40000100013FC1204120413FCFE0412F41294129412941EF4E2944204021402080000EA
+:20B42000102011241124112411FCFC0011FC1004100411FC11001D00E102410200FE0000A0
+:20B4400020042E1E22F02210FA10245E27502150295025503D7EE20005800860101E00001E
+:20B4600010401060108013FE1202FE0212FA128A128A12FA128A1E02E202420A0204000015
+:20B4800010801060104017FE1000FD08129412641264126412941F14E20443FC0204000026
+:20B4A00010801060102413FEFC401088111013E01048168C1918E63040CC03061C040000E9
+:20B4C000100013F812081208FFF81208120813F81244124E1E30F2204218028E07040200DA
+:20B4E000100011F81108110811F8FD08100013FC1040104013FC1C40E04047FE0000000064
+:20B50000000827882488248824FEFC8827C824A824A824A83C88E7884488002800100000EC
+:20B5200011FC11041104110411FCFD24102013FE122212521E4AE28E430A0202020A02047D
+:20B5400011FC1104110411047DFC100013FE1222122212221E22E2424050008C03060C04D0
+:20B56000101E13E0100412461124FDB81128100813FE10881C48E048400800080028001046
+:20B580001040102011FE1102FC0411F81000100013FE10A01CA03120C1220222041E0800E1
+:20B5A0002040204027FC20402040FBF8220823F8220823F822083BF8C20802080FFE00002D
+:20B5C0001040104013FE10A01090FD48124613FC124813F81E48F3F8424A0042003E0000FC
+:20B5E000100011FC110411FCFD0411FC1080108411FE12541C94E12446440184061400087F
+:20B600002040208023FC224423FCFA44224423FC20A0212027FE3820C02000200020002005
+:20B620002040204020A02110FA882446280423F8201020202C483124C522050A09F80000F6
+:20B64000200023BC22A422A423BCFAA422A422A423BC22A43AA4C4A444A40944105400884A
+:20B660002100210021F82110FA2027FC2244224423FC224438A0E0B0412A0222041E08008F
+:20B68000200023F8200821F8F80823F8200027FE24442BF822483A48E24842580040004013
+:20B6A0001040104013F81048FFFE104813F81040124411683CD0E148424E0444014000803A
+:20B6C000200023FE22022202FBFE22102292229222FE22923A10E292449204FE088210004A
+:20B6E00021482148214827FE2148FD78210021FC202023FE20603CB0E12842260424002048
+:20B7000000002FFE20902090FFFE2492249227FE204020403FFCE040404000400FFE000026
+:20B72000200023FC22A422A4FBFC204020202FFE2100210821FC3908C208020804280810BA
+:20B740002200237822082208FDFE24802CFE3520262025FE3C20E4504448048C0486050412
+:20B76000200027FE200021F8FD0821F8200023FC22A422443BF4E244424402540248000047
+:20B78000200027FE24402480FDFC250425FC250425FC242024A834A4C9220A2210A02040C0
+:20B7A00021F8210821F82108F9F8200023FC229423FC20003BFCE1084090006001980606EB
+:20B7C000204027FE242025FC2424F7FE242425FC242025FC3D24E5FC452409FC0924112C5A
+:20B7E000240022F8282824ACF4AA234A22682490284027FC20E03950E248444C0848004044
+:20B80000000023FE220223FEFB2422A8227022A823263AA0E2FC452007FE08200820102092
+:20B8200008787F48084E3E80497C7F2840105FEE81003FF8054019306FFC091008900FF043
+:20B8400008207EFC08203EFC22483E30145CFF8802001FE012201FE01520FFFE01000100AF
+:20B8600010201130FEA0103E7C540090FE9885247C4600827C0044507D4A29422D46F03CA7
+:20B88000044004400440FFFE04400440044000000000000000000000000000000000000013
+:20B8A000042004207FFE04200420020002003FE0022002200420042208221022201E4000F0
+:20B8C00004200420FFFE042004001FF0041004200420047C08040804080410441028201030
+:20B8E00004200420FFFE042004200100010001003FF80100010001000100FFFE0000000080
+:20B90000044004407FFC0440044000383FC001000100FFFE01000100010001000100010060
+:20B920000440FFFE044004403FE004400440048004F80A100A20114010C02130460E980471
+:20B9400004200420FFFE0420042002007FE0022012200C20072005A009223022C01E000052
+:20B960000440FFFE044004403FF8000800081FF8100010001FFC0004000400040028001021
+:20B9800004400440FFFE044004403FF0001000101FF0100010001004100410040FFC0000D5
+:20B9A00008200820FFFE0820040008201FC00088030C1FF008200040008003000C007000FA
+:20B9C00008400840FFFE0840094001003FFC01000100FFFE0280024004200818100E600484
+:20B9E00004400440FFFE044004403FF800000000FFFE04400440044008440844103C200036
+:20BA0000042004207FFE042004201FF800000000FFFE020003200410080811FC3F08000068
+:20BA200008400840FFFE08400100FFFE010001001FF011101110111011501120010000002C
+:20BA400008200820FFFE092001007FFC010001001FF008200440024001800660181EE00434
+:20BA60000420FFFE042000003FFE210021002FF82108210822082208440848489030000099
+:20BA800004200420FFFE04203FFC2000200027F024102410241024504424440483F8000070
+:20BAA00004200420FFFE04203FFC200020003FF0201020103FF02010200020003FFE000037
+:20BAC00008200820FFFE0820104010401040104C1E7010401040104412441446383C1000EF
+:20BAE00008200820FFFE0820082001000100110011F811001100110011001100FFFE00003B
+:20BB000008200820FFFE082009203FF8210821082108228824682848300820082028201057
+:20BB200004400440FFFE044000001FF01110111011101390129016900484188460780000E3
+:20BB40000420FFFE042004200800086008800900FFFE09000880084008300B1C1C0808001A
+:20BB600004200420FFFE04200420000008200820082018501450224822884106860400000F
+:20BB80000420FFFE042005200100028004400A30318EC1041FF00020002000400040008067
+:20BBA000042004207FFE042008000FFE12442244C444088410846104020404041828601080
+:20BBC000042004207FFE042010001FFC10082110410001000280024004200818300EC004BC
+:20BBE00004400440FFFE044000783FC0210021003FFC20802080208020482C487028201004
+:20BC00000440FFFE044000000FE008200820101C2FE004200420024001800660181E60041A
+:20BC2000042004207FFE0420052000803FFC01000180016001300120010001000100000003
+:20BC400008200820FFFE0820092000803FFE200440080000000000000004FFFE000000001C
+:20BC6000044004407FFE04407F000240044008400A400C403840C84008420842283E10000E
+:20BC800004400440FFFE044000082408220823082208201020102410282830442086030423
+:20BCA00004200420FFFE042001007FFE010001003FF8034005200930111C2108410001002B
+:20BCC00004400440FFFE0440044008200820FFFE082008200FE00820082008200FE008203C
+:20BCE00004400440FFFE04407FFC00800100010003200518190C610801000100FFFE0000B1
+:20BD000004200420FFFE0420010801087FFE02800288049004A008C411842286407C000022
+:20BD200004400440FFFE0440022002107FFC040007F00A200A20114010802160421C8C08E8
+:20BD400004400440FFFE04401FF8100810081FF8100810081FF8100810081FF810081008FE
+:20BD600004200420FFFE042000001FF0101010101FF0101010101FF010101010FFFE000070
+:20BD800008200820FFFE092009203FF8210821083FF821082108FFFE2008204820282010ED
+:20BDA00004400440FFFE044000003FF8200827C824482448244827C824482008202820102D
+:20BDC0000420FFFE042008200C4008401040304057FE904010401040104017FE1000000068
+:20BDE00004400440FFFE044014501810101037FE30105110909010D01090101010501020A8
+:20BE000004200420FFFE05200100028004601918E0865FF8001000200240018000C00080B0
+:20BE20000420FFFE042002000FF008100A10095008200FFC00047FF4000400040014000863
+:20BE40000420FFFE042004200600387C204420443E442044204426443854204800400040CF
+:20BE600004207FFE04200020060038FC2284228422842E847284249C048808801080208005
+:20BE8000042004207FFE0420042000007FFE4104810801003FF80100010001007FFE000092
+:20BEA0000440FFFE044004407FFE400480083FE0042004207FA00420042404140408040076
+:20BEC00004200420FFFE04201FF8100810081FF810801FFC1080104012441424381410081E
+:20BEE00004200420FFFE042004203FF804080408082810102FF80808080808080FF80808A8
+:20BF000004400440FFFE04400440FFFE044004403FF8244824482438280830083FF820085D
+:20BF2000044004407FFE05407FFC01003FF001101FF011001FFC0284044C0820101C60082E
+:20BF400004400440FFFE0440023C3FC0021801641EC400387FF8044004420842103E200089
+:20BF60000420FFFE0420042020803E9C20E020822C7E31000100FFFE01000100010001005F
+:20BF800004200420FFFE0420004004440446244C275824602440244027423C42E03E000026
+:20BFA00004200420FFFE042004201FF8100810081FF800003FFC2004200420043FFC200490
+:20BFC00004400440FFFE044004403FF820082FE8200827C82448244827C82448202820101C
+:20BFE00004400440FFFE044004403FFC2004200427E42424242427E4200420043FFC200464
+:20C000000420FFFE0420152011001FF811002100FFFE0380054009201118210E41040100C0
+:20C02000044004407FFE0440781C09E0102020207FFE0420282011FC2800460081FE0000E7
+:20C040000440FFFE044004F03F0002007FFE044008203018C426042004200820102020202B
+:20C0600004207FFE042008400C501848104037FE504090A010A010901110110812061404F8
+:20C0800004207FFE0420042008000C1C13E0304050409FFE104010401040104017FE100092
+:20C0A00004207FFE042008000CFC100028004DFE1810281048108810081008100850082028
+:20C0C000042004207FFE042005000280046008183FEEC10401001FF0010001007FFE0000EB
+:20C0E00004200420FFFE05200280044008303FEEC00400087FFC0420081011F83F100000D0
+:20C1000004400440FFFE044014401FFC100420044FC408440FC4084408440FC408540008AE
+:20C1200004400444FFFE0440020007F0082014C0230004080FFC3808C80808080FF80808CC
+:20C1400004207FFE052004A07FFC0820064001800660181EE4240420042008201020202087
+:20C16000044004407FFE044001007FFE08200C10102C24284440024001800660181EE00465
+:20C1800004400440FFFE044005407FFC0220041008F81F100440044004440844083C100041
+:20C1A00004200420FFFE0420200017FC88406040504010401040E040204020402FFE20001E
+:20C1C00004400440FFFE044004407FFE4104890809001FF821000100FFFE010001000100BD
+:20C1E000042004207FFE04207FFE41048100010C7DB0054009201118210E41048500020047
+:20C2000004200420FFFE04203FF800081FF800083FF80020FFFE08200620042000A00040B1
+:20C2200004400440FFFE04401FF010101FF010101FF01208110C109012601430380E1004E1
+:20C2400004400440FFFE04401FF0101010101FF01080124021B0248E4204818000C00080CB
+:20C26000042004207FFE042004203FFC08880690148008807FFE0080014002300C18301060
+:20C2800004400440FFFE04407E20042008200AA00CA83924C9220A220C20082028A01040AD
+:20C2A00004400440FFFE0440100011FC22207C20082017207C2020200720782023FE00009F
+:20C2C00004400440FFFE04401010121025FE781010102E9070D000900E10F010405000202C
+:20C2E00004400440FFFE04400480108010FE7D0412281020102010501C50E08801060204F7
+:20C30000044004407FFE05401FF801007FFE40049FE8004000807FFC01000100050002002F
+:20C3200004400440FFFE044004487C0847FE440844887C484468444844087C0844280010BF
+:20C3400004200420FFFE04200FF0081008100FF001003FFC2104228424642824201420080F
+:20C360000420FFFE042004F83F8001007FFC05200918310E7FF40420043808080828101089
+:20C3800004200420FFFE04200F5074480448FFFE044407481C5064220452048A1506080040
+:20C3A000042004207FFE08200FFC10002FF049100890FFFE091008900FFE0010005000202A
+:20C3C00004400440FFFE04400840088014FE350856889490145014201450108811061604AE
+:20C3E000042004207FFE052010C0188017FC300050109218111011A0112010001FFE10005E
+:20C40000042004207FFE05200280044008303FEEC1043FF809000D2019102118451002001C
+:20C42000044004407FFE044005400280046008183FE6C00412200DB0092000407FFC0000AC
+:20C4400004400440FFFE044004383FD0121809201FF000400080FFFE0100010005000200A0
+:20C460000420FFFE0420042000F83F10121809100A20FFFE04200420024001800660381CDD
+:20C480000440FFFE044004404490288817FE28A0C8A018A028A048A0892209222A1E140070
+:20C4A00004400440FFFE0440440028401048294CC9501560264044A0849005182A0E1404E1
+:20C4C00004400440FFFE044005403FF8082006300440FFFE010001007FFC010001000100F8
+:20C4E00004400444FFFE044001043FFE200440080FE000007FFC0480048008821082607E55
+:20C5000004400440FFFE044005401FF010101FF010101FF01108109810601430381C1008BF
+:20C52000044004407FFE04407FFE42048FF00A10095008200FFC00047FFC0004001400082B
+:20C5400004400440FFFE04401040184027FC7C40094811482D4871F800421C42E03E000045
+:20C560000440FFFE05403FF801001FF00100FFFE00001FF010101FF010101FF01010103023
+:20C5800004400440FFFE044008207FFC08200FE008200FE00820FFFE08200C101018201040
+:20C5A00004400440FFFE0440144010FC1080FE8010FE38903490549051109110121014107E
+:20C5C00004400440FFFE144010907ED0108839083546366454405090910813FC1108100061
+:20C5E000082008207FFE08200FE001001FF011101FF001003FF801001FF001007FFE000051
+:20C6000008400840FFFE094009407FFC02400C3037EEC0047FF80100212031184508820048
+:20C620000820FFFE09207FFC01003FF00110FFFE01103FF00400FFFE08200E4001E03E1C01
+:20C64000044004407FFE144010901088FFFE108014F81988F150525014201850518E260487
+:20C6600004400440FFFE0440100011FC1E881088FF8808504A5069204950888E29041200A6
+:20C6800004400440FFFE04401FF010101FF010101FF000003FFC20043FFC20043FFC200447
+:20C6A00004400440FFFE0440082008207E3E4A204A204AFC4A844A844A844EFC0884080043
+:20C6C00004400440FFFE04400D38310821083D78210821083FF8028004400830300EC004AC
+:20C6E00004200420FFFE0420152010801FFC30805FFC908010801FFC108010801FFE1000DE
+:20C7000008207FFE08A009201FF011101FF0111012101FF005000900FFFE01000100010004
+:20C7200004400440FFFE04403EFC228422943E8822FC22C43EA8229022A842C64A84848094
+:20C7400004200420FFFE042007F0082010403FF8510811081FF802A0029A0492187E600077
+:20C7600004200420FFFE0420042007F0082010400680187810081E78100810081FF810089A
+:20C7800004200420FFFE052004A03FFC082008200850148823040100FFFE010001000100E4
+:20C7A00004400440FFFE0440102008207F5010481EA6131012101240222022184A1084007C
+:20C7C00004400440FFFE044023F81A08920843F86A084A0813F86208220822082FFE2000A4
+:20C7E000042004207FFE052000807FFE40049FF8020004000FF01810281048100FF00810A3
+:20C8000008207FFE0A2009207FFE40049FF8101010101FF010001FF0101010101FF01010EB
+:20C820000440FFFE044005407FFE400490081EF022904290A49014B008841084207CC000CF
+:20C8400004400440FFFE04407FFE4204842008401F88027C3F84112019102118451002008E
+:20C8600004400440FFFE044004407FFC05500950115015503948D2481268125454F628448B
+:20C88000042004207FFE04201FE00040008049244544438445445934452442047FFC4004AF
+:20C8A0000420FFFE042008007EFC08243E4408447E9C0908FFFE010002C00C30300EC0048E
+:20C8C00004400440FFFE0440044808087E0808FEFF08088808487F6808480F08F828401002
+:20C8E00004400440FFFE044008207FFC08200FE008200FE00820FFFE1220131814101FFCDD
+:20C9000004200420FFFE04200420080008FC7E8418FC1C842A844AFC8884088408FC0884AC
+:20C9200004407FFE044804443FFE20403FC02448244C3F482928293026204952514AA08459
+:20C9400004207FFE042804243FFE20202FA02AA42AA42AA82A902210251049AA50CAA084D6
+:20C96000042004207FFE042010801E9010E414843A7C14001FF010101FF010101FF01010AD
+:20C980000440FFFE04401FF010101FF000007FFE10101FF010101FF01010FFFE00100010BC
+:20C9A0000440FFFE05401FF011101FF00100FFFE00001FF011101110129012400430182003
+:20C9C00004400440FFFE044004401FF011101FF011101FF0010028A82824283647E4000035
+:20C9E00004400440FFFE04403EF822883EF800003FFC0000FFFE04000FF004100090006019
+:20CA000004400440FFFE044013F81A08320853F890401FFE10E01150124E144418401040FD
+:20CA200004200420FFFE142021FC7D244524452445FC7D044500450045027D0240FE00009D
+:20CA40000440FFFE05407FFC00001FF010101FF000007FFE4004BFF8010001000500020016
+:20CA600004400444FFFE0440111009207FFC054039380200FFFE04400C40038006703808A6
+:20CA800004400440FFFE0440243C13C0421C22E02AA40AAC1290F290228824A625C428808D
+:20CAA000042004207FFE05203FFE20045FF800000FF008100FF008100FF000007FFE00002A
+:20CAC00004400440FFFE044000003EF822083EF820083E0020FC20883E50202020D82306DE
+:20CAE0000440FFFE05403FFC01001FF802007FFE082017D0210E5FF405400930112001009D
+:20CB000004207FFE05281FFC01407FFE02600F88740803F800000FF808080FF808080FF8C9
+:20CB200004407FFE04403FFC20002FF820003FFE244825302E0E24243FFC422042A080408D
+:20CB40000440FFFE04401FF0121011101FF00400FFFE083037CEC44407F800083FC8001883
+:20CB60000440FFFE044000001FF011101FF0129014501FF0020009882924283647E4000073
+:20CB800004400440FFFE044010401FFC32106120AFFE200023F82208220823F8220800001D
+:20CBA0000440FFFE044008400D201218244E4FE400203E7C12240A14122422440A140408B8
+:20CBC0000440FFFE044005407FFC00000FF008100FF000003FFC200427E4242427F4200805
+:20CBE00004207FFE052004A01FFE9000740057F814803880DFFE114021202218440E880488
+:20CC00000440FFFE044005407FFE0240119012501FF001003FF8228824482FE82048201874
+:20CC200004207FFE052000803FFC04207FFE420481003FFC040007F0081008101050202005
+:20CC40000420FFFE042008403FFC04803FF80488FFFE04883FF80CC014A0249C4488048075
+:20CC600004200420FFFE04202200147C7F4408442A7C2A443E7C2A440884108421144208AF
+:20CC800004400440FFFE0540408037F8A40857F8540817F81488E450242025182E062404C8
+:20CCA000044004407FFE04407FFE410482C80C303FEEC1041FF81120093009407FFC0000AC
+:20CCC000044004407FFE0440FFFE0410282010FCFE8414A418A410A410A41050508E2304E3
+:20CCE0000440FFFE044008007F20083E3E422AA42A203E201C502A504A88888609040A00EF
+:20CD00000440FFFE04401FF812481FF800007FFE4002BFF808000FC0124011441644183C64
+:20CD20000840FFFE0840090037DC244427C424442C4477DC2000084008400844103C200064
+:20CD400004400440FFFE14401820303C4920892017FE3020D23C12201220152014FE18000E
+:20CD600004200420FFFE042008401440227E5D48808812484B282A1024280F4678840100BC
+:20CD800004200420FFFE2420148000FEFD0022803CFC252027FE24202450448855068A04CA
+:20CDA0000440FFFE0440140009FC250424842FE4348427E4248427E4248427F42414200858
+:20CDC0000420FFFE242013FC4A002BF8120813F8620023FE21007FFC05400930310EC104AC
+:20CDE0000440FFFE044005407FFE4022BE3C002000FC7F4814481430144A248623FE4000A4
+:20CE0000042004207FFE052004A07FFE400493F81840308053F8920813F8120813F8120801
+:20CE20000440FFFE04403E7812480A38134862880C4031B0C60E38E0071838E00700780007
+:20CE40000420FFFE05203FF801001FF011101FF011101FF001083FFC020829A4293647E440
+:20CE60000440FFFE04407FFC04403FF824483FF810101FF010101FF001007FFC01000100B8
+:20CE800004200420FFFE04207FFC51204A207F7E4494551055105F284428444488469084D7
+:20CEA0000420FFFE042004107F50107E3250CC901A7C2A10CD1035FEC4800470280E100000
+:20CEC0000420FFFE04201FF010101FF010101FF00000FFFC22883E5022207F50028E0304C5
+:20CEE0000440FFFE04403E0022503E4800407FFC22403E2422283E1023B2FE4A02840200BB
+:20CF00000440FFFE04401FF812481FF800007FFE40028FF408100FF008100FF008100FF07D
+:20CF200004400440FFFE044000F83F100520FFFE054019307FFE11141FF011101FF0101030
+:20CF400004200420FFFE0420220E14707F4049407F7E49487F480848FF480888088809084F
+:20CF600004207FFE042004203E4820483FFE20483E482048FFFE100012482F447A8421004E
+:20CF800004400440FFFE04407E902090239E3C90479E4490A8901B9E1090209047FE8000BE
+:20CFA0000440FFFE04403FF824483FF800007FFE4004BFF810403E484470A842103E600078
+:20CFC00004207FFE042014203110455097DE102427E46024A7A42498249828A428C6308419
+:20CFE0000440FFFE05403FF80820FFFE00001FF010101FF010101FF000082906289247F0BA
+:20D000000440FFFE04400540FFFE08A0109024FC799016FC249078FC0890109020FC40808A
+:20D0200004400440FFFE144092405444FF7E3888568893482028FE10282848243046CE84DD
+:20D04000042004207FFE042000403E2023FE22843E4821FE3E20522052FE5E20922000206D
+:20D060000440FFFE044023FC2200FAF82A002BFE4A944AC84A9433FE2A104490849008304C
+:20D0800004407FFE05403FF801000FF000007FFE40049FF008201FF001103FF801007FFE06
+:20D0A0000440FFFE04403FF801007FFE41049D700000FFFE08003FF8244824482448201034
+:20D0C00004407FFE04403FF00100FFFE193015501FF001003FF801007FFE24482226422491
+:20D0E00004400440FFFE044020883E5025FE7E20AAFC3E202A203FFE00200E2070200020E7
+:20D1000004207FFE05203FFC042007E000003FF8244827C821087FFE03400530191C6108B5
+:20D120000440FFFE04403E8008FC7EA41D242A54498806401930E54603800D603118030000
+:20D1400004407FFE04403FFC01007FFE5144892010803FF850809FF010801FF010801FFC63
+:20D1600004207FFE04A040F020800FFEE8842BE028882FF029082AD02CE0215056488FFE74
+:20D180000440FFFE244037C0249E57C01D4037FE6548A7C821082FE821082288244828586D
+:20D1A0000440FFFE24503F206A7CBFA82A103F5E02640F8004101FF809480D203110020056
+:20D1C0000440FFFE14407DFC44907DFC40207DFC44207D200120FFFE03C00D30310EC104F8
+:20D1E0000420FFFE05203FFC24203EFC2E7035A822443E7C22402E7822405E7C424082400D
+:20D200000420042004200420042004207FFE0420042004200820082010201020202040001D
+:20D22000010000807FFE04401450144C2444094014A00420FFFE042008200820102020207E
+:20D24000010001007FFE02400430181EE00451101110111011101110211021104110801097
+:20D2600002000200FFFE044008201FF8300E544412601080114012301C2010003FFC100028
+:20D28000020002007FFE042008183FFEC8240FE008200FE00820083EFFE0002000200020ED
+:20D2A000020001007FFE04401450244CC9481080210001007FFE028004400830101C600804
+:20D2C00000F83F2012300960054008E01F80061008F81F9001007FFC02800C60301EC0043F
+:20D2E0000220222022203FFE02207E20222022FC420001007FFE028004400830300EC0046B
+:20D30000104010607E8010FC290445F4BE940094FE9420F47C94248804820482147E0800EF
+:20D3200002000200020002007FFE028002800280048004800880088210822082407E800056
+:20D340001040106010401040FF7C14841504144414241434242424044414440A87FE0000CE
+:20D360002040204020A02090FD0829162A942C9028902890291049104A12880287FE000052
+:20D3800020902090229EFE902AA82AC4288029FC2954295429544BFE4800880287FE00003B
+:20D3A0000200020002007FE00200020002C003000E00720022000200020002000A00040089
+:20D3C0001000120010FE1202FE02120216021A023202D2021202120212021202520A2204E7
+:20D3E000102010201020FDFE104014401BFE3080D08011FC1008101010A0106050302020C0
+:20D40000102010201020FDFE1122152219FE3122D12211FE1020102010201020502020203B
+:20D42000108810C810881108FD0813FE1B0815883148D16811281108110811085128211015
+:20D44000104010401088FD0413FE10021488188837FED0881088110811081208540820083F
+:20D46000111011101110FA7E12921792151219123212D4921FA210A21042508A23040000C2
+:20D4800010201020102013FEFC2010201BFE10003000D1FC110411041104110451FC2104B3
+:20D4A000103C13C01040FC4017FE10A0149019083296DC90109010901110111052102410EB
+:20D4C000100010921124FA48112410921400188030FCD104128810501060104051802600EE
+:20D4E000100011F81108FD0811F814001BFC12243224D3FC120012001202120251FE2000AB
+:20D500001000101E13E0FC441128149018083008D3FE100810881048104810085028201074
+:20D52000100013F81088FBFE1088108817F818803100D1FC13041504190411FC510420009B
+:20D54000100011F810401040FBFE10A015101908324EDC44126812541654104051402080B8
+:20D5600020002FFE24A4FCA427A824A82CB034A867A4A4A224A227B22CAC20A0A0A040A0FB
+:20D58000200023FE22002220FA2023FC22202A2033FEE220222023FC24202420AFFE500008
+:20D5A0001040104017FEFC4010A015101A0E35F4D00017FE104012481244144651442080E0
+:20D5C0001040104013FCFC601090130C17FE180833C8D248124813C810081008502820102A
+:20D5E000100013FE1202FEFE122216221AFA1222322AD22613FE1202120213FE5202200034
+:20D600001020104013FC1224FE2413FC12241A4433FCD0A011201FFE102010205020202083
+:20D6200010001100110011FEFE4212521562184237FAD0E21152125A14421042504A20041C
+:20D640001040102013FCFC001108109014A01FFE3000D1F8110811081108110851F82108E6
+:20D660001040102013FCFA04120413FC1A303228D3FE12201220145014501888510E26042E
+:20D680001040102013FEFE0213FE120016FE1A8232FED28212FE128214821482588A20844C
+:20D6A000100013F8124817FEFA4813F8180033F8D2481248124812C810A01118560C200845
+:20D6C0002290229027FEFA9022F022002BFC30406040A7FE20E0215022482C46A04040407A
+:20D6E0001040104017FE10E0FDD011481A46140433F8D20813F8120813F8100057FE20002D
+:20D70000100013FE120012F8FE8812F816881AF83240D3FE12901260125C138853FE2000BB
+:20D72000221022182210FBBE24222844279032106FD0A210221022A82328A2464084000003
+:20D740001040104010A0FD1813FE14041BC4125433D4D25413D412541254124452CC22443C
+:20D760001040102013FCFD08108814901BFE100031F8D108110811F81108110851F82108E8
+:20D780001040102013FE1204FC0011F8140019F83108D1F8110811F81000100057FE2000FF
+:20D7A00027FC24042404FFFC240824882C5035FE6488A48827FE248829082908B208440823
+:20D7C000100013DE1484FAA8111012081BF63440D04017FE1040106010901088510C2204AE
+:20D7E000108010F8110811F0FC1013FE1480194C3E70D1B0166810A813261C2450A0204033
+:20D800001040107C104013FEFE44124017F81A44323CD2001240152415A21A8A5088207834
+:20D82000100013FC12441244FBFC12441AB4131433FCD0001040152415221D0A50F820008D
+:20D84000201E27E02420FC3C242025FE2D2435F86522A51E250029782A48324AA48A4106AF
+:20D860001218111010A0FFFE112017F811281FFE3128D7F813301528152819265124212040
+:20D880002000245E2292F7D2211E291235526552A7DE21122112222222222442A84A408422
+:20D8A000100013FC1204FBFC129012901BFC129033FED2C412A81490148818AE50C4208004
+:20D8C000100017BC1084FC8413BC12201A2033BED0821492138A129214A21082528A2104A3
+:20D8E00011F010901060FCB0110817BE1C94134834D4D7FE104010E01158164E5044204094
+:20D90000100011FC1124FDFC112411FC1440188831F0D04411FE10221128112652A220404C
+:20D92000200027BE24A224A2F6AA26AA230834946822A0402FFE209021A02070A18E4604E2
+:20D940002040202027FEFC902490249027FE34906490A4F0240024002AA4AA5256520000E3
+:20D960002010279821102110FFFE24A227A234E464A4A794249824C827882C94A0A640C40E
+:20D98000100013DE1042114AFCC6114A1A22104031FCD104110411FC1104110451FC210470
+:20D9A0002100213E27C8F910213E27A2302A202A67AAA4AA24AA24AA27882494A02240427D
+:20D9C000108010F81110FBFC124413FC12441BFC3000D7FE100011F8110811F8510821F813
+:20D9E000111017FE10A0FBFC12A412BC1B0413FC3204D3FC101017FE1090105050102030AE
+:20DA00002080204027FE2494F94827FC224833F86040A7FC2444244427FC2040A04040403A
+:20DA2000222022102FD8FA2827C424BA2F9034906790A27C2F90221022102210A21042108F
+:20DA400023FC22942294FBFC200027FE280031F86108A1F82180234425282958A18E410462
+:20DA60002010278824FEFCA2249427882C3E34086408A7882ABE2A8832882288A3884008EE
+:20DA8000208023F82248FB2822982BF8300027FC6444A7FC244427FC20002FFEA1104610E4
+:20DAA000200023DE214A20C6F94A22522842312063FEA6202BFC222023FC2220A3FE4200AE
+:20DAC00023FC204027FEF442234C20402B4C322063FEA6202BFC222023FC2220A3FE420000
+:20DAE000221023DE2528FBFC23482AA833F86080AFFE2290252E3BC4209023F8A15042C8F0
+:20DB0000204027FC2040FBF822482FFE2AAA33B86110A3F8211027FC21282310A58E410485
+:20DB20000200024002300220020002FCFF0002000100010000800080004400440024001886
+:20DB400000A0009000900080FFFE0080088004400640154050A052A05212930A1E0400009C
+:20DB6000005000480048FFFE2240224022407F40224022203E20222022123E12220A0006E9
+:20DB8000002008288C26482437FE482084201020FFD011105910551291EA170A50042000D6
+:20DBA000004000407C404440446044504448444C44467C4444404040004000400040004003
+:20DBC0000080008000847C8E449844B044C04580468044807C80448000820082007E000052
+:20DBE000000079E049204920492049204920492079204920422002220422081E1000000072
+:20DC000000007CFC4484448444844484448444847C844484449C40880080008000800000EC
+:20DC2000000000007DFC4444444444444444444444847C84450441040204043C0808000017
+:20DC4000004000407C40444047FC44444444444444847C844484450401040228041000000D
+:20DC60000000003CFBC0884088408840887C8FC08840F8408840804400440046003C0000B0
+:20DC800002047D0644884450442044204420442044207C20442040200020002000200000E7
+:20DCA00000400060784048804888490C4A084FF0482078404888410403FE01040000000053
+:20DCC00000400040F8408BFC8840884088408FFEF8A088A0812001100218040C080E10045A
+:20DCE000000007FCF8408840884088408FFE88A0F8A089208120022002220422081E100058
+:20DD000001100110FFFE8910891088008BF888108820F840888081040204040603FC000093
+:20DD200000400040F84088408FFE8840884088A088A0F8A0891081900248044C08061004F8
+:20DD4000000003FEFA408A408A408BFC8A448A44FA448A44828404840504091412080000F7
+:20DD60000004FBFE8A008A008AF88A888A888A88FA888AA88490048004820882087E1000E8
+:20DD80000220022002207A204A204A264BB84A204A204A207A20022202A20722021E0000BD
+:20DDA000000003F8FA088A488A488A488A488A48FA488A48824000A000900108020604042D
+:20DDC0001FF81008100810081FF8010001003FFC210421042284246428343024201420080C
+:20DDE00000800060F0309020908090809488948494869484F4809080808800880078000061
+:20DE0000000007C4784448444BC44A444A044A047BC4484440440044004402840104000054
+:20DE2000000007FEF420942095FC9524952495249524F524953C85280420042007FE0000BC
+:20DE400000800080F8FC8880888088848FFE8880F88088E08898008C008800800080008089
+:20DE60000000FBFE8A228A228BFE8A228A228A228BFEFA22882000200020002000200020D7
+:20DE8000001C03E07AA04AA04AA04A904A904A907A904A88428804A804B409D6308400006A
+:20DEA00000400040F8A0889089488A2E8C2488008BF8F8088810012000C000400060004095
+:20DEC00000C00080F9F889108AA08C4088A089188E8EF844882080800040006000200000F9
+:20DEE0000040002003FEFA028A048C008BFE88208820F820882080200020002000A0004052
+:20DF000000400040F8408A448A448A448BFC8A448840FA448A448244024403FC00040000A7
+:20DF200002000200F27C92449FC494A894A894A89928F5109210051009A811462084010058
+:20DF400000100210F3109210947E98929F1291129212F5228BA21D420842008E00840100C6
+:20DF60000108018C0108F210921094A49FB895089110F22095FC8E20000000000FFE000033
+:20DF8000000003FEFA008BFC8A208A208A208BFC8A20FA208A2003FC0200020003FE000008
+:20DFA00000400040FFFE8840884088408BFC88008800FBF88A088208020803F802080000D7
+:20DFC000000407FEF0A090A090A097FC94A494A494A4F524953C0604040407FC04040404FE
+:20DFE00000800080F8848FFE8880892089248AA6FAA48D28042008501088210602040400F2
+:20E00000002008200620F42491FE90209E2092209230F248924482840300050008FE0000E5
+:20E02000000207E2F102911291D29252925294529A52F1929092811202020C02300A0004DA
+:20E0400000400040F7FC904093F8904893F8924093FCF244905400A801100218040C080821
+:20E0600000800080F0BC97C09088905090E4971C9000F7FE9120012001220222041E0800B6
+:20E08000022002207A264BB84A204A224AA24F1E4A404840784007FE00400040004000409B
+:20E0A00000100090F09090909494949694F894909490F4909490949005F20E12000E000009
+:20E0C00000400040F8488A4C894889508FFE89108910F9108910011002120212040E08004C
+:20E0E000002002247A244A244BFC4A44484048FE49047A844448005000200040018006001D
+:20E10000012001A0F120922093FE923096709A70F2A892A892A4032602240220022000007A
+:20E120000200F3FC9248924895FE94489C4895F8F448944084400480048005000600000073
+:20E14000001CF3E09200921C92E092A492AE92B0F2A092908290048804AC08C630840000E2
+:20E1600000400040F8A0889089088A068FF488008800FFFC88808110020807FC0208000010
+:20E180000000F9F08910891089108A4E8C408848FFFC896081500248044E0844104000402A
+:20E1A00000800040F7FC9210911090A0904091B0960EF914911081100210021004100810F5
+:20E1C00002100198F8A08FFC884088408BFC88408840FFFE884000400040004000400040C5
+:20E1E00000800088F48C929092A090849FFE91C092A0F2B09498888E108420800080000077
+:20E200000080004007FCF404980890F093409040905EF7E09040804000440044003C000067
+:20E2200000400044F3FE9444948890909148914C9350F320952009101148038E01040000EC
+:20E2400003F80208FA088BF88A088A088BF88A408A48FA588A2082100258028E070402006C
+:20E2600001000190F108927C97C89240924093FC9440F840904097FE004000400040004002
+:20E28000004000407BFC48404BFC48404FFE490049F879084A90045000200050008E0304A5
+:20E2A00000400048FBFC884088408FFE88908A908B98FA9484960914011002100450082009
+:20E2C00000900090F7FE9090909097FE94049888F08097F8808800880108010802280410BD
+:20E2E000000007FC784048404BF84A484BF84A484A487BF84840024001800140063C18083E
+:20E300000000F7FC9080908093F0911091109FFEF00093F882080208020803F8020800006A
+:20E320000200020EF27892409F40927E924893489648FA489248824802880A8805080000FE
+:20E3400000400248795048404BF84A084A484A484A487A484A4842A800900108020C0404AA
+:20E36000004000807BF84A084A084BF84A084A084BF878404840007C07C000420042003E57
+:20E3800000100118F0A0904091B0928897FE9140F3FC96440A4412440254024800400040A6
+:20E3A00000400040F248924892489248955495669844F04097FC0040004000400FFE0000C5
+:20E3C0000000F7BE94A294A297A294A294A297A2F4A2952284AE05A40EA004200020002004
+:20E3E00000400040FFFC904093F8908097FE91109248F7F69840004007FC0040004000405F
+:20E40000004007FC78404BF848404FFE48004BF84A087A484A48024800A00110020C0408A3
+:20E4200001100110F7FC91109150904497FE90809080F1F893080508090801F80108000018
+:20E4400001100110F7FE91109110911097FC94449444F7FC94448444044407FC0404000099
+:20E4600002100210F21092109FBE9210973896B8FAD89A548A94131202100210021002106D
+:20E4800002100210F790927E92109510957E97909120F1BE930405280110010801040100FC
+:20E4A000000007FCF444944495F49444944497FC9404F5F49514851405F408040814100881
+:20E4C000010001007BFE4D02490249F24A424BFA4C424A4A7A4A4BFA0002000400140008CE
+:20E4E0000100010079FC4A544A944CA449244E4449A87E1049400534052A090A01F80000BE
+:20E5000000800040F7FC91209120912092D0948C9848F04097FC00400040004000400040D0
+:20E5200000800040FFFC9210912097FE9080908097FCF1109210012000C0012002180410B2
+:20E54000004000207FFE489049084BFC4908480049F8790849F8010801F80108012801108D
+:20E5600000400040F250929894A09110924C9448F246925884A000A00118020E0404080001
+:20E5800000100410F2FE92929894969094BC92C492C4F2A894A80C900530054E0584000072
+:20E5A000004000207BFE4A044C084BFC484048404A407A784A404240054004C0087E100062
+:20E5C0000200013CF7A494A497A894A894B097A8F4A49422852204B405A80EA004200000FF
+:20E5E000004000247BFE4A044A044BFC4A204A284A244BFE7A204A5004500488090E020497
+:20E6000007E2F4229422942A97EA948A948A97EAF6AA8AAA0AAA0AAA12A21082208A008499
+:20E6200007B8F08895289310931894A498409738F0889748813002B004480886130400000E
+:20E6400002000290F29097FC929092F0920093FC9040F7FE90E001500158024E0444004095
+:20E6600001100110F7FE9150904090A0911897F69800F00093F80208020803F80208000040
+:20E6800000400040F7FC904097FC9404951494A495F4F44487FC04440444045404480000B3
+:20E6A000000007FE0400F5FC9524952495FC9524952495FCF42095FC04200820082013FE30
+:20E6C00000800080F7FC90A09150924E9FFC904097FCF040804003F8004000400FFE0000E0
+:20E6E00002200224F22E93B0922292A2935E9080F3F89208820803F80208020803F8020863
+:20E700000000F7FC944497FC9444944497FC9040F7FE94428452047A07920402040A0404B4
+:20E7200003FEFA228BFE8A228A228BFE88008BFEFA028BFE820203FE02020202020A02041D
+:20E74000001001907E10521052545FD65258571056907A904A28122822240246024402804A
+:20E7600000400140F65C9444975C9444944497FC9000F3FC9108009000600098030E0C04F7
+:20E78000008000407FFC4A10499849204FFE48004BF87A084A0803F80208020803F80208DA
+:20E7A000020001007FFC082004403FFE41045FF01110115001201FF0101010101FF010107D
+:20E7C0000210019879204FFE48804BFC488048804FFE79004BFC42200420082017FE000039
+:20E7E0000048024CF15097FE90E09150924E9D449100F7FC9210832000E00118020C0408BF
+:20E8000012100D9809203FFE290449080FF0110001007FFC00000FF0081008100FF008107B
+:20E820000000F7FC940497FC940095FC94409488F5FC94A4842009FC0820102023FE00005A
+:20E84000010001F8F11093F0901097FE90809188FE5091A082700CA803260C2400A000407E
+:20E8600000800080FFF8908097F891009FFC923095C8F84697F821600258044C084800402F
+:20E8800002100218FFA092209FBE924492449FA8F4289728851005100928092C15462284BF
+:20E8A000004007FCF04097FC90409FFE9080911093E0F08893FC8044025004480948008087
+:20E8C0000200021EFFD2925492949FF8911893D4F6548A5293D2225E025403D002500010FC
+:20E8E00000400040F3FC904097FE9080910897FC9204F3F892A802A802A802A80FFE000042
+:20E9000007FC0110F1F0911091F0911097FE9010F7BC94A484A40318052404A408C21082AF
+:20E9200001100114F7FE9110921092FE920896E8F6A88AA892E882A802880208022802108D
+:20E94000004007FEF84089F8890889F8890889F88908F9F881080FFE01100208040608044C
+:20E9600000400040F7FC904097FC9484911093F0F0C893FC804802500348044C09480080B8
+:20E98000000007FEF00093F8920893F8900097FCF51494A485F404440444045404480000C1
+:20E9A00007FC0080F3F8920893F8920893F89208F3F8910083F8051008E011B0060E180420
+:20E9C000000007FCF444944497FC944494A4951497FCF00090888A640A4A0A0A11F80000DE
+:20E9E00000400080F3F8920893F8920893F8904097FEF0A09118864E1BFC004000400040D9
+:20EA00000110030CF4A498409130968E91F49F2090C0F78090FC01080690006001800E005C
+:20EA2000001CF7E09A8C915097FE9484988897FEF10091F89288025004200858118E060467
+:20EA40000208018CF1109FFE910091909108920C9408F7FC94A404A404A404A40FFE0000CC
+:20EA60000040045EF2929FD2911E95529552955297DEF552911202220422084A30840000EC
+:20EA800008800680F4FE990094FC948492A49294F3FE94A484941C9404FE040404140408BA
+:20EAA000000009FCF408941091FC91249DFC95249524F5FC95240524052C0A0011FE200027
+:20EAC00000400248F24893F8904097FC90409040F3F89248824803F80044007E078400000D
+:20EAE0002108310C27D04A22F53C2788711E0780310EC1301FF0101010101FF010100000A9
+:20EB000004900490FFD0949097BE911297D295529552F7D291128FF201120122012A014418
+:20EB2000009007FE78904BFC4A944BFC4A944A944BFC780049F8010801F80108010801F803
+:20EB4000000007FEF09093FC9294929493FC900093FCF00097FE82280324022604A4084039
+:20EB6000001000180014F7FE949094D0949297F29414F49494C80AAA0A9A14A612C6210294
+:20EB800000000FBEE8A2A8A2AAAAAAAAA208A514E8A2AFFE0110039000600098030C0C04D7
+:20EBA00004440444F7FC900097BC94A494A497BC94A4F7BC94A404A408A40AA4115400089A
+:20EBC00008200630F4209F7E944094A0973C9550F590957E8510092809281544224200801A
+:20EBE00000800040FFFE9208911097FC944495F4F44495F48514051405F405040414040890
+:20EC000000800040F7FE9482924895589522914AF1F89640804004440444044407FC000076
+:20EC200001000104FFE6910897D0902497C694489454F7E6908C04C8051001E00E4000000B
+:20EC400000000FFEE810AC50AA9EAFD2A928AD48AD48EFC8A908129412A42442488200003B
+:20EC600000400040F7FE90A4951893FE960C9BF89208F3F8904002500348044C0948008065
+:20EC800000A004A4F2A892B09FFE9208911097FC9040F3F890400FFE00A00118060E180464
+:20ECA00003F80208F3F8920893F890009FFE948097FCF4C897A8049007900CAC00C6008443
+:20ECC00002400320F22093FC96209BFC922093FC9220F22093FE02000548052408B610A461
+:20ECE00000800100F7FC964C955497FC94E495549654F4449FFE00A0011002080406080451
+:20ED0000004000A0F19896469BFC90909264929493FCF08097FC04A4057407940404040C75
+:20ED2000010003F8F4109FFC944497FC944497FC9000F7FC900083F8020803F8020803F8CA
+:20ED400002100118F12097FC965495DC956497FC9400F3F8920803F80208020803F80208D0
+:20ED6000000007A8F0B094A49318910893F69C0093F8F20893F80210011001200FFE000042
+:20ED8000011007FEF110915097FE900091F8910891F8F00097FE040205FA050A05FA040609
+:20EDA00001100110FFFE933895D49552999093FC9000F7FE90400248034404460944008064
+:20EDC000008000F8F08097FC948495E89480947897FCF44884AC0B7008A8112E26A4004090
+:20EDE000008000407BFC48904FFE48004BF84A087BF84A0843F800040A420A2A11F800004D
+:20EE000000800040F7FE992497F8912097F891209FFCF290948E0BF4108000800FFC0000A7
+:20EE200000100790F4FE94C494A497A8947E9410F7909CFE8C901490179024900410000064
+:20EE400007FC0040F7FE94429B58904093589000F7FE910087FC04A404A404A404A4040CAD
+:20EE600000800040F7FE9A0493FC94A89A90910893F6F4009BFC02500348044C09480080DF
+:20EE8000000003FC0040F7FE94429A509148922093FC9620FBFC922083FC022003FE020061
+:20EEA00000400FFEE444A7FCA040A7FEAAAAA3B8A110AFFEE1100FFE012407281990010E9E
+:20EEC00000007FFC400440044004400440044004400440044004400440047FFC400400000C
+:20EEE00000007FFC40044FE44044408441045FF44104410441044104450442047FFC4004DE
+:20EF000000007FFC420442047FFC4444444448444484430444C44834501440047FFC4004D9
+:20EF200000007FFC4104428444444824741C448445C446044424442443E440047FFC4004B2
+:20EF400000007FFC440444044FF44A54525464944494491452144454482440047FFC400485
+:20EF600000007FFC4104428444444A34511C6FE44044448443044104408440047FFC4004A6
+:20EF80007FFC420442045FF4440447E44C2457E4642447E4442444A4444440047FFC40046B
+:20EFA0007FFC40045FF442044FE4422442247FFC40044FE4482448244FE440047FFC4004FA
+:20EFC0007FFC41045FF441045FF441047FFC40044FE448244FE448244FE4482448247FFCBE
+:20EFE0007FFC410441044FE441045FF4482444445FF441047FFC4104410441047FFC4004AC
+:20F000007FFC40045FF452945FF440047FFC40044FE448244FE445244CC456744C247FFCA2
+:20F020001040104010407FFE544055FC5440544057FC544454445C441054104810401040D7
+:20F040001020112011A07D2055FC5620542057FE542054505C501088108C11061204140038
+:20F060002040204023FCFA48AA50AA40ABF8AB08AA88AA90AA5024202450298E3604000026
+:20F08000100011FCFE842288644818302448428681043FF82108210821082138211001003D
+:20F0A0002040204027FEF840ABFCA840AFFEA888A888A97EB908224822482408282820102F
+:20F0C0001020102013FE7C2055FC542057FE540055FC55245D24112411541048108C1108C3
+:20F0E000200023FE2202FBFEAA22AA22AAFAAA22AA22AA32BA2A23FE2202220223FE220270
+:20F10000208020A02110F9FEAB20AD20A9FCA920A920A9FCB9202120212021FE2100000058
+:20F12000200023FC2204FA04ABFCAA00AAFCAA48AAFCAA44AA20BAFC2220242025FE28009E
+:20F1400021F8210821F8F908A9F8A800ABFCAA94ABFCA800ABFCB908209020602198260659
+:20F16000204023FC2108F890AFFEA800ABF8AA08ABF8AA08BBF8204027FC2040204020400A
+:20F18000209022942198F890AFFEA890ABFCA840A9F8A840BBFE204020A02118220E240461
+:20F1A000201C23E02248F950AFFEA8E0A950AA4EAFFCAA48AA48BBF82248224823F82208DC
+:20F1C0000100210821083FF800003FF00820082008780C081210112020C04130860E18043E
+:20F1E000100011FC100454045404540455FC5504550055005D00F1004102010200FE0000F0
+:20F20000100013FE109054905490549057FE549054905C90F490411001100210041000006C
+:20F2200000402040204023FCA840A840ABF8A908A908A890B890E8608090010E0E040400DD
+:20F24000100011FE110455065584554855285510551055285D24E546418401FE0000000075
+:20F26000000021FE20102110A990A910ABFEA830A850A850B890E9100210041008500020CC
+:20F28000100011F8110811485548554855485548554855485CA0E0A041220222041E080008
+:20F2A000000001F83E0002007FFE048004400930310EC1041110111011101FF01010000001
+:20F2C0000100210821083FF80100028004400A30318EC1041FF0002000200040008001000F
+:20F2E0000100210421043FFC00001FF810081848146812881108228A246A58268002000090
+:20F300000100210821083FF8200800003FF8210821083FF820002004200420061FFC0000D2
+:20F3200010201020102013FE542054205420542055FC55045D04E104410401FC0104000025
+:20F340000100210821083FF80000FFFE001000101F90109010901F90109000100050002048
+:20F360000080108810881FF8020002007FFC048008801FF8008008A00C90108C22884100D9
+:20F38000100011FC1124552455FC55245524552455FC55245C20E0204020002000200020E0
+:20F3A000102010201020542055FC55245524552455FC552455245D24E12441FC0104000082
+:20F3C000112019101114317E5F80908010441024111801002108210821087FF82008000044
+:20F3E000108010C0108054FC5504560454F45494549454945CF4F4944404000400280010BE
+:20F400000080208420843FFC0400387C20442244224422442E5472482440044008403040FF
+:20F42000100011FC1104550455FC55205520552055FE55205D20F12041100152038A010405
+:20F4400023FC21082108A890A860A898AB46AC40ABFCA840B840EFFE8840004000400040E2
+:20F46000100011FC1104550455FC550455745554555455545D74E10441040114010800007A
+:20F48000103813C01040544057FE54A05518560E549454905C90E0904110011002100400B3
+:20F4A0001080108010FC5504560455F45514551455F455145D14F1F44114000400140008D5
+:20F4C0001040104010FC5488551057FC542457FE5424542455FC5C20F020402000A0004012
+:20F4E0002110211027FE2110A910ABFEAA04AC88A880ABF8B888C08801080108022804106D
+:20F5000010201020102055FC5428552C54B057FE546054705CA8E0AC4126022404200020DB
+:20F520000100210821083FF8100011207DA011103A183A8E54C450909108127C17C8120098
+:20F540002040204027FEA8A0A910AA4EAFFCAA48ABF8AA48BA48EBF800400042003E0000F6
+:20F560000100210421043FFC00003FFC21042FF4210427E4242427E4242420043FFC200434
+:20F58000210820902060A890A948ABFEA880A9F8AB08ADF8B908C1F8010801080128011059
+:20F5A0002040202027FE2000A9F8A908A9F8A800ABFCA808B810CBFE0020002000A00040C3
+:20F5C0002040202023FE2204AC08A910A988AA04AC00ABF8B840E8400040004007FC000006
+:20F5E00011FC1104110455FC5510555455545554557C55105E94F294449404FC0804000091
+:20F600002090209027FE2090A890ABFEAA24AC20ABFCA860A870B8A8E126022404200020A2
+:20F62000200023FC20A0A8A0ABF8AAA8AAA8ABF8A880BFFEE910012000C001200218040893
+:20F64000010021043FFC005000483FFE20403FC8244C3FA829302510422A454A9884000011
+:20F660000100210821083FF800001FF011101FF011101FF0010008C82894281647F400008B
+:20F68000010021083FF8220804003FF821083FF821083FF8229002A804FC088A107E200048
+:20F6A000010021083FF8010002C00C303FEEC0043E0822483E4822483E4822082228261029
+:20F6C0001008110C109057FE544057FC544057FE5480548055FC5D20E220022005FE08008B
+:20F6E0002048224C214827FEA8E0A950AA4EAC44A900AFFEB910C1A0004000B0010E0604B4
+:20F700001008110C1088545057FE54885488555457EE56B454885D08F15443FE0252000058
+:20F72000200023FE2222AA22ABFEAA00AAFCAA84AAFCAA84BAFCEA84028404FC0484080043
+:20F74000203C23C02040ABFEA950A954AF58A952A952AF4EB8E0E950024C0446084400407C
+:20F76000010021083FF801007FFE00000FF008100FF000003FFC20042FE428242FE4200C97
+:20F780002040224821502148AAA4A918AA06ADF8A908A9F8A908B9F8E10801080128011081
+:20F7A0002080204023FCA890AFFEA800ABF8AA08ABF8AA08BBF8E84087FE004000400040D3
+:20F7C0002248215020E0ABFEA8D0A94EAE44AA10ABBCAC90AED0B97EE21004100810001004
+:20F7E00027A022AC21B02496AA98A90CAAFBAC00A9FCA904A9FCF90888CC009007FE0000C0
+:20F800000100010041027FFA4922556267A64D3A57526D5A5596655249227FFE4002000038
+:20F82000010021083FF8000024FC380822501E2041FE7E2488207EBC08A014A026A0457EAF
+:20F84000010041047FFC1000FEFE20207E7C42447E5442547E544254FF1024284246828462
+:20F86000010001800300068008C011800100030005000900110001000100010001000100FC
+:20F8800010401820202043FE90801880308050FC908410841104110411041204121414087C
+:20F8A00010001BF822084A088E081BF832086208A20823F822082208220822082FFE2000A2
+:20F8C0001100190021FC4A048C040BE41224322453E49224122413E41224100410141008E8
+:20F8E0001210191820A057FC9840304027FC6040A04020402FFE204020402040204020404A
+:20F9000008400C60108821F048400C8819FC3008510091F81310149018601090110E16042F
+:20F920001040184027FC50409A48114821506FFEA0E0216021502248244E284430402040C9
+:20F9400010401840227C52409A4017FE20006040A240227C224022402240254024FE2800CB
+:20F9600010401848244C53489A5017FC24046404A5F42514251425F4251424042414240856
+:20F980001040188023FC4A048FFC1A0433FC500097FE1040104013FC1040104017FE1000E1
+:20F9A000103C1BE430866A648D48191011FC3240544097FE104012441244124413FC100061
+:20F9C00022102A984A908F90203E3FA46064AFA422242FA4222822103F902028204620842C
+:20F9E00021103218279044A0A7BE34E427A46224AFE42214238824882494289432A2214258
+:20FA00002EE03ABE4EE08AA02EE03ABE2EE46504A4842FE4348427E4248427E4249427E88F
+:20FA20000000006000C00100062018306040018003080C1C30300060018006003800000064
+:20FA4000108008800500020005000900118022800280048008801080208000800500020001
+:20FA6000008044802880108033F048908890189028904910891009120A125212240E0800D0
+:20FA8000040045FC282010203020482088201BFE28204820882008200820102050202020A8
+:20FAA0000840882051FE21005100890009001900290049008A000A000A001400540028004A
+:20FAC00044002FF8100831084908891005100DFC1504240447F484040404080428281010DA
+:20FAE000040045FC284810482848484808481BF828884888888808880888088857FE2000E1
+:20FB00000040446028C0109029084BFC88941890289048908890091009120A122C0E1000FB
+:20FB2000040045FE29221122292249FE0D221522252245FE852204200420082028201020EF
+:20FB400004804480290011FC2A0449F485140D14151425F4C50805280512090228FE10006E
+:20FB6000049044902BFC109428944BFC8A941A902BFE4A9288920892091A111452102410F0
+:20FB800088204828302427FE50209124092419242FE8492889100A300A50148A5906200271
+:20FBA0000840884050A020905118920E0DF4180028004FFC88800910120857FC2204000448
+:20FBC0000080884053FE22025414901008101BFE28104910889008900810101050502020D6
+:20FBE00000108FD05090211051109158099419562B524D52899009100910111055502220C0
+:20FC0000022082204A2433B8322052228AA21B1E284048408BFC08400840104057FE2000D0
+:20FC2000040044F82888108828F8480009FC190429FC490489FC09040904110451142108FE
+:20FC4000000290C25702211251129FD211123392535295521512190211025102210A0104A4
+:20FC60008840484030A03098490E8BF41C4028402BFC4840895009480A441444594020804A
+:20FC8000884048A030902108520695F418002808488C8A48094809500810080057FE2000BD
+:20FCA00008408820502423FE500091FC080019FC2800480489FC09040904110451FC21042B
+:20FCC00044802490190813FC281449880A841C8429FC49088A900C6008601098530E2C04A4
+:20FCE000044044402BFC10A03110520897FE18082BC84A488A480BC80A48100850282010D9
+:20FD000008008BF85248224853F89248124813F8304057FE90E01158124E1C44504020407C
+:20FD200000004BFE2A52125233FE4A42888018FC29044B088C9008600840118056002C0062
+:20FD400000804B382A08120832084BB80A081A082BF84920892009200A221222541E28008B
+:20FD60000840884050A02118520E8DF4184028404BF8884008400BF80A080A0853F82208BA
+:20FD80008840482037FE2000511091101AA82C44284048408FFE084008401040504020405D
+:20FDA00088204BA03120213E574294540C901C102F584954895609520992111055502220B6
+:20FDC0000900493C312437E44924893C1D2417A424A444BC84A407A40444084428941108F3
+:20FDE0000840884057FC20E05150924E0C441BF82A084BF88A080BF80A08080057FE200023
+:20FE000088004BF8324823F852488BF818002FFE4A808A860A580A600A300A98530E220417
+:20FE20000BFC8A44524423FC52448A441BFC280049F8890809F8090809F8110851282110ED
+:20FE400088004BFE3222222253FE92000AFC1A842AFC4A848A840AFC0A84148454FC288488
+:20FE600009F88850502027FE50A291240AA01C4028204BFE887008A8112812265424202005
+:20FE80008880504027FC511097FE08001BF82A084BF88A080BF808400FFE104050402040F7
+:20FEA0000880884057FC21105FFE900013F82A082BF84A088BF80920092052222422081E1A
+:20FEC000100497FE66506590A7FE152215143550555097D009280928094452462484000049
+:20FEE0009040504027FE60A0911016081BFE320A53F8920813F811501248A44449400080CD
+:20FF000002009A3E53D2249257DA9564155437DE5554954417FE154415441544A944508421
+:20FF20004BF8284017FE304057FC9554155417FC304057FC90401FFE100015245492289240
+:20FF400008908BFE509023DE525293DE092019FE2B204DFC892009FC0920192051FE210036
+:20FF60001010181010101EFE2210229062909490149009FE08101010201040108010000010
+:20FF800000207F20493E7F4449A849307F4008A0FF3E1C421AA429184810882008C00B001A
+:20FFA0001040104020A03CD8252647F84508A9F8190809F8114811302150418C81040000D6
+:20FFC00004000FF0342002C00F007FFE40029FF401001FF011101FF011101FF00C60701C3F
+:20FFE0000400060004000FF80810081014202420424002800180028004400830300EC004BF
+:020000040003F7
+:200000001000100010003F8021004200500090001000100010001200140018001000000030
+:20002000200023F820103E204440488093FC105410941094112416241844119406080000F2
+:2000400020202020202021FC3E20442049248124112411FC1020102014221822101E0000AF
+:200060002040204020FE3E8045004978920011F8100810081008120A140A18061002000091
+:200080002000201C21E03E2044204820802013FE1020102012201420182011FC000000001D
+:2000A0002000203C21C03E404440484083FE1040104010A01090111015081A061404000072
+:2000C0002040204020403EFE44804940924011FC1044104410441084148419141208000029
+:2000E0001020102020403E48448449FE8002100011FC110411041104150419FC110400008A
+:200100002020202020403DFE49025102A17A214A214A214A217A25022902310A210400007D
+:200120002020202021FC3C2044204BFE820420F82010202023FE2020282030A02040000032
+:200140002040204020A03E90450E4BF4A440204027FC2040215025482A4434442140008053
+:20016000200021F821083FF8450849F880002110211621D82110251029523192210E0000A4
+:200180002040204023FC3C4044E04958A64621F8210821F82108210829F8300027FE000030
+:2001A000206023BC22243E2447BC4A24A3FC2020202023FC21082490286031982E06000027
+:2001C000209023FE20903E0045F84908A1F8210821F8204023FE20602890310826060000D9
+:2001E0002108209023FC3C4045F84840A7FE208020F82128212822F82A4834482BFE0000A6
+:200200002110211027FE3D1045F0484083F8224823F8204023F820402BF8304027FE0000BA
+:200220002290229047D07A9E4FD4902427E424A427942494278824882C9435A624C4000030
+:20024000200023BC42A47BBC4A2092A203BE211023FC211027FE20002910320C24040000BE
+:20026000204027FE22483BF848405FFE8AAA23B8209023FC209023FE299432882CC40084DD
+:20028000010000803FFE2000220022002220227023802200220022044204420681FC000050
+:2002A000010000803FFC20002FF82100210021003FFC21402240224044444844903C200078
+:2002C000010000803FFE208020803FFC208027F824102210212020C02120461C580880001C
+:2002E000010000803FFE2200220027FC24042FE43424242427E42414440A440283FE0000A6
+:20030000020001003FFE2420262024202BFE3870287028A828A8292429264A2448208820AC
+:20032000010000803FFE241022202FFC208020802FF8208020803FFE20804080408080805A
+:20034000010000803FFE22203FFE222023E0200027F8240827F8244024204818480E90049F
+:20036000010000803FFE21003FFC214022B0248E2FF4349027F0249047F4408680FC00004F
+:20038000010000803FFE200020802EB828882EB8288828882FF8294821204210440C8808F8
+:2003A000010000803FFC22002FF028902FF028902FF0218026803FFC2080408040808080F0
+:2003C00001003FFE20802FF820883FFE21082FF824183FF6249024902490414046309810B7
+:2003E00000803FFE242024303FA0243E3F4424243FA4242427282910291051286546828486
+:2004000000803FFE22203FFC222023E020802FF828882FF820802FFC208047F840809FFEB8
+:2004200000803FFE20002FF828882FF828882FF820802FF820803FFE288853E44080BFFE02
+:20044000010000803FFE28002F7C29143F942AAC2FC02AA82ABE2FC82ABE52885288A188C0
+:2004600001003FFE20803FFC20002FF82A482BC82FF820002FF820003FFE24904C8C918847
+:2004800000803FFE25202BFC3D2029FC292029FC280027FC240427FC240447FC4404840C6A
+:2004A0000800080008000A0049004880488088000800080008000800080008000800080079
+:2004C0001000100011FC18445444544490441044104410441084108411041104121C1408F7
+:2004E000100810081008140855FE540854089108108810C8108810081008100810781010FC
+:200500002000207C27C020403040A840A7FEA04020402040204020402040204020402040FB
+:20052000200023FC20403040A840A840A7FE206020A020A02120212222222422281E0000E3
+:2005400020402040204037FCAC40A840A3F82208210821102090206020902108220E2404F4
+:20056000200027FE24003408AD08A490A450242024302448248C25042400240027FE20008F
+:2005800010201020102013FE5A2256229222122213FE10201020102010201020102010207D
+:2005A00021002180210031FCAA20AA20A420A02027FE20202020202020202020202020202E
+:2005C0002100210021FE3200ABFCA400A3F8200820082008200820082008200A200A20043A
+:2005E0002100210821083110A920A9C0A1002FFE21402120212021102148218E21040000F6
+:200600002040204020C030A0A918A20EA5F4211021102110215021202104210420FC0000B5
+:200620002020212021A03120A910AA10A28824C62884208021102108227C27C62204200029
+:200640002080204020403000AFFEA840A040A0602058204C2044204020402040204020406D
+:20066000200027F820883088A888AC88A888A7F8208820882108210821082FFE2000200070
+:2006800020402040204027FEB040A840A040204023F82208220822082208220823F82000D5
+:2006A00020402050204C3048ABFEA840A0C020E0215021502248244E2844204020400000AB
+:2006C000200027FC20403448AA48AA50A15021602FFE2040204020402040204020402040D0
+:2006E000100011FC11041904550455FCD1041104110411FC10001000100013FE10000000A4
+:2007000020402040204033F8AA48AA48A24822482FFE204020A020A0211022082C060000BC
+:2007200010801080108011FE59405640947C10401040107E104010401040104010400000FD
+:20074000200023FC22043204ABFCA200A280228C22B022C02280248024822882307E0000ED
+:200760002090209023FC30942894ABFCA290A29023FE20922092211A211422102C102010DC
+:20078000200027FC208430842904A904A214A40821FC2104210421042104210421FC00008F
+:2007A00023FC210820903060A860A190A64E204023FC204020402FFE204020402040204098
+:2007C00010401040108018885504523E97C2100013FC120412041204120413FC120400006B
+:2007E0002010201027903010A87EA012AFD222122212241225222FA22042208A2104000062
+:20080000100013FE122012285A24562093FE122012201220125014501488190E160410007D
+:20082000200227C224423452AD52A552A552255225522552255221022282244A2844000057
+:200840002040224422443244ABFCA000A3FC2004200423FC220022002202220221FE2000DE
+:2008600010801080110011FC5A04540491E4112411E4112411E41004100410141008000057
+:200880001080108011FC1908569054609060109813061DF8110811081108110811F800003D
+:2008A000200027FE24843080ABFCA900A140224023FC2040204027FE204020402040204084
+:2008C0002040204023FC3040AFFEA404A00023F8202020402FFE204020402140208000002B
+:2008E0002040204027FE3040ABFCAA44A24423FC204020E0215022482C4E20442040000090
+:20090000208022FE22A23294AA88A294A2A220802040204023FC204020402FFE2000000055
+:20092000200023FC224422443244ABFCAA44A24423FC2040204027FC204020402FFE2000AC
+:20094000200023FE22223222ABFEAA62A27222AA22AE232A22222222222223FE20000000FF
+:20096000200023F822083208ABF8A800A7FC2444244427FC240024002402240223FE200022
+:200980002108209023FC3044A844ABFCA240224023FE20C22142214A22442C402040000011
+:2009A00020402040208831FCA804A908A104228224FA21082290206020602190260E2004FA
+:2009C000200027FE24203420ADFCA4A8A47027FE2420245024482484250427FE20000000D2
+:2009E0002040204023FC3040A840A7FEA108209023FC2040204027FE20402040204020403E
+:200A0000209020902090379EA890A090A79E2090209020902F9E20902090209020902090F7
+:200A20002040204032482948A950A7FCA40424F424942494249424F42404241424080000E3
+:200A4000200027FC2404251434A4AFFCA484A44427FC24842484248424F4240424142408A0
+:200A6000100013FE122212225AFA5622D3FE120212F21292129212F214021402180A10048A
+:200A80002100210021FC3254AC54A094A32420D42308204021202524250A2D0A20F80000EF
+:200AA0001040102017FE11105910559892A414441040104017FE10401040104010400000A7
+:200AC000200023F8220833F8AA08AA08A3F82000200027FC24A424A424A424A42FFE2000B7
+:200AE0002040204023F8224833F8A840A7FEA00023F822082248224822682090230C2C04A7
+:200B0000000027BC24A424A437BCA800A3F8A0002FFE2080210021F8200820082050202085
+:200B2000200027FC24A424A4B7FCA880A0402FFE208020F8208821082108222824100000CA
+:200B4000204022442244224433FCA800A7FEA040208027FE24A224A224A224A224AA24A434
+:200B600020D0271021103110AFD2A156A3B823502510251029282128212421462184000041
+:200B8000210021FE220033F8AD08A1F8A10821F8208021FC23082C90206021B02E0E000087
+:200BA000204027FC204033F8A840AFFEA080212027C0210827FC20402448244429442080BD
+:200BC00022102110212027FC3120AFF8A128AFFE212827F8212023302328252629242120C0
+:200BE000202027FE242025FC3424AFFEA424A5FC242025FC252425FC292429FC3124212CDA
+:200C000023F8220823F83208ABF8A040AFFE200023F8220823F82040244824442944208049
+:200C20002140212021FE3220AE20ABFCA22023FC2220222023FE20002524249228920000CD
+:200C40002080204027FC2110B7FEA800A3F8224823F8224823F8204027FC20402FFE20000E
+:200C60002110211027BC3110ABB8A554A110200027FC20482240227C234024C0283E200069
+:200C8000204027FE200033FCAA94AAF4A20423FC200023F820002FFE2040224824C4204045
+:200CA000211027FE211033FCAAA4A3FCA00027FE240421F8210821F8210821F8210821F8C5
+:200CC00000003FF8010001007FFC028004400930110E210451501128212C21284500020066
+:200CE00000403DFE248029FC2A8424FC348429FC2284244C1930E10E09501128050002001E
+:200D000020001BFC080420042004200420042FF420042004200420042004200420142008A9
+:200D200020001BFC0804000427E42004200427E4200420042FF420042004200420142008DB
+:200D400020001BFC490441045FF441044FE441045FF44114411441544124410440144008E2
+:200D600010000BFC090421042FF4210422042284248425042A2437F4201420042014200818
+:200D800010000BFC0804210420842FF42044224421842084214426243824200420142008A6
+:200DA00010000BFC090420842FF42004200423C4224422442254245424342804201420087F
+:200DC00010000BFC480440845084488443F45C8444C44524461444044BF4500440144008F3
+:200DE000100009FC0804200427E4242427E420042FF4281428142FF42004200420142008CA
+:200E0000200013FC40044FE4492449244FE449A44B644D2449244FE4482440044014400826
+:200E2000200017FC520443E444445FE449244FE449244FE44114411440F440044014400839
+:200E4000200017FC5204410447C4444447C4444447C4452444C44644442440044014400850
+:200E6000200013FC00C440A45FF440845E8452A45EA44044465458B4431440044014400849
+:200E800010000BFC480447E4442447E444244FF448144FF448144FF4400440044014400824
+:200EA00010000BFC480442044CE448244EE448244FE4428442944494447448044014400808
+:200EC00010000BFC080420F42F2425442FF4281427E422442184214426242004201420087B
+:200EE000200013FC50044FE449044FF448844A544C3447C4444447C4444447C440144008F5
+:200F0000200013FC5004484444445F644494448C4744492449444924552462044014400862
+:200F2000200013FC00044FE449244CA44A6449244FE441445FF44284444458344004400C5E
+:200F400020001BFC480441244EC44A9444644FA4511C4FE4410442844444584440140008F3
+:200F6000200013FC110447C441044FF4424447E440044FE44AA44AA45FF440044014400863
+:200F8000200017FC51044FF4410447E4442447E4442447E444244FF442444C244004400CBF
+:200FA000200013FC400451444A445F7C4494552455245F2444644854488C510C4004400C6E
+:200FC000200013FC40244E2442445F7C4A944F944A644E244B545E4C4284400440144008DB
+:200FE000004000400840064003400240004000C0034006401C400840004000400040000071
+:20100000000804080408040807F80408000800083FF8020802080408040808081008600896
+:20102000044004502448244027FE7C400448044CFC482430242024504492450A84060402C6
+:201040000800040004000100220012001400040004000800380008000800180008000000BF
+:2010600021001100110003FE8200540053F0102020402080E10022002402240223FE000073
+:20108000200013FC120402048A044A0453FC120022002200E20022022202220221FE000017
+:2010A000200017F805080488825052501110112020A020C0E04020A02118220E2C04000089
+:2010C0002040104013FC80404840484013FC104010402040E7FE20402040204020402040AD
+:2010E000400023FC20000000800057FE5120112021202120E120422242224422581E0000D3
+:2011000040402040204008408BFE504050C010E021502150E248244E284420402040204024
+:20112000200017FE104000408A7C4A445244124413FC2004E004200420042004201420088B
+:2011400040402040204007FC8040544454442444244427FCE444204020422042203E0000BF
+:20116000200013FC1204020482044A044A0413FC12041204E2042204220423FC2204000050
+:201180002000100017FC84044C044C04140417FC2404E4042404240427FC240420000000EE
+:2011A000208010401040000043FE24402440086008581048704010401040104010400000D6
+:2011C0004080204020400FFE9210521052101110212020A0E04020A02118260E3804200051
+:2011E000410020802FFC0000900053E01220222022202220C220442244224822501E0000A2
+:20120000404024402240004087FC50445044108420A42094E11421042204240428142008C5
+:201220004010279024900D7E8E12551255121492249226A2E522242224422442248A2504E6
+:2012400042102210221002108FFE4A100A10121013F02210E21022102210221023F02210A1
+:20126000404020502048004097FE50C050E021602150E25022482448284620442040204075
+:20128000208010A0109000908BFC48A050A010A410A82130E120216222A22222241E2000C4
+:2012A00020401040107E004088404BFC5204120413FC2200E200220022002400240028006E
+:2012C0004040204020400BF88A484A485248124817FE2040E0A02090211022082C0E200415
+:2012E0004000200027FE04928C924C925492149214922512250EE602240227FE24022000C2
+:201300004100210021FE02008A204C24513C11E427242124E124212C2122210220FE000048
+:2013200040802080214009208A18528E5444184027F82010E0202140208020C02040204061
+:2013400040C0271E241204928C924C92549214922492259AE694209021102110221024108D
+:201360004000203C23C002208A204A20522013FE10202128E12422242222242220A02040C7
+:2013800040802040204007FE804048804888111013E02020E04020802108220427FC2004C6
+:2013A0004040244422440948895057FE504010402FFE2040E04020402040204020402040F3
+:2013C0004080204027FE0404800049004900113811C02100E10021002102210220FE00000D
+:2013E00040102790209008908F9054105410141027A020A0E0A020A420C420FE2282210001
+:20140000200013FC120482044BFC4A400A4013FE12202220E22022102212228A2306220200
+:20142000200013F81010802048604890110C1604200023F8E0402040204020402FFE200042
+:20144000200017FE1000000087FC4404540417FC24042404C7FC4000400040004FFE4000B1
+:201460002040104017FE8080490053F816082A0823F8E208220823F82208220822282210A9
+:20148000400227E22102011293D257525452165225922892E112211222022402280A200478
+:2014A00040402040204007FC804052481150106027FE2040C0A040A04110420E4C04000008
+:2014C00020401040107E004088404BF85208124812482248E248228820A02110220C2C04E8
+:2014E000200013FC124402448A444BFC5244124412642294E28C23042204220423FC2204CE
+:20150000200017FC140484044DF44D1415141514251425F4E51424042404240427FC2404F6
+:2015200020401240124003FC8C404840504017FE204020E0E15022482C4E20442040204016
+:2015400020401040108003FC8A044A044BFC120412042204E3FC22042204220423FC220441
+:2015600020401040108083FC4AA44AA412A412A412A422A4E2A422A422A422A42FFE2000C3
+:201580000040204010C0112081184A064DF01000100027FCE08021002108220427FC20042A
+:2015A00040A020A020A000A094AC52B010A021B022A82CA4C120412242224422581E40000A
+:2015C0002100110011FC020482044FE44A24122413E42224E22423E420042004201420087B
+:2015E0004100210021F803108CE049B0564E104023F82240E24022402FFC204020402040B8
+:201600004404220422040FD4809444945294131421142314C2944494448448045014400800
+:2016200040402440224002FE809051105E1012FE12102210E21022902310221020102010B8
+:20164000400027F820080BF8880857F8501010102FFE2210E1102110201020102050202010
+:20166000220012001200023E8FE252A252A224A224A22D22C322412242BE44A258004000EA
+:20168000408020802FFE008097F85488548827F8208021C0C2A04498588E408440804080EE
+:2016A000400027FC208008808BF85088510811082FFE2000E3F822082208220823F82208E7
+:2016C0004040204027FC00409248515051602FFE20C02160C15042484C4E40444040004094
+:2016E000400027FE2442044287FA544255F2144227FA244AE46A2452244227FE2402000021
+:20170000200013F8120802088A084BF8504010401240227CE2402240254024C0283E200082
+:20172000200013F8120882084BF8480017FC140427FC2404E7FC240424042404241424081A
+:2017400040402444244407FC808050C051201210248E3840E7F8201020202020204020401A
+:2017600000004078278024000400940057FC2440244024405FFEC000422042104418580842
+:20178000221011A010C0833048884FFE1100124023FC2644EA4422442254224820402040A6
+:2017A000410021F02210022087F852485248124823F8206020A0E0A2212222222C1E2000A8
+:2017C0002080104017FE0404800053F8500017FE21202120E120212222222222241E280014
+:2017E0002040104413F40048805047FE5040108023F82E08C20843F84208420843F8420842
+:20180000421022102FFC0210921053F05210121023F02210E2102FFE211022082C0C200483
+:2018200042002206223802208FA0523E5228272826A84A28CA485248428842884308420825
+:2018400044102448244804489F44444454861EA02D203420D42064404440448445FE4402FF
+:201860002040104017FC00408FFE40045248114024402240CFFE404040A0411042184C08B7
+:20188000400027FC20800080810C569050E0155026503AA8C12646205820402041404080FF
+:2018A000400023FC224403FC8A444A4453FC100017FE2108E10821082208220824082808A9
+:2018C000400023F82208020883F8504057FC144427FC2444C44447FC404040424042403EEB
+:2018E0004040204020A001108A084DF65040104023F82040E0402248215021602FFE20003E
+:2019000040002F7C295489544F5459541954297C2F402940C940494249425142653E4200B1
+:201920004080204027FE0404800053F85000100027FE2040E2504248444448465142408085
+:201940002080104017FE8444404043F81248124823F82248C24843F8404040404040404081
+:201960004080204027FE0404800053F05210121023F02200E3F822082208220823F8220800
+:20198000400027F0201007F090105FFE5040244822502060C15042484C46404041404080F0
+:2019A000400227E22422042A87EA548A548A27EA26AA2AAACAAA52A252A262E2408A408458
+:2019C0004000229022900FFE829042F0520013FC204027FE40E0C15042484C4640404040DF
+:2019E000200017FE1090009087FC5494549417FC2040204027FCC040404040404FFE0000EC
+:201A000040002FFE2040008097FC54A454E424A424A424E4C4A444A444A447FC440400005B
+:201A2000001041902E102210021282525FB41218271026902A90CA28522862444286430468
+:201A40004040275C24440444975C5444544427FC204027F8C210412040C040B0430E5C043A
+:201A60004040208027F8040897F8540817F820002FFC2040C04047F8404040404FFE4000AA
+:201A800042002200257C04A4882447A4522812282FA82310CA904AA8522862464A84040004
+:201AA000200011201110020885F650905090115022202000C7F84528452845285FFE000049
+:201AC0002210111011200FFE8000578414A417A424A424A4E7A424A424842484249425880F
+:201AE0004080204027FE0404800053F8500013F8220823F84208C3F8400040004FFE40001C
+:201B0000400027FC240407FC940057FC5440249025F82448C8404BFC4840504067FE400073
+:201B2000400027FC2444044487FC540055FC150425FC2504E50445FC4904490451FC4104B1
+:201B400044202420247C0F488490447C4F54145414542F7C2440C44044424442443E0000FE
+:201B60002080108017FC008087F851001FFE222025F0288ED7F441C042A04C9C408840808A
+:201B80002080108013F80080908057FC1100221027F82008C7F84528452845285FFE4000FA
+:201BA00047F8221023F0021083F0521017FC20102F7C2944C528422845104868518600002C
+:201BC000411027FE211000A0909057FE112022182D164110CFFE41104210421044104810DC
+:201BE0004110211027FE0110800057FE540413F820402040E3F820402050204827FC0000FF
+:201C0000405020482FFE004087F8544817F8244827F82448C0104FFE42104110405040208E
+:201C200047FE20A020A007FC84A454A417FC204020402FFEC0C0416042504C4E404440406B
+:201C4000000047FC240025F8040087FE554815302590250C2410C7FE489048505010403076
+:201C6000200013F8120883F84A084BF8100017BC14A42294E08C22942CA420842294210849
+:201C8000400027FE240205FA8C424D9214E2156216B2252EE62224A22442240227FE2402E0
+:201CA0000220422027BE26308948408050781780208027F8C0804FFC408040824082407E29
+:201CC000408027F8240807F8840857F8140827F820A02090CFFE414041204210440E5804C5
+:201CE000412021102218052880C050A013102C0C23F02040C3F04040424841504FFE000052
+:201D00004080204027FC044095F8544817FE244825F82440C5F849084908490851F84108CF
+:201D20002040102017FE0108809047FE1484104027FE208020F8C1084108420844284010C3
+:201D4000400027FE240403F8820843F8120813F8108020402FFEE0002110210822042C0464
+:201D60004110211023FC0110811057FE104023FC224423FCC24443FC40004110410842086E
+:201D80004110211027FE011087FE5484112023C020802110C3F840404448444449444080AD
+:201DA000411027FE2110004083F848480FFE104813F8104422E4E35422542444244428447E
+:201DC0002108110817BE0198835C552A1148110820802FFEE110232020C020A023182C0873
+:201DE00040A02FFE20A007FC84A457FC14A427FC200023F8C20843F8420843F842080000AE
+:201E000040402078204007FE848457F8548014F8240025FC24A8C8704BFE482050A04040A4
+:201E2000200017FC144487FC444417FC1080212023C02108C7FC4044424844444944408076
+:201E40004040204027FC044487FC504017FC244427FC2040C24042844A424A0A51F8000035
+:201E6000421022102210052094BE5F64502424A422A82AA8C51041D85E2840C44306400495
+:201E8000002048A0257C222486285AFE1220224026FC2B44D244427C424442444A7C4444FA
+:201EA00040102110297C061086284A4402FE220426F42A942294C2F4420442044A1444080A
+:201EC0004080204027FC04A084A057FC14A427FC24002520C52445B8492049A2513E000097
+:201EE0004450322002201B7E948064EE671425082590295CC95049D0525052B0670E0000AE
+:201F00004010279021100FBE8524556417A4251425142714C50845C85F1841244146410470
+:201F2000420422042FC402048FBE40040F8428A428942F94C0044884450443C45C14400835
+:201F4000448024862FF804A094A057BE14A427A424A42FE4C12444A444A448445044408408
+:201F6000421022102FBE031896B45A52121027F8240827F8C40847F84408440844284410F0
+:201F8000400021902E12025492385F7C5644277C2AC42A44CA7C5244424442444254424874
+:201FA0004080204027FC01108FFE500013F8224823F82248C3F8404047FC40404FFE0000AB
+:201FC0004FFC28042FFC08008BF058201FFC28402FBC2888C91049FE571051106550422047
+:201FE000422022202FBE02448F884ABE1AA21FAA222A262A272ACA884A14522242420000D1
+:2020000040502E482A400AFE8AD05F501A7C2A502E502A7CCA504A504E504A50407E4040E1
+:20202000412027F8252807F8052897F8500017FC200023F82208C3F8411040A04FFE4000D7
+:20204000410021F0222007FE8C90554817FE240025F82400C5F8480049F8510861F80000BC
+:20206000408020402FFE000087FC551415F4240427FC2000C3F8420843F842084FFE0000DC
+:20208000408020402FFC09208FFC59201FF829282FFE2928CFF851205330652E59244120B6
+:2020A00047FC20402FFE8844477810401778200027FC2100C7FC4524452445244524440CCB
+:2020C00022501254155804D08FFE5488145025FC242025F8C42045FC442044504488450664
+:2020E000208013F8120803F882084BF80A0817FC144417FC2444EFFE2110211022102410A6
+:202100002080104017FE011081F0500017FE240423F82190C6E043504CA843264CA04040DD
+:20212000000047BC2294218C029484A45140112023FE222027FCCA2043FC422043FE420025
+:20214000441024103FA804449F8271003F6E31A25F6A4426DF6A44B2452244AE4444000063
+:20216000420023FE0A220FD4888C551816242D62273C4120C73C4120473C41205FFE00003A
+:2021800080805FFE48000FFC2408A7F860002EB84AA84FF8CB684F6852AA534A668E0000CE
+:2021A00040802140222007F898064DDC49542DDC20002FFCA9244FFC4924493448080000B3
+:2021C000488824902FFE02B0848E5FF8548817F824882FFCE2205FFE421044084804000028
+:2021E00000004FBE28882F8808BE9FA252222FAA252A252A472AC22A4B0852942A22044251
+:2022000047FC20402FFE0842875C5000271C25003FBC25244FBCCAA44FBC42245F4C0284AA
+:202220000200018001043FFE2004400800000000000000000000000000000000000000006D
+:20224000020001003FFE40044208020002003FC0024002400440044008440844103C20009D
+:20226000020001003FFE400400007FFE020004000FF818082808480888080FF80808000009
+:20228000010000807FFE40048428023001200440444844844506860404101C10E3F000007D
+:2022A000020001007FFE440484087FFE08001FF028104FF088100FF0081008100850082078
+:2022C000020001007FFE40049FF810001FF010001FFC15001490246025204E1C84080000E1
+:2022E000010000803FFE25045498142423E000001FF811081FF811081FF8110811281010E7
+:2023000001003FFC24481FF804401FF804407FFC08203FD8C8460FF800083FE80008001841
+:2023200001007FFE44441FF804401FF804407FFE082037DEC1001FF001003FFC0100030017
+:20234000020001007FFE440485F824403DF8248807FE7C0024F82488248844F884880400B2
+:20236000020001007FFE820404007FFE28141FF828164FF408100FF011201118251002005A
+:2023800001007FFE4444BFF804403FFC0440FFFE09103FEEC3040C903460C520061C040870
+:2023A00002007FFE40049FF012901FF00000FFFE00001FF010101FF008903860CE38081091
+:2023C00001007FFE44441FF004401FF804407FFC10102FE848268FE0010009F8090037FE7A
+:2023E00001007FFE44449FF804403FFC04407FFC09083FF6C0040FF000000FF008100FF0E3
+:2024000040002000180010000000700010001000100010001000100010002C0043FE0000E7
+:20242000400027FC30202220022007FCF060106010A01120122014E010402C0043FE0000FE
+:202440004200220033F8224004400040E04027FC2040204020402040204050408FFE0000C7
+:202460004000200037F8240805E80528E528252825E8252825082428241050008FFE000049
+:202480000100410031FE114002400240F47C10401040107C1040104010402840460081FC3F
+:2024A0000200420033FC14000840025802E8EF48224822682254220421FC50008FFE000048
+:2024C0004100210031FE220402080440F040125013481248144410441140288047FE800046
+:2024E0000400440024002FBC04A404A4E4A424A424A424A424BC2AA4212050008FFE000089
+:20250000400027F83010202000D80306EC0423F8204020402040204027FC50008FFE000070
+:20252000408020C030902108027C07C8E00023F822082208220823F8220850008FFE00002A
+:20254000003C47C02400240007FE0400E40025F825082908290831F8200050008FFE000031
+:20256000410021F8211002A004600190EE4E23F82040224023FC2040204050408FFE000024
+:20258000005040482FFE204007FC0444E7FC2444244427FC24442454244850008FFE00008C
+:2025A00000004FFC20002F7809480948ED682B582948294829482B58200050008FFE0000BC
+:2025C0000040405020482FFE00400448E25020E02150224C2C442140208050008FFE0000AB
+:2025E000004044482250216003F80208F3F8120813F81208120812281210280047FE00000A
+:2026000000204920252026241AA40168E3302520392021502150258C220850008FFE000030
+:2026200000804080211023F801200218E50821F0232024C020C02130261050008FFE00006A
+:202640000080408027F820800FFC0220E290248C2BF0208020802FFC200050008FFE0000A9
+:20266000003843C0204027FC0150064CE04020802FFE2110232020E0271850008FFE00007C
+:202680004080204027FC0408000003F0E21023F0220023F8220823F8220850008FFE00006A
+:2026A000000047F0201027F000100FFEE080249822E020A022982C88228051008FFE0000B3
+:2026C00000404444244427FC000007FCE08027FC2524252425242534240850008FFE0000E4
+:2026E0000080410027F8240807F80408E7F8200027F8208027F820802FFC50008FFE00003E
+:202700004220212021400FFC014007F8E54825482638240827F8240827F850008FFE0000FF
+:20272000400027BC2484048407BC0400E7BE24242414278824142426244250008FFE0000E6
+:20274000821042104F90023E0FA40264EF9424082788249428A62AC2310050008FFE00007F
+:20276000012047FC212027FC01200FFE0040E3F8224823F822482FFE220852088FFE00001B
+:2027800043F8220823F8020803F80000EFBC24A42294229424A42884218C50008FFE0000D7
+:2027A0000180463C2414251406A40454E00823F8224823F82248224823F850008FFE00004F
+:2027C00007F8440827F8240807F80240E3FC24402FF8344027F8244027FC54008FFE0000BD
+:2027E0000080429021A02FFC02A00C98E410277C2910355022FE2C10201050008FFE000097
+:20280000008040F8208027FE048407F00488E7FC2480274829B02E7031A826A650408FFE01
+:202820000400447C27A429241FCC0A90EFD02AFC2F902AFE2A902A90319050108FFE000049
+:2028400003209C4055F84A8804F81A88E6882AF836502A5032542A54248C50008FFE00009B
+:20286000008040402FFE292406180120EFF82100279021E02ED02148264050808FFE0000B5
+:2028800002484490224827F805480488E7F826C825A826C825AA248626C250008FFE0000F2
+:2028A0000000000000007FF80008000800083FF80008000800087FF80008000000000000BB
+:2028C000082008207EFE08207EFC08207EFE08203FF8000800081FF8000800083FF8000019
+:2028E000040007F004100FE00020FFFE0610192063400CA03150C2580C4E704401400080B5
+:2029000008000FF008200FE00020FFFE441047D0451079164FD8411042905452E852500EA5
+:202920003FF8200820083FF82108210021002FE0212022204220442044228822901E200038
+:2029400000003EFC22842284228422FC3E842800284824644486420441808060801E0000FC
+:202960003FFC200420043FFC242024202BFE322024202DFC3488245044204450848E0504E6
+:202980003FFC200420043FFC20002F7E29042A742C542A5429742F544A0448148808000089
+:2029A0003FFC20043FFC20002FE020403FFE20803FFC2208241046FE5C1044109450082068
+:2029C0003FFC200420043FFC24202920313C25202BFE38202920293C29204AA04C7E880046
+:2029E0003FFC20043FFC212424A829FC327024A82B2638802FFE288849884870888C0B0209
+:202A00003FFC20043FFC22202FFC208027F020803FFC2AA83F7E24105F7E4410BF7E0410D8
+:202A20000000F9FC0808081078204050408C41067A0209FC08200820082008202BFE1000E4
+:202A4000100011FCFE88245064201850648E3FF400101FF010003FF8100800080028001090
+:202A60000000FBFE0908090809F87908410841F84108F908490E0BF808080808380810081B
+:202A800028402840FE7E2A842B08FEFEA892A892FE922AFE2A802A804E824882487E8800A5
+:202AA00000007BBC090409047BBC42A042A042A07BBC0A840A840B840A84501420080000EC
+:202AC000793C0D443B9C27D03B9C0D44191C7FFE08100FF000003FFC24442FF42104210C19
+:202AE0000100010001002108210821082108210821083FF821080100010001000100010078
+:202B0000108010C0108020FCFD042504268444444864483430241004280446248414000887
+:202B20002000300021FC2004FC04240425FC450445004900290011002902450284FE0000B6
+:202B4000100013FE10881088FC88248827FE48884888288810882D082908420882080408A1
+:202B6000200033FC20402040FC4027FE24A048A048A028A010A029204D228A22041E08004B
+:202B8000100011FE11002108FD8C25482528451049102928112819442584450081FE000097
+:202BA000101011101110FD101510251225DC2910491029101110291025524392810E000049
+:202BC0001040104010A01090FD08254626244420480029FC100828102410442080200000F2
+:202BE00010201020103E11E0FD20252025202BFE4962286210A218A2252A4524822000204B
+:202C000020203020212020A0FE2025FE242224224432442A242A184224424682848A010489
+:202C2000100013F810481048FC482448244825F84888288810881088288847FE8400000067
+:202C4000100013FC10081090FC60242027FE242448284820302010202820442084A0004028
+:202C60001004104410241124FD042504250425044908692811481994252244428080010051
+:202C8000100011FC11041104FD0425FC250425044504250419FC09041400200043FE000070
+:202CA0002020302020202020FDFC45244524452445FC292411241924252445FC81040000C1
+:202CC000200033BC22A422A4FAA44AA44AA44FFE4AA44AA432A42AA44AA444A485A4084CBF
+:202CE000010000803FFC082004300240FFFE040004007FFE08200E4001C0063018186008F3
+:202D0000200033FE20902090F89028944A964A9449984890309028904490449083FE0000A6
+:202D200020802080207C23C0F848283028E24B12480C4FFC30A030A029224A22841E080035
+:202D400010201120112021FCFD202620242027FE486068B010A8112C2A264C2488200020BB
+:202D6000010000807FFE024012501A4C224442400100FFFE04200E40018006601818600874
+:202D8000104010201020FDFE249024C82504268A488848503050102028204458848E0104FC
+:202DA000110818CC109013FEFC882488248824884BFE6888108818882D0849088208040850
+:202DC0002040302021FE2104FA00281C29E02840484E4BF03040104028424642843E00000B
+:202DE000200023F822482248FBF82A482A482BF84A48684013FC18402440204047FE8000A0
+:202E00002020302021FC2124FDFC252425FC44004BFE488031F81888240826084428001069
+:202E2000200031FC21042104FDFC452444204BFE4A224A52324A128E2B0A4A02820A0204B5
+:202E4000210030BE22022222FA224A224BFE4A624A722AAA12AE2B2A2A224222820A020497
+:202E600020201428452429A62A281430706013801400FFFE04200820044003800C60701C89
+:202E80002108209023FC2024F82449FC4920492049FE4862286210AA29244A208420002013
+:202EA000200033FC220423FCFA002A1C2AE04A204AFC2A2013FC2A2022224422841E08008D
+:202EC000238022BE22842284FB742B542B544AD44AD44AF4335412042E044A04821402087F
+:202EE0002040304023F82040FBFC48404FFE480049F8490831F831084DF88908012801106F
+:202F00002040304023FC2040FBFC284028404FFE48804924332815102908494E83840100C9
+:202F2000204027FE204023F8F8482FFE28484BF848403240127C2A402B4044C0887E1000FA
+:202F4000200021FC2104F9FC4904490449FC48004BFE2A0212022BFE2A02420283FE02024C
+:202F60002060204023FCFA242BFC2A244A244BFC4A4448A031202BFE4C2048208020002086
+:202F80002108308C205021FCF92429FC2924492449FC302010202BFE4C2088200020002081
+:202FA000100010FCFE88225014200850148E61043FF822882568290822C8244828282010F5
+:202FC000200031F821082108F9F84908490849F848004BFC2A9412942A94429487FE000076
+:202FE000203C33E022442128FBFE284028404BFE488048FC318811502A204458898E060474
+:203000002080304027FE2000F9F8290829F848004BFE740411F828202420442080E0004076
+:203020007E401440087E7E881B482C304830A84E1484FFFE044008400E8003600C1C300853
+:20304000209023FE209023FCF8902FFE28402BF84A484BF8324817FE2A08420882280210F4
+:203060002110311027FE2110FBF82A084BF84A084BF8484037FE104028A04918820E0404BD
+:203080002040208023FC2294FA644A944BFC48004A10321213DC2A102A104292870E020024
+:2030A000203C33E4214620A8FBFE2A4428404BFC488030F010902D502A204450818E06045C
+:2030C0002040302023FE2202FC3449C0490049FC4910311017FE28002D10498C82080400BD
+:2030E0002000212421242124F9FC48204BFE482049FC292411FC19202424443E83C40100E9
+:2031000008403E7E08487EA81C102A28C8443FFE21003FFC221024202340208043608C1852
+:20312000200033FC20402178F9404FFE490049FC490029FC100429442AA442A484140008F0
+:203140002040304023FC2040FA4849504FFE48004BFC4A0432F432944AF44E048BFC000018
+:20316000200037FE209023FCFA942A942BFC280049FC300013FE28202528422684A40040A5
+:203180002020312420A823FEFA044DF8490849F848404BFC324432444A544A4880400040F1
+:2031A000200031FC212421FCF92429FC2840289049F8684411FE082424A8412682A400403D
+:2031C000202033FE20882050FBFE280029FC490449FC310411FC28202FFE482080200020AF
+:2031E000202033FE202021FCFC0025F8250849F84908489033FE100029F8450881F8010820
+:203200002080304027FE2000FBFC4A944AF44A044BFC480031F81148292841F880000FFED0
+:2032200000203DFC24883C5021FE3E2062FCBE2022200420FFFE08400C8003000CE0701C92
+:2032400001007DBE552A7D3E57EA552A7EBE128812BE7D121592255226524652542A88448B
+:203260002080204027FE2488F7FE549855CC56AA9488544024902520564445FE88841000D9
+:20328000200033FC204027FEFC424A5049484900493C4FE4293C13A42B7C2524493C8124BA
+:2032A0003FE004200420047C082408041084209448880CA008901088208C40880280010004
+:2032C000010009201910210845040200FFFE044009201118294ECD241110211005000200D3
+:2032E00000383FC004082210112000003FE000400080FFFE01000100010001000500020041
+:20330000100011FCFE88228814500820145C22884FE0004000807FFE0080008002800100CB
+:2033200008200440FFFE082012483EF808243EFC02041FE0004000807FFE008002800100C1
+:2033400000001FFC001800600080008600B801C00E8070800080008000800080028001005A
+:203360001FF80030004000802100110009000500030001800160011E0108010005000200F1
+:2033800001007D8005000BFC1204140419F43114511491F4110411141108510220FE0000F5
+:2033A0000000F8F808884888488848F848887E88028802F83288C288028814880BFE000020
+:2033C0000000F9FE095249524952495241527D520552359EC5020502050229FE110200002F
+:2033E0000088F8880888490849084B7E49087D4805283528C50805080508292811100000D1
+:203400000040F84008FC488849104A0048FC7E04020432FCC2040204020414FC08040000D5
+:203420000000F9FC08884850482048D84B267C2005FC3420C42007FE0420142008200020FC
+:203440000800FEF8128824501820145C61880FE0082008200FFC00047FE4000400280010E2
+:2034600000207C2004402448248425FE24023E0002FC3284C284028402840AFC048400001D
+:203480000080F88008FC4B88485048644B947C0C07FC3490C490049005122912120E000091
+:2034A00000907890089449984A9048B048927C8E042005FE3420C420042014200820000062
+:2034C0000108F88808904BFE4888488848887C8807FE04883488C48805080508160808082D
+:2034E0000000F3FE100053DE5252525252527B5A0AD63A52CA520A520A522A5212D6000035
+:20350000F888088848884BFE488848F848887CF80488148827FEC490048815040A040000DA
+:203520000000F9FC092449FC4924492449FC7C2007FE146024B0C4A80528062614240820F7
+:203540000080F8A0091049FE4B204D2049FC7D20052015FC2520C520052015FE0900000098
+:203560000040F89009F8480848404BFE48A07D18064614902724C4C8071014600B80000007
+:2035800000407A78524077FE49406A50506041801FF008100FFC00047FF400040014000875
+:2035A00000207E20143EFF441AA82818D86600000FF008100FFC00047FF4000400140008BF
+:2035C00008207E20083EFF4810481EB02248CFE6002008200FFC00047FF400040014000869
+:2035E00000407BBE0A124A924A524AA24B4A7E0405FC152425FCC524052415FC0904000030
+:203600000040F02013FC120493FC92009200FAEE0A222AAA4A668A660AAA2B22146600007F
+:203620000000FBFE085049FC495449FC48007DFC040017FE2420C52805242A2410A00040A0
+:203640000020F84009FC4944497C4994496441547DFC04402420C4A406822A8A107800006F
+:2036600003FCF20413FC520052F8521053FE7A200BFE0A442A88CBFE0C8855A82890000042
+:203680000090FB9C08924B9249FC492449FC7D2405FC149025FCC49007FE1488090400002C
+:2036A0000020FBFE095449DC489049FC48907DFC049017FE24A4C598068814CE0884000037
+:2036C000080008001000100021007E002400080010002700780000000700F8004000000001
+:2036E000100811FC202024204420F82017FE20204C20F02000200E20F020402000A0004036
+:2037000010101010201028104BFEF010101021104C90F0D040500C10F0104010005000205F
+:20372000108010C0208025FC4500FA004DF8101020207C40008000801D02E10240FE000088
+:20374000104010402040244045F8F848104821484CC8F04840A80CA8F10A420A0406080086
+:2037600010401020202025FE4500F900110021004100F900010001003A00C20004000800B2
+:203780001000100811FC240024004804FBFE104020407C8020900C88F10443FC010400003E
+:2037A00012201220222022204A20FBA6123822204220FA20022002221AA2E322421E0000A7
+:2037C000100019FC100420884450F82013FE20247C28002000201C20E020402000A00040A7
+:2037E00021083108210841084FFEF1081108210841F8F908010801081908E1F8010800001E
+:2038000020002148414841488948FFFE114821484148F948017801001D00E10001FE00003C
+:2038200020803090208840884BFEF080108020FC40C4F94801481A30E2300448088E010482
+:20384000108010C0108021FC29084A10F5FC100420044004F8FC000400041804E1FC00006E
+:203860001090109023FC20944894F3FC1290229043FEF8920092011A1914E210041000105B
+:20388000002010201020212421244924F12421FC4020FA22022202221A22E3FE020200009A
+:2038A00010401060204028804888F10413FE20044000F9FC010401041904E10401FC000008
+:2038C0001040104023FC20A04910F60E11F4200043FCF88000F800081808E00800280010F0
+:2038E0001000117C21002A004A80F4FE1108230825084108F908010801081908E12801101C
+:203900001080108021F82A904860F090114E264443F8F240024003FC1840E040004000401D
+:20392000200023FE202041FC4924F12411FC21244124F9FC022001401880E1400630180E23
+:2039400010201A24112620A84420F9FC0904110421FC7D04010401FC1D04E10401140108BB
+:203960000208211033FC20444844FBFC1240224043FCF8C4014401443A54C448084000409B
+:203980001040184013FC20404840FFFE1110228844FEF114029000A01860E090030C0C0440
+:2039A0001020182013FE20204450FC88090413FE20047DE4012401241DE4E0040014000848
+:2039C000209030902090239E4890F890139C20904090F890079E00903090C090009000908A
+:2039E00010201A2411A629284C20FBFC120422F44294FA9402F41A94E204021402080000B4
+:203A0000200033F8220843F88A08FBF8102022204224FBA802301A20E2A44726021C000079
+:203A20000000203C33C020404FFEFA48124827FE4248F24807FE00401840E04003FC000049
+:203A4000201C33E0224441244928FBFE1204200043F8F91001101CA0E04000B0030E0C04AA
+:203A60002210321023D84A54FD54109020904160FA1E07F802081A08E20803F802080000C5
+:203A800000401448125020404FFCF88017FE21204210F5EE092401201960E108010800F8C9
+:203AA0001040182013FE22024404F9F80908110821F8790001FC01041904E1FC0104000053
+:203AC000212431B6212842504A48F926109423FE4222FA2203FE02221A22E22203FE000083
+:203AE0001110191027FE211049F0F84013F8124822487BF8004007FC1840E0400040004038
+:203B000021003100213C21244FE4F93C13A423644564F53C092401241924E13C012401005F
+:203B2000100019FC110421FC4904F9FC100027FE4020F920013C01201920E2A00460081E9B
+:203B400020103790249044909794E4D224D247D4F496049404883790C02000C003000000DC
+:203B6000204033F8224843F84840F7FE100023F84208FA48024802481AA8E09001180208F8
+:203B8000000023F8324822484BF8FA48124823F84000F920051405123502C90800F80000A3
+:203BA0002200337E221046FE4A92F2FE1292229242FEF210029002601A20E250028E03045F
+:203BC00000002278330822084AFE4A40F27C125022907AFE021002101A28E22402460282E2
+:203BE0000020244032F82288488848F8F680128022F87A88028802881AF8E50008FE000028
+:203C0000000023F8320823F842204BFCFA20129423147A0C01F801081DF8E108010801F80C
+:203C2000200033FC209042944998F09017FE200041F8F908010801F81908E10801F80000DA
+:203C4000204037FC204043F84A08F3F8120823F84208FBF8020807FC1910E108020C040452
+:203C6000200033FC22004BFC4A00F3FE12A822907ACE029003FE3490C4500810105000209A
+:203C80000080204037FE200049F8F90811F8200043FEFA0202F202921AF2E202020A0204BD
+:203CA0002080204027FC40004AA8FA4812A823F84040F7FC04A4051437FCC4140404040C41
+:203CC0000008220C318820904BFCF9101188220647FCF2A802A802A81AA8E2A80FFE0000AA
+:203CE0002108309027FE40A04BFCF8A417FE20A443FCF8A001B01AA8E4AE08A400A000A052
+:203D00000040202033FE22044838F9C0110021FC4110F91003FE00001910E10802040404EA
+:203D2000200037FE209023FC4A94F29423FC4000FBF8000007FE1840E2480444094400800D
+:203D400023F8320823F842084BF8F80017FC24A447FCF00003FC01081890E06001980E06C3
+:203D6000100019FC212425FC4524F9FC084811F020287CC401FE00241D28E22604A4004029
+:203D8000200033BC20A44A944994F2A4104420A073580C86032018C8E310006001800600B1
+:203DA00002482248349022484BF8FA4813F8224843F8F84007FE18E0E158024E04440040A6
+:203DC0002200227E22104FA0527CF2442F5420544754F55405543710C528004600820000CC
+:203DE0002040304023FE4A52498CF1FC170A11F8210879F800201928E126022404A000403E
+:203E000021043084208843FE4A22F2AA127223FE4000F9FC010401FC1904E10401FC0104F8
+:203E200027FE300023F842484BF8FA4813F8200047FCF00003F802481BF8E2480FFE000016
+:203E4000002020FC34A422FC482049FEF00016FC228442FCF28002FC1A84E2FC050008FEA4
+:203E6000200031F0211049F04800F7BC14A427BC4040F7FE00E001501948E24E0444004042
+:203E800013FC1A9413FC20004BFEF80011F8210879F8004400A81D90E28804AE00C4008059
+:203EA0002528352827BE494857BEF29412D424A243F8F208024802483248C0A001180608D1
+:203EC00001000180010002000410081810207FC0208001000210040808FC3F0C1008000094
+:203EE00011201128254879F015283D7C0504FFFE00887E8852907E6052427EA2431A000621
+:203F0000000008880CCC088811102110222044404220211011081088088408840000000035
+:203F200008841108221044202210110811083FF8210821083FF8210821083FF82008000071
+:203F4000088811102220111000001FF010101FF000003FF821083FF8200220021FFE000017
+:203F600000007DFE10201020102010207C201020102010201E20F020402000A0004000004C
+:203F80000000FDF02110211021102110F9102110211021103A10E210441208121012200ED8
+:203FA00000407C4013FE1040104011FC7C40104013FC104410441C446054004800400040A8
+:203FC00000107C9010D01088110811047A0615F8104810481C88E08801080210045008203F
+:203FE00000400020FC2027FE21082108F9082110209020A0204038A0C1100218040E1804DB
+:20400000000003FCFC40204020402040F84023FC2060205020483848C04007FE0000000011
+:2040200000007DFE10041004100411E47D241124112411E411241C046004000400280010DF
+:2040400000400050FE48104817FE10A07CA010A410A410A811301D22E16202A2041E0800A0
+:20406000002000207C20103E102010207C20102011FC110411041D04610401FC010400002B
+:2040800000A000A8FCA421242120233EFDE021202110211021103910C10A010A0106010277
+:2040A000004000607C4011FC110411047D04110411FC110411041D04610401FC0104000018
+:2040C0000000FBFC2204220423FC2220FA20222023FE222022203A20C2140294030C020460
+:2040E0000200FA00220027DE22522252FA5222522252225222523452C45E095210802000E6
+:204100000000FBFE2088208820F8F888208820F820882088389EE7E80008000800080008E9
+:2041200001100110FD10211427FE2110FD10211021142FFE20003C90E108020C040408042E
+:204140000000FDFE1020104011FCFD04112411241124112411241C50E048008603020000AE
+:204160000000F7DE20922494249477F821942192229222923492C49A089410900290011006
+:2041800001000104FA7E240028002100F97E220826082A0822083A08C208020802280210B7
+:2041A0000090F8902090249422942298F89021902298249420903910C1120212040E08006A
+:2041C00000800080FDF8210822902460F8602090210E23FC25083908C10801F801080000FC
+:2041E000080008001FF8210849201110250802003FF8010001001FF0014001207FFC000091
+:204200000000FBFE2242204023FC2080F8A0212023FC212020203BFEC02000200020002030
+:2042200000200420FAFC224020502090F0FC2E10221022FE22103A10C2100580087E0004E9
+:2042400001087D0813FE1108110811F87D08110811F8110811081BFEE0900108020404020D
+:2042600001100110FFFE2110211023FCFA48224822482FFE28C03120C2100418080E3004EA
+:2042800000400040FBFC20A021102208F7FE200823C8224822483BC8C24802080028001061
+:2042A00000400078F84023FE22442270FBC4227C220022F022903C90C4920912120E240031
+:2042C000000003FCFA04220423FC22042204FBFC2000222023A622383A22C2A20322021ECF
+:2042E0000040F840214C215022602090F90822442542214C227038A0C0900108020E0C0418
+:2043000000400020FBFE2202240421F8F800200023FE202021283924C226042208A00040CA
+:2043200000400020FBFE22022504210079FC2264266429A420B43928C22004220822101ECF
+:204340000000FBFE2202249421087244204027FC20C021603950C24804460844104000400C
+:2043600003FCFA04220423FC22202220FBFE2220222025FC25043D04C90409FC1104200068
+:204380000000FBFE220222FA220222FAFA0221FC210421FC210439FCC10401FC0104000028
+:2043A0000040F8A02110220825F62800FBC42254225423D42A543254C3D402540244028824
+:2043C000003C7BC024842248225027FC788027FE208021F82A903250C4200850118E2604A8
+:2043E000000077BC2484248427BC2484740027FE242424242FA83438C410042804C6050470
+:2044000001240124FA48249022482124794423FC220422942A643264C294020403FC020470
+:20442000003CFBC0212420A823FE2242F44823FE208028FC3148C15002200450088E030435
+:2044400000400020FBFE222023FC2224FBFE222423FC222025FC3504C90409FC110400007B
+:2044600001100110F7FE211021F02040FBFC224423FC204027FC3040C3F800400FFE00000C
+:20448000011003FCF910211027FE2000FBF82248224823F82A483248C3F8011002080404E1
+:2044A00007FEF52A252A252A252A25AEFA5424A2288027FE28903190C06000D8030C0C04A7
+:2044C0000040FA44224423FC21442120FBFE26202BFC22202A2033FCC220022003FE02000B
+:2044E0000040F88023FC224422F423947A64229423FC204029603524C50A090A00F80000E3
+:204500000420FA20223E2F402480247EF7102510255E255035502950C9500A70129E2504AA
+:20452000004003FCF908209027FE2000F9F8210821F8210829F83040C7FE004000400040D4
+:2045400000A004A4FAA820B027FE2110FBFC204023FC20402FFE30A0C0900118060E1804DF
+:204560000100F9FC252427A824902B28FA4424802A48215027FE30E0C158064E1844004023
+:204580000040F878204027FE247A27C4F47C240027FC24C03F64C4A80B580896135420200B
+:2045A0000020F7A024BC24E424A82798FA10222823462ABC2A243AA4CB241C3C0024000097
+:2045C00000203EFC22483E5021FE5E2052FC9E2000207FFC01003FF801200110FFFE0000DE
+:2045E0000528F7BE25282FFE2318FDAA25462BFC22082A483248C24802A8011006081804E6
+:20460000080033EC22243BEC22A43BAC22247FFE4002BFF801003FF801200110FFFE000036
+:2046200000203E2022FC3E2022203EF80020FEFC082428242F34282858204C0083FE00007E
+:20464000200020F8FC8820F82088F88820F82000FDFC2554255435542954215427FE20007B
+:20466000100010387DC0104411247C881040119CFD04150415DC15041D04110411FC11049F
+:204680001000100017FEFD101110311039105510551051109110111012121212140E1000C6
+:2046A000108010C01080FDFC110432043804348454445044900410041004101410080000AE
+:2046C000100011F81008FE081008100839F8350055005100910011001102110210FE100081
+:2046E0001000100013FCFD041144312838A8349054505020902010501088110E1604100033
+:20470000100013F81008FD0811083108390835FE5402500293FA100210021002100A100402
+:20472000100011FE11201120FD20112039FC3524552451249124124412441494110800000C
+:204740001000122012201220FE2012203BBE3620522052209220122212A21322121E100021
+:204760001020102010201020FD2811243A2234205024502490081010102010C017000000B8
+:20478000010001007FFC038005401930611C01081FF0101010101FF0101010101FF0101038
+:2047A0001020102010201020FDFC112439243554554C51849104110411041104111411089D
+:2047C000100011FC1104FD44114431443944554455649164106010A010A21122161E10008F
+:2047E000108010801080FDFE112012203820342053FE50209020102010201020102010209E
+:2048000011001108110CFD18112031403BFE550051409120112011101118114E118411004A
+:20482000100011101110FD101110111039103510511051A89268122814441886130410009E
+:20484000010002001FF012101110113010001FFC01047FF40384054C1930611C0108010077
+:20486000104010201020FDFE104010403840347C544450449084108411041214140810008A
+:20488000100011FC1124FD241124392435FC550051009100110011001102110210FE100045
+:2048A000100013F8101010A0FC40104037FE38445448504090401040104010401140108003
+:2048C000010001007FFC03400530191C61081FF00000FFFE01001110310CC1060504020008
+:2048E00010901090109013FE7C9010903BFC344454445044904410541048104010401040C0
+:20490000100013FE1040FE4010403080388055FC5584928414841884108410FC1084100078
+:20492000108010901088FC8013FE30A038A054A454A491281130126012A21422181E1000EE
+:20494000100013FE12401240FE7C32883A90571052209230124812841304120013FE1000BF
+:20496000100013FE1020FC24112430A838B0542057FE902010201020102010201020102038
+:2049800010401040107EFC40104031FC39045504550491FC11001200120014001800100043
+:2049A000100011FC1124FF24112439FC3524552451FC902010201020102010201020102029
+:2049C000100011F81108FD0811F830003BFE5480548090F810081008100810081028101046
+:2049E000102010201020FC2013FE32223A22562253FE922212221222122213FE12021000FC
+:204A0000100011FC1104FD0411043104390455FC54009010108810C41106120214021000DA
+:204A2000101C11E01100FD00110031FE391055105570911811161212121014101810101016
+:204A4000101E13E01200FE0013FE3A0036F852885288928812A8129014821482187E1000B0
+:204A60001040104010A0FC901118324E3824542051FC90081010112010C0106010301020FB
+:204A8000108010C0108011FCFD04320439E455245524912411E410041004101410080000C5
+:204AA0001000103C11E0FD201120312039FE5520552091101110114A118A112610121000C8
+:204AC000101C11E01120FD2011203920352051FE50209128112412261422102210A010403F
+:204AE0001040102013FEFE04120810803880348C54B050C09080108010821082107E10008B
+:204B00001000100013FC1108FC90106030603998564E5044904013FC1040104017FE100014
+:204B2000104010401044FDFC104813FE3820344050FC5140967C10041004100410141008EC
+:204B4000104010401044FDF4104830503BFE54405080918C12F01C8010821082107E10007E
+:204B60000000100013FE10901090FC9010923A9435985090509090901090109017FE1000C6
+:204B80001040104013FE1040FC441028383235CA500657FE9120112012221222141E1000FC
+:204BA000100013FE1040FC401088388435FE5024502091FC102010201020102013FE10006F
+:204BC00010201020103E1020FC2011FC3904350451245124912411241050118C1606100259
+:204BE0001040104012441148FD50384037FE54A050A090A010A0112211221222141E1000CC
+:204C00001020122412241224FBFC100033FC3804540453FC920012001202120211FE1000BE
+:204C2000100C17701110FD1012103AFE3790509050909510137C110012801460181E100031
+:204C4000101C11E01020FE20102033FE3820342051FC510491041104110411FC1104000059
+:204C600010001040119C1104FD043104390455DC5504910411041104110411FC110410000F
+:204C800010A010A011241128FB3011603922351E5440504097FE10401040104010401040B3
+:204CA00020002100217EFA00250071006AFE6A08A6082A08220822082208220822282210A6
+:204CC0001040104010A0FC9011083AF63400500057FE904010801090110813FC100410008A
+:204CE000102010201EFC222024A055FE0820102021207FFE038005400930310EC1040100C5
+:204D000002000100FFFE04401450244C4444054001007FFE034005201918E10E01040100A2
+:204D200001001110093005403FF802007FFC08403130DFEE038405601918610C0104010019
+:204D40001040102013FE1204FE403860344053FE5088908811881050103010C817061002E1
+:204D6000100013FC1044FC4410443254394C5444504C915412641444104410441154108895
+:204D800008200820FFFE18301C682AA6CB20080007E00420062005A004A20822301E000043
+:204DA00010201120112011FCFD201220382037FE5400500091FC11041104110411FC1104E6
+:204DC000103C13C01000FC441128389035FC50085010902017FE10201020102010A0104025
+:204DE000108010F811101120FBFC1124392435FC5124512491FC11241224122414141008B7
+:204E00001040102013FCFD0810903890342053FE5020902013FE10201020102010201020D0
+:204E20002010221021102110F854245472926812A110A11422042E0822082210226021802B
+:204E4000100013F81008FDF810083BF83400504052449258166010A01098110E1604100084
+:204E60001040104013F4FC44104837FE3820544051F893081D0811F81108110811F811086C
+:204E8000081008107EFE1C382A54C992081002400C203018DFEE02240420182060A00040DC
+:204EA0001040104011FCFC4013FE3804352050A05220912017FE102010201058118E1604BE
+:204EC0001000FEFC108028807EFE0890FE9009100B100100FFFC03800560191EE1080100B5
+:204EE00010201020103E1020FDFC110439FC350451FC5020902017FE102010201020102016
+:204F0000100013FE1252FE52125233FE3880548051FE928414481030102010401180160073
+:204F2000200023FC2040F84027FE71486948A7FEA148214827FE20402040204023FC200090
+:204F40001040102013FEFC00100031FC3904550451FC9020112811241226142210A0104018
+:204F6000104017FE1000FDF8110839F8340051F85010902013FE10201020102010A010404F
+:204F800020102710217C2214FAFE2414777C6910A17CA910257E2210231024D0283E2000E3
+:204FA0001040104011F8FC4813FE3048384855F85044934810F01150164C10441140108047
+:204FC000100013FC1204FA0413FC3A20362053FE5220922015FC15041504190411FC1000ED
+:204FE000204027FC2040FBF8208067FE7110AA08A5F6204027FC204020A023102C1C2008C2
+:205000002108210827FEF90821F8710869F8A108A1082FFE229022882304220023FE2000C0
+:205020001020102013FEFC4010803BFE368A525253FA922213FA122212221222122A12049A
+:205040002040204023FC2060F8D8214E764469F8A108A1F8210821F82108200027FE200085
+:205060001040104017FE1040FBFC13543AE4364453FC50C091601158124E14441040104024
+:205080001090129012BEFED01288380037F85208524892481248126810A213221C1E10005C
+:2050A000100011F81108FDF8100037FE390855F8510891F81108113E17C810081008100885
+:2050C000100010FC10841084FC8410FC3884340053DE525292521252125213DE125210002A
+:2050E000200020FE7E8048FC88847EFC0880148062FE0100FFFE03800560191EE10401002B
+:205100002010211026102210FA122F9262547238A710A6902A102A28322822442286230491
+:205120002080233C22242224FBA4224672006BBCA224A22423942E082218222422C6220041
+:2051400020202420224022F8F888208870F86E80A2FCA284228422FC2200250028FE2000BC
+:205160001040102013FC1108FC9010A03BFE3420502051FC902011281124122410A01040AD
+:205180001200113E10021202FAFA128A3AFA3602520252FA928A128A12FA1202120A1204E2
+:2051A000110810901060FBFC10403BFC348057FE5080910011FC12201420102013FE10001A
+:2051C0002088248C2248F95027FE71206910A248ADF62040204027FC2040204020402040A5
+:2051E0001040102013FE1204F80013FC380035F8510851F8910811F8100017FE1000100013
+:20520000100011FE1122FD2211FE310039FE558251FE928212FE1282148214FE1882100076
+:20522000200027FC21082110F93C210472F46A94A264A494290823FC22A422A422A42FFE06
+:205240002040204023FC2040FBF8208077FE6910A2E8AC4623F820D0234C2C442040204068
+:20526000200027FE2450FC5027DE74506C50A7DEA450245027DE24502450245027FE200011
+:20528000100011FC1104FDFC110439FC340053DE5042914A10C6114A12521042114A1084F1
+:2052A0001140112013FCFA2017F83A2037F8522053FC9240104017FE104010401040104073
+:2052C0002104220427C42444F45E27C474446FD4A44CAFC420C42144264438442154208849
+:2052E000104013F81208FBF812083BF8344057FE50A09118164613F81040104010401040F0
+:20530000204027FE2000F9F8210877FE6908A1F8A0C020A4212823102D08214E2184210045
+:205320001040102013FE1000FCF8108838F8340053FE520292F2129212F21202120A1204C5
+:2053400011000A3C3FA4043C15241F3C04240854110801007FFE038005401930611C01088D
+:205360001040102013FE1204F83011C0390035FC5110511097FE10001110120C1C0410004D
+:205380002040202023FEFA04209071086A44A040A0A023182DF621102110211021F0211024
+:2053A0001020142012FE1024FC2811FE3E103620527C52C49344127C12441344127C104496
+:2053C000100013FC1204FFFC12203AA4366852FC528492FC128414FC148418841094108827
+:2053E0001110111017FE1110FDF010403BFC364453FC504093FC104013FC104017FE100005
+:205400001020102011FC1020FCA810703BFE340051FC5104917411541174110411FC110496
+:20542000201020182014F7FE249074906CF4A496A7F4249425C826A8289A28A63286210210
+:2054400011FC102013FEFA2211AC382035AC500051FC900013FE1040107C10041014100882
+:205460001020112410A813FEFA04100038F83488508850F8902011FC1020102017FE1000A2
+:20548000044429FC10486BFE0C4014F8658806F8288811F801007FFE05601918E10E0104DA
+:2054A0002204220423C4F49427CC75446D64A7D4A544257E27C4254425442944294430C422
+:2054C0002010279021102110F7DE22A473A46AD4A394A29422C823882C8C209420A620C47B
+:2054E000221022182214F790227E6FD07252AA4CA3C82A5A2A462A662A422E0031FE200012
+:2055000012207F20127E40487FA84110BD1825243D44030000807FFE01C002B00C8E3084CA
+:2055200001007FFC01001FF011107FFE40041FF008001FF068100FF001007FFC03C01D38CC
+:20554000200027FE24002648FD48248877FE6C92A6ACA6A827E82488250829142A2234C209
+:2055600010A01090111011FEFB2011FC392035FC5120512091FE100012A4125214521000E8
+:205580002040206021982646F1F020A072486AA8A3F8A04027FC24A425F424142404240C8A
+:2055A000108010F81110FBFC112439FC352451FC500093FE100011FC110411FC110411FCE9
+:2055C000111010A017FEFCA013FC3AA4371C53FC520493FC101017FE1110111010501020CE
+:2055E000100013FC1204FBFC12A83A7036AC520052A092FC132015FE142018201020102055
+:2056000011FC1008103013FEFC541190383037FE5292528E9372125212721202120A12048F
+:205620002020223C2224FA78250877FE6A20A462AEB420482298242C284A2188202820107B
+:20564000100011FC102013FEFA2411AC382035AC500051FC912411FC1124112411FC1104ED
+:20566000108010F81110FBFE12881B26361033FE520052FC920012FC140014FC188410FC1A
+:20568000104017FE1000FBFC12043AF4369453FC500093F8100017FE10401248124614C269
+:2056A00000203E1022FE3E2820FE3E10527C5E10811001007FFE03400530190E610401003A
+:2056C000102013FE1204FD0011D03A643598530852F6940013FC10201128112412A4104040
+:2056E000422022282424FF242820FEFEAA20AA20AA50CE508250BA888288FF0C82060404EA
+:2057000008407F40087E7F880948FF3010283E444AA08510FFFE024004200818300EC004B7
+:205720000000FEF0109010923C92250E660055FC88880890105010202058418E8E04000070
+:205740000000FEF81088108820883EF844886488988808F8108810882088408887FE000048
+:20576000008000807EFE110012F83E10222044FC645498540894112426444184861400087C
+:205780000020FE20102010503E88232E444464809B10082010C41708203040C08F00000013
+:2057A0000000FDFC110411FC20003DFC45044504A924192411242154404881840604000098
+:2057C0000020FE20106010503C88250C46F6640098440944112810A8209047FE8000000097
+:2057E000001C7DE0104411283E9023FC4208641094200BFE082010202020402080A00040E3
+:205800000088FE48105011FC1D2425FC2524552489FC0820102017FE2020402080200020D7
+:205820000000FDFC2008201038204BBE4AA24AB4AAA812AC13B22020206040008FFE00006A
+:2058400000400020FBFE220420183DE0450049FCA910111017FE200020904108860C000050
+:2058600000000020FDFE202020FC20003DFE450464FC580088FC108410FC2048405083FEB8
+:20588000100010007FFC1024282428A448A4FEA448A409241E44E8440884088409140A08A5
+:2058A00010001000FDFE2100217C51449144FD44114411541D48F14052421242143E1000CA
+:2058C00010201020FE2020202BFE48204820FE2009FC09041D04E904090409FC09040800AC
+:2058E0002000300021FEFE08200851E85128FD28112811E81D28F00810081008102810103D
+:2059000010201020FE3E202028FC28844884FE8408FC0E803880C8800880090009000A0057
+:2059200010001000FEFC2084508450849084FE8410FC1E00F048104410841082110212006A
+:2059400010201020FD20212051FC52209020FDFE102010201E50F0501088110C120614042C
+:20596000202030202050FE88212622344840FE90491808240EC6F908083008C00B00080079
+:205980001000101EFFE01024212628A448A8FE2049FE08201E20E8200820082008A00840A0
+:2059A0002000203CFDC02100212051205120FDFE102010281D24F1A21222142010A01040CB
+:2059C000100011FCFE441044204428844894FD080AFC08841E84E884088408FC088408005F
+:2059E000202020282024F82027FE50205020FBD0109010901C90F08A10EA17061202100052
+:205A0000100013FCFC4020502088509C51E6FC24102011FC1C20F0205020102013FE100086
+:205A200010201020FE5020882104520291F8FC20102011F81C20F0201020102013FE1000EC
+:205A400020802080FCFC2088418852509020FCD0130E11FC1D08F108110811F811081000E8
+:205A6000200033FE2148FD4821C851489148FD4811C811483D48D17A17CA104A10461040A4
+:205A800008203EFC08207EFE1420225042883FF8040009001FF80100FFFE01000100010034
+:205AA000200021FEFD022186214A51FEFD42112211FE1D42F142117A11021102110A110453
+:205AC000200023FCFC8422A8411052A89044FFBC14A412A43D28D29012A814A6184410004E
+:205AE00020A420B6FD242148224451325122FDFC112411241DFCF1241124112411FC110409
+:205B000020402040FBFC404053F8508093FEFD0812F41442FBFC104010A01110120C1408EF
+:205B20002040202023FCFA90229053FC9294FFFC12901E94F29652D8129014D2148E1800B2
+:205B400010201124FCA823FE207050A89126FD0811FE1A483668D9BE11A811081208140829
+:205B600001007FFC01001FF011101FF011101FF00100FFFE01001FF0101010101FF01010BC
+:205B800002000240022003F87E00020003FC7E000110013800C000C003640C14700C0004D6
+:205BA0000840085014481240217E41C0BE402248222C2A2824102012222A1E460182000056
+:205BC0007FFC01001FF010101FF010101FF010101FF0022003FEFE10012001C20E72700E9A
+:205BE00010401050FE4810407C7E45C07C4044447C2410281010FE3010CA130A10061002D7
+:205C000000003E2022283E240020FFFE22203E2022243E1423182E10F26A038A02060202B7
+:205C2000222022202228FFA422203E3E22E03E242216FF94400C5208511A60267F46018227
+:205C400000203F2021283F2421203FFE482048287F2C4818BF1008300F4A788A210600022D
+:205C600000207E2024282F243D3E35E049245516A6147F185508551857AAF8460182000082
+:205C800000207F20142855243624147EFFA000223E2222143E182212222A3E4622020000CF
+:205CA000002800241FFE502057A05524752617A4F4A857905510553297CA2086210240006C
+:205CC00000007EFE40404440644054784848484854A852A86288408A40AA7ECA0086000052
+:205CE000100011FE1840244042789148084808487EA804A82888108818AA08CA0086000062
+:205D0000100009FE7F400040227814487F4800683E5822882288228822AA3ECA2286000038
+:205D2000080C7F7009863E1822603F8614187EE00000FFFE08000FE0122011A216A2181EE3
+:205D4000040045FE2840FF409178D548B948FF4800687E9842887E88428A42AA7ECA4286D1
+:205D60003E2023FC3E8820507FFEA4203DFC2420FFFE08000FE0092008A008A20A220C1EED
+:205D800001000100010001FC010001003FF81010082008200440028001800E60F01E00088F
+:205DA000020002007FF00210041004120812300ECFE0082008200FE0082008200FE0082087
+:205DC00000001FF810081FF8100810081FF8020002007FF00410041008121012600E0000F1
+:205DE00000007DFC4420442044207C20442047FE442044207C204420002000200020002071
+:205E000000001FF810081FF810081FF800003FFC01000100FFFE028004401830E00E0004D3
+:205E20001FF010101FF010101FF0000000003FF80000FFFE0200042008103FF81008000034
+:205E40001FF810081FF810081FF8010001007FFE0180034005200918310EC104010001003E
+:205E60001FF810081FF810081FF800003FFE2080208020802140212042184C0EB004000086
+:205E8000003879C049004900490079FE4910491049104910791002100210041008100010F2
+:205EA00000807CC0448044FC450445047E4444244414442444447D840004001400080000FD
+:205EC00000101FF810101FF010101FF00100010009080A9012A0244004200810100E6004BC
+:205EE0001FF010101FF0101010101FF008001FFC10843084514416241FF4000400140008A8
+:205F0000102010203F30212C52248C200E2031A0C07E1FF010101FF0101010101FF0101059
+:205F20001FF810081FF810081FF800000C0030FC224422442E44325404481840604000406C
+:205F400000001FF010101FF0101010101FF0010000807FFC0820082004400480FFFE0000A3
+:205F60001000087C00447844084408FC0D44EA442A44297C490048808860283C101000002E
+:205F800003FC7A044A044A044BFC7A804A804A804A8C4AF07A80048004820882307E0000C7
+:205FA00001001FE801107FFE00C003001FE8E40807F800000FF808080FF808080FF8080851
+:205FC0001FF810081FF810081FF8005000483FFE20403F48214825304232404A80860000CE
+:205FE00000A078A04924492C4B304D627922491E494048404FFE784048400040004000407D
+:2060000000003FF820083FF820083FF8028022881A9006E00AA01298648A04820882307ECF
+:206020001FF810081FF810081FF801007FFE420404007FFE082006400180076078180008B8
+:2060400003FE7A04484048404BFC788048A0492049FC4820782007FE002000200020002057
+:20606000005078484BFE48404BFC4A447A444BFC4A444A444BFC7A44024402440254020858
+:206080000040004078A049184A8E4C447BF84810482048404BF87A080208020803F8000010
+:2060A0001FF010101FF010101FF010401F6032504C481B40E0FE1FF0101010101FF01010D7
+:2060C000004000207BFE4A0448004BFC480079F8490849F84908790849F8000007FE0000A7
+:2060E00007C870D054A453285110720855F65840504057FC704000A00118060C18040000E6
+:20610000003C07C0F288915097FE9484F08097FE910091F8F31092A0044008B0030E1C04F3
+:2061200000007BFE4A0449F8490849F8790849F848404FFE78004910010802060402000046
+:2061400002100118F7D0901E979494A4F7A4905497D49088F1C80F140114012605C4020057
+:20616000000003F8F04097FE904097FCF55497FC904097FC9040F7FE800004A80454085418
+:20618000000007BCF0849294918C9294F4C4922093FC96209BFCF22093FC022003FE020053
+:2061A000012077FC504057FC504057FC702057A8512457FE7390555407EA021A03A6008248
+:2061C0001FF011101FF001007FFE12881EF804203FFC04203FFC04207FFE0C901560661E5E
+:2061E000010001007FFC09200920FFFE08201FF01010111011101110128004401830600C8F
+:2062000012201220FFFE122013E010001FFC00001FF011101110111012900460183060109D
+:2062200000007DFC4504450455045504550455FC545054501050285024924692850E0200B4
+:2062400000407C6044404488548455FE5484540054FC54841084288424FC42848284000027
+:20626000084008407DF008503D9208CA29241FF0101011101110111012900440083010100B
+:20628000084008402F4C287028423F42E03E00001FF0111011101110129004600830302052
+:2062A00000807C4047FE54405480551057F855205448548C131028302C4C49868602000006
+:2062C00000007DFC4504450455FC5524552055105588554611342A102440443080100000B0
+:2062E0000000F9FE8900A9FCA900A900A9FEA950A954A958225022485A4854668844000085
+:2063000001003FFC11100920FFFE03400D30310EDFF4101011101110111002C00C3870105F
+:2063200000287C24442457FE5420562455A654A8547054B011282A242426442480A0004092
+:2063400001007FFC0920092015507FFC40041FF0101011101110111012800460081C300867
+:2063600000207CA444A4452054505488550656205424552851202A502448468C8506020490
+:2063800000287C2447FE542055FC552455FC552455FC5524540813FE2908248844A8801058
+:2063A000100011FC11041F24112411247D24452445244450445044907C924512020E040016
+:2063C000100092FC928492A4FEA400A47CA404A404A47C204050405048925112620E440070
+:2063E0000700F8FC08844A844AA44AA44AA44AA4ADA4B820A85008520E92F112020E04005E
+:20640000100010FCFE8410A4FEA452A430A490A450A4FE201020105028524692850E020001
+:206420000800087C144423447E54805471545554755455107528552A512A554A5246508031
+:206440002400FF7C24447F542454FF5408547F5449547F104928FFA8412A414A454E4280D9
+:20646000240024FCFF8424A43CA408A47EA44AA47EA408A47F2008507F520852FF8E010073
+:2064800008000F7C08447FC449547E544854475440544A106AA85B284A4A4F4AB08E8100C5
+:2064A0000920091010FC378050409020111A11061FF821004100FFFE0100010001000100DB
+:2064C0007CF804887CF842207DFC052405FC283C19E409001FF821007FFE01000100010021
+:2064E00008400840284028403F44484C48508B601C40E8404840084008420842083E08006C
+:206500001000103C53C050407C40507C93C01440187E37C0D040104210421042103E10005C
+:2065200010201020502050207FFE50209020162039FCD10411041104110411FC11041000CD
+:20654000100013FC504050407DFC504450449BFE3000D1FC11041104110411FC1104100054
+:2065600010201120512051FC7D20522054209FFE3000D00011F811081108110811F8110866
+:206580001040104053FC50A07D10520897FE180833E85228922813E812281008102810108C
+:2065A000100011F8110851F87D08510851F89508190831F8D108110817FE1090110812047C
+:2065C0001020102016FC52247AFE522494FC172019FCF52052FE1220132014C0183E100401
+:2065E0001040102051FE51027DFE5100510095FE1AAA32AAD2FE12AA14AA14AA18AA1084CB
+:206600001040102053FE50007DF8510895F8180033FED20212FA128A12FA1202120A1204E7
+:2066200008007EFC08247E240824FF54088800701F8000803FF800807FFE00800280010035
+:20664000104048482944224A0648383013C000F83F0001003FF801007FFC01000500020005
+:206660000100F93E21082288FABE2448282827C8FABE22882288248844884A88912800108D
+:206680000100F93E21082288FA7E27C828082008FBFE22482248224823C8400840288010CE
+:2066A0003C2025FC24883C5023FE7C2065FCBC2000200FF000801FF800807FFE0080018077
+:2066C00002001FD00220FFFE028005001FC8640807F87A0002703F800200FFF8020201FE2A
+:2066E00000200C40708811FC10247CA010FC11201020FDFC10201020102210220FFE0000A2
+:2067000000F83F0001F01F0001F87F0201FE3C0010F87C2010F8FE2011FC14221822101E08
+:20672000002018F8E0282EFC2228F4F824202EF82220FAF8262025A0287A20021FFE000037
+:206740001000101824E07E200820FF2014F82320C82035FEC8203220C4221822E01E000056
+:206760000800081814E022207D2080FC71205120752055FE75205520552051227322511EC2
+:20678000082049202A7E7F4841C85D3055105D2843C63FF001001FF001007FFA010200FEB6
+:2067A00001F00D2073F8114811F8114879F8100017FE1108FDF8110811FA10020FFE0000AE
+:2067C00001080C9073FC10A012A8FDB013FE100011F8FD0811F8110811FA10020FFE000013
+:2067E000F78C94B0F7909490F79094BCF79028107F10C47E7F1044107F1244127F8E4000A9
+:20680000100010003FFC20005FF880003FF000100210021002100408040A080A100620024D
+:2068200008001FFE10002FFC4000BFF800080888088808880888088A108A1086608600828F
+:20684000100010003FFC20005FF880007FF004100410245024502452244A3FCA2046000212
+:2068600010001FFC20002FF840003FF0001012501250125012481248224A224640460002F1
+:2068800008000FFC10002FF840003FF008101F90291046101988E4E8020A08060606020252
+:2068A00008000FFC10002FF800007FF000107FD00910091049502990290A090AFFE600020F
+:2068C00010001FFE20002FFC4000BFF000103FD024503F5024482A48314A3FC62046000269
+:2068E00010001FFE10002FF840003FF004107FD004101F9010901F880A0A0A4A124661C275
+:2069000010001FFC20005FF00000FFF000103F9020903F9020907FD04A4A4A4AFFF6000272
+:206920000400040008000FFC0820182024204420024002400180018002600C1E70080000AA
+:20694000084008400844FF7E08487F88494849487F4849501C502B2049508888090E0A0480
+:20696000082010203E2022203E7E22443EC40944FF2810281E1012302248228E4B04040072
+:206980000820482049FC48207DFE4002412478A0492048A04BFE485048504888890E060445
+:2069A000084849484FFE49487D484178410079FE48204BFE486048B04B284C2688200020E4
+:2069C0001040502053FC520453FC7E2843FE42207BFC532455FC552455FC552455348928FE
+:2069E00000783FD0221811203FFC02000200FFFE04000FF80C30136060C083600C1E70040E
+:206A000000200E3EF02003FEA524553851E4093CFF00097849482948294A0A8A2A8E1500D3
+:206A200000043E04222422243E242224222422243E2422242224220442044A14840800000C
+:206A400000003DFC240024003C0027FE248024803DFC248424042404240444045414880873
+:206A600000003E08220C22103E242246220C22103E242246220C220842104E2084400000A0
+:206A800001000080FFFE10001FF800001FF810081FF8100810081FF810081008102810103C
+:206AA00000903C90249024903FFE2490249024903FFE24902490449044905510891002105C
+:206AC00000003DFC240024003C0027FE24903C902490249024904492451295120A0E00004C
+:206AE00000403C40244024403FFC244024A024A03CA0249024902508254C452655248A009B
+:206B000000403C40244027FE3C402440249024903C9025202528264444BE55E688840000D7
+:206B200000207C20442047FE44207C20452445247D2445FC4420442044224422541E8800AE
+:206B400000207820482049FC4924792449244954794C498C4904490449044904A914110818
+:206B60000810062001C0063019087FFE020007F80C0817F8240847F804080408042804105B
+:206B800000803CC0248024FE3D042628242024203C202420245024502488448855068A04B3
+:206BA00000803CA0249824903FFE24A024A024A43CA624A424A824B045625522891E02006B
+:206BC00000403C4027FE24403C8024A0252027FE3D202420252825A44626542488A0004083
+:206BE00000403C40247C24403C40244027FE24403C602450244C2444444054408840004064
+:206C000000203C20243E24203CFE2482248224823CFE24802480248045005D008A000400D0
+:206C200000003DFC252425243DFC2524252425243DFC2524242024204420542088200020CB
+:206C400000203C20242025FC3D24252425FC25243D2425FC2524242024204420542088206C
+:206C600001003FF821083FF821083FF800001FF010101FF010101FF01010101010501020DF
+:206C800000803C80250025FE3E402440247C24403C402440247C44404440544088400000A6
+:206CA0000000783C49D04950795049504950795049484948494849444A544AF64A5494005A
+:206CC00000403C4024A024903D18264E246424903D202448248C25184420444094800900C0
+:206CE00000003C80248025FC3D042604240425E43D24252425E42404440454048814000858
+:206D0000000879FC492049207920492049FE49207920492049104952498AAB2A912600001D
+:206D200000007BFC480848104820785848844B0279FC4820482048204820ABFE9000000095
+:206D400000403C402448264C3D48245027FE24A03CA024A024A024A044A25522891E020089
+:206D600000003DFC250425FC3D042504257425543D542554257425544504551489080000B5
+:206D8000000079FC49244924792449FC4924492479244954498C49044904A9FC9104000005
+:206DA0000040784048A0489079084A064DF8480078004BFC4880488849044BFEA904900093
+:206DC0000008790C48904860789049484A444FFE7840495049484A4C4C484840A9409080A5
+:206DE00000403C2025FE24403C48248C25F824903C2424482490273844445486890400009D
+:206E0000010878CC489048007BFE4890489048907BFE489048904890491049106A10941033
+:206E20000108788848504BFE7820482048204BFE78204820485048504888690E96040000A6
+:206E4000004078444A464944794848404FFE48E0795049504A484A464C444840A840904007
+:206E600000007FFE48404888798C4E5048A049307A704CA849284A264C244820A8A090408A
+:206E800000003CF8248824883CF824A8242025FC3D2425242554458C4504550489140108C5
+:206EA00000203C20252825283D28252826B426B23C2025FE24202420442057FE8800000010
+:206EC000001C7BE04A4449B479284BFC4808485048207BFE482048204820482048A098409F
+:206EE000004078204BFE4A047C0049F8480048007BFC4890489048904892A912910E0200A1
+:206F000000007BFC4A044A047BFC4A204A244BA87AB04AB04AA84AA64B24BA2094A0084051
+:206F200000203FFE242025FC3C2027FE240025FC3D0425FC2504250445FC550489140108D5
+:206F4000004078404FFE4890788849464FFC4A487BF84A484A484BF848424842A83E900044
+:206F60000090789048904F9E789048904B9E4890789048904F9E489048904890B890909056
+:206F8000002078A04B2E4A227A224BAE4A224A227BFE4A20482048504848488C690692041B
+:206FA00000403C2025FE26023C0024FC240024003FFE242024A824A42526462454A08840C0
+:206FC000004078204BFE4A047C004BFC482049207920493C4920492049204AA0AC7E9000B1
+:206FE000002078204F7C49247AFE4A244BFC792049FC4D204AFE4A204A204D20A8FE90006A
+:20700000784048404FFC48407BF848804FFE79084AF64C444BF8484048A04918AA0C94081E
+:20702000004078404FFE48404BFC7B144AA44A447BF44A444BFC4A444A444A444A549A0803
+:2070400000007BFE484048807BFC4A944A944AF47A944AF44A944A944A944BFCAA0490008B
+:2070600000003DF8250825F83D0825F8250824003DFC255425542554255447FE54008800A0
+:2070800000003DDC255425543DDC240025FC24003FFE248025F8248824084408542888102D
+:2070A0000040784048A049187BF64C044BD44A547BD44A544A544BD44A544A444A549A48BB
+:2070C00000487A4C49504BFC78404FFE489049087A4E4C444BF8484048404840AFFE1000A4
+:2070E00000407A4849504BFC78404FFE489049087A464FFC4890491048A0A84091B0060C21
+:2071000000007BFC480049F8790849F848004BFC7A044B144AA44BF44A444A446A44924C6C
+:207120001080FCFE21003E3025C4252855D089061FF010101FF010101FF01010105010202F
+:20714000004078204BFE4A02481879E0490049FC791049104BFE4800489048C8A90C9208D1
+:20716000012478A848B04BFE78404BFE489049287A264D2848B048F04B2C4824A8A010407F
+:20718000004078204BFE4A927CC849044BFC488879FC484448404BFC484048404FFE980085
+:2071A00000407FFC490848907BFE4C444BF84A487A484A5848404BF84A084A08ABF8900007
+:2071C000010879084FC8493E7FC848084BBC4AA47BA448244C584A9849D84E24A8269044B5
+:2071E00000887BFE48884BFE4A0479F848004BFE48807B4848F04B2848D64B10A8509020CE
+:2072000001F8790849F848007B9C4A944A947B9C48404FFE48E048D049584A4EAC44904073
+:2072200000407FFE48004BFC7A944AF44A044BFC780049F8490849F8490849F8A80093FE0B
+:2072400000207BFE4A884A507BFE4A504BFC4A547BFE4A544BFC4A504AD8AAD69554085056
+:20726000024879504BFC48E079504A4E4C444A487BBE4CA84AA84AFE490849086A089408F2
+:207280002040204020403E4020FE20843F20022002201A20E25002500288030E0A04040080
+:2072A000222014200C20327E0844FFA428A07F20A920292029502D502A88088809060A04BF
+:2072C000082008207F200840147E2284FF2802203A202A202A203A50024802880A86050411
+:2072E000002007207820087EFF42088428204B2049206B50495049907F88410802060C04AB
+:20730000104008407E4024FE24841928FF2000207E20422042507E50429042887F0E4204FE
+:2073200008200C2013203F3EC0423E5422943E100010F71011285528334855449186330482
+:2073400000403E40227C22842374225436542A742A4C36402644213C41024082807E000040
+:20736000400023F82208FE0802188B284AA8524852684EA8331AC40604060802100200003C
+:2073800000007E7C4244427C4244667C5A444A7C4A4456FE5528614440824062801E0000DD
+:2073A00000207DAC452445AC45244D246DFC542055F854886C506C20445A448A43FE8000D5
+:2073C000100818FC1488FE881088289826D8C2A824A836A8FFD824D8248A5A8A490A9204A7
+:2073E00000207EA442684230424866845A484B6A4ADC56AC6532410040828062801C000024
+:207400000FE00820082008201020103E60000FF00820042002400180018002600C1C700896
+:2074200008007F7808483E4800487F4E81803E7C02883E4820483E30023002480A860504AC
+:2074400008000878FF480848FF48924E7E80107C28447E2808280F10F8100828084E0984E0
+:2074600008007F7808487E480048FF4890863E784448FF4849487F3049307F4849468B84AB
+:20748000044004407C7C04403C7804407C7E054000807FFE04100220014001800660381C42
+:2074A000020001007FFC044003800660F81E22882EE822882EE822882EE842885FE8800832
+:2074C0000200217E1202FE220BFE4A224BFE2AAA33FE12722AAA4AA683220222020A0204F1
+:2074E000202010201060FE502088208C3D46262024102410244024204410441894080800DD
+:207500002080108001FEFD2022203DFE242024FC24A424A424A444A444AC94200820002012
+:207520002080108011FEFD00223823C03C40247C27C0247E27C0244044424442943E0800FC
+:207540002080108011FEFD0022FC20843CA4249425FE248424844484450495040A14000852
+:20756000208010801080FDFE212022203CA025FC2520262025FC24204420442097FE08007B
+:207580002080108011FEFD0023FC21043DFC25402540254C2570454255428A42023E040034
+:2075A00021001100FDFC224025FC3840289029F828042950295049504952A952164E00001B
+:2075C00020801080FDFE212022FC3C60249027FE240825E8252825E84408540888280010B1
+:2075E000100011FC100814105420584090FE114A104A1892251222224444418486140008CF
+:207600001040104017FE144054405BFC5040904017FE1042284224424454404880400040BF
+:2076200010201020102413FE1420592451249124112411FC2820242044224022801E000096
+:207640001040104014A014A01910520855F6511091102910255025204104410480FC000059
+:20766000100013FE1440144058405080508091FC2284348428842484448440FC80840000C2
+:207680001008103C13E01426152458A850B097FE10201020282024204420402080A000407B
+:2076A00010801040144817FC184050405040904013FC284024402440404447FE80000000AB
+:2076C0001040102013FE144014405888508C93F81110102028402488450443FE81020002B6
+:2076E0000200042008101FF800081FF8100810081FF80900091812A002400420181C6008F1
+:2077000010A010B0152215261B2855325122511E9140104437FE2840444040408040004015
+:2077200010081208111017FC1840504053FC90401040284427FE2440404040408040004097
+:20774000100013FC1040144015F85888508897FE100031F829082508450841F88108000066
+:207760001040104010A01490554C5A2655F890101010202029FC25044504410481FC010449
+:2077800024002204217E24042C44B424A424A484259426AC24A454644C0444048414040859
+:2077A00010201020103E142015FC590451FC9104110411FC2820242043FE40208020002088
+:2077C00001000118113012C02430181E60241020142459285160985024502288410E8604F5
+:2077E0002100213E21222FE22922B13EA122A7A224A234BE2FA224A244424042808A010409
+:20780000100011FC110415FC150459FC5144902013FE1000290C2488249047FE80000000F7
+:2078200011FC1124152415FC1924512451FC500097FE12402A4C263022204298830E020407
+:207840002180277824482C483748A44EA480A4FC274834482D4826304C304458848E0504EA
+:207860000BF81A0813F8304057FE90C01170124C14421108091812A004400830300EC00424
+:207880001040102013FE1404580051F8500091F8110821F8310829F84508400087FE000027
+:2078A0001040102013FC120416045BFC520053FC935415542DFC255429544954910800006C
+:2078C000200020FC248422842AFCB084AEFCA2A2229432882AA44AC24280450088FE0000FF
+:2078E00010C013BE121216925A5252A25354928811FC1124292425FC2524412481FC0104DA
+:2079000011F8110811F8150815F8580053FC925413FC100033FC290844904060819E0E0461
+:207920001040102017FE110814905BFE52529252128A12022AFA268A22FA4202820A02049E
+:207940003F0821083F0821FE2E0820485F285408A5281910111822A004400830300EC00471
+:20796000100013DC1064135414CC59545264908011FC1104290429FC4104410481FC01045A
+:20798000208027FC2444264C2D54B7FCA4C4A564265424442FFE504048A04118860E180415
+:2079A0001010107813C4124C15505BFE50E05150924E144423F832482BF84A4843F8820814
+:2079C000210C288824102DFE3020A0C4AF28A4D0273824542594565044208B0010FE000435
+:2079E0007EFC10202A445CA8A95054B8AA5458960920010811B0124024200810300EC004D7
+:207A0000207C27C0224421282FFCB524A7FCA000278424FE37842CA447944504859406084A
+:207A200017D8244837D82D6824487FFE88227EFC1C7029ACFFFE3560C91E06C4383EE0043C
+:207A4000000000000000000000000000000000002910248822444244000000000000000055
+:207A600001003FFC01003FF802007FFE04140FFE1210211041500020248822442242400034
+:207A800000803C8025FC260425E43D24252425E43D2425040028289824446666C222000019
+:207AA00001047FFE01003FFC10081FF80420FFFE00001FF810081FF8288824446666C222AA
+:207AC000010000803FFC200420043FFC20A020902FFE20802140214042204410580E8004C8
+:207AE000010000801FFC10041FFC1020122011A014A02320213E2FE04020402080200020C3
+:207B0000010000803FFC200420043FFC200020002FFC280429E4292429E4480448148808F0
+:207B2000010000803FFC20043FFC200027F0241027F020002FF828884FF8480287FE00009B
+:207B4000010000803FFC20043FFC222022203E3E22202E3C22205E3E4220422082200220F8
+:207B60000800040004003F800100020006000D003480C48004000400040004000400040010
+:207B80002000100011FCFD0405040904110439FC55049500110011021102110210FE1000F1
+:207BA0002000100813FCFC400440084017FE38A054A090A0111011101208120814061804F9
+:207BC000202010201020FC2005200920113E392055209520112011201120112417FE1000DC
+:207BE000204010401040FDFC04400840104037FE5840944010901108120C17FC12081000FB
+:207C0000202010201020FFFE042008201020302059FC950411041104110411FC110410009C
+:207C200020A010901088FFFE0480088010FC3888550891901250122014501888110E160428
+:207C4000208010801080FCFE054009401240387E54409440107E104010401040104010404E
+:207C6000208010801080FCFE052209241220392855A49524122212221422182010A01040DB
+:207C80002008101C13E0FA200A20122013FE3A205620921012101218124812AC13261204F1
+:207CA000200011FE1002FC0205FA080211F239125512951211F2111210021002101410089A
+:207CC00020201020103E7C2005FC09041124392455249524112411241050108811041204EB
+:207CE00020A010A010A07CA404A80AB011A038B055A892A410A0112011221222141E100088
+:207D00002088108813FEFC88048808F81088308858F89488108813FE1000108811041202CC
+:207D2000210410881050FDFC0524092411FC3924552491FC1020102013FE10201020102066
+:207D40004100213C27D4FD140BD4092417B43948554097FE10A010A011101218140E18040E
+:207D6000220811081010FBFC0840104013FC3840544097FE1000102412921252125214009D
+:207D8000404027FE2040FBFC080011F8110831F8589097FE100011F81108110811F81108AA
+:207DA000404027FE2000F7BC14A427BC212077FCA92027FC21202FFE23442E282290230C04
+:207DC00000007FFE01000180016001300120010000000900488848844816881407F000005A
+:207DE00001000100010001F80100010001007FFE0000010828C428862814481047F0000099
+:207E000000107E10021025FE141008901450221042500020090028842892481207F00000CB
+:207E2000080008FC7F2408247F2408447F44089409080000090028842892681207F0000028
+:207E4000010001001FF001007FFC01001FF0010001007FFE000009002894281267F20000AE
+:207E600000007FFE020004001FF812481248124812481028091028842892681207F00000D8
+:207E8000087C0BC01040104037FE50409040104013FC0000090028842892481207F000003F
+:207EA000082004403FFC010001001FF8010001007FFE0000090028842882681207F00000B3
+:207EC0000100410021FC22480A50144060A02110260E0004010028842882681207F00000FA
+:207EE00001007FFC01001FF000007FFE400407C00442183E010028882884681407F0000002
+:207F00001000123C2900C800127E3108D048108813081128001029042892681207F00000DD
+:207F200000407E40427E7E8448C47F2848104A2866CE4204000009082884281467F000003A
+:207F40007FFE44205FF845205FFC420047F05C1047F040007FFE010048844812C7F2000070
+:207F60000E10702010FCFE8410FC7C8444FC44847CFC0000090828842896681207F000004D
+:207F80000820FF20223E3E4800483EA804100F10F82828CE100401002884281267F20000E9
+:207FA00017C810881108FFFE31583B1C552A992A13481108000029082884682407E000004E
+:207FC00041202FFC012087FC512017FC2524E5B4264C2494000828802894681207F0000004
+:207FE00010407EFC2948FE3044CE7FFC44207DFC1088FEA810A8105000882A00291447F230
+:208000000100010001003FF001100110FFFE011001103FF0010001000100010001000100B8
+:20802000010001001FF801087FFE010801081FF801003FF8010001007FFE010001000100BE
+:208040000100010C7D3005C009400930151E62081FF8100810081FF8100810081FF81008C4
+:2080600012080908091000207FFE410401003D0805900960092011102118410E05040200B9
+:20808000010001183DA005400930350E02040820EBAC2CB02CA84AA849268A2428A010408C
+:2080A0000000FEF0209020902090209078904890C8904910491079124A124212040E0800D3
+:2080C00000007EFC10201020202020203DFE6420A420242024203C2024202020002000201B
+:2080E00000007DF810101020104020803DFC6454A45424A425243E44248421040228001048
+:20810000010001007FFC01003FF80100FFFE01007FFC020004000FF83808C8080FF80808FC
+:208120000040FC4023FC208020A0212079206BFCA82028242FFE282038202820202000207A
+:208140000020FE20102013FE20202124392469246924A9FC2824282038222822201E000089
+:208160000000FDFE10081088208821083DFE64186428A448248825083E08240800280010D1
+:208180000008FEFC10801080108020FE3C906490A490249024903D10211002100C100010F7
+:2081A0000000F87C27802040204043FC7C086410A420244024803D00260025C0083E00044F
+:2081C0000000FBF82208222822384328FAA84A484A484AA84B287A2A4C0A440608061002E4
+:2081E0000020FE201020102411FE20203C20642067FEA440244024903C8825FC20840000C4
+:208200000090FC9017FE1090209020003D086508A510249024A024403CA02118260E180415
+:208220000004FFFE1200120022FE3A206A206A3CAA242A442A443C44248409041228241022
+:20824000024002207FFE0280049C04E20B82107E2000FFFE04000FF83808C8080FF80808CB
+:2082600000800080FEFE1140114022403C7C24406440A47C244024403C40244020400040D6
+:208280000040FE4010A010902118220E7C046800ABFC2840284028403840284027FE0000DB
+:2082A000001CFDE021202120212041FE79204920C920492049104912790A496A419601129B
+:2082C0000040FE20102013FE100022083D0C6508A488249024903C102420200007FE0000C6
+:2082E0000040FC20202023FE2202248438806888689CA8E02880288438842884207C000069
+:2083000000907C9013FC1094209423FC3A906A90ABFE2A922892391A29142210041008106A
+:208320000004F7E42284229442944294F7D45294529452945294549474844884509400085B
+:2083400000887C8813FE108810C820A83C2067FEA4802480248024803C80248020FC0000FB
+:208360000040FC4023FE20402248214879506FFEA84028A028A0391029102208040E0804B5
+:208380000080FC8020BE27C0204C407079A26E1EA8002FFC2920292039202A222422081EE3
+:2083A00004402440274C247024422742783E0000FFFE04000FF81808680888080FF808084A
+:2083C00000007DFE1102110221FE21023D7A654A654AA54A257A3D4A25422102010A0104F6
+:2083E00000200020FE4011FC110421943D546554A5242554255425943D04250421FC0104DE
+:208400000100FD0011FC1308249020607850498ECE0449F849084908790849F841080000A3
+:208420000010FCD017141114211027FE79104954C9944B084D10491A792A494A458602021F
+:208440000020FFFE102011FC202023FE7C0065FCA5042524252425243C50248801040204BD
+:2084600000A0FC90111011FE131025103DFC65106510A5FC251025103D1025FE2100010088
+:2084800000407C2013FE1000110420883C5067FE6400A5FC250425043D0425FC2104000053
+:2084A0000040FC2013FE1204240023FC3C206520A520253C25203D2026A02260041E0804D7
+:2084C0000840FC9011F81048108027FE38906928AA462D94282028C82B10382020C00300FA
+:2084E0000020FDFE102011FC102023FE380069F8A94829282FFE2948392829FE202800107A
+:208500000000F9FC210421FC210421FC388069FE6A22AC222A522A8A3A022BFA201400089C
+:2085200000400020FBFC2108209023FE42427C44A9FC2948294829482968395020400040F4
+:2085400000407C2013FE1202140421FC380069F8A90829F8290829F83908280027FE00009A
+:208560000040FC2013FE1202120223FE3A006BFEAB522B522BFE2D523D522552095A110402
+:208580000108F90823BE24482AA8213E7A086C48A8482FFE28E029503A482C4E20440040DF
+:2085A0000040FC2013FE1090110C224438906908ABFC286428A829103B102D48218E010442
+:2085C00001F8FE88203021D823BE20647A986996AA602FFE286028B039282A2624200020B1
+:2085E00008007F7808483E4800867F7849487F30404880847FFC04001FF068100FF0081040
+:208600000200FD7C2540227C2244217C79406E7CAA202BFE287028A828A839262A2400203E
+:208620000210F91827D02010279E44A477A4D02457D4509451685F88751451244546028476
+:208640000020FDA410A814921294210822F63C0069F86908A9F828003908289027FE00001F
+:20866000000003FEFD2421FC212441FC7800CBFE480049FC492449FC792449FC400007FE92
+:208680000090FBFE20902100229E45647A986908AAF62C002BFC38202928222404A20040CC
+:2086A0000090FBFE209027FE240229F878046BFEA8802F4428E82B3038E8272620A00040BD
+:2086C0000090FBFE2090282825FE40207CFC6AA4AAFC29A42AFC2AA43CFE2448242800109F
+:2086E000010002C00C3077EE00000FF008100FF001207FFE028002A004C01982667E0000FB
+:20870000044024481450FFFE111009203FF82108210825882568292831082108212820100F
+:2087200028402850AA486C40FEFE5440387CFE449244BAA8D6A893109228924E8684000038
+:2087400028102818AA146CFEFF1054FE3892FEFE9292BA92D6FE9292929292929A9A949446
+:208760000000FBFC88208820F82088208FFEF820882088208820F8208820802000A0004015
+:2087800000047BFE482049207920493C4924492479244BFC48044804780448040028001017
+:2087A00000007BFE4A004A087B0C4A884A484A307A104A284A4C4A847B044A0003FE000015
+:2087C0000040784048404FFC48407A484A484A487A484BF84A48484078424842003E0000BF
+:2087E0000040784048404850794849444A464C427840484C48484810782048C003001C0002
+:208800000040784048404BFE4A427C44486048A078A048A0492049227A224422081E1000A7
+:20882000110011001FF821005FF00100FFFE00001FF010101FF010101FF010101FF01010D5
+:2088400010001EF822884288A4A814920882307EC0001FF010101FF010101FF010101FF0F8
+:208860000040786048404890488879044BFE4902480079FC490449044904790449FC010434
+:208880000040004078404BFC484078444FFE4800784048404BFC48407840484447FE0000E8
+:2088A00000907890489048904A927A944AD84A907A904A904A904A927A924BD2460E000073
+:2088C00000407C7E488449084E10792048C04F40787E488449484A50782048C043001C00C7
+:2088E0000080789049084BFC78044A404A407BFC4C4048404FFE78404840404000400040B0
+:20890000004078484BFC48404A44794849504FFE78E048D0495049487A4E4C4408400040D9
+:208920000040784048A049104A087C064BF0480078844C444A484948791048044FFE0000D6
+:20894000010878904BFC4824782449FC4920492079FE486248A2492A7A244C204020002098
+:208960000080788049104A084BFC789049084A847CFC49884A904C6078605190060E1804AE
+:2089800000007BFE4A204A207AFC4A204A204BFE7A004A204A204AFC7C2044200BFE10004A
+:2089A0000080F33892089208F3B892089208F3F892A890A090A0F120912002220C22301E12
+:2089C0000140792049244BFE4E207A204BFC4A207A204BFC4A204A207A244BFE420002006E
+:2089E00000407BFC4A444A444BFC7A444A444BFC788049204A204FFE782048204020002032
+:208A0000020003F802007FFE40049FF00C603198C6463FF0D01E1FF410101FF010101FF038
+:208A20000040795C4A444A444B5C7A444A444BFC78404BFC49084890786048B0430E0C0472
+:208A4000002077A850B259245510721055EE5844704057FC508050A07110520844040804A0
+:208A60007E40044008FEFE881B48283048C8AB061FF010101FF010101FF010101FF0101030
+:208A8000004078404BFC484048407FFE489049087BFC48044BF84AA87AA84AA80FFE0000C8
+:208AA00000007BFE4A024DFC490879F8490849F8784048204FFE4800789041080204040242
+:208AC000000477FE50A057FC54A477FC500053F8700057FE504052507248444409440080CE
+:208AE00000407A44494848504BFE7A024DF84908790849F848404BFC7840484047FE0000DE
+:208B00000010F790909091209FBEF4E494A497A4F4A894A897A89490F4A897A88CA600C439
+:208B200000407248515057FE50E07150564E5A5473BE54905950557E721054104810101013
+:208B40000820FF2008FC7E2022F83E8822501730F8CE5FF410101FF010101FF010101FF0ED
+:208B60000000FFFE921092109210FE109210921092109210FE1082108010001000500020CC
+:208B80003FF8210821083FF8210821083FF80000FFFE08200820082008201020102020204F
+:208BA000002000287C245424542055FE7C205460545054507C5044884088010C0206040479
+:208BC000004000407C40548454FE54887D0856885450545054207C6044904108060E18040B
+:208BE0000000001C7DE05500550055FC7D485548554855507D3046304248048809061204FF
+:208C0000004000407CA05490550856267C4054885710542054C47F084410406003801C0056
+:208C2000010002800C6037D8C0063FF80920151022085FF011101FF0111011101FF01010D1
+:208C4000004000207DFE5502568455DC7D5456545554555C7C94449241120212040E08009B
+:208C6000002001FCF888A850ABFEA800A9FCF924A9FCA924A9FCA820F9FC8820002003FEAF
+:208C800000003FFC224422443FFC00007FFE0080010003400530191861080100010001007F
+:208CA00000003FFC224422443FFC000000007FFC0100110011F81100110011007FFE00002C
+:208CC00000003FF8244824483FF801000100FFFE010001001FF01010101010101FF01010AF
+:208CE0003FF8244824483FF822080100FFFE00001FF000001FF000001FF0101010101FF08A
+:208D00003FF8244824483FF80400FFFE0830310EDFF411101FF011101FF00102010200FE5E
+:208D20003FF8244824483FF801001FF801007FFC02400C201FF000202888266444440000FA
+:208D40003FFC224422443FFC0100FFFE01003FFC24442FF421043FF421042104211420080D
+:208D60003FFC224422443FFC2140212033FEAA20A7FCAA20222023FC2220222023FE22007F
+:208D80003FFC224422443FFC2400FF7824483C4808487E7C4A047EF40804FF0408140808C1
+:208DA0003FFC224422443FFC08207FFC511449247FFC00001FF010101FF010101FF01010F4
+:208DC000010001003FFC01000100FFFE044008201FF000103FF8248824882488FFFE000094
+:208DE0000C80309C20842EA422C43CDC24A428943EBC210400001FF81248124812487FFE62
+:208E000042FE24AA28AAFEFE008024FE42A281FA7CAA54FA5422543A5DCAF00200140008C8
+:208E20001000100010003F00200020005E00480088007F000800080008000A000C000800A0
+:208E40001040104010401F40204020407F40484088407F40084009420A420C42083E0000C2
+:208E60001000100010FC3E0420087C1050209020FE401080108011021502190210FE0000FF
+:208E8000102010201F20102020203E204830882C7F260822082008200A200C20082000207C
+:208EA000100410041F04102420243E24482488247F2408240824082408040A040C14080804
+:208EC000100010FE1F04100820103E10481088107F100810081008100A100C100850002046
+:208EE000102010201F20102020203EFC482088207F200820082008200A200C200BFE0000A3
+:208F00001002108220823E9240927C9290921092FE921092109210921512191212020002B9
+:208F20001000100820103E2040C07C0090081010FE6010021004120814101860138000007A
+:208F40002200213E3882220242027A02A2022202FA022202220222022A023202220A020430
+:208F6000100011FC21043D4441287CA890881090FE5010501020105010501488190612047A
+:208F80001020102020203E4041FE7C4890881088FD101090106012301448198C1604000086
+:208FA0001000100021FE3E1040107C2090201070FE6810A4112210221420182010200020CD
+:208FC0001020102020203E2040207DFE90201020FE2010501050108815481A2614040000AD
+:208FE000100010FE20803E8040807CFC90841084FE8410FC108012801480188010FE00002B
+:20900000201C21E03D00210041007DFCA1842148FD482130211021282A4C32862504000006
+:20902000204020403CA0209041087A4EA0242020FBF820082010201028203020204000005C
+:209040001040102020103DFE40407C40907C1044FE4410841084108415041A141408000028
+:209060001080106020203DFE40007CF090901090FE9010901090129215121912120E000025
+:209080001008100820883E4840487C0890881048FE4811FE10081008100814081808100805
+:2090A000200020203E20202040247D2CA1302120FC202050205020902888310E26040000CE
+:2090C000100011FC21243D2441247D24912411FCFD001100110011021502190210FE000093
+:2090E000100011FC20203E2040207C20902011FCFE201028102412241420182013FE0000BF
+:20910000100011FE20203E2040207C209020113EFD201120112011201520192017FE000064
+:209120001020102020203C2041FE7C2090201020FDFC110411041104150419FC11040000FD
+:20914000200020003DFE200440047DE4A1242124FD24212421E42004280430042014000896
+:20916000200021FC21003D00410041787D48A1482148FD48217821002900310021FE0000CB
+:20918000201020103C2021FE404078A0A0FC21A4FAA420A420A420A428AC3020202000208D
+:2091A000208020903C88208843FE7C80A0F82088FD882150215022202A5034882B06000066
+:2091C000202020283E24202041FE7D20A1242124FD28212821502192292A304A2186000277
+:2091E000100010FC20843E8440847CFC90841084FE8410FC10841284148418FC1084000011
+:20920000100011FC21043D0441047DFC91041104FD0411FC100010001400180013FE0000F8
+:209220001000100021FC3D2441247D24912411FCFF24112411241124152419FC11040000A3
+:20924000201C21E03D00210041207D20A1FE2020FC202128212422262A22342220A0004002
+:209260001040102023FE3C2040207DFC91241124FD24112411241134152818201020002099
+:209280001040102020003DFE40207C2090441088FDF0101010201040108415021BFE100228
+:2092A0001040102020203DFE41047C0090801084FC9810E01080108214821882107E0000EA
+:2092C0001040102420243EA440887C8890901294FEA212A214C012C414841984127C000091
+:2092E000100011FC21043D0441FC7D0091401144FF5811601140114216421A42143E000099
+:209300001020102021FE3D2441287D2091FC1184FD4811481130111016301A4E15840000FE
+:20932000200021F83C88205040207CD0A30E2020FDFC2020202023FE282030202020002091
+:20934000204020443DF4204840507BFEA04020FCF9402640207C2004200428043014200890
+:20936000204020403C4021F440447C48A3FE2020FC402080239C20E028843084207C0000DC
+:20938000100013FE20883E8840F87C88908810F8FE88108810BE13C81008140818081008AF
+:2093A0001020102021FE3C4040407CFC91841284FEFC108410FC108412841484189410886F
+:2093C000201020183E1421FE41107D14A1D42154FD582148215022DA2A2A344628020000C5
+:2093E000204020403C4021FC40407C48A14820D0FBFE204020A024A029103108220E0C0468
+:20940000208020803CFC238040507824A054218CFBFE20A020A020A229223122221E00004B
+:20942000200027DE3C94229442947A98A7D42192F9922192229A22942C90329021100010FC
+:209440002020202022223D2440A87CB0A1FE2002FC0221FE200224022802300221FE000032
+:2094600010FC108420843C8440FC7C2091FE1122FD2211221122112A1524182010200020CD
+:20948000100011FC21243D2441247DFC91241124FD54114C118411041104150419FC110491
+:2094A0001020112421243D2441FC7C0091FC1004FC0411FC110011021502190210FE0000D6
+:2094C000202020203D2021FC41207A20A02023FEFCB020A8212821242A26342420200020AC
+:2094E000200C27703910211041107A10A3FE2090FC902290217C290032802460181E000093
+:209500001000101C20E03E2040207DFC90201020FDFE102010401040108415021BFE100257
+:209520001090109021163B1841107D729112110EFC40104017FE1040144018401040004032
+:209540002040204020A03C9041087A06A1F82040FC4021F8204020402840304027FE0000EB
+:209560001020102020503C5040887D0692FC1000FC0011FC110411041504190411FC000030
+:20958000200020883E502030404C7DA4A02023FEFC2020A820A421262922322220A0004009
+:2095A0001050105020503C5442547D5890D010D8FD5412541050109214921912120E00008E
+:2095C0001040104020F83C8841107BFC904413FEFC44104413FC10401440184011400080F2
+:2095E0001040104020FC3C8841107DFC93241124FD2411FC110011001502190210FE0000A5
+:20960000204020203C2023FE40407C50A08821FCFC9420902090209229123112220E00004C
+:209620002000227C3D04210844107A20A27E212AFD2A212A265222922A2232CA220400009D
+:20964000204020203DFE210440487840A04023FEF8882090219020602850318C2604000009
+:20966000210021003D00211E47D27952A1522252FA922692211221922A5E34522800000081
+:20968000209020903BFE209040007BFEA2442040F9F82048204820882888312822100000DE
+:2096A000202020203DFC202041287CA8A0B023FEFC6020B020B025282A2634242020002062
+:2096C000202020283C2423FE40207920A0A02090FD102150253025082D4A31C62002000008
+:2096E000208020803ABE22A442947A88A29822A6F880204021FC20402840304027FE000040
+:20970000100010FC3E84208440847CFC900011FEFC20102010FC10201220142019FE1000D7
+:20972000100011FC3D24212441FC7D24912411FC1020FE2011FC102012201420182013FE8C
+:20974000202020A03CA020FC41207A20A02023FEFC0021F8210821082508290831F821081E
+:20976000201020583D94409440907BFEA0902094FCD421882288209A20AA2886328621023F
+:20978000202020203E2821284128792C92B214B2FC2011FC102010201420182013FE00007C
+:2097A0002000203C3BC0204442247D28A1002008FDFE2088204820482408280830282010A3
+:2097C0001040102023FE3C2040407C8891FC1000FD2811281128112A152A192A122E0000D7
+:2097E0002200213E3802420242FA7A52A2522252FBFE2252225222922A923312220A020432
+:20980000210020803CBE220242727E5292521272FE52125212521272120216021A0A12047B
+:20982000204020203DF8210841F87D08910811F8FD441128113011101110154819861104BC
+:2098400021F8200821F83C0841F87800A3FE2204FDF8210820902460286031902E0E000417
+:20986000100011FC21043D0441FC7D0091FE1102FD7211521152127216021A02140A0004FA
+:20988000200023BE3A84428442F47B54A2D422D4FAD422F4230422042A0432142208000003
+:2098A000102011FC3C2021FC40207BFE900011FCFD0411FC110411FC1504190411140108E8
+:2098C000209020903BFE40904090F82023FE2040F88020FC218422842084288430FC2084B7
+:2098E000204020403DFE209041487A46A1F82040F950211027FE21102910321022100410EA
+:2099000021F821083DF8210841087DF8A00021FCFC0823FE208824482848300820280010F3
+:20992000200023F822483BF842487A48A3F82040FBFE20E0215025482A4E344420400040A1
+:20994000200021F83D0821F841087D0891F81000FD1211DC1110111015521992110E00009A
+:20996000200023FE22223A2243FE7A22922212FAFA8A128A128A12FA16021A0213FE00005C
+:209980001080108020FC3D5442547C9490A41124FC4C100010A4129216821A881078000079
+:2099A000204020203DFC200041087C88A09023FEFC0021F8210821082508290831F82108F9
+:2099C0002040224821487D5043FC8040FBFE20902108FAF62490209028B43084207C000036
+:2099E0002020202020A43CB841307C48A1862020FD22212422382020285031882606000038
+:209A00002092209221243E4841247C92900011FEFD22112211FE1122152219FE1102000010
+:209A20002100210023BC391443947914A7A4214CF82023FE202020202850318E2604000082
+:209A4000211021103D1621D841107D5291BE1040FDFC1104110411FC1104150419FC110411
+:209A6000200021FC21243D2441FC7D24A12421FCFC00204020A422A22A8A34882078000057
+:209A8000200021DC3D54215441DC7C00A1FC2000FBFE204020782008240828083028201050
+:209AA0002000201C21E03C2040207DFEA02020AEFD22212221AE25222922312221FE00004F
+:209AC00020A0232C3A24222443AC7A24A3FC2020FBFC210820902060286031982E0E000486
+:209AE000203C21C03C44212840807DF8A04023FEFC8020F8218821502A203450298E0004F3
+:209B00002040202023FE3C0041F87D08A10821F8FCA420A8219021902A8830AE20C400800A
+:209B2000202021243CA823FE407078A8A3262040FC4023FE2088219020602850318C26040D
+:209B400021102110213E7D4445288310792821C8FBFE25482128212821082908312821101D
+:209B6000209023FC3C9423FC42907BFE90921316FDFC11041124112411241450188C1304C5
+:209B8000100011FC11243D2421FC4100FDFC2184FDFC2184218422FC2A84348428FC0084A7
+:209BA0002090209023FE3C9041FC7904A1FC2104F9FC202023FE20202850318826060000E9
+:209BC000200023FE3C0021FC410479FCA00023FEFA8A225222FA222222222A22322A220406
+:209BE00020A020903DFE212043FC7D20A1FC2120FDFE210020FC2488289E3102210A0204B1
+:209C0000204020A021183BF644007DF8A10821F8F80021F8202021FC282033FE20200060B8
+:209C2000202021DE3D0A210A414A7D7291A61000FDFC1124112411FC1524192411FC0000BF
+:209C4000210420843C88201043FE7C90908811041202FDFC115411541554195413FE00000F
+:209C60002040202023FE7A0441F8804078842348F87021B0266820AE2B24302020A0004011
+:209C8000204020203BFE220440387DC0A10021FCFD10211023FE2000209029083604200494
+:209CA000200023FE3C9043FC4294FA9423FC2000F9F8200023FE20202924362220A200409C
+:209CC0002020212420A47CA843FE7A04A0F82088FC8820F8202025F82820302027FE000062
+:209CE00021F8210821F83D0841F84000FBFC229423FCF80021F82090206028603090230CC7
+:209D0000200021FC21243DFC41247DFC90401090FDE0104411FE102015241A2210A2004063
+:209D20002040202023FE3A2042FC7A24A3FE2224FAFC22A422FC22A42AFC34A424A4088C4B
+:209D40002410221020207FBE4260FA2023BC22D0FA9022FE249024A83AA829461084000084
+:209D600022102110381E47A042007A3EA3842288FA8E22A822A82CA836A82958108E00008B
+:209D80002040202023FE388840507BFEA22223FEFA22222222FA228A22FA2A023206220288
+:209DA00023FE205039FC215441FC7800A1FC2104FDFC210421FC20202BFE3020202000209D
+:209DC000200027FE44007628854807DEF49446A846A8F6A847E84494551465264A4400001F
+:209DE0002090229421983BFE4108F89023FC2040F9F8204023FE204028A0311C26080000A6
+:209E0000108010F83D1023FC41247DFC912411FCFC0013FE100011FC110415FC190411FC24
+:209E20002210211027D0382047BE74C4A7A42024F7E42094210825C82F14312623440000FE
+:209E40002200217E2502344245FA7442A7FA255AF4EA27FA246224D2274A34422406000003
+:209E6000208420483DFE2048414A78CCA3FE2000F8FC2084208424FC2884308420FC008447
+:209E80002040202023FE3A94412C4020F9FC112411FCF82011FE112215FE1820102000203A
+:209EA0002000273C21247924473CF4102410247EF7522152217E21102914357E2202000040
+:209EC000200021E422683992408C7908A1F62200F9F8210821F82110289030A023FE0000F5
+:209EE000209023FE209078A041FE7B20A5FC2120F9FC212021FE2088245028203050218E25
+:209F0000200023FE3A5223FE408079FE92421042FBF2125213F2104A13FE1002180A1004ED
+:209F20002040202021FC3C8840507DFE900011F87D0811F8110811F816241A92148A007850
+:209F40002040202023FE7B0441DC81647B982690F9F8220621F820202924312222A20040E0
+:209F60002040202023FE7A9043FC8294FBFC229022D4FA9A22D2248E2C0035542A520000B7
+:209F8000203C21E020207DFE402081FC7D2411FC1124FDFC102011FC1420182017FE000032
+:209FA000200421E43C24502451E491047D04110411E4102428242424442440448144008452
+:209FC0002020202021283D285128912812AC7C721422102029FC24202420402083FE000081
+:209FE00010A0109020903DFE51101310FDFE1110111029FE25104510411081FE01000000E3
+:20A000000D10711011101110FD1011DE31103910551055109110111211521192110E100017
+:20A020000C207024103E11E0FD203120392055FE5062906210A210AA112412201020102030
+:20A040000C207020102013FEFC20102039FC34205470506890A810A61124122010201020FD
+:20A060000C50704810481040FFFE30E030E0595055505248924814461044104010401040A7
+:20A080000C0070FC10841084FE8410FC3884340055FE5102910211021102110211FE11020E
+:20A0A00000400E50704811FEFE5010503892348E37205420502092221222122213FE120285
+:20A0C0000C1E71E010041144FCA430A839FC34085010502097FE10201020102010A01040BE
+:20A0E0000C40702011FC1104FD0431FC3904350455FC51425124912811101148118E11047E
+:20A100000DFC7124112411FCFD24112439FC342053FE506090B010A8112E122414201020AE
+:20A120000C40F06010901108FE4634203BF8541050A09040114815441512151218F01000C3
+:20A140000C20702013FE1040FDF8310831F8590855F8550891F8110817FE109011081204FA
+:20A160000C0071FC112411FCFD2411FC38883504528250FC9108169010601058118E16040D
+:20A1800000200C20F1FC10201124FCA813FE300039FC5504517491541174110411FC110448
+:20A1A0003E200820FF201C3E2A20C92008201C202AFCCB842C841C842A84C9FC2884100015
+:20A1C0000C8070FE1100FCFC388454FC90847CFC4440447C7CC4452844307C4845860000F0
+:20A1E0001840E7FE200027BCFCA427BC71106FFC6110A7FCA1102FFE23282D50318E210412
+:20A200001008203C7BC04A004A004BF87A884A884A904A507A504A2044500488090E1604EB
+:20A220000080104020447BFE489049084A147D14491048A048A0784048A00118060E180447
+:20A24000202031204120F9FC8A208C208820FBFE880089F889088908F908890881F80108E1
+:20A26000081C08E0FE8018FE2C884A8889080A081FF0101010101FF0101010101FF0101048
+:20A28000103C17C0224879504FFE48E049507A484C464BF84A487BF84A48424803F802089D
+:20A2A000000007203A202AA02AFC2B202BFE2A302A48298429044A804A404D30490E800467
+:20A2C000101C10E8FEA828A844A87EA800A8FEA820A820A83CA4052405342A2E1404000042
+:20A2E0003FF8003006C001003FF8210821083FF8210821083FF821082108210821282010F3
+:20A300001010102010F810C8FCA814A81498148014FE2402240225FA46024402800A0004D4
+:20A320000240022001FC7F00008404640FFC0A10093008000FFC00047FF400040014000849
+:20A340000020404046F878C840A842883E98108010FCFE04100411F410041004101410083C
+:20A360001020104010F8FEC892A8948810A8289028FE280228024BFA4C0288020014000816
+:20A380001020104010F81088FEC810A810987C8044FC4404440445F47C0444140008000092
+:20A3A00010101020FEFC10C420A428A4488C7E8008FE28022C024AFA8A02280A10040000A9
+:20A3C000101010201EF810C87EA842A842887E98408040FE400243FA40024002800A800440
+:20A3E000202020403EFC42C442A4BAA42A8C2A802AFE3A0202FA020202020A0A0404000055
+:20A400000020074078F848C848A848887EA8489048FC480444F455046B04491400080000A2
+:20A420001020244878F010207CF800007FFC04001FF01210113010001FFC00047FD40008F9
+:20A440000020FE4020FC20C440A4FEA4AA84AA8CAA80AAFEAA02AAF2AA02860A82040000D8
+:20A4600010801080FBF010903990D5543A0C1FF01410123010001FFC0004FFC40014000876
+:20A4800000200E40F0F810C810A8FEA8109810807CFE4402440245FA44027C0A440400009F
+:20A4A00014101420247C24643F5464446454AE482D7E3402240225FA2402240A2404000091
+:20A4C000020001007FFE02401250124C26445FE0142012601FFC00047FF4000400140008F9
+:20A4E0000020104010FC7EC410A410A4FF8C82803EFE040208020EFAF8020802280A10040B
+:20A500000010FF20007CEF64A954A954A94CED40EB7EA902A902A9FAA902AD0AEA0400006F
+:20A520000820284028FC3EC448A408A4FF8C008000FE7E02420243FA42027E02420A0004AF
+:20A540000010242022F842C890A8188824A8229040FEBC02240225FA240224023C0A240432
+:20A5600000104E20227C826492549244FE549248BA7EB602D20292FA920282028A0A84046D
+:20A5800044102820FEFC12A41294FE94908C9080FEFE1202320252FA56029002101A100453
+:20A5A00004100420767C0544FF5404541444144C5C40547E550255025B7AE302010A0004E0
+:20A5C0002410242024FCFF8424C424A47EA4528C52807EFE520253FA52027E02420A00049D
+:20A5E00010101020FEFC28C434A450A4FE8C52807EFE52027E0211FA1402180A1004000056
+:20A60000082010407EFC4AC47EA44AA44A8C7E8010FE2802FF0208FA0802080208140808DB
+:20A6200010200840FEF800C83CA824A83C9800807EFC04040E0479F4080408042814100873
+:20A640002008279024BC24A4F7B424AC24ACF4A097BE9482948294FAF8820A8A1104000062
+:20A660000020EE40AAF8EEC800A87CA80098FE8020FC3C0405F404040404141408080000B5
+:20A6800044102420287CFF6422544244444C9540EE7E2202440244FAA902FF0A00040000EE
+:20A6A00000107E204AFC4AC47EA440A45E8C52805EFE520252025EFA9202920A1E04000028
+:20A6C0007E40144008FEFE882B50C8301ACE04001FE0122011601FF80008FF8800280010FD
+:20A6E0000E10F020A2FC52C404A440A47E8C888008FEFE0208024AFA4A024E02720A00046A
+:20A7000042102420FF7C2844FE642A54FF4C2A40FE7E28026C026AFAAA022802280A28047B
+:20A720000010FF20917CD564D554D5546644994C1040FF7E240265FA18021402220AC00451
+:20A74000101008207EFC54C454A47EA4548C548054FE5C024002557AAA82A002000A0004B4
+:20A760000010F720557C336455549944084C3440C37E100268FA3202C402181AE004000037
+:20A7800008100820FF7C896456542244FFD422483E40227E3E0208FA4A028902280A100447
+:20A7A000302028407EF848C8C8A87E8848987E8048FC48047E0440F4AA04AA14000800004D
+:20A7C0000850FF4822FC3E5008942C94CB0C1FF01210115010201FFC0004FFE4001400081B
+:20A7E0007E100420187CFF641A542844D8547F48557E63025D02557A5D024102450A420446
+:20A80000108823FE7C88652055FC47204DFC41207DFC052015FE2488C4500430144E098400
+:20A820007C8044F87D9010605D9C50F85E88E4F81FE01420126010001FFC0004FFD40008B1
+:20A840002410FF20247C776455547744284C3F40687E7E02A8023EFA280228023F0A2004CA
+:20A86000008000400FFE880048004800080018002800C800100010002000200040008000C3
+:20A88000010000801FFE1000900057FC5040304050409040104020402040404041408080B6
+:20A8A000010000801FFE1000900057F85088108830885088908810A820902080408080802B
+:20A8C000010000801FFE100090005FFE5080108030F8510891082208220844104850902073
+:20A8E000010000801FFE104090405044144434445444944414442444244427FC40048000B7
+:20A90000010000801FFE100093FE5220122033FC52449244144424842484490492282410D6
+:20A92000010000841FFE1100912051105FFE1140314051409240224024424442483E90006C
+:20A94000010000801FFE1210921052105FFC12103210521093F022102210221043F0821034
+:20A96000010000841FFE100090045FFE5008100837C85448944827C8200820084028801016
+:20A98000010000801FFE1000900053F85208120833F85208920813F8220820004FFE800079
+:20A9A000008000401FFE1200920053FE5480148038FC5080908020FC20802080408080802D
+:20A9C000010000801FFE120093FC540457E41A24322453E4922812102202220241FE8000F7
+:20A9E000010000801FFE108090405FFC50401040304057FC90402040204020405FFE80008E
+:20AA0000010000841FFE108090445FFE50801110322057C09080211022084FFC44048000FB
+:20AA2000010000801FFE120092005FBC52A412A432A452A494A424A424A4493C5524A200D9
+:20AA4000008000401FFE1000900057FC50A010A038A454A492A822B020A040A04FFE800039
+:20AA600001001FFE10889FFC508057F8108837F8548097FC2144212422284410480E900406
+:20AA8000010000801FFE104090405FFC5040104037FC500090882A442A522A1251F080003B
+:20AAA000008000401FFE111091105FFE511037FE5442984017F820882088410886501820E0
+:20AAC000008000441FFE900057FC508017F831085FFE900017F82408240847F8840800007B
+:20AAE000008000401FFE1040924852485254155438E2504097FC1040204020404FFE80008C
+:20AB0000008000401FFE140092FC5444544415F4344454E4A5542654244444444454840846
+:20AB2000008000401FFE14209220502854A432A2512292202C22240C4418446081800E005C
+:20AB4000010000803FFE20002FFCA08063082C906560A26025D02958424E44448A80010045
+:20AB6000008000401FFE112091205F3E51201120373C512091202F3E212021204120812051
+:20AB8000010000841FFE900057FC544415F43444544495F4151415F42514240447FC840498
+:20ABA00000801FFC100093F850405FFC11603250544E91442FFE2110232040E083301C0872
+:20ABC000010000801FFE1080973C54445444175C34445444A7FC24C4212042188C0E3004CD
+:20ABE000010000803FFE2410A2106F90242827246542A5902508292049105508A208000069
+:20AC0000008000401FFE9210512057FC144437FC5444944417FC20402FFE204040408040B6
+:20AC2000010000803FFC2208AF8862282FA82AA86AA8AFA827282AA84A485208A228021072
+:20AC4000010000803FFE2080AFFC649022A02FFE6120A690388E23F4408040809FFE000057
+:20AC600000803FFE220022F0A41067FE2C8034FC64A0A52027FE2460245044884506860467
+:20AC8000010000803FFE2220AFFC608027F820806FFCA10021F822402440484057FE800022
+:20ACA000010000803FFE2490A2A06FFC21C026BE7904AFFE2120232040E043B89C0C00003F
+:20ACC00000803FFE2000AFBC688428842FBC6800AFBC280428242FA82810482848C68B0442
+:20ACE000010000801FFE100097F8515010A03FFE544497F8244827F82448407C8FC4000458
+:20AD0000008000403FFE22002FFCA2246FA422242FD46248A28020444A4A4A0A91F8000026
+:20AD200000803FFE22102FFCA21067F8240867F8A40827F820803FFE21404230440E9804F4
+:20AD4000010000803FFE24002F78A9486D482B4629806F7CB9442D442B2849105528A2C6C0
+:20AD600000801FFE12489150524854B0110E36045BF8920813F8120823F822084228021031
+:20AD8000008000401FFE111097FC51105FFE104037FC544497FC144427FC21104208840438
+:20ADA00000803FFE20002FFEA12067FC2524252467FCA00027FC20002FFE44484944908235
+:20ADC00000801FFE100017FC944457FC544417FC308853F0911027F8204844504948908481
+:20ADE00001003FFE20002F7CA1446554255424546A28B1443FFE2220264041804678B81008
+:20AE0000010000803FFE2220A53C68A835102A1065EEA80437FC20404250444889440080C5
+:20AE2000010000803FFE20802EF8AA886B502C302A486BA6AAA02CFC29204AFC48208BFED0
+:20AE4000010000803FFE20402E78AA886AFC2C042AFC6A04AAFC2C4028A44AA24A8A8C7830
+:20AE600001043FFE2000AF786528231825286888A160265C398826604198466081800E00EC
+:20AE8000010000803FFE2080AE3E65E8244825486F7EA4C8244826A85928427E84000000EA
+:20AEA000010000803FFE22202FBCA2486FBE2AA22AAA6FAAA22A272A2AAA52146222824238
+:20AEC00001003FFE20802FFCA2107FFE200027F86408A7F8240827F828844A42520A81F898
+:20AEE00001003FFC20002FF8A8286FE82AAE2AC06FBCAAA42AA82FD84A9052685446A8843A
+:20AF0000010000803FFE2020AF1069FE29442F2868FEAF102D10357E55105510A71045105E
+:20AF200000803FFE24003F7CA4106F10297C2F446954AF5429542F5429545FA84944908247
+:20AF400000803FFE29442F7CA9446F7C29442F7C6480A7FE2C4037FC244047FC444087FE54
+:20AF6000400023DC1044FC440044855444CC484428CC295412641C44E044015400880000FD
+:20AF80004040204023FCFC4003F80A488A4853F8504050E021503948E2480446184400404A
+:20AFA000010000807FFE400208201210620C07F804080C1012200040008003000C00700001
+:20AFC000010000807FFE481210082FF4001000100FF0080008000FF8000800080048003020
+:20AFE000020001007FFE44240810310C01007FFC0100111011101FF001000104010400FC3F
+:20B00000020001007FFE4422081810FC7F0001003FF8002000C003000C003000CFFE00007B
+:20B02000020001007FFE44241810604C104015F8244878481048144824887C8805500220F0
+:20B04000020001007FFE4622181862460240224812500A603258C448044008423042C03E24
+:20B06000020001007FFE481211082FF401003FFC0908151009007FFE0240042018186008C4
+:20B08000020001007FFE482210187FF411101FF011101FF00100FFFE03400D30710E0104C9
+:20B0A000020001007FFE4424191862C60C3037CEC0041F0811481F4811481F481528121044
+:20B0C00001007FFE44220A1031081FF8082004407FFC00001FF010101FF010101FF01010AE
+:20B0E000020001007FFE44221818291405207FFC0560191802007FFE04200E4001C07E3C5B
+:20B10000020001007FFE40040C603018C63679D0555055505550555055485D58526684440C
+:20B120000400020002003F8000800100020006400A80130062C00240020002000200020076
+:20B140004000300013FCFD08054809281110349058A094A0144010A01098110E12041400E7
+:20B16000404030402040FBFC0A44124422446A44AAA4329C2B1422042204220422142208A3
+:20B180002000181C11E0FC2004200820122035FE5820942014201020102013FE10001000AC
+:20B1A0004040304010A0FC900908124624246820B3FC2C08280820102010202020202040D7
+:20B1C000204010401040FBF80848104814483BFE584094A010A01110111012081206140437
+:20B1E000202010241226FDA404A8082013FE342058209BFE14201020102010201020102094
+:20B20000402032242126FDA40928102013FC3404580495FC12041004100413FC100410008A
+:20B220002040104010A0FC9005080A0611F83400580099F815081108110811F8110810005E
+:20B240004080308020FCFD840A881050302054D89B0615F811081108110811F81108100048
+:20B26000200011F81108FDF80908110815F839005988954C113011101148138611041000EC
+:20B280004420322022FCF8200820105026FE6A10B21032FE2A1022102210251028FE200091
+:20B2A000200019F81108FD08050809F8080017FC3840544093FC10401040104017FE100066
+:20B2C0004040304010C00120FA180DF610001408348C5A4895501150112017FE100010003E
+:20B2E0002200190010BCFE040AF40A94129436F45A949694129412F41204120412141208A9
+:20B300004020302013FEF82009FC0820102037FE584094C4112813101518114E1184110044
+:20B320004040304411FCFC4804500BFE1040348059F89708150811F81108110811F81108FD
+:20B34000400031FC2104FDFC0504090415FC390059FE969214921112162210C21314100871
+:20B360002020104001FCFD2409FC0924132435FC584094A013FE10201020102010201020B8
+:20B38000400031FC1104FD0405FC0920132035FC5920952012FC12841284128414FC1484F6
+:20B3A000400037BC2484FB2809100AA8144414003BFE54A49328111012A81446188211008C
+:20B3C0002110111007FEF910084010A025186A0EB5F4280025F821082108210821F82108B5
+:20B3E00040883088138EFC880988128A108629FC7104A9FC250421FC2104210421142108B8
+:20B40000410031FC1144FA440A44167C12542A1072FEAA302A582254229623142210221016
+:20B420004020312410A8FFFE087008A81126324054409BFE148811D01030104C11861600DE
+:20B44000208018601020FFFC0A040BFC120037FC5B54975413FC155419541154110C10003E
+:20B46000409030902290FABE0AA012D026886888B0002BF826A822A822A822A82FFE20005C
+:20B48000401E27E0243CFC2015FE152025F86D22B51E2D0025782548254A2A4A2A86290011
+:20B4A000200017DC1264F954094C0A541444382055FC9504110411FC1104110411FC1104FB
+:20B4C0004000277C0144F9440F7C1410247C6C54B7542D54217C21102114251E22E4200000
+:20B4E000400037FE2040FBFE0A42155C20406800B7FE284027FC2294229422942294220CB3
+:20B5000042A8324817BEFA5C0F5A12A812882FFE7110AAEE24442BF8204027FC204020C04B
+:20B5200000007FFC010401080100111011F8110011001100290025002300410040FE8000B4
+:20B5400000007FFE010411F81100290047FC80001FF010101FF010101FF010101050102046
+:20B5600000207F20522091FE7D24212851207DF8114811481D48F15012301248148E190488
+:20B580001010241042FE7E9208942490429090FC3EC424C85528891015302248448E890447
+:20B5A00000207E20045028501088FE881B462A24282049FC4808880808100810281010202F
+:20B5C000010001003FFC01001FF0010001007FFE0380054005200918110E2104410001000B
+:20B5E000100011FCFE0810507E201020FE2011FE38203420562054209020102010A0104057
+:20B6000010201020FE2010A87CA411221122FE24102638243408561094201040118016006D
+:20B62000080008FCFF8408847E8408FC0880FF8008FE1C822A824A828882088208FE0882A2
+:20B6400010201020FE5010887D06120411F8FE00100039F8350857085508910811F811080F
+:20B6600010901090FFFE10907C9011FE1204FE40104039FC364454445084908411141208C0
+:20B6800010201020FF2410A67EA8102011FEFF02117A394A354A574A957A1102110A11048B
+:20B6A000100011FCFD2411FC7D24112411FCFC2013FE3A22362A563E93EA1202120A12041C
+:20B6C00010401248FD5013FC10E07D58124EFC8410803BFE3508559090601090110C120411
+:20B6E00010901090FFFE10907DFC109013FEFE2011FC392455FC552493FE1104111411080D
+:20B7000011FE1100FDFC11007DFE11541158FF6E1144390855FE52089288148810281010F8
+:20B7200020402020FBFE22887BFE22D823ACFA8A228873FE6A40AAFCA584268424FC2884F6
+:20B7400001001FEC01307FFE02001FE8E80807F800001FF808101FFC00883FF800807FFE31
+:20B760000000FF0022FE22103E102210221022103E10221022102F10F2100210025002201B
+:20B780000020FC2049FC4924792449FC4924792449244BFE5D04E904090409040914090883
+:20B7A0000040FE40444044A07C98454E46247C0045FC44084E10F4A00460043004200400D7
+:20B7C0000020FE1045FE45027E04440044007DFE441044104E10F410441004100450042042
+:20B7E0000000FE1C45E044207C2047FE44207C20442045FC4F047504C50405FC050404007D
+:20B800000020FDFC492449FC78204BFE480079FC490449245D24E924085008480886090434
+:20B8200008207F20087E7F4410A81E10222844447FFE08200FE008200FE00820FFFE002050
+:20B840007FFE04403FF824483FF800001FF010101FF010101FF00100FFFE010001000100DF
+:20B8600000007DFE1020104011FC1104FF2411241124112411241050104810861302000051
+:20B8800000003DFE2020204020FC3E8424A424A424A424A424A444504448848605020000D6
+:20B8A000100009FE0820FF4000FC00843CA424A424A424A424A42650444841848606000037
+:20B8C000100011FE1020FE4010FC10847CA400A47CA444A444A444507C4844860102000062
+:20B8E000100011FE1820244022FC7E8480A400A43CA424A424A424203C50248C03040000AE
+:20B9000040004DFE7020444044FC3C8410A410A4F6A438A434A452A49250508C23040000F7
+:20B9200011FE0810FF2010FC148424A478A408A412A424A4C8A414302248C08603020000AA
+:20B94000080009FE1410322048FC80847E8404A408A43EA422A422303E4820860302000099
+:20B960000000EEFEAA20EE4000FC7C840084FEA410A41EA402A4022002500A8C0504000092
+:20B98000000008FE4A104A207E7C0044FF5410547F5455545554552855245546438200006D
+:20B9A0007F00227E3E10227C3E442244FFD40254FFD48954555422283524484690820000CF
+:20B9C000240024FEFF1024207F7E14427F525552555255526B524952511845264242000005
+:20B9E0007E0024FE18101420627CF74455543254D5540854FF541C102A28C846098208000C
+:20BA00007EFE42107E20427E7E420852FF5200527E5242527E5208284A244946A9821000A1
+:20BA20007EFE0810FF208AFC6E8408A46EA400A4FFA410A4FEA4AA30AA48AA46AE82000094
+:20BA400009FE2E4028FCFEA44AA44C308A4C3FF0D1101FF012101FF00900FFFE0100010013
+:20BA60000100010001F001003FFE2104210021202140218023002D082108410C40F8800086
+:20BA8000010001F801003FFE21043FF0210820F820803FFE222022202140408043609C1CFC
+:20BAA00008400840084008407F404940494049407F40494008400A440F44F246003C000067
+:20BAC000100010F010907C9054905490549054907C90109014901F12F512420E040000003E
+:20BAE00000007FFE040007F00810105021205FF0111011101FF01110010801FC7F080000C7
+:20BB00000020FF20242025FC25242524252425FC24282424243E25C44400440283FE00009B
+:20BB2000108010C0108011FE7D00560055F854087C105420104014801F04F50400FC00008E
+:20BB40001040102010101000FFFE928092809280FE801080148012801F80F2FE408000007F
+:20BB6000204020402040FBFCA840A840A840ABFEF840A040284024A03E90C518410E020409
+:20BB80001110111011107D10551455D8551055107D105510111015101F52E592010E000026
+:20BBA00010201020102011FC7D245524552455247D54514C118415041F04E5040114010896
+:20BBC000100011FC11047D0455245524552455247D241154185014901E92E512021E0400F1
+:20BBE0001000103813C07C405440547857C054407C7C13C0144012441F44F246003C000007
+:20BC00001040104010A07C9055085606549454907C905090189014901E90E5100110021045
+:20BC20001000109010907C9054885508550C7D4652441040184014901E88E5FC408800001A
+:20BC40001010111010907C5054105510549054507C1E53F0181014101E10E410001000008B
+:20BC6000100013E410247C2455E45504550455047DE41024182414241E24E42400A400446A
+:20BC80000100110811081FF80100FFFE010001001FF811081FF81110010801FC7E08000066
+:20BCA0001088108810887FFE54885488548854887CF81088188814881EF8E488008800007D
+:20BCC0001020102010207FFE54205420542054207DFC1104190415041F04E5FC01040000BA
+:20BCE000100013FE10087C0855E85528552855287D2851E8192814081E08E408002800104E
+:20BD0000100011FE11007D0055FE55205520553C7D241124192415441F44E58402940508CD
+:20BD200010201020102010207DFC5524552455247DFC1124192415241F24E5FC0104000012
+:20BD40001020102011FC7D245524552455FC55247D2457FE190415041F04E50401140108C3
+:20BD60001040104010807CFE55405640547C54407C405440187C14401E40E4400040000090
+:20BD80001000101C11E011007D005500550055FE7D105110191015101F10E51003FE00008A
+:20BDA00010401040104010A07C90554E5624542055FC7C08101014A01E40E220002000001D
+:20BDC000100013FC11087C88549054605490550E7E44504013FC184014401C40E7FE0000FA
+:20BDE0002110219021102110FA7CAC94AF94A914F91422A422A42FA43A44C84400940108B6
+:20BE000000F87E8810C810A8112A1E0A650601001FF811081FF81100010801FC3E04000025
+:20BE20001040104010407FFC56485548555054507FFE1040184014A01E98E50E0204040087
+:20BE40001040104013FC7C405458542454547D8857FC10A010A014A41F24E526421C04008B
+:20BE6000100011FE102010407C48548455FE54247C2055FC1020142012201F20E3FE000019
+:20BE8000208020BE2288FA88AABEAAAAAAAAAAAAFAAAA2AA22AA28AE3D08E90802080408B6
+:20BEA00010481048104810487DFE554A554A554A55FE7D4A114A194A154AFFFE450200004F
+:20BEC0002000278E20F0F910A910AA10AFFEF890A8903290297C3D00EA804440083E0000BC
+:20BEE0001000101C13E07C20542057FE542054207C2051FC190415041F04E5FC010400009E
+:20BF00001040102013FE7C905490546054907D0E52941090189014901E90E51002100410E2
+:20BF20001080104010007FFE54905508561455107D1050A018A014401EA0E518020E0C0420
+:20BF40001108108C10507DFE5420542055FC7C20542050201BFE14201E20E42000200020C9
+:20BF60001040106810847DFE54845520552055FC7E2012201BFE14201E20E4200020002038
+:20BF80003FFC20002FF820003FFE249024582620251E2FF449104FF0810801FC3F08000081
+:20BFA000100C10F0FE8010FE7C901110521025001FF8110811081FF8011001F87F0C000828
+:20BFC00010201224112610A87DFC5504550455FC7D04510419FC15041F04E5040114010862
+:20BFE000200021FC2104F904A9FCA800ABFCA820F820A7FE305028503C88E8880106020430
+:20C00000100013E21082108A7FFA548A54CA55AA7DAA528A1A8A148A1E8AF482008A00840A
+:20C020002040204020A0F890A908ABF6AC44A840FBF82040315029483E44EA440540008014
+:20C04000103E13E011247C96549455FC540854507C2057FE1020182014201E20E4A0004090
+:20C060001210119810A013FE7C4055FC544054407FFE50A018A014A01F22E522021E0400BA
+:20C08000102013FE10207DFC542057FE540055FC7D0411FC190415FC1F04E5040114010862
+:20C0A0001088108813FE7C88548854F854887CF85488188815FE1E90E4C800840106020449
+:20C0C000208020862098FFF0A890A9DEA9D4AAB4FAB4A494349428943C94C8A400A400C0CF
+:20C0E0001010101410147FFE541055D0555455567DD45154180815D81E2AE4C60302000084
+:20C1000004407C7E04403C7C04407C7E054001001FF0111011101FF0010801FC7E04000079
+:20C12000100011FC11247DFC5524552455FC54207FFE1070187014A81EA8E5260224002025
+:20C14000100011FE11027DFA5522552255FA7D225532112E192A15FE1F02E5FE0102000037
+:20C16000100011F8110811F87D0855F8548054FC7D545254189414A41D24E64404940108A7
+:20C180001020104011FC7D2455FC5524552455FC7C6050A01BFE14201E20E4200020002042
+:20C1A000100011FE11227D22557A552255FE7D02557A194A154A1F7AE54A0202020A040405
+:20C1C0002040224821502040FBFCA880AFFEA920FA1825F6311429503D20C90401FC00001D
+:20C1E0002040202023FEFA04AD08A900A9DEAA52FA52A65A319428903D12CA12041E080081
+:20C200002200211E23D2FA52AA54ABD4AA58AA54FBD4221232922A5A3EF4CB500210001045
+:20C22000100011FC10587C2057FE5420542054A07C4011FC195415541F54E55407FE00005C
+:20C240002040204023FCF840A9F8A840AFFEA890F908A3FE350829F83D08C90801F8010841
+:20C260001048104811FE10487C0055FE552254207DFE5460107014A81EA6E5240220002073
+:20C280002040204027FEF840A840ABFCAA94AA94FBFC224433FC2A443E44CA44025402088C
+:20C2A000100013FE10007CF85488548854F854007DFC112419FC15241F24E5FC010400005C
+:20C2C0001040104013FC10A07C98554E56F454407DF81000184015F81E40E44007FC0000FB
+:20C2E00020C827082148F928AFC8A948AB28ABA8FD4EA978210829083D08C908010800002A
+:20C30000110011FE12007DFC550455FC550455FC7C8050FC188415483E30C44801860604D2
+:20C32000102010A0112C7D2455AC552455FC54207DFC1108188814501E20E4D0030E0C0457
+:20C340002040204020A02118FAF6AC00ABC4AA54FBD4225432542BD43E54CA4405540488CC
+:20C3600024202220222027BEFA40AA3EAB84AA88FA88A2FE32882A883C88C4880AA811101C
+:20C380001020112410A87DFC547054AE572454407C4013FE188814D01E30E44800840100E2
+:20C3A0001108108C10907FFE5450545055FC55547D54519C190415FC1F04E50401FC000074
+:20C3C0002040202023FCFA04AA04ABFCAA00ABFCFB54A3542BFC3F54ED540544091411083A
+:20C3E0007E4014600840FFFE1AC82948C830294811861FF811081FF8011001F87F0C00088F
+:20C400002040204023FCF840A9FCA840ABFEA888F9FCA22235FC28703CA8C9260224002004
+:20C4200008407E40087C7E8809487E481E3012482A84C5021FF011101FF0111001F83E0899
+:20C440002090209023FCF890A800AFFEA890ABFCFA94229432942B6C3E2CEA44020C00005A
+:20C460002090209027FEF890A840ABFEA890A908FA96249023FC28903C90E9100110021032
+:20C480001090109013FE7C9055F8550855F855087DF810401BFE14401EA0E510020E0404EE
+:20C4A000100011FE11107D20557C5544557C7D445544117C15101D54E6540292055208209A
+:20C4C0001040108011F811087DF8550855F8550855F87C4010301AA4168A1E8AE4F80000B3
+:20C4E0001040102013FE7C0055545524555455FC7C2013FE1A4216921FFAE612020A02043F
+:20C500002040202023FEFA20AAFCAA24ABFEFA2422FC22202AFC3E84EA84048404FC0800BF
+:20C520002040202023FEF888A850ABFEAA42A820F9FCA040287824883E88C5080228041073
+:20C5400008403E40087EFF4814C85630A53024CE49041FF811081FF8111001FC7E080000E7
+:20C560001090109013FC7C90549057FE542055FC7D2411FC15241FFCF48800840106020453
+:20C580001050105013FE7C5055FC555455FC55547DFC100019FC15041FFCE50401FC01044D
+:20C5A000100013FE10507DFC555455FC54007DFC540013FE182015281DA4E52602A400402E
+:20C5C0002020212420A8F820ABFEAA04ADF8A908F9F8214830402BFC3C40C84007FE0000CF
+:20C5E000101C11E0102011247CA857FE547054A87F265440102014A41E8AE28A02F8000051
+:20C60000208020F82110FBFCAD24A944A9FCA880FB4424A831302A583C96C914065000209C
+:20C62000040007F00C20724001800E70F10E08D008107EFC4A947EFC08100A140F1E72E4A8
+:20C64000204023FC2108F890AFFEA800A9FCA904F9FC210421FC28203FFEE4200020002003
+:20C660001080104017FC10427E9455E8554456927DF8544810401BFC1440FE400440004017
+:20C680003FF0022001407FFC06881880E39009107EFC4A944A947EFC0C100A14FFFE0204EE
+:20C6A0002100210227E4F908ABD0A802ABC4AA48FBD0200032222A223D44E8E807100000B1
+:20C6C000202023FE2020F9FCA924A9FCA924A9FCF82823FE30042AA23E92EA84047C0000E1
+:20C6E000101C13E011247CA855FE547054A855247FFE1124192415FC1F24E52401FC0104E8
+:20C700001104108813FE7C2055FC542055FE55247CA813FE180014FC1E84E48400FC008447
+:20C72000209027FE20D0F920ADFCAB20ADF8A920F9FCA12031FC28883C50E82000D8030631
+:20C74000209027FE2090FBFEAA02A9F8A800ABFEF8842148327029B03E6CE9A6062400609A
+:20C76000208020F82110FBFEAE48AAA4ABFEAA00FAFCA20032FC2A003EFCCA8404FC0400C4
+:20C78000202023FE22882250FBFEAA50ABFCAA54FBFEA25433FC2AD8FED80B56055408507C
+:20C7A000209027FE2090F800ABFCAA94ABFCA828F82423FE32242B283E90CA32044A088416
+:20C7C00008000FE010207FFE02100D3871C006E0389CC9A03EFC2AA43EFC2A240F3E72E4D7
+:20C7E00001003FF801007FFE4002BFF810002FF048100FF008107EFC4A947EFC0A12FFFE01
+:20C8000023DE225223DEFA52ABDEA920ABFEAE20FBFC22202BFE25083E90E4600198060647
+:20C8200008000C0008001FF81100210041007FFE010021082108210821083FF820080000D1
+:20C840003EFC2AA42AA42AA42AA41450224C50841FF8210001007FFE0100110811081FF8C0
+:20C8600008007F7808483E4800867F7849487F30404850849FF82100FFFE010021083FF8B4
+:20C88000402040387C2051FE9124FDF81120111C55F0559255545DFE72100210045008208D
+:20C8A0000C1CF0F0109010901090FE9010FE10907C904490449044907CAA44CA40840000D4
+:20C8C000104010401F7E208028A04510821000001FF800000000000000007FFE0000000038
+:20C8E00010401F7E28A0449085101FF801000100FFFE0100010001000100010005000200F8
+:20C90000104010403EFE28904508BFF004200440047C0A08091010A0204041B0860E3804A3
+:20C9200020803EFE2890450882083FF00010081008100FFE00027FFA000200020014000875
+:20C9400020403F7E4850848801007FFC042004200420FFFE082008201020102020204020E1
+:20C96000204020403F7E509089081FF0101011101110111011101290028004841884607CF2
+:20C98000208020803EFE51208A1000F81F401140112011201120111021102108410E810486
+:20C9A00010401E7E28A04510851001F83F0021003FFC0304050405040928111021000100B8
+:20C9C000208020803EFE492085100A000FFC3224C22404441844608403040C047028001045
+:20C9E000104010401F7E28904508007C7F4408480850084808440F42F042405400480040D3
+:20CA000020403E7E2850448885083FFC2000200027F02410241027F0200020003FFE00009B
+:20CA200020403F7E2850448845089FF0101010101FF0101010101FF010100000FFFE0000FE
+:20CA4000204020403F7E48908508128010801FFC208040801FF80080008000807FFE000043
+:20CA600020403F7E50904908840004000FFE0A00120023FC4200020003FC0200020002004F
+:20CA800020403F7E5050488889001FFC100420042FC4484408440FC4084400040028001007
+:20CAA000104010403F7E28A04510851000803FFC082004300420024002400080FFFE00002B
+:20CAC00020403E7E48A085107FF800087FE800081F88108810881F88108800080028001079
+:20CAE00020403E7E489085083FF8020802080408185060201FF81008100810081FF81008E8
+:20CB000020403F7E28504488890808007F7C09441144114411442144214442448A7C044436
+:20CB2000104010401F7E24904288204013F8004870481088108811081250282047FE000097
+:20CB4000104010403EFE51108A080420081010F83F0C00041FF01010101010101FF01010D5
+:20CB600020403E7E489045088A0808007EFC08840A841C84E8844884088408FC2884100022
+:20CB800020403F7E28904508A0803E9820E020842684387C21000100FFFE01000100010059
+:20CBA00010401F7E28A02490490809000FF8110021007FFE02400240044008423042C03E7A
+:20CBC00010401F7E28504488850879FC102021207D3C0520492031FE1800260041FE80003E
+:20CBE000208020803EFE5120891002800440083037EEC10401000FF0010001007FFC00004A
+:20CC000020403F7E5090890804000FE03040DFF80108FFFE01081FF801000100050002001D
+:20CC200020403F7E48A0451092901080FCFC11041244102410041C64E384400400280010DA
+:20CC400020403F7E28504488850800007FFC1120112011202950254843848100FFFE0000AD
+:20CC600020403F7E485084887FFE01001FF811081FF811083FF80900060005C0183EE004D0
+:20CC800020403F7E28504488940811FCFF24112411241DFC3100D10011001102510220FE4D
+:20CCA00010401E7E28A025104080088804901FFC10041FFC10041FFC1004100410141008CA
+:20CCC00020403F7E289045088888088010FC25106690A4902450242024502088230E2C04FA
+:20CCE00020403EFE4910BFF801001FF001007FFE00001FF010101FF010101FF010501020FD
+:20CD000020403E7E509089083FF801001FF00100FFFE00001FF01110111012D00C30700C56
+:20CD200020403F7E48904508BFFC20802FF8249022A03FFC21402220221024083FFE000040
+:20CD400020403E7E48A0851001041FC80130FFFE018007F01810EFF0081008100FF008105A
+:20CD600020403F7E2890450888207FFC09200A20FFFE040008001FF82808C8080FF80808E4
+:20CD800020403E7E2890440891081108FFFE11081508190831F8D1081108110851F82108C7
+:20CDA00020403E7E2890450893F81090FE6011981E463040D3FC104017FE104050402040D8
+:20CDC00020403F7E28504488BFF821083FF821083FF80000FFFE082008201020102020208E
+:20CDE00020403F7E28A04510882004403FF821083FF821083FF80100FFFE01000100010015
+:20CE000020403F7E28504488810800807FFE4422181860061FF80100010001007FFE000098
+:20CE200020403F7E2850468881007FFE400420003EFC228452848C94048808821082607ED1
+:20CE400020403E7E50A089103FF80108FFFE01083FF8010025882548292829285108810811
+:20CE600020803EFE48A0851002483FFE20403F4820482F50295029202F32404A408681020E
+:20CE800020403F7E48A085101FF011101FF00100FFFE00001FF01110111012900C607018D4
+:20CEA00020403F7E289045089FF010101FF010101FF000007FFC01003FF80100FFFE0000B2
+:20CEC00020403F7E489085080BF0081017FE210063FCA4402FFE204020A02090210E2204F2
+:20CEE00020403E7E489085483FFC04403FFC0440FFFE01001FF81108FFFE100810281010D8
+:20CF000020403F7E48A085103FFC224022403E7C22402E7822403E7C2240224022403FFE37
+:20CF200020403F7E48A085107FFC02401FF812481FF801007FFE05400930310EC104010011
+:20CF400020403F7E28A04510BFF82448238824483FF82080209C3EE0208022822C82307E0C
+:20CF600020403E7E489085083FFC20A820C02FFE28822FF828842BFC4A2052229422281EA2
+:20CF800020403E7E50908B080A48FF40087E7EA44B284A207E501C502A88288849060A04F3
+:20CFA00020403F7E48A085103FFC24443FFC014001203FFC30882850246241A2461A9806C5
+:20CFC00020403F7E4890850877DC444447C4444447C4581C64440440044008423042C03EF8
+:20CFE00020403F7E4890850800803FFE22403FFC22443FFC2840284C2F7048424B428C3E58
+:20D0000020403F7E48908508041C55604E407F7E4C48564865484488448845087F080208D9
+:20D0200020403F7E48909FF010101FF010101FF810901660181E1FF8124812487FFE000072
+:20D0400020403E7E4890FFFE04407FFC44447FFC10101FF010101FF00100FFFE01000100BF
+:20D0600020403F7E509089087EFC49207FFE14502692C50E1FF010101FF010101FF0101046
+:20D0800020403F7E489085087E90246018201FF0200EDFF410101FF008200440FFFE00009C
+:20D0A00020403F7E4890A50824107EFE24943C9024FC3CC424A8FEA809102528424E858409
+:20D0C00020403E7E48908548087CFE8809107EFC4A847EA418A42CA44AB48848088609020F
+:20D0E00020403F7E48908568139E1212FE9212D21B2A3044D3FE122213FE122253FE22028D
+:20D1000001000D003178210821083D78210821083FF821080280024004200810101C20084B
+:20D12000060038F820083EF8200820083FF824480440FFFE0440044008400840104020405F
+:20D1400001007FFC01003FF80200FFFE0440082012F83C16D0101EF0101010101FF01010F7
+:20D1600003001C7810081E7810081FF8080008001FFC2124489424D42694240440140008B9
+:20D1800002001FF810081FF810081FF810081FF80100FFFE038005400930311EC1040100D5
+:20D1A0000000080010FC7F2455245524552455FC554455445544554457C4F84401FE000042
+:20D1C000080010003E0023FC32202A202220FE20222032202A202220222043FE4A0084006D
+:20D1E000081010103C10241034922C922492FC92249234922C922492249244FE5C008800E3
+:20D20000080010403D24252435042C882488FC88245034502C2024202450448855068A043E
+:20D22000089010903C90249034942CF82490FC90249034902C902490249245D2548E8800EB
+:20D24000081010103E1022FE32922A922292FE92229232FE2A922210221042104A10841020
+:20D26000101E21F07D004500657C55444544FD4465285528551045104528452855468A8422
+:20D28000084010203C1025FE34402C402440FC7C244434442C4424442484448455148A08C8
+:20D2A000080010003EFE220432042AF4FE94229432942AF42A942204220442044A1484083A
+:20D2C000082010203C3E242034FC2C842484FC8424FC34842C8024802480450055008A0040
+:20D2E000081010103C10241034FE2C922492FC9224FE34922C922492249244FE5482880090
+:20D30000082010203E40227E32A02B20223CFE20222032202E3E2A20222042204A20842002
+:20D32000100023FE7C50645055FC55544554FD5445546554559C450445FC45045504880061
+:20D34000082011243EA8222032FC2A842284FEFC228432842AFC2284228442844A9484884E
+:20D36000080011FC3D0425FC35002D3C25E0FD2025FC35202DFC252025224522551E8A00E7
+:20D38000100021F8781048206BFE58204820F8A048406BF85AA84AA84AA84AA86FFE9000D3
+:20D3A0000908108C3C5027FE34202C4025FCFD0425FC35042DFC2504250445FC5504880036
+:20D3C000104820487DFE444865FE554A45FEFD4A45FE640054FC548444FC448494FC888487
+:20D3E000104010203DFC248837FE2C0025FCFD2425FC35242DFC242045FC54208BFE000000
+:20D40000109023FE78904BFE6A0258F84800FBFC488069445AA849304A6848A48B229860CC
+:20D420000100028006400930308EDFF402100120FFFE0108028C0C503420C5180E0E0404E1
+:20D4400004001FE01420132012201FF8000802280110FFFE04880C903460C530060E04040C
+:20D460000800FF7C094411441144257C42440100FFFE0300049808603820CA100C1C08089C
+:20D48000012001107FFC112009C01130250C0200FFFE030004881850E8300A180C0E08041D
+:20D4A0002040914869464242124C603021C02E000100FFFE05100CB83440C5300E0E04049F
+:20D4C00000203EFC22883E5021FE7E2062FCBF2000A07FFE0288045C1820EA180C0E080459
+:20D4E0000000441E29F0FF10111011107DFE11101110FF101110110A214A21A64122800043
+:20D50000000045FC2804FE08101010287E4411821000FFFC102010202020202043FE80003F
+:20D52000004044602888FDFC100410887D04128410F8FD081290145020202050418E86047F
+:20D54000000045FC2904FFFC110411FC7C8010FE1122FF221552118A21FA2002400A8004D5
+:20D56000002045242924FDFC108013FE7C8010A010A8FD70112022502248448E89040000FE
+:20D5800008207FFC01003FF801007FFC3C2808247FFE1C202A247F2420183E32024A06847C
+:20D5A00008100810491029102A92FF9218921C922A922A92489248928892089208FE088294
+:20D5C000104010605240544038FEFE8811883A8834505450502090201050118E16041000DD
+:20D5E000100011FC952455245924FD24312439FC550055005100910011021102110210FEE1
+:20D60000100011FE9500550059FEFD403140397C554451445244928414841904122810105E
+:20D62000210821083FF80100210821083FF8111009100524FFFE03400D203118C10E0104EA
+:20D64000100011FE945054505850FFFE3152395255525152518E91021102110211FE11026C
+:20D66000210011FC1244084810A06110260E19140520FFFE038005400930310EC10401002C
+:20D6800008000FFC28843F486230944809843110C9207FFE038005400930310EC10401009C
+:20D6A000081449142A14FFA41C282B28C85021503BA84D28952457D4211421124112811266
+:20D6C0001040102095FE55025800FEFC3000380055FE5020512891241222142210A01040CB
+:20D6E00010401080951057F85888FFFC31203A10544E5494532090C8131010601180160051
+:20D70000108010BC9488550859FEFD40337C3550599055FE551091281128114411861104D8
+:20D720001110111091D855545B54FC9031403A3E540055F8510891F81108110811F811089A
+:20D7400012081108949054205BFEFC8831083952565253BC508891081210129417FE104206
+:20D76000100013FE9522553C59A0FD7E320039F8550855F8510891F8110811081128111051
+:20D78000100011FC9448583053FEFCA431283AA05440542053FE907010A8112E162410202A
+:20D7A0001020104095FC550459FCFD0431FC390455FC5448504497FE10A01098110E12049C
+:20D7C000100013BE90A254A258BEFF8832083A3E57AA50AA50BE90881088108A157E1202F7
+:20D7E00000001FF0101010101FF0101010101FF01208111C10A0104012201418380E10047D
+:20D800003E0022FC3E2022A03EFE28302C52359E20001FF010101FF010101FF00000FFFE1D
+:20D820003EF8020812280A18722822C80A28041004207FFE042004200820082010202020D9
+:20D84000100011DE28422442455250CA8C4A08467ECA05522A4210420842094A00840000A6
+:20D86000010002C00C3037EEC0040FF008100FF000007EF8224812280A4812882A2804103E
+:20D8800001101FF801407FFE02000FF03810CFF008100FF03E7C12240A1412242A540408B5
+:20D8A00004407C7E04403C7C04407C7E044000007EFC220412440A24124462840A14040822
+:20D8C00008207FFC00081E4812481E4812481E2812107EFC12440A24121422240A540408E1
+:20D8E0000800047E7F92409240DA7FB640127F926AB66ADA7F926A92AA92AA92205A002482
+:20D900000000FEEE00227C2245327CAA00AAFE22AA6692AAFF329222922292AA8644000009
+:20D920007E7850487E4848867E78484854307E4800867EF822481228224842880A280410DB
+:20D94000010001000220042008401F8002100C081FFC008408A4089010882084428401008C
+:20D96000084008407DF809481C8868CA292A120604801F0004201FF0010011202518420881
+:20D9800008207FFC08200FE008200FE00820FFFE121024C8CF0604201FF009201510220803
+:20D9A00008403E7E228823503E2020D8420644408F8002200FF0010011201118250802006A
+:20D9C0000E00F01C00E05220544420F83E1048247EFE88124A504A544E9271120050002050
+:20D9E00001007FFC0100FFFE1110FFFE10901FF032242A782224FF7E08104A54899218300C
+:20DA000010201020FE2010FC7C201020FE2021FE3C206420985008501488230EC2040000C0
+:20DA200010401040FEFE10A255AA5672BA2244FAA2223E7264AA99221822242AC00400002E
+:20DA40000800080408047E4408440844FF440844085C2F642844280458044C0083FE000005
+:20DA6000080008F808887E8808F80888FF8808F848884E8848884BFE4800B8008FFE0000A5
+:20DA8000100413E47D14111411D4FD541254565451545C94508451145208B0008FFE00001A
+:20DAA000081009107E9E08A20844FE90089048904B284D24494248424880A8009FFE00001F
+:20DAC0001128153C17A87D7E13D012AAFCCE13F852485E48524850A05118B2109FFE0000FC
+:20DAE000080008FC7E8408840894FF88148014BC56A455A494A49498249424A654C488800C
+:20DB0000082008207EFE08240828FFFE24102420A47CA6C4A544247C24445444887C00440D
+:20DB20000000FF0000FE00107E10421042107E1042100410461028100E10F1FE0000000017
+:20DB40000020FE20002001FC7C20442044F87C88448808504C5028200E50F088010606043B
+:20DB6000FF0014FE141014107F10551055105510671041107F10411041107F504120000065
+:20DB80000000FEFC28202820FE20AA20ABFEAE20C2208220FE2082208220FE2082200020D6
+:20DBA0000008FF0828082808FEFEAA08AA08AA48C6288228FE0882088208FE28821000003A
+:20DBC0000010FE1028902894FE9EAAF4AB94AA94CE948294FE9C82908282FE82827E000054
+:20DBE0000020FE2028202820FEFEAA20AA20AA20CEFC8284FE8482848284FEFC828400009F
+:20DC00000040FF402840287EFEA0AAA0AB3EAA20AE20C23EFE2082208220FE2082200000EC
+:20DC20000020FE10281028FEFE84AA00AA40AA44AE48C2708240FE4082428242FE3E000068
+:20DC40000020FE2028A0FEFCAAA0AB20AA20AFFEC2508250FE5082908292FF12860E00003B
+:20DC60000040FE40287E2884FEC8AB28AA10AA20CE7C83C4FE4482448244FE7C8244000018
+:20DC80000000FE80289C28E0FE80AAFEAA00AAFCAA84CE8482FCFE848284FEFC828400003E
+:20DCA0000000FEFE285028D4FE58AAFEAA80AE80C2808280FE8082808280FF008200000057
+:20DCC0000000FDFE30003000FDDEB552B552BDDAC5568552FD5285528552FDD285560000D0
+:20DCE0000000FEFC28842884FE84AAFCAA00AAFECE208220FEFC8220FE20822081FE0000ED
+:20DD00000020FE2028602850FE88ABF6AA20AA20CFFE8220FEB082A8FF24822480A000409A
+:20DD2000000CFEF028022922FE94AA90AA08ABFEAE08C2888248FE488208FE2882100000FB
+:20DD40000000FEFC288428FCFE84AA84AAFCAA00AE90C29682F8FE908292FED2828E000067
+:20DD60000040FE2029FC2800FE88AA48AA50ABFEAE00C2F88288FE8882888288FEF88288D1
+:20DD80000080FE9E28922BF2FE9EAA92AA92AFD2C25E8252FE5283D28222FE22824A0004CE
+:20DDA0000000FEF8288828F8FE88AAF8AA00AFFEC22082A0FEBC82A082A0FF60823E0000FD
+:20DDC0000000FEFE282428A0FEBEAB60AA1EAAFCCE8482FCFE8482FC8284FE848294008808
+:20DDE0000040FE4033FE3080FCF8B588B688B4F8AC00C5FC8554FD548554FFFE84000000B8
+:20DE00000040FC2051FE5120FDFCD524D5FEDD24C5FC8520FDFC85848684FEFC84840000AC
+:20DE20000000FDDC30443154FCCCB554B424B450ADA8C4468590FC648588FC3085C0000011
+:20DE400000A0FCA032A831B0FFFEB490B5FCBC40C5F88440FFFE84608490FD0886060000D6
+:20DE600000A0FE90310031FEFF20B5FCB520B5FCAD20C5FE8500FC008554FD2A822A000001
+:20DE80000040FC2033FE3040FC88B5FCB4A8B4AAAD2EC40085FCFD548554FD5487FE000076
+:20DEA0000020FC3C302031FEFD24B5F8B522B5FEBD20C5E48538FDD88536FDD48650002099
+:20DEC0000050FC5031FC3154FDFCB554B5FCB400ADFEC40084FCFC8484FCFC4881FE0000DB
+:20DEE000003CFDE028202BFEFC20ADFCAD74ADFCC42085FCFC2087FEFDA4855282520000B7
+:20DF000000007FFC020004100A183120C2C005A019A06250844808463044C040028001005A
+:20DF2000208420443C4821FEFC2085FCCC40AFFE94409480ACFCAD20C6208420FDFE0000FE
+:20DF40000000FFFE040007F00810105020201FF010101FF0010011FC1100290047FE8000C6
+:20DF60003CF0089008D008B03D12020E1FF0101010101FF0010009F80900150023FE40000F
+:20DF8000100CFEF010801CFE7090111032101FF010101FF01100010009F80900150023FEDA
+:20DFA00000283FFE2420272424283F905532654A9FF410101FF0010011F81100290047FED1
+:20DFC00049202A207F7E49485DA86B10496E5FF4101010101FF0010011F811002D0043FE9E
+:20DFE00000807CC0448044FC45047D04128410445E245024500450045E04F0440028001041
+:20E0000000007FFC4488448844907CBC109411845D485148513052305A48E486090402004C
+:20E0200000007DFE444844487C48544813FE50485E485048508856887908C10802080408F0
+:20E0400000207C20442045FC44207C20102013FE5C205020505050505C886106820404001D
+:20E0600000407C4044A0449045087D0612FC108850885E8850B850905E84F086407C0000BC
+:20E0800000007DFE4420442044407C40108051FC5E845084508450845E84E0FC0084000080
+:20E0A000008878C84888490849FE7B08150811485D285128510851085D08E10801280110FF
+:20E0C00000007BBC4AA44AA47AA412A417FE52A45EA452A452A45EA472A4C2A404A409CC65
+:20E0E00000007CFC4480449044907D1011FE10105C10509450D450925D12E2100050002059
+:20E1000000407C30442045FE45047E40504010485E5850605040504450445C46E03C0000A1
+:20E120000100790049004FDE49527952115251525D52515251525E52F25E0452095210804D
+:20E1400000207C2045FE452445287D20517811885D885150515051207E50C28805060A0422
+:20E1600000207C304440444844847D3E51E210005E0050FC50845084568478FCC084000019
+:20E1800000207C20442045FC44207C2055FE100050205C2051FC50205C207020C3FE000045
+:20E1A00000407C40447E47C0444C7C3010D2510A5C0453FC50A056A058A2E122021E04006B
+:20E1C00001107D10451445D845107D521192110E5C20502053FE50205C20E02000200020DC
+:20E1E00000207920492049FC4A207A20142013FE5C905090509051105D12E212040E0800E5
+:20E200000000780C4CF04B104A10781017FE11105D105110511051105D106280847E0000EA
+:20E22000004078204BFE4908489078601090130E5C945090509054905910E11002100410E7
+:20E2400000407C30442047FE44007C8810C611045E8850885050502050505C88E1060204B7
+:20E2600000407C2045F8450845087DF8110811085DF85144512C51105D58F18E4104000003
+:20E2800000007DF84408440845F87D02110250FE5C00504052B452A27A8AC48800780000A6
+:20E2A00000207C20443E442045FC7D0411FC11045DFC5020502053FE50205C20E020002042
+:20E2C00000007DFC452445FC45247D2411FC10205FFE506050B050A87D2CC22604240020F6
+:20E2E00002007B004A3C4BE44D247924512413E45D245124512452BC7A64C46408200000CB
+:20E30000001C7DE04510451045FE7D10117C11445D54515451545D547228C2480486090441
+:20E3200000407C2045FE452045207D3C112011205D2051FC528452845A84E4FC0884000019
+:20E3400000407C2047FE440045087C90100013FE5C0051FC510451045F04E1FC0104000046
+:20E3600000007C9E4AD249144FD47918111857D45912511252925A5E6454C81010100010D8
+:20E38000001078104F7C491449FE7A1457FC11105D7C511055FE52107B10C490187E000010
+:20E3A00000487D48454847FE45487D78110011FE5C2053FE507050A85D28E2260424002082
+:20E3C00000407A484A484A484BF8780017FC50405FFC529452945E947294C294028C0000B6
+:20E3E000001C7DE0442047FE44207DFC112451FC5D2451FC502051FC50205C20E3FE000044
+:20E40000001C7DE0442045FC45247D2411FC10205FFE5232522A523E5EEAF202020A02045C
+:20E42000004078204BFE4A484A487BFE124812785E0052FC528852505A20E458088E1104B1
+:20E4400001087C9047FE444045FC7C40104013FE5C80510051FC522054205820E3FE0000C7
+:20E46000004078204BFC4A044A047BFC520013FC5B54535453FC55547D54C554090C0000BC
+:20E480007DFC440844D044207FFC10A8112052A05C4057FE50E05D50714CC24604440040CE
+:20E4A0007BFE490849F8490849F8790813FE180857BC54A452A85D1072A8C44818860104D2
+:20E4C000009078904FFE489048007FFE109053FC5E9452945294536C5E44E20402140208A6
+:20E4E000003C7FC0444C452845507C8811F010485DFC502453FE50205C50E0880106020403
+:20E5000000007BFF4A424AE24A427BEF220223EA3B2E23E6A202A542B482CBE2100A200484
+:20E520000000F7FE94109690951EF7D225202548BD48A7C8A548A514B514CA220A4214823D
+:20E5400000907A94499848904FFE789013FC50405DFC504057FE50405CA0E118060E18047D
+:20E56000001C7BE04A4849504BFE78D0114812465FFC524853F852487E48C3F80208000052
+:20E580000210F1149FD4901497FEF49024903790A228A228AB28BAA8CA4A124A0A860500EB
+:20E5A00000007BFC4A944A944BFC790011FE52425DFA514A51FA504A5C7EE3CA000A000459
+:20E5C0000088FFFE8888891E8A82FA5222FE2392BAFEA292A2FEA292BAFEE282020A0204E4
+:20E5E00000207BFE4A004AFC7AA452FC12A45EFC522053FE524852A47B22C5FC04200BFE98
+:20E6000001287A484C904A487BFC1294126452945FFC52485368524A7B6AC2560762024034
+:20E620000108F52897BC994897BEF318A5AA294EA3F8BA08A248A248BA48E0B0810C060400
+:20E640000288FA488AEA8E1C8AE8FA0822E83AB4A5E2A800A3F8A110B8A0C04001B00E0EC4
+:20E66000007007803900088C047003807C4000A003100C2830C803080C08711000A00040C4
+:20E6800000001DFEF02248222E423042C89C150824FCCA8412842284C28402FC14840800F2
+:20E6A00004001BFEE8204440288031FCC90409043504C5FC0D043504C50405FC29041000B7
+:20E6C0001920E1A015208A2057FE2220527092702A684AA89AA62B24CA200A202A201220A3
+:20E6E00000901E90E5FE52902DFC3104C9FC190425FCCC2017FE2420C4500488290612048C
+:20E7000000401C80E9FC45542924115429FCC80015102512CD1415D82512C552158E0900DC
+:20E72000100810083E4824287F28A98829483F48290829FE3F0829084908490885080208FE
+:20E7400000203E20442088207EFC4A244A247E244BFE4A207E204A504A48428C4A86850493
+:20E7600020803C8044FE88807F7C540854307CFC54547C5454945524544444A4551488084E
+:20E780002000201C3EE844A8FEA852A852A87EA852A87EA852A852B452AC4B7A852A0200B7
+:20E7A0000840084C2F7028422F42F43E07E008403FF8C8880FF808880FF8088810A82090C5
+:20E7C000202021243F2642A47EA8CA207FFE4A504A507E504A504A504A524A92848E01001B
+:20E7E00020203E2023FE4420FEFC52A452A47EA452FC7E205270526852A643244A20842019
+:20E80000110410843E4824FE7E92AAFE3E922A922AFE3E102A102BFE2A1042104A10841010
+:20E820000840084C2F7028442E46F9BC01007FFE00001FF000001FF000001FF010101FF02E
+:20E8400008787F4808483E8600787F4849307F4840845FF880000FF000000FF008100FF02E
+:20E86000080008007F7C08443E440854FF5400543E5422543E1022303E3222522A92250E41
+:20E880001FF801007FFE41045D7001001C7000001FF800007FFE020007F000100050002037
+:20E8A0001FFC01007FFE41041D7001001C7000001FF811001FF81108220822084428081030
+:20E8C0001FF001007FFE41041D7001001C70010000803FFC04400280010002C00C38701043
+:20E8E0001FF801007FFE41045D7001001D70000078F810203DFC042028F810006FFE000049
+:20E900000FF001007FFE41041D7001001D7001007FFE0440038002403C3C042004200820AB
+:20E920001FF801007FFE41041D7001001D70404027FC80404BFC1244125462482040204012
+:20E940001FF801007FFE41041D7001001D70000004407C7E04407C7C0440FC7E0440044002
+:20E960001FF801007FFE492415500A2001003FF80440FFFE02007FFC04400C8003801E7827
+:20E980001FF801007FFE55540B200100007827809288415017FC10406FFE204027FC2000D0
+:20E9A0001FF801007FFE55540928200011F8110801F8710813FC164412A413FC1804100CCE
+:20E9C0001FF801007FFE55520B2814007E20143EFF4400483EA82A1036302A48238E260466
+:20E9E0001FF800807FFE449212C8082000FC14A408FC74A416FC6A2012FC62200AFE040023
+:20EA0000084008402E4028402844FF44004849504960494055406342414241427F3E0000D1
+:20EA2000080008782E4828482848FF7800481048524852785A486648424842487FFE00009C
+:20EA4000084008402EFC28842904FEF40094109452F452846A8C468042824E82727E00009D
+:20EA6000080008FC2E2428242844FF4400944A084A7C4A445644624442444E7C72440000BD
+:20EA8000105010501C5050505050FD5601785550555055506D50455045727D92460E0000E3
+:20EAA000080008FC2E84288428FCFF84108452FC52A45AA86690429042A84EC672840000AF
+:20EAC000080008FC2E20282028F8FF48104852FE520052006AFC468442844E8472FC0000AB
+:20EAE000080008FC2E8428842884FEFC1020522052A052BC6AA046A042A04F60721E000053
+:20EB0000100010FE5C8250FE5080FEFE009010A854FC54946C90457C451046107CFE00007D
+:20EB20003FE0202020203FE002007FF0421042107FF0421042107FF20202020201FE000077
+:20EB40001FF800007FFE0444383C1FF010101FF002803EF822883EF8228A3EFA028201FE28
+:20EB60003E7C22443FFC10881FF810881FF80000FFFE08101FF8154813281FFA010200FEFE
+:20EB800009000CC008401FFE10803080DFFC108010801FFC1080108010801FFE1000000008
+:20EBA000090008801FFC30805FF810801FF810801FFC00807FFE00800080008000800080D3
+:20EBC000090008801FFC10803FF850809FFC10801FFE00001FF80410043C080408141008FF
+:20EBE00000A07C9044FC452047207DFC452045207D2045FC452047205920E1FE0100010016
+:20EC0000202020903C9045FE69909A9014FC2290FC9024FC2490249024903CFE248000006A
+:20EC20003E7C22443E7C22443E7C22443F7C08801FFE3080DFFC10801FFC10801FFE100021
+:20EC400020202A2825247D3E4868CB687DBE4928492849287D3E49A8492848287E3E402004
+:20EC600001F07D10119011501D52E2120D0E02C00C3077EE010007E0092005407FFC000062
+:20EC800001007FFC044014482444C544018002400C3077EE01001FF009200540FFFE000008
+:20ECA00040F02780808057FC1080E3602D1022C00C3077EE010007E009200540FFFE000044
+:20ECC0000800FF7E1040287E7E500890FE90091006C01BB0E10E07C0092005407FFC00007C
+:20ECE00000407E40147EFF441AA82810C8681B0404C01FB0E10E07C0092005407FFC0000C6
+:20ED00001040FE4010FCFE881150FE202050390C4E801870E7CC01000FE0054003807FFC63
+:20ED2000408027FCA12043F010002294C2944C9C43801CE0EFDE01000FE005407FFC0000BC
+:20ED400000203E1022FC3E4820FE3E1062FCBF1004C01FB0E10E07C0092005407FFC0000D6
+:20ED6000030004800860379CC10007C009203FFC102028507EF889263CF02AA81E7071FE1D
+:20ED8000204020503C48444849FEFC50545054507C50545054507C9200921D12E20E0000E5
+:20EDA000104010203C1025FE4840FE404A407E7C4A444A447E4400840E84F1140208000017
+:20EDC00020503C48444049FCFE405240527C7E44528452C87EA801101D28E24601840000FD
+:20EDE000200021FC3C20452448A4FCA854A87C2055FE54207C2000200E20F02000200020E8
+:20EE0000102010203E20243E7E20CA204A207E204AFC4A847E8400840E84F0FC00840000A6
+:20EE2000202020203E3E44207E20D2FC52847E8452FC52807E8001000D00F200040000000C
+:20EE400020003C1C45E04820FC20542057FE7C60547054A87CA801281D24E226042400204E
+:20EE6000208820883C8849087D7ED50857087D48552855287D0801081D08E128011000006A
+:20EE800012100910092000407FFE44040FE010403FF051101FF011101FF000007FFC000080
+:20EEA000202020203E2042484444FEFE520252007EFC528452847E8400840E84F0FC008412
+:20EEC000102010203C2024FC4820FC2055FE54207C20542055FC7C2000201C20E3FE0000D1
+:20EEE000102010203E2025FE4820BE202A202AFC3E002AFC2A843E8400840E84F0FC008421
+:20EF0000202020207C4045FE4880FDFC568454FC7C8454FC54847C8400840E94F0880000C1
+:20EF2000100011FE3C2024204840FDFE555255527D52555255527D5201521D52E10A0004A4
+:20EF400020403C2025FE48887E48D23052287E46538852487E4800480E88F088010800085A
+:20EF600020403C20442049FEFC10548855047E8A548854507C5000200E50F18E0E04000086
+:20EF800012400A400A803FF80400FFFE0C2037D0C88E1FF031101FF011101FF000007FFC80
+:20EFA000200021FC3C0445FC4804FC0455FC54087FFE540854887C4800481C08E02800109D
+:20EFC000200023FE3C2048207DFCD52455FC7D2455FC54207CA000400E60F198060E000498
+:20EFE000200021FE3C0048007DDED55255527D5A55D6555255527D52015219DAE15400008B
+:20F00000202020203CFE4A207D20D45057507DFC551055107DFE01101D10E290047E000074
+:20F020002040217E3D6245544954FD48555854667C00542054FC7C2000201C20E3FE000037
+:20F0400020043C0445C44944FD44557E55C47D64555455547D4401C41C04E00400140008B0
+:20F06000204020407CFC448889507C3054C857267C2055FE54207CA400A21D22E0A000404A
+:20F0800020003C3C45C04820FC4854F054207C4454FE54127C1000941C92E11202500020C4
+:20F0A0002040115081484A54102060C0270027E008403FF0D1101FF011101FF00000FFFE16
+:20F0C00020403C20242049FE7D04D40054FC7C0055FE54507C5000920C92F112060E0000BE
+:20F0E00020003C0025DE49527D52D5D255527D5255D255127D12015A1D94E11000100010F0
+:20F10000202021FE3C2044FC4820FFFE540055FC7D0455FC55047DFC01041D04E114010822
+:20F12000202020203DFC44204BFEFC10548855467E78548855507C2000501C8EE3040000F2
+:20F14000200023E03940497E51E2FD62555455547DD4555455487DC803541C66E04400404F
+:20F16000205020503C5049DE7C50D45054507DDE545054507DDE00501C50E05000500050DE
+:20F18000200021FC3D0445FC4904FD0455FC54107D1055D655187D1001521D92E10E00000A
+:20F1A000200020FC3C8444FC4884FCFC540054007DFE550255FE7D0201021DFEE102000002
+:20F1C000200021FE3D2249227D22D5FE55227D7A554A554A7D7A01021D02E1FE010200000D
+:20F1E000200020407D9C4904FD0455DC55047D0455FC54507C5000901C92E112060E000017
+:20F20000204020407C604890914E7E2055FC54087C10546054307C9402821E8AE4780000F4
+:20F22000200021FE3D224922517AFD2255FA7D02557A554A7D7A01020A023202C40A000493
+:20F24000200021F87C0849F87C48D5F855487D48554855F87C4A005A1C76E39600020000A6
+:20F2600020523C5224A449487CA4D45254007CFE549254927CFE00920E92F0FE0082000039
+:20F28000202021FC3C2048887DFED48854007DFC550455247D2401241C50E08C03040000CA
+:20F2A000204821483D4847FE4948FD78550055FE7C2057FE54207C7000A81CAEE12400201D
+:20F2C000200021DC3D5449547DDCD40055F87C0057FE54407CF800081C08E0080028001044
+:20F2E00020103C5045904890FC9457F454D87DB056D054907C9000A81CA8E0C600840000C5
+:20F30000208020807CFE4900FDFC568454FC7C8454FC54807CFC01881A50E03000CE030453
+:20F32000202020403DFC450449FCFD0455FC54007DFC542054207DFC00201C20E3FE0000A9
+:20F34000204020203DFC49047D04D5FC55007DFE55AA55AA7DFE02AA1AAAE4AA0886000060
+:20F3600020003DFC24A848507C30D4CE57207DFC552455247DFC00200E24F1FE00020000E4
+:20F3800008207E20083EFF4408441EA81210266E04040FC010807FF011101FF01110FFFE32
+:20F3A000204020483DF844504BFEFC8057F454847C7C540054FC7C8400FC1C84E0FC00843C
+:20F3C000200020FC3C8444FC88847CFC540055DE7C42554A54C67D4A02521C42E14A008447
+:20F3E000200021FE3D5249527DFED40054287CA454A255227EA800A41D22E22200200020FF
+:20F40000201C21E03C4449247CA8D49054FC7D20542057FE7C2001241D24E1FC01040000A0
+:20F42000200021483BE8494851DEFC8A57EA56AA7FEA548A57EA7C8A00921C92E0AA0084BD
+:20F44000200021FE3C5045FC4954FD5455FC54007CF8540055FE7C2001281D24E2A4004026
+:20F46000200021FC3C2047FE4A22FDAC542055AC7C0055FC54047DFC00041C04E1FC000085
+:20F4800020F820883CF8448848F8FC0055FC55547DFC540055FC7C8800501C30E0CE030403
+:20F4A0007F404040BE7E2AC8FF282A103E680FC608801FF031105FF011101FF00000FFFEAF
+:20F4C000204020203DFE4510497CFD1455FE55147D7C551055FE7D9202FE1E92E2FE049680
+:20F4E000400043FE7A089328FACEABF2AA8AFAA8AAA8AAA8FBE802943494C5240AC2000079
+:20F50000210820903DFC48207DFCD42057FE7D2454A857FE7C0001FC1D04E10401FC000041
+:20F5200020883C5025FE48507DFCD554559C7DFC550455FC54087DFE00880E88F028001009
+:20F54000204820483DFE454A49FEFD4A55FE54007DFE540054FC7C8400FC1C48E05003FE2C
+:20F5600024002400FEFC24843C8410847EFC52847E84108410FCFE001000100011FE10001E
+:20F5800024202420FE2024F83CA810A87EA852A87FFE10201050FE501088110E16041000B1
+:20F5A00028102810FD102890387E10107D90549054A87CA810A4FEC410801140123E100078
+:20F5C000240024FCFE2024203DFE10507C8855967C9010901090FC9011101110121010109F
+:20F5E00024402440FEF824903D2013FC7D2455247DFC10501050FE9210921112120E100055
+:20F60000288829FEFE882840384011FE7C8055BC7E88109010FEFE901090109010B01090AF
+:20F6200024402440FEFE25023C4211FA7C0254F27C0210F21002FEF2109210F2100A10043E
+:20F640002800FEFC28103BFE10647CA8552054607C2011FEFE6010B010A81126102010203E
+:20F66000285029FCFC5029FC385013FE7C2055FC7D2411FC1124FFFE1104110411141108AE
+:20F6800028502850FEFC2850385011FE7C8055FC56A47CFC10A4FEFC10A410A41094108860
+:20F6A0007C204420746054505488FF0682907C9044907C9044907C904510451056104810AB
+:20F6C0007CF84488748854885488FF0E82003DFC24883C9024503C2024502450348C29084D
+:20F6E00000103E1022103A102AFE7F1041103E10227E3E4222423E4222422242267E220048
+:20F7000000207C4044FC74C454A4FF8482943C8824FE3C0224023DFA24022402240A2C04D9
+:20F720007C0C44F0749054905490FF9082FE7C9044907C8844887C8A44A644D64C92440056
+:20F740007C1C44E074805480FE8082FE7C8044807CFC44C47CC444C445444D44467C0000C3
+:20F7600000407C40447C748454C8FF3082303CC827063CF824883C88248824882CF82488DB
+:20F7800000007DFC452475FC5524FF2485FC7C2045FE7C2044707CA844AE55244A200020B1
+:20F7A00000107C2044FC749454FCFE9482947CFC44307C5044907DFE4410441054104810F2
+:20F7C00000207D2444A875FE5460FEB0852C7C2044407FFE44887D884450443054CC4B0411
+:20F7E00000407C2045FE754454FCFE8885507C2044587D8E46FC7C884488448854F8488849
+:20F8000000207C1045FE75045450FEFE84507CFC44A47CA444A47CB4445044525492490E0D
+:20F8200000207C1045FE75045418FEE082807CFC44907C9045FE7C00444844865502480008
+:20F840007DFC4554755455FCFE8082807DFE46427DF245527DF24442445245FA4C0A44048B
+:20F86000082010207E2052FC7E2053FE52207E7018A81AAE1D242F202822480287FE0000C4
+:20F88000082010287F2449FE7F204920497C7FC414A4155817D8242424C4440283FE000003
+:20F8A0003FFE20A020903FFC214026B0390E27F8248827F8248827F8419046AA987E000056
+:20F8C000100023FEFC50A450FDFCA554A554FD5429AC2BAC2D042F14490A480287FE000039
+:20F8E000101020147F5449387F7C4944497C7F44147C154416C427D4244A440283FE00005D
+:20F90000090010BC7E044ACC7EB44AFC4A947EFC18A41ABC1D842F94288A480287FE000033
+:20F92000084010207EFE52507EA452D452FC7E2018FC1AAC1CFC2F842886480287FE0000DB
+:20F940001040104020A029984A46F5F0211045F0FD1009F4094811301150218CC10400003C
+:20F960007FFE412041105FFC42204D9873464CB057EC452044A047E844504520861C04089F
+:20F9800000207E5011A81C5624A854500B2036C0C9303FEEC9200FE008900A600C30081069
+:20F9A0003C202438FFFE11241DF805381D4A06CE1930EFEE09200FE008900A600C3008103C
+:20F9C0000100FFFE192023FC792015FC792011FEE3C00D383FF6C9100FF808500E300808DC
+:20F9E00000003F0420183EE0200020043E1820E02000FF82100422087F1001600380000082
+:20FA00003E0820303CC420083E3020C4FF0824307EC000007FFE044008420842103E00009A
+:20FA20003E0820303CC420183CE2200CFE3025C07FF001001FF001003FFA010200FE0000E1
+:20FA40003E0820303CC42018FF62240C7F7001001FF811081FF811087FFE1008102810100A
+:20FA60003E04281834642808FF3024C47E1800E03FF806080C2830101FF810081FF8100898
+:20FA80003E08283034C42818FF6414183EE001007FFE01001FF800001FF810081FF8000007
+:20FAA0003E08283024C4301828E0FF0C24307DC0044004402758246024442744783C0000C2
+:20FAC0003E08283034C42818FF6424187EE0084008401FFC30C0D16012581C4E104410400F
+:20FAE0003E08283034C42818FEE2240C7D7009403FF002007FFE04401FF0684C089007F0A6
+:20FB00003E04281834E42818FEE424187DE000203E2008AC7E701C202A502848488E090467
+:20FB20003F0C34702A0CFF70220C7F7000803FFE20040FE008000FF80820FFFE08201010C8
+:20FB40003E2028D0342428C8FE3024C07FF012901FF000007FFC08200FE018906C60081CAB
+:20FB60003C3829C0341C28E0FE0E29707E4009203FF822883FF825502B10254A31A6210213
+:20FB800001007FFE482048207EFC4C705AA868AE49244200428044804910920887FC000816
+:20FBA00001003FFE24103F7C26382D56341420E02F0021002FF021003FF84102410280FE24
+:20FBC00000803FFE242024203FFC2E7035A82524222027C0211027F8209044A04A90810079
+:20FBE00001003FFE22403FF822483FF828402F7A28422C3E27E0242044224822901E0000DF
+:20FC000001003FFC24403FF824483FF828402F7A28422E3E27F020804FFC41C086B0188CA6
+:20FC200001003FFE22403FFC22443FFC28402F7C2A422D3E20802FFC208047F840809FFE57
+:20FC400001003FFE22403FFC22443FFC28402F782A422C3E229021A02FFC41A04690988CCA
+:20FC6000104808487FFE54487F48557855487F78544854485EFE55005E489486810200006F
+:20FC800001003FFC24403FF824483FF828402E7A48424D3E82C00FF0708E07F002A01FFED0
+:20FCA00001003FFC24403FF824483FF82444263C3F08357E3B0855487F2845288908311838
+:20FCC000102008A47F6854FE7F7055AC7F20488848FE7F2849484AFE5C88A90882080008C3
+:20FCE00008A0109037FCD04010241FFC192815481FF801003FF801007FFE0000248842448D
+:20FD000000007E20522056A47AA452A47EA410FC10207CA410A41EA4E0A46AA495FC0000AE
+:20FD20000010FC109490DC90B53EFD521392FC9211121D52E3E204222A42A89481080000F4
+:20FD400000107E104A106EFE5A107E1008FC7E0008000EFCF0842A845584548480FC000064
+:20FD6000FE20923CD644BAC89230FE201050FE90103E1E42E0A42A285510542080C003008D
+:20FD800000207E20524876FC5A047E50108C7D0410801CFCE18804506A2054D0930E000498
+:20FDA00000207E2052FC76205BFE7E0410A07D6010A01C20E3FE0050AA48AA848104000077
+:20FDC0003E40087C7E541C942A24484C1FF8192815481FF801003FF801007FFE244442226F
+:20FDE00000407E2053FE76005A007EF810887E8810F81E20E0A000A8AB24AA2480A0004085
+:20FE000000207E20524876FC5A247FFE10507E8811261E40E1900464AB98A86087800000F7
+:20FE200000207E1053FC76885A487E5011FE7E0010FC10841EFCE0840084AA84AAFC0084D0
+:20FE400010106E1042486E4842867E84010052FC7A2456245A24764453447994510800005E
+:20FE60002010CE108210EE1082FEFE9200929292DAFEB692DA92B6929292D99291FE00002C
+:20FE80002000CEFC8220EE20827CFE24002492FEDA00B67CDA44B6449344D944917C0000CF
+:20FEA000207CCE44827CEE44827CFE1000FE92A2DA20B6FEDA48B6489330D92C91440000BB
+:20FEC0002000CE3883C0EF4882B0FE20004892F0DA28B6FCDA20B6FE9330D94E9184000007
+:20FEE000084010403E402A4037F82A487F4849487F4849487F480048FF4A248A248A450632
+:20FF000008003E002A7C36102A1026107F10497E7F1049107F100010FF902210221042101D
+:20FF200020207C2055FE6C205470FEAE9324FEF89288FEF80088FE8824F8240025FE440024
+:20FF40002020202020202020202020202020202020202020202020202020202020202020A1
+:20FF6000202020202020202020202020202020202020202020202020202020202020202081
+:20FF8000202020202020202020202020202020202020202020202020202020202020202061
+:20FFA000202020202020202020202020202020202020202020202020202020202020202041
+:20FFC000202020202020202020202020202020202020202020202020202020202020202021
+:20FFE000202020202020202020202020202020202020202020202020202020202020202001
+:020000040004F6
+:200000002020202020202020202020202020202020202020202020202020202020202020E0
+:200020002020202020202020202020202020202020202020202020202020202020202020C0
+:200040002020202020202020202020202020202020202020202020202020202020202020A0
+:20006000202020202020202020202020202020202020202020202020202020202020202080
+:20008000202020202020202020202020202020202020202020202020202020202020202060
+:2000A000202020202020202020202020202020202020202020202020202020202020202040
+:2000C000202020202020202020202020202020202020202020202020202020202020202020
+:2000E000202020202020202020202020202020202020202020202020202020202020202000
+:200100002020202020202020202020202020202020202020202020202020202020202020DF
+:200120002020202020202020202020202020202020202020202020202020202020202020BF
+:2001400020202020202020202020202020202020202020202020202020202020202020209F
+:2001600020202020202020202020202020202020202020202020202020202020202020207F
+:2001800020202020202020202020202020202020202020202020202020202020202020205F
+:2001A00020202020202020202020202020202020202020202020202020202020202020203F
+:2001C00020202020202020202020202020202020202020202020202020202020202020201F
+:2001E0002020202020202020202020202020202020202020202020202020202020202020FF
+:200200002020202020202020202020202020202020202020202020202020202020202020DE
+:200220002020202020202020202020202020202020202020202020202020202020202020BE
+:2002400020202020202020202020202020202020202020202020202020202020202020209E
+:2002600020202020202020202020202020202020202020202020202020202020202020207E
+:2002800020202020202020202020202020202020202020202020202020202020202020205E
+:2002A00020202020202020202020202020202020202020202020202020202020202020203E
+:2002C00020202020202020202020202020202020202020202020202020202020202020201E
+:2002E0002020202020202020202020202020202020202020202020202020202020202020FE
+:200300002020202020202020202020202020202020202020202020202020202020202020DD
+:200320002020202020202020202020202020202020202020202020202020202020202020BD
+:2003400020202020202020202020202020202020202020202020202020202020202020209D
+:2003600020202020202020202020202020202020202020202020202020202020202020207D
+:2003800020202020202020202020202020202020202020202020202020202020202020205D
+:2003A00020202020202020202020202020202020202020202020202020202020202020203D
+:2003C00020202020202020202020202020202020202020202020202020202020202020201D
+:2003E0002020202020202020202020202020202020202020202020202020202020202020FD
+:200400002020202020202020202020202020202020202020202020202020202020202020DC
+:200420002020202020202020202020202020202020202020202020202020202020202020BC
+:2004400020202020202020202020202020202020202020202020202020202020202020209C
+:2004600020202020202020202020202020202020202020202020202020202020202020207C
+:2004800020202020202020202020202020202020202020202020202020202020202020205C
+:2004A00020202020202020202020202020202020202020202020202020202020202020203C
+:2004C00020202020202020202020202020202020202020202020202020202020202020201C
+:2004E0002020202020202020202020202020202020202020202020202020202020202020FC
+:200500002020202020202020202020202020202020202020202020202020202020202020DB
+:200520002020202020202020202020202020202020202020202020202020202020202020BB
+:2005400020202020202020202020202020202020202020202020202020202020202020209B
+:2005600020202020202020202020202020202020202020202020202020202020202020207B
+:2005800020202020202020202020202020202020202020202020202020202020202020205B
+:2005A00020202020202020202020202020202020202020202020202020202020202020203B
+:2005C00020202020202020202020202020202020202020202020202020202020202020201B
+:2005E0002020202020202020202020202020202020202020202020202020202020202020FB
+:200600002020202020202020202020202020202020202020202020202020202020202020DA
+:200620002020202020202020202020202020202020202020202020202020202020202020BA
+:2006400020202020202020202020202020202020202020202020202020202020202020209A
+:2006600020202020202020202020202020202020202020202020202020202020202020207A
+:2006800020202020202020202020202020202020202020202020202020202020202020205A
+:2006A00020202020202020202020202020202020202020202020202020202020202020203A
+:2006C00020202020202020202020202020202020202020202020202020202020202020201A
+:2006E0002020202020202020202020202020202020202020202020202020202020202020FA
+:200700002020202020202020202020202020202020202020202020202020202020202020D9
+:200720002020202020202020202020202020202020202020202020202020202020202020B9
+:20074000202020202020202020202020202020202020202020202020202020202020202099
+:20076000202020202020202020202020202020202020202020202020202020202020202079
+:20078000202020202020202020202020202020202020202020202020202020202020202059
+:2007A000202020202020202020202020202020202020202020202020202020202020202039
+:2007C000202020202020202020202020202020202020202020202020202020202020202019
+:2007E0002020202020202020202020202020202020202020202020202020202020202020F9
+:200800002020202020202020202020202020202020202020202020202020202020202020D8
+:200820002020202020202020202020202020202020202020202020202020202020202020B8
+:20084000202020202020202020202020202020202020202020202020202020202020202098
+:20086000202020202020202020202020202020202020202020202020202020202020202078
+:20088000202020202020202020202020202020202020202020202020202020202020202058
+:2008A000202020202020202020202020202020202020202020202020202020202020202038
+:2008C000202020202020202020202020202020202020202020202020202020202020202018
+:2008E0002020202020202020202020202020202020202020202020202020202020202020F8
+:200900002020202020202020202020202020202020202020202020202020202020202020D7
+:200920002020202020202020202020202020202020202020202020202020202020202020B7
+:20094000202020202020202020202020202020202020202020202020202020202020202097
+:20096000202020202020202020202020202020202020202020202020202020202020202077
+:20098000202020202020202020202020202020202020202020202020202020202020202057
+:2009A000202020202020202020202020202020202020202020202020202020202020202037
+:2009C000202020202020202020202020202020202020202020202020202020202020202017
+:2009E0002020202020202020202020202020202020202020202020202020202020202020F7
+:200A00002020202020202020202020202020202020202020202020202020202020202020D6
+:200A20002020202020202020202020202020202020202020202020202020202020202020B6
+:200A4000202020202020202020202020202020202020202020202020202020202020202096
+:200A6000202020202020202020202020202020202020202020202020202020202020202076
+:200A8000202020202020202020202020202020202020202020202020202020202020202056
+:200AA000202020202020202020202020202020202020202020202020202020202020202036
+:200AC000202020202020202020202020202020202020202020202020202020202020202016
+:200AE0002020202020202020202020202020202020202020202020202020202020202020F6
+:200B00002020202020202020202020202020202020202020202020202020202020202020D5
+:200B20002020202020202020202020202020202020202020202020202020202020202020B5
+:200B4000202020202020202020202020202020202020202020202020202020202020202095
+:200B6000202020202020202020202020202020202020202020202020202020202020202075
+:200B8000202020202020202020202020202020202020202020202020202020202020202055
+:200BA000202020202020202020202020202020202020202020202020202020202020202035
+:200BC000202020202020202020202020202020202020202020202020202020202020202015
+:200BE0002020202020202020202020202020202020202020202020202020202020202020F5
+:200C00002020202020202020202020202020202020202020202020202020202020202020D4
+:200C20002020202020202020202020202020202020202020202020202020202020202020B4
+:200C4000202020202020202020202020202020202020202020202020202020202020202094
+:200C6000202020202020202020202020202020202020202020202020202020202020202074
+:200C8000202020202020202020202020202020202020202020202020202020202020202054
+:200CA000202020202020202020202020202020202020202020202020202020202020202034
+:200CC000202020202020202020202020202020202020202020202020202020202020202014
+:200CE0002020202020202020202020202020202020202020202020202020202020202020F4
+:200D00002020202020202020202020202020202020202020202020202020202020202020D3
+:200D20002020202020202020202020202020202020202020202020202020202020202020B3
+:200D4000202020202020202020202020202020202020202020202020202020202020202093
+:200D6000202020202020202020202020202020202020202020202020202020202020202073
+:200D8000202020202020202020202020202020202020202020202020202020202020202053
+:200DA000202020202020202020202020202020202020202020202020202020202020202033
+:200DC000202020202020202020202020202020202020202020202020202020202020202013
+:200DE0002020202020202020202020202020202020202020202020202020202020202020F3
+:200E00002020202020202020202020202020202020202020202020202020202020202020D2
+:200E20002020202020202020202020202020202020202020202020202020202020202020B2
+:200E4000202020202020202020202020202020202020202020202020202020202020202092
+:200E6000202020202020202020202020202020202020202020202020202020202020202072
+:200E8000202020202020202020202020202020202020202020202020202020202020202052
+:200EA000202020202020202020202020202020202020202020202020202020202020202032
+:200EC000202020202020202020202020202020202020202020202020202020202020202012
+:200EE0002020202020202020202020202020202020202020202020202020202020202020F2
+:200F00002020202020202020202020202020202020202020202020202020202020202020D1
+:200F20002020202020202020202020202020202020202020202020202020202020202020B1
+:200F4000202020202020202020202020202020202020202020202020202020202020202091
+:200F6000202020202020202020202020202020202020202020202020202020202020202071
+:200F8000202020202020202020202020202020202020202020202020202020202020202051
+:200FA000202020202020202020202020202020202020202020202020202020202020202031
+:200FC000202020202020202020202020202020202020202020202020202020202020202011
+:200FE0002020202020202020202020202020202020202020202020202020202020202020F1
+:201000002020202020202020202020202020202020202020202020202020202020202020D0
+:201020002020202020202020202020202020202020202020202020202020202020202020B0
+:20104000202020202020202020202020202020202020202020202020202020202020202090
+:20106000202020202020202020202020202020202020202020202020202020202020202070
+:20108000202020202020202020202020202020202020202020202020202020202020202050
+:2010A000202020202020202020202020202020202020202020202020202020202020202030
+:2010C000202020202020202020202020202020202020202020202020202020202020202010
+:2010E0002020202020202020202020202020202020202020202020202020202020202020F0
+:201100002020202020202020202020202020202020202020202020202020202020202020CF
+:201120002020202020202020202020202020202020202020202020202020202020202020AF
+:2011400020202020202020202020202020202020202020202020202020202020202020208F
+:2011600020202020202020202020202020202020202020202020202020202020202020206F
+:2011800020202020202020202020202020202020202020202020202020202020202020204F
+:2011A00020202020202020202020202020202020202020202020202020202020202020202F
+:2011C00020202020202020202020202020202020202020202020202020202020202020200F
+:2011E0002020202020202020202020202020202020202020202020202020202020202020EF
+:201200002020202020202020202020202020202020202020202020202020202020202020CE
+:201220002020202020202020202020202020202020202020202020202020202020202020AE
+:2012400020202020202020202020202020202020202020202020202020202020202020208E
+:2012600020202020202020202020202020202020202020202020202020202020202020206E
+:2012800020202020202020202020202020202020202020202020202020202020202020204E
+:2012A00020202020202020202020202020202020202020202020202020202020202020202E
+:2012C00020202020202020202020202020202020202020202020202020202020202020200E
+:2012E0002020202020202020202020202020202020202020202020202020202020202020EE
+:201300002020202020202020202020202020202020202020202020202020202020202020CD
+:201320002020202020202020202020202020202020202020202020202020202020202020AD
+:2013400020202020202020202020202020202020202020202020202020202020202020208D
+:2013600020202020202020202020202020202020202020202020202020202020202020206D
+:2013800020202020202020202020202020202020202020202020202020202020202020204D
+:2013A00020202020202020202020202020202020202020202020202020202020202020202D
+:2013C00020202020202020202020202020202020202020202020202020202020202020200D
+:2013E0002020202020202020202020202020202020202020202020202020202020202020ED
+:201400002020202020202020202020202020202020202020202020202020202020202020CC
+:201420002020202020202020202020202020202020202020202020202020202020202020AC
+:2014400020202020202020202020202020202020202020202020202020202020202020208C
+:2014600020202020202020202020202020202020202020202020202020202020202020206C
+:2014800020202020202020202020202020202020202020202020202020202020202020204C
+:2014A00020202020202020202020202020202020202020202020202020202020202020202C
+:2014C00020202020202020202020202020202020202020202020202020202020202020200C
+:2014E0002020202020202020202020202020202020202020202020202020202020202020EC
+:201500002020202020202020202020202020202020202020202020202020202020202020CB
+:201520002020202020202020202020202020202020202020202020202020202020202020AB
+:2015400020202020202020202020202020202020202020202020202020202020202020208B
+:2015600020202020202020202020202020202020202020202020202020202020202020206B
+:2015800020202020202020202020202020202020202020202020202020202020202020204B
+:2015A00020202020202020202020202020202020202020202020202020202020202020202B
+:2015C00020202020202020202020202020202020202020202020202020202020202020200B
+:2015E0002020202020202020202020202020202020202020202020202020202020202020EB
+:201600002020202020202020202020202020202020202020202020202020202020202020CA
+:201620002020202020202020202020202020202020202020202020202020202020202020AA
+:2016400020202020202020202020202020202020202020202020202020202020202020208A
+:2016600020202020202020202020202020202020202020202020202020202020202020206A
+:2016800020202020202020202020202020202020202020202020202020202020202020204A
+:2016A00020202020202020202020202020202020202020202020202020202020202020202A
+:2016C00020202020202020202020202020202020202020202020202020202020202020200A
+:2016E0002020202020202020202020202020202020202020202020202020202020202020EA
+:201700002020202020202020202020202020202020202020202020202020202020202020C9
+:201720002020202020202020202020202020202020202020202020202020202020202020A9
+:20174000202020202020202020202020202020202020202020202020202020202020202089
+:20176000202020202020202020202020202020202020202020202020202020202020202069
+:20178000202020202020202020202020202020202020202020202020202020202020202049
+:2017A000202020202020202020202020202020202020202020202020202020202020202029
+:2017C000202020202020202020202020202020202020202020202020202020202020202009
+:2017E0002020202020202020202020202020202020202020202020202020202020202020E9
+:201800002020202020202020202020202020202020202020202020202020202020202020C8
+:201820002020202020202020202020202020202020202020202020202020202020202020A8
+:20184000202020202020202020202020202020202020202020202020202020202020202088
+:20186000202020202020202020202020202020202020202020202020202020202020202068
+:20188000202020202020202020202020202020202020202020202020202020202020202048
+:2018A000202020202020202020202020202020202020202020202020202020202020202028
+:2018C000202020202020202020202020202020202020202020202020202020202020202008
+:2018E0002020202020202020202020202020202020202020202020202020202020202020E8
+:201900002020202020202020202020202020202020202020202020202020202020202020C7
+:201920002020202020202020202020202020202020202020202020202020202020202020A7
+:20194000202020202020202020202020202020202020202020202020202020202020202087
+:20196000202020202020202020202020202020202020202020202020202020202020202067
+:20198000202020202020202020202020202020202020202020202020202020202020202047
+:2019A000202020202020202020202020202020202020202020202020202020202020202027
+:2019C000202020202020202020202020202020202020202020202020202020202020202007
+:2019E0002020202020202020202020202020202020202020202020202020202020202020E7
+:201A00002020202020202020202020202020202020202020202020202020202020202020C6
+:201A20002020202020202020202020202020202020202020202020202020202020202020A6
+:201A4000202020202020202020202020202020202020202020202020202020202020202086
+:201A6000202020202020202020202020202020202020202020202020202020202020202066
+:201A8000202020202020202020202020202020202020202020202020202020202020202046
+:201AA000202020202020202020202020202020202020202020202020202020202020202026
+:201AC000202020202020202020202020202020202020202020202020202020202020202006
+:201AE0002020202020202020202020202020202020202020202020202020202020202020E6
+:201B00002020202020202020202020202020202020202020202020202020202020202020C5
+:201B20002020202020202020202020202020202020202020202020202020202020202020A5
+:201B4000202020202020202020202020202020202020202020202020202020202020202085
+:201B6000202020202020202020202020202020202020202020202020202020202020202065
+:201B8000202020202020202020202020202020202020202020202020202020202020202045
+:201BA000202020202020202020202020202020202020202020202020202020202020202025
+:201BC000202020202020202020202020202020202020202020202020202020202020202005
+:201BE0002020202020202020202020202020202020202020202020202020202020202020E5
+:201C00002020202020202020202020202020202020202020202020202020202020202020C4
+:201C20002020202020202020202020202020202020202020202020202020202020202020A4
+:201C4000202020202020202020202020202020202020202020202020202020202020202084
+:201C6000202020202020202020202020202020202020202020202020202020202020202064
+:201C8000202020202020202020202020202020202020202020202020202020202020202044
+:201CA000202020202020202020202020202020202020202020202020202020202020202024
+:201CC000202020202020202020202020202020202020202020202020202020202020202004
+:201CE0002020202020202020202020202020202020202020202020202020202020202020E4
+:201D00002020202020202020202020202020202020202020202020202020202020202020C3
+:201D20002020202020202020202020202020202020202020202020202020202020202020A3
+:201D4000202020202020202020202020202020202020202020202020202020202020202083
+:201D6000202020202020202020202020202020202020202020202020202020202020202063
+:201D8000202020202020202020202020202020202020202020202020202020202020202043
+:201DA000202020202020202020202020202020202020202020202020202020202020202023
+:201DC000202020202020202020202020202020202020202020202020202020202020202003
+:201DE0002020202020202020202020202020202020202020202020202020202020202020E3
+:201E00002020202020202020202020202020202020202020202020202020202020202020C2
+:201E20002020202020202020202020202020202020202020202020202020202020202020A2
+:201E4000202020202020202020202020202020202020202020202020202020202020202082
+:201E6000202020202020202020202020202020202020202020202020202020202020202062
+:201E8000202020202020202020202020202020202020202020202020202020202020202042
+:201EA000202020202020202020202020202020202020202020202020202020202020202022
+:201EC000202020202020202020202020202020202020202020202020202020202020202002
+:201EE0002020202020202020202020202020202020202020202020202020202020202020E2
+:201F00002020202020202020202020202020202020202020202020202020202020202020C1
+:201F20002020202020202020202020202020202020202020202020202020202020202020A1
+:201F4000202020202020202020202020202020202020202020202020202020202020202081
+:201F6000202020202020202020202020202020202020202020202020202020202020202061
+:201F8000202020202020202020202020202020202020202020202020202020202020202041
+:201FA000202020202020202020202020202020202020202020202020202020202020202021
+:201FC000202020202020202020202020202020202020202020202020202020202020202001
+:201FE0002020202020202020202020202020202020202020202020202020202020202020E1
+:202000002020202020202020202020202020202020202020202020202020202020202020C0
+:202020002020202020202020202020202020202020202020202020202020202020202020A0
+:20204000202020202020202020202020202020202020202020202020202020202020202080
+:20206000202020202020202020202020202020202020202020202020202020202020202060
+:20208000202020202020202020202020202020202020202020202020202020202020202040
+:2020A000202020202020202020202020202020202020202020202020202020202020202020
+:2020C000202020202020202020202020202020202020202020202020202020202020202000
+:2020E0002020202020202020202020202020202020202020202020202020202020202020E0
+:202100002020202020202020202020202020202020202020202020202020202020202020BF
+:2021200020202020202020202020202020202020202020202020202020202020202020209F
+:2021400020202020202020202020202020202020202020202020202020202020202020207F
+:2021600020202020202020202020202020202020202020202020202020202020202020205F
+:2021800020202020202020202020202020202020202020202020202020202020202020203F
+:2021A00020202020202020202020202020202020202020202020202020202020202020201F
+:2021C0002020202020202020202020202020202020202020202020202020202020202020FF
+:2021E0002020202020202020202020202020202020202020202020202020202020202020DF
+:202200002020202020202020202020202020202020202020202020202020202020202020BE
+:2022200020202020202020202020202020202020202020202020202020202020202020209E
+:2022400020202020202020202020202020202020202020202020202020202020202020207E
+:2022600020202020202020202020202020202020202020202020202020202020202020205E
+:2022800020202020202020202020202020202020202020202020202020202020202020203E
+:2022A00020202020202020202020202020202020202020202020202020202020202020201E
+:2022C0002020202020202020202020202020202020202020202020202020202020202020FE
+:2022E0002020202020202020202020202020202020202020202020202020202020202020DE
+:202300002020202020202020202020202020202020202020202020202020202020202020BD
+:2023200020202020202020202020202020202020202020202020202020202020202020209D
+:2023400020202020202020202020202020202020202020202020202020202020202020207D
+:2023600020202020202020202020202020202020202020202020202020202020202020205D
+:2023800020202020202020202020202020202020202020202020202020202020202020203D
+:2023A00020202020202020202020202020202020202020202020202020202020202020201D
+:2023C0002020202020202020202020202020202020202020202020202020202020202020FD
+:2023E0002020202020202020202020202020202020202020202020202020202020202020DD
+:202400002020202020202020202020202020202020202020202020202020202020202020BC
+:2024200020202020202020202020202020202020202020202020202020202020202020209C
+:2024400020202020202020202020202020202020202020202020202020202020202020207C
+:2024600020202020202020202020202020202020202020202020202020202020202020205C
+:2024800020202020202020202020202020202020202020202020202020202020202020203C
+:2024A00020202020202020202020202020202020202020202020202020202020202020201C
+:2024C0002020202020202020202020202020202020202020202020202020202020202020FC
+:2024E0002020202020202020202020202020202020202020202020202020202020202020DC
+:202500002020202020202020202020202020202020202020202020202020202020202020BB
+:2025200020202020202020202020202020202020202020202020202020202020202020209B
+:2025400020202020202020202020202020202020202020202020202020202020202020207B
+:2025600020202020202020202020202020202020202020202020202020202020202020205B
+:2025800020202020202020202020202020202020202020202020202020202020202020203B
+:2025A00020202020202020202020202020202020202020202020202020202020202020201B
+:2025C0002020202020202020202020202020202020202020202020202020202020202020FB
+:2025E0002020202020202020202020202020202020202020202020202020202020202020DB
+:202600002020202020202020202020202020202020202020202020202020202020202020BA
+:2026200020202020202020202020202020202020202020202020202020202020202020209A
+:2026400020202020202020202020202020202020202020202020202020202020202020207A
+:2026600020202020202020202020202020202020202020202020202020202020202020205A
+:2026800020202020202020202020202020202020202020202020202020202020202020203A
+:2026A00020202020202020202020202020202020202020202020202020202020202020201A
+:2026C0002020202020202020202020202020202020202020202020202020202020202020FA
+:2026E0002020202020202020202020202020202020202020202020202020202020202020DA
+:202700002020202020202020202020202020202020202020202020202020202020202020B9
+:20272000202020202020202020202020202020202020202020202020202020202020202099
+:20274000202020202020202020202020202020202020202020202020202020202020202079
+:20276000202020202020202020202020202020202020202020202020202020202020202059
+:20278000202020202020202020202020202020202020202020202020202020202020202039
+:2027A000202020202020202020202020202020202020202020202020202020202020202019
+:2027C0002020202020202020202020202020202020202020202020202020202020202020F9
+:2027E0002020202020202020202020202020202020202020202020202020202020202020D9
+:202800002020202020202020202020202020202020202020202020202020202020202020B8
+:20282000202020202020202020202020202020202020202020202020202020202020202098
+:20284000202020202020202020202020202020202020202020202020202020202020202078
+:20286000202020202020202020202020202020202020202020202020202020202020202058
+:20288000202020202020202020202020202020202020202020202020202020202020202038
+:2028A000202020202020202020202020202020202020202020202020202020202020202018
+:2028C0002020202020202020202020202020202020202020202020202020202020202020F8
+:2028E0002020202020202020202020202020202020202020202020202020202020202020D8
+:202900002020202020202020202020202020202020202020202020202020202020202020B7
+:20292000202020202020202020202020202020202020202020202020202020202020202097
+:20294000202020202020202020202020202020202020202020202020202020202020202077
+:20296000202020202020202020202020202020202020202020202020202020202020202057
+:20298000202020202020202020202020202020202020202020202020202020202020202037
+:2029A000202020202020202020202020202020202020202020202020202020202020202017
+:2029C0002020202020202020202020202020202020202020202020202020202020202020F7
+:2029E0002020202020202020202020202020202020202020202020202020202020202020D7
+:202A00002020202020202020202020202020202020202020202020202020202020202020B6
+:202A2000202020202020202020202020202020202020202020202020202020202020202096
+:202A4000202020202020202020202020202020202020202020202020202020202020202076
+:202A6000202020202020202020202020202020202020202020202020202020202020202056
+:202A8000202020202020202020202020202020202020202020202020202020202020202036
+:202AA000202020202020202020202020202020202020202020202020202020202020202016
+:202AC0002020202020202020202020202020202020202020202020202020202020202020F6
+:202AE0002020202020202020202020202020202020202020202020202020202020202020D6
+:202B00002020202020202020202020202020202020202020202020202020202020202020B5
+:202B2000202020202020202020202020202020202020202020202020202020202020202095
+:202B4000202020202020202020202020202020202020202020202020202020202020202075
+:202B6000202020202020202020202020202020202020202020202020202020202020202055
+:202B8000202020202020202020202020202020202020202020202020202020202020202035
+:202BA000202020202020202020202020202020202020202020202020202020202020202015
+:202BC0002020202020202020202020202020202020202020202020202020202020202020F5
+:202BE0002020202020202020202020202020202020202020202020202020202020202020D5
+:202C00002020202020202020202020202020202020202020202020202020202020202020B4
+:202C2000202020202020202020202020202020202020202020202020202020202020202094
+:202C4000202020202020202020202020202020202020202020202020202020202020202074
+:202C6000202020202020202020202020202020202020202020202020202020202020202054
+:202C8000202020202020202020202020202020202020202020202020202020202020202034
+:202CA000202020202020202020202020202020202020202020202020202020202020202014
+:202CC0002020202020202020202020202020202020202020202020202020202020202020F4
+:202CE0002020202020202020202020202020202020202020202020202020202020202020D4
+:202D00002020202020202020202020202020202020202020202020202020202020202020B3
+:202D2000202020202020202020202020202020202020202020202020202020202020202093
+:202D4000202020202020202020202020202020202020202020202020202020202020202073
+:202D6000202020202020202020202020202020202020202020202020202020202020202053
+:202D8000202020202020202020202020202020202020202020202020202020202020202033
+:202DA000202020202020202020202020202020202020202020202020202020202020202013
+:202DC0002020202020202020202020202020202020202020202020202020202020202020F3
+:202DE0002020202020202020202020202020202020202020202020202020202020202020D3
+:202E00002020202020202020202020202020202020202020202020202020202020202020B2
+:202E2000202020202020202020202020202020202020202020202020202020202020202092
+:202E4000202020202020202020202020202020202020202020202020202020202020202072
+:202E6000202020202020202020202020202020202020202020202020202020202020202052
+:202E8000202020202020202020202020202020202020202020202020202020202020202032
+:202EA000202020202020202020202020202020202020202020202020202020202020202012
+:202EC0002020202020202020202020202020202020202020202020202020202020202020F2
+:202EE0002020202020202020202020202020202020202020202020202020202020202020D2
+:202F00002020202020202020202020202020202020202020202020202020202020202020B1
+:202F2000202020202020202020202020202020202020202020202020202020202020202091
+:202F4000202020202020202020202020202020202020202020202020202020202020202071
+:202F6000202020202020202020202020202020202020202020202020202020202020202051
+:202F8000202020202020202020202020202020202020202020202020202020202020202031
+:202FA000202020202020202020202020202020202020202020202020202020202020202011
+:202FC0002020202020202020202020202020202020202020202020202020202020202020F1
+:202FE0002020202020202020202020202020202020202020202020202020202020202020D1
+:203000000000000000000000000000000000000000007E81A58181BD9981817E0000000034
+:2030200000007EFFDBFFFFC3E7FFFF7E00000000000000006CFEFEFEFE7C381000000000EC
+:203040000000000010387CFE7C38100000000000000000183C3CE7E7E718183C0000000039
+:20306000000000183C7EFFFF7E18183C00000000000000000000183C3C18000000000000EE
+:20308000FFFFFFFFFFFFE7C3C3E7FFFFFFFFFFFF00000000003C664242663C000000000020
+:2030A000FFFFFFFFFFC399BDBD99C3FFFFFFFFFF00001E0E1A3278CCCCCCCC780000000050
+:2030C00000003C666666663C187E18180000000000003F333F3030303070F0E00000000069
+:2030E00000007F637F6363636367E7E6C00000000000001818DB3CE73CDB1818000000007A
+:203100000080C0E0F0F8FEF8F0E0C080000000000002060E1E3EFE3E1E0E060200000000BF
+:203120000000183C7E1818187E3C180000000000000066666666666666006666000000000D
+:2031400000007FDBDBDB7B1B1B1B1B1B00000000007CC660386CC6C66C380CC67C00000099
+:203160000000000000000000FEFEFEFE000000000000183C7E1818187E3C187E00000000ED
+:203180000000183C7E18181818181818000000000000181818181818187E3C18000000003B
+:2031A0000000000000180CFE0C1800000000000000000000003060FE6030000000000000AB
+:2031C000000000000000C0C0C0FE0000000000000000000000286CFE6C280000000000008B
+:2031E000000000001038387C7CFEFE000000000000000000FEFE7C7C3838100000000000E7
+:20320000000000000000000000000000000000000000183C3C3C181818001818000000006A
+:20322000006666662400000000000000000000000000006C6CFE6C6C6CFE6C6C0000000048
+:2032400018187CC6C2C07C060686C67C1818000000000000C2C60C183060C6860000000072
+:203260000000386C6C3876DCCCCCCC760000000000303030600000000000000000000000EA
+:2032800000000C18303030303030180C00000000000030180C0C0C0C0C0C183000000000EE
+:2032A0000000000000663CFF3C66000000000000000000000018187E1818000000000000ED
+:2032C0000000000000000000001818183000000000000000000000FE000000000000000078
+:2032E000000000000000000000001818000000000000000002060C183060C08000000000A2
+:203300000000386CC6C6D6D6C6C66C380000000000001838781818181818187E00000000CB
+:2033200000007CC6060C183060C0C6FE0000000000007CC606063C060606C67C000000002F
+:2033400000000C1C3C6CCCFE0C0C0C1E000000000000FEC0C0C0FC060606C67C0000000003
+:2033600000003860C0C0FCC6C6C6C67C000000000000FEC606060C183030303000000000F1
+:2033800000007CC6C6C67CC6C6C6C67C0000000000007CC6C6C67E0606060C78000000006D
+:2033A00000000000181800000018180000000000000000001818000000181830000000001D
+:2033C000000000060C18306030180C060000000000000000007E00007E00000000000000DD
+:2033E0000000006030180C060C1830600000000000007CC6C60C18181800181800000000D3
+:203400000000007CC6C6DEDEDEDCC07C00000000000010386CC6C6FEC6C6C6C6000000009C
+:203420000000FC6666667C66666666FC0000000000003C66C2C0C0C0C0C2663C0000000086
+:203440000000F86C6666666666666CF8000000000000FE6662687868606266FE000000000C
+:203460000000FE6662687868606060F00000000000003C66C2C0C0DEC6C6663A0000000040
+:203480000000C6C6C6C6FEC6C6C6C6C60000000000003C18181818181818183C0000000000
+:2034A00000001E0C0C0C0C0CCCCCCC78000000000000E666666C78786C6666E600000000AA
+:2034C0000000F06060606060606266FE000000000000C6EEFEFED6C6C6C6C6C60000000092
+:2034E0000000C6E6F6FEDECEC6C6C6C60000000000007CC6C6C6C6C6C6C6C67C0000000040
+:203500000000FC6666667C60606060F00000000000007CC6C6C6C6C6C6D6DE7C0C0E000027
+:203520000000FC6666667C6C666666E60000000000007CC6C660380C06C6C67C00000000A3
+:2035400000007E7E5A1818181818183C000000000000C6C6C6C6C6C6C6C6C67C00000000D7
+:203560000000C6C6C6C6C6C6C66C3810000000000000C6C6C6C6D6D6D6FEEE6C000000003B
+:203580000000C6C66C7C38387C6CC6C6000000000000666666663C181818183C0000000063
+:2035A0000000FEC6860C183060C2C6FE0000000000003C30303030303030303C000000008F
+:2035C00000000080C0E070381C0E06020000000000003C0C0C0C0C0C0C0C0C3C0000000019
+:2035E00010386CC600000000000000000000000000000000000000000000000000FF000052
+:20360000303018000000000000000000000000000000000000780C7CCCCCCC760000000058
+:203620000000E06060786C666666667C0000000000000000007CC6C0C0C0C67C000000002E
+:2036400000001C0C0C3C6CCCCCCCCC760000000000000000007CC6FEC0C0C67C00000000E6
+:203660000000386C6460F060606060F000000000000000000076CCCCCCCCCC7C0CCC780044
+:203680000000E060606C7666666666E60000000000001818003818181818183C000000000E
+:2036A00000000606000E06060606060666663C000000E06060666C78786C66E600000000AA
+:2036C00000003818181818181818183C000000000000000000ECFED6D6D6D6C600000000AE
+:2036E0000000000000DC6666666666660000000000000000007CC6C6C6C6C67C00000000B4
+:203700000000000000DC66666666667C6060F000000000000076CCCCCCCCCC7C0C0C1E007F
+:203720000000000000DC7666606060F00000000000000000007CC660380CC67C0000000099
+:203740000000103030FC30303030361C000000000000000000CCCCCCCCCCCC7600000000AD
+:20376000000000000066666666663C18000000000000000000C6C6D6D6D6FE6C000000007F
+:203780000000000000C66C3838386CC6000000000000000000C6C6C6C6C6C67E060CF800F1
+:2037A0000000000000FECC183060C6FE0000000000000E18181870181818180E000000009F
+:2037C000000018181818001818181818000000000000701818180E1818181870000000007B
+:2037E000000076DC0000000000000000000000000000000010386CC6C6C6FE000000000073
+:2038000000003C66C2C0C0C0C2663C0C067C00000000CC0000CCCCCCCCCCCC760000000008
+:20382000000C1830007CC6FEC0C0C67C000000000010386C00780C7CCCCCCC7600000000A4
+:203840000000CC0000780C7CCCCCCC76000000000060301800780C7CCCCCCC760000000040
+:2038600000386C3800780C7CCCCCCC7600000000000000003C666060663C0C063C00000040
+:203880000010386C007CC6FEC0C0C67C000000000000C600007CC6FEC0C0C67C00000000AA
+:2038A00000603018007CC6FEC0C0C67C0000000000006600003818181818183C000000000C
+:2038C00000183C66003818181818183C0000000000603018003818181818183C00000000AE
+:2038E00000C60010386CC6C6FEC6C6C600000000386C3800386CC6C6FEC6C6C60000000016
+:2039000018306000FE66607C606066FE000000000000000000CC76367ED8D86E0000000087
+:2039200000003E6CCCCCFECCCCCCCCCE000000000010386C007CC6C6C6C6C67C00000000BF
+:203940000000C600007CC6C6C6C6C67C0000000000603018007CC6C6C6C6C67C000000004D
+:20396000003078CC00CCCCCCCCCCCC76000000000060301800CCCCCCCCCCCC7600000000AF
+:203980000000C60000C6C6C6C6C6C67E060C780000C6007CC6C6C6C6C6C6C67C000000008D
+:2039A00000C600C6C6C6C6C6C6C6C67C000000000018183C66606060663C181800000000D1
+:2039C00000386C6460F060606060E6FC00000000000066663C187E187E18181800000000B1
+:2039E00000F8CCCCF8C4CCDECCCCCCC600000000000E1B1818187E1818181818D8700000F8
+:203A00000018306000780C7CCCCCCC7600000000000C1830003818181818183C00000000E4
+:203A200000183060007CC6C6C6C6C67C000000000018306000CCCCCCCCCCCC760000000022
+:203A4000000076DC00DC6666666666660000000076DC00C6E6F6FEDECEC6C6C600000000E4
+:203A6000003C6C6C3E007E00000000000000000000386C6C38007C000000000000000000B2
+:203A80000000303000303060C0C6C67C00000000000000000000FEC0C0C0C0000000000040
+:203AA000000000000000FE06060606000000000000C0C0C2C6CC183060DC860C183E0000B0
+:203AC00000C0C0C2C6CC183066CE9E3E0606000000001818001818183C3C3C18000000006A
+:203AE0000000000000366CD86C360000000000000000000000D86C366CD8000000000000EC
+:203B00001144114411441144114411441144114455AA55AA55AA55AA55AA55AA55AA55AA05
+:203B2000DD77DD77DD77DD77DD77DD77DD77DD771818181818181818181818181818181865
+:203B400018181818181818F818181818181818181818181818F818F81818181818181818C5
+:203B600036363636363636F6363636363636363600000000000000FE363636363636363677
+:203B80000000000000F818F818181818181818183636363636F606F63636363636363636AD
+:203BA000363636363636363636363636363636360000000000FE06F63636363636363636FB
+:203BC0003636363636F606FE000000000000000036363636363636FE000000000000000065
+:203BE0001818181818F818F8000000000000000000000000000000F818181818181818188D
+:203C0000181818181818181F000000000000000018181818181818FF000000000000000036
+:203C200000000000000000FF1818181818181818181818181818181F18181818181818183E
+:203C400000000000000000FF000000000000000018181818181818FF1818181818181818FE
+:203C600018181818181F181F18181818181818183636363636363637363636363636363655
+:203C8000363636363637303F000000000000000000000000003F303736363636363636361A
+:203CA0003636363636F700FF00000000000000000000000000FF00F736363636363636365A
+:203CC000363636363637303736363636363636360000000000FF00FF00000000000000008A
+:203CE0003636363636F700F736363636363636361818181818FF00FF0000000000000000A2
+:203D000036363636363636FF00000000000000000000000000FF00FF18181818181818186C
+:203D200000000000000000FF3636363636363636363636363636363F00000000000000001B
+:203D400018181818181F181F000000000000000000000000001F181F18181818181818187F
+:203D6000000000000000003F363636363636363636363636363636FF36363636363636362B
+:203D80001818181818FF18FF181818181818181818181818181818F8000000000000000035
+:203DA000000000000000001F1818181818181818FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF34
+:203DC00000000000000000FFFFFFFFFFFFFFFFFFF0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0EC
+:203DE0000F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0FFFFFFFFFFFFFFF000000000000000000DA
+:203E0000000000000076DCD8D8D8DC7600000000000078CCCCCCD8CCC6C6C6CC00000000D8
+:203E20000000FEC6C6C0C0C0C0C0C0C00000000000000000FE6C6C6C6C6C6C6C00000000C6
+:203E4000000000FEC66030183060C6FE0000000000000000007ED8D8D8D8D870000000007C
+:203E60000000000066666666667C6060C00000000000000076DC1818181818180000000066
+:203E80000000007E183C6666663C187E00000000000000386CC6C6FEC6C66C3800000000EE
+:203EA0000000386CC6C6C66C6C6C6CEE0000000000001E30180C3E666666663C00000000EA
+:203EC00000000000007EDBDBDB7E00000000000000000003067EDBDBF37E60C00000000087
+:203EE00000001C3060607C606060301C000000000000007CC6C6C6C6C6C6C6C60000000022
+:203F000000000000FE0000FE0000FE00000000000000000018187E18180000FF00000000CA
+:203F200000000030180C060C1830007E000000000000000C18306030180C007E00000000CF
+:203F400000000E1B1B18181818181818181818181818181818181818D8D8D870000000005D
+:203F6000000000001818007E0018180000000000000000000076DC0076DC000000000000BF
+:203F800000386C6C38000000000000000000000000000000000000181800000000000000A9
+:203FA00000000000000000001800000000000000000F0C0C0C0C0CEC6C6C3C1C0000000082
+:203FC00000D86C6C6C6C6C0000000000000000000070D83060C8F800000000000000000055
+:203FE000000000007C7C7C7C7C7C7C0000000000000000000000000000000000000000005D
+:00000001FF
diff --git a/zk/sk_zk_16_10A.upf b/zk/sk_zk_16_10A.upf
new file mode 100644
index 0000000..e6f36f1
--- /dev/null
+++ b/zk/sk_zk_16_10A.upf
Binary files differ
diff --git a/zk/sk_zk_16_15A.upf b/zk/sk_zk_16_15A.upf
new file mode 100644
index 0000000..1e8b6f2
--- /dev/null
+++ b/zk/sk_zk_16_15A.upf
Binary files differ