├── cifar10
├── .gitignore
├── ARMCM4_debug
│ └── arm_nnexample_cifar10.sct
├── DebugConfig
│ ├── ARMCM4_FP_STM32F407VGTx.dbgconf
│ └── STM32F407DISCO_STM32F407VGTx.dbgconf
├── EventRecorderStub.scvd
├── RTE
│ ├── Compiler
│ │ └── EventRecorderConf.h
│ ├── Device
│ │ ├── ARMCM0
│ │ │ ├── startup_ARMCM0.s
│ │ │ └── system_ARMCM0.c
│ │ ├── ARMCM3
│ │ │ ├── startup_ARMCM3.s
│ │ │ └── system_ARMCM3.c
│ │ ├── ARMCM4_FP
│ │ │ ├── startup_ARMCM4.s
│ │ │ └── system_ARMCM4.c
│ │ ├── ARMCM7_SP
│ │ │ ├── gcc_arm.ld
│ │ │ ├── startup_ARMCM7.c
│ │ │ ├── startup_ARMCM7.s
│ │ │ └── system_ARMCM7.c
│ │ └── STM32F407VGTx
│ │ │ ├── startup_stm32f407xx.s
│ │ │ ├── system_stm32f4xx-backup.c
│ │ │ └── system_stm32f4xx.c
│ ├── _ARMCM0
│ │ └── RTE_Components.h
│ ├── _ARMCM3
│ │ └── RTE_Components.h
│ ├── _ARMCM4_FP
│ │ └── RTE_Components.h
│ ├── _ARMCM7_SP
│ │ └── RTE_Components.h
│ └── _STM32F407DISCO
│ │ └── RTE_Components.h
├── arm_nnexamples_cifar10.cpp
├── arm_nnexamples_cifar10.uvprojx
├── arm_nnexamples_cifar10_inputs.h
├── arm_nnexamples_cifar10_parameter.h
├── arm_nnexamples_cifar10_weights.h
└── readme.txt
├── readme.md
└── scripts
├── .gitignore
├── README.md
├── cifar-10-IMG_DATA.ipynb
├── model.png
└── requirements.txt
/cifar10/.gitignore:
--------------------------------------------------------------------------------
1 | # A .gitignore for Keil projects.
2 | # Taken mostly from http://www.keil.com/support/man/docs/uv4/uv4_b_filetypes.htm
3 |
4 | # User-specific uVision files
5 | *.opt
6 | *.uvopt
7 | *.uvoptx
8 | *.uvgui
9 | *.uvgui.*
10 | *.uvguix.*
11 |
12 | # Listing files
13 | *.cod
14 | *.htm
15 | *.i
16 | *.lst
17 | *.map
18 | *.m51
19 | *.m66
20 | *.scr # define exception below if needed
21 |
22 | # Object and HEX files
23 | *.axf
24 | *.b[0-3][0-9]
25 | *.hex
26 | *.d
27 | *.crf
28 | *.elf
29 | *.hex
30 | *.h86
31 | *.lib
32 | *.obj
33 | *.o
34 | *.sbr
35 |
36 | # Build files
37 | *.bat # define exception below if needed
38 | *._ia
39 | *.__i
40 | *._ii
41 |
42 | # Generated output files
43 | /Listings/*
44 | /Objects/*
45 |
46 | # Debugger files
47 | *.ini # define exception below if needed
48 |
49 | # Other files
50 | *.build_log.htm
51 | *.cdb
52 | *.dep
53 | *.ic
54 | *.lin
55 | *.lnp
56 | *.orc
57 | *.pack # define exception below if needed
58 | *.pdsc # define exception below if needed
59 | *.plg
60 | *.sct # define exception below if needed
61 | *.sfd
62 | *.sfr
63 |
64 | # Miscellaneous
65 | *.tra
66 | *.bin
67 | *.fed
68 | *.l1p
69 | *.l2p
70 | *.iex
71 |
72 | # To explicitly override the above, define any exceptions here; e.g.:
73 | # !my_customized_scatter_file.sct
--------------------------------------------------------------------------------
/cifar10/ARMCM4_debug/arm_nnexample_cifar10.sct:
--------------------------------------------------------------------------------
1 | ; *************************************************************
2 | ; *** Scatter-Loading Description File generated by uVision ***
3 | ; *************************************************************
4 |
5 | LR_IROM1 0x08000000 0x00100000 { ; load region size_region
6 | ER_IROM1 0x08000000 0x00100000 { ; load address = execution address
7 | *.o (RESET, +First)
8 | *(InRoot$$Sections)
9 | .ANY (+RO)
10 | }
11 | RW_IRAM1 0x20000000 0x00020000 { ; RW data
12 | .ANY (+RW +ZI)
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/cifar10/DebugConfig/ARMCM4_FP_STM32F407VGTx.dbgconf:
--------------------------------------------------------------------------------
1 | // File: STM32F405_415_407_417_427_437_429_439.dbgconf
2 | // Version: 1.0.0
3 | // Note: refer to STM32F405/415 STM32F407/417 STM32F427/437 STM32F429/439 reference manual (RM0090)
4 | // refer to STM32F40x STM32F41x datasheets
5 | // refer to STM32F42x STM32F43x datasheets
6 |
7 | // <<< Use Configuration Wizard in Context Menu >>>
8 |
9 | // Debug MCU configuration register (DBGMCU_CR)
10 | // DBG_STANDBY Debug Standby Mode
11 | // DBG_STOP Debug Stop Mode
12 | // DBG_SLEEP Debug Sleep Mode
13 | //
14 | DbgMCU_CR = 0x00000007;
15 |
16 | // Debug MCU APB1 freeze register (DBGMCU_APB1_FZ)
17 | // Reserved bits must be kept at reset value
18 | // DBG_CAN2_STOP CAN2 stopped when core is halted
19 | // DBG_CAN1_STOP CAN2 stopped when core is halted
20 | // DBG_I2C3_SMBUS_TIMEOUT I2C3 SMBUS timeout mode stopped when core is halted
21 | // DBG_I2C2_SMBUS_TIMEOUT I2C2 SMBUS timeout mode stopped when core is halted
22 | // DBG_I2C1_SMBUS_TIMEOUT I2C1 SMBUS timeout mode stopped when core is halted
23 | // DBG_IWDG_STOP Independent watchdog stopped when core is halted
24 | // DBG_WWDG_STOP Window watchdog stopped when core is halted
25 | // DBG_RTC_STOP RTC stopped when core is halted
26 | // DBG_TIM14_STOP TIM14 counter stopped when core is halted
27 | // DBG_TIM13_STOP TIM13 counter stopped when core is halted
28 | // DBG_TIM12_STOP TIM12 counter stopped when core is halted
29 | // DBG_TIM7_STOP TIM7 counter stopped when core is halted
30 | // DBG_TIM6_STOP TIM6 counter stopped when core is halted
31 | // DBG_TIM5_STOP TIM5 counter stopped when core is halted
32 | // DBG_TIM4_STOP TIM4 counter stopped when core is halted
33 | // DBG_TIM3_STOP TIM3 counter stopped when core is halted
34 | // DBG_TIM2_STOP TIM2 counter stopped when core is halted
35 | //
36 | DbgMCU_APB1_Fz = 0x00000000;
37 |
38 | // Debug MCU APB2 freeze register (DBGMCU_APB2_FZ)
39 | // Reserved bits must be kept at reset value
40 | // DBG_TIM11_STOP TIM11 counter stopped when core is halted
41 | // DBG_TIM10_STOP TIM10 counter stopped when core is halted
42 | // DBG_TIM9_STOP TIM9 counter stopped when core is halted
43 | // DBG_TIM8_STOP TIM8 counter stopped when core is halted
44 | // DBG_TIM1_STOP TIM1 counter stopped when core is halted
45 | //
46 | DbgMCU_APB2_Fz = 0x00000000;
47 |
48 | // <<< end of configuration section >>>
--------------------------------------------------------------------------------
/cifar10/DebugConfig/STM32F407DISCO_STM32F407VGTx.dbgconf:
--------------------------------------------------------------------------------
1 | // File: STM32F405_415_407_417_427_437_429_439.dbgconf
2 | // Version: 1.0.0
3 | // Note: refer to STM32F405/415 STM32F407/417 STM32F427/437 STM32F429/439 reference manual (RM0090)
4 | // refer to STM32F40x STM32F41x datasheets
5 | // refer to STM32F42x STM32F43x datasheets
6 |
7 | // <<< Use Configuration Wizard in Context Menu >>>
8 |
9 | // Debug MCU configuration register (DBGMCU_CR)
10 | // DBG_STANDBY Debug Standby Mode
11 | // DBG_STOP Debug Stop Mode
12 | // DBG_SLEEP Debug Sleep Mode
13 | //
14 | DbgMCU_CR = 0x00000007;
15 |
16 | // Debug MCU APB1 freeze register (DBGMCU_APB1_FZ)
17 | // Reserved bits must be kept at reset value
18 | // DBG_CAN2_STOP CAN2 stopped when core is halted
19 | // DBG_CAN1_STOP CAN2 stopped when core is halted
20 | // DBG_I2C3_SMBUS_TIMEOUT I2C3 SMBUS timeout mode stopped when core is halted
21 | // DBG_I2C2_SMBUS_TIMEOUT I2C2 SMBUS timeout mode stopped when core is halted
22 | // DBG_I2C1_SMBUS_TIMEOUT I2C1 SMBUS timeout mode stopped when core is halted
23 | // DBG_IWDG_STOP Independent watchdog stopped when core is halted
24 | // DBG_WWDG_STOP Window watchdog stopped when core is halted
25 | // DBG_RTC_STOP RTC stopped when core is halted
26 | // DBG_TIM14_STOP TIM14 counter stopped when core is halted
27 | // DBG_TIM13_STOP TIM13 counter stopped when core is halted
28 | // DBG_TIM12_STOP TIM12 counter stopped when core is halted
29 | // DBG_TIM7_STOP TIM7 counter stopped when core is halted
30 | // DBG_TIM6_STOP TIM6 counter stopped when core is halted
31 | // DBG_TIM5_STOP TIM5 counter stopped when core is halted
32 | // DBG_TIM4_STOP TIM4 counter stopped when core is halted
33 | // DBG_TIM3_STOP TIM3 counter stopped when core is halted
34 | // DBG_TIM2_STOP TIM2 counter stopped when core is halted
35 | //
36 | DbgMCU_APB1_Fz = 0x00000000;
37 |
38 | // Debug MCU APB2 freeze register (DBGMCU_APB2_FZ)
39 | // Reserved bits must be kept at reset value
40 | // DBG_TIM11_STOP TIM11 counter stopped when core is halted
41 | // DBG_TIM10_STOP TIM10 counter stopped when core is halted
42 | // DBG_TIM9_STOP TIM9 counter stopped when core is halted
43 | // DBG_TIM8_STOP TIM8 counter stopped when core is halted
44 | // DBG_TIM1_STOP TIM1 counter stopped when core is halted
45 | //
46 | DbgMCU_APB2_Fz = 0x00000000;
47 |
48 | // <<< end of configuration section >>>
--------------------------------------------------------------------------------
/cifar10/EventRecorderStub.scvd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/cifar10/RTE/Compiler/EventRecorderConf.h:
--------------------------------------------------------------------------------
1 | /*------------------------------------------------------------------------------
2 | * MDK - Component ::Event Recorder
3 | * Copyright (c) 2016 ARM Germany GmbH. All rights reserved.
4 | *------------------------------------------------------------------------------
5 | * Name: EventRecorderConf.h
6 | * Purpose: Event Recorder Configuration
7 | * Rev.: V1.0.0
8 | *----------------------------------------------------------------------------*/
9 |
10 | //-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
11 |
12 | // Event Recorder
13 |
14 | // Number of Records
15 | // <8=>8 <16=>16 <32=>32 <64=>64 <128=>128 <256=>256 <512=>512 <1024=>1024
16 | // <2048=>2048 <4096=>4096 <8192=>8192 <16384=>16384 <32768=>32768
17 | // <65536=>65536 <131072=>131072 <262144=>262144 <524288=>524288
18 | // <1048576=>1048576
19 | // Configure size of Event Record Buffer (each record is 16 bytes)
20 | // Must be 2^n (min=8, max=1048576)
21 | #define EVENT_RECORD_COUNT 64U
22 |
23 | // Time Stamp Source
24 | // <0=> DWT Cycle Counter <1=> SysTick
25 | // <3=> User Timer (Normal Reset) <4=> User Timer (Power-On Reset)
26 | // Selects source for 32-bit time stamp
27 | #define EVENT_TIMESTAMP_SOURCE 1
28 |
29 | // SysTick Configuration
30 | // Configure values when Time Stamp Source is set to SysTick
31 |
32 | // SysTick Input Clock Frequency [Hz] <1-1000000000>
33 | // Defines SysTick input clock (typical identical with processor clock)
34 | #define SYSTICK_CLOCK 100000000U
35 |
36 | // SysTick Interrupt Period [us] <1-1000000000>
37 | // Defines time period of the SysTick timer interrupt
38 | #define SYSTICK_PERIOD_US 1000U
39 |
40 | //
41 |
42 | //
43 |
44 | //------------- <<< end of configuration section >>> ---------------------------
45 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/ARMCM0/startup_ARMCM0.s:
--------------------------------------------------------------------------------
1 | ;/**************************************************************************//**
2 | ; * @file startup_ARMCM0.s
3 | ; * @brief CMSIS Core Device Startup File for
4 | ; * ARMCM0 Device Series
5 | ; * @version V5.00
6 | ; * @date 02. March 2016
7 | ; ******************************************************************************/
8 | ;/*
9 | ; * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
10 | ; *
11 | ; * SPDX-License-Identifier: Apache-2.0
12 | ; *
13 | ; * Licensed under the Apache License, Version 2.0 (the License); you may
14 | ; * not use this file except in compliance with the License.
15 | ; * You may obtain a copy of the License at
16 | ; *
17 | ; * www.apache.org/licenses/LICENSE-2.0
18 | ; *
19 | ; * Unless required by applicable law or agreed to in writing, software
20 | ; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 | ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | ; * See the License for the specific language governing permissions and
23 | ; * limitations under the License.
24 | ; */
25 |
26 | ;/*
27 | ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
28 | ;*/
29 |
30 |
31 | ; Stack Configuration
32 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
33 | ;
34 |
35 | Stack_Size EQU 0x00000400
36 |
37 | AREA STACK, NOINIT, READWRITE, ALIGN=3
38 | Stack_Mem SPACE Stack_Size
39 | __initial_sp
40 |
41 |
42 | ; Heap Configuration
43 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
44 | ;
45 |
46 | Heap_Size EQU 0x00000C00
47 |
48 | AREA HEAP, NOINIT, READWRITE, ALIGN=3
49 | __heap_base
50 | Heap_Mem SPACE Heap_Size
51 | __heap_limit
52 |
53 |
54 | PRESERVE8
55 | THUMB
56 |
57 |
58 | ; Vector Table Mapped to Address 0 at Reset
59 |
60 | AREA RESET, DATA, READONLY
61 | EXPORT __Vectors
62 | EXPORT __Vectors_End
63 | EXPORT __Vectors_Size
64 |
65 | __Vectors DCD __initial_sp ; Top of Stack
66 | DCD Reset_Handler ; Reset Handler
67 | DCD NMI_Handler ; NMI Handler
68 | DCD HardFault_Handler ; Hard Fault Handler
69 | DCD 0 ; Reserved
70 | DCD 0 ; Reserved
71 | DCD 0 ; Reserved
72 | DCD 0 ; Reserved
73 | DCD 0 ; Reserved
74 | DCD 0 ; Reserved
75 | DCD 0 ; Reserved
76 | DCD SVC_Handler ; SVCall Handler
77 | DCD 0 ; Reserved
78 | DCD 0 ; Reserved
79 | DCD PendSV_Handler ; PendSV Handler
80 | DCD SysTick_Handler ; SysTick Handler
81 |
82 | ; External Interrupts
83 | DCD WDT_IRQHandler ; 0: Watchdog Timer
84 | DCD RTC_IRQHandler ; 1: Real Time Clock
85 | DCD TIM0_IRQHandler ; 2: Timer0 / Timer1
86 | DCD TIM2_IRQHandler ; 3: Timer2 / Timer3
87 | DCD MCIA_IRQHandler ; 4: MCIa
88 | DCD MCIB_IRQHandler ; 5: MCIb
89 | DCD UART0_IRQHandler ; 6: UART0 - DUT FPGA
90 | DCD UART1_IRQHandler ; 7: UART1 - DUT FPGA
91 | DCD UART2_IRQHandler ; 8: UART2 - DUT FPGA
92 | DCD UART4_IRQHandler ; 9: UART4 - not connected
93 | DCD AACI_IRQHandler ; 10: AACI / AC97
94 | DCD CLCD_IRQHandler ; 11: CLCD Combined Interrupt
95 | DCD ENET_IRQHandler ; 12: Ethernet
96 | DCD USBDC_IRQHandler ; 13: USB Device
97 | DCD USBHC_IRQHandler ; 14: USB Host Controller
98 | DCD CHLCD_IRQHandler ; 15: Character LCD
99 | DCD FLEXRAY_IRQHandler ; 16: Flexray
100 | DCD CAN_IRQHandler ; 17: CAN
101 | DCD LIN_IRQHandler ; 18: LIN
102 | DCD I2C_IRQHandler ; 19: I2C ADC/DAC
103 | DCD 0 ; 20: Reserved
104 | DCD 0 ; 21: Reserved
105 | DCD 0 ; 22: Reserved
106 | DCD 0 ; 23: Reserved
107 | DCD 0 ; 24: Reserved
108 | DCD 0 ; 25: Reserved
109 | DCD 0 ; 26: Reserved
110 | DCD 0 ; 27: Reserved
111 | DCD CPU_CLCD_IRQHandler ; 28: Reserved - CPU FPGA CLCD
112 | DCD 0 ; 29: Reserved - CPU FPGA
113 | DCD UART3_IRQHandler ; 30: UART3 - CPU FPGA
114 | DCD SPI_IRQHandler ; 31: SPI Touchscreen - CPU FPGA
115 | __Vectors_End
116 |
117 | __Vectors_Size EQU __Vectors_End - __Vectors
118 |
119 | AREA |.text|, CODE, READONLY
120 |
121 |
122 | ; Reset Handler
123 |
124 | Reset_Handler PROC
125 | EXPORT Reset_Handler [WEAK]
126 | IMPORT SystemInit
127 | IMPORT __main
128 | LDR R0, =SystemInit
129 | BLX R0
130 | LDR R0, =__main
131 | BX R0
132 | ENDP
133 |
134 |
135 | ; Dummy Exception Handlers (infinite loops which can be modified)
136 |
137 | NMI_Handler PROC
138 | EXPORT NMI_Handler [WEAK]
139 | B .
140 | ENDP
141 | HardFault_Handler\
142 | PROC
143 | EXPORT HardFault_Handler [WEAK]
144 | B .
145 | ENDP
146 | SVC_Handler PROC
147 | EXPORT SVC_Handler [WEAK]
148 | B .
149 | ENDP
150 | PendSV_Handler PROC
151 | EXPORT PendSV_Handler [WEAK]
152 | B .
153 | ENDP
154 | SysTick_Handler PROC
155 | EXPORT SysTick_Handler [WEAK]
156 | B .
157 | ENDP
158 |
159 | Default_Handler PROC
160 |
161 | EXPORT WDT_IRQHandler [WEAK]
162 | EXPORT RTC_IRQHandler [WEAK]
163 | EXPORT TIM0_IRQHandler [WEAK]
164 | EXPORT TIM2_IRQHandler [WEAK]
165 | EXPORT MCIA_IRQHandler [WEAK]
166 | EXPORT MCIB_IRQHandler [WEAK]
167 | EXPORT UART0_IRQHandler [WEAK]
168 | EXPORT UART1_IRQHandler [WEAK]
169 | EXPORT UART2_IRQHandler [WEAK]
170 | EXPORT UART3_IRQHandler [WEAK]
171 | EXPORT UART4_IRQHandler [WEAK]
172 | EXPORT AACI_IRQHandler [WEAK]
173 | EXPORT CLCD_IRQHandler [WEAK]
174 | EXPORT ENET_IRQHandler [WEAK]
175 | EXPORT USBDC_IRQHandler [WEAK]
176 | EXPORT USBHC_IRQHandler [WEAK]
177 | EXPORT CHLCD_IRQHandler [WEAK]
178 | EXPORT FLEXRAY_IRQHandler [WEAK]
179 | EXPORT CAN_IRQHandler [WEAK]
180 | EXPORT LIN_IRQHandler [WEAK]
181 | EXPORT I2C_IRQHandler [WEAK]
182 | EXPORT CPU_CLCD_IRQHandler [WEAK]
183 | EXPORT SPI_IRQHandler [WEAK]
184 |
185 | WDT_IRQHandler
186 | RTC_IRQHandler
187 | TIM0_IRQHandler
188 | TIM2_IRQHandler
189 | MCIA_IRQHandler
190 | MCIB_IRQHandler
191 | UART0_IRQHandler
192 | UART1_IRQHandler
193 | UART2_IRQHandler
194 | UART3_IRQHandler
195 | UART4_IRQHandler
196 | AACI_IRQHandler
197 | CLCD_IRQHandler
198 | ENET_IRQHandler
199 | USBDC_IRQHandler
200 | USBHC_IRQHandler
201 | CHLCD_IRQHandler
202 | FLEXRAY_IRQHandler
203 | CAN_IRQHandler
204 | LIN_IRQHandler
205 | I2C_IRQHandler
206 | CPU_CLCD_IRQHandler
207 | SPI_IRQHandler
208 | B .
209 |
210 | ENDP
211 |
212 |
213 | ALIGN
214 |
215 |
216 | ; User Initial Stack & Heap
217 |
218 | IF :DEF:__MICROLIB
219 |
220 | EXPORT __initial_sp
221 | EXPORT __heap_base
222 | EXPORT __heap_limit
223 |
224 | ELSE
225 |
226 | IMPORT __use_two_region_memory
227 | EXPORT __user_initial_stackheap
228 |
229 | __user_initial_stackheap PROC
230 | LDR R0, = Heap_Mem
231 | LDR R1, =(Stack_Mem + Stack_Size)
232 | LDR R2, = (Heap_Mem + Heap_Size)
233 | LDR R3, = Stack_Mem
234 | BX LR
235 | ENDP
236 |
237 | ALIGN
238 |
239 | ENDIF
240 |
241 |
242 | END
243 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/ARMCM0/system_ARMCM0.c:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file system_ARMCM0.c
3 | * @brief CMSIS Device System Source File for
4 | * ARMCM0 Device Series
5 | * @version V5.00
6 | * @date 08. April 2016
7 | ******************************************************************************/
8 | /*
9 | * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
10 | *
11 | * SPDX-License-Identifier: Apache-2.0
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the License); you may
14 | * not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | */
25 |
26 | #include "ARMCM0.h"
27 |
28 | /*----------------------------------------------------------------------------
29 | Define clocks
30 | *----------------------------------------------------------------------------*/
31 | #define XTAL ( 5000000U) /* Oscillator frequency */
32 |
33 | #define SYSTEM_CLOCK (5 * XTAL)
34 |
35 |
36 | /*----------------------------------------------------------------------------
37 | System Core Clock Variable
38 | *----------------------------------------------------------------------------*/
39 | uint32_t SystemCoreClock = SYSTEM_CLOCK;
40 |
41 |
42 | /*----------------------------------------------------------------------------
43 | System Core Clock update function
44 | *----------------------------------------------------------------------------*/
45 | void SystemCoreClockUpdate (void)
46 | {
47 | SystemCoreClock = SYSTEM_CLOCK;
48 | }
49 |
50 | /*----------------------------------------------------------------------------
51 | System initialization function
52 | *----------------------------------------------------------------------------*/
53 | void SystemInit (void)
54 | {
55 | SystemCoreClock = SYSTEM_CLOCK;
56 | }
57 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/ARMCM3/startup_ARMCM3.s:
--------------------------------------------------------------------------------
1 | ;/**************************************************************************//**
2 | ; * @file startup_ARMCM3.s
3 | ; * @brief CMSIS Core Device Startup File for
4 | ; * ARMCM3 Device Series
5 | ; * @version V5.00
6 | ; * @date 02. March 2016
7 | ; ******************************************************************************/
8 | ;/*
9 | ; * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
10 | ; *
11 | ; * SPDX-License-Identifier: Apache-2.0
12 | ; *
13 | ; * Licensed under the Apache License, Version 2.0 (the License); you may
14 | ; * not use this file except in compliance with the License.
15 | ; * You may obtain a copy of the License at
16 | ; *
17 | ; * www.apache.org/licenses/LICENSE-2.0
18 | ; *
19 | ; * Unless required by applicable law or agreed to in writing, software
20 | ; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 | ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | ; * See the License for the specific language governing permissions and
23 | ; * limitations under the License.
24 | ; */
25 |
26 | ;/*
27 | ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
28 | ;*/
29 |
30 |
31 | ; Stack Configuration
32 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
33 | ;
34 |
35 | Stack_Size EQU 0x00000400
36 |
37 | AREA STACK, NOINIT, READWRITE, ALIGN=3
38 | Stack_Mem SPACE Stack_Size
39 | __initial_sp
40 |
41 |
42 | ; Heap Configuration
43 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
44 | ;
45 |
46 | Heap_Size EQU 0x00000C00
47 |
48 | AREA HEAP, NOINIT, READWRITE, ALIGN=3
49 | __heap_base
50 | Heap_Mem SPACE Heap_Size
51 | __heap_limit
52 |
53 |
54 | PRESERVE8
55 | THUMB
56 |
57 |
58 | ; Vector Table Mapped to Address 0 at Reset
59 |
60 | AREA RESET, DATA, READONLY
61 | EXPORT __Vectors
62 | EXPORT __Vectors_End
63 | EXPORT __Vectors_Size
64 |
65 | __Vectors DCD __initial_sp ; Top of Stack
66 | DCD Reset_Handler ; Reset Handler
67 | DCD NMI_Handler ; NMI Handler
68 | DCD HardFault_Handler ; Hard Fault Handler
69 | DCD MemManage_Handler ; MPU Fault Handler
70 | DCD BusFault_Handler ; Bus Fault Handler
71 | DCD UsageFault_Handler ; Usage Fault Handler
72 | DCD 0 ; Reserved
73 | DCD 0 ; Reserved
74 | DCD 0 ; Reserved
75 | DCD 0 ; Reserved
76 | DCD SVC_Handler ; SVCall Handler
77 | DCD DebugMon_Handler ; Debug Monitor Handler
78 | DCD 0 ; Reserved
79 | DCD PendSV_Handler ; PendSV Handler
80 | DCD SysTick_Handler ; SysTick Handler
81 |
82 | ; External Interrupts
83 | DCD WDT_IRQHandler ; 0: Watchdog Timer
84 | DCD RTC_IRQHandler ; 1: Real Time Clock
85 | DCD TIM0_IRQHandler ; 2: Timer0 / Timer1
86 | DCD TIM2_IRQHandler ; 3: Timer2 / Timer3
87 | DCD MCIA_IRQHandler ; 4: MCIa
88 | DCD MCIB_IRQHandler ; 5: MCIb
89 | DCD UART0_IRQHandler ; 6: UART0 - DUT FPGA
90 | DCD UART1_IRQHandler ; 7: UART1 - DUT FPGA
91 | DCD UART2_IRQHandler ; 8: UART2 - DUT FPGA
92 | DCD UART4_IRQHandler ; 9: UART4 - not connected
93 | DCD AACI_IRQHandler ; 10: AACI / AC97
94 | DCD CLCD_IRQHandler ; 11: CLCD Combined Interrupt
95 | DCD ENET_IRQHandler ; 12: Ethernet
96 | DCD USBDC_IRQHandler ; 13: USB Device
97 | DCD USBHC_IRQHandler ; 14: USB Host Controller
98 | DCD CHLCD_IRQHandler ; 15: Character LCD
99 | DCD FLEXRAY_IRQHandler ; 16: Flexray
100 | DCD CAN_IRQHandler ; 17: CAN
101 | DCD LIN_IRQHandler ; 18: LIN
102 | DCD I2C_IRQHandler ; 19: I2C ADC/DAC
103 | DCD 0 ; 20: Reserved
104 | DCD 0 ; 21: Reserved
105 | DCD 0 ; 22: Reserved
106 | DCD 0 ; 23: Reserved
107 | DCD 0 ; 24: Reserved
108 | DCD 0 ; 25: Reserved
109 | DCD 0 ; 26: Reserved
110 | DCD 0 ; 27: Reserved
111 | DCD CPU_CLCD_IRQHandler ; 28: Reserved - CPU FPGA CLCD
112 | DCD 0 ; 29: Reserved - CPU FPGA
113 | DCD UART3_IRQHandler ; 30: UART3 - CPU FPGA
114 | DCD SPI_IRQHandler ; 31: SPI Touchscreen - CPU FPGA
115 | __Vectors_End
116 |
117 | __Vectors_Size EQU __Vectors_End - __Vectors
118 |
119 | AREA |.text|, CODE, READONLY
120 |
121 |
122 | ; Reset Handler
123 |
124 | Reset_Handler PROC
125 | EXPORT Reset_Handler [WEAK]
126 | IMPORT SystemInit
127 | IMPORT __main
128 | LDR R0, =SystemInit
129 | BLX R0
130 | LDR R0, =__main
131 | BX R0
132 | ENDP
133 |
134 |
135 | ; Dummy Exception Handlers (infinite loops which can be modified)
136 |
137 | NMI_Handler PROC
138 | EXPORT NMI_Handler [WEAK]
139 | B .
140 | ENDP
141 | HardFault_Handler\
142 | PROC
143 | EXPORT HardFault_Handler [WEAK]
144 | B .
145 | ENDP
146 | MemManage_Handler\
147 | PROC
148 | EXPORT MemManage_Handler [WEAK]
149 | B .
150 | ENDP
151 | BusFault_Handler\
152 | PROC
153 | EXPORT BusFault_Handler [WEAK]
154 | B .
155 | ENDP
156 | UsageFault_Handler\
157 | PROC
158 | EXPORT UsageFault_Handler [WEAK]
159 | B .
160 | ENDP
161 | SVC_Handler PROC
162 | EXPORT SVC_Handler [WEAK]
163 | B .
164 | ENDP
165 | DebugMon_Handler\
166 | PROC
167 | EXPORT DebugMon_Handler [WEAK]
168 | B .
169 | ENDP
170 | PendSV_Handler PROC
171 | EXPORT PendSV_Handler [WEAK]
172 | B .
173 | ENDP
174 | SysTick_Handler PROC
175 | EXPORT SysTick_Handler [WEAK]
176 | B .
177 | ENDP
178 |
179 | Default_Handler PROC
180 |
181 | EXPORT WDT_IRQHandler [WEAK]
182 | EXPORT RTC_IRQHandler [WEAK]
183 | EXPORT TIM0_IRQHandler [WEAK]
184 | EXPORT TIM2_IRQHandler [WEAK]
185 | EXPORT MCIA_IRQHandler [WEAK]
186 | EXPORT MCIB_IRQHandler [WEAK]
187 | EXPORT UART0_IRQHandler [WEAK]
188 | EXPORT UART1_IRQHandler [WEAK]
189 | EXPORT UART2_IRQHandler [WEAK]
190 | EXPORT UART3_IRQHandler [WEAK]
191 | EXPORT UART4_IRQHandler [WEAK]
192 | EXPORT AACI_IRQHandler [WEAK]
193 | EXPORT CLCD_IRQHandler [WEAK]
194 | EXPORT ENET_IRQHandler [WEAK]
195 | EXPORT USBDC_IRQHandler [WEAK]
196 | EXPORT USBHC_IRQHandler [WEAK]
197 | EXPORT CHLCD_IRQHandler [WEAK]
198 | EXPORT FLEXRAY_IRQHandler [WEAK]
199 | EXPORT CAN_IRQHandler [WEAK]
200 | EXPORT LIN_IRQHandler [WEAK]
201 | EXPORT I2C_IRQHandler [WEAK]
202 | EXPORT CPU_CLCD_IRQHandler [WEAK]
203 | EXPORT SPI_IRQHandler [WEAK]
204 |
205 | WDT_IRQHandler
206 | RTC_IRQHandler
207 | TIM0_IRQHandler
208 | TIM2_IRQHandler
209 | MCIA_IRQHandler
210 | MCIB_IRQHandler
211 | UART0_IRQHandler
212 | UART1_IRQHandler
213 | UART2_IRQHandler
214 | UART3_IRQHandler
215 | UART4_IRQHandler
216 | AACI_IRQHandler
217 | CLCD_IRQHandler
218 | ENET_IRQHandler
219 | USBDC_IRQHandler
220 | USBHC_IRQHandler
221 | CHLCD_IRQHandler
222 | FLEXRAY_IRQHandler
223 | CAN_IRQHandler
224 | LIN_IRQHandler
225 | I2C_IRQHandler
226 | CPU_CLCD_IRQHandler
227 | SPI_IRQHandler
228 | B .
229 |
230 | ENDP
231 |
232 |
233 | ALIGN
234 |
235 |
236 | ; User Initial Stack & Heap
237 |
238 | IF :DEF:__MICROLIB
239 |
240 | EXPORT __initial_sp
241 | EXPORT __heap_base
242 | EXPORT __heap_limit
243 |
244 | ELSE
245 |
246 | IMPORT __use_two_region_memory
247 | EXPORT __user_initial_stackheap
248 |
249 | __user_initial_stackheap PROC
250 | LDR R0, = Heap_Mem
251 | LDR R1, =(Stack_Mem + Stack_Size)
252 | LDR R2, = (Heap_Mem + Heap_Size)
253 | LDR R3, = Stack_Mem
254 | BX LR
255 | ENDP
256 |
257 | ALIGN
258 |
259 | ENDIF
260 |
261 |
262 | END
263 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/ARMCM3/system_ARMCM3.c:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file system_ARMCM3.c
3 | * @brief CMSIS Device System Source File for
4 | * ARMCM3 Device Series
5 | * @version V5.00
6 | * @date 08. April 2016
7 | ******************************************************************************/
8 | /*
9 | * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
10 | *
11 | * SPDX-License-Identifier: Apache-2.0
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the License); you may
14 | * not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | */
25 |
26 | #include "ARMCM3.h"
27 |
28 | /*----------------------------------------------------------------------------
29 | Define clocks
30 | *----------------------------------------------------------------------------*/
31 | #define XTAL ( 5000000U) /* Oscillator frequency */
32 |
33 | #define SYSTEM_CLOCK (5 * XTAL)
34 |
35 |
36 | /*----------------------------------------------------------------------------
37 | Externals
38 | *----------------------------------------------------------------------------*/
39 | #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1)
40 | extern uint32_t __Vectors;
41 | #endif
42 |
43 | /*----------------------------------------------------------------------------
44 | System Core Clock Variable
45 | *----------------------------------------------------------------------------*/
46 | uint32_t SystemCoreClock = SYSTEM_CLOCK;
47 |
48 |
49 | /*----------------------------------------------------------------------------
50 | System Core Clock update function
51 | *----------------------------------------------------------------------------*/
52 | void SystemCoreClockUpdate (void)
53 | {
54 | SystemCoreClock = SYSTEM_CLOCK;
55 | }
56 |
57 | /*----------------------------------------------------------------------------
58 | System initialization function
59 | *----------------------------------------------------------------------------*/
60 | void SystemInit (void)
61 | {
62 |
63 | #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1)
64 | SCB->VTOR = (uint32_t) &__Vectors;
65 | #endif
66 |
67 | SystemCoreClock = SYSTEM_CLOCK;
68 | }
69 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/ARMCM4_FP/startup_ARMCM4.s:
--------------------------------------------------------------------------------
1 | ;/**************************************************************************//**
2 | ; * @file startup_ARMCM4.s
3 | ; * @brief CMSIS Core Device Startup File for
4 | ; * ARMCM4 Device Series
5 | ; * @version V5.00
6 | ; * @date 02. March 2016
7 | ; ******************************************************************************/
8 | ;/*
9 | ; * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
10 | ; *
11 | ; * SPDX-License-Identifier: Apache-2.0
12 | ; *
13 | ; * Licensed under the Apache License, Version 2.0 (the License); you may
14 | ; * not use this file except in compliance with the License.
15 | ; * You may obtain a copy of the License at
16 | ; *
17 | ; * www.apache.org/licenses/LICENSE-2.0
18 | ; *
19 | ; * Unless required by applicable law or agreed to in writing, software
20 | ; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 | ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | ; * See the License for the specific language governing permissions and
23 | ; * limitations under the License.
24 | ; */
25 |
26 | ;/*
27 | ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
28 | ;*/
29 |
30 |
31 | ; Stack Configuration
32 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
33 | ;
34 |
35 | Stack_Size EQU 0x00000800
36 |
37 | AREA STACK, NOINIT, READWRITE, ALIGN=3
38 | Stack_Mem SPACE Stack_Size
39 | __initial_sp
40 |
41 |
42 | ; Heap Configuration
43 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
44 | ;
45 |
46 | Heap_Size EQU 0x00080000
47 |
48 | AREA HEAP, NOINIT, READWRITE, ALIGN=3
49 | __heap_base
50 | Heap_Mem SPACE Heap_Size
51 | __heap_limit
52 |
53 |
54 | PRESERVE8
55 | THUMB
56 |
57 |
58 | ; Vector Table Mapped to Address 0 at Reset
59 |
60 | AREA RESET, DATA, READONLY
61 | EXPORT __Vectors
62 | EXPORT __Vectors_End
63 | EXPORT __Vectors_Size
64 |
65 | __Vectors DCD __initial_sp ; Top of Stack
66 | DCD Reset_Handler ; Reset Handler
67 | DCD NMI_Handler ; NMI Handler
68 | DCD HardFault_Handler ; Hard Fault Handler
69 | DCD MemManage_Handler ; MPU Fault Handler
70 | DCD BusFault_Handler ; Bus Fault Handler
71 | DCD UsageFault_Handler ; Usage Fault Handler
72 | DCD 0 ; Reserved
73 | DCD 0 ; Reserved
74 | DCD 0 ; Reserved
75 | DCD 0 ; Reserved
76 | DCD SVC_Handler ; SVCall Handler
77 | DCD DebugMon_Handler ; Debug Monitor Handler
78 | DCD 0 ; Reserved
79 | DCD PendSV_Handler ; PendSV Handler
80 | DCD SysTick_Handler ; SysTick Handler
81 |
82 | ; External Interrupts
83 | DCD WDT_IRQHandler ; 0: Watchdog Timer
84 | DCD RTC_IRQHandler ; 1: Real Time Clock
85 | DCD TIM0_IRQHandler ; 2: Timer0 / Timer1
86 | DCD TIM2_IRQHandler ; 3: Timer2 / Timer3
87 | DCD MCIA_IRQHandler ; 4: MCIa
88 | DCD MCIB_IRQHandler ; 5: MCIb
89 | DCD UART0_IRQHandler ; 6: UART0 - DUT FPGA
90 | DCD UART1_IRQHandler ; 7: UART1 - DUT FPGA
91 | DCD UART2_IRQHandler ; 8: UART2 - DUT FPGA
92 | DCD UART4_IRQHandler ; 9: UART4 - not connected
93 | DCD AACI_IRQHandler ; 10: AACI / AC97
94 | DCD CLCD_IRQHandler ; 11: CLCD Combined Interrupt
95 | DCD ENET_IRQHandler ; 12: Ethernet
96 | DCD USBDC_IRQHandler ; 13: USB Device
97 | DCD USBHC_IRQHandler ; 14: USB Host Controller
98 | DCD CHLCD_IRQHandler ; 15: Character LCD
99 | DCD FLEXRAY_IRQHandler ; 16: Flexray
100 | DCD CAN_IRQHandler ; 17: CAN
101 | DCD LIN_IRQHandler ; 18: LIN
102 | DCD I2C_IRQHandler ; 19: I2C ADC/DAC
103 | DCD 0 ; 20: Reserved
104 | DCD 0 ; 21: Reserved
105 | DCD 0 ; 22: Reserved
106 | DCD 0 ; 23: Reserved
107 | DCD 0 ; 24: Reserved
108 | DCD 0 ; 25: Reserved
109 | DCD 0 ; 26: Reserved
110 | DCD 0 ; 27: Reserved
111 | DCD CPU_CLCD_IRQHandler ; 28: Reserved - CPU FPGA CLCD
112 | DCD 0 ; 29: Reserved - CPU FPGA
113 | DCD UART3_IRQHandler ; 30: UART3 - CPU FPGA
114 | DCD SPI_IRQHandler ; 31: SPI Touchscreen - CPU FPGA
115 | __Vectors_End
116 |
117 | __Vectors_Size EQU __Vectors_End - __Vectors
118 |
119 | AREA |.text|, CODE, READONLY
120 |
121 |
122 | ; Reset Handler
123 |
124 | Reset_Handler PROC
125 | EXPORT Reset_Handler [WEAK]
126 | IMPORT SystemInit
127 | IMPORT __main
128 | LDR R0, =SystemInit
129 | BLX R0
130 | LDR R0, =__main
131 | BX R0
132 | ENDP
133 |
134 |
135 | ; Dummy Exception Handlers (infinite loops which can be modified)
136 |
137 | NMI_Handler PROC
138 | EXPORT NMI_Handler [WEAK]
139 | B .
140 | ENDP
141 | HardFault_Handler\
142 | PROC
143 | EXPORT HardFault_Handler [WEAK]
144 | B .
145 | ENDP
146 | MemManage_Handler\
147 | PROC
148 | EXPORT MemManage_Handler [WEAK]
149 | B .
150 | ENDP
151 | BusFault_Handler\
152 | PROC
153 | EXPORT BusFault_Handler [WEAK]
154 | B .
155 | ENDP
156 | UsageFault_Handler\
157 | PROC
158 | EXPORT UsageFault_Handler [WEAK]
159 | B .
160 | ENDP
161 | SVC_Handler PROC
162 | EXPORT SVC_Handler [WEAK]
163 | B .
164 | ENDP
165 | DebugMon_Handler\
166 | PROC
167 | EXPORT DebugMon_Handler [WEAK]
168 | B .
169 | ENDP
170 | PendSV_Handler PROC
171 | EXPORT PendSV_Handler [WEAK]
172 | B .
173 | ENDP
174 | SysTick_Handler PROC
175 | EXPORT SysTick_Handler [WEAK]
176 | B .
177 | ENDP
178 |
179 | Default_Handler PROC
180 |
181 | EXPORT WDT_IRQHandler [WEAK]
182 | EXPORT RTC_IRQHandler [WEAK]
183 | EXPORT TIM0_IRQHandler [WEAK]
184 | EXPORT TIM2_IRQHandler [WEAK]
185 | EXPORT MCIA_IRQHandler [WEAK]
186 | EXPORT MCIB_IRQHandler [WEAK]
187 | EXPORT UART0_IRQHandler [WEAK]
188 | EXPORT UART1_IRQHandler [WEAK]
189 | EXPORT UART2_IRQHandler [WEAK]
190 | EXPORT UART3_IRQHandler [WEAK]
191 | EXPORT UART4_IRQHandler [WEAK]
192 | EXPORT AACI_IRQHandler [WEAK]
193 | EXPORT CLCD_IRQHandler [WEAK]
194 | EXPORT ENET_IRQHandler [WEAK]
195 | EXPORT USBDC_IRQHandler [WEAK]
196 | EXPORT USBHC_IRQHandler [WEAK]
197 | EXPORT CHLCD_IRQHandler [WEAK]
198 | EXPORT FLEXRAY_IRQHandler [WEAK]
199 | EXPORT CAN_IRQHandler [WEAK]
200 | EXPORT LIN_IRQHandler [WEAK]
201 | EXPORT I2C_IRQHandler [WEAK]
202 | EXPORT CPU_CLCD_IRQHandler [WEAK]
203 | EXPORT SPI_IRQHandler [WEAK]
204 |
205 | WDT_IRQHandler
206 | RTC_IRQHandler
207 | TIM0_IRQHandler
208 | TIM2_IRQHandler
209 | MCIA_IRQHandler
210 | MCIB_IRQHandler
211 | UART0_IRQHandler
212 | UART1_IRQHandler
213 | UART2_IRQHandler
214 | UART3_IRQHandler
215 | UART4_IRQHandler
216 | AACI_IRQHandler
217 | CLCD_IRQHandler
218 | ENET_IRQHandler
219 | USBDC_IRQHandler
220 | USBHC_IRQHandler
221 | CHLCD_IRQHandler
222 | FLEXRAY_IRQHandler
223 | CAN_IRQHandler
224 | LIN_IRQHandler
225 | I2C_IRQHandler
226 | CPU_CLCD_IRQHandler
227 | SPI_IRQHandler
228 | B .
229 |
230 | ENDP
231 |
232 |
233 | ALIGN
234 |
235 |
236 | ; User Initial Stack & Heap
237 |
238 | IF :DEF:__MICROLIB
239 |
240 | EXPORT __initial_sp
241 | EXPORT __heap_base
242 | EXPORT __heap_limit
243 |
244 | ELSE
245 |
246 | IMPORT __use_two_region_memory
247 | EXPORT __user_initial_stackheap
248 |
249 | __user_initial_stackheap PROC
250 | LDR R0, = Heap_Mem
251 | LDR R1, =(Stack_Mem + Stack_Size)
252 | LDR R2, = (Heap_Mem + Heap_Size)
253 | LDR R3, = Stack_Mem
254 | BX LR
255 | ENDP
256 |
257 | ALIGN
258 |
259 | ENDIF
260 |
261 |
262 | END
263 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/ARMCM4_FP/system_ARMCM4.c:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file system_ARMCM4.c
3 | * @brief CMSIS Device System Source File for
4 | * ARMCM4 Device Series
5 | * @version V5.00
6 | * @date 08. April 2016
7 | ******************************************************************************/
8 | /*
9 | * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
10 | *
11 | * SPDX-License-Identifier: Apache-2.0
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the License); you may
14 | * not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | */
25 |
26 | #if defined (ARMCM4)
27 | #include "ARMCM4.h"
28 | #elif defined (ARMCM4_FP)
29 | #include "ARMCM4_FP.h"
30 | #else
31 | #error device not specified!
32 | #endif
33 |
34 | /*----------------------------------------------------------------------------
35 | Define clocks
36 | *----------------------------------------------------------------------------*/
37 | #define XTAL ( 5000000U) /* Oscillator frequency */
38 |
39 | #define SYSTEM_CLOCK (5 * XTAL)
40 |
41 |
42 | /*----------------------------------------------------------------------------
43 | Externals
44 | *----------------------------------------------------------------------------*/
45 | #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1)
46 | extern uint32_t __Vectors;
47 | #endif
48 |
49 | /*----------------------------------------------------------------------------
50 | System Core Clock Variable
51 | *----------------------------------------------------------------------------*/
52 | uint32_t SystemCoreClock = SYSTEM_CLOCK;
53 |
54 |
55 | /*----------------------------------------------------------------------------
56 | System Core Clock update function
57 | *----------------------------------------------------------------------------*/
58 | void SystemCoreClockUpdate (void)
59 | {
60 | SystemCoreClock = SYSTEM_CLOCK;
61 | }
62 |
63 | /*----------------------------------------------------------------------------
64 | System initialization function
65 | *----------------------------------------------------------------------------*/
66 | void SystemInit (void)
67 | {
68 |
69 | #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1)
70 | SCB->VTOR = (uint32_t) &__Vectors;
71 | #endif
72 |
73 | #if defined (__FPU_USED) && (__FPU_USED == 1)
74 | SCB->CPACR |= ((3U << 10*2) | /* set CP10 Full Access */
75 | (3U << 11*2) ); /* set CP11 Full Access */
76 | #endif
77 |
78 | #ifdef UNALIGNED_SUPPORT_DISABLE
79 | SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk;
80 | #endif
81 |
82 | SystemCoreClock = SYSTEM_CLOCK;
83 | }
84 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/ARMCM7_SP/gcc_arm.ld:
--------------------------------------------------------------------------------
1 | /* Linker script to configure memory regions. */
2 | MEMORY
3 | {
4 | FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K
5 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
6 | }
7 |
8 | /* Library configurations */
9 | GROUP(libgcc.a libc.a libm.a libnosys.a)
10 |
11 | /* Linker script to place sections and symbol values. Should be used together
12 | * with other linker script that defines memory regions FLASH and RAM.
13 | * It references following symbols, which must be defined in code:
14 | * Reset_Handler : Entry of reset handler
15 | *
16 | * It defines following symbols, which code can use without definition:
17 | * __exidx_start
18 | * __exidx_end
19 | * __copy_table_start__
20 | * __copy_table_end__
21 | * __zero_table_start__
22 | * __zero_table_end__
23 | * __etext
24 | * __data_start__
25 | * __preinit_array_start
26 | * __preinit_array_end
27 | * __init_array_start
28 | * __init_array_end
29 | * __fini_array_start
30 | * __fini_array_end
31 | * __data_end__
32 | * __bss_start__
33 | * __bss_end__
34 | * __end__
35 | * end
36 | * __HeapBase
37 | * __HeapLimit
38 | * __StackLimit
39 | * __StackTop
40 | * __stack
41 | * __Vectors_End
42 | * __Vectors_Size
43 | */
44 | ENTRY(Reset_Handler)
45 |
46 | SECTIONS
47 | {
48 | .text :
49 | {
50 | KEEP(*(.vectors))
51 | __Vectors_End = .;
52 | __Vectors_Size = __Vectors_End - __Vectors;
53 | __end__ = .;
54 |
55 | *(.text*)
56 |
57 | KEEP(*(.init))
58 | KEEP(*(.fini))
59 |
60 | /* .ctors */
61 | *crtbegin.o(.ctors)
62 | *crtbegin?.o(.ctors)
63 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
64 | *(SORT(.ctors.*))
65 | *(.ctors)
66 |
67 | /* .dtors */
68 | *crtbegin.o(.dtors)
69 | *crtbegin?.o(.dtors)
70 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
71 | *(SORT(.dtors.*))
72 | *(.dtors)
73 |
74 | *(.rodata*)
75 |
76 | KEEP(*(.eh_frame*))
77 | } > FLASH
78 |
79 | .ARM.extab :
80 | {
81 | *(.ARM.extab* .gnu.linkonce.armextab.*)
82 | } > FLASH
83 |
84 | __exidx_start = .;
85 | .ARM.exidx :
86 | {
87 | *(.ARM.exidx* .gnu.linkonce.armexidx.*)
88 | } > FLASH
89 | __exidx_end = .;
90 |
91 | /* To copy multiple ROM to RAM sections,
92 | * uncomment .copy.table section and,
93 | * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
94 | /*
95 | .copy.table :
96 | {
97 | . = ALIGN(4);
98 | __copy_table_start__ = .;
99 | LONG (__etext)
100 | LONG (__data_start__)
101 | LONG (__data_end__ - __data_start__)
102 | LONG (__etext2)
103 | LONG (__data2_start__)
104 | LONG (__data2_end__ - __data2_start__)
105 | __copy_table_end__ = .;
106 | } > FLASH
107 | */
108 |
109 | /* To clear multiple BSS sections,
110 | * uncomment .zero.table section and,
111 | * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
112 | /*
113 | .zero.table :
114 | {
115 | . = ALIGN(4);
116 | __zero_table_start__ = .;
117 | LONG (__bss_start__)
118 | LONG (__bss_end__ - __bss_start__)
119 | LONG (__bss2_start__)
120 | LONG (__bss2_end__ - __bss2_start__)
121 | __zero_table_end__ = .;
122 | } > FLASH
123 | */
124 |
125 | __etext = .;
126 |
127 | .data : AT (__etext)
128 | {
129 | __data_start__ = .;
130 | *(vtable)
131 | *(.data*)
132 |
133 | . = ALIGN(4);
134 | /* preinit data */
135 | PROVIDE_HIDDEN (__preinit_array_start = .);
136 | KEEP(*(.preinit_array))
137 | PROVIDE_HIDDEN (__preinit_array_end = .);
138 |
139 | . = ALIGN(4);
140 | /* init data */
141 | PROVIDE_HIDDEN (__init_array_start = .);
142 | KEEP(*(SORT(.init_array.*)))
143 | KEEP(*(.init_array))
144 | PROVIDE_HIDDEN (__init_array_end = .);
145 |
146 |
147 | . = ALIGN(4);
148 | /* finit data */
149 | PROVIDE_HIDDEN (__fini_array_start = .);
150 | KEEP(*(SORT(.fini_array.*)))
151 | KEEP(*(.fini_array))
152 | PROVIDE_HIDDEN (__fini_array_end = .);
153 |
154 | KEEP(*(.jcr*))
155 | . = ALIGN(4);
156 | /* All data end */
157 | __data_end__ = .;
158 |
159 | } > RAM
160 |
161 | .bss :
162 | {
163 | . = ALIGN(4);
164 | __bss_start__ = .;
165 | *(.bss*)
166 | *(COMMON)
167 | . = ALIGN(4);
168 | __bss_end__ = .;
169 | } > RAM
170 |
171 | .heap (COPY):
172 | {
173 | __HeapBase = .;
174 | __end__ = .;
175 | end = __end__;
176 | KEEP(*(.heap*))
177 | __HeapLimit = .;
178 | } > RAM
179 |
180 | /* .stack_dummy section doesn't contains any symbols. It is only
181 | * used for linker to calculate size of stack sections, and assign
182 | * values to stack symbols later */
183 | .stack_dummy (COPY):
184 | {
185 | KEEP(*(.stack*))
186 | } > RAM
187 |
188 | /* Set stack top to end of RAM, and stack limit move down by
189 | * size of stack_dummy section */
190 | __StackTop = ORIGIN(RAM) + LENGTH(RAM);
191 | __StackLimit = __StackTop - SIZEOF(.stack_dummy);
192 | PROVIDE(__stack = __StackTop);
193 |
194 | /* Check if data + heap + stack exceeds RAM limit */
195 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
196 | }
197 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/ARMCM7_SP/startup_ARMCM7.c:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file startup_ARMCM7.s
3 | * @brief CMSIS Core Device Startup File for
4 | * ARMCM7 Device Series
5 | * @version V5.00
6 | * @date 26. April 2016
7 | ******************************************************************************/
8 | /*
9 | * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
10 | *
11 | * SPDX-License-Identifier: Apache-2.0
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the License); you may
14 | * not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | */
25 |
26 | #include
27 |
28 |
29 | /*----------------------------------------------------------------------------
30 | Linker generated Symbols
31 | *----------------------------------------------------------------------------*/
32 | extern uint32_t __etext;
33 | extern uint32_t __data_start__;
34 | extern uint32_t __data_end__;
35 | extern uint32_t __copy_table_start__;
36 | extern uint32_t __copy_table_end__;
37 | extern uint32_t __zero_table_start__;
38 | extern uint32_t __zero_table_end__;
39 | extern uint32_t __bss_start__;
40 | extern uint32_t __bss_end__;
41 | extern uint32_t __StackTop;
42 |
43 | /*----------------------------------------------------------------------------
44 | Exception / Interrupt Handler Function Prototype
45 | *----------------------------------------------------------------------------*/
46 | typedef void( *pFunc )( void );
47 |
48 |
49 | /*----------------------------------------------------------------------------
50 | External References
51 | *----------------------------------------------------------------------------*/
52 | #ifndef __START
53 | extern void _start(void) __attribute__((noreturn)); /* PreeMain (C library entry point) */
54 | #else
55 | extern int __START(void) __attribute__((noreturn)); /* main entry point */
56 | #endif
57 |
58 | #ifndef __NO_SYSTEM_INIT
59 | extern void SystemInit (void); /* CMSIS System Initialization */
60 | #endif
61 |
62 |
63 | /*----------------------------------------------------------------------------
64 | Internal References
65 | *----------------------------------------------------------------------------*/
66 | void Default_Handler(void); /* Default empty handler */
67 | void Reset_Handler(void); /* Reset Handler */
68 |
69 |
70 | /*----------------------------------------------------------------------------
71 | User Initial Stack & Heap
72 | *----------------------------------------------------------------------------*/
73 | #ifndef __STACK_SIZE
74 | #define __STACK_SIZE 0x00000400
75 | #endif
76 | static uint8_t stack[__STACK_SIZE] __attribute__ ((aligned(8), used, section(".stack")));
77 |
78 | #ifndef __HEAP_SIZE
79 | #define __HEAP_SIZE 0x00000C00
80 | #endif
81 | #if __HEAP_SIZE > 0
82 | static uint8_t heap[__HEAP_SIZE] __attribute__ ((aligned(8), used, section(".heap")));
83 | #endif
84 |
85 |
86 | /*----------------------------------------------------------------------------
87 | Exception / Interrupt Handler
88 | *----------------------------------------------------------------------------*/
89 | /* Cortex-M7 Processor Exceptions */
90 | void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
91 | void HardFault_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
92 | void MemManage_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
93 | void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
94 | void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
95 | void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
96 | void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
97 | void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
98 | void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
99 |
100 | /* ARMCM7 Specific Interrupts */
101 | void WDT_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
102 | void RTC_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
103 | void TIM0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
104 | void TIM2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
105 | void MCIA_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
106 | void MCIB_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
107 | void UART0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
108 | void UART1_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
109 | void UART2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
110 | void UART4_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
111 | void AACI_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
112 | void CLCD_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
113 | void ENET_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
114 | void USBDC_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
115 | void USBHC_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
116 | void CHLCD_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
117 | void FLEXRAY_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
118 | void CAN_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
119 | void LIN_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
120 | void I2C_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
121 | void CPU_CLCD_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
122 | void UART3_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
123 | void SPI_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
124 |
125 |
126 | /*----------------------------------------------------------------------------
127 | Exception / Interrupt Vector table
128 | *----------------------------------------------------------------------------*/
129 | const pFunc __Vectors[] __attribute__ ((section(".vectors"))) = {
130 | /* Cortex-M7 Exceptions Handler */
131 | (pFunc)((uint32_t)&__StackTop), /* Initial Stack Pointer */
132 | Reset_Handler, /* Reset Handler */
133 | NMI_Handler, /* NMI Handler */
134 | HardFault_Handler, /* Hard Fault Handler */
135 | MemManage_Handler, /* MPU Fault Handler */
136 | BusFault_Handler, /* Bus Fault Handler */
137 | UsageFault_Handler, /* Usage Fault Handler */
138 | 0, /* Reserved */
139 | 0, /* Reserved */
140 | 0, /* Reserved */
141 | 0, /* Reserved */
142 | SVC_Handler, /* SVCall Handler */
143 | DebugMon_Handler, /* Debug Monitor Handler */
144 | 0, /* Reserved */
145 | PendSV_Handler, /* PendSV Handler */
146 | SysTick_Handler, /* SysTick Handler */
147 |
148 | /* External interrupts */
149 | WDT_IRQHandler, /* 0: Watchdog Timer */
150 | RTC_IRQHandler, /* 1: Real Time Clock */
151 | TIM0_IRQHandler, /* 2: Timer0 / Timer1 */
152 | TIM2_IRQHandler, /* 3: Timer2 / Timer3 */
153 | MCIA_IRQHandler, /* 4: MCIa */
154 | MCIB_IRQHandler, /* 5: MCIb */
155 | UART0_IRQHandler, /* 6: UART0 - DUT FPGA */
156 | UART1_IRQHandler, /* 7: UART1 - DUT FPGA */
157 | UART2_IRQHandler, /* 8: UART2 - DUT FPGA */
158 | UART4_IRQHandler, /* 9: UART4 - not connected */
159 | AACI_IRQHandler, /* 10: AACI / AC97 */
160 | CLCD_IRQHandler, /* 11: CLCD Combined Interrupt */
161 | ENET_IRQHandler, /* 12: Ethernet */
162 | USBDC_IRQHandler, /* 13: USB Device */
163 | USBHC_IRQHandler, /* 14: USB Host Controller */
164 | CHLCD_IRQHandler, /* 15: Character LCD */
165 | FLEXRAY_IRQHandler, /* 16: Flexray */
166 | CAN_IRQHandler, /* 17: CAN */
167 | LIN_IRQHandler, /* 18: LIN */
168 | I2C_IRQHandler, /* 19: I2C ADC/DAC */
169 | 0, /* 20: Reserved */
170 | 0, /* 21: Reserved */
171 | 0, /* 22: Reserved */
172 | 0, /* 23: Reserved */
173 | 0, /* 24: Reserved */
174 | 0, /* 25: Reserved */
175 | 0, /* 26: Reserved */
176 | 0, /* 27: Reserved */
177 | CPU_CLCD_IRQHandler, /* 28: Reserved - CPU FPGA CLCD */
178 | 0, /* 29: Reserved - CPU FPGA */
179 | UART3_IRQHandler, /* 30: UART3 - CPU FPGA */
180 | SPI_IRQHandler /* 31: SPI Touchscreen - CPU FPGA */
181 | };
182 |
183 |
184 | /*----------------------------------------------------------------------------
185 | Reset Handler called on controller reset
186 | *----------------------------------------------------------------------------*/
187 | void Reset_Handler(void) {
188 | uint32_t *pSrc, *pDest;
189 | uint32_t *pTable __attribute__((unused));
190 |
191 | /* Firstly it copies data from read only memory to RAM. There are two schemes
192 | * to copy. One can copy more than one sections. Another can only copy
193 | * one section. The former scheme needs more instructions and read-only
194 | * data to implement than the latter.
195 | * Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */
196 |
197 | #ifdef __STARTUP_COPY_MULTIPLE
198 | /* Multiple sections scheme.
199 | *
200 | * Between symbol address __copy_table_start__ and __copy_table_end__,
201 | * there are array of triplets, each of which specify:
202 | * offset 0: LMA of start of a section to copy from
203 | * offset 4: VMA of start of a section to copy to
204 | * offset 8: size of the section to copy. Must be multiply of 4
205 | *
206 | * All addresses must be aligned to 4 bytes boundary.
207 | */
208 | pTable = &__copy_table_start__;
209 |
210 | for (; pTable < &__copy_table_end__; pTable = pTable + 3) {
211 | pSrc = (uint32_t*)*(pTable + 0);
212 | pDest = (uint32_t*)*(pTable + 1);
213 | for (; pDest < (uint32_t*)(*(pTable + 1) + *(pTable + 2)) ; ) {
214 | *pDest++ = *pSrc++;
215 | }
216 | }
217 | #else
218 | /* Single section scheme.
219 | *
220 | * The ranges of copy from/to are specified by following symbols
221 | * __etext: LMA of start of the section to copy from. Usually end of text
222 | * __data_start__: VMA of start of the section to copy to
223 | * __data_end__: VMA of end of the section to copy to
224 | *
225 | * All addresses must be aligned to 4 bytes boundary.
226 | */
227 | pSrc = &__etext;
228 | pDest = &__data_start__;
229 |
230 | for ( ; pDest < &__data_end__ ; ) {
231 | *pDest++ = *pSrc++;
232 | }
233 | #endif /*__STARTUP_COPY_MULTIPLE */
234 |
235 | /* This part of work usually is done in C library startup code. Otherwise,
236 | * define this macro to enable it in this startup.
237 | *
238 | * There are two schemes too. One can clear multiple BSS sections. Another
239 | * can only clear one section. The former is more size expensive than the
240 | * latter.
241 | *
242 | * Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former.
243 | * Otherwise efine macro __STARTUP_CLEAR_BSS to choose the later.
244 | */
245 | #ifdef __STARTUP_CLEAR_BSS_MULTIPLE
246 | /* Multiple sections scheme.
247 | *
248 | * Between symbol address __copy_table_start__ and __copy_table_end__,
249 | * there are array of tuples specifying:
250 | * offset 0: Start of a BSS section
251 | * offset 4: Size of this BSS section. Must be multiply of 4
252 | */
253 | pTable = &__zero_table_start__;
254 |
255 | for (; pTable < &__zero_table_end__; pTable = pTable + 2) {
256 | pDest = (uint32_t*)*(pTable + 0);
257 | for (; pDest < (uint32_t*)(*(pTable + 0) + *(pTable + 1)) ; ) {
258 | *pDest++ = 0;
259 | }
260 | }
261 | #elif defined (__STARTUP_CLEAR_BSS)
262 | /* Single BSS section scheme.
263 | *
264 | * The BSS section is specified by following symbols
265 | * __bss_start__: start of the BSS section.
266 | * __bss_end__: end of the BSS section.
267 | *
268 | * Both addresses must be aligned to 4 bytes boundary.
269 | */
270 | pDest = &__bss_start__;
271 |
272 | for ( ; pDest < &__bss_end__ ; ) {
273 | *pDest++ = 0UL;
274 | }
275 | #endif /* __STARTUP_CLEAR_BSS_MULTIPLE || __STARTUP_CLEAR_BSS */
276 |
277 | #ifndef __NO_SYSTEM_INIT
278 | SystemInit();
279 | #endif
280 |
281 | #ifndef __START
282 | #define __START _start
283 | #endif
284 | __START();
285 |
286 | }
287 |
288 |
289 | /*----------------------------------------------------------------------------
290 | Default Handler for Exceptions / Interrupts
291 | *----------------------------------------------------------------------------*/
292 | void Default_Handler(void) {
293 |
294 | while(1);
295 | }
296 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/ARMCM7_SP/startup_ARMCM7.s:
--------------------------------------------------------------------------------
1 | ;/**************************************************************************//**
2 | ; * @file startup_ARMCM7.s
3 | ; * @brief CMSIS Core Device Startup File for
4 | ; * ARMCM7 Device Series
5 | ; * @version V5.00
6 | ; * @date 02. March 2016
7 | ; ******************************************************************************/
8 | ;/*
9 | ; * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
10 | ; *
11 | ; * SPDX-License-Identifier: Apache-2.0
12 | ; *
13 | ; * Licensed under the Apache License, Version 2.0 (the License); you may
14 | ; * not use this file except in compliance with the License.
15 | ; * You may obtain a copy of the License at
16 | ; *
17 | ; * www.apache.org/licenses/LICENSE-2.0
18 | ; *
19 | ; * Unless required by applicable law or agreed to in writing, software
20 | ; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 | ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | ; * See the License for the specific language governing permissions and
23 | ; * limitations under the License.
24 | ; */
25 |
26 | ;/*
27 | ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
28 | ;*/
29 |
30 |
31 | ; Stack Configuration
32 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
33 | ;
34 |
35 | Stack_Size EQU 0x00000400
36 |
37 | AREA STACK, NOINIT, READWRITE, ALIGN=3
38 | Stack_Mem SPACE Stack_Size
39 | __initial_sp
40 |
41 |
42 | ; Heap Configuration
43 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
44 | ;
45 |
46 | Heap_Size EQU 0x00000C00
47 |
48 | AREA HEAP, NOINIT, READWRITE, ALIGN=3
49 | __heap_base
50 | Heap_Mem SPACE Heap_Size
51 | __heap_limit
52 |
53 |
54 | PRESERVE8
55 | THUMB
56 |
57 |
58 | ; Vector Table Mapped to Address 0 at Reset
59 |
60 | AREA RESET, DATA, READONLY
61 | EXPORT __Vectors
62 | EXPORT __Vectors_End
63 | EXPORT __Vectors_Size
64 |
65 | __Vectors DCD __initial_sp ; Top of Stack
66 | DCD Reset_Handler ; Reset Handler
67 | DCD NMI_Handler ; NMI Handler
68 | DCD HardFault_Handler ; Hard Fault Handler
69 | DCD MemManage_Handler ; MPU Fault Handler
70 | DCD BusFault_Handler ; Bus Fault Handler
71 | DCD UsageFault_Handler ; Usage Fault Handler
72 | DCD 0 ; Reserved
73 | DCD 0 ; Reserved
74 | DCD 0 ; Reserved
75 | DCD 0 ; Reserved
76 | DCD SVC_Handler ; SVCall Handler
77 | DCD DebugMon_Handler ; Debug Monitor Handler
78 | DCD 0 ; Reserved
79 | DCD PendSV_Handler ; PendSV Handler
80 | DCD SysTick_Handler ; SysTick Handler
81 |
82 | ; External Interrupts
83 | DCD WDT_IRQHandler ; 0: Watchdog Timer
84 | DCD RTC_IRQHandler ; 1: Real Time Clock
85 | DCD TIM0_IRQHandler ; 2: Timer0 / Timer1
86 | DCD TIM2_IRQHandler ; 3: Timer2 / Timer3
87 | DCD MCIA_IRQHandler ; 4: MCIa
88 | DCD MCIB_IRQHandler ; 5: MCIb
89 | DCD UART0_IRQHandler ; 6: UART0 - DUT FPGA
90 | DCD UART1_IRQHandler ; 7: UART1 - DUT FPGA
91 | DCD UART2_IRQHandler ; 8: UART2 - DUT FPGA
92 | DCD UART4_IRQHandler ; 9: UART4 - not connected
93 | DCD AACI_IRQHandler ; 10: AACI / AC97
94 | DCD CLCD_IRQHandler ; 11: CLCD Combined Interrupt
95 | DCD ENET_IRQHandler ; 12: Ethernet
96 | DCD USBDC_IRQHandler ; 13: USB Device
97 | DCD USBHC_IRQHandler ; 14: USB Host Controller
98 | DCD CHLCD_IRQHandler ; 15: Character LCD
99 | DCD FLEXRAY_IRQHandler ; 16: Flexray
100 | DCD CAN_IRQHandler ; 17: CAN
101 | DCD LIN_IRQHandler ; 18: LIN
102 | DCD I2C_IRQHandler ; 19: I2C ADC/DAC
103 | DCD 0 ; 20: Reserved
104 | DCD 0 ; 21: Reserved
105 | DCD 0 ; 22: Reserved
106 | DCD 0 ; 23: Reserved
107 | DCD 0 ; 24: Reserved
108 | DCD 0 ; 25: Reserved
109 | DCD 0 ; 26: Reserved
110 | DCD 0 ; 27: Reserved
111 | DCD CPU_CLCD_IRQHandler ; 28: Reserved - CPU FPGA CLCD
112 | DCD 0 ; 29: Reserved - CPU FPGA
113 | DCD UART3_IRQHandler ; 30: UART3 - CPU FPGA
114 | DCD SPI_IRQHandler ; 31: SPI Touchscreen - CPU FPGA
115 | __Vectors_End
116 |
117 | __Vectors_Size EQU __Vectors_End - __Vectors
118 |
119 | AREA |.text|, CODE, READONLY
120 |
121 |
122 | ; Reset Handler
123 |
124 | Reset_Handler PROC
125 | EXPORT Reset_Handler [WEAK]
126 | IMPORT SystemInit
127 | IMPORT __main
128 | LDR R0, =SystemInit
129 | BLX R0
130 | LDR R0, =__main
131 | BX R0
132 | ENDP
133 |
134 |
135 | ; Dummy Exception Handlers (infinite loops which can be modified)
136 |
137 | NMI_Handler PROC
138 | EXPORT NMI_Handler [WEAK]
139 | B .
140 | ENDP
141 | HardFault_Handler\
142 | PROC
143 | EXPORT HardFault_Handler [WEAK]
144 | B .
145 | ENDP
146 | MemManage_Handler\
147 | PROC
148 | EXPORT MemManage_Handler [WEAK]
149 | B .
150 | ENDP
151 | BusFault_Handler\
152 | PROC
153 | EXPORT BusFault_Handler [WEAK]
154 | B .
155 | ENDP
156 | UsageFault_Handler\
157 | PROC
158 | EXPORT UsageFault_Handler [WEAK]
159 | B .
160 | ENDP
161 | SVC_Handler PROC
162 | EXPORT SVC_Handler [WEAK]
163 | B .
164 | ENDP
165 | DebugMon_Handler\
166 | PROC
167 | EXPORT DebugMon_Handler [WEAK]
168 | B .
169 | ENDP
170 | PendSV_Handler PROC
171 | EXPORT PendSV_Handler [WEAK]
172 | B .
173 | ENDP
174 | SysTick_Handler PROC
175 | EXPORT SysTick_Handler [WEAK]
176 | B .
177 | ENDP
178 |
179 | Default_Handler PROC
180 |
181 | EXPORT WDT_IRQHandler [WEAK]
182 | EXPORT RTC_IRQHandler [WEAK]
183 | EXPORT TIM0_IRQHandler [WEAK]
184 | EXPORT TIM2_IRQHandler [WEAK]
185 | EXPORT MCIA_IRQHandler [WEAK]
186 | EXPORT MCIB_IRQHandler [WEAK]
187 | EXPORT UART0_IRQHandler [WEAK]
188 | EXPORT UART1_IRQHandler [WEAK]
189 | EXPORT UART2_IRQHandler [WEAK]
190 | EXPORT UART3_IRQHandler [WEAK]
191 | EXPORT UART4_IRQHandler [WEAK]
192 | EXPORT AACI_IRQHandler [WEAK]
193 | EXPORT CLCD_IRQHandler [WEAK]
194 | EXPORT ENET_IRQHandler [WEAK]
195 | EXPORT USBDC_IRQHandler [WEAK]
196 | EXPORT USBHC_IRQHandler [WEAK]
197 | EXPORT CHLCD_IRQHandler [WEAK]
198 | EXPORT FLEXRAY_IRQHandler [WEAK]
199 | EXPORT CAN_IRQHandler [WEAK]
200 | EXPORT LIN_IRQHandler [WEAK]
201 | EXPORT I2C_IRQHandler [WEAK]
202 | EXPORT CPU_CLCD_IRQHandler [WEAK]
203 | EXPORT SPI_IRQHandler [WEAK]
204 |
205 | WDT_IRQHandler
206 | RTC_IRQHandler
207 | TIM0_IRQHandler
208 | TIM2_IRQHandler
209 | MCIA_IRQHandler
210 | MCIB_IRQHandler
211 | UART0_IRQHandler
212 | UART1_IRQHandler
213 | UART2_IRQHandler
214 | UART3_IRQHandler
215 | UART4_IRQHandler
216 | AACI_IRQHandler
217 | CLCD_IRQHandler
218 | ENET_IRQHandler
219 | USBDC_IRQHandler
220 | USBHC_IRQHandler
221 | CHLCD_IRQHandler
222 | FLEXRAY_IRQHandler
223 | CAN_IRQHandler
224 | LIN_IRQHandler
225 | I2C_IRQHandler
226 | CPU_CLCD_IRQHandler
227 | SPI_IRQHandler
228 | B .
229 |
230 | ENDP
231 |
232 |
233 | ALIGN
234 |
235 |
236 | ; User Initial Stack & Heap
237 |
238 | IF :DEF:__MICROLIB
239 |
240 | EXPORT __initial_sp
241 | EXPORT __heap_base
242 | EXPORT __heap_limit
243 |
244 | ELSE
245 |
246 | IMPORT __use_two_region_memory
247 | EXPORT __user_initial_stackheap
248 |
249 | __user_initial_stackheap PROC
250 | LDR R0, = Heap_Mem
251 | LDR R1, =(Stack_Mem + Stack_Size)
252 | LDR R2, = (Heap_Mem + Heap_Size)
253 | LDR R3, = Stack_Mem
254 | BX LR
255 | ENDP
256 |
257 | ALIGN
258 |
259 | ENDIF
260 |
261 |
262 | END
263 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/ARMCM7_SP/system_ARMCM7.c:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file system_ARMCM7.c
3 | * @brief CMSIS Device System Source File for
4 | * ARMCM7 Device Series
5 | * @version V5.00
6 | * @date 08. April 2016
7 | ******************************************************************************/
8 | /*
9 | * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
10 | *
11 | * SPDX-License-Identifier: Apache-2.0
12 | *
13 | * Licensed under the Apache License, Version 2.0 (the License); you may
14 | * not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | */
25 |
26 | #if defined (ARMCM7)
27 | #include "ARMCM7.h"
28 | #elif defined (ARMCM7_SP)
29 | #include "ARMCM7_SP.h"
30 | #elif defined (ARMCM7_DP)
31 | #include "ARMCM7_DP.h"
32 | #else
33 | #error device not specified!
34 | #endif
35 |
36 | /*----------------------------------------------------------------------------
37 | Define clocks
38 | *----------------------------------------------------------------------------*/
39 | #define XTAL ( 5000000U) /* Oscillator frequency */
40 |
41 | #define SYSTEM_CLOCK (5 * XTAL)
42 |
43 |
44 | /*----------------------------------------------------------------------------
45 | Externals
46 | *----------------------------------------------------------------------------*/
47 | #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1)
48 | extern uint32_t __Vectors;
49 | #endif
50 |
51 | /*----------------------------------------------------------------------------
52 | System Core Clock Variable
53 | *----------------------------------------------------------------------------*/
54 | uint32_t SystemCoreClock = SYSTEM_CLOCK;
55 |
56 |
57 | /*----------------------------------------------------------------------------
58 | System Core Clock update function
59 | *----------------------------------------------------------------------------*/
60 | void SystemCoreClockUpdate (void)
61 | {
62 | SystemCoreClock = SYSTEM_CLOCK;
63 | }
64 |
65 | /*----------------------------------------------------------------------------
66 | System initialization function
67 | *----------------------------------------------------------------------------*/
68 | void SystemInit (void)
69 | {
70 |
71 | #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1)
72 | SCB->VTOR = (uint32_t) &__Vectors;
73 | #endif
74 |
75 | #if defined (__FPU_USED) && (__FPU_USED == 1)
76 | SCB->CPACR |= ((3U << 10*2) | /* set CP10 Full Access */
77 | (3U << 11*2) ); /* set CP11 Full Access */
78 | #endif
79 |
80 | #ifdef UNALIGNED_SUPPORT_DISABLE
81 | SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk;
82 | #endif
83 |
84 | SystemCoreClock = SYSTEM_CLOCK;
85 | }
86 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/STM32F407VGTx/startup_stm32f407xx.s:
--------------------------------------------------------------------------------
1 | ;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
2 | ;* File Name : startup_stm32f407xx.s
3 | ;* Author : MCD Application Team
4 | ;* Description : STM32F407xx devices vector table for MDK-ARM toolchain.
5 | ;* This module performs:
6 | ;* - Set the initial SP
7 | ;* - Set the initial PC == Reset_Handler
8 | ;* - Set the vector table entries with the exceptions ISR address
9 | ;* - Branches to __main in the C library (which eventually
10 | ;* calls main()).
11 | ;* After Reset the CortexM4 processor is in Thread mode,
12 | ;* priority is Privileged, and the Stack is set to Main.
13 | ;* <<< Use Configuration Wizard in Context Menu >>>
14 | ;*******************************************************************************
15 | ;
16 | ;* Redistribution and use in source and binary forms, with or without modification,
17 | ;* are permitted provided that the following conditions are met:
18 | ;* 1. Redistributions of source code must retain the above copyright notice,
19 | ;* this list of conditions and the following disclaimer.
20 | ;* 2. Redistributions in binary form must reproduce the above copyright notice,
21 | ;* this list of conditions and the following disclaimer in the documentation
22 | ;* and/or other materials provided with the distribution.
23 | ;* 3. Neither the name of STMicroelectronics nor the names of its contributors
24 | ;* may be used to endorse or promote products derived from this software
25 | ;* without specific prior written permission.
26 | ;*
27 | ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 | ;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 | ;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30 | ;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31 | ;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 | ;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33 | ;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 | ;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35 | ;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 | ;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 | ;
38 | ;*******************************************************************************
39 |
40 | ; Amount of memory (in bytes) allocated for Stack
41 | ; Tailor this value to your application needs
42 | ; Stack Configuration
43 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
44 | ;
45 |
46 | Stack_Size EQU 0x00000400
47 |
48 | AREA STACK, NOINIT, READWRITE, ALIGN=3
49 | Stack_Mem SPACE Stack_Size
50 | __initial_sp
51 |
52 |
53 | ; Heap Configuration
54 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
55 | ;
56 |
57 | Heap_Size EQU 0x00000200
58 |
59 | AREA HEAP, NOINIT, READWRITE, ALIGN=3
60 | __heap_base
61 | Heap_Mem SPACE Heap_Size
62 | __heap_limit
63 |
64 | PRESERVE8
65 | THUMB
66 |
67 |
68 | ; Vector Table Mapped to Address 0 at Reset
69 | AREA RESET, DATA, READONLY
70 | EXPORT __Vectors
71 | EXPORT __Vectors_End
72 | EXPORT __Vectors_Size
73 |
74 | __Vectors DCD __initial_sp ; Top of Stack
75 | DCD Reset_Handler ; Reset Handler
76 | DCD NMI_Handler ; NMI Handler
77 | DCD HardFault_Handler ; Hard Fault Handler
78 | DCD MemManage_Handler ; MPU Fault Handler
79 | DCD BusFault_Handler ; Bus Fault Handler
80 | DCD UsageFault_Handler ; Usage Fault Handler
81 | DCD 0 ; Reserved
82 | DCD 0 ; Reserved
83 | DCD 0 ; Reserved
84 | DCD 0 ; Reserved
85 | DCD SVC_Handler ; SVCall Handler
86 | DCD DebugMon_Handler ; Debug Monitor Handler
87 | DCD 0 ; Reserved
88 | DCD PendSV_Handler ; PendSV Handler
89 | DCD SysTick_Handler ; SysTick Handler
90 |
91 | ; External Interrupts
92 | DCD WWDG_IRQHandler ; Window WatchDog
93 | DCD PVD_IRQHandler ; PVD through EXTI Line detection
94 | DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
95 | DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
96 | DCD FLASH_IRQHandler ; FLASH
97 | DCD RCC_IRQHandler ; RCC
98 | DCD EXTI0_IRQHandler ; EXTI Line0
99 | DCD EXTI1_IRQHandler ; EXTI Line1
100 | DCD EXTI2_IRQHandler ; EXTI Line2
101 | DCD EXTI3_IRQHandler ; EXTI Line3
102 | DCD EXTI4_IRQHandler ; EXTI Line4
103 | DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
104 | DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
105 | DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
106 | DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
107 | DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
108 | DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
109 | DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
110 | DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
111 | DCD CAN1_TX_IRQHandler ; CAN1 TX
112 | DCD CAN1_RX0_IRQHandler ; CAN1 RX0
113 | DCD CAN1_RX1_IRQHandler ; CAN1 RX1
114 | DCD CAN1_SCE_IRQHandler ; CAN1 SCE
115 | DCD EXTI9_5_IRQHandler ; External Line[9:5]s
116 | DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
117 | DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
118 | DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
119 | DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
120 | DCD TIM2_IRQHandler ; TIM2
121 | DCD TIM3_IRQHandler ; TIM3
122 | DCD TIM4_IRQHandler ; TIM4
123 | DCD I2C1_EV_IRQHandler ; I2C1 Event
124 | DCD I2C1_ER_IRQHandler ; I2C1 Error
125 | DCD I2C2_EV_IRQHandler ; I2C2 Event
126 | DCD I2C2_ER_IRQHandler ; I2C2 Error
127 | DCD SPI1_IRQHandler ; SPI1
128 | DCD SPI2_IRQHandler ; SPI2
129 | DCD USART1_IRQHandler ; USART1
130 | DCD USART2_IRQHandler ; USART2
131 | DCD USART3_IRQHandler ; USART3
132 | DCD EXTI15_10_IRQHandler ; External Line[15:10]s
133 | DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
134 | DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
135 | DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
136 | DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
137 | DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
138 | DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
139 | DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
140 | DCD FMC_IRQHandler ; FMC
141 | DCD SDIO_IRQHandler ; SDIO
142 | DCD TIM5_IRQHandler ; TIM5
143 | DCD SPI3_IRQHandler ; SPI3
144 | DCD UART4_IRQHandler ; UART4
145 | DCD UART5_IRQHandler ; UART5
146 | DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
147 | DCD TIM7_IRQHandler ; TIM7
148 | DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
149 | DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
150 | DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
151 | DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
152 | DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
153 | DCD ETH_IRQHandler ; Ethernet
154 | DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
155 | DCD CAN2_TX_IRQHandler ; CAN2 TX
156 | DCD CAN2_RX0_IRQHandler ; CAN2 RX0
157 | DCD CAN2_RX1_IRQHandler ; CAN2 RX1
158 | DCD CAN2_SCE_IRQHandler ; CAN2 SCE
159 | DCD OTG_FS_IRQHandler ; USB OTG FS
160 | DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
161 | DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
162 | DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
163 | DCD USART6_IRQHandler ; USART6
164 | DCD I2C3_EV_IRQHandler ; I2C3 event
165 | DCD I2C3_ER_IRQHandler ; I2C3 error
166 | DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
167 | DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
168 | DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
169 | DCD OTG_HS_IRQHandler ; USB OTG HS
170 | DCD DCMI_IRQHandler ; DCMI
171 | DCD 0 ; Reserved
172 | DCD HASH_RNG_IRQHandler ; Hash and Rng
173 | DCD FPU_IRQHandler ; FPU
174 |
175 |
176 | __Vectors_End
177 |
178 | __Vectors_Size EQU __Vectors_End - __Vectors
179 |
180 | AREA |.text|, CODE, READONLY
181 |
182 | ; Reset handler
183 | Reset_Handler PROC
184 | EXPORT Reset_Handler [WEAK]
185 | IMPORT SystemInit
186 | IMPORT __main
187 |
188 | LDR R0, =SystemInit
189 | BLX R0
190 | LDR R0, =__main
191 | BX R0
192 | ENDP
193 |
194 | ; Dummy Exception Handlers (infinite loops which can be modified)
195 |
196 | NMI_Handler PROC
197 | EXPORT NMI_Handler [WEAK]
198 | B .
199 | ENDP
200 | HardFault_Handler\
201 | PROC
202 | EXPORT HardFault_Handler [WEAK]
203 | B .
204 | ENDP
205 | MemManage_Handler\
206 | PROC
207 | EXPORT MemManage_Handler [WEAK]
208 | B .
209 | ENDP
210 | BusFault_Handler\
211 | PROC
212 | EXPORT BusFault_Handler [WEAK]
213 | B .
214 | ENDP
215 | UsageFault_Handler\
216 | PROC
217 | EXPORT UsageFault_Handler [WEAK]
218 | B .
219 | ENDP
220 | SVC_Handler PROC
221 | EXPORT SVC_Handler [WEAK]
222 | B .
223 | ENDP
224 | DebugMon_Handler\
225 | PROC
226 | EXPORT DebugMon_Handler [WEAK]
227 | B .
228 | ENDP
229 | PendSV_Handler PROC
230 | EXPORT PendSV_Handler [WEAK]
231 | B .
232 | ENDP
233 | SysTick_Handler PROC
234 | EXPORT SysTick_Handler [WEAK]
235 | B .
236 | ENDP
237 |
238 | Default_Handler PROC
239 |
240 | EXPORT WWDG_IRQHandler [WEAK]
241 | EXPORT PVD_IRQHandler [WEAK]
242 | EXPORT TAMP_STAMP_IRQHandler [WEAK]
243 | EXPORT RTC_WKUP_IRQHandler [WEAK]
244 | EXPORT FLASH_IRQHandler [WEAK]
245 | EXPORT RCC_IRQHandler [WEAK]
246 | EXPORT EXTI0_IRQHandler [WEAK]
247 | EXPORT EXTI1_IRQHandler [WEAK]
248 | EXPORT EXTI2_IRQHandler [WEAK]
249 | EXPORT EXTI3_IRQHandler [WEAK]
250 | EXPORT EXTI4_IRQHandler [WEAK]
251 | EXPORT DMA1_Stream0_IRQHandler [WEAK]
252 | EXPORT DMA1_Stream1_IRQHandler [WEAK]
253 | EXPORT DMA1_Stream2_IRQHandler [WEAK]
254 | EXPORT DMA1_Stream3_IRQHandler [WEAK]
255 | EXPORT DMA1_Stream4_IRQHandler [WEAK]
256 | EXPORT DMA1_Stream5_IRQHandler [WEAK]
257 | EXPORT DMA1_Stream6_IRQHandler [WEAK]
258 | EXPORT ADC_IRQHandler [WEAK]
259 | EXPORT CAN1_TX_IRQHandler [WEAK]
260 | EXPORT CAN1_RX0_IRQHandler [WEAK]
261 | EXPORT CAN1_RX1_IRQHandler [WEAK]
262 | EXPORT CAN1_SCE_IRQHandler [WEAK]
263 | EXPORT EXTI9_5_IRQHandler [WEAK]
264 | EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
265 | EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
266 | EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
267 | EXPORT TIM1_CC_IRQHandler [WEAK]
268 | EXPORT TIM2_IRQHandler [WEAK]
269 | EXPORT TIM3_IRQHandler [WEAK]
270 | EXPORT TIM4_IRQHandler [WEAK]
271 | EXPORT I2C1_EV_IRQHandler [WEAK]
272 | EXPORT I2C1_ER_IRQHandler [WEAK]
273 | EXPORT I2C2_EV_IRQHandler [WEAK]
274 | EXPORT I2C2_ER_IRQHandler [WEAK]
275 | EXPORT SPI1_IRQHandler [WEAK]
276 | EXPORT SPI2_IRQHandler [WEAK]
277 | EXPORT USART1_IRQHandler [WEAK]
278 | EXPORT USART2_IRQHandler [WEAK]
279 | EXPORT USART3_IRQHandler [WEAK]
280 | EXPORT EXTI15_10_IRQHandler [WEAK]
281 | EXPORT RTC_Alarm_IRQHandler [WEAK]
282 | EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
283 | EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
284 | EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
285 | EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
286 | EXPORT TIM8_CC_IRQHandler [WEAK]
287 | EXPORT DMA1_Stream7_IRQHandler [WEAK]
288 | EXPORT FMC_IRQHandler [WEAK]
289 | EXPORT SDIO_IRQHandler [WEAK]
290 | EXPORT TIM5_IRQHandler [WEAK]
291 | EXPORT SPI3_IRQHandler [WEAK]
292 | EXPORT UART4_IRQHandler [WEAK]
293 | EXPORT UART5_IRQHandler [WEAK]
294 | EXPORT TIM6_DAC_IRQHandler [WEAK]
295 | EXPORT TIM7_IRQHandler [WEAK]
296 | EXPORT DMA2_Stream0_IRQHandler [WEAK]
297 | EXPORT DMA2_Stream1_IRQHandler [WEAK]
298 | EXPORT DMA2_Stream2_IRQHandler [WEAK]
299 | EXPORT DMA2_Stream3_IRQHandler [WEAK]
300 | EXPORT DMA2_Stream4_IRQHandler [WEAK]
301 | EXPORT ETH_IRQHandler [WEAK]
302 | EXPORT ETH_WKUP_IRQHandler [WEAK]
303 | EXPORT CAN2_TX_IRQHandler [WEAK]
304 | EXPORT CAN2_RX0_IRQHandler [WEAK]
305 | EXPORT CAN2_RX1_IRQHandler [WEAK]
306 | EXPORT CAN2_SCE_IRQHandler [WEAK]
307 | EXPORT OTG_FS_IRQHandler [WEAK]
308 | EXPORT DMA2_Stream5_IRQHandler [WEAK]
309 | EXPORT DMA2_Stream6_IRQHandler [WEAK]
310 | EXPORT DMA2_Stream7_IRQHandler [WEAK]
311 | EXPORT USART6_IRQHandler [WEAK]
312 | EXPORT I2C3_EV_IRQHandler [WEAK]
313 | EXPORT I2C3_ER_IRQHandler [WEAK]
314 | EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
315 | EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
316 | EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
317 | EXPORT OTG_HS_IRQHandler [WEAK]
318 | EXPORT DCMI_IRQHandler [WEAK]
319 | EXPORT HASH_RNG_IRQHandler [WEAK]
320 | EXPORT FPU_IRQHandler [WEAK]
321 |
322 | WWDG_IRQHandler
323 | PVD_IRQHandler
324 | TAMP_STAMP_IRQHandler
325 | RTC_WKUP_IRQHandler
326 | FLASH_IRQHandler
327 | RCC_IRQHandler
328 | EXTI0_IRQHandler
329 | EXTI1_IRQHandler
330 | EXTI2_IRQHandler
331 | EXTI3_IRQHandler
332 | EXTI4_IRQHandler
333 | DMA1_Stream0_IRQHandler
334 | DMA1_Stream1_IRQHandler
335 | DMA1_Stream2_IRQHandler
336 | DMA1_Stream3_IRQHandler
337 | DMA1_Stream4_IRQHandler
338 | DMA1_Stream5_IRQHandler
339 | DMA1_Stream6_IRQHandler
340 | ADC_IRQHandler
341 | CAN1_TX_IRQHandler
342 | CAN1_RX0_IRQHandler
343 | CAN1_RX1_IRQHandler
344 | CAN1_SCE_IRQHandler
345 | EXTI9_5_IRQHandler
346 | TIM1_BRK_TIM9_IRQHandler
347 | TIM1_UP_TIM10_IRQHandler
348 | TIM1_TRG_COM_TIM11_IRQHandler
349 | TIM1_CC_IRQHandler
350 | TIM2_IRQHandler
351 | TIM3_IRQHandler
352 | TIM4_IRQHandler
353 | I2C1_EV_IRQHandler
354 | I2C1_ER_IRQHandler
355 | I2C2_EV_IRQHandler
356 | I2C2_ER_IRQHandler
357 | SPI1_IRQHandler
358 | SPI2_IRQHandler
359 | USART1_IRQHandler
360 | USART2_IRQHandler
361 | USART3_IRQHandler
362 | EXTI15_10_IRQHandler
363 | RTC_Alarm_IRQHandler
364 | OTG_FS_WKUP_IRQHandler
365 | TIM8_BRK_TIM12_IRQHandler
366 | TIM8_UP_TIM13_IRQHandler
367 | TIM8_TRG_COM_TIM14_IRQHandler
368 | TIM8_CC_IRQHandler
369 | DMA1_Stream7_IRQHandler
370 | FMC_IRQHandler
371 | SDIO_IRQHandler
372 | TIM5_IRQHandler
373 | SPI3_IRQHandler
374 | UART4_IRQHandler
375 | UART5_IRQHandler
376 | TIM6_DAC_IRQHandler
377 | TIM7_IRQHandler
378 | DMA2_Stream0_IRQHandler
379 | DMA2_Stream1_IRQHandler
380 | DMA2_Stream2_IRQHandler
381 | DMA2_Stream3_IRQHandler
382 | DMA2_Stream4_IRQHandler
383 | ETH_IRQHandler
384 | ETH_WKUP_IRQHandler
385 | CAN2_TX_IRQHandler
386 | CAN2_RX0_IRQHandler
387 | CAN2_RX1_IRQHandler
388 | CAN2_SCE_IRQHandler
389 | OTG_FS_IRQHandler
390 | DMA2_Stream5_IRQHandler
391 | DMA2_Stream6_IRQHandler
392 | DMA2_Stream7_IRQHandler
393 | USART6_IRQHandler
394 | I2C3_EV_IRQHandler
395 | I2C3_ER_IRQHandler
396 | OTG_HS_EP1_OUT_IRQHandler
397 | OTG_HS_EP1_IN_IRQHandler
398 | OTG_HS_WKUP_IRQHandler
399 | OTG_HS_IRQHandler
400 | DCMI_IRQHandler
401 | HASH_RNG_IRQHandler
402 | FPU_IRQHandler
403 |
404 | B .
405 |
406 | ENDP
407 |
408 | ALIGN
409 |
410 | ;*******************************************************************************
411 | ; User Stack and Heap initialization
412 | ;*******************************************************************************
413 | IF :DEF:__MICROLIB
414 |
415 | EXPORT __initial_sp
416 | EXPORT __heap_base
417 | EXPORT __heap_limit
418 |
419 | ELSE
420 |
421 | IMPORT __use_two_region_memory
422 | EXPORT __user_initial_stackheap
423 |
424 | __user_initial_stackheap
425 |
426 | LDR R0, = Heap_Mem
427 | LDR R1, =(Stack_Mem + Stack_Size)
428 | LDR R2, = (Heap_Mem + Heap_Size)
429 | LDR R3, = Stack_Mem
430 | BX LR
431 |
432 | ALIGN
433 |
434 | ENDIF
435 |
436 | END
437 |
438 | ;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
439 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/STM32F407VGTx/system_stm32f4xx-backup.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f4xx.c
4 | * @author MCD Application Team
5 | * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
6 | *
7 | * This file provides two functions and one global variable to be called from
8 | * user application:
9 | * - SystemInit(): This function is called at startup just after reset and
10 | * before branch to main program. This call is made inside
11 | * the "startup_stm32f4xx.s" file.
12 | *
13 | * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
14 | * by the user application to setup the SysTick
15 | * timer or configure other parameters.
16 | *
17 | * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
18 | * be called whenever the core clock is changed
19 | * during program execution.
20 | *
21 | *
22 | ******************************************************************************
23 | * @attention
24 | *
25 | * © COPYRIGHT 2017 STMicroelectronics
26 | *
27 | * Redistribution and use in source and binary forms, with or without modification,
28 | * are permitted provided that the following conditions are met:
29 | * 1. Redistributions of source code must retain the above copyright notice,
30 | * this list of conditions and the following disclaimer.
31 | * 2. Redistributions in binary form must reproduce the above copyright notice,
32 | * this list of conditions and the following disclaimer in the documentation
33 | * and/or other materials provided with the distribution.
34 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
35 | * may be used to endorse or promote products derived from this software
36 | * without specific prior written permission.
37 | *
38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
42 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 | *
49 | ******************************************************************************
50 | */
51 |
52 | /** @addtogroup CMSIS
53 | * @{
54 | */
55 |
56 | /** @addtogroup stm32f4xx_system
57 | * @{
58 | */
59 |
60 | /** @addtogroup STM32F4xx_System_Private_Includes
61 | * @{
62 | */
63 |
64 |
65 | #include "stm32f4xx.h"
66 |
67 | #if !defined (HSE_VALUE)
68 | #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */
69 | #endif /* HSE_VALUE */
70 |
71 | #if !defined (HSI_VALUE)
72 | #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
73 | #endif /* HSI_VALUE */
74 |
75 | /**
76 | * @}
77 | */
78 |
79 | /** @addtogroup STM32F4xx_System_Private_TypesDefinitions
80 | * @{
81 | */
82 |
83 | /**
84 | * @}
85 | */
86 |
87 | /** @addtogroup STM32F4xx_System_Private_Defines
88 | * @{
89 | */
90 |
91 | /************************* Miscellaneous Configuration ************************/
92 | /*!< Uncomment the following line if you need to use external SRAM or SDRAM as data memory */
93 | #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
94 | || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
95 | || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
96 | /* #define DATA_IN_ExtSRAM */
97 | #endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\
98 | STM32F412Zx || STM32F412Vx */
99 |
100 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
101 | || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
102 | /* #define DATA_IN_ExtSDRAM */
103 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
104 | STM32F479xx */
105 |
106 | /*!< Uncomment the following line if you need to relocate your vector Table in
107 | Internal SRAM. */
108 | /* #define VECT_TAB_SRAM */
109 | #define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
110 | This value must be a multiple of 0x200. */
111 | /******************************************************************************/
112 |
113 | /**
114 | * @}
115 | */
116 |
117 | /** @addtogroup STM32F4xx_System_Private_Macros
118 | * @{
119 | */
120 |
121 | /**
122 | * @}
123 | */
124 |
125 | /** @addtogroup STM32F4xx_System_Private_Variables
126 | * @{
127 | */
128 | /* This variable is updated in three ways:
129 | 1) by calling CMSIS function SystemCoreClockUpdate()
130 | 2) by calling HAL API function HAL_RCC_GetHCLKFreq()
131 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
132 | Note: If you use this function to configure the system clock; then there
133 | is no need to call the 2 first functions listed above, since SystemCoreClock
134 | variable is updated automatically.
135 | */
136 | uint32_t SystemCoreClock = 16000000;
137 | const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
138 | const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
139 | /**
140 | * @}
141 | */
142 |
143 | /** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
144 | * @{
145 | */
146 |
147 | #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
148 | static void SystemInit_ExtMemCtl(void);
149 | #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
150 |
151 | /**
152 | * @}
153 | */
154 |
155 | /** @addtogroup STM32F4xx_System_Private_Functions
156 | * @{
157 | */
158 |
159 | /**
160 | * @brief Setup the microcontroller system
161 | * Initialize the FPU setting, vector table location and External memory
162 | * configuration.
163 | * @param None
164 | * @retval None
165 | */
166 | void SystemInit(void)
167 | {
168 | /* FPU settings ------------------------------------------------------------*/
169 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
170 | SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
171 | #endif
172 | /* Reset the RCC clock configuration to the default reset state ------------*/
173 | /* Set HSION bit */
174 | RCC->CR |= (uint32_t)0x00000001;
175 |
176 | /* Reset CFGR register */
177 | RCC->CFGR = 0x00000000;
178 |
179 | /* Reset HSEON, CSSON and PLLON bits */
180 | RCC->CR &= (uint32_t)0xFEF6FFFF;
181 |
182 | /* Reset PLLCFGR register */
183 | RCC->PLLCFGR = 0x24003010;
184 |
185 | /* Reset HSEBYP bit */
186 | RCC->CR &= (uint32_t)0xFFFBFFFF;
187 |
188 | /* Disable all interrupts */
189 | RCC->CIR = 0x00000000;
190 |
191 | #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
192 | SystemInit_ExtMemCtl();
193 | #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
194 |
195 | /* Configure the Vector Table location add offset address ------------------*/
196 | #ifdef VECT_TAB_SRAM
197 | SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
198 | #else
199 | SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
200 | #endif
201 | }
202 |
203 | /**
204 | * @brief Update SystemCoreClock variable according to Clock Register Values.
205 | * The SystemCoreClock variable contains the core clock (HCLK), it can
206 | * be used by the user application to setup the SysTick timer or configure
207 | * other parameters.
208 | *
209 | * @note Each time the core clock (HCLK) changes, this function must be called
210 | * to update SystemCoreClock variable value. Otherwise, any configuration
211 | * based on this variable will be incorrect.
212 | *
213 | * @note - The system frequency computed by this function is not the real
214 | * frequency in the chip. It is calculated based on the predefined
215 | * constant and the selected clock source:
216 | *
217 | * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
218 | *
219 | * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
220 | *
221 | * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
222 | * or HSI_VALUE(*) multiplied/divided by the PLL factors.
223 | *
224 | * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value
225 | * 16 MHz) but the real value may vary depending on the variations
226 | * in voltage and temperature.
227 | *
228 | * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value
229 | * depends on the application requirements), user has to ensure that HSE_VALUE
230 | * is same as the real frequency of the crystal used. Otherwise, this function
231 | * may have wrong result.
232 | *
233 | * - The result of this function could be not correct when using fractional
234 | * value for HSE crystal.
235 | *
236 | * @param None
237 | * @retval None
238 | */
239 | void SystemCoreClockUpdate(void)
240 | {
241 | uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
242 |
243 | /* Get SYSCLK source -------------------------------------------------------*/
244 | tmp = RCC->CFGR & RCC_CFGR_SWS;
245 |
246 | switch (tmp)
247 | {
248 | case 0x00: /* HSI used as system clock source */
249 | SystemCoreClock = HSI_VALUE;
250 | break;
251 | case 0x04: /* HSE used as system clock source */
252 | SystemCoreClock = HSE_VALUE;
253 | break;
254 | case 0x08: /* PLL used as system clock source */
255 |
256 | /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
257 | SYSCLK = PLL_VCO / PLL_P
258 | */
259 | pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
260 | pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
261 |
262 | if (pllsource != 0)
263 | {
264 | /* HSE used as PLL clock source */
265 | pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
266 | }
267 | else
268 | {
269 | /* HSI used as PLL clock source */
270 | pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
271 | }
272 |
273 | pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
274 | SystemCoreClock = pllvco/pllp;
275 | break;
276 | default:
277 | SystemCoreClock = HSI_VALUE;
278 | break;
279 | }
280 | /* Compute HCLK frequency --------------------------------------------------*/
281 | /* Get HCLK prescaler */
282 | tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
283 | /* HCLK frequency */
284 | SystemCoreClock >>= tmp;
285 | }
286 |
287 | #if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM)
288 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
289 | || defined(STM32F469xx) || defined(STM32F479xx)
290 | /**
291 | * @brief Setup the external memory controller.
292 | * Called in startup_stm32f4xx.s before jump to main.
293 | * This function configures the external memories (SRAM/SDRAM)
294 | * This SRAM/SDRAM will be used as program data memory (including heap and stack).
295 | * @param None
296 | * @retval None
297 | */
298 | void SystemInit_ExtMemCtl(void)
299 | {
300 | __IO uint32_t tmp = 0x00;
301 |
302 | register uint32_t tmpreg = 0, timeout = 0xFFFF;
303 | register __IO uint32_t index;
304 |
305 | /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */
306 | RCC->AHB1ENR |= 0x000001F8;
307 |
308 | /* Delay after an RCC peripheral clock enabling */
309 | tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
310 |
311 | /* Connect PDx pins to FMC Alternate function */
312 | GPIOD->AFR[0] = 0x00CCC0CC;
313 | GPIOD->AFR[1] = 0xCCCCCCCC;
314 | /* Configure PDx pins in Alternate function mode */
315 | GPIOD->MODER = 0xAAAA0A8A;
316 | /* Configure PDx pins speed to 100 MHz */
317 | GPIOD->OSPEEDR = 0xFFFF0FCF;
318 | /* Configure PDx pins Output type to push-pull */
319 | GPIOD->OTYPER = 0x00000000;
320 | /* No pull-up, pull-down for PDx pins */
321 | GPIOD->PUPDR = 0x00000000;
322 |
323 | /* Connect PEx pins to FMC Alternate function */
324 | GPIOE->AFR[0] = 0xC00CC0CC;
325 | GPIOE->AFR[1] = 0xCCCCCCCC;
326 | /* Configure PEx pins in Alternate function mode */
327 | GPIOE->MODER = 0xAAAA828A;
328 | /* Configure PEx pins speed to 100 MHz */
329 | GPIOE->OSPEEDR = 0xFFFFC3CF;
330 | /* Configure PEx pins Output type to push-pull */
331 | GPIOE->OTYPER = 0x00000000;
332 | /* No pull-up, pull-down for PEx pins */
333 | GPIOE->PUPDR = 0x00000000;
334 |
335 | /* Connect PFx pins to FMC Alternate function */
336 | GPIOF->AFR[0] = 0xCCCCCCCC;
337 | GPIOF->AFR[1] = 0xCCCCCCCC;
338 | /* Configure PFx pins in Alternate function mode */
339 | GPIOF->MODER = 0xAA800AAA;
340 | /* Configure PFx pins speed to 50 MHz */
341 | GPIOF->OSPEEDR = 0xAA800AAA;
342 | /* Configure PFx pins Output type to push-pull */
343 | GPIOF->OTYPER = 0x00000000;
344 | /* No pull-up, pull-down for PFx pins */
345 | GPIOF->PUPDR = 0x00000000;
346 |
347 | /* Connect PGx pins to FMC Alternate function */
348 | GPIOG->AFR[0] = 0xCCCCCCCC;
349 | GPIOG->AFR[1] = 0xCCCCCCCC;
350 | /* Configure PGx pins in Alternate function mode */
351 | GPIOG->MODER = 0xAAAAAAAA;
352 | /* Configure PGx pins speed to 50 MHz */
353 | GPIOG->OSPEEDR = 0xAAAAAAAA;
354 | /* Configure PGx pins Output type to push-pull */
355 | GPIOG->OTYPER = 0x00000000;
356 | /* No pull-up, pull-down for PGx pins */
357 | GPIOG->PUPDR = 0x00000000;
358 |
359 | /* Connect PHx pins to FMC Alternate function */
360 | GPIOH->AFR[0] = 0x00C0CC00;
361 | GPIOH->AFR[1] = 0xCCCCCCCC;
362 | /* Configure PHx pins in Alternate function mode */
363 | GPIOH->MODER = 0xAAAA08A0;
364 | /* Configure PHx pins speed to 50 MHz */
365 | GPIOH->OSPEEDR = 0xAAAA08A0;
366 | /* Configure PHx pins Output type to push-pull */
367 | GPIOH->OTYPER = 0x00000000;
368 | /* No pull-up, pull-down for PHx pins */
369 | GPIOH->PUPDR = 0x00000000;
370 |
371 | /* Connect PIx pins to FMC Alternate function */
372 | GPIOI->AFR[0] = 0xCCCCCCCC;
373 | GPIOI->AFR[1] = 0x00000CC0;
374 | /* Configure PIx pins in Alternate function mode */
375 | GPIOI->MODER = 0x0028AAAA;
376 | /* Configure PIx pins speed to 50 MHz */
377 | GPIOI->OSPEEDR = 0x0028AAAA;
378 | /* Configure PIx pins Output type to push-pull */
379 | GPIOI->OTYPER = 0x00000000;
380 | /* No pull-up, pull-down for PIx pins */
381 | GPIOI->PUPDR = 0x00000000;
382 |
383 | /*-- FMC Configuration -------------------------------------------------------*/
384 | /* Enable the FMC interface clock */
385 | RCC->AHB3ENR |= 0x00000001;
386 | /* Delay after an RCC peripheral clock enabling */
387 | tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
388 |
389 | FMC_Bank5_6->SDCR[0] = 0x000019E4;
390 | FMC_Bank5_6->SDTR[0] = 0x01115351;
391 |
392 | /* SDRAM initialization sequence */
393 | /* Clock enable command */
394 | FMC_Bank5_6->SDCMR = 0x00000011;
395 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
396 | while((tmpreg != 0) && (timeout-- > 0))
397 | {
398 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
399 | }
400 |
401 | /* Delay */
402 | for (index = 0; index<1000; index++);
403 |
404 | /* PALL command */
405 | FMC_Bank5_6->SDCMR = 0x00000012;
406 | timeout = 0xFFFF;
407 | while((tmpreg != 0) && (timeout-- > 0))
408 | {
409 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
410 | }
411 |
412 | /* Auto refresh command */
413 | FMC_Bank5_6->SDCMR = 0x00000073;
414 | timeout = 0xFFFF;
415 | while((tmpreg != 0) && (timeout-- > 0))
416 | {
417 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
418 | }
419 |
420 | /* MRD register program */
421 | FMC_Bank5_6->SDCMR = 0x00046014;
422 | timeout = 0xFFFF;
423 | while((tmpreg != 0) && (timeout-- > 0))
424 | {
425 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
426 | }
427 |
428 | /* Set refresh count */
429 | tmpreg = FMC_Bank5_6->SDRTR;
430 | FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
431 |
432 | /* Disable write protection */
433 | tmpreg = FMC_Bank5_6->SDCR[0];
434 | FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
435 |
436 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
437 | /* Configure and enable Bank1_SRAM2 */
438 | FMC_Bank1->BTCR[2] = 0x00001011;
439 | FMC_Bank1->BTCR[3] = 0x00000201;
440 | FMC_Bank1E->BWTR[2] = 0x0fffffff;
441 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
442 | #if defined(STM32F469xx) || defined(STM32F479xx)
443 | /* Configure and enable Bank1_SRAM2 */
444 | FMC_Bank1->BTCR[2] = 0x00001091;
445 | FMC_Bank1->BTCR[3] = 0x00110212;
446 | FMC_Bank1E->BWTR[2] = 0x0fffffff;
447 | #endif /* STM32F469xx || STM32F479xx */
448 |
449 | (void)(tmp);
450 | }
451 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
452 | #elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
453 | /**
454 | * @brief Setup the external memory controller.
455 | * Called in startup_stm32f4xx.s before jump to main.
456 | * This function configures the external memories (SRAM/SDRAM)
457 | * This SRAM/SDRAM will be used as program data memory (including heap and stack).
458 | * @param None
459 | * @retval None
460 | */
461 | void SystemInit_ExtMemCtl(void)
462 | {
463 | __IO uint32_t tmp = 0x00;
464 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
465 | || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
466 | #if defined (DATA_IN_ExtSDRAM)
467 | register uint32_t tmpreg = 0, timeout = 0xFFFF;
468 | register __IO uint32_t index;
469 |
470 | #if defined(STM32F446xx)
471 | /* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface
472 | clock */
473 | RCC->AHB1ENR |= 0x0000007D;
474 | #else
475 | /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
476 | clock */
477 | RCC->AHB1ENR |= 0x000001F8;
478 | #endif /* STM32F446xx */
479 | /* Delay after an RCC peripheral clock enabling */
480 | tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
481 |
482 | #if defined(STM32F446xx)
483 | /* Connect PAx pins to FMC Alternate function */
484 | GPIOA->AFR[0] |= 0xC0000000;
485 | GPIOA->AFR[1] |= 0x00000000;
486 | /* Configure PDx pins in Alternate function mode */
487 | GPIOA->MODER |= 0x00008000;
488 | /* Configure PDx pins speed to 50 MHz */
489 | GPIOA->OSPEEDR |= 0x00008000;
490 | /* Configure PDx pins Output type to push-pull */
491 | GPIOA->OTYPER |= 0x00000000;
492 | /* No pull-up, pull-down for PDx pins */
493 | GPIOA->PUPDR |= 0x00000000;
494 |
495 | /* Connect PCx pins to FMC Alternate function */
496 | GPIOC->AFR[0] |= 0x00CC0000;
497 | GPIOC->AFR[1] |= 0x00000000;
498 | /* Configure PDx pins in Alternate function mode */
499 | GPIOC->MODER |= 0x00000A00;
500 | /* Configure PDx pins speed to 50 MHz */
501 | GPIOC->OSPEEDR |= 0x00000A00;
502 | /* Configure PDx pins Output type to push-pull */
503 | GPIOC->OTYPER |= 0x00000000;
504 | /* No pull-up, pull-down for PDx pins */
505 | GPIOC->PUPDR |= 0x00000000;
506 | #endif /* STM32F446xx */
507 |
508 | /* Connect PDx pins to FMC Alternate function */
509 | GPIOD->AFR[0] = 0x000000CC;
510 | GPIOD->AFR[1] = 0xCC000CCC;
511 | /* Configure PDx pins in Alternate function mode */
512 | GPIOD->MODER = 0xA02A000A;
513 | /* Configure PDx pins speed to 50 MHz */
514 | GPIOD->OSPEEDR = 0xA02A000A;
515 | /* Configure PDx pins Output type to push-pull */
516 | GPIOD->OTYPER = 0x00000000;
517 | /* No pull-up, pull-down for PDx pins */
518 | GPIOD->PUPDR = 0x00000000;
519 |
520 | /* Connect PEx pins to FMC Alternate function */
521 | GPIOE->AFR[0] = 0xC00000CC;
522 | GPIOE->AFR[1] = 0xCCCCCCCC;
523 | /* Configure PEx pins in Alternate function mode */
524 | GPIOE->MODER = 0xAAAA800A;
525 | /* Configure PEx pins speed to 50 MHz */
526 | GPIOE->OSPEEDR = 0xAAAA800A;
527 | /* Configure PEx pins Output type to push-pull */
528 | GPIOE->OTYPER = 0x00000000;
529 | /* No pull-up, pull-down for PEx pins */
530 | GPIOE->PUPDR = 0x00000000;
531 |
532 | /* Connect PFx pins to FMC Alternate function */
533 | GPIOF->AFR[0] = 0xCCCCCCCC;
534 | GPIOF->AFR[1] = 0xCCCCCCCC;
535 | /* Configure PFx pins in Alternate function mode */
536 | GPIOF->MODER = 0xAA800AAA;
537 | /* Configure PFx pins speed to 50 MHz */
538 | GPIOF->OSPEEDR = 0xAA800AAA;
539 | /* Configure PFx pins Output type to push-pull */
540 | GPIOF->OTYPER = 0x00000000;
541 | /* No pull-up, pull-down for PFx pins */
542 | GPIOF->PUPDR = 0x00000000;
543 |
544 | /* Connect PGx pins to FMC Alternate function */
545 | GPIOG->AFR[0] = 0xCCCCCCCC;
546 | GPIOG->AFR[1] = 0xCCCCCCCC;
547 | /* Configure PGx pins in Alternate function mode */
548 | GPIOG->MODER = 0xAAAAAAAA;
549 | /* Configure PGx pins speed to 50 MHz */
550 | GPIOG->OSPEEDR = 0xAAAAAAAA;
551 | /* Configure PGx pins Output type to push-pull */
552 | GPIOG->OTYPER = 0x00000000;
553 | /* No pull-up, pull-down for PGx pins */
554 | GPIOG->PUPDR = 0x00000000;
555 |
556 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
557 | || defined(STM32F469xx) || defined(STM32F479xx)
558 | /* Connect PHx pins to FMC Alternate function */
559 | GPIOH->AFR[0] = 0x00C0CC00;
560 | GPIOH->AFR[1] = 0xCCCCCCCC;
561 | /* Configure PHx pins in Alternate function mode */
562 | GPIOH->MODER = 0xAAAA08A0;
563 | /* Configure PHx pins speed to 50 MHz */
564 | GPIOH->OSPEEDR = 0xAAAA08A0;
565 | /* Configure PHx pins Output type to push-pull */
566 | GPIOH->OTYPER = 0x00000000;
567 | /* No pull-up, pull-down for PHx pins */
568 | GPIOH->PUPDR = 0x00000000;
569 |
570 | /* Connect PIx pins to FMC Alternate function */
571 | GPIOI->AFR[0] = 0xCCCCCCCC;
572 | GPIOI->AFR[1] = 0x00000CC0;
573 | /* Configure PIx pins in Alternate function mode */
574 | GPIOI->MODER = 0x0028AAAA;
575 | /* Configure PIx pins speed to 50 MHz */
576 | GPIOI->OSPEEDR = 0x0028AAAA;
577 | /* Configure PIx pins Output type to push-pull */
578 | GPIOI->OTYPER = 0x00000000;
579 | /* No pull-up, pull-down for PIx pins */
580 | GPIOI->PUPDR = 0x00000000;
581 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
582 |
583 | /*-- FMC Configuration -------------------------------------------------------*/
584 | /* Enable the FMC interface clock */
585 | RCC->AHB3ENR |= 0x00000001;
586 | /* Delay after an RCC peripheral clock enabling */
587 | tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
588 |
589 | /* Configure and enable SDRAM bank1 */
590 | #if defined(STM32F446xx)
591 | FMC_Bank5_6->SDCR[0] = 0x00001954;
592 | #else
593 | FMC_Bank5_6->SDCR[0] = 0x000019E4;
594 | #endif /* STM32F446xx */
595 | FMC_Bank5_6->SDTR[0] = 0x01115351;
596 |
597 | /* SDRAM initialization sequence */
598 | /* Clock enable command */
599 | FMC_Bank5_6->SDCMR = 0x00000011;
600 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
601 | while((tmpreg != 0) && (timeout-- > 0))
602 | {
603 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
604 | }
605 |
606 | /* Delay */
607 | for (index = 0; index<1000; index++);
608 |
609 | /* PALL command */
610 | FMC_Bank5_6->SDCMR = 0x00000012;
611 | timeout = 0xFFFF;
612 | while((tmpreg != 0) && (timeout-- > 0))
613 | {
614 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
615 | }
616 |
617 | /* Auto refresh command */
618 | #if defined(STM32F446xx)
619 | FMC_Bank5_6->SDCMR = 0x000000F3;
620 | #else
621 | FMC_Bank5_6->SDCMR = 0x00000073;
622 | #endif /* STM32F446xx */
623 | timeout = 0xFFFF;
624 | while((tmpreg != 0) && (timeout-- > 0))
625 | {
626 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
627 | }
628 |
629 | /* MRD register program */
630 | #if defined(STM32F446xx)
631 | FMC_Bank5_6->SDCMR = 0x00044014;
632 | #else
633 | FMC_Bank5_6->SDCMR = 0x00046014;
634 | #endif /* STM32F446xx */
635 | timeout = 0xFFFF;
636 | while((tmpreg != 0) && (timeout-- > 0))
637 | {
638 | tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
639 | }
640 |
641 | /* Set refresh count */
642 | tmpreg = FMC_Bank5_6->SDRTR;
643 | #if defined(STM32F446xx)
644 | FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1));
645 | #else
646 | FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
647 | #endif /* STM32F446xx */
648 |
649 | /* Disable write protection */
650 | tmpreg = FMC_Bank5_6->SDCR[0];
651 | FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
652 | #endif /* DATA_IN_ExtSDRAM */
653 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
654 |
655 | #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
656 | || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
657 | || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
658 |
659 | #if defined(DATA_IN_ExtSRAM)
660 | /*-- GPIOs Configuration -----------------------------------------------------*/
661 | /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
662 | RCC->AHB1ENR |= 0x00000078;
663 | /* Delay after an RCC peripheral clock enabling */
664 | tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);
665 |
666 | /* Connect PDx pins to FMC Alternate function */
667 | GPIOD->AFR[0] = 0x00CCC0CC;
668 | GPIOD->AFR[1] = 0xCCCCCCCC;
669 | /* Configure PDx pins in Alternate function mode */
670 | GPIOD->MODER = 0xAAAA0A8A;
671 | /* Configure PDx pins speed to 100 MHz */
672 | GPIOD->OSPEEDR = 0xFFFF0FCF;
673 | /* Configure PDx pins Output type to push-pull */
674 | GPIOD->OTYPER = 0x00000000;
675 | /* No pull-up, pull-down for PDx pins */
676 | GPIOD->PUPDR = 0x00000000;
677 |
678 | /* Connect PEx pins to FMC Alternate function */
679 | GPIOE->AFR[0] = 0xC00CC0CC;
680 | GPIOE->AFR[1] = 0xCCCCCCCC;
681 | /* Configure PEx pins in Alternate function mode */
682 | GPIOE->MODER = 0xAAAA828A;
683 | /* Configure PEx pins speed to 100 MHz */
684 | GPIOE->OSPEEDR = 0xFFFFC3CF;
685 | /* Configure PEx pins Output type to push-pull */
686 | GPIOE->OTYPER = 0x00000000;
687 | /* No pull-up, pull-down for PEx pins */
688 | GPIOE->PUPDR = 0x00000000;
689 |
690 | /* Connect PFx pins to FMC Alternate function */
691 | GPIOF->AFR[0] = 0x00CCCCCC;
692 | GPIOF->AFR[1] = 0xCCCC0000;
693 | /* Configure PFx pins in Alternate function mode */
694 | GPIOF->MODER = 0xAA000AAA;
695 | /* Configure PFx pins speed to 100 MHz */
696 | GPIOF->OSPEEDR = 0xFF000FFF;
697 | /* Configure PFx pins Output type to push-pull */
698 | GPIOF->OTYPER = 0x00000000;
699 | /* No pull-up, pull-down for PFx pins */
700 | GPIOF->PUPDR = 0x00000000;
701 |
702 | /* Connect PGx pins to FMC Alternate function */
703 | GPIOG->AFR[0] = 0x00CCCCCC;
704 | GPIOG->AFR[1] = 0x000000C0;
705 | /* Configure PGx pins in Alternate function mode */
706 | GPIOG->MODER = 0x00085AAA;
707 | /* Configure PGx pins speed to 100 MHz */
708 | GPIOG->OSPEEDR = 0x000CAFFF;
709 | /* Configure PGx pins Output type to push-pull */
710 | GPIOG->OTYPER = 0x00000000;
711 | /* No pull-up, pull-down for PGx pins */
712 | GPIOG->PUPDR = 0x00000000;
713 |
714 | /*-- FMC/FSMC Configuration --------------------------------------------------*/
715 | /* Enable the FMC/FSMC interface clock */
716 | RCC->AHB3ENR |= 0x00000001;
717 |
718 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
719 | /* Delay after an RCC peripheral clock enabling */
720 | tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
721 | /* Configure and enable Bank1_SRAM2 */
722 | FMC_Bank1->BTCR[2] = 0x00001011;
723 | FMC_Bank1->BTCR[3] = 0x00000201;
724 | FMC_Bank1E->BWTR[2] = 0x0fffffff;
725 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
726 | #if defined(STM32F469xx) || defined(STM32F479xx)
727 | /* Delay after an RCC peripheral clock enabling */
728 | tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
729 | /* Configure and enable Bank1_SRAM2 */
730 | FMC_Bank1->BTCR[2] = 0x00001091;
731 | FMC_Bank1->BTCR[3] = 0x00110212;
732 | FMC_Bank1E->BWTR[2] = 0x0fffffff;
733 | #endif /* STM32F469xx || STM32F479xx */
734 | #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\
735 | || defined(STM32F412Zx) || defined(STM32F412Vx)
736 | /* Delay after an RCC peripheral clock enabling */
737 | tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);
738 | /* Configure and enable Bank1_SRAM2 */
739 | FSMC_Bank1->BTCR[2] = 0x00001011;
740 | FSMC_Bank1->BTCR[3] = 0x00000201;
741 | FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF;
742 | #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */
743 |
744 | #endif /* DATA_IN_ExtSRAM */
745 | #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\
746 | STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */
747 | (void)(tmp);
748 | }
749 | #endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */
750 | /**
751 | * @}
752 | */
753 |
754 | /**
755 | * @}
756 | */
757 |
758 | /**
759 | * @}
760 | */
761 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
762 |
--------------------------------------------------------------------------------
/cifar10/RTE/Device/STM32F407VGTx/system_stm32f4xx.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f4xx.c
4 | * @author MCD Application Team
5 | * @version V1.0.0
6 | * @date 30-September-2011
7 | * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
8 | * This file contains the system clock configuration for STM32F4xx devices,
9 | * and is generated by the clock configuration tool
10 | * stm32f4xx_Clock_Configuration_V1.0.0.xls
11 | *
12 | * 1. This file provides two functions and one global variable to be called from
13 | * user application:
14 | * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
15 | * and Divider factors, AHB/APBx prescalers and Flash settings),
16 | * depending on the configuration made in the clock xls tool.
17 | * This function is called at startup just after reset and
18 | * before branch to main program. This call is made inside
19 | * the "startup_stm32f4xx.s" file.
20 | *
21 | * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
22 | * by the user application to setup the SysTick
23 | * timer or configure other parameters.
24 | *
25 | * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
26 | * be called whenever the core clock is changed
27 | * during program execution.
28 | *
29 | * 2. After each device reset the HSI (16 MHz) is used as system clock source.
30 | * Then SystemInit() function is called, in "startup_stm32f4xx.s" file, to
31 | * configure the system clock before to branch to main program.
32 | *
33 | * 3. If the system clock source selected by user fails to startup, the SystemInit()
34 | * function will do nothing and HSI still used as system clock source. User can
35 | * add some code to deal with this issue inside the SetSysClock() function.
36 | *
37 | * 4. The default value of HSE crystal is set to 8MHz, refer to "HSE_VALUE" define
38 | * in "stm32f4xx.h" file. When HSE is used as system clock source, directly or
39 | * through PLL, and you are using different crystal you have to adapt the HSE
40 | * value to your own configuration.
41 | *
42 | * 5. This file configures the system clock as follows:
43 | *=============================================================================
44 | *=============================================================================
45 | * Supported STM32F4xx device revision | Rev A
46 | *-----------------------------------------------------------------------------
47 | * System Clock source | PLL (HSE)
48 | *-----------------------------------------------------------------------------
49 | * SYSCLK(Hz) | 168000000
50 | *-----------------------------------------------------------------------------
51 | * HCLK(Hz) | 168000000
52 | *-----------------------------------------------------------------------------
53 | * AHB Prescaler | 1
54 | *-----------------------------------------------------------------------------
55 | * APB1 Prescaler | 4
56 | *-----------------------------------------------------------------------------
57 | * APB2 Prescaler | 2
58 | *-----------------------------------------------------------------------------
59 | * HSE Frequency(Hz) | 8000000
60 | *-----------------------------------------------------------------------------
61 | * PLL_M | 8
62 | *-----------------------------------------------------------------------------
63 | * PLL_N | 336
64 | *-----------------------------------------------------------------------------
65 | * PLL_P | 2
66 | *-----------------------------------------------------------------------------
67 | * PLL_Q | 7
68 | *-----------------------------------------------------------------------------
69 | * PLLI2S_N | NA
70 | *-----------------------------------------------------------------------------
71 | * PLLI2S_R | NA
72 | *-----------------------------------------------------------------------------
73 | * I2S input clock | NA
74 | *-----------------------------------------------------------------------------
75 | * VDD(V) | 3.3
76 | *-----------------------------------------------------------------------------
77 | * Main regulator output voltage | Scale1 mode
78 | *-----------------------------------------------------------------------------
79 | * Flash Latency(WS) | 5
80 | *-----------------------------------------------------------------------------
81 | * Prefetch Buffer | OFF
82 | *-----------------------------------------------------------------------------
83 | * Instruction cache | ON
84 | *-----------------------------------------------------------------------------
85 | * Data cache | ON
86 | *-----------------------------------------------------------------------------
87 | * Require 48MHz for USB OTG FS, | Enabled
88 | * SDIO and RNG clock |
89 | *-----------------------------------------------------------------------------
90 | *=============================================================================
91 | ******************************************************************************
92 | * @attention
93 | *
94 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
95 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
96 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
97 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
98 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
99 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
100 | *
101 | * © COPYRIGHT 2011 STMicroelectronics
102 | ******************************************************************************
103 | */
104 |
105 | /** @addtogroup CMSIS
106 | * @{
107 | */
108 |
109 | /** @addtogroup stm32f4xx_system
110 | * @{
111 | */
112 |
113 | /** @addtogroup STM32F4xx_System_Private_Includes
114 | * @{
115 | */
116 |
117 | #include "stm32f4xx.h"
118 |
119 | /**
120 | * @}
121 | */
122 |
123 | /** @addtogroup STM32F4xx_System_Private_TypesDefinitions
124 | * @{
125 | */
126 |
127 | /**
128 | * @}
129 | */
130 |
131 | /** @addtogroup STM32F4xx_System_Private_Defines
132 | * @{
133 | */
134 | #if !defined (HSE_VALUE)
135 | #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz */
136 | #endif /* HSE_VALUE */
137 |
138 | #if !defined (HSI_VALUE)
139 | #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
140 | #endif /* HSI_VALUE */
141 | //External High Speed oscillator (HSE) Startup Timeout value.
142 | #if !defined (HSE_STARTUP_TIMEOUT)
143 | #define HSE_STARTUP_TIMEOUT ((uint16_t)0x0500)
144 | #endif /* HSE_STARTUP_TIMEOUT */
145 | /************************* Miscellaneous Configuration ************************/
146 | /*!< Uncomment the following line if you need to use external SRAM mounted
147 | on STM324xG_EVAL board as data memory */
148 | /* #define DATA_IN_ExtSRAM */
149 |
150 | /*!< Uncomment the following line if you need to relocate your vector Table in
151 | Internal SRAM. */
152 | /* #define VECT_TAB_SRAM */
153 | #define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
154 | This value must be a multiple of 0x200. */
155 | /******************************************************************************/
156 |
157 | /************************* PLL Parameters *************************************/
158 | /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
159 | #define PLL_M 8
160 | #define PLL_N 336
161 |
162 | /* SYSCLK = PLL_VCO / PLL_P */
163 | #define PLL_P 2
164 |
165 | /* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */
166 | #define PLL_Q 7
167 |
168 | /******************************************************************************/
169 |
170 | /**
171 | * @}
172 | */
173 |
174 | /** @addtogroup STM32F4xx_System_Private_Macros
175 | * @{
176 | */
177 |
178 | /**
179 | * @}
180 | */
181 |
182 | /** @addtogroup STM32F4xx_System_Private_Variables
183 | * @{
184 | */
185 |
186 | uint32_t SystemCoreClock = 168000000;
187 |
188 | //__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
189 | const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
190 | /**
191 | * @}
192 | */
193 |
194 | /** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
195 | * @{
196 | */
197 |
198 | static void SetSysClock(void);
199 | #ifdef DATA_IN_ExtSRAM
200 | static void SystemInit_ExtMemCtl(void);
201 | #endif /* DATA_IN_ExtSRAM */
202 |
203 | /**
204 | * @}
205 | */
206 |
207 | /** @addtogroup STM32F4xx_System_Private_Functions
208 | * @{
209 | */
210 |
211 | /**
212 | * @brief Setup the microcontroller system
213 | * Initialize the Embedded Flash Interface, the PLL and update the
214 | * SystemFrequency variable.
215 | * @param None
216 | * @retval None
217 | */
218 | void SystemInit(void)
219 | {
220 | /* FPU settings ------------------------------------------------------------*/
221 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
222 | SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
223 | #endif
224 |
225 | /* Reset the RCC clock configuration to the default reset state ------------*/
226 | /* Set HSION bit */
227 | RCC->CR |= (uint32_t)0x00000001;
228 |
229 | /* Reset CFGR register */
230 | RCC->CFGR = 0x00000000;
231 |
232 | /* Reset HSEON, CSSON and PLLON bits */
233 | RCC->CR &= (uint32_t)0xFEF6FFFF;
234 |
235 | /* Reset PLLCFGR register */
236 | RCC->PLLCFGR = 0x24003010;
237 |
238 | /* Reset HSEBYP bit */
239 | RCC->CR &= (uint32_t)0xFFFBFFFF;
240 |
241 | /* Disable all interrupts */
242 | RCC->CIR = 0x00000000;
243 |
244 | #ifdef DATA_IN_ExtSRAM
245 | SystemInit_ExtMemCtl();
246 | #endif /* DATA_IN_ExtSRAM */
247 |
248 | /* Configure the System clock source, PLL Multiplier and Divider factors,
249 | AHB/APBx prescalers and Flash settings ----------------------------------*/
250 | SetSysClock();
251 |
252 | /* Configure the Vector Table location add offset address ------------------*/
253 | #ifdef VECT_TAB_SRAM
254 | SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
255 | #else
256 | SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
257 | #endif
258 | }
259 |
260 | /**
261 | * @brief Update SystemCoreClock variable according to Clock Register Values.
262 | * The SystemCoreClock variable contains the core clock (HCLK), it can
263 | * be used by the user application to setup the SysTick timer or configure
264 | * other parameters.
265 | *
266 | * @note Each time the core clock (HCLK) changes, this function must be called
267 | * to update SystemCoreClock variable value. Otherwise, any configuration
268 | * based on this variable will be incorrect.
269 | *
270 | * @note - The system frequency computed by this function is not the real
271 | * frequency in the chip. It is calculated based on the predefined
272 | * constant and the selected clock source:
273 | *
274 | * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
275 | *
276 | * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
277 | *
278 | * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
279 | * or HSI_VALUE(*) multiplied/divided by the PLL factors.
280 | *
281 | * (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value
282 | * 16 MHz) but the real value may vary depending on the variations
283 | * in voltage and temperature.
284 | *
285 | * (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value
286 | * 25 MHz), user has to ensure that HSE_VALUE is same as the real
287 | * frequency of the crystal used. Otherwise, this function may
288 | * have wrong result.
289 | *
290 | * - The result of this function could be not correct when using fractional
291 | * value for HSE crystal.
292 | *
293 | * @param None
294 | * @retval None
295 | */
296 | void SystemCoreClockUpdate(void)
297 | {
298 | uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
299 |
300 | /* Get SYSCLK source -------------------------------------------------------*/
301 | tmp = RCC->CFGR & RCC_CFGR_SWS;
302 |
303 | switch (tmp)
304 | {
305 | case 0x00: /* HSI used as system clock source */
306 | SystemCoreClock = HSI_VALUE;
307 | break;
308 | case 0x04: /* HSE used as system clock source */
309 | SystemCoreClock = HSE_VALUE;
310 | break;
311 | case 0x08: /* PLL used as system clock source */
312 |
313 | /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
314 | SYSCLK = PLL_VCO / PLL_P
315 | */
316 | pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
317 | pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
318 |
319 | if (pllsource != 0)
320 | {
321 | /* HSE used as PLL clock source */
322 | pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
323 | }
324 | else
325 | {
326 | /* HSI used as PLL clock source */
327 | pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
328 | }
329 |
330 | pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
331 | SystemCoreClock = pllvco/pllp;
332 | break;
333 | default:
334 | SystemCoreClock = HSI_VALUE;
335 | break;
336 | }
337 | /* Compute HCLK frequency --------------------------------------------------*/
338 | /* Get HCLK prescaler */
339 | tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
340 | /* HCLK frequency */
341 | SystemCoreClock >>= tmp;
342 | }
343 |
344 | /**
345 | * @brief Configures the System clock source, PLL Multiplier and Divider factors,
346 | * AHB/APBx prescalers and Flash settings
347 | * @Note This function should be called only once the RCC clock configuration
348 | * is reset to the default reset state (done in SystemInit() function).
349 | * @param None
350 | * @retval None
351 | */
352 | static void SetSysClock(void)
353 | {
354 | /******************************************************************************/
355 | /* PLL (clocked by HSE) used as System clock source */
356 | /******************************************************************************/
357 | __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
358 |
359 | /* Enable HSE */
360 | RCC->CR |= ((uint32_t)RCC_CR_HSEON);
361 |
362 | /* Wait till HSE is ready and if Time out is reached exit */
363 | do
364 | {
365 | HSEStatus = RCC->CR & RCC_CR_HSERDY;
366 | StartUpCounter++;
367 | } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
368 |
369 | if ((RCC->CR & RCC_CR_HSERDY) != RESET)
370 | {
371 | HSEStatus = (uint32_t)0x01;
372 | }
373 | else
374 | {
375 | HSEStatus = (uint32_t)0x00;
376 | }
377 |
378 | if (HSEStatus == (uint32_t)0x01)
379 | {
380 | /* Select regulator voltage output Scale 1 mode, System frequency up to 168 MHz */
381 | RCC->APB1ENR |= RCC_APB1ENR_PWREN;
382 | PWR->CR |= PWR_CR_VOS;
383 |
384 | /* HCLK = SYSCLK / 1*/
385 | RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
386 |
387 | /* PCLK2 = HCLK / 2*/
388 | RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
389 |
390 | /* PCLK1 = HCLK / 4*/
391 | RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
392 |
393 | /* Configure the main PLL */
394 | RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) |
395 | (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);
396 |
397 | /* Enable the main PLL */
398 | RCC->CR |= RCC_CR_PLLON;
399 |
400 | /* Wait till the main PLL is ready */
401 | while((RCC->CR & RCC_CR_PLLRDY) == 0)
402 | {
403 | }
404 |
405 | /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
406 | FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;
407 |
408 | /* Select the main PLL as system clock source */
409 | RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
410 | RCC->CFGR |= RCC_CFGR_SW_PLL;
411 |
412 | /* Wait till the main PLL is used as system clock source */
413 | while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
414 | {
415 | }
416 | }
417 | else
418 | { /* If HSE fails to start-up, the application will have wrong clock
419 | configuration. User can add here some code to deal with this error */
420 | }
421 |
422 | }
423 |
424 | /**
425 | * @brief Setup the external memory controller. Called in startup_stm32f4xx.s
426 | * before jump to __main
427 | * @param None
428 | * @retval None
429 | */
430 | #ifdef DATA_IN_ExtSRAM
431 | /**
432 | * @brief Setup the external memory controller.
433 | * Called in startup_stm32f4xx.s before jump to main.
434 | * This function configures the external SRAM mounted on STM324xG_EVAL board
435 | * This SRAM will be used as program data memory (including heap and stack).
436 | * @param None
437 | * @retval None
438 | */
439 | void SystemInit_ExtMemCtl(void)
440 | {
441 | /*-- GPIOs Configuration -----------------------------------------------------*/
442 | /*
443 | +-------------------+--------------------+------------------+------------------+
444 | + SRAM pins assignment +
445 | +-------------------+--------------------+------------------+------------------+
446 | | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 |
447 | | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 |
448 | | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
449 | | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
450 | | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
451 | | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
452 | | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
453 | | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+
454 | | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 |
455 | | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 |
456 | | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+
457 | | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 |
458 | | | PE15 <-> FSMC_D12 |
459 | +-------------------+--------------------+
460 | */
461 | /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
462 | RCC->AHB1ENR = 0x00000078;
463 |
464 | /* Connect PDx pins to FSMC Alternate function */
465 | GPIOD->AFR[0] = 0x00cc00cc;
466 | GPIOD->AFR[1] = 0xcc0ccccc;
467 | /* Configure PDx pins in Alternate function mode */
468 | GPIOD->MODER = 0xaaaa0a0a;
469 | /* Configure PDx pins speed to 100 MHz */
470 | GPIOD->OSPEEDR = 0xffff0f0f;
471 | /* Configure PDx pins Output type to push-pull */
472 | GPIOD->OTYPER = 0x00000000;
473 | /* No pull-up, pull-down for PDx pins */
474 | GPIOD->PUPDR = 0x00000000;
475 |
476 | /* Connect PEx pins to FSMC Alternate function */
477 | GPIOE->AFR[0] = 0xc00cc0cc;
478 | GPIOE->AFR[1] = 0xcccccccc;
479 | /* Configure PEx pins in Alternate function mode */
480 | GPIOE->MODER = 0xaaaa828a;
481 | /* Configure PEx pins speed to 100 MHz */
482 | GPIOE->OSPEEDR = 0xffffc3cf;
483 | /* Configure PEx pins Output type to push-pull */
484 | GPIOE->OTYPER = 0x00000000;
485 | /* No pull-up, pull-down for PEx pins */
486 | GPIOE->PUPDR = 0x00000000;
487 |
488 | /* Connect PFx pins to FSMC Alternate function */
489 | GPIOF->AFR[0] = 0x00cccccc;
490 | GPIOF->AFR[1] = 0xcccc0000;
491 | /* Configure PFx pins in Alternate function mode */
492 | GPIOF->MODER = 0xaa000aaa;
493 | /* Configure PFx pins speed to 100 MHz */
494 | GPIOF->OSPEEDR = 0xff000fff;
495 | /* Configure PFx pins Output type to push-pull */
496 | GPIOF->OTYPER = 0x00000000;
497 | /* No pull-up, pull-down for PFx pins */
498 | GPIOF->PUPDR = 0x00000000;
499 |
500 | /* Connect PGx pins to FSMC Alternate function */
501 | GPIOG->AFR[0] = 0x00cccccc;
502 | GPIOG->AFR[1] = 0x000000c0;
503 | /* Configure PGx pins in Alternate function mode */
504 | GPIOG->MODER = 0x00080aaa;
505 | /* Configure PGx pins speed to 100 MHz */
506 | GPIOG->OSPEEDR = 0x000c0fff;
507 | /* Configure PGx pins Output type to push-pull */
508 | GPIOG->OTYPER = 0x00000000;
509 | /* No pull-up, pull-down for PGx pins */
510 | GPIOG->PUPDR = 0x00000000;
511 |
512 | /*-- FSMC Configuration ------------------------------------------------------*/
513 | /* Enable the FSMC interface clock */
514 | RCC->AHB3ENR = 0x00000001;
515 |
516 | /* Configure and enable Bank1_SRAM2 */
517 | FSMC_Bank1->BTCR[2] = 0x00001015;
518 | FSMC_Bank1->BTCR[3] = 0x00010603;
519 | FSMC_Bank1E->BWTR[2] = 0x0fffffff;
520 | /*
521 | Bank1_SRAM2 is configured as follow:
522 |
523 | p.FSMC_AddressSetupTime = 3;
524 | p.FSMC_AddressHoldTime = 0;
525 | p.FSMC_DataSetupTime = 6;
526 | p.FSMC_BusTurnAroundDuration = 1;
527 | p.FSMC_CLKDivision = 0;
528 | p.FSMC_DataLatency = 0;
529 | p.FSMC_AccessMode = FSMC_AccessMode_A;
530 |
531 | FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
532 | FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
533 | FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM;
534 | FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
535 | FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
536 | FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
537 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
538 | FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
539 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
540 | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
541 | FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
542 | FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
543 | FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
544 | FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
545 | FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
546 | */
547 |
548 | }
549 | #endif /* DATA_IN_ExtSRAM */
550 |
551 |
552 | /**
553 | * @}
554 | */
555 |
556 | /**
557 | * @}
558 | */
559 |
560 | /**
561 | * @}
562 | */
563 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
564 |
--------------------------------------------------------------------------------
/cifar10/RTE/_ARMCM0/RTE_Components.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Auto generated Run-Time-Environment Component Configuration File
4 | * *** Do not modify ! ***
5 | *
6 | * Project: 'arm_nnexamples_cifar10'
7 | * Target: 'ARMCM0'
8 | */
9 |
10 | #ifndef RTE_COMPONENTS_H
11 | #define RTE_COMPONENTS_H
12 |
13 |
14 | /*
15 | * Define the Device Header File:
16 | */
17 | #define CMSIS_device_header "ARMCM0.h"
18 |
19 | #define RTE_Compiler_EventRecorder
20 | #define RTE_Compiler_EventRecorder_DAP
21 | #define RTE_Compiler_IO_STDOUT /* Compiler I/O: STDOUT */
22 | #define RTE_Compiler_IO_STDOUT_EVR /* Compiler I/O: STDOUT EVR */
23 |
24 | #endif /* RTE_COMPONENTS_H */
25 |
--------------------------------------------------------------------------------
/cifar10/RTE/_ARMCM3/RTE_Components.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Auto generated Run-Time-Environment Component Configuration File
4 | * *** Do not modify ! ***
5 | *
6 | * Project: 'arm_nnexamples_cifar10'
7 | * Target: 'ARMCM3'
8 | */
9 |
10 | #ifndef RTE_COMPONENTS_H
11 | #define RTE_COMPONENTS_H
12 |
13 |
14 | /*
15 | * Define the Device Header File:
16 | */
17 | #define CMSIS_device_header "ARMCM3.h"
18 |
19 | #define RTE_Compiler_IO_STDOUT /* Compiler I/O: STDOUT */
20 | #define RTE_Compiler_IO_STDOUT_ITM /* Compiler I/O: STDOUT ITM */
21 |
22 | #endif /* RTE_COMPONENTS_H */
23 |
--------------------------------------------------------------------------------
/cifar10/RTE/_ARMCM4_FP/RTE_Components.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Auto generated Run-Time-Environment Component Configuration File
4 | * *** Do not modify ! ***
5 | *
6 | * Project: 'arm_nnexamples_cifar10'
7 | * Target: 'ARMCM4_FP'
8 | */
9 |
10 | #ifndef RTE_COMPONENTS_H
11 | #define RTE_COMPONENTS_H
12 |
13 |
14 | /*
15 | * Define the Device Header File:
16 | */
17 | #define CMSIS_device_header "stm32f4xx.h"
18 |
19 | #define RTE_Compiler_IO_STDOUT /* Compiler I/O: STDOUT */
20 | #define RTE_Compiler_IO_STDOUT_ITM /* Compiler I/O: STDOUT ITM */
21 | #define RTE_DEVICE_STARTUP_STM32F4XX /* Device Startup for STM32F4 */
22 |
23 | #endif /* RTE_COMPONENTS_H */
24 |
--------------------------------------------------------------------------------
/cifar10/RTE/_ARMCM7_SP/RTE_Components.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Auto generated Run-Time-Environment Component Configuration File
4 | * *** Do not modify ! ***
5 | *
6 | * Project: 'arm_nnexamples_cifar10'
7 | * Target: 'ARMCM7_SP'
8 | */
9 |
10 | #ifndef RTE_COMPONENTS_H
11 | #define RTE_COMPONENTS_H
12 |
13 |
14 | /*
15 | * Define the Device Header File:
16 | */
17 | #define CMSIS_device_header "ARMCM7_SP.h"
18 |
19 | #define RTE_Compiler_IO_STDOUT /* Compiler I/O: STDOUT */
20 | #define RTE_Compiler_IO_STDOUT_ITM /* Compiler I/O: STDOUT ITM */
21 |
22 | #endif /* RTE_COMPONENTS_H */
23 |
--------------------------------------------------------------------------------
/cifar10/RTE/_STM32F407DISCO/RTE_Components.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Auto generated Run-Time-Environment Component Configuration File
4 | * *** Do not modify ! ***
5 | *
6 | * Project: 'arm_nnexamples_cifar10'
7 | * Target: 'STM32F407DISCO'
8 | */
9 |
10 | #ifndef RTE_COMPONENTS_H
11 | #define RTE_COMPONENTS_H
12 |
13 |
14 | /*
15 | * Define the Device Header File:
16 | */
17 | #define CMSIS_device_header "stm32f4xx.h"
18 |
19 | #define RTE_Compiler_IO_STDOUT /* Compiler I/O: STDOUT */
20 | #define RTE_Compiler_IO_STDOUT_ITM /* Compiler I/O: STDOUT ITM */
21 | #define RTE_DEVICE_STARTUP_STM32F4XX /* Device Startup for STM32F4 */
22 |
23 | #endif /* RTE_COMPONENTS_H */
24 |
--------------------------------------------------------------------------------
/cifar10/arm_nnexamples_cifar10.cpp:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------
2 | * Copyright (C) 2010-2018 Arm Limited. All rights reserved.
3 | *
4 | *
5 | * Project: CMSIS NN Library
6 | * Title: arm_nnexamples_cifar10.cpp
7 | *
8 | * Description: Convolutional Neural Network Example
9 | *
10 | * Target Processor: Cortex-M4/Cortex-M7
11 | *
12 | * Redistribution and use in source and binary forms, with or without
13 | * modification, are permitted provided that the following conditions
14 | * are met:
15 | * - Redistributions of source code must retain the above copyright
16 | * notice, this list of conditions and the following disclaimer.
17 | * - Redistributions in binary form must reproduce the above copyright
18 | * notice, this list of conditions and the following disclaimer in
19 | * the documentation and/or other materials provided with the
20 | * distribution.
21 | * - Neither the name of Arm LIMITED nor the names of its contributors
22 | * may be used to endorse or promote products derived from this
23 | * software without specific prior written permission.
24 | *
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 | * POSSIBILITY OF SUCH DAMAGE.
37 | * -------------------------------------------------------------------- */
38 |
39 | /**
40 | * @ingroup groupExamples
41 | */
42 |
43 | /**
44 | * @defgroup CNNExample Convolutional Neural Network Example
45 | *
46 | * \par Description:
47 | * \par
48 | * Demonstrates a convolutional neural network (CNN) example with the use of convolution,
49 | * ReLU activation, pooling and fully-connected functions.
50 | *
51 | * \par Model definition:
52 | * \par
53 | * The CNN used in this example is based on CIFAR-10 example from Caffe [1].
54 | * The neural network consists
55 | * of 3 convolution layers interspersed by ReLU activation and max pooling layers, followed by a
56 | * fully-connected layer at the end. The input to the network is a 32x32 pixel color image, which will
57 | * be classified into one of the 10 output classes.
58 | * This example model implementation needs 32.3 KB to store weights, 40 KB for activations and
59 | * 3.1 KB for storing the \c im2col data.
60 | *
61 | * \image html CIFAR10_CNN.gif "Neural Network model definition"
62 | *
63 | * \par Variables Description:
64 | * \par
65 | * \li \c conv1_wt, \c conv2_wt, \c conv3_wt are convolution layer weight matrices
66 | * \li \c conv1_bias, \c conv2_bias, \c conv3_bias are convolution layer bias arrays
67 | * \li \c ip1_wt, ip1_bias point to fully-connected layer weights and biases
68 | * \li \c image_data points to the input image data
69 | * \li \c output_data points to the classification output
70 | * \li \c col_buffer is a buffer to store the \c im2col output
71 | * \li \c scratch_buffer is used to store the activation data (intermediate layer outputs)
72 | *
73 | * \par CMSIS DSP Software Library Functions Used:
74 | * \par
75 | * - arm_convolve_HWC_q7_RGB()
76 | * - arm_convolve_HWC_q7_fast()
77 | * - arm_relu_q7()
78 | * - arm_maxpool_q7_HWC()
79 | * - arm_avepool_q7_HWC()
80 | * - arm_fully_connected_q7_opt()
81 | * - arm_fully_connected_q7()
82 | *
83 | * Refer
84 | * \link arm_nnexamples_cifar10.cpp \endlink
85 | *
86 | * \par [1] https://github.com/BVLC/caffe
87 | */
88 |
89 | #include
90 | #include
91 | #include "arm_math.h"
92 | #include "arm_nnexamples_cifar10_parameter.h"
93 | #include "arm_nnexamples_cifar10_weights.h"
94 |
95 | #include "arm_nnfunctions.h"
96 | #include "arm_nnexamples_cifar10_inputs.h"
97 |
98 | #ifdef _RTE_
99 | #include "RTE_Components.h"
100 | #ifdef RTE_Compiler_EventRecorder
101 | #include "EventRecorder.h"
102 | #endif
103 | #endif
104 |
105 | // include the input and weights
106 |
107 | static q7_t conv1_wt[CONV1_IM_CH * CONV1_KER_DIM * CONV1_KER_DIM * CONV1_OUT_CH] = CONV1_WT;
108 | static q7_t conv1_bias[CONV1_OUT_CH] = CONV1_BIAS;
109 |
110 | static q7_t conv2_wt[CONV2_IM_CH * CONV2_KER_DIM * CONV2_KER_DIM * CONV2_OUT_CH] = CONV2_WT;
111 | static q7_t conv2_bias[CONV2_OUT_CH] = CONV2_BIAS;
112 |
113 | static q7_t conv3_wt[CONV3_IM_CH * CONV3_KER_DIM * CONV3_KER_DIM * CONV3_OUT_CH] = CONV3_WT;
114 | static q7_t conv3_bias[CONV3_OUT_CH] = CONV3_BIAS;
115 |
116 | static q7_t ip1_wt[IP1_DIM * IP1_OUT] = IP1_WT;
117 | static q7_t ip1_bias[IP1_OUT] = IP1_BIAS;
118 |
119 | /* Here the image_data should be the raw uint8 type RGB image in [RGB, RGB, RGB ... RGB] format */
120 | uint8_t image_data[CONV1_IM_CH * CONV1_IM_DIM * CONV1_IM_DIM] = IMG_DATA;
121 | q7_t output_data[IP1_OUT];
122 |
123 | //vector buffer: max(im2col buffer,average pool buffer, fully connected buffer)
124 | q7_t col_buffer[2 * 5 * 5 * 32 * 2];
125 |
126 | q7_t scratch_buffer[32 * 32 * 10 * 4];
127 |
128 | int main()
129 | {
130 | #ifdef RTE_Compiler_EventRecorder
131 | EventRecorderInitialize (EventRecordAll, 1); // initialize and start Event Recorder
132 | #endif
133 |
134 | printf("start execution\n");
135 | /* start the execution */
136 |
137 | q7_t *img_buffer1 = scratch_buffer;
138 | q7_t *img_buffer2 = img_buffer1 + 32 * 32 * 32;
139 |
140 | /* input pre-processing */
141 | int mean_data[3] = INPUT_MEAN_SHIFT;
142 | unsigned int scale_data[3] = INPUT_RIGHT_SHIFT;
143 | for (int i=0;i<32*32*3; i+=3) {
144 | img_buffer2[i] = (q7_t)__SSAT( ((((int)image_data[i] - mean_data[0])<<7) + (0x1<<(scale_data[0]-1)))
145 | >> scale_data[0], 8);
146 | img_buffer2[i+1] = (q7_t)__SSAT( ((((int)image_data[i+1] - mean_data[1])<<7) + (0x1<<(scale_data[1]-1)))
147 | >> scale_data[1], 8);
148 | img_buffer2[i+2] = (q7_t)__SSAT( ((((int)image_data[i+2] - mean_data[2])<<7) + (0x1<<(scale_data[2]-1)))
149 | >> scale_data[2], 8);
150 | }
151 |
152 | // conv1 img_buffer2 -> img_buffer1
153 | arm_convolve_HWC_q7_RGB(img_buffer2, CONV1_IM_DIM, CONV1_IM_CH, conv1_wt, CONV1_OUT_CH, CONV1_KER_DIM, CONV1_PADDING,
154 | CONV1_STRIDE, conv1_bias, CONV1_BIAS_LSHIFT, CONV1_OUT_RSHIFT, img_buffer1, CONV1_OUT_DIM,
155 | (q15_t *) col_buffer, NULL);
156 |
157 | arm_relu_q7(img_buffer1, CONV1_OUT_DIM * CONV1_OUT_DIM * CONV1_OUT_CH);
158 |
159 | // pool1 img_buffer1 -> img_buffer2
160 | arm_maxpool_q7_HWC(img_buffer1, CONV1_OUT_DIM, CONV1_OUT_CH, POOL1_KER_DIM,
161 | POOL1_PADDING, POOL1_STRIDE, POOL1_OUT_DIM, NULL, img_buffer2);
162 |
163 | // conv2 img_buffer2 -> img_buffer1
164 | arm_convolve_HWC_q7_fast(img_buffer2, CONV2_IM_DIM, CONV2_IM_CH, conv2_wt, CONV2_OUT_CH, CONV2_KER_DIM,
165 | CONV2_PADDING, CONV2_STRIDE, conv2_bias, CONV2_BIAS_LSHIFT, CONV2_OUT_RSHIFT, img_buffer1,
166 | CONV2_OUT_DIM, (q15_t *) col_buffer, NULL);
167 |
168 | arm_relu_q7(img_buffer1, CONV2_OUT_DIM * CONV2_OUT_DIM * CONV2_OUT_CH);
169 |
170 | // pool2 img_buffer1 -> img_buffer2
171 | arm_maxpool_q7_HWC(img_buffer1, CONV2_OUT_DIM, CONV2_OUT_CH, POOL2_KER_DIM,
172 | POOL2_PADDING, POOL2_STRIDE, POOL2_OUT_DIM, col_buffer, img_buffer2);
173 |
174 | // conv3 img_buffer2 -> img_buffer1
175 | arm_convolve_HWC_q7_fast(img_buffer2, CONV3_IM_DIM, CONV3_IM_CH, conv3_wt, CONV3_OUT_CH, CONV3_KER_DIM,
176 | CONV3_PADDING, CONV3_STRIDE, conv3_bias, CONV3_BIAS_LSHIFT, CONV3_OUT_RSHIFT, img_buffer1,
177 | CONV3_OUT_DIM, (q15_t *) col_buffer, NULL);
178 |
179 | arm_relu_q7(img_buffer1, CONV3_OUT_DIM * CONV3_OUT_DIM * CONV3_OUT_CH);
180 |
181 | // pool3 img_buffer-> img_buffer2
182 | arm_maxpool_q7_HWC(img_buffer1, CONV3_OUT_DIM, CONV3_OUT_CH, POOL3_KER_DIM,
183 | POOL3_PADDING, POOL3_STRIDE, POOL3_OUT_DIM, col_buffer, img_buffer2);
184 |
185 | arm_fully_connected_q7_opt(img_buffer2, ip1_wt, IP1_DIM, IP1_OUT, IP1_BIAS_LSHIFT, IP1_OUT_RSHIFT, ip1_bias,
186 | output_data, (q15_t *) img_buffer1);
187 |
188 | arm_softmax_q7(output_data, 10, output_data);
189 |
190 | for (int i = 0; i < 10; i++)
191 | {
192 | printf("%d: %d\n", i, output_data[i]);
193 | }
194 |
195 | return 0;
196 | }
197 |
--------------------------------------------------------------------------------
/cifar10/arm_nnexamples_cifar10_inputs.h:
--------------------------------------------------------------------------------
1 | /* Here are two different test images */
2 | //#define IMG_DATA {158,112,49,159,111,47,165,116,51,166,118,53,160,112,46,156,109,41,162,115,47,159,113,45,158,111,44,159,113,41,161,116,41,160,111,52,161,111,49,166,117,41,169,117,45,170,119,44,167,117,40,162,113,38,160,111,39,160,112,43,156,109,44,149,107,45,150,107,45,148,106,43,149,107,44,143,101,39,140,98,43,141,97,41,143,97,38,137,95,36,126,91,36,116,85,33,152,112,51,151,110,40,159,114,45,166,116,56,162,112,49,160,113,43,164,117,47,162,114,45,163,116,46,156,110,38,155,111,41,159,110,54,163,113,52,170,119,41,171,117,40,171,115,33,169,115,30,160,111,33,154,112,41,151,115,50,145,110,53,139,104,55,140,102,52,141,100,48,149,105,50,147,102,46,145,102,45,142,97,38,143,98,34,136,95,31,125,91,32,119,88,34,151,110,47,151,109,33,158,111,36,167,111,48,160,106,42,163,115,44,165,117,45,165,117,45,163,115,43,162,115,43,158,114,48,157,109,57,161,111,51,166,115,38,167,114,37,169,113,35,170,116,39,159,114,47,145,111,54,121,96,49,110,90,52,98,78,50,101,77,47,114,85,50,120,86,48,134,96,55,143,103,51,140,99,39,142,99,35,139,98,34,130,95,34,120,89,33,155,107,40,155,110,32,160,109,31,174,112,44,167,110,43,167,117,46,169,120,48,169,119,48,165,115,44,165,117,45,167,123,57,191,146,95,177,130,75,157,111,41,162,115,47,164,114,54,158,112,58,149,111,67,104,80,47,103,87,65,98,90,76,92,90,84,80,75,66,74,63,50,86,70,52,83,62,39,113,85,45,132,98,46,140,102,43,140,101,39,136,99,39,127,94,36,155,107,41,156,114,48,161,115,49,170,114,47,169,114,43,163,113,40,169,120,47,166,116,44,164,113,41,164,116,42,173,128,59,246,214,164,195,156,107,151,114,56,146,111,60,142,108,71,111,80,50,78,53,31,85,69,56,113,103,98,112,110,111,106,114,118,97,102,105,93,94,93,74,72,67,84,78,70,85,73,47,105,83,45,128,96,48,138,101,46,133,94,36,129,93,36,148,109,54,133,104,64,130,100,57,147,112,53,161,115,44,165,113,39,167,116,41,167,115,41,163,111,37,165,116,39,163,118,42,180,138,85,157,122,78,128,102,58,97,75,43,66,50,31,69,58,43,66,56,45,89,83,76,118,113,110,122,121,120,119,122,122,114,116,116,94,96,96,99,100,97,91,91,86,58,58,47,67,58,37,108,84,49,140,105,58,138,98,44,134,95,40,127,100,57,109,95,80,47,37,17,88,74,28,153,117,48,170,118,43,168,115,40,170,118,43,169,117,42,166,116,37,164,120,39,147,107,52,129,98,59,127,108,75,100,87,70,68,67,57,78,83,72,72,75,64,83,84,74,132,130,121,146,142,132,124,118,108,105,99,90,107,102,94,115,111,103,85,83,77,63,71,69,46,47,39,79,61,36,132,98,58,141,99,48,134,93,39,131,115,90,99,96,92,42,43,38,70,64,41,143,111,56,167,117,42,165,114,36,168,116,39,171,119,49,161,113,51,140,109,51,120,94,49,130,110,77,144,131,107,116,106,93,88,87,79,91,95,88,85,88,82,77,77,69,124,118,107,163,153,140,136,124,112,102,93,81,106,98,88,100,93,84,85,81,74,54,60,58,49,53,49,57,47,32,107,83,50,138,103,51,136,97,39,170,161,144,103,105,105,54,58,59,124,121,113,153,124,82,161,113,43,163,117,41,166,122,50,165,121,66,174,135,95,113,89,59,125,105,78,157,141,121,156,143,128,121,111,101,86,80,74,82,81,77,84,85,82,80,78,73,81,71,61,138,125,112,146,135,123,113,103,93,87,79,70,83,77,69,86,82,76,71,73,67,56,57,53,40,35,27,74,59,35,133,106,59,137,103,45,180,176,163,134,139,143,94,100,105,154,154,149,174,149,112,158,116,51,156,116,47,153,118,60,207,180,146,237,214,198,207,180,166,156,131,119,174,153,145,148,131,125,125,110,107,93,85,79,86,84,79,74,74,71,59,57,53,76,68,58,137,125,112,143,133,122,133,124,114,106,98,89,86,81,74,87,85,78,84,85,78,75,76,71,50,49,43,40,30,15,95,75,44,132,103,57,183,183,175,108,116,122,142,151,158,165,169,168,177,156,122,155,112,50,159,118,51,122,89,47,213,197,179,237,224,226,220,191,188,164,135,131,183,159,155,156,137,132,125,108,104,120,111,104,78,76,69,80,80,77,45,44,40,91,85,77,175,165,154,157,147,137,155,147,138,107,100,92,87,83,77,103,102,96,88,88,79,78,79,73,59,59,59,41,36,33,59,46,31,104,81,46,188,191,189,100,108,116,135,144,153,170,175,178,187,167,136,166,120,59,173,123,55,134,93,44,117,95,80,194,182,188,199,171,164,170,142,133,185,161,151,189,171,159,134,119,106,117,107,95,102,98,89,84,84,79,38,38,34,125,121,113,210,201,192,160,152,142,146,139,130,93,89,82,83,80,75,94,93,88,104,104,94,85,87,81,73,75,78,55,53,55,62,55,48,76,56,26,189,194,194,90,96,105,127,134,144,175,180,185,174,156,133,166,123,68,178,123,53,159,109,47,97,68,44,168,154,152,168,144,126,137,114,94,186,166,148,216,202,183,160,149,129,123,113,98,120,114,105,115,114,109,50,50,47,150,147,140,194,187,178,155,149,140,123,118,111,91,88,83,84,83,79,84,84,80,95,95,85,86,87,81,84,87,89,73,73,73,79,74,64,73,55,24,189,192,193,93,95,103,152,154,163,185,188,192,119,110,98,136,106,66,173,124,58,167,116,50,103,72,39,147,132,120,145,125,103,167,149,127,189,174,155,226,216,200,180,172,157,141,131,117,126,117,107,117,114,109,71,71,68,154,152,147,186,181,174,149,144,136,114,110,104,87,85,80,80,80,76,72,73,70,80,80,72,99,100,94,100,101,99,90,88,81,97,89,69,94,73,34,194,196,196,108,107,112,168,167,172,186,186,188,105,109,109,99,89,67,156,119,62,167,122,55,100,74,34,115,106,88,138,123,103,198,185,169,190,180,169,172,165,159,145,140,140,154,143,134,146,136,125,103,100,95,71,71,70,152,152,149,179,175,170,137,133,127,130,128,122,110,109,105,85,86,83,91,93,91,95,96,90,109,110,104,115,116,111,100,96,80,97,85,53,117,95,47,197,197,197,132,129,136,172,167,174,184,178,181,130,137,142,78,83,77,140,120,88,155,125,77,115,94,52,130,120,93,143,131,116,230,221,211,242,236,230,145,138,137,135,130,130,131,121,112,121,112,101,108,104,95,95,88,75,144,134,118,168,159,146,152,147,138,112,108,101,87,85,80,71,72,68,87,88,87,105,104,99,112,109,99,120,110,93,103,86,54,121,96,48,136,104,48,203,203,204,146,146,160,168,164,178,191,182,188,168,170,172,78,86,90,126,125,126,138,126,113,138,121,82,96,80,37,154,143,133,173,163,155,162,152,141,140,132,117,113,106,88,113,106,90,101,101,92,105,101,87,112,90,58,171,143,104,156,138,109,148,141,126,135,130,118,109,105,97,78,76,72,79,79,77,94,93,94,101,91,82,107,83,55,125,88,45,151,108,55,144,104,46,214,215,215,163,166,180,164,167,184,183,184,194,176,182,186,94,102,105,96,96,102,156,149,145,148,137,111,106,93,61,129,116,105,118,105,95,114,102,89,116,105,89,102,91,73,115,110,98,86,91,88,101,103,95,144,128,102,118,96,64,68,56,32,128,120,105,133,126,115,75,69,61,60,56,51,58,56,53,71,70,65,102,93,78,116,94,64,143,112,68,150,116,64,140,110,54,212,211,205,178,184,192,167,175,189,173,181,193,176,184,188,124,131,133,86,88,96,141,139,143,153,148,141,135,128,111,104,90,80,77,64,55,134,121,108,124,111,96,129,117,100,147,143,133,85,92,93,92,96,93,150,139,120,132,117,93,117,109,92,107,99,86,75,68,58,64,59,52,44,41,39,65,62,60,86,69,40,133,105,59,155,119,62,160,120,54,154,115,45,151,111,46,199,192,180,187,189,187,171,176,181,174,179,185,177,182,184,144,149,152,86,90,99,119,121,132,122,124,130,137,136,135,144,134,126,70,59,51,129,118,108,108,97,86,145,134,123,184,176,168,116,118,118,73,75,73,131,119,103,137,124,105,134,129,118,89,86,78,51,49,44,52,51,50,47,49,52,90,90,93,121,91,60,163,118,68,171,121,64,164,113,52,158,111,50,149,107,46,165,156,146,195,193,187,179,178,175,177,173,172,181,181,180,152,157,160,99,103,111,131,135,146,171,175,185,103,105,111,93,90,87,80,77,73,93,90,86,122,118,116,178,173,173,191,182,177,150,148,148,100,100,101,89,78,66,87,77,63,60,61,57,46,52,54,38,46,51,24,33,41,46,57,69,60,71,83,108,100,75,144,125,82,144,123,76,128,109,61,127,113,69,120,105,63,117,120,124,195,200,200,177,178,176,178,169,168,181,179,179,138,144,147,83,87,91,150,153,159,245,247,250,219,222,225,133,140,144,134,141,147,149,156,164,176,182,192,190,196,208,194,192,197,168,172,181,125,133,143,110,109,109,61,62,62,35,49,58,34,54,68,49,70,87,58,81,102,61,85,110,58,84,111,69,99,122,72,101,119,78,104,120,69,96,112,59,92,112,55,90,115,79,105,133,175,197,213,174,183,192,176,172,177,177,177,182,140,146,150,109,112,113,211,211,209,253,252,247,252,253,252,208,224,232,124,143,157,114,132,149,124,141,162,116,133,156,122,133,152,104,124,148,68,93,119,68,87,104,60,82,101,52,84,111,50,84,110,51,85,115,56,93,125,56,94,131,51,91,130,43,96,135,51,104,141,59,108,142,48,97,132,43,97,137,42,95,132,41,89,135,96,137,168,144,168,188,168,174,188,178,182,192,165,170,174,165,166,164,246,245,237,253,251,241,227,231,228,110,136,153,60,88,111,53,80,105,49,76,105,49,75,107,48,72,101,45,79,115,42,81,120,46,81,113,42,82,116,38,86,125,46,90,125,46,89,126,43,87,128,42,89,132,46,93,139,46,94,137,50,96,137,55,96,135,53,94,134,51,95,139,45,90,133,29,91,141,29,87,130,59,102,134,131,153,176,166,179,191,132,136,137,194,189,181,254,250,242,241,245,245,141,159,175,61,94,127,50,84,118,50,84,119,51,85,121,49,83,120,50,84,116,47,86,117,42,84,117,39,82,115,34,79,113,35,83,120,39,86,125,38,85,125,42,89,130,45,92,134,56,103,145,62,103,142,59,101,142,56,102,146,50,99,144,46,94,140,51,103,149,48,111,162,30,94,140,34,85,124,73,106,136,128,148,167,128,136,143,215,213,209,255,253,249,187,198,205,66,93,118,54,91,128,50,88,125,52,90,127,52,90,127,46,83,121,45,82,115,43,82,113,41,81,112,36,80,113,39,83,117,40,86,123,40,89,131,43,92,134,46,95,138,59,108,150,62,110,152,64,109,147,59,108,149,54,108,154,50,105,152,70,123,167,83,137,182,52,114,165,35,99,147,31,86,130,41,83,122,66,95,126,128,145,164,224,229,234,240,245,247,124,143,153,58,92,114,49,87,123,56,94,131,54,92,129,44,82,119,44,82,119,47,83,119,46,84,119,43,83,119,43,86,123,44,88,127,44,90,131,45,97,141,54,106,150,58,110,154,54,105,150,46,97,141,43,95,140,36,91,138,51,108,158,73,130,178,85,138,182,76,125,169,50,110,162,35,98,149,29,89,138,35,86,133,44,83,126,78,106,138,202,219,233,211,228,234,97,126,140,65,104,126,54,94,129,48,87,124,58,97,133,48,87,123,40,80,116,45,82,119,47,84,122,48,87,126,47,89,130,46,89,132,51,97,140,39,92,138,39,93,139,48,102,148,47,101,147,39,93,139,28,85,133,40,101,153,67,129,182,67,126,176,46,98,142,51,96,139,50,108,161,35,97,147,32,92,143,33,88,141,41,88,138,46,84,125,104,133,159,170,197,211,64,100,119,54,97,121,52,94,128,53,95,130,61,103,139,58,100,135,54,96,131,45,83,120,42,79,118,41,80,120,46,88,130,49,92,135,46,92,136,42,95,139,40,93,138,39,92,136,37,90,135,40,93,138,44,102,151,63,125,178,47,110,164,31,90,140,15,60,103,51,93,136,68,124,177,42,100,148,31,88,137,38,91,146,37,87,139,43,89,132,42,79,113,71,107,133,49,89,114,31,77,105,27,71,105,38,82,117,49,93,128,56,100,135,58,102,137,53,92,128,56,94,131,60,99,137,57,99,139,53,97,138,50,95,137,45,94,136,39,88,131,33,83,125,42,91,133,62,112,154,79,132,179,73,131,181,56,116,168,38,97,146,13,64,108,40,85,127,61,116,168,49,102,148,35,85,132,43,91,143,39,90,139,42,92,134,44,88,125,40,81,112,42,85,115,27,72,104,23,67,102,30,74,109,27,71,106,29,73,108,36,80,115,47,86,120,56,95,128,62,101,135,66,109,144,75,119,156,69,113,152,49,95,134,43,88,127,43,88,127,60,105,144,85,130,170,109,156,197,93,145,190,60,115,164,26,82,130,29,82,126,20,64,107,54,107,160,56,105,149,45,89,132,43,86,134,40,89,134,40,92,132,40,87,123,38,81,115,36,79,114,26,69,105,22,66,101,29,73,108,25,69,104,29,73,108,19,63,98,18,58,89,32,70,100,47,87,118,61,104,137,74,119,152,66,111,145,53,96,131,52,95,130,45,87,123,67,109,145,89,131,167,105,146,182,89,135,175,48,99,145,24,77,124,34,84,129,21,67,110}
3 | //#define IMG_DATA {235,235,235,231,231,231,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,232,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,232,233,233,231,233,232,231,233,231,233,233,230,233,232,232,232,234,232,231,234,232,232,232,233,233,230,232,233,231,233,233,233,232,232,232,232,232,232,232,232,232,233,233,233,233,233,233,232,232,232,238,238,238,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,237,234,233,236,234,233,236,236,234,234,236,234,234,235,237,234,234,238,235,236,237,236,236,235,236,236,234,236,236,236,235,235,235,235,235,235,235,235,235,236,236,236,236,236,236,235,235,235,237,237,237,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,235,235,235,235,234,234,236,233,231,236,234,231,235,235,234,234,235,236,227,230,233,231,235,238,231,233,235,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,235,235,235,235,235,235,234,234,234,238,238,238,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,235,235,235,235,235,234,233,233,230,232,232,231,228,230,232,223,226,231,186,192,197,209,216,219,207,210,213,228,228,230,236,235,235,234,234,234,234,234,234,234,234,234,234,234,234,235,235,235,235,235,235,235,235,235,237,237,237,234,234,234,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,234,234,234,234,234,234,235,235,235,235,235,235,234,234,234,234,234,234,235,235,235,235,235,235,236,238,236,233,237,237,219,225,230,203,210,219,163,172,179,195,205,208,214,218,221,230,229,232,237,235,237,235,235,235,235,235,235,235,235,235,235,236,236,236,236,236,236,236,236,236,236,236,239,239,238,236,235,235,236,235,235,236,235,235,236,235,235,236,235,235,235,236,235,235,235,235,234,234,234,235,235,235,237,236,236,237,236,236,234,235,236,232,233,234,235,237,237,229,231,232,208,216,218,194,205,210,185,198,207,174,188,200,165,179,189,184,196,202,207,215,220,226,228,232,236,235,237,236,236,235,236,236,235,236,236,235,236,236,236,237,237,237,237,237,237,237,237,237,228,229,229,228,227,228,232,230,231,231,228,230,234,232,233,237,236,236,237,237,235,236,237,235,237,235,236,237,235,236,239,236,237,239,237,238,225,229,230,224,228,229,233,237,238,221,226,228,183,197,204,161,180,190,159,180,191,154,176,190,144,163,177,143,159,171,156,169,177,198,206,211,233,238,239,236,237,234,235,236,233,235,235,235,235,236,236,236,238,237,237,237,237,239,237,238,212,220,222,224,230,233,230,234,238,227,232,234,229,234,234,234,237,236,237,238,235,238,237,236,239,237,238,239,237,238,239,236,237,240,238,239,201,204,203,219,222,221,233,236,235,214,218,218,193,204,210,185,201,210,184,201,211,173,191,203,165,182,196,159,174,187,162,176,185,186,199,204,229,239,240,234,239,238,233,238,237,233,238,238,234,239,238,236,239,238,237,239,238,238,238,238,216,234,241,221,236,243,225,238,246,225,239,243,227,240,240,231,238,237,236,237,235,238,236,235,238,236,237,238,236,237,237,237,237,239,239,239,197,198,196,220,221,218,233,234,231,230,231,229,209,213,217,209,216,222,219,228,235,208,218,227,209,221,234,210,224,235,217,233,240,218,235,241,225,240,243,228,238,240,228,239,240,230,240,240,230,240,239,235,240,239,237,240,239,238,238,238,118,140,149,119,138,148,124,142,153,136,155,161,172,188,191,225,234,233,235,236,233,237,234,232,236,233,234,235,235,235,235,237,236,233,237,235,214,216,214,226,228,226,232,234,232,236,237,236,228,230,232,227,230,235,231,236,241,225,232,239,225,237,247,217,233,243,201,219,226,185,204,211,172,189,195,167,179,186,167,180,185,186,199,201,223,235,235,235,241,239,236,240,239,238,240,239,109,130,141,103,121,133,108,125,137,111,127,137,146,159,165,222,229,231,227,228,225,229,226,224,236,232,233,234,234,234,231,236,234,230,237,235,229,234,235,231,235,236,232,237,238,230,235,236,231,236,238,231,237,240,229,237,241,223,232,238,191,206,213,164,184,191,146,165,172,137,156,163,134,149,159,128,140,153,121,133,143,149,162,166,216,228,229,234,241,239,235,240,238,237,240,239,195,212,224,188,202,215,199,211,224,200,211,223,209,217,227,223,227,231,213,213,211,211,209,206,216,213,214,220,222,222,219,226,225,210,221,219,209,219,223,211,221,225,216,225,230,220,229,233,225,234,237,226,236,239,225,237,241,218,231,237,183,204,208,175,198,203,181,200,207,178,194,202,186,197,211,170,178,196,142,151,164,185,195,202,219,230,233,231,240,238,234,241,239,236,240,239,193,207,222,191,202,217,202,211,224,214,217,234,223,225,241,214,219,227,203,208,208,171,174,174,177,180,183,207,213,214,174,184,188,98,112,121,93,114,126,101,121,132,111,129,139,122,138,147,137,152,161,153,167,174,202,216,220,223,236,237,218,232,235,220,233,238,223,234,240,217,226,233,221,228,237,212,219,229,196,203,212,222,230,237,219,227,234,221,230,233,232,239,242,235,241,242,113,130,152,111,125,147,113,125,141,125,131,151,138,145,165,170,182,193,191,201,205,190,199,204,208,219,226,216,230,234,158,172,183,54,71,92,45,70,91,49,73,91,53,73,90,66,84,98,102,114,129,159,168,179,221,227,233,234,239,241,233,237,241,227,231,237,223,228,233,207,211,217,202,208,212,211,218,220,212,219,223,199,206,214,179,186,196,188,197,205,211,221,227,221,231,234,61,81,108,69,86,114,63,79,100,68,85,102,123,141,155,139,155,164,151,157,164,195,200,207,214,228,234,206,223,228,163,180,190,103,121,138,95,112,131,101,117,135,138,151,168,181,192,207,207,212,223,221,222,232,219,219,227,205,203,212,183,186,195,158,166,174,147,154,163,131,138,147,125,133,140,130,139,144,136,146,152,133,142,151,128,137,147,138,153,160,182,197,203,197,212,216,40,53,77,58,70,94,85,98,116,127,144,153,132,151,156,96,107,110,119,115,118,163,158,161,173,180,182,184,194,197,182,194,198,181,193,200,183,194,202,198,209,217,218,228,236,200,210,217,174,181,186,159,165,172,145,150,159,132,136,149,116,125,138,98,111,123,94,106,118,99,111,123,105,118,128,107,121,130,122,135,145,138,151,161,150,164,174,157,174,184,188,206,213,185,203,208,13,15,35,26,29,47,134,140,151,206,216,220,138,150,150,118,123,123,141,133,134,172,162,162,181,181,180,207,209,211,220,224,225,228,234,233,224,234,232,230,241,240,226,238,238,176,189,190,144,159,163,138,154,162,142,158,170,145,163,177,154,171,187,149,165,182,149,165,182,154,171,187,157,174,189,160,177,191,173,190,204,187,204,217,190,207,218,178,196,208,165,183,193,157,175,183,5,5,24,58,62,79,200,207,217,225,232,239,197,205,212,199,207,211,212,212,218,226,224,229,229,230,237,233,236,246,232,238,245,230,238,239,209,221,220,223,238,239,221,238,241,210,228,234,198,217,228,180,200,214,193,216,230,188,213,229,189,212,231,194,214,234,192,212,232,184,204,224,172,193,212,171,191,209,161,181,197,144,165,179,136,156,169,131,146,161,128,143,158,138,154,165,39,45,71,145,155,179,190,204,222,186,196,216,184,197,217,192,211,229,194,211,230,194,208,227,194,206,227,191,203,228,192,207,228,190,207,221,177,193,207,180,198,215,154,176,193,147,169,188,145,161,184,156,171,195,146,163,186,113,133,156,114,137,161,132,157,180,126,150,173,111,135,158,92,115,138,91,112,135,93,114,133,94,116,131,105,125,140,121,133,151,129,141,158,129,142,156,122,135,161,162,179,207,143,160,194,137,154,189,131,152,187,128,152,190,127,150,192,130,150,193,131,150,192,128,147,190,127,147,189,129,149,189,129,149,188,124,145,186,104,126,163,100,122,154,102,120,154,118,134,170,112,128,163,94,109,145,94,112,148,94,117,153,87,112,144,83,103,136,80,97,130,83,103,134,93,111,139,101,117,141,108,121,144,115,125,146,121,133,148,130,144,156,73,87,109,76,90,113,77,90,122,80,93,127,84,98,134,87,102,142,87,102,147,90,105,150,94,111,152,102,119,160,107,124,165,113,131,172,115,137,181,118,136,186,118,132,180,120,133,175,115,136,172,110,133,168,106,127,163,100,119,155,95,109,148,85,101,139,79,97,132,80,92,127,80,94,129,77,100,133,80,100,129,82,98,122,92,104,126,113,119,138,125,135,146,136,149,156,13,25,41,3,11,25,9,16,35,18,26,48,18,26,52,21,25,56,20,25,58,22,30,61,26,36,62,34,43,70,42,51,77,48,59,87,52,69,106,60,75,121,66,77,126,70,79,126,71,87,127,72,88,126,67,81,120,60,72,112,55,67,106,53,68,104,53,69,103,57,69,102,57,71,105,57,78,110,72,89,115,87,100,119,104,113,128,120,124,136,130,136,141,137,146,149,36,46,55,11,16,20,8,13,19,32,44,53,36,45,58,22,25,41,8,11,30,3,8,24,1,4,17,0,2,15,0,2,15,0,4,20,6,13,42,5,18,56,1,19,60,3,23,62,13,29,71,24,38,81,21,33,77,21,31,76,21,38,78,22,44,79,30,50,83,39,58,90,57,70,101,85,90,118,113,115,138,123,123,138,116,115,125,122,123,128,134,139,137,153,160,158,35,41,45,26,27,26,13,19,18,27,41,41,71,81,84,70,70,76,49,50,57,27,31,37,15,15,21,5,5,11,2,2,7,0,0,7,17,17,35,57,64,91,31,50,78,10,36,62,4,30,60,4,30,62,7,30,63,14,35,69,25,43,74,41,55,83,62,71,99,86,97,123,122,124,146,144,131,149,132,120,135,114,105,114,117,111,116,132,134,133,146,152,146,172,179,175,16,15,17,13,10,9,4,10,8,3,12,11,45,44,46,65,52,57,54,43,47,36,33,35,18,18,20,4,4,7,2,2,4,0,1,3,7,8,15,118,117,134,161,158,179,131,128,148,112,112,131,105,105,125,105,103,124,109,105,127,118,107,126,138,115,133,154,126,144,151,126,141,127,106,116,105,86,91,106,94,97,120,116,116,129,130,129,142,147,144,164,172,165,184,194,190,40,40,35,12,10,7,0,3,3,0,4,4,12,6,7,30,12,17,32,12,17,21,10,12,7,6,7,2,1,3,2,1,2,3,2,3,0,0,2,68,58,64,182,128,146,205,130,148,196,127,144,194,123,141,195,119,137,187,113,129,172,110,122,150,96,106,123,75,83,103,66,69,95,71,70,104,93,88,122,118,113,129,132,126,132,141,135,152,162,158,171,182,176,185,197,194,69,77,64,26,29,21,1,1,1,1,1,2,4,1,0,12,2,5,18,3,9,12,2,5,4,1,2,2,0,0,2,0,0,4,0,1,1,1,1,32,12,11,153,45,59,203,47,68,195,46,67,191,48,69,179,50,67,155,49,59,119,42,49,91,38,42,81,48,46,94,77,71,117,110,102,125,126,116,125,128,120,129,135,128,144,153,147,162,176,171,173,187,183,184,198,196,83,94,82,47,52,43,1,1,1,2,1,2,2,0,0,5,1,2,7,1,5,4,0,2,1,0,0,1,0,0,1,0,0,3,0,0,1,2,0,27,3,2,142,25,38,205,32,54,198,25,46,169,25,43,121,25,36,85,29,34,74,41,39,85,66,56,102,92,82,121,113,105,128,124,115,122,126,115,121,127,118,132,139,131,147,157,150,165,179,174,176,191,187,186,201,199,92,102,93,54,60,50,6,7,3,3,2,1,2,2,0,1,3,1,1,3,3,1,2,2,1,1,1,1,0,0,1,0,0,1,1,1,0,3,2,15,1,0,102,19,28,157,31,47,117,17,23,74,13,12,56,27,22,74,58,55,99,90,81,115,115,99,122,126,111,124,124,112,123,123,113,125,130,119,128,135,126,136,145,137,148,159,151,162,176,171,177,192,188,188,202,201,87,99,89,43,51,37,19,23,11,11,12,4,8,10,2,5,11,4,2,10,4,2,7,2,3,4,1,3,4,1,3,4,1,2,3,2,0,6,6,4,5,2,42,13,13,71,21,24,53,27,25,57,50,41,80,77,62,113,98,82,132,113,101,134,126,113,123,126,112,116,125,111,120,128,115,131,138,126,139,148,137,143,154,145,156,168,161,169,184,179,182,197,193,188,202,201,82,96,82,46,57,36,36,44,22,31,35,17,27,30,15,22,28,15,17,26,13,16,23,12,18,21,12,19,21,13,20,22,14,19,23,15,19,27,20,23,31,21,37,40,27,64,55,45,87,70,67,104,88,81,116,102,85,128,112,88,139,121,105,131,122,110,117,122,107,115,127,112,123,133,119,131,139,127,139,149,138,148,160,151,159,172,164,174,189,183,185,200,196,187,202,200,85,101,83,62,75,48,58,67,38,55,61,37,51,56,35,47,53,33,46,53,34,48,55,38,49,55,40,51,56,41,53,58,44,55,62,46,59,67,45,68,71,48,81,84,59,104,96,74,116,103,83,127,109,92,133,116,97,127,121,97,127,127,107,118,124,106,114,125,108,122,131,117,129,136,123,136,145,133,141,152,141,149,162,153,158,171,163,168,183,178,180,195,191,186,200,199}
4 |
5 | /* A CIFAR10 test set image - a dog, label 5 */
6 | //#define IMG_DATA {91,64,30,82,58,30,87,73,59,89,87,83,95,92,80,98,90,71,97,87,68,94,90,75,92,93,84,98,94,85,81,76,66,28,26,19,15,15,10,18,19,16,19,19,20,19,19,20,16,16,17,15,15,16,13,15,13,10,16,8,10,14,10,13,13,12,15,14,8,26,24,12,29,25,15,26,21,12,39,34,25,25,20,11,18,13,6,22,13,13,22,15,13,18,13,10,94,65,34,79,56,30,90,78,59,124,120,106,144,138,118,133,121,96,111,97,71,101,94,71,98,96,81,94,88,79,48,41,35,14,9,6,12,10,7,11,11,9,14,13,14,16,14,16,24,23,24,32,30,32,26,26,26,27,28,24,22,22,20,22,19,15,52,48,32,67,61,36,56,45,24,57,45,24,67,55,34,60,49,26,42,29,10,36,19,7,61,46,32,47,36,26,94,66,39,86,65,40,120,105,82,156,142,119,155,138,111,147,125,93,135,112,79,123,105,76,114,103,81,88,78,65,41,32,22,39,32,25,42,38,32,40,37,31,49,48,32,51,50,33,58,57,41,56,55,38,47,45,31,30,28,21,38,33,28,29,21,14,53,44,27,55,45,21,41,26,7,71,54,29,53,36,12,63,47,20,63,45,21,54,33,14,82,64,42,59,46,32,89,69,42,108,90,67,136,112,88,133,101,72,130,95,63,126,88,52,124,85,48,126,92,60,124,100,74,85,72,51,47,38,19,54,48,30,61,56,41,94,90,75,84,81,59,84,81,57,61,58,35,69,66,43,74,71,48,45,39,24,48,39,28,32,20,11,37,23,11,54,40,20,56,39,20,73,56,35,58,41,21,44,27,9,66,46,24,80,56,34,72,54,33,32,22,8,72,60,33,94,78,56,105,75,51,106,62,33,134,86,53,123,73,36,109,59,20,117,70,36,113,77,47,88,70,41,61,51,23,64,57,32,75,69,47,99,94,74,72,66,51,82,76,63,69,63,50,49,43,30,48,42,27,75,68,45,64,54,36,47,33,23,62,46,31,68,52,31,54,37,21,47,31,17,56,39,26,40,24,10,32,15,4,46,25,14,36,20,8,25,19,5,43,37,16,54,39,20,62,35,16,83,45,24,127,81,51,123,73,39,105,53,17,110,57,21,102,53,16,97,65,25,79,59,27,66,56,33,87,81,62,75,69,53,86,80,66,80,74,60,67,60,46,71,65,52,77,72,55,88,82,58,66,58,41,50,40,30,62,53,37,62,52,30,58,42,24,31,15,3,40,26,10,38,26,11,31,20,8,23,10,6,29,15,8,27,16,6,47,42,26,46,29,11,47,19,3,67,30,11,111,66,36,116,69,35,101,51,15,105,52,14,105,51,12,107,61,21,89,58,27,56,40,20,56,49,33,67,63,46,77,71,55,68,62,46,74,68,51,75,69,53,78,72,54,76,70,48,49,42,26,52,44,32,52,45,29,51,43,20,72,56,34,59,43,24,63,50,30,56,44,27,37,28,13,28,20,6,45,33,13,34,22,5,69,60,46,71,50,31,68,35,17,66,25,2,98,54,22,109,64,30,102,54,17,110,60,21,112,59,19,111,55,19,97,53,26,62,40,21,48,42,25,52,50,32,60,55,39,82,76,60,75,69,53,57,51,35,46,40,23,81,75,54,60,52,36,41,33,22,55,48,31,41,33,14,39,23,6,61,45,24,55,42,24,49,38,21,40,31,15,29,21,5,49,36,11,45,32,8,79,60,44,112,87,67,134,100,78,104,65,39,114,73,40,118,75,40,109,64,27,111,64,24,108,57,17,103,48,12,95,52,25,66,44,26,56,50,34,59,57,40,82,77,60,75,69,53,75,69,53,68,62,46,73,67,51,73,67,46,64,57,40,42,34,23,52,45,29,44,36,16,50,34,15,53,37,16,42,29,11,45,34,17,52,41,26,42,29,18,44,27,13,38,21,8,120,87,66,129,98,77,158,128,107,136,105,83,127,90,58,116,76,39,109,66,28,114,69,28,106,59,17,100,54,14,114,81,50,93,77,57,65,58,43,63,58,42,72,66,51,71,65,50,99,93,77,95,89,73,107,101,83,100,94,71,64,57,41,46,38,27,40,34,18,45,37,15,51,34,14,54,38,17,43,29,11,40,29,14,49,39,24,53,39,20,53,33,16,36,17,5,161,120,94,126,93,70,135,108,90,143,117,100,144,108,79,126,86,52,102,62,26,110,68,30,105,61,21,118,86,46,170,149,118,156,146,124,115,110,92,114,107,90,123,117,100,126,120,104,152,146,130,144,137,122,114,107,90,113,107,85,115,108,91,120,112,100,109,102,85,85,77,57,81,65,46,67,52,31,51,38,18,54,40,22,54,40,19,60,44,16,82,63,31,76,57,29,164,126,100,130,103,78,99,72,51,129,94,76,159,114,93,152,111,90,123,91,69,112,80,54,118,83,53,151,131,107,189,178,159,173,167,148,149,145,122,154,146,122,178,165,147,177,169,152,175,170,152,170,162,146,140,128,114,141,134,117,172,165,149,179,171,156,178,171,155,172,164,148,159,149,135,127,118,99,100,87,62,97,72,44,89,59,31,59,35,12,63,41,18,87,69,44,161,125,95,147,116,88,125,89,65,144,100,80,146,105,87,141,111,95,161,138,124,156,133,115,169,145,122,186,170,153,182,171,153,162,151,131,147,138,113,161,150,124,173,155,136,174,162,144,178,173,154,178,170,154,172,160,146,174,166,150,183,176,160,173,166,150,169,162,146,184,176,162,178,169,158,172,164,147,145,133,108,115,89,60,99,67,38,83,60,37,66,49,28,53,40,21,163,124,89,159,119,88,163,118,92,166,120,98,97,73,52,81,66,52,155,142,132,180,167,155,195,181,164,188,174,157,154,136,115,131,110,85,137,118,92,164,146,121,147,125,102,150,135,112,183,176,155,186,178,162,185,174,162,186,178,163,189,183,166,182,175,159,169,163,146,182,174,160,182,172,162,178,170,156,179,169,148,145,123,100,122,94,70,139,121,96,125,113,90,44,38,21,168,126,92,172,128,99,172,128,102,146,110,84,59,51,23,51,48,28,138,130,120,177,169,160,192,186,172,169,158,139,126,104,78,124,93,62,139,110,81,153,127,103,133,106,79,139,120,93,184,175,152,193,185,169,193,183,172,195,187,172,198,191,175,198,191,175,190,183,167,188,179,166,191,180,171,194,186,174,199,191,175,179,161,144,146,122,103,167,147,125,181,169,146,99,97,74,177,129,103,178,133,110,168,133,110,118,99,71,57,63,26,43,46,18,114,106,92,173,165,154,192,189,174,163,153,133,131,103,73,149,108,70,149,109,78,142,110,87,133,100,71,156,133,103,195,184,159,197,190,173,198,189,179,200,192,177,203,196,180,205,198,182,195,188,172,192,182,169,201,188,181,204,196,186,203,197,185,189,175,163,140,117,106,137,111,95,170,154,130,129,127,96,182,135,115,177,136,116,153,129,104,96,94,61,70,85,41,58,66,30,98,91,72,164,155,142,192,187,172,180,171,151,169,144,115,172,131,95,154,111,80,140,103,77,137,101,67,176,152,121,201,191,168,197,189,173,200,190,177,200,192,177,203,197,180,204,197,181,191,185,168,191,183,169,202,190,184,204,197,188,204,199,189,189,180,171,145,127,117,115,86,69,129,106,81,113,103,68,182,142,123,165,133,110,121,109,77,83,93,51,73,93,45,62,77,35,76,79,51,152,143,129,193,181,172,201,195,179,198,187,165,181,157,131,160,128,101,147,110,79,140,103,63,176,154,125,195,188,173,194,184,171,196,180,163,193,185,169,197,191,175,193,187,171,191,185,169,197,190,176,202,195,186,201,195,186,198,192,182,183,177,166,145,133,117,117,90,65,131,97,71,123,95,66,182,144,125,138,114,88,89,89,51,75,95,48,71,94,44,61,77,34,44,50,20,113,108,90,183,171,161,205,197,186,206,198,183,193,179,160,183,165,142,163,140,112,141,111,77,167,148,125,183,176,168,183,172,164,185,169,156,189,181,165,190,184,168,185,179,163,194,188,172,199,194,179,200,195,182,196,188,175,183,170,156,166,147,133,144,120,101,137,103,77,150,108,83,138,100,74,161,128,108,103,91,60,75,86,44,69,95,46,68,91,43,69,85,42,46,54,22,53,54,31,138,133,116,197,187,178,205,195,186,194,186,172,187,181,162,178,170,148,164,144,120,168,154,138,169,162,156,167,158,153,182,168,160,188,181,166,178,172,156,182,176,160,197,190,174,199,195,178,197,194,177,184,174,156,154,130,112,149,113,94,162,120,99,162,119,95,163,116,93,148,105,81,128,108,83,83,83,48,71,89,45,68,93,45,68,89,42,70,87,43,68,80,43,44,51,20,77,78,53,173,165,152,197,188,178,195,189,176,177,174,159,164,161,144,164,154,134,158,149,134,153,146,136,153,145,137,161,152,143,162,156,141,152,146,130,171,166,149,197,191,175,199,194,178,200,195,180,172,159,142,128,101,82,150,110,88,177,130,107,177,130,107,174,127,105,159,114,91,97,92,62,75,87,48,71,90,45,73,91,45,73,90,46,73,90,46,74,89,48,68,80,42,46,53,23,135,130,110,191,182,166,197,189,173,170,161,146,132,124,109,109,106,87,107,103,84,113,106,90,100,93,80,95,89,77,96,89,75,81,74,60,127,121,106,188,182,166,196,190,176,204,194,188,175,159,150,116,89,73,135,98,77,178,134,110,182,137,114,183,141,117,175,136,111,79,87,50,70,88,46,69,89,44,74,91,46,76,92,48,75,91,48,76,91,50,74,89,48,46,57,20,105,102,79,190,182,164,198,188,171,168,155,141,119,108,93,66,70,45,55,60,32,63,65,36,61,63,35,53,57,30,60,63,37,56,57,32,65,62,41,152,145,127,193,184,172,202,191,185,199,185,175,148,128,112,121,97,76,161,131,105,183,146,119,177,141,113,173,136,110,72,90,43,69,88,41,69,90,42,71,91,44,74,89,46,72,85,43,77,89,48,77,89,48,54,64,26,91,88,68,189,181,167,194,186,172,164,155,141,140,133,118,85,93,62,62,74,37,63,74,34,75,87,43,75,88,43,71,87,43,74,84,42,52,53,19,86,76,56,152,139,131,177,170,163,164,157,149,135,127,118,103,95,86,111,99,84,155,132,105,156,126,99,162,124,99,70,92,42,72,90,42,73,87,40,74,84,39,80,86,48,87,91,56,97,100,65,104,108,73,86,88,56,103,96,78,190,181,167,187,178,164,161,152,137,162,154,139,106,102,80,79,76,50,79,76,48,89,88,55,89,87,53,82,78,44,82,77,42,73,65,36,56,42,28,66,53,55,71,69,84,47,46,64,41,40,57,44,43,61,45,42,53,80,69,61,125,105,91,159,127,107,70,91,45,74,87,44,84,88,48,95,95,57,106,101,71,115,108,81,117,110,83,125,118,90,114,106,81,121,111,93,197,185,169,185,174,157,160,149,132,152,140,124,115,99,85,104,86,72,98,81,66,99,81,66,96,77,61,96,72,54,93,72,52,85,70,53,80,68,63,49,43,52,24,32,55,23,33,57,26,36,60,26,36,61,26,34,57,31,32,48,59,50,56,111,92,82,75,88,53,84,90,58,101,100,70,111,105,78,109,98,76,109,97,77,111,98,79,114,102,82,106,93,74,118,106,87,190,177,159,187,174,156,151,139,121,126,113,95,110,92,78,111,90,78,99,78,68,98,77,69,103,80,74,104,76,70,102,80,71,90,79,71,62,58,60,33,38,49,21,38,51,21,39,52,21,39,52,20,38,50,22,38,55,25,34,60,28,30,47,43,37,41,91,91,73,104,104,86,108,105,88,104,99,83,100,92,75,100,90,73,100,90,73,103,93,76,95,85,67,101,87,68,179,164,144,189,174,154,133,118,98,91,77,56,99,87,66,115,102,85,110,97,83,113,99,90,123,108,103,116,102,99,108,101,94,76,78,73,34,42,49,23,36,51,21,39,51,20,39,50,20,38,50,22,40,52,20,37,52,22,32,56,24,31,53,24,30,46,105,98,88,103,98,88,102,99,88,96,93,82,95,88,75,94,86,74,95,87,77,97,88,77,96,84,71,117,102,81,176,162,139,175,163,141,106,94,74,68,59,38,102,95,72,116,109,88,114,106,88,125,117,101,135,126,113,126,120,111,97,98,95,39,48,53,19,33,45,19,35,52,18,33,54,18,34,55,20,35,56,23,39,59,23,37,59,22,34,54,17,33,49,22,33,55,106,97,88,103,96,86,103,99,88,104,100,88,109,98,88,108,98,92,102,94,92,105,93,89,119,102,92,151,133,111,179,164,140,147,136,115,105,97,79,109,103,86,125,112,96,129,115,99,130,117,100,129,117,99,124,113,93,122,112,96,75,75,77,20,29,49,17,32,51,19,34,49,18,32,54,19,34,57,20,35,58,18,34,57,21,33,58,20,34,52,14,37,43,21,32,55,114,103,91,114,104,92,120,110,98,125,114,102,132,117,102,125,113,102,112,105,97,115,104,94,139,121,106,164,140,120,163,139,119,129,108,90,129,110,95,144,125,112,142,117,106,139,114,102,134,113,99,125,107,93,125,109,94,112,103,92,50,52,57,20,30,51,20,35,56,22,36,53,21,36,58,22,37,60,24,38,61,21,36,59,21,34,57,36,47,61,37,50,55,22,30,51,136,121,106,131,115,100,133,114,100,134,113,99,130,108,91,129,113,97,126,117,104,118,109,92,126,109,89,145,115,100,142,108,94,141,108,95,150,117,104,147,113,101,143,108,98,144,111,102,140,112,104,141,118,110,137,119,112,74,69,67,30,36,45,23,37,56,23,37,60,26,38,60,24,39,61,25,40,63,25,40,62,23,38,61,24,39,59,80,84,92,78,72,76,28,31,50}
7 |
8 | /* Custom image - a cat, label 3 */
9 | #define IMG_DATA {231,227,224,220,214,212,212,205,204,229,222,223,241,238,239,244,243,244,243,244,244,243,244,244,243,244,244,243,243,244,199,188,182,156,141,133,162,144,129,151,126,108,81,55,45,92,66,49,90,69,58,107,88,77,121,108,100,162,152,151,191,182,184,223,220,222,238,233,235,247,244,245,253,252,252,244,243,243,240,239,240,239,237,239,239,237,237,238,232,232,233,227,227,233,227,227,225,220,217,212,206,204,175,167,164,162,153,147,187,181,179,214,210,209,231,229,228,239,236,235,237,234,233,235,232,231,210,200,194,172,156,151,159,145,140,174,153,135,120,94,74,80,54,40,81,59,48,92,73,61,103,89,77,121,112,103,103,93,92,91,84,86,107,100,102,145,138,140,191,185,187,225,219,221,238,235,235,234,230,230,232,227,228,230,224,224,226,220,220,226,220,220,221,216,213,215,210,207,190,185,181,141,135,127,122,117,108,135,130,122,164,158,152,191,183,177,201,192,189,201,193,189,187,178,168,180,167,156,161,150,141,155,142,128,161,138,112,102,70,48,86,63,49,93,79,69,108,99,92,117,111,100,81,74,70,74,68,67,63,58,60,59,56,58,67,64,65,111,105,107,191,184,185,220,214,215,231,225,224,227,220,220,220,214,214,218,212,212,216,212,209,214,209,206,197,192,189,157,153,147,122,115,107,113,106,98,111,104,96,114,110,100,119,113,105,140,132,122,166,153,138,164,150,136,150,137,126,130,117,104,159,138,113,123,94,71,80,63,49,101,90,82,116,105,99,103,92,86,89,81,76,84,78,73,80,74,73,79,73,74,75,69,68,76,70,69,100,93,91,129,122,121,159,153,152,189,184,185,206,201,201,212,207,207,207,206,204,210,207,204,198,193,190,162,157,154,121,116,108,105,100,91,105,101,92,105,101,92,103,98,88,127,118,107,161,144,127,143,125,115,144,131,119,137,123,108,144,122,98,122,100,78,76,64,50,78,68,62,98,87,81,86,78,77,85,80,76,97,87,82,90,85,83,88,83,80,105,95,91,105,94,89,122,108,97,126,110,95,126,110,96,125,111,103,128,116,116,161,157,158,197,196,194,198,196,193,193,190,186,169,164,161,126,121,115,100,96,88,102,98,89,102,98,89,103,97,88,107,98,89,124,111,98,154,140,123,158,142,120,143,126,101,120,99,76,111,94,74,99,87,71,77,66,60,76,67,61,69,63,62,72,67,67,93,82,79,85,79,74,79,76,71,96,86,77,129,110,91,149,126,103,161,143,123,162,145,126,150,133,116,140,123,104,117,101,92,188,187,185,186,185,182,176,174,170,152,147,144,114,109,104,93,89,81,94,90,81,95,92,83,99,94,84,95,87,77,87,77,70,136,123,104,151,135,110,121,105,82,85,69,52,86,72,59,72,63,52,50,43,40,63,54,50,44,41,41,94,83,77,89,79,71,98,85,73,114,98,81,132,112,93,142,122,104,144,128,113,160,145,135,167,151,142,146,129,122,137,120,111,150,132,112,181,180,178,182,181,179,174,173,171,145,144,140,105,101,93,90,86,77,89,85,76,91,88,79,91,85,77,94,82,70,115,99,85,127,112,93,131,116,97,110,96,78,94,81,65,59,49,42,54,46,42,54,49,45,59,52,46,66,59,53,71,62,55,87,74,63,124,105,89,149,127,101,130,112,99,142,126,115,151,135,124,178,162,154,199,182,174,163,139,134,129,103,99,144,123,112,178,177,175,180,179,177,175,174,171,147,145,141,104,100,94,87,83,76,90,86,77,90,86,77,81,76,68,98,83,67,152,134,114,138,124,100,129,113,92,129,113,91,107,92,74,63,53,45,69,60,51,75,62,55,59,53,48,65,55,50,88,75,61,120,101,80,143,122,97,126,107,89,122,104,95,150,136,126,167,151,142,184,168,158,205,186,179,188,160,154,135,106,99,143,119,107,173,172,170,173,172,170,169,169,167,143,143,140,108,104,98,93,85,75,73,68,60,67,62,56,70,65,57,123,109,89,140,123,99,116,100,80,131,116,92,124,107,84,71,59,49,58,49,43,57,49,43,88,79,67,88,75,64,69,60,54,87,76,63,104,90,72,105,88,69,123,101,86,130,106,94,150,135,121,181,166,157,187,167,158,171,144,130,166,139,127,140,112,103,141,112,95,172,171,170,168,167,165,143,144,142,101,97,92,88,79,70,67,60,50,35,33,29,34,31,29,51,46,40,129,113,92,125,107,86,107,95,79,140,126,105,97,81,64,50,42,39,70,60,51,90,79,69,109,99,85,83,70,61,123,106,87,84,74,61,99,86,73,128,110,92,149,124,109,160,134,119,148,127,117,175,158,150,189,173,165,175,149,133,154,118,101,158,128,113,160,132,116,118,112,110,111,106,98,91,85,75,78,68,59,70,62,52,64,58,48,40,39,33,36,36,31,45,40,35,113,100,83,142,127,112,154,140,118,94,82,71,103,88,74,90,80,67,83,74,63,104,93,78,79,68,58,95,81,67,130,113,93,116,101,83,109,92,76,140,119,105,149,125,112,160,137,123,158,133,122,171,153,141,161,141,127,189,162,149,165,131,120,135,108,94,158,138,123,76,66,57,88,78,67,95,86,75,88,80,71,74,66,58,73,64,55,39,35,31,32,30,29,84,73,63,164,143,123,135,113,88,159,140,118,121,104,86,112,97,80,73,63,55,61,54,47,101,87,73,135,117,97,118,100,80,124,108,92,125,108,91,129,108,89,140,117,103,139,115,98,142,118,101,155,132,117,161,142,122,173,147,134,170,135,123,131,101,86,144,120,100,162,143,120,98,88,78,102,91,80,93,83,73,84,77,66,65,60,54,49,44,42,36,35,31,41,38,32,86,75,59,180,153,124,165,130,79,54,58,58,126,114,92,112,96,78,95,84,70,79,68,61,139,124,104,113,98,85,91,78,70,146,129,111,118,100,86,138,116,97,152,125,106,143,117,98,132,107,88,133,111,94,144,121,108,157,133,121,127,102,90,109,89,73,148,128,105,127,109,87,92,82,73,90,80,73,77,68,62,64,56,50,60,53,45,67,60,50,59,53,46,47,41,35,75,64,48,152,129,104,168,131,80,115,94,54,125,111,82,132,116,99,138,120,99,124,109,92,146,129,105,91,73,66,122,107,96,109,91,80,101,81,70,136,110,93,154,129,109,147,121,100,140,115,93,141,119,96,128,105,87,119,99,80,114,97,77,118,102,82,134,118,96,126,109,90,88,80,71,54,49,45,50,46,39,79,69,60,83,73,63,98,89,76,87,79,65,57,49,38,62,52,43,108,92,75,167,137,111,144,110,72,129,112,88,142,126,102,155,136,113,148,131,111,185,164,137,171,144,121,154,131,110,131,113,97,136,117,101,130,105,83,149,122,97,146,119,94,140,116,90,143,123,95,139,117,90,129,107,83,132,113,88,127,110,85,129,112,89,123,108,94,67,60,51,64,57,50,68,61,53,100,90,77,107,96,82,120,107,93,128,113,97,72,59,44,65,53,40,111,94,76,161,137,111,151,123,105,132,113,95,154,135,110,154,136,114,191,172,148,218,198,175,157,127,90,116,100,76,127,119,117,165,148,125,168,143,117,163,134,107,156,131,104,153,129,104,158,136,110,142,116,88,136,110,83,130,108,82,122,100,79,110,90,72,103,93,83,93,80,71,98,86,76,106,93,82,130,115,100,132,117,104,138,122,108,150,133,117,79,65,52,74,61,49,141,122,98,151,126,102,131,103,77,138,114,87,165,144,117,175,152,128,229,207,181,146,121,115,105,79,47,113,106,77,71,77,69,143,116,71,153,125,104,140,115,92,110,92,74,118,101,83,142,121,99,125,103,81,127,103,77,142,120,93,132,109,88,100,84,72,125,120,115,120,106,96,91,81,72,119,106,93,139,122,106,147,130,112,137,121,100,148,131,108,99,83,68,61,51,39,127,110,89,144,118,93,139,106,75,184,153,121,176,151,126,195,167,137,190,163,139,136,104,95,144,114,99,145,117,75,150,119,71,156,124,95,202,177,154,140,118,91,80,66,52,78,67,61,59,49,46,113,96,80,137,115,94,140,118,98,125,105,86,106,94,83,148,139,132,125,110,98,116,105,94,127,114,99,139,123,107,136,120,97,119,101,80,136,118,94,112,92,72,55,39,26,164,142,116,165,126,95,159,114,73,199,162,124,189,153,117,167,132,95,112,86,69,166,135,110,218,190,161,178,152,125,168,138,115,175,153,129,138,118,96,113,93,73,145,127,102,164,142,118,114,97,83,62,52,46,105,92,76,102,87,76,103,88,77,124,109,101,174,160,153,106,94,82,113,101,87,127,112,95,132,116,98,144,124,101,115,96,77,138,121,100,137,111,87,75,55,43,137,122,108,174,144,117,166,126,90,193,149,108,161,115,74,118,86,59,131,107,85,165,143,119,159,140,118,155,136,114,148,128,107,116,98,82,107,91,74,134,116,96,165,143,121,166,144,121,151,129,106,120,100,87,115,100,85,101,86,73,120,106,98,170,157,150,190,177,169,107,93,78,119,105,91,119,100,82,113,96,78,148,126,101,110,92,75,142,125,103,147,122,94,108,92,81,94,82,77,144,121,108,150,115,91,149,113,89,120,79,52,155,114,80,179,146,118,148,123,99,160,139,117,145,126,109,128,111,94,128,111,95,127,109,95,144,125,108,139,120,107,157,138,118,134,111,93,123,103,86,132,112,93,136,119,106,165,152,142,186,173,165,192,177,169,111,95,81,137,123,105,129,109,92,103,85,72,143,127,105,120,102,82,106,93,74,145,124,103,140,124,108,110,100,92,101,86,77,147,119,102,149,125,115,189,163,139,212,179,145,181,152,127,139,115,94,149,127,105,175,153,131,177,157,140,172,153,137,178,158,141,173,149,130,150,126,107,141,118,98,139,117,96,140,121,101,137,121,102,162,146,136,194,176,170,196,181,174,190,176,167,120,106,90,129,117,101,142,124,104,117,97,82,108,91,75,115,99,82,121,106,94,140,124,111,151,135,119,149,134,121,70,61,57,97,86,80,188,175,163,219,208,193,219,201,182,203,178,156,188,163,140,177,151,127,167,144,127,165,148,137,168,149,138,162,137,121,160,132,109,175,150,128,167,144,123,159,139,122,170,151,137,188,171,165,205,191,184,210,192,185,211,194,187,205,190,181,120,105,94,135,123,115,144,129,118,135,121,109,153,136,126,155,139,131,182,166,154,180,162,151,180,165,154,179,166,154,160,142,132,139,120,113,178,158,147,198,179,167,195,177,163,193,170,154,171,148,131,173,152,142,196,177,168,202,185,176,206,190,182,192,172,161,169,148,135,178,155,138,189,168,153,205,188,178,206,189,179,212,195,186,211,193,186,213,198,189,214,196,187,197,180,171,176,161,153,207,192,186,208,190,182,200,183,174,219,202,195,215,195,185,208,187,173,215,196,183,200,178,163,189,170,158,207,189,177,211,193,181,223,204,193,220,201,189,212,192,179,203,179,168,192,167,155,202,181,169,216,199,187,217,198,186,213,193,181,209,189,176,207,187,179,196,171,158,204,184,173,214,198,190,214,196,189,210,191,183,219,202,194,211,194,186,208,192,186,203,187,179,211,194,183,213,195,184,209,190,178,206,184,171,207,184,171,207,183,171,208,179,165,211,186,172,197,168,150,197,168,151,210,185,172,218,198,187,218,196,186,223,202,189,223,196,183,221,194,180,221,198,186,210,182,169,215,190,177,211,183,169,211,185,170,212,185,172,205,181,168,191,165,150,188,161,148,209,187,177,205,187,175,210,191,180,213,195,184,218,201,193,208,191,184,188,167,161,200,182,167,207,189,177,206,180,169,204,177,164,218,193,181,211,185,170,198,168,149,200,168,150,207,174,155,202,168,147,191,160,140,191,161,144,206,178,163,205,176,160,218,192,176,223,197,182,218,190,176,217,191,178,207,178,164,199,169,151,202,175,156,202,173,158,205,180,164,202,177,162,198,173,161,213,195,186,209,191,182,216,197,186,216,198,187,219,201,194,209,190,183,187,168,160,188,157,144,201,172,158,216,189,179,214,188,178,202,172,157,204,171,152,197,162,146,214,188,171,213,183,168,197,162,145,195,162,143,189,152,133,191,155,135,199,168,147,204,172,153,213,186,173,229,207,195,218,194,179,201,169,153,203,173,157,210,184,169,213,185,172,220,194,181,217,193,182,207,187,177,201,178,166,206,184,172,209,187,175,214,195,184,212,194,185,195,174,166,185,166,158,195,160,149,200,165,152,205,176,161,205,171,158,210,182,168,208,175,157,205,169,150,204,171,155,210,177,162,208,177,164,196,160,144,189,152,133,191,155,135,199,165,145,205,169,150,208,175,158,215,186,173,209,178,163,204,172,154,205,176,161,218,191,181,222,198,186,218,195,182,212,191,180,198,177,166,182,153,141,205,179,168,203,175,161,202,177,166,202,180,170,181,161,150,169,148,137,196,162,146,196,159,143,199,164,147,202,165,149,197,163,147,199,168,151,200,166,149,205,172,154,204,172,154,199,166,148,190,157,140,192,157,139,194,155,136,201,164,145,207,176,158,204,170,154,191,154,134,197,164,145,204,171,157,210,182,171,212,185,174,215,193,186,215,190,180,210,188,179,181,157,146,179,146,134,204,174,163,207,179,168,208,183,175,199,180,172,181,162,154,173,153,148,200,165,149,197,161,147,188,150,136,200,166,149,203,170,154,194,155,140,199,162,145,208,176,159,207,176,162,204,171,158,189,156,141,188,151,134,198,160,142,206,169,151,206,175,160,205,173,159,196,160,145,191,160,145,200,168,155,213,180,171,215,191,180,216,193,183,210,186,175,204,181,172,172,140,127,181,146,131,209,179,167,210,185,176,204,181,174,196,176,169,163,145,138,162,147,140}
10 |
11 |
--------------------------------------------------------------------------------
/cifar10/arm_nnexamples_cifar10_parameter.h:
--------------------------------------------------------------------------------
1 | #define CONV1_IM_DIM 32
2 | #define CONV1_IM_CH 3
3 | #define CONV1_KER_DIM 5
4 | #define CONV1_PADDING 2
5 | #define CONV1_STRIDE 1
6 | #define CONV1_OUT_CH 32
7 | #define CONV1_OUT_DIM 32
8 |
9 | #define POOL1_KER_DIM 3
10 | #define POOL1_STRIDE 2
11 | #define POOL1_PADDING 0
12 | #define POOL1_OUT_DIM 16
13 |
14 | #define CONV2_IM_DIM 16
15 | #define CONV2_IM_CH 32
16 | #define CONV2_KER_DIM 5
17 | #define CONV2_PADDING 2
18 | #define CONV2_STRIDE 1
19 | #define CONV2_OUT_CH 16
20 | #define CONV2_OUT_DIM 16
21 |
22 | #define POOL2_KER_DIM 3
23 | #define POOL2_STRIDE 2
24 | #define POOL2_PADDING 0
25 | #define POOL2_OUT_DIM 8
26 |
27 | #define CONV3_IM_DIM 8
28 | #define CONV3_IM_CH 16
29 | #define CONV3_KER_DIM 5
30 | #define CONV3_PADDING 2
31 | #define CONV3_STRIDE 1
32 | #define CONV3_OUT_CH 32
33 | #define CONV3_OUT_DIM 8
34 |
35 | #define POOL3_KER_DIM 3
36 | #define POOL3_STRIDE 2
37 | #define POOL3_PADDING 0
38 | #define POOL3_OUT_DIM 4
39 |
40 | #define IP1_DIM 4*4*32
41 | #define IP1_IM_DIM 4
42 | #define IP1_IM_CH 32
43 | #define IP1_OUT 10
44 |
--------------------------------------------------------------------------------
/cifar10/readme.txt:
--------------------------------------------------------------------------------
1 | CMSIS NN Lib example arm_nnexample_cifar10 for
2 | Cortex-M4 and Cortex-M7.
3 |
4 | The example is configured for uVision Simulator as well as the STM32F407 DISCOVERY board.
5 | For more information, please read the following tutorial
6 | [How to run deep learning model on microcontroller with CMSIS-NN](https://www.dlology.com/blog/how-to-run-deep-learning-model-on-microcontroller-with-cmsis-nn/)
7 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | ## [How to run deep learning model on microcontroller with CMSIS-NN](https://www.dlology.com/blog/how-to-run-deep-learning-model-on-microcontroller-with-cmsis-nn/) Blog
2 |
3 | ## `cifar10` folder
4 |
5 | CMSIS NN Lib example arm_nnexample_cifar10 for
6 | Cortex-M4 and Cortex-M7.
7 |
8 | The example is configured for uVision Simulator as well as the STM32F407 DISCOVERY board.
9 |
10 |
11 | ## `script` folder
12 | It contains a Python Jupyter notebook to generate `#define IMG_DATA {...}` data with a new custom image.
13 |
14 | For more information, please read the tutorial.
15 |
16 | Please noted that the microcontroller project is built with Keil MDK-ARM run on Windows, if you don't have the IDE installed yet, you can find a copy and instruction to install [here](https://pan.baidu.com/s/1EYw5TofPFaihKQG1vCu0kQ).
--------------------------------------------------------------------------------
/scripts/.gitignore:
--------------------------------------------------------------------------------
1 | images
2 | *.tar.gz
3 | *.pyc
4 | *.hdf5
5 | *.ipynb_checkpoints
6 | *.p
7 | *.h5
8 | *.HDF5
9 | __pycache__
10 | *.jpg
--------------------------------------------------------------------------------
/scripts/README.md:
--------------------------------------------------------------------------------
1 | To generate a header file with the correct `IMG_DATA` format, look for the following example in the jupyter notebook.
2 | ```python
3 | srcfile = 'cat.jpg'
4 | newImg2File(srcfile, show=True)
5 | ```
--------------------------------------------------------------------------------
/scripts/model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tony607/arm_nn_examples/27fc63294fe18653402546f20f86e6d2afff791a/scripts/model.png
--------------------------------------------------------------------------------
/scripts/requirements.txt:
--------------------------------------------------------------------------------
1 | numpy
2 | keras
3 | numpy
4 | matplotlib
5 | pillow
--------------------------------------------------------------------------------