The following macros only work for the Teensy 3.0 (4 DMA channels), because they use a fixed, hard coded number of DMA channels. The Teensy 3.1 has 16 channels, so I suggest changing in mk20x128.h:
to
There might be more, these are just the macros that pedvide and I have found to be not adapted to T3.1. The "restrictions" block can easily be adapted for the upcoming Teensy++3, if that has a different chip. We could also split mk20dx128.h into a chip-specific and generic headers, which I like better than including mk20dx128.h when actually writing code for the '256.
Regards
Christoph
Code:
#define DMA_CEEI_CEEI(n) ((uint8_t)(n & 3)<<0)
#define DMA_SEEI_SEEI(n) ((uint8_t)(n & 3)<<0)
#define DMA_CERQ_CERQ(n) ((uint8_t)(n & 3)<<0)
#define DMA_SERQ_SERQ(n) ((uint8_t)(n & 3)<<0)
#define DMA_CDNE_CDNE(n) ((uint8_t)(n & 3)<<0)
#define DMA_SSRT_SSRT(n) ((uint8_t)(n & 3)<<0)
#define DMA_CERR_CERR(n) ((uint8_t)(n & 3)<<0)
#define DMA_CINT_CINT(n) ((uint8_t)(n & 3)<<0)
to
Code:
#ifdef(__MK20DX128__)
#define NUM_DMA_CHANNELS 4
... <we should/could add other IO restrictions for the T3.0 here> ...
#elif defined(__MK20DX256__)
#define NUM_DMA_CHANNELS 16
... <we should/could add other IO restrictions for the T3.1 here> ...
#else
#warning I don't know your chip. That's bad.
#endif
#define DMA_CHANNEL_N_MASK (NUM_DMA_CHANNELS-1) // generic
... <other existing IO defines here> ...
#define DMA_CEEI_CEEI(n) ((uint8_t)(n & DMA_CHANNEL_N_MASK)<<0)
#define DMA_SEEI_SEEI(n) ((uint8_t)(n & DMA_CHANNEL_N_MASK)<<0)
#define DMA_CERQ_CERQ(n) ((uint8_t)(n & DMA_CHANNEL_N_MASK)<<0)
#define DMA_SERQ_SERQ(n) ((uint8_t)(n & DMA_CHANNEL_N_MASK)<<0)
#define DMA_CDNE_CDNE(n) ((uint8_t)(n & DMA_CHANNEL_N_MASK)<<0)
#define DMA_SSRT_SSRT(n) ((uint8_t)(n & DMA_CHANNEL_N_MASK)<<0)
#define DMA_CERR_CERR(n) ((uint8_t)(n & DMA_CHANNEL_N_MASK)<<0)
#define DMA_CINT_CINT(n) ((uint8_t)(n & DMA_CHANNEL_N_MASK)<<0)
There might be more, these are just the macros that pedvide and I have found to be not adapted to T3.1. The "restrictions" block can easily be adapted for the upcoming Teensy++3, if that has a different chip. We could also split mk20dx128.h into a chip-specific and generic headers, which I like better than including mk20dx128.h when actually writing code for the '256.
Regards
Christoph