#define HAS_KINETIS_LLWU_16CH | #define HAS_KINETIS_LLWU_16CH | ||||
#define HAS_KINETIS_ADC0 | #define HAS_KINETIS_ADC0 | ||||
#define HAS_KINETIS_TSI | #define HAS_KINETIS_TSI | ||||
#define HAS_KINETIS_FLASH_FTFL | |||||
// Teensy 3.1 | |||||
// Teensy 3.1 & 3.2 | |||||
#elif defined(__MK20DX256__) | #elif defined(__MK20DX256__) | ||||
enum IRQ_NUMBER_t { | enum IRQ_NUMBER_t { | ||||
IRQ_DMA_CH0 = 0, | IRQ_DMA_CH0 = 0, | ||||
#define HAS_KINETIS_ADC0 | #define HAS_KINETIS_ADC0 | ||||
#define HAS_KINETIS_ADC1 | #define HAS_KINETIS_ADC1 | ||||
#define HAS_KINETIS_TSI | #define HAS_KINETIS_TSI | ||||
#define HAS_KINETIS_FLASH_FTFL | |||||
// Teensy-LC | // Teensy-LC | ||||
#elif defined(__MKL26Z64__) | #elif defined(__MKL26Z64__) | ||||
#define HAS_KINETIS_LLWU_16CH | #define HAS_KINETIS_LLWU_16CH | ||||
#define HAS_KINETIS_ADC0 | #define HAS_KINETIS_ADC0 | ||||
#define HAS_KINETIS_TSI_LITE | #define HAS_KINETIS_TSI_LITE | ||||
#define HAS_KINETIS_FLASH_FTFA | |||||
#elif defined(__MK64FX512__) | #elif defined(__MK64FX512__) | ||||
#define HAS_KINETIS_MPU | #define HAS_KINETIS_MPU | ||||
#define HAS_KINETIS_ADC0 | #define HAS_KINETIS_ADC0 | ||||
#define HAS_KINETIS_ADC1 | #define HAS_KINETIS_ADC1 | ||||
#define HAS_KINETIS_FLASH_FTFE | |||||
#elif defined(__MK66FX1M0__) | #elif defined(__MK66FX1M0__) | ||||
#define HAS_KINETIS_ADC0 | #define HAS_KINETIS_ADC0 | ||||
#define HAS_KINETIS_ADC1 | #define HAS_KINETIS_ADC1 | ||||
#define HAS_KINETIS_TSI_LITE | #define HAS_KINETIS_TSI_LITE | ||||
#define HAS_KINETIS_FLASH_FTFE | |||||
uint32_t i, num; | uint32_t i, num; | ||||
__disable_irq(); | __disable_irq(); | ||||
#if defined(HAS_KINETIS_FLASH_FTFA) || defined(HAS_KINETIS_FLASH_FTFL) | |||||
FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL; | FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL; | ||||
FTFL_FCCOB0 = 0x41; | FTFL_FCCOB0 = 0x41; | ||||
FTFL_FCCOB1 = 15; | FTFL_FCCOB1 = 15; | ||||
FTFL_FSTAT = FTFL_FSTAT_CCIF; | FTFL_FSTAT = FTFL_FSTAT_CCIF; | ||||
while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait | while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait | ||||
num = *(uint32_t *)&FTFL_FCCOB7; | num = *(uint32_t *)&FTFL_FCCOB7; | ||||
#elif defined(HAS_KINETIS_FLASH_FTFE) | |||||
// TODO: does not work in HSRUN mode | |||||
FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL; | |||||
*(uint32_t *)&FTFL_FCCOB3 = 0x41070000; | |||||
FTFL_FSTAT = FTFL_FSTAT_CCIF; | |||||
while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait | |||||
num = *(uint32_t *)&FTFL_FCCOBB; | |||||
#endif | |||||
__enable_irq(); | __enable_irq(); | ||||
// add extra zero to work around OS-X CDC-ACM driver bug | // add extra zero to work around OS-X CDC-ACM driver bug | ||||
if (num < 10000000) num = num * 10; | if (num < 10000000) num = num * 10; |