├── LICENSE
├── README.md
├── arm_ucos
├── IAR
│ ├── 128KB_Ram.icf
│ ├── 512KB_Pflash.icf
│ └── iar.h
├── gpio_k60_tower.dep
├── gpio_k60_tower.ewd
├── gpio_k60_tower.ewp
├── gpio_k60_tower.ewt
├── src
│ ├── CMSIS
│ │ ├── arm_common_tables.h
│ │ ├── arm_math.h
│ │ ├── core_cm0.h
│ │ ├── core_cm3.h
│ │ ├── core_cm4.h
│ │ ├── core_cm4_simd.h
│ │ ├── core_cmFunc.h
│ │ ├── core_cmInstr.h
│ │ └── iar_cortexM4l_math.a
│ ├── LIB
│ │ ├── CMSIS
│ │ │ ├── arm_common_tables.h
│ │ │ ├── arm_math.h
│ │ │ ├── core_cm0.h
│ │ │ ├── core_cm3.h
│ │ │ ├── core_cm4.h
│ │ │ ├── core_cm4_simd.h
│ │ │ ├── core_cmFunc.h
│ │ │ ├── core_cmInstr.h
│ │ │ └── iar_cortexM4l_math.a
│ │ └── FatFs
│ │ │ ├── 00readme.txt
│ │ │ ├── diskio.c
│ │ │ ├── diskio.h
│ │ │ ├── ff.c
│ │ │ ├── ff.h
│ │ │ ├── ffconf.h
│ │ │ ├── integer.h
│ │ │ └── option
│ │ │ ├── cc932.c
│ │ │ ├── cc936.c
│ │ │ ├── cc949.c
│ │ │ ├── cc950.c
│ │ │ ├── ccsbcs.c
│ │ │ └── syscall.c
│ ├── common
│ │ ├── alloc.c
│ │ ├── assert.c
│ │ ├── assert.h
│ │ ├── common.h
│ │ ├── io.c
│ │ ├── io.h
│ │ ├── memtest.c
│ │ ├── memtest.h
│ │ ├── printf.c
│ │ ├── queue.c
│ │ ├── queue.h
│ │ ├── startup.c
│ │ ├── startup.h
│ │ ├── stdlib.c
│ │ ├── stdlib.h
│ │ ├── uif.c
│ │ └── uif.h
│ ├── cpu
│ │ ├── arm_cm4.c
│ │ ├── arm_cm4.h
│ │ ├── crt0.s
│ │ ├── cw_crt0.s
│ │ ├── dma_channels.h
│ │ ├── headers
│ │ │ └── MK60DZ10.h
│ │ ├── start.c
│ │ ├── start.h
│ │ ├── sysinit.c
│ │ ├── sysinit.h
│ │ ├── vectors.c
│ │ └── vectors.h
│ ├── drivers
│ │ ├── mcg
│ │ │ ├── mcg.c
│ │ │ └── mcg.h
│ │ ├── uart
│ │ │ ├── uart.c
│ │ │ └── uart.h
│ │ └── wdog
│ │ │ ├── wdog.c
│ │ │ └── wdog.h
│ ├── platforms
│ │ └── k60_tower.h
│ ├── projects
│ │ ├── bsp.c
│ │ ├── bsp.h
│ │ ├── character.c
│ │ ├── character.h
│ │ ├── common_header.h
│ │ ├── dds_data.c
│ │ ├── dds_data.h
│ │ ├── fpga_data.c
│ │ ├── fpga_data.h
│ │ ├── isr.c
│ │ ├── isr.h
│ │ ├── main.c
│ │ ├── mcu_math.c
│ │ ├── mcu_math.h
│ │ ├── task_common.c
│ │ └── task_header.h
│ └── uCOS-II
│ │ ├── App
│ │ ├── CFG
│ │ │ ├── app_cfg.h
│ │ │ └── os_cfg.h
│ │ ├── app.c
│ │ ├── app.h
│ │ └── app_hooks.c
│ │ ├── Ports
│ │ ├── os_cpu.h
│ │ ├── os_cpu_a.asm
│ │ ├── os_cpu_c.c
│ │ └── os_dbg.c
│ │ └── Source
│ │ ├── os_core.c
│ │ ├── os_flag.c
│ │ ├── os_mbox.c
│ │ ├── os_mem.c
│ │ ├── os_mutex.c
│ │ ├── os_q.c
│ │ ├── os_sem.c
│ │ ├── os_task.c
│ │ ├── os_time.c
│ │ ├── os_tmr.c
│ │ └── ucos_ii.h
└── uCOS-II.eww
├── fpga
├── dds.V
├── digital.mcs
├── lcd_show.V
├── ram_write.V
├── signal_rw.V
├── testbench.V
└── top.V
└── res
├── img1.jpg
├── img2.jpg
├── img3.jpg
├── img4.jpg
├── img5.jpg
├── img6.jpg
├── img7.jpg
└── img8.png
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 莫失莫忘
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 开源示波器
2 |
学生作品,吃灰机器
3 |
ARM cortex-M4处理器+UcosII实时操作系统+FPGA实现。
4 | 实现了高通/低通滤波,快速傅里叶变换,卡尔曼滤波等熟悉信号处理算法。
5 | 
6 | 
7 | 
8 | 
9 | 
10 |
11 |
--------------------------------------------------------------------------------
/arm_ucos/IAR/128KB_Ram.icf:
--------------------------------------------------------------------------------
1 | /*###ICF### Section handled by ICF editor, don't touch! ****/
2 | /*-Editor annotation file-*/
3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
4 | /*-Specials-*/
5 | define symbol __ICFEDIT_intvec_start__ = 0x1fff0000;
6 | /*-Memory Regions-*/
7 | define symbol __ICFEDIT_region_ROM_start__ = 0x0;
8 | define symbol __ICFEDIT_region_ROM_end__ = 0x0;
9 | define symbol __ICFEDIT_region_RAM_start__ = 0x1fff0000;
10 | define symbol __ICFEDIT_region_RAM_end__ = 0x20000000;
11 | /*-Sizes-*/
12 | define symbol __ICFEDIT_size_cstack__ = 0x400;
13 | define symbol __ICFEDIT_size_heap__ = 0x800;//b06862
14 | /**** End of ICF editor section. ###ICF###*/
15 |
16 | define symbol __region_RAM2_start__ = 0x20000000;
17 | define symbol __region_RAM2_end__ = 0x20010000;
18 |
19 | define exported symbol __VECTOR_TABLE = 0x1fff0000;
20 | define exported symbol __VECTOR_RAM = 0x1fff0000;
21 |
22 | define exported symbol __BOOT_STACK_ADDRESS = __region_RAM2_end__ - 8; //0x2000FFF8;
23 |
24 | define symbol __code_start__ = 0x1fff0410;
25 |
26 | define memory mem with size = 4G;
27 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
28 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__] | mem:[from __region_RAM2_start__ to __region_RAM2_end__];
29 |
30 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
31 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
32 |
33 | initialize manually { readwrite };
34 | initialize manually { section .data};
35 | initialize manually { section .textrw };
36 | do not initialize { section .noinit };
37 |
38 | define block CodeRelocate { section .textrw_init };
39 | define block CodeRelocateRam { section .textrw };
40 |
41 |
42 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
43 | place at address mem:__code_start__ { readonly section .noinit };
44 |
45 | place in RAM_region { readonly, block CodeRelocate };
46 |
47 | place in RAM_region { readwrite, block CodeRelocateRam,
48 | block CSTACK, block HEAP };
--------------------------------------------------------------------------------
/arm_ucos/IAR/512KB_Pflash.icf:
--------------------------------------------------------------------------------
1 | /*###ICF### Section handled by ICF editor, don't touch! ****/
2 | /*-Editor annotation file-*/
3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
4 | /*-Specials-*/
5 | define symbol __ICFEDIT_intvec_start__ = 0x00000000;
6 | /*-Memory Regions-*/
7 | define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
8 | define symbol __ICFEDIT_region_ROM_end__ = 0x00080000;
9 | define symbol __ICFEDIT_region_RAM_start__ = 0x1FFF0410;
10 | define symbol __ICFEDIT_region_RAM_end__ = 0x20000000;
11 | /*-Sizes-*/
12 | define symbol __ICFEDIT_size_cstack__ = 0x1000;
13 | define symbol __ICFEDIT_size_heap__ = 0x200;
14 | /**** End of ICF editor section. ###ICF###*/
15 |
16 | define symbol __region_RAM2_start__ = 0x20000000;
17 | define symbol __region_RAM2_end__ = 0x20010000;
18 |
19 | define exported symbol __VECTOR_TABLE = 0x00000000;
20 | define exported symbol __VECTOR_RAM = 0x1fff0000;
21 |
22 | define exported symbol __BOOT_STACK_ADDRESS = __region_RAM2_end__ - 8; //0x2000FFF8;
23 |
24 | define symbol __code_start__ = 0x00000410;
25 |
26 | define memory mem with size = 4G;
27 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
28 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__] | mem:[from __region_RAM2_start__ to __region_RAM2_end__];
29 |
30 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
31 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
32 |
33 | initialize manually { readwrite };
34 | initialize manually { section .data};
35 | initialize manually { section .textrw };
36 | do not initialize { section .noinit };
37 |
38 | define block CodeRelocate { section .textrw_init };
39 | define block CodeRelocateRam { section .textrw };
40 |
41 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
42 | place at address mem:__code_start__ { readonly section .noinit };
43 |
44 | place in ROM_region { readonly, block CodeRelocate};
45 |
46 | place in RAM_region { readwrite, block CodeRelocateRam,
47 | block CSTACK, block HEAP };
48 |
--------------------------------------------------------------------------------
/arm_ucos/IAR/iar.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: iar.h
3 | * Purpose: Define constants used by IAR toolchain
4 | *
5 | * Notes:
6 | *
7 | */
8 |
9 | #ifndef _IAR_H_
10 | #define _IAR_H_
11 |
12 | /********************************************************************/
13 |
14 | /********************************************************************/
15 |
16 | #endif /* _IAR_H_ */
17 |
--------------------------------------------------------------------------------
/arm_ucos/src/CMSIS/arm_common_tables.h:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------
2 | * Copyright (C) 2010 ARM Limited. All rights reserved.
3 | *
4 | * $Date: 11. November 2010
5 | * $Revision: V1.0.2
6 | *
7 | * Project: CMSIS DSP Library
8 | * Title: arm_common_tables.h
9 | *
10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions
11 | *
12 | * Target Processor: Cortex-M4/Cortex-M3
13 | *
14 | * Version 1.0.2 2010/11/11
15 | * Documentation updated.
16 | *
17 | * Version 1.0.1 2010/10/05
18 | * Production release and review comments incorporated.
19 | *
20 | * Version 1.0.0 2010/09/20
21 | * Production release and review comments incorporated.
22 | * -------------------------------------------------------------------- */
23 |
24 | #ifndef _ARM_COMMON_TABLES_H
25 | #define _ARM_COMMON_TABLES_H
26 |
27 | #include "arm_math.h"
28 |
29 | extern uint16_t armBitRevTable[256];
30 | extern q15_t armRecipTableQ15[64];
31 | extern q31_t armRecipTableQ31[64];
32 | extern const q31_t realCoefAQ31[1024];
33 | extern const q31_t realCoefBQ31[1024];
34 |
35 | #endif /* ARM_COMMON_TABLES_H */
36 |
--------------------------------------------------------------------------------
/arm_ucos/src/CMSIS/core_cmFunc.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file core_cmFunc.h
3 | * @brief CMSIS Cortex-M Core Function Access Header File
4 | * @version V2.10
5 | * @date 26. July 2011
6 | *
7 | * @note
8 | * Copyright (C) 2009-2011 ARM Limited. All rights reserved.
9 | *
10 | * @par
11 | * ARM Limited (ARM) is supplying this software for use with Cortex-M
12 | * processor based microcontrollers. This file can be freely distributed
13 | * within development tools that are supporting such ARM based processors.
14 | *
15 | * @par
16 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
17 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
19 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
20 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
21 | *
22 | ******************************************************************************/
23 |
24 | #ifndef __CORE_CMFUNC_H
25 | #define __CORE_CMFUNC_H
26 |
27 |
28 | /* ########################### Core Function Access ########################### */
29 | /** \ingroup CMSIS_Core_FunctionInterface
30 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
31 | @{
32 | */
33 |
34 | #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
35 | /* ARM armcc specific functions */
36 |
37 | #if (__ARMCC_VERSION < 400677)
38 | #error "Please use ARM Compiler Toolchain V4.0.677 or later!"
39 | #endif
40 |
41 | /* intrinsic void __enable_irq(); */
42 | /* intrinsic void __disable_irq(); */
43 |
44 | /** \brief Get Control Register
45 |
46 | This function returns the content of the Control Register.
47 |
48 | \return Control Register value
49 | */
50 | static __INLINE uint32_t __get_CONTROL(void)
51 | {
52 | register uint32_t __regControl __ASM("control");
53 | return(__regControl);
54 | }
55 |
56 |
57 | /** \brief Set Control Register
58 |
59 | This function writes the given value to the Control Register.
60 |
61 | \param [in] control Control Register value to set
62 | */
63 | static __INLINE void __set_CONTROL(uint32_t control)
64 | {
65 | register uint32_t __regControl __ASM("control");
66 | __regControl = control;
67 | }
68 |
69 |
70 | /** \brief Get ISPR Register
71 |
72 | This function returns the content of the ISPR Register.
73 |
74 | \return ISPR Register value
75 | */
76 | static __INLINE uint32_t __get_IPSR(void)
77 | {
78 | register uint32_t __regIPSR __ASM("ipsr");
79 | return(__regIPSR);
80 | }
81 |
82 |
83 | /** \brief Get APSR Register
84 |
85 | This function returns the content of the APSR Register.
86 |
87 | \return APSR Register value
88 | */
89 | static __INLINE uint32_t __get_APSR(void)
90 | {
91 | register uint32_t __regAPSR __ASM("apsr");
92 | return(__regAPSR);
93 | }
94 |
95 |
96 | /** \brief Get xPSR Register
97 |
98 | This function returns the content of the xPSR Register.
99 |
100 | \return xPSR Register value
101 | */
102 | static __INLINE uint32_t __get_xPSR(void)
103 | {
104 | register uint32_t __regXPSR __ASM("xpsr");
105 | return(__regXPSR);
106 | }
107 |
108 |
109 | /** \brief Get Process Stack Pointer
110 |
111 | This function returns the current value of the Process Stack Pointer (PSP).
112 |
113 | \return PSP Register value
114 | */
115 | static __INLINE uint32_t __get_PSP(void)
116 | {
117 | register uint32_t __regProcessStackPointer __ASM("psp");
118 | return(__regProcessStackPointer);
119 | }
120 |
121 |
122 | /** \brief Set Process Stack Pointer
123 |
124 | This function assigns the given value to the Process Stack Pointer (PSP).
125 |
126 | \param [in] topOfProcStack Process Stack Pointer value to set
127 | */
128 | static __INLINE void __set_PSP(uint32_t topOfProcStack)
129 | {
130 | register uint32_t __regProcessStackPointer __ASM("psp");
131 | __regProcessStackPointer = topOfProcStack;
132 | }
133 |
134 |
135 | /** \brief Get Main Stack Pointer
136 |
137 | This function returns the current value of the Main Stack Pointer (MSP).
138 |
139 | \return MSP Register value
140 | */
141 | static __INLINE uint32_t __get_MSP(void)
142 | {
143 | register uint32_t __regMainStackPointer __ASM("msp");
144 | return(__regMainStackPointer);
145 | }
146 |
147 |
148 | /** \brief Set Main Stack Pointer
149 |
150 | This function assigns the given value to the Main Stack Pointer (MSP).
151 |
152 | \param [in] topOfMainStack Main Stack Pointer value to set
153 | */
154 | static __INLINE void __set_MSP(uint32_t topOfMainStack)
155 | {
156 | register uint32_t __regMainStackPointer __ASM("msp");
157 | __regMainStackPointer = topOfMainStack;
158 | }
159 |
160 |
161 | /** \brief Get Priority Mask
162 |
163 | This function returns the current state of the priority mask bit from the Priority Mask Register.
164 |
165 | \return Priority Mask value
166 | */
167 | static __INLINE uint32_t __get_PRIMASK(void)
168 | {
169 | register uint32_t __regPriMask __ASM("primask");
170 | return(__regPriMask);
171 | }
172 |
173 |
174 | /** \brief Set Priority Mask
175 |
176 | This function assigns the given value to the Priority Mask Register.
177 |
178 | \param [in] priMask Priority Mask
179 | */
180 | static __INLINE void __set_PRIMASK(uint32_t priMask)
181 | {
182 | register uint32_t __regPriMask __ASM("primask");
183 | __regPriMask = (priMask);
184 | }
185 |
186 |
187 | #if (__CORTEX_M >= 0x03)
188 |
189 | /** \brief Enable FIQ
190 |
191 | This function enables FIQ interrupts by clearing the F-bit in the CPSR.
192 | Can only be executed in Privileged modes.
193 | */
194 | #define __enable_fault_irq __enable_fiq
195 |
196 |
197 | /** \brief Disable FIQ
198 |
199 | This function disables FIQ interrupts by setting the F-bit in the CPSR.
200 | Can only be executed in Privileged modes.
201 | */
202 | #define __disable_fault_irq __disable_fiq
203 |
204 |
205 | /** \brief Get Base Priority
206 |
207 | This function returns the current value of the Base Priority register.
208 |
209 | \return Base Priority register value
210 | */
211 | static __INLINE uint32_t __get_BASEPRI(void)
212 | {
213 | register uint32_t __regBasePri __ASM("basepri");
214 | return(__regBasePri);
215 | }
216 |
217 |
218 | /** \brief Set Base Priority
219 |
220 | This function assigns the given value to the Base Priority register.
221 |
222 | \param [in] basePri Base Priority value to set
223 | */
224 | static __INLINE void __set_BASEPRI(uint32_t basePri)
225 | {
226 | register uint32_t __regBasePri __ASM("basepri");
227 | __regBasePri = (basePri & 0xff);
228 | }
229 |
230 |
231 | /** \brief Get Fault Mask
232 |
233 | This function returns the current value of the Fault Mask register.
234 |
235 | \return Fault Mask register value
236 | */
237 | static __INLINE uint32_t __get_FAULTMASK(void)
238 | {
239 | register uint32_t __regFaultMask __ASM("faultmask");
240 | return(__regFaultMask);
241 | }
242 |
243 |
244 | /** \brief Set Fault Mask
245 |
246 | This function assigns the given value to the Fault Mask register.
247 |
248 | \param [in] faultMask Fault Mask value to set
249 | */
250 | static __INLINE void __set_FAULTMASK(uint32_t faultMask)
251 | {
252 | register uint32_t __regFaultMask __ASM("faultmask");
253 | __regFaultMask = (faultMask & (uint32_t)1);
254 | }
255 |
256 | #endif /* (__CORTEX_M >= 0x03) */
257 |
258 |
259 | #if (__CORTEX_M == 0x04)
260 |
261 | /** \brief Get FPSCR
262 |
263 | This function returns the current value of the Floating Point Status/Control register.
264 |
265 | \return Floating Point Status/Control register value
266 | */
267 | static __INLINE uint32_t __get_FPSCR(void)
268 | {
269 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
270 | register uint32_t __regfpscr __ASM("fpscr");
271 | return(__regfpscr);
272 | #else
273 | return(0);
274 | #endif
275 | }
276 |
277 |
278 | /** \brief Set FPSCR
279 |
280 | This function assigns the given value to the Floating Point Status/Control register.
281 |
282 | \param [in] fpscr Floating Point Status/Control value to set
283 | */
284 | static __INLINE void __set_FPSCR(uint32_t fpscr)
285 | {
286 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
287 | register uint32_t __regfpscr __ASM("fpscr");
288 | __regfpscr = (fpscr);
289 | #endif
290 | }
291 |
292 | #endif /* (__CORTEX_M == 0x04) */
293 |
294 |
295 | #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
296 | /* IAR iccarm specific functions */
297 |
298 | #include
299 |
300 | #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
301 | /* GNU gcc specific functions */
302 |
303 | /** \brief Enable IRQ Interrupts
304 |
305 | This function enables IRQ interrupts by clearing the I-bit in the CPSR.
306 | Can only be executed in Privileged modes.
307 | */
308 | __attribute__( ( always_inline ) ) static __INLINE void __enable_irq(void)
309 | {
310 | __ASM volatile ("cpsie i");
311 | }
312 |
313 |
314 | /** \brief Disable IRQ Interrupts
315 |
316 | This function disables IRQ interrupts by setting the I-bit in the CPSR.
317 | Can only be executed in Privileged modes.
318 | */
319 | __attribute__( ( always_inline ) ) static __INLINE void __disable_irq(void)
320 | {
321 | __ASM volatile ("cpsid i");
322 | }
323 |
324 |
325 | /** \brief Get Control Register
326 |
327 | This function returns the content of the Control Register.
328 |
329 | \return Control Register value
330 | */
331 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_CONTROL(void)
332 | {
333 | uint32_t result;
334 |
335 | __ASM volatile ("MRS %0, control" : "=r" (result) );
336 | return(result);
337 | }
338 |
339 |
340 | /** \brief Set Control Register
341 |
342 | This function writes the given value to the Control Register.
343 |
344 | \param [in] control Control Register value to set
345 | */
346 | __attribute__( ( always_inline ) ) static __INLINE void __set_CONTROL(uint32_t control)
347 | {
348 | __ASM volatile ("MSR control, %0" : : "r" (control) );
349 | }
350 |
351 |
352 | /** \brief Get ISPR Register
353 |
354 | This function returns the content of the ISPR Register.
355 |
356 | \return ISPR Register value
357 | */
358 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_IPSR(void)
359 | {
360 | uint32_t result;
361 |
362 | __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
363 | return(result);
364 | }
365 |
366 |
367 | /** \brief Get APSR Register
368 |
369 | This function returns the content of the APSR Register.
370 |
371 | \return APSR Register value
372 | */
373 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_APSR(void)
374 | {
375 | uint32_t result;
376 |
377 | __ASM volatile ("MRS %0, apsr" : "=r" (result) );
378 | return(result);
379 | }
380 |
381 |
382 | /** \brief Get xPSR Register
383 |
384 | This function returns the content of the xPSR Register.
385 |
386 | \return xPSR Register value
387 | */
388 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_xPSR(void)
389 | {
390 | uint32_t result;
391 |
392 | __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
393 | return(result);
394 | }
395 |
396 |
397 | /** \brief Get Process Stack Pointer
398 |
399 | This function returns the current value of the Process Stack Pointer (PSP).
400 |
401 | \return PSP Register value
402 | */
403 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_PSP(void)
404 | {
405 | register uint32_t result;
406 |
407 | __ASM volatile ("MRS %0, psp\n" : "=r" (result) );
408 | return(result);
409 | }
410 |
411 |
412 | /** \brief Set Process Stack Pointer
413 |
414 | This function assigns the given value to the Process Stack Pointer (PSP).
415 |
416 | \param [in] topOfProcStack Process Stack Pointer value to set
417 | */
418 | __attribute__( ( always_inline ) ) static __INLINE void __set_PSP(uint32_t topOfProcStack)
419 | {
420 | __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) );
421 | }
422 |
423 |
424 | /** \brief Get Main Stack Pointer
425 |
426 | This function returns the current value of the Main Stack Pointer (MSP).
427 |
428 | \return MSP Register value
429 | */
430 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_MSP(void)
431 | {
432 | register uint32_t result;
433 |
434 | __ASM volatile ("MRS %0, msp\n" : "=r" (result) );
435 | return(result);
436 | }
437 |
438 |
439 | /** \brief Set Main Stack Pointer
440 |
441 | This function assigns the given value to the Main Stack Pointer (MSP).
442 |
443 | \param [in] topOfMainStack Main Stack Pointer value to set
444 | */
445 | __attribute__( ( always_inline ) ) static __INLINE void __set_MSP(uint32_t topOfMainStack)
446 | {
447 | __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) );
448 | }
449 |
450 |
451 | /** \brief Get Priority Mask
452 |
453 | This function returns the current state of the priority mask bit from the Priority Mask Register.
454 |
455 | \return Priority Mask value
456 | */
457 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_PRIMASK(void)
458 | {
459 | uint32_t result;
460 |
461 | __ASM volatile ("MRS %0, primask" : "=r" (result) );
462 | return(result);
463 | }
464 |
465 |
466 | /** \brief Set Priority Mask
467 |
468 | This function assigns the given value to the Priority Mask Register.
469 |
470 | \param [in] priMask Priority Mask
471 | */
472 | __attribute__( ( always_inline ) ) static __INLINE void __set_PRIMASK(uint32_t priMask)
473 | {
474 | __ASM volatile ("MSR primask, %0" : : "r" (priMask) );
475 | }
476 |
477 |
478 | #if (__CORTEX_M >= 0x03)
479 |
480 | /** \brief Enable FIQ
481 |
482 | This function enables FIQ interrupts by clearing the F-bit in the CPSR.
483 | Can only be executed in Privileged modes.
484 | */
485 | __attribute__( ( always_inline ) ) static __INLINE void __enable_fault_irq(void)
486 | {
487 | __ASM volatile ("cpsie f");
488 | }
489 |
490 |
491 | /** \brief Disable FIQ
492 |
493 | This function disables FIQ interrupts by setting the F-bit in the CPSR.
494 | Can only be executed in Privileged modes.
495 | */
496 | __attribute__( ( always_inline ) ) static __INLINE void __disable_fault_irq(void)
497 | {
498 | __ASM volatile ("cpsid f");
499 | }
500 |
501 |
502 | /** \brief Get Base Priority
503 |
504 | This function returns the current value of the Base Priority register.
505 |
506 | \return Base Priority register value
507 | */
508 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_BASEPRI(void)
509 | {
510 | uint32_t result;
511 |
512 | __ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
513 | return(result);
514 | }
515 |
516 |
517 | /** \brief Set Base Priority
518 |
519 | This function assigns the given value to the Base Priority register.
520 |
521 | \param [in] basePri Base Priority value to set
522 | */
523 | __attribute__( ( always_inline ) ) static __INLINE void __set_BASEPRI(uint32_t value)
524 | {
525 | __ASM volatile ("MSR basepri, %0" : : "r" (value) );
526 | }
527 |
528 |
529 | /** \brief Get Fault Mask
530 |
531 | This function returns the current value of the Fault Mask register.
532 |
533 | \return Fault Mask register value
534 | */
535 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_FAULTMASK(void)
536 | {
537 | uint32_t result;
538 |
539 | __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
540 | return(result);
541 | }
542 |
543 |
544 | /** \brief Set Fault Mask
545 |
546 | This function assigns the given value to the Fault Mask register.
547 |
548 | \param [in] faultMask Fault Mask value to set
549 | */
550 | __attribute__( ( always_inline ) ) static __INLINE void __set_FAULTMASK(uint32_t faultMask)
551 | {
552 | __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) );
553 | }
554 |
555 | #endif /* (__CORTEX_M >= 0x03) */
556 |
557 |
558 | #if (__CORTEX_M == 0x04)
559 |
560 | /** \brief Get FPSCR
561 |
562 | This function returns the current value of the Floating Point Status/Control register.
563 |
564 | \return Floating Point Status/Control register value
565 | */
566 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_FPSCR(void)
567 | {
568 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
569 | uint32_t result;
570 |
571 | __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
572 | return(result);
573 | #else
574 | return(0);
575 | #endif
576 | }
577 |
578 |
579 | /** \brief Set FPSCR
580 |
581 | This function assigns the given value to the Floating Point Status/Control register.
582 |
583 | \param [in] fpscr Floating Point Status/Control value to set
584 | */
585 | __attribute__( ( always_inline ) ) static __INLINE void __set_FPSCR(uint32_t fpscr)
586 | {
587 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
588 | __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) );
589 | #endif
590 | }
591 |
592 | #endif /* (__CORTEX_M == 0x04) */
593 |
594 |
595 | #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
596 | /* TASKING carm specific functions */
597 |
598 | /*
599 | * The CMSIS functions have been implemented as intrinsics in the compiler.
600 | * Please use "carm -?i" to get an up to date list of all instrinsics,
601 | * Including the CMSIS ones.
602 | */
603 |
604 | #endif
605 |
606 | /*@} end of CMSIS_Core_RegAccFunctions */
607 |
608 |
609 | #endif /* __CORE_CMFUNC_H */
610 |
--------------------------------------------------------------------------------
/arm_ucos/src/CMSIS/iar_cortexM4l_math.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wlgq2/Oscilloscope/5f4895840352b80a9925aacdb7ed7563082526e0/arm_ucos/src/CMSIS/iar_cortexM4l_math.a
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/CMSIS/arm_common_tables.h:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------
2 | * Copyright (C) 2010 ARM Limited. All rights reserved.
3 | *
4 | * $Date: 11. November 2010
5 | * $Revision: V1.0.2
6 | *
7 | * Project: CMSIS DSP Library
8 | * Title: arm_common_tables.h
9 | *
10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions
11 | *
12 | * Target Processor: Cortex-M4/Cortex-M3
13 | *
14 | * Version 1.0.2 2010/11/11
15 | * Documentation updated.
16 | *
17 | * Version 1.0.1 2010/10/05
18 | * Production release and review comments incorporated.
19 | *
20 | * Version 1.0.0 2010/09/20
21 | * Production release and review comments incorporated.
22 | * -------------------------------------------------------------------- */
23 |
24 | #ifndef _ARM_COMMON_TABLES_H
25 | #define _ARM_COMMON_TABLES_H
26 |
27 | #include "arm_math.h"
28 |
29 | extern uint16_t armBitRevTable[256];
30 | extern q15_t armRecipTableQ15[64];
31 | extern q31_t armRecipTableQ31[64];
32 | extern const q31_t realCoefAQ31[1024];
33 | extern const q31_t realCoefBQ31[1024];
34 |
35 | #endif /* ARM_COMMON_TABLES_H */
36 |
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/CMSIS/core_cmFunc.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file core_cmFunc.h
3 | * @brief CMSIS Cortex-M Core Function Access Header File
4 | * @version V2.10
5 | * @date 26. July 2011
6 | *
7 | * @note
8 | * Copyright (C) 2009-2011 ARM Limited. All rights reserved.
9 | *
10 | * @par
11 | * ARM Limited (ARM) is supplying this software for use with Cortex-M
12 | * processor based microcontrollers. This file can be freely distributed
13 | * within development tools that are supporting such ARM based processors.
14 | *
15 | * @par
16 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
17 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
19 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
20 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
21 | *
22 | ******************************************************************************/
23 |
24 | #ifndef __CORE_CMFUNC_H
25 | #define __CORE_CMFUNC_H
26 |
27 |
28 | /* ########################### Core Function Access ########################### */
29 | /** \ingroup CMSIS_Core_FunctionInterface
30 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
31 | @{
32 | */
33 |
34 | #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
35 | /* ARM armcc specific functions */
36 |
37 | #if (__ARMCC_VERSION < 400677)
38 | #error "Please use ARM Compiler Toolchain V4.0.677 or later!"
39 | #endif
40 |
41 | /* intrinsic void __enable_irq(); */
42 | /* intrinsic void __disable_irq(); */
43 |
44 | /** \brief Get Control Register
45 |
46 | This function returns the content of the Control Register.
47 |
48 | \return Control Register value
49 | */
50 | static __INLINE uint32_t __get_CONTROL(void)
51 | {
52 | register uint32_t __regControl __ASM("control");
53 | return(__regControl);
54 | }
55 |
56 |
57 | /** \brief Set Control Register
58 |
59 | This function writes the given value to the Control Register.
60 |
61 | \param [in] control Control Register value to set
62 | */
63 | static __INLINE void __set_CONTROL(uint32_t control)
64 | {
65 | register uint32_t __regControl __ASM("control");
66 | __regControl = control;
67 | }
68 |
69 |
70 | /** \brief Get ISPR Register
71 |
72 | This function returns the content of the ISPR Register.
73 |
74 | \return ISPR Register value
75 | */
76 | static __INLINE uint32_t __get_IPSR(void)
77 | {
78 | register uint32_t __regIPSR __ASM("ipsr");
79 | return(__regIPSR);
80 | }
81 |
82 |
83 | /** \brief Get APSR Register
84 |
85 | This function returns the content of the APSR Register.
86 |
87 | \return APSR Register value
88 | */
89 | static __INLINE uint32_t __get_APSR(void)
90 | {
91 | register uint32_t __regAPSR __ASM("apsr");
92 | return(__regAPSR);
93 | }
94 |
95 |
96 | /** \brief Get xPSR Register
97 |
98 | This function returns the content of the xPSR Register.
99 |
100 | \return xPSR Register value
101 | */
102 | static __INLINE uint32_t __get_xPSR(void)
103 | {
104 | register uint32_t __regXPSR __ASM("xpsr");
105 | return(__regXPSR);
106 | }
107 |
108 |
109 | /** \brief Get Process Stack Pointer
110 |
111 | This function returns the current value of the Process Stack Pointer (PSP).
112 |
113 | \return PSP Register value
114 | */
115 | static __INLINE uint32_t __get_PSP(void)
116 | {
117 | register uint32_t __regProcessStackPointer __ASM("psp");
118 | return(__regProcessStackPointer);
119 | }
120 |
121 |
122 | /** \brief Set Process Stack Pointer
123 |
124 | This function assigns the given value to the Process Stack Pointer (PSP).
125 |
126 | \param [in] topOfProcStack Process Stack Pointer value to set
127 | */
128 | static __INLINE void __set_PSP(uint32_t topOfProcStack)
129 | {
130 | register uint32_t __regProcessStackPointer __ASM("psp");
131 | __regProcessStackPointer = topOfProcStack;
132 | }
133 |
134 |
135 | /** \brief Get Main Stack Pointer
136 |
137 | This function returns the current value of the Main Stack Pointer (MSP).
138 |
139 | \return MSP Register value
140 | */
141 | static __INLINE uint32_t __get_MSP(void)
142 | {
143 | register uint32_t __regMainStackPointer __ASM("msp");
144 | return(__regMainStackPointer);
145 | }
146 |
147 |
148 | /** \brief Set Main Stack Pointer
149 |
150 | This function assigns the given value to the Main Stack Pointer (MSP).
151 |
152 | \param [in] topOfMainStack Main Stack Pointer value to set
153 | */
154 | static __INLINE void __set_MSP(uint32_t topOfMainStack)
155 | {
156 | register uint32_t __regMainStackPointer __ASM("msp");
157 | __regMainStackPointer = topOfMainStack;
158 | }
159 |
160 |
161 | /** \brief Get Priority Mask
162 |
163 | This function returns the current state of the priority mask bit from the Priority Mask Register.
164 |
165 | \return Priority Mask value
166 | */
167 | static __INLINE uint32_t __get_PRIMASK(void)
168 | {
169 | register uint32_t __regPriMask __ASM("primask");
170 | return(__regPriMask);
171 | }
172 |
173 |
174 | /** \brief Set Priority Mask
175 |
176 | This function assigns the given value to the Priority Mask Register.
177 |
178 | \param [in] priMask Priority Mask
179 | */
180 | static __INLINE void __set_PRIMASK(uint32_t priMask)
181 | {
182 | register uint32_t __regPriMask __ASM("primask");
183 | __regPriMask = (priMask);
184 | }
185 |
186 |
187 | #if (__CORTEX_M >= 0x03)
188 |
189 | /** \brief Enable FIQ
190 |
191 | This function enables FIQ interrupts by clearing the F-bit in the CPSR.
192 | Can only be executed in Privileged modes.
193 | */
194 | #define __enable_fault_irq __enable_fiq
195 |
196 |
197 | /** \brief Disable FIQ
198 |
199 | This function disables FIQ interrupts by setting the F-bit in the CPSR.
200 | Can only be executed in Privileged modes.
201 | */
202 | #define __disable_fault_irq __disable_fiq
203 |
204 |
205 | /** \brief Get Base Priority
206 |
207 | This function returns the current value of the Base Priority register.
208 |
209 | \return Base Priority register value
210 | */
211 | static __INLINE uint32_t __get_BASEPRI(void)
212 | {
213 | register uint32_t __regBasePri __ASM("basepri");
214 | return(__regBasePri);
215 | }
216 |
217 |
218 | /** \brief Set Base Priority
219 |
220 | This function assigns the given value to the Base Priority register.
221 |
222 | \param [in] basePri Base Priority value to set
223 | */
224 | static __INLINE void __set_BASEPRI(uint32_t basePri)
225 | {
226 | register uint32_t __regBasePri __ASM("basepri");
227 | __regBasePri = (basePri & 0xff);
228 | }
229 |
230 |
231 | /** \brief Get Fault Mask
232 |
233 | This function returns the current value of the Fault Mask register.
234 |
235 | \return Fault Mask register value
236 | */
237 | static __INLINE uint32_t __get_FAULTMASK(void)
238 | {
239 | register uint32_t __regFaultMask __ASM("faultmask");
240 | return(__regFaultMask);
241 | }
242 |
243 |
244 | /** \brief Set Fault Mask
245 |
246 | This function assigns the given value to the Fault Mask register.
247 |
248 | \param [in] faultMask Fault Mask value to set
249 | */
250 | static __INLINE void __set_FAULTMASK(uint32_t faultMask)
251 | {
252 | register uint32_t __regFaultMask __ASM("faultmask");
253 | __regFaultMask = (faultMask & (uint32_t)1);
254 | }
255 |
256 | #endif /* (__CORTEX_M >= 0x03) */
257 |
258 |
259 | #if (__CORTEX_M == 0x04)
260 |
261 | /** \brief Get FPSCR
262 |
263 | This function returns the current value of the Floating Point Status/Control register.
264 |
265 | \return Floating Point Status/Control register value
266 | */
267 | static __INLINE uint32_t __get_FPSCR(void)
268 | {
269 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
270 | register uint32_t __regfpscr __ASM("fpscr");
271 | return(__regfpscr);
272 | #else
273 | return(0);
274 | #endif
275 | }
276 |
277 |
278 | /** \brief Set FPSCR
279 |
280 | This function assigns the given value to the Floating Point Status/Control register.
281 |
282 | \param [in] fpscr Floating Point Status/Control value to set
283 | */
284 | static __INLINE void __set_FPSCR(uint32_t fpscr)
285 | {
286 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
287 | register uint32_t __regfpscr __ASM("fpscr");
288 | __regfpscr = (fpscr);
289 | #endif
290 | }
291 |
292 | #endif /* (__CORTEX_M == 0x04) */
293 |
294 |
295 | #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
296 | /* IAR iccarm specific functions */
297 |
298 | #include
299 |
300 | #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
301 | /* GNU gcc specific functions */
302 |
303 | /** \brief Enable IRQ Interrupts
304 |
305 | This function enables IRQ interrupts by clearing the I-bit in the CPSR.
306 | Can only be executed in Privileged modes.
307 | */
308 | __attribute__( ( always_inline ) ) static __INLINE void __enable_irq(void)
309 | {
310 | __ASM volatile ("cpsie i");
311 | }
312 |
313 |
314 | /** \brief Disable IRQ Interrupts
315 |
316 | This function disables IRQ interrupts by setting the I-bit in the CPSR.
317 | Can only be executed in Privileged modes.
318 | */
319 | __attribute__( ( always_inline ) ) static __INLINE void __disable_irq(void)
320 | {
321 | __ASM volatile ("cpsid i");
322 | }
323 |
324 |
325 | /** \brief Get Control Register
326 |
327 | This function returns the content of the Control Register.
328 |
329 | \return Control Register value
330 | */
331 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_CONTROL(void)
332 | {
333 | uint32_t result;
334 |
335 | __ASM volatile ("MRS %0, control" : "=r" (result) );
336 | return(result);
337 | }
338 |
339 |
340 | /** \brief Set Control Register
341 |
342 | This function writes the given value to the Control Register.
343 |
344 | \param [in] control Control Register value to set
345 | */
346 | __attribute__( ( always_inline ) ) static __INLINE void __set_CONTROL(uint32_t control)
347 | {
348 | __ASM volatile ("MSR control, %0" : : "r" (control) );
349 | }
350 |
351 |
352 | /** \brief Get ISPR Register
353 |
354 | This function returns the content of the ISPR Register.
355 |
356 | \return ISPR Register value
357 | */
358 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_IPSR(void)
359 | {
360 | uint32_t result;
361 |
362 | __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
363 | return(result);
364 | }
365 |
366 |
367 | /** \brief Get APSR Register
368 |
369 | This function returns the content of the APSR Register.
370 |
371 | \return APSR Register value
372 | */
373 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_APSR(void)
374 | {
375 | uint32_t result;
376 |
377 | __ASM volatile ("MRS %0, apsr" : "=r" (result) );
378 | return(result);
379 | }
380 |
381 |
382 | /** \brief Get xPSR Register
383 |
384 | This function returns the content of the xPSR Register.
385 |
386 | \return xPSR Register value
387 | */
388 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_xPSR(void)
389 | {
390 | uint32_t result;
391 |
392 | __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
393 | return(result);
394 | }
395 |
396 |
397 | /** \brief Get Process Stack Pointer
398 |
399 | This function returns the current value of the Process Stack Pointer (PSP).
400 |
401 | \return PSP Register value
402 | */
403 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_PSP(void)
404 | {
405 | register uint32_t result;
406 |
407 | __ASM volatile ("MRS %0, psp\n" : "=r" (result) );
408 | return(result);
409 | }
410 |
411 |
412 | /** \brief Set Process Stack Pointer
413 |
414 | This function assigns the given value to the Process Stack Pointer (PSP).
415 |
416 | \param [in] topOfProcStack Process Stack Pointer value to set
417 | */
418 | __attribute__( ( always_inline ) ) static __INLINE void __set_PSP(uint32_t topOfProcStack)
419 | {
420 | __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) );
421 | }
422 |
423 |
424 | /** \brief Get Main Stack Pointer
425 |
426 | This function returns the current value of the Main Stack Pointer (MSP).
427 |
428 | \return MSP Register value
429 | */
430 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_MSP(void)
431 | {
432 | register uint32_t result;
433 |
434 | __ASM volatile ("MRS %0, msp\n" : "=r" (result) );
435 | return(result);
436 | }
437 |
438 |
439 | /** \brief Set Main Stack Pointer
440 |
441 | This function assigns the given value to the Main Stack Pointer (MSP).
442 |
443 | \param [in] topOfMainStack Main Stack Pointer value to set
444 | */
445 | __attribute__( ( always_inline ) ) static __INLINE void __set_MSP(uint32_t topOfMainStack)
446 | {
447 | __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) );
448 | }
449 |
450 |
451 | /** \brief Get Priority Mask
452 |
453 | This function returns the current state of the priority mask bit from the Priority Mask Register.
454 |
455 | \return Priority Mask value
456 | */
457 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_PRIMASK(void)
458 | {
459 | uint32_t result;
460 |
461 | __ASM volatile ("MRS %0, primask" : "=r" (result) );
462 | return(result);
463 | }
464 |
465 |
466 | /** \brief Set Priority Mask
467 |
468 | This function assigns the given value to the Priority Mask Register.
469 |
470 | \param [in] priMask Priority Mask
471 | */
472 | __attribute__( ( always_inline ) ) static __INLINE void __set_PRIMASK(uint32_t priMask)
473 | {
474 | __ASM volatile ("MSR primask, %0" : : "r" (priMask) );
475 | }
476 |
477 |
478 | #if (__CORTEX_M >= 0x03)
479 |
480 | /** \brief Enable FIQ
481 |
482 | This function enables FIQ interrupts by clearing the F-bit in the CPSR.
483 | Can only be executed in Privileged modes.
484 | */
485 | __attribute__( ( always_inline ) ) static __INLINE void __enable_fault_irq(void)
486 | {
487 | __ASM volatile ("cpsie f");
488 | }
489 |
490 |
491 | /** \brief Disable FIQ
492 |
493 | This function disables FIQ interrupts by setting the F-bit in the CPSR.
494 | Can only be executed in Privileged modes.
495 | */
496 | __attribute__( ( always_inline ) ) static __INLINE void __disable_fault_irq(void)
497 | {
498 | __ASM volatile ("cpsid f");
499 | }
500 |
501 |
502 | /** \brief Get Base Priority
503 |
504 | This function returns the current value of the Base Priority register.
505 |
506 | \return Base Priority register value
507 | */
508 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_BASEPRI(void)
509 | {
510 | uint32_t result;
511 |
512 | __ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
513 | return(result);
514 | }
515 |
516 |
517 | /** \brief Set Base Priority
518 |
519 | This function assigns the given value to the Base Priority register.
520 |
521 | \param [in] basePri Base Priority value to set
522 | */
523 | __attribute__( ( always_inline ) ) static __INLINE void __set_BASEPRI(uint32_t value)
524 | {
525 | __ASM volatile ("MSR basepri, %0" : : "r" (value) );
526 | }
527 |
528 |
529 | /** \brief Get Fault Mask
530 |
531 | This function returns the current value of the Fault Mask register.
532 |
533 | \return Fault Mask register value
534 | */
535 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_FAULTMASK(void)
536 | {
537 | uint32_t result;
538 |
539 | __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
540 | return(result);
541 | }
542 |
543 |
544 | /** \brief Set Fault Mask
545 |
546 | This function assigns the given value to the Fault Mask register.
547 |
548 | \param [in] faultMask Fault Mask value to set
549 | */
550 | __attribute__( ( always_inline ) ) static __INLINE void __set_FAULTMASK(uint32_t faultMask)
551 | {
552 | __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) );
553 | }
554 |
555 | #endif /* (__CORTEX_M >= 0x03) */
556 |
557 |
558 | #if (__CORTEX_M == 0x04)
559 |
560 | /** \brief Get FPSCR
561 |
562 | This function returns the current value of the Floating Point Status/Control register.
563 |
564 | \return Floating Point Status/Control register value
565 | */
566 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_FPSCR(void)
567 | {
568 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
569 | uint32_t result;
570 |
571 | __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
572 | return(result);
573 | #else
574 | return(0);
575 | #endif
576 | }
577 |
578 |
579 | /** \brief Set FPSCR
580 |
581 | This function assigns the given value to the Floating Point Status/Control register.
582 |
583 | \param [in] fpscr Floating Point Status/Control value to set
584 | */
585 | __attribute__( ( always_inline ) ) static __INLINE void __set_FPSCR(uint32_t fpscr)
586 | {
587 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
588 | __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) );
589 | #endif
590 | }
591 |
592 | #endif /* (__CORTEX_M == 0x04) */
593 |
594 |
595 | #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
596 | /* TASKING carm specific functions */
597 |
598 | /*
599 | * The CMSIS functions have been implemented as intrinsics in the compiler.
600 | * Please use "carm -?i" to get an up to date list of all instrinsics,
601 | * Including the CMSIS ones.
602 | */
603 |
604 | #endif
605 |
606 | /*@} end of CMSIS_Core_RegAccFunctions */
607 |
608 |
609 | #endif /* __CORE_CMFUNC_H */
610 |
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/CMSIS/iar_cortexM4l_math.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wlgq2/Oscilloscope/5f4895840352b80a9925aacdb7ed7563082526e0/arm_ucos/src/LIB/CMSIS/iar_cortexM4l_math.a
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/FatFs/00readme.txt:
--------------------------------------------------------------------------------
1 | FatFs Module Source Files R0.09 (C)ChaN, 2011
2 |
3 |
4 | FILES
5 |
6 | ffconf.h Configuration file for FatFs module.
7 | ff.h Common include file for FatFs and application module.
8 | ff.c FatFs module.
9 | diskio.h Common include file for FatFs and disk I/O module.
10 | integer.h Alternative type definitions for integer variables.
11 | option Optional external functions.
12 |
13 | Low level disk I/O module is not included in this archive because the FatFs
14 | module is only a generic file system layer and not depend on any specific
15 | storage device. You have to provide a low level disk I/O module that written
16 | to control your storage device.
17 |
18 |
19 |
20 | AGREEMENTS
21 |
22 | FatFs module is an open source software to implement FAT file system to
23 | small embedded systems. This is a free software and is opened for education,
24 | research and commercial developments under license policy of following trems.
25 |
26 | Copyright (C) 2011, ChaN, all right reserved.
27 |
28 | * The FatFs module is a free software and there is NO WARRANTY.
29 | * No restriction on use. You can use, modify and redistribute it for
30 | personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
31 | * Redistributions of source code must retain the above copyright notice.
32 |
33 |
34 |
35 | REVISION HISTORY
36 |
37 | Feb 26, 2006 R0.00 Prototype
38 |
39 | Apr 29, 2006 R0.01 First release.
40 |
41 | Jun 01, 2006 R0.02 Added FAT12.
42 | Removed unbuffered mode.
43 | Fixed a problem on small (<32M) patition.
44 |
45 | Jun 10, 2006 R0.02a Added a configuration option _FS_MINIMUM.
46 |
47 | Sep 22, 2006 R0.03 Added f_rename.
48 | Changed option _FS_MINIMUM to _FS_MINIMIZE.
49 |
50 | Dec 11, 2006 R0.03a Improved cluster scan algolithm to write files fast.
51 | Fixed f_mkdir creates incorrect directory on FAT32.
52 |
53 | Feb 04, 2007 R0.04 Supported multiple drive system. (FatFs)
54 | Changed some APIs for multiple drive system.
55 | Added f_mkfs. (FatFs)
56 | Added _USE_FAT32 option. (Tiny-FatFs)
57 |
58 | Apr 01, 2007 R0.04a Supported multiple partitions on a plysical drive. (FatFs)
59 | Fixed an endian sensitive code in f_mkfs. (FatFs)
60 | Added a capability of extending the file size to f_lseek.
61 | Added minimization level 3.
62 | Fixed a problem that can collapse a sector when recreate an
63 | existing file in any sub-directory at non FAT32 cfg. (Tiny-FatFs)
64 |
65 | May 05, 2007 R0.04b Added _USE_NTFLAG option.
66 | Added FSInfo support.
67 | Fixed some problems corresponds to FAT32. (Tiny-FatFs)
68 | Fixed DBCS name can result FR_INVALID_NAME.
69 | Fixed short seek (0 < ofs <= csize) collapses the file object.
70 |
71 | Aug 25, 2007 R0.05 Changed arguments of f_read, f_write.
72 | Changed arguments of f_mkfs. (FatFs)
73 | Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs)
74 | Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs)
75 |
76 | Feb 03, 2008 R0.05a Added f_truncate().
77 | Added f_utime().
78 | Fixed off by one error at FAT sub-type determination.
79 | Fixed btr in f_read() can be mistruncated.
80 | Fixed cached sector is not flushed when create and close without write.
81 |
82 | Apr 01, 2008 R0.06 Added f_forward(). (Tiny-FatFs)
83 | Added string functions: fputc(), fputs(), fprintf() and fgets().
84 | Improved performance of f_lseek() on move to the same or following cluster.
85 |
86 | Apr 01, 2009, R0.07 Merged Tiny-FatFs as a buffer configuration option.
87 | Added long file name support.
88 | Added multiple code page support.
89 | Added re-entrancy for multitask operation.
90 | Added auto cluster size selection to f_mkfs().
91 | Added rewind option to f_readdir().
92 | Changed result code of critical errors.
93 | Renamed string functions to avoid name collision.
94 |
95 | Apr 14, 2009, R0.07a Separated out OS dependent code on reentrant cfg.
96 | Added multiple sector size support.
97 |
98 | Jun 21, 2009, R0.07c Fixed f_unlink() may return FR_OK on error.
99 | Fixed wrong cache control in f_lseek().
100 | Added relative path feature.
101 | Added f_chdir().
102 | Added f_chdrive().
103 | Added proper case conversion for extended characters.
104 |
105 | Nov 03, 2009 R0.07e Separated out configuration options from ff.h to ffconf.h.
106 | Added a configuration option, _LFN_UNICODE.
107 | Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
108 | Fixed name matching error on the 13 char boundary.
109 | Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
110 |
111 | May 15, 2010, R0.08 Added a memory configuration option. (_USE_LFN)
112 | Added file lock feature. (_FS_SHARE)
113 | Added fast seek feature. (_USE_FASTSEEK)
114 | Changed some types on the API, XCHAR->TCHAR.
115 | Changed fname member in the FILINFO structure on Unicode cfg.
116 | String functions support UTF-8 encoding files on Unicode cfg.
117 |
118 | Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)
119 | Added sector erase feature. (_USE_ERASE)
120 | Moved file lock semaphore table from fs object to the bss.
121 | Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
122 | Fixed f_mkfs() creates wrong FAT32 volume.
123 |
124 | Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
125 | f_lseek() reports required table size on creating CLMP.
126 | Extended format syntax of f_printf function.
127 | Ignores duplicated directory separators in given path names.
128 |
129 | Sep 06,'11 R0.09 f_mkfs() supports multiple partition to finish the multiple partition feature.
130 | Added f_fdisk(). (_MULTI_PARTITION = 2)
131 |
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/FatFs/diskio.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wlgq2/Oscilloscope/5f4895840352b80a9925aacdb7ed7563082526e0/arm_ucos/src/LIB/FatFs/diskio.c
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/FatFs/diskio.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wlgq2/Oscilloscope/5f4895840352b80a9925aacdb7ed7563082526e0/arm_ucos/src/LIB/FatFs/diskio.h
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/FatFs/ff.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wlgq2/Oscilloscope/5f4895840352b80a9925aacdb7ed7563082526e0/arm_ucos/src/LIB/FatFs/ff.c
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/FatFs/ff.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wlgq2/Oscilloscope/5f4895840352b80a9925aacdb7ed7563082526e0/arm_ucos/src/LIB/FatFs/ff.h
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/FatFs/ffconf.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wlgq2/Oscilloscope/5f4895840352b80a9925aacdb7ed7563082526e0/arm_ucos/src/LIB/FatFs/ffconf.h
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/FatFs/integer.h:
--------------------------------------------------------------------------------
1 | /*-------------------------------------------*/
2 | /* Integer type definitions for FatFs module */
3 | /*-------------------------------------------*/
4 |
5 | #ifndef _INTEGER
6 | #define _INTEGER
7 |
8 | #ifdef _WIN32 /* FatFs development platform */
9 |
10 | #include
11 | #include
12 |
13 | #else /* Embedded platform */
14 |
15 |
16 |
17 | /* These types must be 16-bit, 32-bit or larger integer */
18 | typedef int INT;
19 | typedef unsigned int UINT;
20 |
21 | /* These types must be 8-bit integer */
22 | typedef char CHAR;
23 | typedef unsigned char UCHAR;
24 | typedef unsigned char BYTE;
25 |
26 | /* These types must be 16-bit integer */
27 | typedef short SHORT;
28 | typedef unsigned short USHORT;
29 | typedef unsigned short WORD;
30 | typedef unsigned short WCHAR;
31 |
32 | /* These types must be 32-bit integer */
33 | typedef long LONG;
34 | typedef unsigned long ULONG;
35 | typedef unsigned long DWORD;
36 |
37 | #endif
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/arm_ucos/src/LIB/FatFs/option/syscall.c:
--------------------------------------------------------------------------------
1 | /*------------------------------------------------------------------------*/
2 | /* Sample code of OS dependent controls for FatFs R0.08b */
3 | /* (C)ChaN, 2011 */
4 | /*------------------------------------------------------------------------*/
5 |
6 | #include /* ANSI memory controls */
7 | #include /* ANSI memory controls */
8 |
9 | #include "../ff.h"
10 |
11 |
12 | #if _FS_REENTRANT
13 | /*------------------------------------------------------------------------*/
14 | /* Create a Synchronization Object
15 | /*------------------------------------------------------------------------*/
16 | /* This function is called in f_mount function to create a new
17 | / synchronization object, such as semaphore and mutex. When a zero is
18 | / returned, the f_mount function fails with FR_INT_ERR.
19 | */
20 |
21 | int ff_cre_syncobj ( /* TRUE:Function succeeded, FALSE:Could not create due to any error */
22 | BYTE vol, /* Corresponding logical drive being processed */
23 | _SYNC_t *sobj /* Pointer to return the created sync object */
24 | )
25 | {
26 | int ret;
27 |
28 | *sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */
29 | ret = (*sobj != INVALID_HANDLE_VALUE);
30 |
31 | // *sobj = SyncObjects[vol]; /* uITRON (give a static sync object) */
32 | // ret = 1; /* The initial value of the semaphore must be 1. */
33 |
34 | // *sobj = OSMutexCreate(0, &err); /* uC/OS-II */
35 | // ret = (err == OS_NO_ERR);
36 |
37 | // *sobj = xSemaphoreCreateMutex(); /* FreeRTOS */
38 | // ret = (*sobj != NULL);
39 |
40 | return ret;
41 | }
42 |
43 |
44 |
45 | /*------------------------------------------------------------------------*/
46 | /* Delete a Synchronization Object */
47 | /*------------------------------------------------------------------------*/
48 | /* This function is called in f_mount function to delete a synchronization
49 | / object that created with ff_cre_syncobj function. When a zero is
50 | / returned, the f_mount function fails with FR_INT_ERR.
51 | */
52 |
53 | int ff_del_syncobj ( /* TRUE:Function succeeded, FALSE:Could not delete due to any error */
54 | _SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
55 | )
56 | {
57 | BOOL ret;
58 |
59 | ret = CloseHandle(sobj); /* Win32 */
60 |
61 | // ret = 1; /* uITRON (nothing to do) */
62 |
63 | // OSMutexDel(sobj, OS_DEL_ALWAYS, &err); /* uC/OS-II */
64 | // ret = (err == OS_NO_ERR);
65 |
66 | // ret = 1; /* FreeRTOS (nothing to do) */
67 |
68 | return ret;
69 | }
70 |
71 |
72 |
73 | /*------------------------------------------------------------------------*/
74 | /* Request Grant to Access the Volume */
75 | /*------------------------------------------------------------------------*/
76 | /* This function is called on entering file functions to lock the volume.
77 | / When a zero is returned, the file function fails with FR_TIMEOUT.
78 | */
79 |
80 | int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
81 | _SYNC_t sobj /* Sync object to wait */
82 | )
83 | {
84 | int ret;
85 |
86 | ret = (WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0); /* Win32 */
87 |
88 | // ret = (wai_sem(sobj) == E_OK); /* uITRON */
89 |
90 | // OSMutexPend(sobj, _FS_TIMEOUT, &err)); /* uC/OS-II */
91 | // ret = (err == OS_NO_ERR);
92 |
93 | // ret = (xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE); /* FreeRTOS */
94 |
95 | return ret;
96 | }
97 |
98 |
99 |
100 | /*------------------------------------------------------------------------*/
101 | /* Release Grant to Access the Volume */
102 | /*------------------------------------------------------------------------*/
103 | /* This function is called on leaving file functions to unlock the volume.
104 | */
105 |
106 | void ff_rel_grant (
107 | _SYNC_t sobj /* Sync object to be signaled */
108 | )
109 | {
110 | ReleaseMutex(sobj); /* Win32 */
111 |
112 | // sig_sem(sobj); /* uITRON */
113 |
114 | // OSMutexPost(sobj); /* uC/OS-II */
115 |
116 | // xSemaphoreGive(sobj); /* FreeRTOS */
117 |
118 | }
119 |
120 | #endif
121 |
122 |
123 |
124 |
125 | #if _USE_LFN == 3 /* LFN with a working buffer on the heap */
126 | /*------------------------------------------------------------------------*/
127 | /* Allocate a memory block */
128 | /*------------------------------------------------------------------------*/
129 | /* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
130 | */
131 |
132 | void *ff_memalloc ( /* Returns pointer to the allocated memory block */
133 | UINT size /* Number of bytes to allocate */
134 | )
135 | {
136 | return malloc(size);
137 | }
138 |
139 |
140 | /*------------------------------------------------------------------------*/
141 | /* Free a memory block */
142 | /*------------------------------------------------------------------------*/
143 |
144 | void ff_memfree(
145 | void *mblock /* Pointer to the memory block to free */
146 | )
147 | {
148 | free(mblock);
149 | }
150 |
151 | #endif
152 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/alloc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * File: alloc.c
3 | * Purpose: generic malloc() and free() engine
4 | *
5 | * Notes: 99% of this code stolen/borrowed from the K&R C
6 | * examples.
7 | *
8 | */
9 |
10 | #include "common.h"
11 | #include "stdlib.h"
12 |
13 | #pragma section = "HEAP"
14 |
15 | /********************************************************************/
16 |
17 | /*
18 | * This struct forms the minimum block size which is allocated, and
19 | * also forms the linked list for the memory space used with alloc()
20 | * and free(). It is padded so that on a 32-bit machine, all malloc'ed
21 | * pointers are 16-byte aligned.
22 | */
23 | typedef struct ALLOC_HDR
24 | {
25 | struct
26 | {
27 | struct ALLOC_HDR *ptr;
28 | unsigned int size;
29 | } s;
30 | unsigned int align;
31 | unsigned int pad;
32 | } ALLOC_HDR;
33 |
34 | static ALLOC_HDR base;
35 | static ALLOC_HDR *freep = NULL;
36 |
37 | /********************************************************************/
38 | void
39 | free (void *ap)
40 | {
41 | ALLOC_HDR *bp, *p;
42 |
43 | bp = (ALLOC_HDR *)ap - 1; /* point to block header */
44 | for (p = freep; !((bp > p) && (bp < p->s.ptr)) ; p = p->s.ptr)
45 | {
46 | if ((p >= p->s.ptr) && ((bp > p) || (bp < p->s.ptr)))
47 | {
48 | break; /* freed block at start or end of arena */
49 | }
50 | }
51 |
52 | if ((bp + bp->s.size) == p->s.ptr)
53 | {
54 | bp->s.size += p->s.ptr->s.size;
55 | bp->s.ptr = p->s.ptr->s.ptr;
56 | }
57 | else
58 | {
59 | bp->s.ptr = p->s.ptr;
60 | }
61 |
62 | if ((p + p->s.size) == bp)
63 | {
64 | p->s.size += bp->s.size;
65 | p->s.ptr = bp->s.ptr;
66 | }
67 | else
68 | {
69 | p->s.ptr = bp;
70 | }
71 |
72 | freep = p;
73 | }
74 |
75 | /********************************************************************/
76 | void *
77 | malloc (unsigned nbytes)
78 | {
79 | /* Get addresses for the HEAP start and end */
80 | #if (defined(CW))
81 | extern char __HEAP_START;
82 | extern char __HEAP_END[];
83 | #elif (defined(IAR))
84 | char* __HEAP_START = __section_begin("HEAP");
85 | char* __HEAP_END = __section_end("HEAP");
86 | #endif
87 |
88 | ALLOC_HDR *p, *prevp;
89 | unsigned nunits;
90 |
91 | nunits = ((nbytes+sizeof(ALLOC_HDR)-1) / sizeof(ALLOC_HDR)) + 1;
92 |
93 | if ((prevp = freep) == NULL)
94 | {
95 | p = (ALLOC_HDR *)__HEAP_START;
96 | p->s.size = ( ((uint32)__HEAP_END - (uint32)__HEAP_START)
97 | / sizeof(ALLOC_HDR) );
98 | p->s.ptr = &base;
99 | base.s.ptr = p;
100 | base.s.size = 0;
101 | prevp = freep = &base;
102 | }
103 |
104 | for (p = prevp->s.ptr; ; prevp = p, p = p->s.ptr)
105 | {
106 | if (p->s.size >= nunits)
107 | {
108 | if (p->s.size == nunits)
109 | {
110 | prevp->s.ptr = p->s.ptr;
111 | }
112 | else
113 | {
114 | p->s.size -= nunits;
115 | p += p->s.size;
116 | p->s.size = nunits;
117 | }
118 | freep = prevp;
119 | return (void *)(p + 1);
120 | }
121 |
122 | if (p == freep)
123 | return NULL;
124 | }
125 | }
126 |
127 | /********************************************************************/
128 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/assert.c:
--------------------------------------------------------------------------------
1 | /*
2 | * File: assert.c
3 | * Purpose: Provide macro for software assertions
4 | *
5 | * Notes: ASSERT macro defined in assert.h calls assert_failed()
6 | */
7 |
8 | #include "common.h"
9 |
10 | const char ASSERT_FAILED_STR[] = "Assertion failed in %s at line %d\n";
11 |
12 | /********************************************************************/
13 | void
14 | assert_failed(char *file, int line)
15 | {
16 | int i;
17 |
18 | printf(ASSERT_FAILED_STR, file, line);
19 |
20 | while (1)
21 | {
22 | // platform_led_display(0xFF);
23 | for (i = 100000; i; i--) ;
24 | // platform_led_display(0x00);
25 | for (i = 100000; i; i--) ;
26 | }
27 | }
28 | /********************************************************************/
29 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/assert.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: assert.h
3 | * Purpose: Provide macro for software assertions
4 | *
5 | * Notes: assert_failed() defined in assert.c
6 | */
7 |
8 | #ifndef _ASSERT_H_
9 | #define _ASSERT_H_
10 |
11 | /********************************************************************/
12 |
13 | void assert_failed(char *, int);
14 |
15 | #ifdef DEBUG_PRINT
16 | #define ASSERT(expr) \
17 | if (!(expr)) \
18 | assert_failed(__FILE__, __LINE__)
19 | #else
20 | #define ASSERT(expr)
21 | #endif
22 |
23 | /********************************************************************/
24 | #endif /* _ASSERT_H_ */
25 |
26 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/common.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: common.h
3 | * Purpose: File to be included by all project files
4 | *
5 | * Notes:
6 | */
7 |
8 | #ifndef _COMMON_H_
9 | #define _COMMON_H_
10 |
11 | /********************************************************************/
12 |
13 | /*
14 | * Debug prints ON (#define) or OFF (#undef)
15 | */
16 | #define DEBUG
17 | #define DEBUG_PRINT
18 |
19 | /*
20 | * Include the generic CPU header file
21 | */
22 | #include "arm_cm4.h"
23 |
24 | /*
25 | * Include the platform specific header file
26 | */
27 | #if (defined(TWR_K40X256))
28 | #include "k40_tower.h"
29 | #elif (defined(TWR_K60N512))
30 | #include "k60_tower.h"
31 | #elif (defined(TWR_K53N512))
32 | #include "k53_tower.h"
33 | #else
34 | #error "No valid platform defined"
35 | #endif
36 |
37 | /*
38 | * Include the cpu specific header file
39 | */
40 | #if (defined(CPU_MK40N512VMD100))
41 | // #include "MK40N512VMD100.h"
42 | #include "MK40DZ10.h"
43 | #elif (defined(CPU_MK60N512VMD100))
44 | // #include "MK60N512VMD100.h"
45 | #include "MK60DZ10.h"
46 | #elif (defined(CPU_MK53N512CMD100))
47 | // #include "MK53N512CMD100.h"
48 | #include "MK53DZ10.h"
49 | #else
50 | #error "No valid CPU defined"
51 | #endif
52 |
53 |
54 | /*
55 | * Include any toolchain specfic header files
56 | */
57 | #if (defined(CW))
58 | #include "cw.h"
59 | #elif (defined(IAR))
60 | #include "iar.h"
61 | #else
62 | #warning "No toolchain specific header included"
63 | #endif
64 |
65 | /*
66 | * Include common utilities
67 | */
68 | #include "assert.h"
69 | #include "io.h"
70 | #include "startup.h"
71 | #include "stdlib.h"
72 |
73 | #if (defined(IAR))
74 | #include "intrinsics.h"
75 | #endif
76 |
77 | /********************************************************************/
78 |
79 | #endif /* _COMMON_H_ */
80 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/io.c:
--------------------------------------------------------------------------------
1 | /*
2 | * File: io.c
3 | * Purpose: Serial Input/Output routines
4 | *
5 | * Notes: TERMINAL_PORT defined in .h
6 | */
7 |
8 | #include "common.h"
9 | #include "uart.h"
10 |
11 | /********************************************************************/
12 | char
13 | in_char (void)
14 | {
15 | return uart_getchar(TERM_PORT);
16 | }
17 | /********************************************************************/
18 | void
19 | out_char (char ch)
20 | {
21 | uart_putchar(TERM_PORT, ch);
22 | }
23 | /********************************************************************/
24 | int
25 | char_present (void)
26 | {
27 | return uart_getchar_present(TERM_PORT);
28 | }
29 | /********************************************************************/
30 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/io.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: io.h
3 | * Purpose: Serial Input/Output routines
4 | *
5 | */
6 |
7 | #ifndef _IO_H
8 | #define _IO_H
9 |
10 | /********************************************************************/
11 |
12 | char
13 | in_char(void);
14 |
15 | void
16 | out_char(char);
17 |
18 | int
19 | char_present(void);
20 |
21 | int
22 | printf(const char *, ... );
23 |
24 | int
25 | sprintf(char *, const char *, ... );
26 |
27 | /********************************************************************/
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/memtest.c:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | *
3 | * Filename: memtest.c
4 | *
5 | * Description: General-purpose memory testing functions.
6 | *
7 | * Notes: This software can be easily ported to systems with
8 | * different data bus widths by redefining 'datum'.
9 | *
10 | *
11 | * Copyright (c) 1998 by Michael Barr. This software is placed into
12 | * the public domain and may be used for any purpose. However, this
13 | * notice must not be changed or removed and no warranty is either
14 | * expressed or implied by its publication or distribution.
15 | **********************************************************************/
16 |
17 |
18 | #include "memtest.h"
19 |
20 |
21 | /**********************************************************************
22 | *
23 | * Function: memTestDataBus()
24 | *
25 | * Description: Test the data bus wiring in a memory region by
26 | * performing a walking 1's test at a fixed address
27 | * within that region. The address (and hence the
28 | * memory region) is selected by the caller.
29 | *
30 | * Notes:
31 | *
32 | * Returns: 0 if the test succeeds.
33 | * A non-zero result is the first pattern that failed.
34 | *
35 | **********************************************************************/
36 | datum
37 | memTestDataBus(volatile datum * address)
38 | {
39 | datum pattern;
40 |
41 |
42 | /*
43 | * Perform a walking 1's test at the given address.
44 | */
45 | for (pattern = 1; pattern != 0; pattern <<= 1)
46 | {
47 | /*
48 | * Write the test pattern.
49 | */
50 | *address = pattern;
51 |
52 | /*
53 | * Read it back (immediately is okay for this test).
54 | */
55 | if (*address != pattern)
56 | {
57 | return (pattern);
58 | }
59 | }
60 |
61 | return (0);
62 |
63 | } /* memTestDataBus() */
64 |
65 |
66 | /**********************************************************************
67 | *
68 | * Function: memTestAddressBus()
69 | *
70 | * Description: Test the address bus wiring in a memory region by
71 | * performing a walking 1's test on the relevant bits
72 | * of the address and checking for aliasing. This test
73 | * will find single-bit address failures such as stuck
74 | * -high, stuck-low, and shorted pins. The base address
75 | * and size of the region are selected by the caller.
76 | *
77 | * Notes: For best results, the selected base address should
78 | * have enough LSB 0's to guarantee single address bit
79 | * changes. For example, to test a 64-Kbyte region,
80 | * select a base address on a 64-Kbyte boundary. Also,
81 | * select the region size as a power-of-two--if at all
82 | * possible.
83 | *
84 | * Returns: NULL if the test succeeds.
85 | * A non-zero result is the first address at which an
86 | * aliasing problem was uncovered. By examining the
87 | * contents of memory, it may be possible to gather
88 | * additional information about the problem.
89 | *
90 | **********************************************************************/
91 | datum *
92 | memTestAddressBus(volatile datum * baseAddress, unsigned long nBytes)
93 | {
94 | unsigned long addressMask = (nBytes/sizeof(datum) - 1);
95 | unsigned long offset;
96 | unsigned long testOffset;
97 |
98 | datum pattern = (datum) 0xAAAAAAAA;
99 | datum antipattern = (datum) 0x55555555;
100 |
101 |
102 | /*
103 | * Write the default pattern at each of the power-of-two offsets.
104 | */
105 | for (offset = 1; (offset & addressMask) != 0; offset <<= 1)
106 | {
107 | baseAddress[offset] = pattern;
108 | }
109 |
110 | /*
111 | * Check for address bits stuck high.
112 | */
113 | testOffset = 0;
114 | baseAddress[testOffset] = antipattern;
115 |
116 | for (offset = 1; (offset & addressMask) != 0; offset <<= 1)
117 | {
118 | if (baseAddress[offset] != pattern)
119 | {
120 | return ((datum *) &baseAddress[offset]);
121 | }
122 | }
123 |
124 | baseAddress[testOffset] = pattern;
125 |
126 | /*
127 | * Check for address bits stuck low or shorted.
128 | */
129 | for (testOffset = 1; (testOffset & addressMask) != 0; testOffset <<= 1)
130 | {
131 | baseAddress[testOffset] = antipattern;
132 |
133 | if (baseAddress[0] != pattern)
134 | {
135 | return ((datum *) &baseAddress[testOffset]);
136 | }
137 |
138 | for (offset = 1; (offset & addressMask) != 0; offset <<= 1)
139 | {
140 | if ((baseAddress[offset] != pattern) && (offset != testOffset))
141 | {
142 | return ((datum *) &baseAddress[testOffset]);
143 | }
144 | }
145 |
146 | baseAddress[testOffset] = pattern;
147 | }
148 |
149 | return (NULL);
150 |
151 | } /* memTestAddressBus() */
152 |
153 |
154 | /**********************************************************************
155 | *
156 | * Function: memTestDevice()
157 | *
158 | * Description: Test the integrity of a physical memory device by
159 | * performing an increment/decrement test over the
160 | * entire region. In the process every storage bit
161 | * in the device is tested as a zero and a one. The
162 | * base address and the size of the region are
163 | * selected by the caller.
164 | *
165 | * Notes:
166 | *
167 | * Returns: NULL if the test succeeds.
168 | *
169 | * A non-zero result is the first address at which an
170 | * incorrect value was read back. By examining the
171 | * contents of memory, it may be possible to gather
172 | * additional information about the problem.
173 | *
174 | **********************************************************************/
175 | datum *
176 | memTestDevice(volatile datum * baseAddress, unsigned long nBytes)
177 | {
178 | unsigned long offset;
179 | unsigned long nWords = nBytes / sizeof(datum);
180 |
181 | datum pattern;
182 | datum antipattern;
183 |
184 |
185 | /*
186 | * Fill memory with a known pattern.
187 | */
188 | for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++)
189 | {
190 | baseAddress[offset] = pattern;
191 | }
192 |
193 | /*
194 | * Check each location and invert it for the second pass.
195 | */
196 | for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++)
197 | {
198 | if (baseAddress[offset] != pattern)
199 | {
200 | return ((datum *) &baseAddress[offset]);
201 | }
202 |
203 | antipattern = ~pattern;
204 | baseAddress[offset] = antipattern;
205 | }
206 |
207 | /*
208 | * Check each location for the inverted pattern and zero it.
209 | */
210 | for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++)
211 | {
212 | antipattern = ~pattern;
213 | if (baseAddress[offset] != antipattern)
214 | {
215 | return ((datum *) &baseAddress[offset]);
216 | }
217 | }
218 |
219 | return (NULL);
220 |
221 | } /* memTestDevice() */
222 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/memtest.h:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | *
3 | * Filename: memtest.h
4 | *
5 | * Description: Memory-testing module API.
6 | *
7 | * Notes: The memory tests can be easily ported to systems with
8 | * different data bus widths by redefining 'datum' type.
9 | *
10 | *
11 | * Copyright (c) 2000 by Michael Barr. This software is placed into
12 | * the public domain and may be used for any purpose. However, this
13 | * notice must not be changed or removed and no warranty is either
14 | * expressed or implied by its publication or distribution.
15 | **********************************************************************/
16 |
17 | #ifndef _memtest_h
18 | #define _memtest_h
19 |
20 |
21 | /*
22 | * Define NULL pointer value.
23 | */
24 | #ifndef NULL
25 | #define NULL (void *) 0
26 | #endif
27 |
28 | /*
29 | * Set the data bus width.
30 | */
31 | typedef unsigned long datum;
32 |
33 | /*
34 | * Function prototypes.
35 | */
36 | datum memTestDataBus(volatile datum * address);
37 | datum * memTestAddressBus(volatile datum * baseAddress, unsigned long nBytes);
38 | datum * memTestDevice(volatile datum * baseAddress, unsigned long nBytes);
39 |
40 |
41 | #endif /* _memtest_h */
42 |
43 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/queue.c:
--------------------------------------------------------------------------------
1 | /*
2 | * File: queue.c
3 | * Purpose: Implement a first in, first out linked list
4 | *
5 | * Notes:
6 | */
7 |
8 | #include "common.h"
9 | #include "queue.h"
10 |
11 | /********************************************************************/
12 | /*
13 | * Initialize the specified queue to an empty state
14 | *
15 | * Parameters:
16 | * q Pointer to queue structure
17 | */
18 | void
19 | queue_init(QUEUE *q)
20 | {
21 | q->head = NULL;
22 | }
23 | /********************************************************************/
24 | /*
25 | * Check for an empty queue
26 | *
27 | * Parameters:
28 | * q Pointer to queue structure
29 | *
30 | * Return Value:
31 | * 1 if Queue is empty
32 | * 0 otherwise
33 | */
34 | int
35 | queue_isempty(QUEUE *q)
36 | {
37 | return (q->head == NULL);
38 | }
39 | /********************************************************************/
40 | /*
41 | * Add an item to the end of the queue
42 | *
43 | * Parameters:
44 | * q Pointer to queue structure
45 | * node New node to add to the queue
46 | */
47 | void
48 | queue_add(QUEUE *q, QNODE *node)
49 | {
50 | if (queue_isempty(q))
51 | {
52 | q->head = q->tail = node;
53 | }
54 | else
55 | {
56 | q->tail->next = node;
57 | q->tail = node;
58 | }
59 |
60 | node->next = NULL;
61 | }
62 |
63 | /********************************************************************/
64 | /*
65 | * Remove and return first (oldest) entry from the specified queue
66 | *
67 | * Parameters:
68 | * q Pointer to queue structure
69 | *
70 | * Return Value:
71 | * Node at head of queue - NULL if queue is empty
72 | */
73 | QNODE*
74 | queue_remove(QUEUE *q)
75 | {
76 | QNODE *oldest;
77 |
78 | if (queue_isempty(q))
79 | return NULL;
80 |
81 | oldest = q->head;
82 | q->head = oldest->next;
83 | return oldest;
84 | }
85 | /********************************************************************/
86 | /*
87 | * Peek into the queue and return pointer to first (oldest) entry.
88 | * The queue is not modified
89 | *
90 | * Parameters:
91 | * q Pointer to queue structure
92 | *
93 | * Return Value:
94 | * Node at head of queue - NULL if queue is empty
95 | */
96 | QNODE*
97 | queue_peek(QUEUE *q)
98 | {
99 | return q->head;
100 | }
101 | /********************************************************************/
102 | /*
103 | * Move entire contents of one queue to the other
104 | *
105 | * Parameters:
106 | * src Pointer to source queue
107 | * dst Pointer to destination queue
108 | */
109 | void
110 | queue_move(QUEUE *dst, QUEUE *src)
111 | {
112 | if (queue_isempty(src))
113 | return;
114 |
115 | if (queue_isempty(dst))
116 | dst->head = src->head;
117 | else
118 | dst->tail->next = src->head;
119 |
120 | dst->tail = src->tail;
121 | src->head = NULL;
122 | return;
123 | }
124 | /********************************************************************/
125 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/queue.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: queue.h
3 | * Purpose: Implement a first in, first out linked list
4 | *
5 | * Notes:
6 | */
7 |
8 | #ifndef _QUEUE_H_
9 | #define _QUEUE_H_
10 |
11 | /********************************************************************/
12 |
13 | /*
14 | * Individual queue node
15 | */
16 | typedef struct NODE
17 | {
18 | struct NODE *next;
19 | } QNODE;
20 |
21 | /*
22 | * Queue Struture - linked list of qentry items
23 | */
24 | typedef struct
25 | {
26 | QNODE *head;
27 | QNODE *tail;
28 | } QUEUE;
29 |
30 | /*
31 | * Functions provided by queue.c
32 | */
33 | void
34 | queue_init(QUEUE *);
35 |
36 | int
37 | queue_isempty(QUEUE *);
38 |
39 | void
40 | queue_add(QUEUE *, QNODE *);
41 |
42 | QNODE*
43 | queue_remove(QUEUE *);
44 |
45 | QNODE*
46 | queue_peek(QUEUE *);
47 |
48 | void
49 | queue_move(QUEUE *, QUEUE *);
50 |
51 | /********************************************************************/
52 |
53 | #endif /* _QUEUE_H_ */
54 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/startup.c:
--------------------------------------------------------------------------------
1 | /*
2 | * File: startup.c
3 | * Purpose: Generic Kinetis startup code
4 | *
5 | * Notes:
6 | */
7 |
8 | #include "common.h"
9 |
10 | #if (defined(IAR))
11 | #pragma section = ".data"
12 | #pragma section = ".data_init"
13 | #pragma section = ".bss"
14 | #pragma section = "CodeRelocate"
15 | #pragma section = "CodeRelocateRam"
16 | #endif
17 |
18 | /********************************************************************/
19 | void
20 | common_startup(void)
21 | {
22 |
23 | #if (defined(CW))
24 | extern char __START_BSS[];
25 | extern char __END_BSS[];
26 | extern uint32 __DATA_ROM[];
27 | extern uint32 __DATA_RAM[];
28 | extern char __DATA_END[];
29 | #endif
30 |
31 | /* Declare a counter we'll use in all of the copy loops */
32 | uint32 n;
33 |
34 | /* Declare pointers for various data sections. These pointers
35 | * are initialized using values pulled in from the linker file
36 | */
37 | uint8 * data_ram, * data_rom, * data_rom_end;
38 | uint8 * bss_start, * bss_end;
39 |
40 |
41 | /* Addresses for VECTOR_TABLE and VECTOR_RAM come from the linker file */
42 | extern uint32 __VECTOR_TABLE[];
43 | extern uint32 __VECTOR_RAM[];
44 |
45 | /* Copy the vector table to RAM */
46 | if (__VECTOR_RAM != __VECTOR_TABLE)
47 | {
48 | for (n = 0; n < 0x410; n++)
49 | __VECTOR_RAM[n] = __VECTOR_TABLE[n];
50 | }
51 | /* Point the VTOR to the new copy of the vector table */
52 | write_vtor((uint32)__VECTOR_RAM);
53 |
54 | /* Get the addresses for the .data section (initialized data section) */
55 | #if (defined(CW))
56 | data_ram = (uint8 *)__DATA_RAM;
57 | data_rom = (uint8 *)__DATA_ROM;
58 | data_rom_end = (uint8 *)__DATA_END; /* This is actually a RAM address in CodeWarrior */
59 | n = data_rom_end - data_ram;
60 | #elif (defined(IAR))
61 | data_ram = __section_begin(".data");
62 | data_rom = __section_begin(".data_init");
63 | data_rom_end = __section_end(".data_init");
64 | n = data_rom_end - data_rom;
65 | #endif
66 |
67 | /* Copy initialized data from ROM to RAM */
68 | while (n--)
69 | *data_ram++ = *data_rom++;
70 |
71 |
72 | /* Get the addresses for the .bss section (zero-initialized data) */
73 | #if (defined(CW))
74 | bss_start = (uint8 *)__START_BSS;
75 | bss_end = (uint8 *)__END_BSS;
76 | #elif (defined(IAR))
77 | bss_start = __section_begin(".bss");
78 | bss_end = __section_end(".bss");
79 | #endif
80 |
81 |
82 |
83 |
84 | /* Clear the zero-initialized data section */
85 | n = bss_end - bss_start;
86 | while(n--)
87 | *bss_start++ = 0;
88 |
89 | /* Get addresses for any code sections that need to be copied from ROM to RAM.
90 | * The IAR tools have a predefined keyword that can be used to mark individual
91 | * functions for execution from RAM. Add "__ramfunc" before the return type in
92 | * the function prototype for any routines you need to execute from RAM instead
93 | * of ROM. ex: __ramfunc void foo(void);
94 | */
95 | #if (defined(IAR))
96 | uint8* code_relocate_ram = __section_begin("CodeRelocateRam");
97 | uint8* code_relocate = __section_begin("CodeRelocate");
98 | uint8* code_relocate_end = __section_end("CodeRelocate");
99 |
100 | /* Copy functions from ROM to RAM */
101 | n = code_relocate_end - code_relocate;
102 | while (n--)
103 | *code_relocate_ram++ = *code_relocate++;
104 | #endif
105 | }
106 | /********************************************************************/
107 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/startup.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: startup.h
3 | * Purpose: Determine cause of Reset and which processor is running
4 | *
5 | * Notes:
6 | */
7 |
8 | #ifndef _STARTUP_H_
9 | #define _STARTUP_H_
10 |
11 | /********************************************************************/
12 |
13 | void common_startup(void);
14 |
15 | /********************************************************************/
16 |
17 | #endif /* _STARTUP_H_ */
18 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/stdlib.c:
--------------------------------------------------------------------------------
1 | /*
2 | * File: stdlib.c
3 | * Purpose: Functions normally found in a standard C lib.
4 | *
5 | * Notes: This supports ASCII only!!!
6 | *
7 | */
8 |
9 | #include "common.h"
10 | #include "stdlib.h"
11 |
12 | /****************************************************************/
13 | int
14 | isspace (int ch)
15 | {
16 | if ((ch == ' ') || (ch == '\t')) /* \n ??? */
17 | return TRUE;
18 | else
19 | return FALSE;
20 | }
21 |
22 | /****************************************************************/
23 | int
24 | isalnum (int ch)
25 | {
26 | /* ASCII only */
27 | if (((ch >= '0') && (ch <= '9')) ||
28 | ((ch >= 'A') && (ch <= 'Z')) ||
29 | ((ch >= 'a') && (ch <= 'z')))
30 | return TRUE;
31 | else
32 | return FALSE;
33 | }
34 |
35 | /****************************************************************/
36 | int
37 | isdigit (int ch)
38 | {
39 | /* ASCII only */
40 | if ((ch >= '0') && (ch <= '9'))
41 | return TRUE;
42 | else
43 | return FALSE;
44 | }
45 |
46 | /****************************************************************/
47 | int
48 | isupper (int ch)
49 | {
50 | /* ASCII only */
51 | if ((ch >= 'A') && (ch <= 'Z'))
52 | return TRUE;
53 | else
54 | return FALSE;
55 | }
56 |
57 | /****************************************************************/
58 | int
59 | strcasecmp (const char *s1, const char *s2)
60 | {
61 | char c1, c2;
62 | int result = 0;
63 |
64 | while (result == 0)
65 | {
66 | c1 = *s1++;
67 | c2 = *s2++;
68 | if ((c1 >= 'a') && (c1 <= 'z'))
69 | c1 = (char)(c1 - ' ');
70 | if ((c2 >= 'a') && (c2 <= 'z'))
71 | c2 = (char)(c2 - ' ');
72 | if ((result = (c1 - c2)) != 0)
73 | break;
74 | if ((c1 == 0) || (c2 == 0))
75 | break;
76 | }
77 | return result;
78 | }
79 |
80 |
81 | /****************************************************************/
82 | int
83 | strncasecmp (const char *s1, const char *s2, int n)
84 | {
85 | char c1, c2;
86 | int k = 0;
87 | int result = 0;
88 |
89 | while ( k++ < n )
90 | {
91 | c1 = *s1++;
92 | c2 = *s2++;
93 | if ((c1 >= 'a') && (c1 <= 'z'))
94 | c1 = (char)(c1 - ' ');
95 | if ((c2 >= 'a') && (c2 <= 'z'))
96 | c2 = (char)(c2 - ' ');
97 | if ((result = (c1 - c2)) != 0)
98 | break;
99 | if ((c1 == 0) || (c2 == 0))
100 | break;
101 | }
102 | return result;
103 | }
104 |
105 | /****************************************************************/
106 | uint32
107 | strtoul (char *str, char **ptr, int base)
108 | {
109 | unsigned long rvalue;
110 | int c, err, neg;
111 | char *endp;
112 | char *startp;
113 |
114 | rvalue = 0; err = 0; neg = 0;
115 |
116 | /* Check for invalid arguments */
117 | if ((str == NULL) || (base < 0) || (base == 1) || (base > 36))
118 | {
119 | if (ptr != NULL)
120 | {
121 | *ptr = str;
122 | }
123 | return 0;
124 | }
125 |
126 | /* Skip leading white spaces */
127 | for (startp = str; isspace(*startp); ++startp)
128 | ;
129 |
130 | /* Check for notations */
131 | switch (startp[0])
132 | {
133 | case '0':
134 | if ((startp[1] == 'x') || (startp[1] == 'X'))
135 | {
136 | if ((base == 0) || (base == 16))
137 | {
138 | base = 16;
139 | startp = &startp[2];
140 | }
141 | }
142 | break;
143 | case '-':
144 | neg = 1;
145 | startp = &startp[1];
146 | break;
147 | default:
148 | break;
149 | }
150 |
151 | if (base == 0)
152 | base = 10;
153 |
154 | /* Check for invalid chars in str */
155 | for ( endp = startp; (c = *endp) != '\0'; ++endp)
156 | {
157 | /* Check for 0..9,Aa-Zz */
158 | if (!isalnum(c))
159 | {
160 | err = 1;
161 | break;
162 | }
163 |
164 | /* Convert char to num in 0..36 */
165 | if (isdigit(c))
166 | {
167 | c = c - '0';
168 | }
169 | else
170 | {
171 | if (isupper(c))
172 | {
173 | c = c - 'A' + 10;
174 | }
175 | else
176 | {
177 | c = c - 'a' + 10;
178 | }
179 | }
180 |
181 | /* check c against base */
182 | if (c >= base)
183 | {
184 | err = 1;
185 | break;
186 | }
187 |
188 | if (neg)
189 | {
190 | rvalue = (rvalue * base) - c;
191 | }
192 | else
193 | {
194 | rvalue = (rvalue * base) + c;
195 | }
196 | }
197 |
198 | /* Upon exit, endp points to the character at which valid info */
199 | /* STOPS. No chars including and beyond endp are used. */
200 |
201 | if (ptr != NULL)
202 | *ptr = endp;
203 |
204 | if (err)
205 | {
206 | if (ptr != NULL)
207 | *ptr = str;
208 |
209 | return 0;
210 | }
211 | else
212 | {
213 | return rvalue;
214 | }
215 | }
216 |
217 | /****************************************************************/
218 | int
219 | strlen (const char *str)
220 | {
221 | char *s = (char *)str;
222 | int len = 0;
223 |
224 | if (s == NULL)
225 | return 0;
226 |
227 | while (*s++ != '\0')
228 | ++len;
229 |
230 | return len;
231 | }
232 |
233 | /****************************************************************/
234 | char *
235 | strcat (char *dest, const char *src)
236 | {
237 | char *dp;
238 | char *sp = (char *)src;
239 |
240 | if ((dest != NULL) && (src != NULL))
241 | {
242 | dp = &dest[strlen(dest)];
243 |
244 | while (*sp != '\0')
245 | {
246 | *dp++ = *sp++;
247 | }
248 | *dp = '\0';
249 | }
250 | return dest;
251 | }
252 |
253 | /****************************************************************/
254 | char *
255 | strncat (char *dest, const char *src, int n)
256 | {
257 | char *dp;
258 | char *sp = (char *)src;
259 |
260 | if ((dest != NULL) && (src != NULL) && (n > 0))
261 | {
262 | dp = &dest[strlen(dest)];
263 |
264 | while ((*sp != '\0') && (n-- > 0))
265 | {
266 | *dp++ = *sp++;
267 | }
268 | *dp = '\0';
269 | }
270 | return dest;
271 | }
272 |
273 | /****************************************************************/
274 | char *
275 | strcpy (char *dest, const char *src)
276 | {
277 | char *dp = (char *)dest;
278 | char *sp = (char *)src;
279 |
280 | if ((dest != NULL) && (src != NULL))
281 | {
282 | while (*sp != '\0')
283 | {
284 | *dp++ = *sp++;
285 | }
286 | *dp = '\0';
287 | }
288 | return dest;
289 | }
290 |
291 | /****************************************************************/
292 | char *
293 | strncpy (char *dest, const char *src, int n)
294 | {
295 | char *dp = (char *)dest;
296 | char *sp = (char *)src;
297 |
298 | if ((dest != NULL) && (src != NULL) && (n > 0))
299 | {
300 | while ((*sp != '\0') && (n-- > 0))
301 | {
302 | *dp++ = *sp++;
303 | }
304 | *dp = '\0';
305 | }
306 | return dest;
307 | }
308 |
309 | /****************************************************************/
310 | int
311 | strcmp (const char *s1, const char *s2)
312 | {
313 | /* No checks for NULL */
314 | char *s1p = (char *)s1;
315 | char *s2p = (char *)s2;
316 |
317 | while (*s2p != '\0')
318 | {
319 | if (*s1p != *s2p)
320 | break;
321 |
322 | ++s1p;
323 | ++s2p;
324 | }
325 | return (*s1p - *s2p);
326 | }
327 |
328 | /****************************************************************/
329 | int
330 | strncmp (const char *s1, const char *s2, int n)
331 | {
332 | /* No checks for NULL */
333 | char *s1p = (char *)s1;
334 | char *s2p = (char *)s2;
335 |
336 | if (n <= 0)
337 | return 0;
338 |
339 | while (*s2p != '\0')
340 | {
341 | if (*s1p != *s2p)
342 | break;
343 |
344 | if (--n == 0)
345 | break;
346 |
347 | ++s1p;
348 | ++s2p;
349 | }
350 | return (*s1p - *s2p);
351 | }
352 |
353 | /****************************************************************/
354 | void *
355 | memcpy (void *dest, const void *src, unsigned n)
356 | {
357 | int longs, bytes;
358 | uint32 *dpl = (uint32 *)dest;
359 | uint32 *spl = (uint32 *)src;
360 | uint8 *dpb, *spb;
361 |
362 | if ((dest != NULL) && (src != NULL) && (n > 0))
363 | {
364 | bytes = (n & 0x3);
365 | longs = (n - bytes) >> 2;
366 |
367 | while (longs--)
368 | *dpl++ = *spl++;
369 |
370 | dpb = (uint8 *)dpl;
371 | spb = (uint8 *)spl;
372 |
373 | while (bytes--)
374 | *dpb++ = *spb++;
375 | }
376 | return dest;
377 | }
378 |
379 | /****************************************************************/
380 | void *
381 | memset (void *s, int c, unsigned n)
382 | {
383 | /* Not optimized, but very portable */
384 | unsigned char *sp = (unsigned char *)s;
385 |
386 | if ((s != NULL) && (n > 0))
387 | {
388 | while (n--)
389 | {
390 | *sp++ = (unsigned char)c;
391 | }
392 | }
393 | return s;
394 | }
395 |
396 | /****************************************************************/
397 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/stdlib.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: stdlib.h
3 | * Purpose: Function prototypes for standard library functions
4 | *
5 | * Notes:
6 | */
7 |
8 | #ifndef _STDLIB_H
9 | #define _STDLIB_H
10 |
11 | /********************************************************************
12 | * Standard library functions
13 | ********************************************************************/
14 |
15 | int
16 | isspace (int);
17 |
18 | int
19 | isalnum (int);
20 |
21 | int
22 | isdigit (int);
23 |
24 | int
25 | isupper (int);
26 |
27 | int
28 | strcasecmp (const char *, const char *);
29 |
30 | int
31 | strncasecmp (const char *, const char *, int);
32 |
33 | unsigned long
34 | strtoul (char *, char **, int);
35 |
36 | int
37 | strlen (const char *);
38 |
39 | char *
40 | strcat (char *, const char *);
41 |
42 | char *
43 | strncat (char *, const char *, int);
44 |
45 | char *
46 | strcpy (char *, const char *);
47 |
48 | char *
49 | strncpy (char *, const char *, int);
50 |
51 | int
52 | strcmp (const char *, const char *);
53 |
54 | int
55 | strncmp (const char *, const char *, int);
56 |
57 | void *
58 | memcpy (void *, const void *, unsigned);
59 |
60 | void *
61 | memset (void *, int, unsigned);
62 |
63 | void
64 | free (void *);
65 |
66 | void *
67 | malloc (unsigned);
68 |
69 | /********************************************************************/
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/uif.c:
--------------------------------------------------------------------------------
1 | /*
2 | * File: uif.c
3 | * Purpose: Provide an interactive user interface
4 | *
5 | * Notes: The commands, set/show parameters, and prompt are configured
6 | * at the project level
7 | */
8 |
9 | #include "common.h"
10 | #include "uif.h"
11 |
12 | /********************************************************************/
13 | /*
14 | * Global messages -- constant strings
15 | */
16 | const char HELPMSG[] =
17 | "Enter 'help' for help.\n";
18 |
19 | const char INVARG[] =
20 | "Error: Invalid argument: %s\n";
21 |
22 | const char INVALUE[] =
23 | "Error: Invalid value: %s\n";
24 |
25 | /*
26 | * Strings used by this file only
27 | */
28 | static const char INVCMD[] =
29 | "Error: No such command: %s\n";
30 |
31 | static const char HELPFORMAT[] =
32 | "%8s %-25s %s %s\n";
33 |
34 | static const char SYNTAX[] =
35 | "Error: Invalid syntax for: %s\n";
36 |
37 | static const char INVOPT[] =
38 | "Error: Invalid set/show option: %s\n";
39 |
40 | static const char OPTFMT[] =
41 | "%12s: ";
42 |
43 | static char cmdline1 [UIF_MAX_LINE];
44 | static char cmdline2 [UIF_MAX_LINE];
45 |
46 | /********************************************************************/
47 | char *
48 | get_line (char *line)
49 | {
50 | int pos;
51 | int ch;
52 |
53 | pos = 0;
54 | ch = (int)in_char();
55 | while ( (ch != 0x0D /* CR */) &&
56 | (ch != 0x0A /* LF/NL */) &&
57 | (pos < UIF_MAX_LINE))
58 | {
59 | switch (ch)
60 | {
61 | case 0x08: /* Backspace */
62 | case 0x7F: /* Delete */
63 | if (pos > 0)
64 | {
65 | pos -= 1;
66 | out_char(0x08); /* backspace */
67 | out_char(' ');
68 | out_char(0x08); /* backspace */
69 | }
70 | break;
71 | default:
72 | if ((pos+1) < UIF_MAX_LINE)
73 | {
74 | if ((ch > 0x1f) && (ch < 0x80))
75 | {
76 | line[pos++] = (char)ch;
77 | out_char((char)ch);
78 | }
79 | }
80 | break;
81 | }
82 | ch = (int)in_char();
83 | }
84 | line[pos] = '\0';
85 | out_char(0x0D); /* CR */
86 | out_char(0x0A); /* LF */
87 |
88 | return line;
89 | }
90 |
91 | /********************************************************************/
92 | int
93 | make_argv (char *cmdline, char *argv[])
94 | {
95 | int argc, i, in_text;
96 |
97 | /*
98 | * Break cmdline into strings and argv
99 | * It is permissible for argv to be NULL, in which case
100 | * the purpose of this routine becomes to count args
101 | */
102 | argc = 0;
103 | i = 0;
104 | in_text = FALSE;
105 | while (cmdline[i] != '\0') /* getline() must place 0x00 on end */
106 | {
107 | if (((cmdline[i] == ' ') ||
108 | (cmdline[i] == '\t')) )
109 | {
110 | if (in_text)
111 | {
112 | /* end of command line argument */
113 | cmdline[i] = '\0';
114 | in_text = FALSE;
115 | }
116 | else
117 | {
118 | /* still looking for next argument */
119 |
120 | }
121 | }
122 | else
123 | {
124 | /* got non-whitespace character */
125 | if (in_text)
126 | {
127 | }
128 | else
129 | {
130 | /* start of an argument */
131 | in_text = TRUE;
132 | if (argc < UIF_MAX_ARGS)
133 | {
134 | if (argv != NULL)
135 | argv[argc] = &cmdline[i];
136 | argc++;
137 | }
138 | else
139 | /*return argc;*/
140 | break;
141 | }
142 |
143 | }
144 | i++; /* proceed to next character */
145 | }
146 | if (argv != NULL)
147 | argv[argc] = NULL;
148 | return argc;
149 | }
150 |
151 | /********************************************************************/
152 | void
153 | run_cmd (void)
154 | {
155 | /*
156 | * Global array of pointers to emulate C argc,argv interface
157 | */
158 | int argc;
159 | char *argv[UIF_MAX_ARGS + 1]; /* one extra for null terminator */
160 |
161 | get_line(cmdline1);
162 |
163 | if (!(argc = make_argv(cmdline1,argv)))
164 | {
165 | /* no command entered, just a blank line */
166 | strcpy(cmdline1,cmdline2);
167 | argc = make_argv(cmdline1,argv);
168 | }
169 | cmdline2[0] = '\0';
170 |
171 | if (argc)
172 | {
173 | int i;
174 | for (i = 0; i < UIF_NUM_CMD; i++)
175 | {
176 | if (strcasecmp(UIF_CMDTAB[i].cmd,argv[0]) == 0)
177 | {
178 | if (((argc-1) >= UIF_CMDTAB[i].min_args) &&
179 | ((argc-1) <= UIF_CMDTAB[i].max_args))
180 | {
181 | if (UIF_CMDTAB[i].flags & UIF_CMD_FLAG_REPEAT)
182 | {
183 | strcpy(cmdline2,argv[0]);
184 | }
185 | UIF_CMDTAB[i].func(argc,argv);
186 | return;
187 | }
188 | else
189 | {
190 | printf(SYNTAX,argv[0]);
191 | return;
192 | }
193 | }
194 | }
195 | printf(INVCMD,argv[0]);
196 | printf(HELPMSG);
197 | }
198 | }
199 | /********************************************************************/
200 | uint32
201 | get_value (char *s, int *success, int base)
202 | {
203 | uint32 value;
204 | char *p;
205 |
206 | value = strtoul(s,&p,base);
207 | if ((value == 0) && (p == s))
208 | {
209 | *success = FALSE;
210 | return 0;
211 | }
212 | else
213 | {
214 | *success = TRUE;
215 | return value;
216 | }
217 | }
218 | /********************************************************************/
219 | void
220 | uif_cmd_help (int argc, char **argv)
221 | {
222 | int index;
223 |
224 | (void)argc;
225 | (void)argv;
226 |
227 | printf("\n");
228 | for (index = 0; index < UIF_NUM_CMD; index++)
229 | {
230 | printf(HELPFORMAT,
231 | UIF_CMDTAB[index].cmd,
232 | UIF_CMDTAB[index].description,
233 | UIF_CMDTAB[index].cmd,
234 | UIF_CMDTAB[index].syntax);
235 | }
236 | printf("\n");
237 | }
238 | /********************************************************************/
239 | void
240 | uif_cmd_set (int argc, char **argv)
241 | {
242 | int index;
243 |
244 | printf("\n");
245 | if (argc == 1)
246 | {
247 | printf("Valid 'set' options:\n");
248 | for (index = 0; index < UIF_NUM_SETCMD; ++index)
249 | {
250 | printf(OPTFMT,UIF_SETCMDTAB[index].option);
251 | printf("%s\n",UIF_SETCMDTAB[index].syntax);
252 | }
253 | printf("\n");
254 | return;
255 | }
256 |
257 | if (argc != 3)
258 | {
259 | printf("Error: Invalid argument list\n");
260 | return;
261 | }
262 |
263 | for (index = 0; index < UIF_NUM_SETCMD; index++)
264 | {
265 | if (strcasecmp(UIF_SETCMDTAB[index].option,argv[1]) == 0)
266 | {
267 | if (((argc-1-1) >= UIF_SETCMDTAB[index].min_args) &&
268 | ((argc-1-1) <= UIF_SETCMDTAB[index].max_args))
269 | {
270 | UIF_SETCMDTAB[index].func(argc,argv);
271 | return;
272 | }
273 | else
274 | {
275 | printf(INVARG,argv[1]);
276 | return;
277 | }
278 | }
279 | }
280 | printf(INVOPT,argv[1]);
281 | }
282 |
283 | /********************************************************************/
284 | void
285 | uif_cmd_show (int argc, char **argv)
286 | {
287 | int index;
288 |
289 | printf("\n");
290 | if (argc == 1)
291 | {
292 | /*
293 | * Show all Option settings
294 | */
295 | argc = 2;
296 | argv[2] = NULL;
297 | for (index = 0; index < UIF_NUM_SETCMD; index++)
298 | {
299 | printf(OPTFMT,UIF_SETCMDTAB[index].option);
300 | UIF_SETCMDTAB[index].func(argc,argv);
301 | printf("\n");
302 | }
303 | printf("\n");
304 | return;
305 | }
306 |
307 | for (index = 0; index < UIF_NUM_SETCMD; index++)
308 | {
309 | if (strcasecmp(UIF_SETCMDTAB[index].option,argv[1]) == 0)
310 | {
311 | if (((argc-1-1) >= UIF_SETCMDTAB[index].min_args) &&
312 | ((argc-1-1) <= UIF_SETCMDTAB[index].max_args))
313 | {
314 | printf(OPTFMT,UIF_SETCMDTAB[index].option);
315 | UIF_SETCMDTAB[index].func(argc,argv);
316 | printf("\n\n");
317 | return;
318 | }
319 | else
320 | {
321 | printf(INVARG,argv[1]);
322 | return;
323 | }
324 | }
325 | }
326 | printf(INVOPT,argv[1]);
327 | }
328 |
329 | /********************************************************************/
330 |
--------------------------------------------------------------------------------
/arm_ucos/src/common/uif.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: uif.h
3 | * Purpose: Provide an interactive user interface
4 | *
5 | * Notes: The commands, set/show parameters, and prompt are configured
6 | * at the project level
7 | */
8 |
9 | #ifndef _UIF_H_
10 | #define _UIF_H_
11 |
12 | /********************************************************************/
13 |
14 | /*
15 | * Function prototypes
16 | */
17 | char *
18 | get_line (char *);
19 |
20 | uint32
21 | get_value (char *, int *, int);
22 |
23 | void
24 | run_cmd (void);
25 |
26 | int
27 | make_argv (char *, char **);
28 |
29 | void
30 | uif_cmd_help (int, char **);
31 |
32 | void
33 | uif_cmd_set (int, char **);
34 |
35 | void
36 | uif_cmd_show (int, char **);
37 |
38 | /*
39 | * Maximum command line arguments
40 | */
41 | #define UIF_MAX_ARGS 10
42 |
43 | /*
44 | * Maximum length of the command line
45 | */
46 | #define UIF_MAX_LINE 80
47 |
48 | /*
49 | * The command table entry data structure
50 | */
51 | typedef const struct
52 | {
53 | char * cmd; /* command name user types, ie. GO */
54 | int min_args; /* min num of args command accepts */
55 | int max_args; /* max num of args command accepts */
56 | int flags; /* command flags (e.g. repeat) */
57 | void (*func)(int, char **); /* actual function to call */
58 | char * description; /* brief description of command */
59 | char * syntax; /* syntax of command */
60 | } UIF_CMD;
61 |
62 | /*
63 | * Prototype and macro for size of the command table
64 | */
65 | extern UIF_CMD UIF_CMDTAB[];
66 | extern const int UIF_NUM_CMD;
67 | #define UIF_CMDTAB_SIZE (sizeof(UIF_CMDTAB)/sizeof(UIF_CMD))
68 |
69 | #define UIF_CMD_FLAG_REPEAT 0x1
70 |
71 | /*
72 | * Macros for User InterFace command table entries
73 | */
74 | #ifndef UIF_CMD_HELP
75 | #define UIF_CMD_HELP \
76 | {"help",0,1,0,uif_cmd_help,"Help",""},
77 | #endif
78 |
79 | #ifndef UIF_CMD_SET
80 | #define UIF_CMD_SET \
81 | {"set",0,2,0,uif_cmd_set,"Set Config","