Mercurial > ecos
annotate packages/hal/cortexm/arch/current/src/hal_misc.c @ 2677:d16f29a90821
* src/hal_misc.c (hal_deliver_interrupt): Fix instrumentation call
to allow it to compile properly.
| author | nickg |
|---|---|
| date | Wed, 03 Dec 2008 15:52:34 +0000 |
| parents | 9da21501bc5b |
| children | 74dbf4c3f2e1 |
| rev | line source |
|---|---|
|
2580
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
1 /*========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
2 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
3 // hal_misc.c |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
4 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
5 // Cortex-M exception vectors |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
6 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
7 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
8 //####ECOSGPLCOPYRIGHTBEGIN#### |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
9 // ------------------------------------------- |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
11 // Copyright (C) 2008 eCosCentric Limited. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
12 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later version. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
16 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
20 // for more details. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
21 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
22 // You should have received a copy of the GNU General Public License along |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
23 // with eCos; if not, write to the Free Software Foundation, Inc., |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
25 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
26 // As a special exception, if other files instantiate templates or use macros |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
27 // or inline functions from this file, or you compile this file and link it |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
28 // with other works to produce a work based on this file, this file does not |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
29 // by itself cause the resulting work to be covered by the GNU General Public |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
30 // License. However the source code for this file must still be made available |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
31 // in accordance with section (3) of the GNU General Public License. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
32 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
33 // This exception does not invalidate any other reasons why a work based on |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
34 // this file might be covered by the GNU General Public License. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
35 // ------------------------------------------- |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
36 //####ECOSGPLCOPYRIGHTEND#### |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
37 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
38 //#####DESCRIPTIONBEGIN#### |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
39 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
40 // Author(s): nickg |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
41 // Date: 2008-07-30 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
42 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
43 //####DESCRIPTIONEND#### |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
44 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
45 //========================================================================*/ |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
46 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
47 #include <pkgconf/hal.h> |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
48 #include <pkgconf/hal_cortexm.h> |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
49 #ifdef CYGPKG_KERNEL |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
50 #include <pkgconf/kernel.h> |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
51 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
52 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
53 #include <cyg/infra/diag.h> |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
54 #include <cyg/infra/cyg_type.h> |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
55 #include <cyg/infra/cyg_trac.h> // tracing macros |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
56 #include <cyg/infra/cyg_ass.h> // assertion macros |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
57 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
58 #include <cyg/hal/hal_arch.h> // HAL header |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
59 #include <cyg/hal/hal_intr.h> // HAL header |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
60 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
61 #include <cyg/hal/drv_api.h> |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
62 |
|
2677
d16f29a90821
* src/hal_misc.c (hal_deliver_interrupt): Fix instrumentation call
nickg
parents:
2589
diff
changeset
|
63 |
|
d16f29a90821
* src/hal_misc.c (hal_deliver_interrupt): Fix instrumentation call
nickg
parents:
2589
diff
changeset
|
64 #if defined(CYGPKG_KERNEL_INSTRUMENT) && \ |
|
d16f29a90821
* src/hal_misc.c (hal_deliver_interrupt): Fix instrumentation call
nickg
parents:
2589
diff
changeset
|
65 defined(CYGDBG_KERNEL_INSTRUMENT_INTR) |
|
d16f29a90821
* src/hal_misc.c (hal_deliver_interrupt): Fix instrumentation call
nickg
parents:
2589
diff
changeset
|
66 #include <cyg/kernel/instrmnt.h> |
|
d16f29a90821
* src/hal_misc.c (hal_deliver_interrupt): Fix instrumentation call
nickg
parents:
2589
diff
changeset
|
67 #endif |
|
d16f29a90821
* src/hal_misc.c (hal_deliver_interrupt): Fix instrumentation call
nickg
parents:
2589
diff
changeset
|
68 |
|
2580
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
69 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
70 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
71 typedef cyg_uint32 cyg_isr(cyg_uint32 vector, CYG_ADDRWORD data); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
72 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
73 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
74 // External references |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
75 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
76 // VSRs in vectors.S |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
77 __externC void hal_default_exception_vsr( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
78 __externC void hal_default_interrupt_vsr( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
79 __externC void hal_default_svc_vsr( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
80 __externC void hal_pendable_svc_vsr( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
81 __externC void hal_switch_state_vsr( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
82 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
83 // HAL and eCos functions |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
84 __externC void hal_system_init( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
85 __externC void hal_variant_init( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
86 __externC void hal_platform_init( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
87 __externC void hal_ctrlc_isr_init( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
88 __externC void initialize_stub( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
89 __externC void cyg_hal_invoke_constructors( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
90 __externC void cyg_start( void ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
91 __externC void cyg_interrupt_post_dsr( CYG_ADDRWORD intr_obj ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
92 __externC void interrupt_end(cyg_uint32 isr_ret, CYG_ADDRWORD intr, HAL_SavedRegisters *regs ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
93 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
94 // DATA and BSS locations |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
95 __externC cyg_uint32 __ram_data_start; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
96 __externC cyg_uint32 __ram_data_end; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
97 __externC cyg_uint32 __rom_data_start; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
98 __externC cyg_uint32 __bss_start; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
99 __externC cyg_uint32 __bss_end; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
100 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
101 // Scheduler lock |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
102 __externC volatile cyg_uint32 cyg_scheduler_sched_lock; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
103 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
104 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
105 // Interrupt tables |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
106 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
107 volatile CYG_ADDRESS hal_interrupt_handlers[CYGNUM_HAL_ISR_COUNT]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
108 volatile CYG_ADDRWORD hal_interrupt_data [CYGNUM_HAL_ISR_COUNT]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
109 volatile CYG_ADDRESS hal_interrupt_objects [CYGNUM_HAL_ISR_COUNT]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
110 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
111 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
112 // Main entry point |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
113 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
114 // Enter here from reset via slot 1 of VSR table. The stack pointer is |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
115 // already set to the value in VSR slot 0, usually the top of internal |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
116 // SRAM. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
117 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
118 void hal_reset_vsr( void ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
119 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
120 // Call system init routine. This should do the minimum necessary |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
121 // for the rest of the initialization to complete. For example set |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
122 // up GPIO, the SRAM, power management etc. This routine is |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
123 // usually supplied by the platform HAL. Calls to |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
124 // hal_variant_init() and hal_platform_init() later will perform |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
125 // the main initialization. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
126 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
127 hal_system_init(); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
128 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
129 // Initialize vector table in base of SRAM. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
130 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
131 register int i; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
132 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
133 #if !defined(CYG_HAL_STARTUP_RAM) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
134 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
135 // Only install the exception vectors for non-RAM startup. For |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
136 // RAM startup we want these to continue to point to the original |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
137 // VSRs, which will belong to RedBoot or GDB stubs. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
138 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
139 for( i = 2; i < 15; i++ ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
140 hal_vsr_table[i] = (CYG_ADDRESS)hal_default_exception_vsr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
141 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
142 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
143 // Always point SVC and PENDSVC vectors to our local versions |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
144 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
145 hal_vsr_table[CYGNUM_HAL_VECTOR_SERVICE] = (CYG_ADDRESS)hal_default_svc_vsr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
146 hal_vsr_table[CYGNUM_HAL_VECTOR_PENDSV] = (CYG_ADDRESS)hal_pendable_svc_vsr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
147 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
148 // For all startup type, redirect interrupt vectors to our VSR. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
149 for( i = CYGNUM_HAL_VECTOR_SYS_TICK ; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
150 i < CYGNUM_HAL_VECTOR_SYS_TICK + CYGNUM_HAL_VSR_MAX; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
151 i++ ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
152 hal_vsr_table[i] = (CYG_ADDRESS)hal_default_interrupt_vsr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
153 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
154 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
155 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
156 #if !defined(CYG_HAL_STARTUP_RAM) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
157 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
158 // Ensure that the CPU will use the vector table we have just set |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
159 // up. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
160 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
161 # if defined(CYGHWR_HAL_CORTEXM_M3) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
162 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
163 // On M3 parts, the NVIC contains a vector table base register. We |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
164 // program this to relocate the vector table base to the base of |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
165 // SRAM. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
166 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
167 HAL_WRITE_UINT32( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_VTOR, |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
168 CYGARC_REG_NVIC_VTOR_TBLOFF(0)| |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
169 CYGARC_REG_NVIC_VTOR_TBLBASE_SRAM ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
170 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
171 # else |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
172 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
173 # error Unknown SRAM/VECTAB remap mechanism |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
174 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
175 # endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
176 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
177 // Use SVC to switch our state to thread mode running on the PSP. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
178 // We don't need to do this for RAM startup since the ROM code |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
179 // will have already done it. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
180 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
181 hal_vsr_table[CYGNUM_HAL_VECTOR_SERVICE] = (CYG_ADDRESS)hal_switch_state_vsr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
182 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
183 __asm__ volatile( "swi" ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
184 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
185 hal_vsr_table[CYGNUM_HAL_VECTOR_SERVICE] = (CYG_ADDRESS)hal_default_svc_vsr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
186 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
187 #endif // !defined(CYG_HAL_STARTUP_RAM) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
188 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
189 #if defined(CYG_HAL_STARTUP_ROM) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
190 // Relocate data from ROM to RAM |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
191 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
192 register cyg_uint32 *p, *q; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
193 for( p = &__ram_data_start, q = &__rom_data_start; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
194 p < &__ram_data_end; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
195 p++, q++ ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
196 *p = *q; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
197 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
198 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
199 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
200 // Clear BSS |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
201 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
202 register cyg_uint32 *p; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
203 for( p = &__bss_start; p < &__bss_end; p++ ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
204 *p = 0; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
205 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
206 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
207 // Initialize interrupt vectors. Set the levels for all interrupts |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
208 // to default values. Also set the default priorities of the |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
209 // system handlers: all exceptions maximum priority except SVC and |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
210 // PendSVC which are lowest priority. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
211 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
212 register int i; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
213 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
214 HAL_WRITE_UINT32( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_SHPR0, 0x00000000 ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
215 HAL_WRITE_UINT32( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_SHPR1, 0xFF000000 ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
216 HAL_WRITE_UINT32( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_SHPR2, 0x00FF0000 ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
217 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
218 hal_interrupt_handlers[CYGNUM_HAL_INTERRUPT_SYS_TICK] = (CYG_ADDRESS)hal_default_isr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
219 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
220 for( i = 1; i < CYGNUM_HAL_ISR_COUNT; i++ ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
221 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
222 hal_interrupt_handlers[i] = (CYG_ADDRESS)hal_default_isr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
223 HAL_WRITE_UINT8( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_PR(i-CYGNUM_HAL_INTERRUPT_EXTERNAL), 0x80 ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
224 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
225 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
226 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
227 #if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
228 // Enable DebugMonitor exceptions. This is needed to enable single |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
229 // step. This only has an effect if no external JTAG device is |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
230 // attached. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
231 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
232 CYG_ADDRESS base = CYGARC_REG_DEBUG_BASE; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
233 cyg_uint32 demcr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
234 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
235 HAL_READ_UINT32( base+CYGARC_REG_DEBUG_DEMCR, demcr ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
236 demcr |= CYGARC_REG_DEBUG_DEMCR_MON_EN; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
237 HAL_WRITE_UINT32( base+CYGARC_REG_DEBUG_DEMCR, demcr ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
238 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
239 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
240 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
241 #if !defined(CYG_HAL_STARTUP_RAM) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
242 // Enable Usage, Bus and Mem fault handlers. Do this for ROM and |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
243 // JTAG startups. For RAM startups, this will have already been |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
244 // done by the ROM monitor. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
245 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
246 CYG_ADDRESS base = CYGARC_REG_NVIC_BASE; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
247 cyg_uint32 shcsr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
248 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
249 HAL_READ_UINT32( base+CYGARC_REG_NVIC_SHCSR, shcsr ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
250 shcsr |= CYGARC_REG_NVIC_SHCSR_USGFAULTENA; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
251 shcsr |= CYGARC_REG_NVIC_SHCSR_BUSFAULTENA; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
252 shcsr |= CYGARC_REG_NVIC_SHCSR_MEMFAULTENA; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
253 HAL_WRITE_UINT32( base+CYGARC_REG_NVIC_SHCSR, shcsr ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
254 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
255 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
256 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
257 // Call variant and platform init routines |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
258 hal_variant_init(); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
259 hal_platform_init(); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
260 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
261 // Start up the system clock |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
262 HAL_CLOCK_INITIALIZE( CYGNUM_HAL_RTC_PERIOD ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
263 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
264 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
265 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
266 initialize_stub(); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
267 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
268 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
269 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
270 #if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT) || \ |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
271 defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
272 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
273 hal_ctrlc_isr_init(); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
274 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
275 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
276 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
277 // Run through static constructors |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
278 cyg_hal_invoke_constructors(); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
279 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
280 // Finally call into application |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
281 cyg_start(); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
282 for(;;); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
283 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
284 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
285 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
286 // Handle Exceptions |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
287 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
288 // Exceptions are passed here from the initial VSR. We pass the |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
289 // exception on to GDB stubs or the kernel as appropriate. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
290 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
291 __externC void __handle_exception (void); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
292 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
293 __externC HAL_SavedRegisters *_hal_registers; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
294 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
295 __externC void* volatile __mem_fault_handler; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
296 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
297 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
298 void hal_deliver_exception( HAL_SavedRegisters *regs ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
299 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
300 // Special case handler for code which has chosen to take care |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
301 // of data exceptions (i.e. code which expects them to happen) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
302 // This is common in discovery code, e.g. checking for a particular |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
303 // device which may generate an exception when probing if the |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
304 // device is not present |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
305 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
306 if (__mem_fault_handler ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
307 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
308 regs->u.exception.pc = (unsigned long)__mem_fault_handler; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
309 return; // Caught an exception inside stubs |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
310 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
311 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
312 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
313 #if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
314 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
315 _hal_registers = regs; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
316 __handle_exception(); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
317 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
318 #elif defined(CYGPKG_KERNEL_EXCEPTIONS) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
319 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
320 cyg_hal_deliver_exception( regs->u.exception.vector, (CYG_ADDRWORD)regs ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
321 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
322 #else |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
323 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
324 CYG_FAIL("Exception!!!"); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
325 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
326 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
327 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
328 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
329 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
330 // Handle Interrupts |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
331 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
332 // Interrupts are passed here from the low-level VSR in vectors.S. We |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
333 // look up the ISR in the interrupt table, call it and if it requests |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
334 // it, post a DSR. If necessary we also then cause the pendable SVC to |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
335 // be requested. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
336 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
337 // This function is also callable from ISR springboards that decode |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
338 // additional interrupts via external controllers to deliver an |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
339 // interrupt to a secondary vector. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
340 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
341 void hal_deliver_interrupt( cyg_uint32 vector ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
342 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
343 register cyg_uint32 isr_result; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
344 register cyg_isr *isr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
345 cyg_bool pendsvc = false; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
346 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
347 #if defined(CYGPKG_KERNEL_INSTRUMENT) && \ |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
348 defined(CYGDBG_KERNEL_INSTRUMENT_INTR) |
|
2677
d16f29a90821
* src/hal_misc.c (hal_deliver_interrupt): Fix instrumentation call
nickg
parents:
2589
diff
changeset
|
349 CYG_INSTRUMENT_INTR(RAISE, vector, 0); |
|
2580
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
350 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
351 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
352 isr = (cyg_isr *)hal_interrupt_handlers[vector]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
353 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
354 // Call the ISR |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
355 isr_result = isr( vector, hal_interrupt_data[vector] ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
356 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
357 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
358 #if !defined(CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
359 // If the ISR has returned the CALL_DSR bit, post the DSR and set |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
360 // the pendable SVC exception pending. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
361 if( isr_result & CYG_ISR_CALL_DSR ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
362 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
363 cyg_interrupt_post_dsr( hal_interrupt_objects[vector] ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
364 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
365 // Post the pendable SVC to call interrupt_end(). But only if |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
366 // the scheduler lock is currently zero. If it is non zero |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
367 // then interrupt_end will do nothing useful, so avoid calling |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
368 // it. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
369 if( cyg_scheduler_sched_lock == 0 ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
370 pendsvc = true; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
371 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
372 #else |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
373 // When chaining we don't know here whether the nested interrupt |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
374 // has posted a DSR, so we have to run interrupt_end() regardless. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
375 // However, the same considerations as above regarding the |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
376 // scheduler lock still apply. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
377 if( cyg_scheduler_sched_lock == 0 ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
378 pendsvc = true; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
379 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
380 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
381 // Post the pendable SVC if required. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
382 if( pendsvc ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
383 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
384 cyg_uint32 icsr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
385 HAL_READ_UINT32( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_ICSR, icsr ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
386 icsr |= CYGARC_REG_NVIC_ICSR_PENDSVSET; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
387 HAL_WRITE_UINT32( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_ICSR, icsr ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
388 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
389 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
390 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
391 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
392 // Call interrupt_end() |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
393 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
394 // This is called on the thread stack as a result of the pendable |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
395 // SVC. interrupt_end() decrements the scheduler lock, calls DSRs and |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
396 // optionally switches thread context. So before calling, we must |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
397 // increment the lock. The actual interrupt end processing has already |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
398 // been done above in hal_default_interrupt_vsr1(), so the arguments |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
399 // are zero. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
400 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
401 __externC void hal_interrupt_end( void ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
402 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
403 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
404 cyg_scheduler_sched_lock++; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
405 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
406 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
407 interrupt_end(0,0,0); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
408 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
409 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
410 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
411 // Interrupt masking and configuration |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
412 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
413 #ifndef HAL_VAR_INTERRUPT_MASK |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
414 #define HAL_VAR_INTERRUPT_MASK( __vector ) CYG_EMPTY_STATEMENT |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
415 #define HAL_VAR_INTERRUPT_UNMASK( __vector ) CYG_EMPTY_STATEMENT |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
416 #define HAL_VAR_INTERRUPT_SET_LEVEL( __vector, __level ) CYG_EMPTY_STATEMENT |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
417 #define HAL_VAR_INTERRUPT_ACKNOWLEDGE( __vector ) CYG_EMPTY_STATEMENT |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
418 #define HAL_VAR_INTERRUPT_CONFIGURE( __vector, __level, __up ) CYG_EMPTY_STATEMENT |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
419 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
420 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
421 //-------------------------------------------------------------------------- |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
422 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
423 __externC void hal_interrupt_mask( cyg_uint32 vector ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
424 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
425 if( vector >= CYGNUM_HAL_INTERRUPT_EXTERNAL && |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
426 vector <= CYGNUM_HAL_INTERRUPT_NVIC_MAX ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
427 HAL_WRITE_UINT32( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_CER(vector-CYGNUM_HAL_INTERRUPT_EXTERNAL), |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
428 CYGARC_REG_NVIC_IBIT(vector-CYGNUM_HAL_INTERRUPT_EXTERNAL) ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
429 else if( vector == CYGNUM_HAL_INTERRUPT_SYS_TICK ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
430 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
431 cyg_uint32 csr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
432 HAL_READ_UINT32(CYGARC_REG_SYSTICK_BASE+CYGARC_REG_SYSTICK_CSR, csr ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
433 csr &= ~CYGARC_REG_SYSTICK_CSR_TICKINT; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
434 HAL_WRITE_UINT32(CYGARC_REG_SYSTICK_BASE+CYGARC_REG_SYSTICK_CSR, csr ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
435 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
436 HAL_VAR_INTERRUPT_MASK( vector ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
437 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
438 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
439 //-------------------------------------------------------------------------- |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
440 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
441 __externC void hal_interrupt_unmask( cyg_uint32 vector ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
442 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
443 if( vector >= CYGNUM_HAL_INTERRUPT_EXTERNAL && |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
444 vector <= CYGNUM_HAL_INTERRUPT_NVIC_MAX ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
445 HAL_WRITE_UINT32( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_SER(vector-CYGNUM_HAL_INTERRUPT_EXTERNAL), |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
446 CYGARC_REG_NVIC_IBIT(vector-CYGNUM_HAL_INTERRUPT_EXTERNAL) ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
447 else if( vector == CYGNUM_HAL_INTERRUPT_SYS_TICK ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
448 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
449 cyg_uint32 csr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
450 HAL_READ_UINT32(CYGARC_REG_SYSTICK_BASE+CYGARC_REG_SYSTICK_CSR, csr ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
451 csr |= CYGARC_REG_SYSTICK_CSR_TICKINT; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
452 HAL_WRITE_UINT32(CYGARC_REG_SYSTICK_BASE+CYGARC_REG_SYSTICK_CSR, csr ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
453 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
454 HAL_VAR_INTERRUPT_UNMASK( vector ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
455 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
456 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
457 //-------------------------------------------------------------------------- |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
458 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
459 __externC void hal_interrupt_acknowledge( cyg_uint32 vector ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
460 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
461 HAL_VAR_INTERRUPT_ACKNOWLEDGE( vector ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
462 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
463 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
464 //-------------------------------------------------------------------------- |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
465 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
466 __externC void hal_interrupt_configure( cyg_uint32 vector, cyg_uint32 level, cyg_uint32 up ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
467 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
468 HAL_VAR_INTERRUPT_CONFIGURE( vector, level, up ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
469 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
470 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
471 //-------------------------------------------------------------------------- |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
472 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
473 __externC void hal_interrupt_set_level( cyg_uint32 vector, cyg_uint32 level ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
474 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
475 cyg_uint32 l = (level)+CYGNUM_HAL_CORTEXM_PRIORITY_MAX; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
476 if( l > 0xFF ) l = 0xFF; /* clamp to 0xFF */ |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
477 if( vector >= CYGNUM_HAL_INTERRUPT_EXTERNAL && |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
478 vector <= CYGNUM_HAL_INTERRUPT_NVIC_MAX ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
479 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
480 HAL_WRITE_UINT8( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_PR(vector-CYGNUM_HAL_INTERRUPT_EXTERNAL), |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
481 l ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
482 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
483 else if ( vector == CYGNUM_HAL_INTERRUPT_SYS_TICK ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
484 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
485 cyg_uint32 shpr2; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
486 HAL_READ_UINT32( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_SHPR2, shpr2 ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
487 shpr2 &= ~0xFF000000; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
488 shpr2 |= (l)<<24; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
489 HAL_WRITE_UINT32( CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_SHPR2, shpr2 ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
490 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
491 HAL_VAR_INTERRUPT_SET_LEVEL( vector, level ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
492 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
493 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
494 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
495 // Microsecond delay |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
496 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
497 // The system RTC is set up to tick at 1MHz so all we need to do here |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
498 // is count ticks. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
499 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
500 __externC void hal_delay_us( cyg_int32 us ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
501 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
502 cyg_uint32 t0, t1; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
503 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
504 HAL_CLOCK_READ( &t0 ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
505 while ( us > 0 ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
506 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
507 HAL_CLOCK_READ( &t1 ); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
508 if( t1 < t0 ) |
| 2589 | 509 us -= (t1 + CYGNUM_HAL_RTC_PERIOD - t0); |
| 510 else | |
| 511 us -= t1 - t0; | |
|
2580
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
512 t0 = t1; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
513 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
514 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
515 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
516 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
517 // C++ support - run initial constructors |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
518 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
519 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
520 cyg_bool cyg_hal_stop_constructors; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
521 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
522 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
523 typedef void (*pfunc) (void); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
524 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
525 extern pfunc __init_array_start__[]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
526 extern pfunc __init_array_end__[]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
527 #define CONSTRUCTORS_START (__init_array_start__[0]) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
528 #define CONSTRUCTORS_END (__init_array_end__) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
529 #define NEXT_CONSTRUCTOR(c) ((c)++) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
530 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
531 void |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
532 cyg_hal_invoke_constructors (void) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
533 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
534 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
535 static pfunc *p = &CONSTRUCTORS_START; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
536 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
537 cyg_hal_stop_constructors = 0; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
538 for (; p != CONSTRUCTORS_END; NEXT_CONSTRUCTOR(p)) { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
539 (*p)(); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
540 if (cyg_hal_stop_constructors) { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
541 NEXT_CONSTRUCTOR(p); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
542 break; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
543 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
544 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
545 #else |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
546 pfunc *p; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
547 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
548 for (p = &CONSTRUCTORS_START; p != CONSTRUCTORS_END; NEXT_CONSTRUCTOR(p)) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
549 (*p)(); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
550 #endif |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
551 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
552 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
553 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
554 // Architecture default ISR |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
555 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
556 __externC cyg_uint32 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
557 hal_arch_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
558 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
559 CYG_TRACE1(true, "Interrupt: %d", vector); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
560 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
561 CYG_FAIL("Spurious Interrupt!!!"); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
562 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
563 return 0; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
564 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
565 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
566 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
567 // GDB support |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
568 // |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
569 // These functions translate between HAL saved contexts and GDB |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
570 // register dumps. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
571 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
572 __externC void hal_get_gdb_registers( HAL_CORTEXM_GDB_Registers *gdbreg, HAL_SavedRegisters *regs ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
573 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
574 int i; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
575 cyg_uint32 *p = gdbreg->f0; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
576 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
577 switch( regs->u.type ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
578 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
579 case HAL_SAVEDREGISTERS_THREAD: |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
580 for( i = 0; i < 13; i++ ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
581 gdbreg->gpr[i] = regs->u.thread.r[i]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
582 gdbreg->gpr[13] = regs->u.thread.sp; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
583 gdbreg->gpr[14] = regs->u.thread.pc; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
584 gdbreg->gpr[15] = regs->u.thread.pc; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
585 gdbreg->ps = 0x01000000; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
586 break; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
587 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
588 case HAL_SAVEDREGISTERS_EXCEPTION: |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
589 gdbreg->gpr[0] = regs->u.exception.r0; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
590 gdbreg->gpr[1] = regs->u.exception.r1; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
591 gdbreg->gpr[2] = regs->u.exception.r2; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
592 gdbreg->gpr[3] = regs->u.exception.r3; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
593 for( i = 0; i < 8; i++ ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
594 gdbreg->gpr[i+4] = regs->u.exception.r4_11[i]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
595 gdbreg->gpr[12] = regs->u.exception.r12; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
596 gdbreg->gpr[13] = ((cyg_uint32)regs)+sizeof(regs->u.exception); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
597 gdbreg->gpr[14] = regs->u.exception.lr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
598 gdbreg->gpr[15] = regs->u.exception.pc; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
599 gdbreg->ps = regs->u.exception.psr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
600 break; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
601 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
602 case HAL_SAVEDREGISTERS_INTERRUPT: |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
603 gdbreg->gpr[0] = regs->u.interrupt.r0; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
604 gdbreg->gpr[1] = regs->u.interrupt.r1; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
605 gdbreg->gpr[2] = regs->u.interrupt.r2; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
606 gdbreg->gpr[3] = regs->u.interrupt.r3; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
607 gdbreg->gpr[12] = regs->u.interrupt.r12; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
608 gdbreg->gpr[13] = ((cyg_uint32)regs)+sizeof(regs->u.interrupt); |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
609 gdbreg->gpr[14] = regs->u.interrupt.lr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
610 gdbreg->gpr[15] = regs->u.interrupt.pc; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
611 gdbreg->ps = regs->u.interrupt.psr; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
612 break; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
613 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
614 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
615 // Clear FP state, which we don't use |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
616 for( i = 0; i < (8*3+1); i++ ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
617 p[i] = 0; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
618 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
619 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
620 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
621 __externC void hal_set_gdb_registers( HAL_CORTEXM_GDB_Registers *gdbreg, HAL_SavedRegisters *regs ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
622 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
623 int i; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
624 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
625 switch( regs->u.type ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
626 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
627 case HAL_SAVEDREGISTERS_THREAD: |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
628 for( i = 0; i < 13; i++ ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
629 regs->u.thread.r[i] = gdbreg->gpr[i]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
630 regs->u.thread.sp = gdbreg->gpr[13]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
631 regs->u.thread.pc = gdbreg->gpr[14]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
632 regs->u.thread.pc = gdbreg->gpr[15]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
633 break; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
634 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
635 case HAL_SAVEDREGISTERS_EXCEPTION: |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
636 regs->u.exception.r0 = gdbreg->gpr[0]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
637 regs->u.exception.r1 = gdbreg->gpr[1]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
638 regs->u.exception.r2 = gdbreg->gpr[2]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
639 regs->u.exception.r3 = gdbreg->gpr[3]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
640 for( i = 0; i < 8; i++ ) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
641 regs->u.exception.r4_11[i] = gdbreg->gpr[i+4]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
642 regs->u.exception.r12 = gdbreg->gpr[12]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
643 regs->u.exception.lr = gdbreg->gpr[14]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
644 regs->u.exception.pc = gdbreg->gpr[15]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
645 regs->u.exception.psr = gdbreg->ps; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
646 break; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
647 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
648 case HAL_SAVEDREGISTERS_INTERRUPT: |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
649 regs->u.interrupt.r0 = gdbreg->gpr[0]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
650 regs->u.interrupt.r1 = gdbreg->gpr[1]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
651 regs->u.interrupt.r2 = gdbreg->gpr[2]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
652 regs->u.interrupt.r3 = gdbreg->gpr[3]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
653 regs->u.interrupt.r12 = gdbreg->gpr[12]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
654 regs->u.interrupt.lr = gdbreg->gpr[14]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
655 regs->u.interrupt.pc = gdbreg->gpr[15]; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
656 regs->u.interrupt.psr = gdbreg->ps; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
657 break; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
658 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
659 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
660 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
661 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
662 // When compiling C++ code with static objects the compiler |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
663 // inserts a call to __cxa_atexit() with __dso_handle as one of the |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
664 // arguments. __cxa_atexit() would normally be provided by glibc, and |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
665 // __dso_handle is part of crtstuff.c. eCos applications |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
666 // are linked rather differently, so either a differently-configured |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
667 // compiler is needed or dummy versions of these symbols should be |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
668 // provided. If these symbols are not actually used then providing |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
669 // them is still harmless, linker garbage collection will remove them. |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
670 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
671 void |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
672 __cxa_atexit(void (*arg1)(void*), void* arg2, void* arg3) |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
673 { |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
674 } |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
675 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
676 void* __dso_handle = (void*) &__dso_handle; |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
677 |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
678 //========================================================================== |
|
07fc475e1c28
Add Cortex-M architecture HAL, STM32 variant and STM3210E platform HALs.
nickg
parents:
diff
changeset
|
679 // EOF hal_misc.c |
