Browse Source

Support more clock speeds

dds
PaulStoffregen 8 years ago
parent
commit
13d11c61a3
4 changed files with 50 additions and 1 deletions
  1. +10
    -0
      output_i2s.cpp
  2. +10
    -0
      output_i2s_quad.cpp
  3. +10
    -0
      output_spdif.cpp
  4. +20
    -1
      utility/pdb.h

+ 10
- 0
output_i2s.cpp View File

#elif F_CPU == 180000000 #elif F_CPU == 180000000
#define MCLK_MULT 16 #define MCLK_MULT 16
#define MCLK_DIV 255 #define MCLK_DIV 255
#define MCLK_SRC 0
#elif F_CPU == 192000000 #elif F_CPU == 192000000
#define MCLK_MULT 1 #define MCLK_MULT 1
#define MCLK_DIV 17 #define MCLK_DIV 17
#elif F_CPU == 216000000
#define MCLK_MULT 8
#define MCLK_DIV 153
#define MCLK_SRC 0
#elif F_CPU == 240000000
#define MCLK_MULT 4
#define MCLK_DIV 85
#elif F_CPU == 16000000 #elif F_CPU == 16000000
#define MCLK_MULT 12 #define MCLK_MULT 12
#define MCLK_DIV 17 #define MCLK_DIV 17
#error "This CPU Clock Speed is not supported by the Audio library"; #error "This CPU Clock Speed is not supported by the Audio library";
#endif #endif


#ifndef MCLK_SRC
#if F_CPU >= 20000000 #if F_CPU >= 20000000
#define MCLK_SRC 3 // the PLL #define MCLK_SRC 3 // the PLL
#else #else
#define MCLK_SRC 0 // system clock #define MCLK_SRC 0 // system clock
#endif #endif
#endif


void AudioOutputI2S::config_i2s(void) void AudioOutputI2S::config_i2s(void)
{ {

+ 10
- 0
output_i2s_quad.cpp View File

#elif F_CPU == 180000000 #elif F_CPU == 180000000
#define MCLK_MULT 16 #define MCLK_MULT 16
#define MCLK_DIV 255 #define MCLK_DIV 255
#define MCLK_SRC 0
#elif F_CPU == 192000000 #elif F_CPU == 192000000
#define MCLK_MULT 1 #define MCLK_MULT 1
#define MCLK_DIV 17 #define MCLK_DIV 17
#elif F_CPU == 216000000
#define MCLK_MULT 8
#define MCLK_DIV 153
#define MCLK_SRC 0
#elif F_CPU == 240000000
#define MCLK_MULT 4
#define MCLK_DIV 85
#elif F_CPU == 16000000 #elif F_CPU == 16000000
#define MCLK_MULT 12 #define MCLK_MULT 12
#define MCLK_DIV 17 #define MCLK_DIV 17
#error "This CPU Clock Speed is not supported by the Audio library"; #error "This CPU Clock Speed is not supported by the Audio library";
#endif #endif


#ifndef MCLK_SRC
#if F_CPU >= 20000000 #if F_CPU >= 20000000
#define MCLK_SRC 3 // the PLL #define MCLK_SRC 3 // the PLL
#else #else
#define MCLK_SRC 0 // system clock #define MCLK_SRC 0 // system clock
#endif #endif
#endif


void AudioOutputI2SQuad::config_i2s(void) void AudioOutputI2SQuad::config_i2s(void)
{ {

+ 10
- 0
output_spdif.cpp View File

#elif F_CPU == 180000000 #elif F_CPU == 180000000
#define MCLK_MULT 16 #define MCLK_MULT 16
#define MCLK_DIV 255 #define MCLK_DIV 255
#define MCLK_SRC 0
#elif F_CPU == 192000000 #elif F_CPU == 192000000
#define MCLK_MULT 1 #define MCLK_MULT 1
#define MCLK_DIV 17 #define MCLK_DIV 17
#elif F_CPU == 216000000
#define MCLK_MULT 8
#define MCLK_DIV 153
#define MCLK_SRC 0
#elif F_CPU == 240000000
#define MCLK_MULT 4
#define MCLK_DIV 85
#elif F_CPU == 16000000 #elif F_CPU == 16000000
#define MCLK_MULT 12 #define MCLK_MULT 12
#define MCLK_DIV 17 #define MCLK_DIV 17
#error "This CPU Clock Speed is not supported by the Audio library"; #error "This CPU Clock Speed is not supported by the Audio library";
#endif #endif


#ifndef MCLK_SRC
#if F_CPU >= 20000000 #if F_CPU >= 20000000
#define MCLK_SRC 3 // the PLL #define MCLK_SRC 3 // the PLL
#else #else
#define MCLK_SRC 0 // system clock #define MCLK_SRC 0 // system clock
#endif #endif
#endif




void AudioOutputSPDIF::config_SPDIF(void) void AudioOutputSPDIF::config_SPDIF(void)

+ 20
- 1
utility/pdb.h View File



#define PDB_CONFIG (PDB_SC_TRGSEL(15) | PDB_SC_PDBEN | PDB_SC_CONT | PDB_SC_PDBIE | PDB_SC_DMAEN) #define PDB_CONFIG (PDB_SC_TRGSEL(15) | PDB_SC_PDBEN | PDB_SC_CONT | PDB_SC_PDBIE | PDB_SC_DMAEN)


#if F_BUS == 60000000

#if F_BUS == 120000000
#define PDB_PERIOD (2720-1)
#elif F_BUS == 108000000
#define PDB_PERIOD (2448-1)
#elif F_BUS == 96000000
#define PDB_PERIOD (2176-1)
#elif F_BUS == 90000000
#define PDB_PERIOD (2040-1)
#elif F_BUS == 80000000
#define PDB_PERIOD (1813-1) // small ?? error
#elif F_BUS == 72000000
#define PDB_PERIOD (1632-1)
#elif F_BUS == 64000000
#define PDB_PERIOD (1451-1) // small ?? error
#elif F_BUS == 60000000
#define PDB_PERIOD (1360-1) #define PDB_PERIOD (1360-1)
#elif F_BUS == 56000000 #elif F_BUS == 56000000
#define PDB_PERIOD (1269-1) // 0.026% error #define PDB_PERIOD (1269-1) // 0.026% error
#elif F_BUS == 54000000
#define PDB_PERIOD (1224-1)
#elif F_BUS == 48000000 #elif F_BUS == 48000000
#define PDB_PERIOD (1088-1) #define PDB_PERIOD (1088-1)
#elif F_BUS == 40000000
#define PDB_PERIOD (907-1) // small ?? error
#elif F_BUS == 36000000 #elif F_BUS == 36000000
#define PDB_PERIOD (816-1) #define PDB_PERIOD (816-1)
#elif F_BUS == 24000000 #elif F_BUS == 24000000

Loading…
Cancel
Save