Browse Source

Add attachInterruptVector()

teensy4-core
PaulStoffregen 10 years ago
parent
commit
3b5dc896f7
3 changed files with 14 additions and 12 deletions
  1. +5
    -0
      teensy3/core_pins.h
  2. +4
    -12
      teensy3/kinetis.h
  3. +5
    -0
      teensy3/pins_teensy.c

+ 5
- 0
teensy3/core_pins.h View File

static inline void analogWriteResolution(uint32_t bits) { analogWriteRes(bits); } static inline void analogWriteResolution(uint32_t bits) { analogWriteRes(bits); }
void analogWriteFrequency(uint8_t pin, uint32_t frequency); void analogWriteFrequency(uint8_t pin, uint32_t frequency);
void analogWriteDAC0(int val); void analogWriteDAC0(int val);
#ifdef __cplusplus
void attachInterruptVector(IRQ_NUMBER_t irq, void (*function)(void));
#else
void attachInterruptVector(enum IRQ_NUMBER_t irq, void (*function)(void));
#endif
void attachInterrupt(uint8_t pin, void (*function)(void), int mode); void attachInterrupt(uint8_t pin, void (*function)(void), int mode);
void detachInterrupt(uint8_t pin); void detachInterrupt(uint8_t pin);
void _init_Teensyduino_internal_(void); void _init_Teensyduino_internal_(void);

+ 4
- 12
teensy3/kinetis.h View File



#include <stdint.h> #include <stdint.h>


#ifdef __cplusplus
#define BEGIN_ENUM(NAME) enum name {
#define END_ENUM(NAME) };
#else
#define BEGIN_ENUM(NAME) typedef enum {
#define END_ENUM(NAME) } name;
#endif

// Teensy 3.0 // Teensy 3.0
#if defined(__MK20DX128__) #if defined(__MK20DX128__)
BEGIN_ENUM(IRQ_NUMBER_t)
enum IRQ_NUMBER_t {
IRQ_DMA_CH0 = 0, IRQ_DMA_CH0 = 0,
IRQ_DMA_CH1 = 1, IRQ_DMA_CH1 = 1,
IRQ_DMA_CH2 = 2, IRQ_DMA_CH2 = 2,
IRQ_PORTD = 43, IRQ_PORTD = 43,
IRQ_PORTE = 44, IRQ_PORTE = 44,
IRQ_SOFTWARE = 45 IRQ_SOFTWARE = 45
END_ENUM(IRQ_NUMBER_t)
};
#define NVIC_NUM_INTERRUPTS 46 #define NVIC_NUM_INTERRUPTS 46
#define DMA_NUM_CHANNELS 4 #define DMA_NUM_CHANNELS 4
#define KINETISK_UART0 #define KINETISK_UART0


// Teensy 3.1 // Teensy 3.1
#elif defined(__MK20DX256__) #elif defined(__MK20DX256__)
BEGIN_ENUM(IRQ_NUMBER_t)
enum IRQ_NUMBER_t {
IRQ_DMA_CH0 = 0, IRQ_DMA_CH0 = 0,
IRQ_DMA_CH1 = 1, IRQ_DMA_CH1 = 1,
IRQ_DMA_CH2 = 2, IRQ_DMA_CH2 = 2,
IRQ_PORTD = 90, IRQ_PORTD = 90,
IRQ_PORTE = 91, IRQ_PORTE = 91,
IRQ_SOFTWARE = 94 IRQ_SOFTWARE = 94
END_ENUM(IRQ_NUMBER_t)
};
#define NVIC_NUM_INTERRUPTS 95 #define NVIC_NUM_INTERRUPTS 95
#define DMA_NUM_CHANNELS 16 #define DMA_NUM_CHANNELS 16
#define KINETISK_UART0 #define KINETISK_UART0

+ 5
- 0
teensy3/pins_teensy.c View File

// fast interrupts will still be serviced quickly? // fast interrupts will still be serviced quickly?
} }


void attachInterruptVector(enum IRQ_NUMBER_t irq, void (*function)(void))
{
_VectorsRam[irq + 16] = function;
}

void attachInterrupt(uint8_t pin, void (*function)(void), int mode) void attachInterrupt(uint8_t pin, void (*function)(void), int mode)
{ {
volatile uint32_t *config; volatile uint32_t *config;

Loading…
Cancel
Save