forked from PAWPAW-Mirror/lib_xua
Merge remote-tracking branch 'upstream' into feature/ai_examples
This commit is contained in:
@@ -789,12 +789,11 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk,
|
||||
null,
|
||||
p_dsd_clk,
|
||||
#endif
|
||||
divide, curSamFreq, dsdMode);
|
||||
p_mclk_in, clk_audio_bclk, divide, curSamFreq, dsdMode);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
||||
ConfigAudioPortsWrapper(
|
||||
#if (I2S_CHANS_DAC != 0)
|
||||
p_i2s_dac,
|
||||
@@ -813,7 +812,7 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk,
|
||||
p_bclk,
|
||||
#endif
|
||||
#endif
|
||||
divide, curSamFreq, dsdMode);
|
||||
p_mclk_in, clk_audio_bclk, divide, curSamFreq, dsdMode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#include "xua.h"
|
||||
#if XUA_USB_EN
|
||||
#include <xs1.h>
|
||||
#include <print.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef MIDI
|
||||
#include "usb_midi.h"
|
||||
@@ -357,7 +356,21 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
timer tmr;
|
||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||
#ifndef LOCAL_CLOCK_INCREMENT
|
||||
#define LOCAL_CLOCK_INCREMENT (100000) /* 500Hz */
|
||||
#endif
|
||||
#ifndef LOCAL_CLOCK_MARGIN
|
||||
#define LOCAL_CLOCK_MARGIN (1000)
|
||||
#endif
|
||||
int sofClockValid = 0;
|
||||
timer t_sofCheck;
|
||||
unsigned timeLastEdge;
|
||||
unsigned timeNextEdge;
|
||||
t_sofCheck :> timeLastEdge;
|
||||
timeNextEdge + LOCAL_CLOCK_INCREMENT;
|
||||
i_pll_ref.toggle();
|
||||
#endif
|
||||
|
||||
while(1)
|
||||
{
|
||||
@@ -502,6 +515,13 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
}
|
||||
break;
|
||||
}
|
||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||
case t_sofCheck when timerafter(timeNextEdge) :> void:
|
||||
i_pll_ref.toggle();
|
||||
timeLastEdge = timeNextEdge;
|
||||
timeNextEdge += LOCAL_CLOCK_INCREMENT;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#define MASK_16_13 (7) /* Bits that should not be transmitted as part of feedback */
|
||||
#define MASK_16_10 (127) /* For Audio 1.0 we use a mask 1 bit longer than expected to avoid Windows LSB issues */
|
||||
@@ -517,12 +537,11 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
int framesPerSec;
|
||||
GET_SHARED_GLOBAL(usbSpeed, g_curUsbSpeed);
|
||||
static int sofCount = 0;
|
||||
static unsigned syncPinVal = 0;
|
||||
|
||||
framesPerSec = (usbSpeed == XUD_SPEED_HS) ? 8000 : 1000;
|
||||
float float_clocks = (float) sampleFreq/framesPerSec ;
|
||||
|
||||
clocks = (unsigned) (float_clocks * (1 << 16));
|
||||
clocks = ((int64_t) sampleFreq << 16) / framesPerSec;
|
||||
|
||||
asm volatile("stw %0, dp[g_speed]"::"r"(clocks));
|
||||
|
||||
sofCount += 1000;
|
||||
@@ -530,7 +549,9 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
{
|
||||
/* Port is accessed via interface to allow flexibilty with location */
|
||||
i_pll_ref.toggle();
|
||||
t_sofCheck :> timeLastEdge;
|
||||
sofCount = 0;
|
||||
timeNextEdge = timeLastEdge + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN;
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -889,6 +910,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
case XUD_SetData_Select(c_hid, ep_hid, result):
|
||||
hid_ready_flag = 0U;
|
||||
unsigned reportTime;
|
||||
timer tmr;
|
||||
tmr :> reportTime;
|
||||
hidCaptureReportTime(hid_ready_id, reportTime);
|
||||
hidCalcNextReportTime(hid_ready_id);
|
||||
|
||||
@@ -485,20 +485,14 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
|
||||
timeNextClockDetection = timeNextEdge + (LOCAL_CLOCK_INCREMENT/2);
|
||||
timeNextEdge += LOCAL_CLOCK_INCREMENT;
|
||||
|
||||
/* If we are in an external clock mode and this fire, then clock invalid */
|
||||
|
||||
/* If we are in an external clock mode and this fire, then clock invalid
|
||||
* reset counters in case we are moved to digital clock - we want a well timed
|
||||
* first edge */
|
||||
#if (XUA_SPDIF_RX_EN)
|
||||
// if(clkMode == CLOCK_SPDIF)
|
||||
{
|
||||
/* We must have lost valid S/PDIF stream, reset counters, so we dont produce a double edge */
|
||||
spdifCounters.receivedSamples = 0;
|
||||
}
|
||||
spdifCounters.receivedSamples = 0;
|
||||
#endif
|
||||
#if ADAT_RX
|
||||
//if(clkMode == CLOCK_ADAT)
|
||||
{
|
||||
adatCounters.receivedSamples = 0;
|
||||
}
|
||||
adatCounters.receivedSamples = 0;
|
||||
#endif
|
||||
|
||||
#ifdef CLOCK_VALIDITY_CALL
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2013-2021 XMOS LIMITED.
|
||||
// Copyright 2013-2022 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
#include <xs1.h>
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <platform.h>
|
||||
#undef __ASSEMBLER__
|
||||
#include "audioports.h"
|
||||
#include <xccompat.h>
|
||||
#include "xua.h"
|
||||
|
||||
/* Note since DSD ports could be reused for I2S ports we do all the setup manually in C */
|
||||
@@ -46,7 +45,7 @@ void ConfigAudioPortsWrapper(
|
||||
port p_lrclk,
|
||||
port p_bclk,
|
||||
#endif
|
||||
unsigned int divide, unsigned curSamFreq, unsigned int dsdMode)
|
||||
port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned curSamFreq, unsigned int dsdMode)
|
||||
{
|
||||
ConfigAudioPorts(
|
||||
#if (I2S_CHANS_DAC != 0) || (DSD_CHANS_DAC != 0)
|
||||
@@ -61,6 +60,6 @@ unsigned int divide, unsigned curSamFreq, unsigned int dsdMode)
|
||||
p_lrclk,
|
||||
p_bclk,
|
||||
#endif
|
||||
divide, curSamFreq);
|
||||
p_mclk_in, clk_audio_bclk, divide, curSamFreq);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
// Copyright 2011-2021 XMOS LIMITED.
|
||||
// Copyright 2011-2022 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#ifndef _AUDIOPORTS_H_
|
||||
#define _AUDIOPORTS_H_
|
||||
|
||||
#include <xccompat.h>
|
||||
#ifdef __STDC__
|
||||
typedef unsigned clock;
|
||||
#endif
|
||||
#include "xua.h"
|
||||
|
||||
#ifdef __XC__
|
||||
@@ -28,7 +31,7 @@ void ConfigAudioPorts(
|
||||
in port p_bclk,
|
||||
#endif
|
||||
#endif
|
||||
unsigned int divide, unsigned int curSamFreq);
|
||||
in port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned int curSamFreq);
|
||||
#else
|
||||
|
||||
void ConfigAudioPorts(
|
||||
@@ -51,7 +54,7 @@ void ConfigAudioPorts(
|
||||
port p_bclk,
|
||||
#endif
|
||||
#endif
|
||||
unsigned int divide, unsigned int curSamFreq);
|
||||
port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned int curSamFreq);
|
||||
|
||||
|
||||
#endif /* __XC__*/
|
||||
@@ -76,7 +79,7 @@ void ConfigAudioPortsWrapper(
|
||||
buffered in port:32 p_bclk,
|
||||
#endif
|
||||
#endif
|
||||
unsigned int divide, unsigned curSamFreq, unsigned int dsdMode);
|
||||
in port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned curSamFreq, unsigned int dsdMode);
|
||||
#else
|
||||
|
||||
void ConfigAudioPortsWrapper(
|
||||
@@ -92,7 +95,7 @@ void ConfigAudioPortsWrapper(
|
||||
port p_lrclk,
|
||||
port p_bclk,
|
||||
#endif
|
||||
unsigned int divide, unsigned curSamFreq, unsigned int dsdMode);
|
||||
port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned curSamFreq, unsigned int dsdMode);
|
||||
|
||||
|
||||
#endif /* __XC__*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2011-2021 XMOS LIMITED.
|
||||
// Copyright 2011-2022 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <xs1.h>
|
||||
#include <platform.h>
|
||||
@@ -6,11 +6,9 @@
|
||||
#include "xua.h"
|
||||
#include "audioports.h"
|
||||
|
||||
|
||||
|
||||
extern in port p_mclk_in;
|
||||
//extern in port p_mclk_in;
|
||||
extern clock clk_audio_mclk;
|
||||
extern clock clk_audio_bclk;
|
||||
//extern clock clk_audio_bclk;
|
||||
|
||||
void ConfigAudioPorts(
|
||||
#if (I2S_CHANS_DAC != 0) || (DSD_CHANS_DAC != 0)
|
||||
@@ -32,7 +30,7 @@ void ConfigAudioPorts(
|
||||
in port p_bclk,
|
||||
#endif
|
||||
#endif
|
||||
unsigned int divide, unsigned curSamFreq)
|
||||
in port p_mclk_in, clock clk_audio_bclk, unsigned int divide, unsigned curSamFreq)
|
||||
{
|
||||
#if (I2S_CHANS_DAC != 0) || (I2S_CHANS_ADC != 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user