Przeglądaj źródła

Fix USB serial number on K64 & K66

main
PaulStoffregen 8 lat temu
rodzic
commit
0ed6ba9a96
2 zmienionych plików z 16 dodań i 1 usunięć
  1. +7
    -1
      teensy3/kinetis.h
  2. +9
    -0
      teensy3/usb_desc.c

+ 7
- 1
teensy3/kinetis.h Wyświetl plik

@@ -138,8 +138,10 @@ enum IRQ_NUMBER_t {
#define HAS_KINETIS_LLWU_16CH
#define HAS_KINETIS_ADC0
#define HAS_KINETIS_TSI
#define HAS_KINETIS_FLASH_FTFL

// Teensy 3.1

// Teensy 3.1 & 3.2
#elif defined(__MK20DX256__)
enum IRQ_NUMBER_t {
IRQ_DMA_CH0 = 0,
@@ -278,6 +280,7 @@ enum IRQ_NUMBER_t {
#define HAS_KINETIS_ADC0
#define HAS_KINETIS_ADC1
#define HAS_KINETIS_TSI
#define HAS_KINETIS_FLASH_FTFL

// Teensy-LC
#elif defined(__MKL26Z64__)
@@ -368,6 +371,7 @@ enum IRQ_NUMBER_t {
#define HAS_KINETIS_LLWU_16CH
#define HAS_KINETIS_ADC0
#define HAS_KINETIS_TSI_LITE
#define HAS_KINETIS_FLASH_FTFA


#elif defined(__MK64FX512__)
@@ -545,6 +549,7 @@ enum IRQ_NUMBER_t {
#define HAS_KINETIS_MPU
#define HAS_KINETIS_ADC0
#define HAS_KINETIS_ADC1
#define HAS_KINETIS_FLASH_FTFE


#elif defined(__MK66FX1M0__)
@@ -747,6 +752,7 @@ enum IRQ_NUMBER_t {
#define HAS_KINETIS_ADC0
#define HAS_KINETIS_ADC1
#define HAS_KINETIS_TSI_LITE
#define HAS_KINETIS_FLASH_FTFE




+ 9
- 0
teensy3/usb_desc.c Wyświetl plik

@@ -1221,12 +1221,21 @@ void usb_init_serialnumber(void)
uint32_t i, num;

__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_FCCOB0 = 0x41;
FTFL_FCCOB1 = 15;
FTFL_FSTAT = FTFL_FSTAT_CCIF;
while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
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();
// add extra zero to work around OS-X CDC-ACM driver bug
if (num < 10000000) num = num * 10;

Ładowanie…
Anuluj
Zapisz