Browse Source

Fix TDM input on Teensy 4.0

dds
PaulStoffregen 5 years ago
parent
commit
c5a33a0049
2 changed files with 10 additions and 7 deletions
  1. +4
    -5
      input_tdm.cpp
  2. +6
    -2
      output_tdm.cpp

+ 4
- 5
input_tdm.cpp View File

#include <Arduino.h> #include <Arduino.h>
#include "input_tdm.h" #include "input_tdm.h"
#include "output_tdm.h" #include "output_tdm.h"
#if defined(KINETISK) || defined(__IMXRT1052__) || defined(__IMXRT1062__)
#if defined(KINETISK) || defined(__IMXRT1062__)
#include "utility/imxrt_hw.h" #include "utility/imxrt_hw.h"


DMAMEM __attribute__((aligned(32))) DMAMEM __attribute__((aligned(32)))
I2S0_RCSR |= I2S_RCSR_RE | I2S_RCSR_BCE | I2S_RCSR_FRDE | I2S_RCSR_FR; I2S0_RCSR |= I2S_RCSR_RE | I2S_RCSR_BCE | I2S_RCSR_FRDE | I2S_RCSR_FR;
I2S0_TCSR |= I2S_TCSR_TE | I2S_TCSR_BCE; // TX clock enable, because sync'd to TX I2S0_TCSR |= I2S_TCSR_TE | I2S_TCSR_BCE; // TX clock enable, because sync'd to TX
dma.attachInterrupt(isr); dma.attachInterrupt(isr);
#else
CORE_PIN7_CONFIG = 3; //RX_DATA0
#elif defined(__IMXRT1062__)
CORE_PIN8_CONFIG = 3; //RX_DATA0
IOMUXC_SAI1_RX_DATA0_SELECT_INPUT = 2; IOMUXC_SAI1_RX_DATA0_SELECT_INPUT = 2;
dma.TCD->SADDR = &I2S1_RDR0; dma.TCD->SADDR = &I2S1_RDR0;
dma.TCD->SOFF = 0; dma.TCD->SOFF = 0;
update_responsibility = update_setup(); update_responsibility = update_setup();
dma.enable(); dma.enable();


I2S1_RCSR |= I2S_RCSR_RE | I2S_RCSR_BCE | I2S_RCSR_FRDE | I2S_RCSR_FR;
I2S1_TCSR |= I2S_TCSR_TE | I2S_TCSR_BCE;
I2S1_RCSR = I2S_RCSR_RE | I2S_RCSR_BCE | I2S_RCSR_FRDE | I2S_RCSR_FR;
dma.attachInterrupt(isr); dma.attachInterrupt(isr);
#endif #endif
} }

+ 6
- 2
output_tdm.cpp View File

update_responsibility = update_setup(); update_responsibility = update_setup();
dma.enable(); dma.enable();


I2S1_RCSR |= I2S_RCSR_RE;
I2S1_TCSR |= I2S_TCSR_TE | I2S_TCSR_BCE | I2S_TCSR_FRDE;
I2S1_RCSR |= I2S_RCSR_RE | I2S_RCSR_BCE;
I2S1_TCSR = I2S_TCSR_TE | I2S_TCSR_BCE | I2S_TCSR_FRDE;


#endif #endif
dma.attachInterrupt(isr); dma.attachInterrupt(isr);


#elif defined(__IMXRT1062__) #elif defined(__IMXRT1062__)
CCM_CCGR5 |= CCM_CCGR5_SAI1(CCM_CCGR_ON); CCM_CCGR5 |= CCM_CCGR5_SAI1(CCM_CCGR_ON);

// if either transmitter or receiver is enabled, do nothing
if (I2S1_TCSR & I2S_TCSR_TE) return;
if (I2S1_RCSR & I2S_RCSR_RE) return;
//PLL: //PLL:
int fs = AUDIO_SAMPLE_RATE_EXACT; int fs = AUDIO_SAMPLE_RATE_EXACT;
// PLL between 27*24 = 648MHz und 54*24=1296MHz // PLL between 27*24 = 648MHz und 54*24=1296MHz

Loading…
Cancel
Save