ChibiOS/RT
2.6.0
vectors.c
Go to the documentation of this file.
00001 /*
00002     ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
00003                  2011,2012,2013 Giovanni Di Sirio.
00004 
00005     This file is part of ChibiOS/RT.
00006 
00007     ChibiOS/RT is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     ChibiOS/RT is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 
00020                                       ---
00021 
00022     A special exception to the GPL can be applied should you wish to distribute
00023     a combined work that includes ChibiOS/RT, without being obliged to provide
00024     the source code for any proprietary components. See the file exception.txt
00025     for full details of how and when the exception can be applied.
00026 */
00027 
00028 /**
00029  * @file    GCC/ARMCMx/STM32F1xx/vectors.c
00030  * @brief   Interrupt vectors for the STM32F1xx family.
00031  *
00032  * @defgroup ARMCMx_STM32F1xx_VECTORS STM32F1xx Interrupt Vectors
00033  * @ingroup ARMCMx_SPECIFIC
00034  * @details Interrupt vectors for the STM32F1xx family.
00035  *          One of the following macros must be defined on the
00036  *          compiler command line or in a file named <tt>board.h</tt>:
00037  *          - @p STM32F10X_LD
00038  *          - @p STM32F10X_LD_VL
00039  *          - @p STM32F10X_MD
00040  *          - @p STM32F10X_MD_VL
00041  *          - @p STM32F10X_HD
00042  *          - @p STM32F10X_XL
00043  *          - @p STM32F10X_CL
00044  *          .
00045  *          This is required in order to include a vectors table with
00046  *          the correct length for the specified STM32 model.
00047  * @{
00048  */
00049 
00050 #include "ch.h"
00051 
00052 #if !defined(STM32F10X_LD) && !defined(STM32F10X_LD_VL) &&                  \
00053     !defined(STM32F10X_MD) && !defined(STM32F10X_MD_VL) &&                  \
00054     !defined(STM32F10X_HD) && !defined(STM32F10X_XL) &&                     \
00055     !defined(STM32F10X_CL)
00056 #include "board.h"
00057 #endif
00058 
00059 #if defined(STM32F10X_MD_VL) ||  defined(__DOXYGEN__)
00060 #define NUM_VECTORS     46
00061 #elif defined(STM32F10X_HD)  || defined(STM32F10X_XL)
00062 #define NUM_VECTORS     60
00063 #elif defined(STM32F10X_CL)
00064 #define NUM_VECTORS     68
00065 #else
00066 #define NUM_VECTORS     43
00067 #endif
00068 
00069 /**
00070  * @brief   Type of an IRQ vector.
00071  */
00072 typedef void  (*irq_vector_t)(void);
00073 
00074 /**
00075  * @brief   Type of a structure representing the whole vectors table.
00076  */
00077 typedef struct {
00078   uint32_t      *init_stack;
00079   irq_vector_t  reset_vector;
00080   irq_vector_t  nmi_vector;
00081   irq_vector_t  hardfault_vector;
00082   irq_vector_t  memmanage_vector;
00083   irq_vector_t  busfault_vector;
00084   irq_vector_t  usagefault_vector;
00085   irq_vector_t  vector1c;
00086   irq_vector_t  vector20;
00087   irq_vector_t  vector24;
00088   irq_vector_t  vector28;
00089   irq_vector_t  svcall_vector;
00090   irq_vector_t  debugmonitor_vector;
00091   irq_vector_t  vector34;
00092   irq_vector_t  pendsv_vector;
00093   irq_vector_t  systick_vector;
00094   irq_vector_t  vectors[NUM_VECTORS];
00095 } vectors_t;
00096 
00097 #if !defined(__DOXYGEN__)
00098 extern uint32_t __main_stack_end__;
00099 extern void ResetHandler(void);
00100 extern void NMIVector(void);
00101 extern void HardFaultVector(void);
00102 extern void MemManageVector(void);
00103 extern void BusFaultVector(void);
00104 extern void UsageFaultVector(void);
00105 extern void Vector1C(void);
00106 extern void Vector20(void);
00107 extern void Vector24(void);
00108 extern void Vector28(void);
00109 extern void SVCallVector(void);
00110 extern void DebugMonitorVector(void);
00111 extern void Vector34(void);
00112 extern void PendSVVector(void);
00113 extern void SysTickVector(void);
00114 extern void Vector40(void);
00115 extern void Vector44(void);
00116 extern void Vector48(void);
00117 extern void Vector4C(void);
00118 extern void Vector50(void);
00119 extern void Vector54(void);
00120 extern void Vector58(void);
00121 extern void Vector5C(void);
00122 extern void Vector60(void);
00123 extern void Vector64(void);
00124 extern void Vector68(void);
00125 extern void Vector6C(void);
00126 extern void Vector70(void);
00127 extern void Vector74(void);
00128 extern void Vector78(void);
00129 extern void Vector7C(void);
00130 extern void Vector80(void);
00131 extern void Vector84(void);
00132 extern void Vector88(void);
00133 extern void Vector8C(void);
00134 extern void Vector90(void);
00135 extern void Vector94(void);
00136 extern void Vector98(void);
00137 extern void Vector9C(void);
00138 extern void VectorA0(void);
00139 extern void VectorA4(void);
00140 extern void VectorA8(void);
00141 extern void VectorAC(void);
00142 extern void VectorB0(void);
00143 extern void VectorB4(void);
00144 extern void VectorB8(void);
00145 extern void VectorBC(void);
00146 extern void VectorC0(void);
00147 extern void VectorC4(void);
00148 extern void VectorC8(void);
00149 extern void VectorCC(void);
00150 extern void VectorD0(void);
00151 extern void VectorD4(void);
00152 extern void VectorD8(void);
00153 extern void VectorDC(void);
00154 extern void VectorE0(void);
00155 extern void VectorE4(void);
00156 extern void VectorE8(void);
00157 #if defined(STM32F10X_MD_VL) || defined(STM32F10X_HD) ||                    \
00158     defined(STM32F10X_XL)    || defined(STM32F10X_CL)
00159 extern void VectorEC(void);
00160 extern void VectorF0(void);
00161 extern void VectorF4(void);
00162 #endif
00163 #if defined(STM32F10X_HD)    || defined(STM32F10X_XL) || defined(STM32F10X_CL)
00164 extern void VectorF8(void);
00165 extern void VectorFC(void);
00166 extern void Vector100(void);
00167 extern void Vector104(void);
00168 extern void Vector108(void);
00169 extern void Vector10C(void);
00170 extern void Vector110(void);
00171 extern void Vector114(void);
00172 extern void Vector118(void);
00173 extern void Vector11C(void);
00174 extern void Vector120(void);
00175 extern void Vector124(void);
00176 extern void Vector128(void);
00177 extern void Vector12C(void);
00178 #endif
00179 #if defined(STM32F10X_CL)
00180 extern void Vector130(void);
00181 extern void Vector134(void);
00182 extern void Vector138(void);
00183 extern void Vector13C(void);
00184 extern void Vector140(void);
00185 extern void Vector144(void);
00186 extern void Vector148(void);
00187 extern void Vector14C(void);
00188 #endif
00189 #endif
00190 
00191 /**
00192  * @brief   STM32 vectors table.
00193  */
00194 #if !defined(__DOXYGEN__)
00195 __attribute__ ((section("vectors")))
00196 #endif
00197 vectors_t _vectors = {
00198   &__main_stack_end__,ResetHandler,       NMIVector,          HardFaultVector,
00199   MemManageVector,    BusFaultVector,     UsageFaultVector,   Vector1C,
00200   Vector20,           Vector24,           Vector28,           SVCallVector,
00201   DebugMonitorVector, Vector34,           PendSVVector,       SysTickVector,
00202   {
00203     Vector40,           Vector44,           Vector48,           Vector4C,
00204     Vector50,           Vector54,           Vector58,           Vector5C,
00205     Vector60,           Vector64,           Vector68,           Vector6C,
00206     Vector70,           Vector74,           Vector78,           Vector7C,
00207     Vector80,           Vector84,           Vector88,           Vector8C,
00208     Vector90,           Vector94,           Vector98,           Vector9C,
00209     VectorA0,           VectorA4,           VectorA8,           VectorAC,
00210     VectorB0,           VectorB4,           VectorB8,           VectorBC,
00211     VectorC0,           VectorC4,           VectorC8,           VectorCC,
00212     VectorD0,           VectorD4,           VectorD8,           VectorDC,
00213     VectorE0,           VectorE4,           VectorE8,
00214 #if defined(STM32F10X_MD_VL) || defined(STM32F10X_HD) ||                    \
00215     defined(STM32F10X_XL)    || defined(STM32F10X_CL)
00216     VectorEC,           VectorF0,           VectorF4,
00217 #endif
00218 #if defined(STM32F10X_HD)    || defined(STM32F10X_XL) || defined(STM32F10X_CL)
00219     VectorF8,           VectorFC,           Vector100,          Vector104,
00220     Vector108,          Vector10C,          Vector110,          Vector114,
00221     Vector118,          Vector11C,          Vector120,          Vector124,
00222     Vector128,          Vector12C,
00223 #endif
00224 #if defined(STM32F10X_CL)
00225     Vector130,          Vector134,          Vector138,          Vector13C,
00226     Vector140,          Vector144,          Vector148,          Vector14C
00227 #endif
00228   }
00229 };
00230 
00231 /**
00232  * @brief   Unhandled exceptions handler.
00233  * @details Any undefined exception vector points to this function by default.
00234  *          This function simply stops the system into an infinite loop.
00235  *
00236  * @notapi
00237  */
00238 #if !defined(__DOXYGEN__)
00239 __attribute__ ((naked))
00240 #endif
00241 void _unhandled_exception(void) {
00242 
00243   while (TRUE)
00244     ;
00245 }
00246 
00247 void NMIVector(void) __attribute__((weak, alias("_unhandled_exception")));
00248 void HardFaultVector(void) __attribute__((weak, alias("_unhandled_exception")));
00249 void MemManageVector(void) __attribute__((weak, alias("_unhandled_exception")));
00250 void BusFaultVector(void) __attribute__((weak, alias("_unhandled_exception")));
00251 void UsageFaultVector(void) __attribute__((weak, alias("_unhandled_exception")));
00252 void Vector1C(void) __attribute__((weak, alias("_unhandled_exception")));
00253 void Vector20(void) __attribute__((weak, alias("_unhandled_exception")));
00254 void Vector24(void) __attribute__((weak, alias("_unhandled_exception")));
00255 void Vector28(void) __attribute__((weak, alias("_unhandled_exception")));
00256 void SVCallVector(void) __attribute__((weak, alias("_unhandled_exception")));
00257 void DebugMonitorVector(void) __attribute__((weak, alias("_unhandled_exception")));
00258 void Vector34(void) __attribute__((weak, alias("_unhandled_exception")));
00259 void PendSVVector(void) __attribute__((weak, alias("_unhandled_exception")));
00260 void SysTickVector(void) __attribute__((weak, alias("_unhandled_exception")));
00261 void Vector40(void) __attribute__((weak, alias("_unhandled_exception")));
00262 void Vector44(void) __attribute__((weak, alias("_unhandled_exception")));
00263 void Vector48(void) __attribute__((weak, alias("_unhandled_exception")));
00264 void Vector4C(void) __attribute__((weak, alias("_unhandled_exception")));
00265 void Vector50(void) __attribute__((weak, alias("_unhandled_exception")));
00266 void Vector54(void) __attribute__((weak, alias("_unhandled_exception")));
00267 void Vector58(void) __attribute__((weak, alias("_unhandled_exception")));
00268 void Vector5C(void) __attribute__((weak, alias("_unhandled_exception")));
00269 void Vector60(void) __attribute__((weak, alias("_unhandled_exception")));
00270 void Vector64(void) __attribute__((weak, alias("_unhandled_exception")));
00271 void Vector68(void) __attribute__((weak, alias("_unhandled_exception")));
00272 void Vector6C(void) __attribute__((weak, alias("_unhandled_exception")));
00273 void Vector70(void) __attribute__((weak, alias("_unhandled_exception")));
00274 void Vector74(void) __attribute__((weak, alias("_unhandled_exception")));
00275 void Vector78(void) __attribute__((weak, alias("_unhandled_exception")));
00276 void Vector7C(void) __attribute__((weak, alias("_unhandled_exception")));
00277 void Vector80(void) __attribute__((weak, alias("_unhandled_exception")));
00278 void Vector84(void) __attribute__((weak, alias("_unhandled_exception")));
00279 void Vector88(void) __attribute__((weak, alias("_unhandled_exception")));
00280 void Vector8C(void) __attribute__((weak, alias("_unhandled_exception")));
00281 void Vector90(void) __attribute__((weak, alias("_unhandled_exception")));
00282 void Vector94(void) __attribute__((weak, alias("_unhandled_exception")));
00283 void Vector98(void) __attribute__((weak, alias("_unhandled_exception")));
00284 void Vector9C(void) __attribute__((weak, alias("_unhandled_exception")));
00285 void VectorA0(void) __attribute__((weak, alias("_unhandled_exception")));
00286 void VectorA4(void) __attribute__((weak, alias("_unhandled_exception")));
00287 void VectorA8(void) __attribute__((weak, alias("_unhandled_exception")));
00288 void VectorAC(void) __attribute__((weak, alias("_unhandled_exception")));
00289 void VectorB0(void) __attribute__((weak, alias("_unhandled_exception")));
00290 void VectorB4(void) __attribute__((weak, alias("_unhandled_exception")));
00291 void VectorB8(void) __attribute__((weak, alias("_unhandled_exception")));
00292 void VectorBC(void) __attribute__((weak, alias("_unhandled_exception")));
00293 void VectorC0(void) __attribute__((weak, alias("_unhandled_exception")));
00294 void VectorC4(void) __attribute__((weak, alias("_unhandled_exception")));
00295 void VectorC8(void) __attribute__((weak, alias("_unhandled_exception")));
00296 void VectorCC(void) __attribute__((weak, alias("_unhandled_exception")));
00297 void VectorD0(void) __attribute__((weak, alias("_unhandled_exception")));
00298 void VectorD4(void) __attribute__((weak, alias("_unhandled_exception")));
00299 void VectorD8(void) __attribute__((weak, alias("_unhandled_exception")));
00300 void VectorDC(void) __attribute__((weak, alias("_unhandled_exception")));
00301 void VectorE0(void) __attribute__((weak, alias("_unhandled_exception")));
00302 void VectorE4(void) __attribute__((weak, alias("_unhandled_exception")));
00303 void VectorE8(void) __attribute__((weak, alias("_unhandled_exception")));
00304 #if defined(STM32F10X_MD_VL) || defined(STM32F10X_HD) ||                    \
00305     defined(STM32F10X_XL)    || defined(STM32F10X_CL)
00306 void VectorEC(void) __attribute__((weak, alias("_unhandled_exception")));
00307 void VectorF0(void) __attribute__((weak, alias("_unhandled_exception")));
00308 void VectorF4(void) __attribute__((weak, alias("_unhandled_exception")));
00309 #endif
00310 #if defined(STM32F10X_HD)    || defined(STM32F10X_XL) || defined(STM32F10X_CL)
00311 void VectorF8(void) __attribute__((weak, alias("_unhandled_exception")));
00312 void VectorFC(void) __attribute__((weak, alias("_unhandled_exception")));
00313 void Vector100(void) __attribute__((weak, alias("_unhandled_exception")));
00314 void Vector104(void) __attribute__((weak, alias("_unhandled_exception")));
00315 void Vector108(void) __attribute__((weak, alias("_unhandled_exception")));
00316 void Vector10C(void) __attribute__((weak, alias("_unhandled_exception")));
00317 void Vector110(void) __attribute__((weak, alias("_unhandled_exception")));
00318 void Vector114(void) __attribute__((weak, alias("_unhandled_exception")));
00319 void Vector118(void) __attribute__((weak, alias("_unhandled_exception")));
00320 void Vector11C(void) __attribute__((weak, alias("_unhandled_exception")));
00321 void Vector120(void) __attribute__((weak, alias("_unhandled_exception")));
00322 void Vector124(void) __attribute__((weak, alias("_unhandled_exception")));
00323 void Vector128(void) __attribute__((weak, alias("_unhandled_exception")));
00324 void Vector12C(void) __attribute__((weak, alias("_unhandled_exception")));
00325 #endif
00326 #if defined(STM32F10X_CL)
00327 void Vector130(void) __attribute__((weak, alias("_unhandled_exception")));
00328 void Vector134(void) __attribute__((weak, alias("_unhandled_exception")));
00329 void Vector138(void) __attribute__((weak, alias("_unhandled_exception")));
00330 void Vector13C(void) __attribute__((weak, alias("_unhandled_exception")));
00331 void Vector140(void) __attribute__((weak, alias("_unhandled_exception")));
00332 void Vector144(void) __attribute__((weak, alias("_unhandled_exception")));
00333 void Vector148(void) __attribute__((weak, alias("_unhandled_exception")));
00334 void Vector14C(void) __attribute__((weak, alias("_unhandled_exception")));
00335 #endif
00336 
00337 /** @} */