Browse Source

Fix USB serial number on K64 & K66

teensy4-core
PaulStoffregen 8 years ago
parent
commit
0ed6ba9a96
2 changed files with 16 additions and 1 deletions
  1. +7
    -1
      teensy3/kinetis.h
  2. +9
    -0
      teensy3/usb_desc.c

+ 7
- 1
teensy3/kinetis.h View File

#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







+ 9
- 0
teensy3/usb_desc.c View File

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;

Loading…
Cancel
Save