forked from PAWPAW-Mirror/lib_xua
Merge branch 'develop' of git@github.com:mbanth/lib_xua.git into feature/configurable_hid
This commit is contained in:
@@ -4,7 +4,8 @@ TARGET = xk-audio-216-mc.xn
|
||||
|
||||
# The flags passed to xcc when building the application
|
||||
XCC_FLAGS = -fcomment-asm -Xmapper --map -Xmapper MAPFILE -O3 -report -save-temps \
|
||||
-g -Wno-unused-function -Wno-timing -DXUD_SERIES_SUPPORT=XUD_X200_SERIES -DUSB_TILE=tile[1] -fxscope
|
||||
-g -Wno-unused-function -Wno-timing -DXUD_SERIES_SUPPORT=XUD_X200_SERIES \
|
||||
-DXUD_CORE_CLOCK=600 -DUSB_TILE=tile[1] -fxscope
|
||||
|
||||
#-DSDA_HIGH=2 -DSCL_HIGH=1 -fxscope
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ int main()
|
||||
/* Low level USB device layer core */
|
||||
on tile[1]: XUD_Main(c_ep_out, 2, c_ep_in, 2,
|
||||
c_sof, epTypeTableOut, epTypeTableIn,
|
||||
null, null, -1 ,
|
||||
XUD_SPEED_HS, XUD_PWR_SELF);
|
||||
|
||||
/* Endpoint 0 core from lib_xua */
|
||||
|
||||
@@ -4,8 +4,8 @@ TARGET = xk-audio-216-mc.xn
|
||||
|
||||
# The flags passed to xcc when building the application
|
||||
XCC_FLAGS = -fcomment-asm -Xmapper --map -Xmapper MAPFILE -O3 -report -save-temps \
|
||||
-g -Wno-unused-function -Wno-timing -DXUD_SERIES_SUPPORT=XUD_X200_SERIES -DUSB_TILE=tile[1] \
|
||||
-DSDA_HIGH=2 -DSCL_HIGH=1 -fxscope
|
||||
-g -Wno-unused-function -Wno-timing -DXUD_SERIES_SUPPORT=XUD_X200_SERIES \
|
||||
-DXUD_CORE_CLOCK=600 -DUSB_TILE=tile[1] -DSDA_HIGH=2 -DSCL_HIGH=1 -fxscope
|
||||
|
||||
# The USED_MODULES variable lists other module used by the application. These
|
||||
# modules will extend the SOURCE_DIRS, INCLUDE_DIRS and LIB_DIRS variables.
|
||||
|
||||
@@ -61,7 +61,7 @@ int main()
|
||||
par
|
||||
{
|
||||
/* Low level USB device layer core */
|
||||
on tile[1]: XUD_Main(c_ep_out, 2, c_ep_in, 2, c_sof, epTypeTableOut, epTypeTableIn, null, null, -1, XUD_SPEED_HS, XUD_PWR_SELF);
|
||||
on tile[1]: XUD_Main(c_ep_out, 2, c_ep_in, 2, c_sof, epTypeTableOut, epTypeTableIn, XUD_SPEED_HS, XUD_PWR_SELF);
|
||||
|
||||
/* Endpoint 0 core from lib_xua */
|
||||
/* Note, since we are not using many features we pass in null for quite a few params.. */
|
||||
|
||||
@@ -22,7 +22,6 @@ out port p_gpio = on tile[0]:XS1_PORT_8C;
|
||||
void AudioHwConfig(unsigned samFreq, unsigned mClk, unsigned dsdMode,
|
||||
unsigned sampRes_DAC, unsigned sampRes_ADC)
|
||||
{
|
||||
unsigned char data[1] = {0};
|
||||
unsigned char gpioVal = 0;
|
||||
|
||||
/* Set master clock select appropriately and put ADC and DAC into reset */
|
||||
|
||||
@@ -4,8 +4,8 @@ TARGET = mic_array_ref.xn
|
||||
|
||||
# The flags passed to xcc when building the application
|
||||
XCC_FLAGS = -fcomment-asm -Xmapper --map -Xmapper MAPFILE -O3 -report -save-temps \
|
||||
-g -Wno-unused-function -Wno-timing -DXUD_SERIES_SUPPORT=XUD_X200_SERIES -DUSB_TILE=tile[1] \
|
||||
-DSDA_HIGH=2 -DSCL_HIGH=1 -fxscope
|
||||
-g -Wno-unused-function -Wno-timing -DXUD_SERIES_SUPPORT=XUD_X200_SERIES \
|
||||
-DXUD_CORE_CLOCK=600 -DUSB_TILE=tile[1] -DSDA_HIGH=2 -DSCL_HIGH=1 -fxscope
|
||||
|
||||
# The USED_MODULES variable lists other module used by the application. These
|
||||
# modules will extend the SOURCE_DIRS, INCLUDE_DIRS and LIB_DIRS variables.
|
||||
|
||||
@@ -65,7 +65,7 @@ int main()
|
||||
par
|
||||
{
|
||||
/* Low level USB device layer core */
|
||||
on tile[1]: XUD_Main(c_ep_out, 2, c_ep_in, 2, c_sof, epTypeTableOut, epTypeTableIn, null, null, -1, XUD_SPEED_HS, XUD_PWR_BUS);
|
||||
on tile[1]: XUD_Main(c_ep_out, 2, c_ep_in, 2, c_sof, epTypeTableOut, epTypeTableIn, XUD_SPEED_HS, XUD_PWR_BUS);
|
||||
|
||||
/* Endpoint 0 core from lib_xua */
|
||||
/* Note, since we are not using many features we pass in null for quite a few params.. */
|
||||
|
||||
@@ -3,7 +3,7 @@ TARGET = xk-audio-216-mc.xn
|
||||
USED_MODULES = lib_xua \
|
||||
module_i2c_shared module_i2c_single_port lib_logging
|
||||
|
||||
BUILD_FLAGS = -O0 -g -lflash -DXUD_SERIES_SUPPORT=4 -fxscope -save-temps -march=xs2a -DUSB_TILE=tile[1]
|
||||
BUILD_FLAGS = -O0 -g -lflash -DXUD_SERIES_SUPPORT=4 -DXUD_CORE_CLOCK=600 -fxscope -save-temps -march=xs2a -DUSB_TILE=tile[1]
|
||||
|
||||
BUILD_FLAGS_i2s_master_2in_2out_48khz = $(BUILD_FLAGS) \
|
||||
-D ADAT_RX=0 -D ADAT_TX=0 -D SPDIF_RX=0 -D SPDIF_TX=0 -D MIDI=0 \
|
||||
|
||||
@@ -40,7 +40,6 @@ INCLUDE_DIRS = $(EXPORT_INCLUDE_DIRS) \
|
||||
src/core/pdm_mics \
|
||||
src/core/ports \
|
||||
src/core/support \
|
||||
src/core/support/powersave \
|
||||
src/core/user \
|
||||
src/core/user/audiostream \
|
||||
src/core/user/hid \
|
||||
@@ -58,7 +57,6 @@ SOURCE_DIRS = src/core \
|
||||
src/core/pdm_mics \
|
||||
src/core/ports \
|
||||
src/core/support \
|
||||
src/core/support/powersave \
|
||||
src/core/user/audiostream \
|
||||
src/core/user/hostactive \
|
||||
src/core/xuduser \
|
||||
|
||||
@@ -187,20 +187,20 @@ on tile[XUD_TILE] : clock clk_spd_rx = CLKBLK_SPDIF_RX;
|
||||
#endif
|
||||
|
||||
#if (XUA_NUM_PDM_MICS > 0)
|
||||
in port p_pdm_clk = PORT_PDM_CLK;
|
||||
in port p_pdm_clk = PORT_PDM_CLK;
|
||||
|
||||
in buffered port:32 p_pdm_mics = PORT_PDM_DATA;
|
||||
in buffered port:32 p_pdm_mics = PORT_PDM_DATA;
|
||||
#if (PDM_TILE != AUDIO_IO_TILE)
|
||||
/* If Mics and I2S are not the same tile we need a separate MCLK port */
|
||||
in port p_pdm_mclk = PORT_PDM_MCLK;
|
||||
in port p_pdm_mclk = PORT_PDM_MCLK;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if(XUD_SERIES_SUPPORT == XUD_L_SERIES) && (ADAT_RX)
|
||||
#if (defined(__XS2A__) && (ADAT_RX))
|
||||
/* Cannot use default clock (CLKBLK_REF) for ADAT RX since it is tied to the
|
||||
60MHz USB clock on G/L series parts. */
|
||||
60MHz USB clock on XS2 processors. */
|
||||
on tile[XUD_TILE] : clock clk_adat_rx = CLKBLK_ADAT_RX;
|
||||
#endif
|
||||
|
||||
@@ -212,15 +212,14 @@ on tile[XUD_TILE] : clock clk_audio_mclk_usb = CLKBLK_MCLK;
|
||||
on tile[XUD_TILE] : in port p_mclk_in_usb = PORT_MCLK_IN_USB;
|
||||
#endif
|
||||
|
||||
on tile[AUDIO_IO_TILE] : clock clk_audio_bclk = CLKBLK_I2S_BIT; /* Bit clock */
|
||||
on tile[AUDIO_IO_TILE] : clock clk_audio_bclk = CLKBLK_I2S_BIT; /* Bit clock */
|
||||
|
||||
|
||||
/* L/G Series needs a port to use for USB reset */
|
||||
#if (XUD_SERIES_SUPPORT != XUD_U_SERIES) && defined(PORT_USB_RESET)
|
||||
#if ((defined(__XS2A__) || defined (__XS3A__)) && defined(PORT_USB_RESET))
|
||||
/* This define is checked since it could be on a shift reg or similar */
|
||||
on tile[XUD_TILE] : out port p_usb_rst = PORT_USB_RESET;
|
||||
#else
|
||||
/* Reset port not required for U series due to built in Phy */
|
||||
#define p_usb_rst null
|
||||
#endif
|
||||
|
||||
@@ -726,8 +725,8 @@ int main()
|
||||
{
|
||||
set_thread_fast_mode_on();
|
||||
|
||||
#if(XUD_SERIES_SUPPORT == XUD_L_SERIES)
|
||||
/* Can't use REF clock on L-series as this is usb clock */
|
||||
#if defined(__XS2A__)
|
||||
/* Can't use REF clock as this is usb clock */
|
||||
set_port_clock(p_adat_rx, clk_adat_rx);
|
||||
start_clock(clk_adat_rx);
|
||||
#endif
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2013-2021 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#ifndef ARCH_U_POWER_SAVING_
|
||||
#define ARCH_U_POWER_SAVING_
|
||||
|
||||
/* Sets the voltage down by VOLTAGE_REDUCTION_mV (voltage is set to 10 * X + 600 mV),
|
||||
* and adjusts other features to save power
|
||||
*/
|
||||
void archU_powerSaving();
|
||||
|
||||
#endif /*ARCH_U_POWER_SAVING_*/
|
||||
@@ -1,70 +0,0 @@
|
||||
// Copyright 2013-2021 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
#if (XUD_SERIES_SUPPORT==1)
|
||||
#include "archU_powerSaving.h"
|
||||
#include <xs1.h>
|
||||
#include <xs1_l_registers.h>
|
||||
#include <xs1_su_registers.h>
|
||||
#include <platform.h>
|
||||
|
||||
#if (XCC_MAJOR_VERSION >= 1300)
|
||||
#include <hwtimer.h>
|
||||
#else
|
||||
#define hwtimer_t timer
|
||||
#endif
|
||||
|
||||
#ifndef VOLTAGE_REDUCTION_mV
|
||||
#define VOLTAGE_REDUCTION_mV 20
|
||||
#endif
|
||||
|
||||
unsigned get_tile_id(tileref t); // Required for use with 12.0 tools. get_tile_id() available in xs1.h with 13.0 tools.
|
||||
|
||||
#define ARCH_U_VOLTAGE_FIRST_STEP 39 // First step down from 1V
|
||||
#define ARCH_U_SSWITCH_PRESCALER 8 // Sswitch down to 1/8 clk freq
|
||||
|
||||
void archU_powerSaving()
|
||||
{
|
||||
if (get_local_tile_id() == get_tile_id(tile[0]))
|
||||
{
|
||||
unsigned writeval[1];
|
||||
unsigned char writevalc[1];
|
||||
|
||||
// Reduce the VDDCORE voltage level
|
||||
for (unsigned count=0; count < (VOLTAGE_REDUCTION_mV/10); count++)
|
||||
{
|
||||
hwtimer_t t;
|
||||
int time;
|
||||
|
||||
writeval[0] = (ARCH_U_VOLTAGE_FIRST_STEP - count);
|
||||
write_periph_32(usb_tile, XS1_SU_PER_PWR_CHANEND_NUM, XS1_SU_PER_PWR_VOUT1_LVL_NUM, 1, writeval);
|
||||
|
||||
t :> time;
|
||||
time += (1 * PLATFORM_REFERENCE_MHZ); // Wait 1us per step
|
||||
t when timerafter(time) :> void;
|
||||
}
|
||||
|
||||
// Set switch prescaler down
|
||||
write_node_config_reg(tile[0], XS1_SSWITCH_CLK_DIVIDER_NUM, (ARCH_U_SSWITCH_PRESCALER - 1)); // PLL clk will be divided by value + 1
|
||||
|
||||
// Both DC-DCs in PWM mode, I/O and PLL supply on, Analogue & core on
|
||||
writeval[0] = XS1_SU_PWR_VOUT1_EN_SET(0, 1);
|
||||
writeval[0] = XS1_SU_PWR_VOUT2_EN_SET(writeval[0], 1);
|
||||
writeval[0] = XS1_SU_PWR_VOUT5_EN_SET(writeval[0], 1);
|
||||
writeval[0] = XS1_SU_PWR_VOUT6_EN_SET(writeval[0], 1);
|
||||
write_periph_32(usb_tile, XS1_SU_PER_PWR_CHANEND_NUM, XS1_SU_PER_PWR_STATE_AWAKE_NUM, 1, writeval);
|
||||
|
||||
// USB suspend off, voltage adjustable, sleep clock 32KHz
|
||||
writeval[0] = XS1_SU_PWR_USB_PD_EN_SET(0, 1);
|
||||
writeval[0] = XS1_SU_PWR_RST_VOUT_LVL_SET(writeval[0], 1);
|
||||
writeval[0] = XS1_SU_PWR_LD_AWAKE_SET(writeval[0], 1);
|
||||
write_periph_32(usb_tile, XS1_SU_PER_PWR_CHANEND_NUM, XS1_SU_PER_PWR_MISC_CTRL_NUM, 1, writeval);
|
||||
|
||||
// Turn off on-chip silicon oscillator (20MHz or 32KHz)
|
||||
writevalc[0] = XS1_SU_ON_SI_OSC_EN_SET(0, 1);
|
||||
writevalc[0] = XS1_SU_ON_SI_OSC_SLOW_SET(writevalc[0], 1);
|
||||
write_periph_8(usb_tile, XS1_SU_PER_OSC_CHANEND_NUM, XS1_SU_PER_OSC_ON_SI_CTRL_NUM, 1, writevalc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,18 +5,9 @@
|
||||
#include <print.h>
|
||||
#include <xs1_su.h>
|
||||
|
||||
#define XS1_SU_PERIPH_USB_ID 0x1
|
||||
|
||||
//Normally we would enumerate the XUD_SERIES_SUPPORT possibilities using defines in
|
||||
//xud.h but we have hard coded them to remove dependancy of sc_xud
|
||||
|
||||
#if (XUD_SERIES_SUPPORT == 4)
|
||||
#include "xs2_su_registers.h"
|
||||
#define XS2_SU_PERIPH_USB_ID 0x1
|
||||
#define PLL_MASK 0x3FFFFFFF
|
||||
#else
|
||||
#define PLL_MASK 0xFFFFFFFF
|
||||
#endif
|
||||
|
||||
/* Note, this function is prototyped in xs1.h only from 13 tools onwards */
|
||||
unsigned get_tile_id(tileref);
|
||||
@@ -38,25 +29,17 @@ static void reset_tile(unsigned const tileId)
|
||||
*/
|
||||
void device_reboot(void)
|
||||
{
|
||||
#if (XUD_SERIES_SUPPORT == 1)
|
||||
/* Disconnect from bus */
|
||||
unsigned data[] = {4};
|
||||
write_periph_32(usb_tile, XS1_SU_PERIPH_USB_ID, XS1_SU_PER_UIFM_FUNC_CONTROL_NUM, 1, data);
|
||||
|
||||
/* Ideally we would reset SU1 here but then we loose power to the xcore and therefore the DFU flag */
|
||||
/* Disable USB and issue reset to xcore only - not analogue chip */
|
||||
write_node_config_reg(usb_tile, XS1_SU_CFG_RST_MISC_NUM,0b10);
|
||||
#else
|
||||
|
||||
unsigned int localTileId = get_local_tile_id();
|
||||
unsigned int tileId;
|
||||
unsigned int tileArrayLength;
|
||||
unsigned int localTileNum;
|
||||
|
||||
#if (XUD_SERIES_SUPPORT == 4)
|
||||
#if defined(__XS2A__)
|
||||
/* Disconnect from bus */
|
||||
unsigned data[] = {4};
|
||||
write_periph_32(usb_tile, XS2_SU_PERIPH_USB_ID, XS1_GLX_PER_UIFM_FUNC_CONTROL_NUM, 1, data);
|
||||
#elif defined(__XS3A__)
|
||||
#warning Assuming that tile reset also resets USB in XS3 architectures
|
||||
#endif
|
||||
|
||||
tileArrayLength = sizeof(tile)/sizeof(tileref);
|
||||
@@ -75,24 +58,14 @@ void device_reboot(void)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__XS2A__) || defined(__XS3A__)
|
||||
/* Reset all even tiles, starting from the remote ones */
|
||||
for(int tileNum = tileArrayLength-2; tileNum>=0; tileNum-=2)
|
||||
#else
|
||||
/* Reset all tiles, starting from the remote ones */
|
||||
for(int tileNum = tileArrayLength-1; tileNum>=0; tileNum--)
|
||||
#endif
|
||||
{
|
||||
/* Cannot cast tileref to unsigned! */
|
||||
tileId = get_tile_id(tile[tileNum]);
|
||||
|
||||
/* Do not reboot local tile (or tiles residing on the same node) yet */
|
||||
#if defined(__XS2A__) || defined(__XS3A__)
|
||||
if((localTileNum | 1) != (tileNum | 1))
|
||||
|
||||
#else
|
||||
if(localTileNum != tileNum)
|
||||
#endif
|
||||
{
|
||||
reset_tile(tileId);
|
||||
}
|
||||
@@ -100,7 +73,6 @@ void device_reboot(void)
|
||||
|
||||
/* Finally reboot the node this tile resides on */
|
||||
reset_tile(localTileId);
|
||||
#endif
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
@@ -11,13 +11,11 @@
|
||||
#include "flash_interface.h"
|
||||
#include "dfu_interface.h"
|
||||
|
||||
#if (XUD_SERIES_SUPPORT==4)
|
||||
/* xCORE-200 */
|
||||
#if defined(__XS3A__)
|
||||
#define FLAG_ADDRESS 0xfffcc
|
||||
#elif defined(__XS2A__)
|
||||
/* Note range 0x7FFC8 - 0x7FFFF guarenteed to be untouched by tools */
|
||||
#define FLAG_ADDRESS 0x7ffcc
|
||||
#else
|
||||
/* Note range 0x1FFC8 - 0x1FFFF guarenteed to be untouched by tools */
|
||||
#define FLAG_ADDRESS 0x1ffcc
|
||||
#endif
|
||||
|
||||
/* Store Flag to fixed address */
|
||||
|
||||
@@ -13,7 +13,7 @@ in port p_mclk_in = XS1_PORT_1D;
|
||||
|
||||
/* Clock-block declarations */
|
||||
clock clk_audio_bclk = on tile[0]: XS1_CLKBLK_1; /* Bit clock */
|
||||
clock clk_audio_mclk = on tile[0]: XS1_CLKBLK_3; /* Master clock */
|
||||
clock clk_audio_mclk = on tile[0]: XS1_CLKBLK_4; /* Master clock */
|
||||
|
||||
// Supply missing but unused function
|
||||
void AudioHwConfig(unsigned samFreq, unsigned mClk, unsigned dsdMode, unsigned sampRes_DAC, unsigned sampRes_ADC)
|
||||
|
||||
Reference in New Issue
Block a user