Browse Source

Use RAM-based interrupt vector table

teensy4-core
PaulStoffregen 10 years ago
parent
commit
e8a02961b0
2 changed files with 10 additions and 4 deletions
  1. +8
    -3
      teensy3/mk20dx128.c
  2. +2
    -1
      teensy3/mk20dx128.h

+ 8
- 3
teensy3/mk20dx128.c View File

void porte_isr(void) __attribute__ ((weak, alias("unused_isr"))); void porte_isr(void) __attribute__ ((weak, alias("unused_isr")));
void software_isr(void) __attribute__ ((weak, alias("unused_isr"))); void software_isr(void) __attribute__ ((weak, alias("unused_isr")));


#if defined(__MK20DX128__)
__attribute__ ((section(".dmabuffers"), used, aligned(256)))
#else
__attribute__ ((section(".dmabuffers"), used, aligned(512)))
#endif
void (* _VectorsRam[NVIC_NUM_INTERRUPTS+16])(void);


// TODO: create AVR-stype ISR() macro, with default linkage to undefined handler
//
__attribute__ ((section(".vectors"), used)) __attribute__ ((section(".vectors"), used))
void (* const gVectors[])(void) =
void (* const _VectorsFlash[NVIC_NUM_INTERRUPTS+16])(void) =
{ {
(void (*)(void))((unsigned long)&_estack), // 0 ARM: Initial Stack Pointer (void (*)(void))((unsigned long)&_estack), // 0 ARM: Initial Stack Pointer
ResetHandler, // 1 ARM: Initial Program Counter ResetHandler, // 1 ARM: Initial Program Counter
SCB_VTOR = 0; // use vector table in flash SCB_VTOR = 0; // use vector table in flash


// default all interrupts to medium priority level // default all interrupts to medium priority level
for (i=0; i < NVIC_NUM_INTERRUPTS + 16; i++) _VectorsRam[i] = _VectorsFlash[i];
for (i=0; i < NVIC_NUM_INTERRUPTS; i++) NVIC_SET_PRIORITY(i, 128); for (i=0; i < NVIC_NUM_INTERRUPTS; i++) NVIC_SET_PRIORITY(i, 128);


// hardware always starts in FEI mode // hardware always starts in FEI mode

+ 2
- 1
teensy3/mk20dx128.h View File








#define __disable_irq() __asm__ volatile("CPSID i"); #define __disable_irq() __asm__ volatile("CPSID i");
#define __enable_irq() __asm__ volatile("CPSIE i"); #define __enable_irq() __asm__ volatile("CPSIE i");


extern void software_isr(void); extern void software_isr(void);




extern void (* _VectorsRam[NVIC_NUM_INTERRUPTS+16])(void);
extern void (* const _VectorsFlash[NVIC_NUM_INTERRUPTS+16])(void);


#ifdef __cplusplus #ifdef __cplusplus
} }

Loading…
Cancel
Save