diff --git a/README.md b/README.md
index d926d4c..a9b7689 100644
--- a/README.md
+++ b/README.md
@@ -13,9 +13,18 @@ A variant which bypasses the mic-pipeline. Hence, the raw mic signal is streamed
Firmware for debugging purposes only. It runs on the XCORE.AI evaluation board.
-**satellite1_usb_debug**
-
-Firmware for debugging purposes only. It enables basic logging on the satellite1 via usb-cdc.
+**satellite1_usb_firmware_PIPELINE_CONFIGURATION**
+
+PIPELINE_CONFIGURATION:
+- aec__vnr_ic__ns__agc
+- aec__vnr_ic__ns
+- aec__vnr_ic
+- vnr_ic__ns
+- vnr_ic
+- ns
+
+Work in progress firmware, currently for debugging purposes only.
+It configures the Satellite1 as an USB-Audio device and enables basic logging on the satellite1 via usb-cdc.
## Firmware Files
diff --git a/satellite-xmos-firmware/audio_pipelines/reference/fixed_delay/audio_pipeline_t0.c b/satellite-xmos-firmware/audio_pipelines/reference/fixed_delay/audio_pipeline_t0.c
index 12f936c..61e6aaa 100644
--- a/satellite-xmos-firmware/audio_pipelines/reference/fixed_delay/audio_pipeline_t0.c
+++ b/satellite-xmos-firmware/audio_pipelines/reference/fixed_delay/audio_pipeline_t0.c
@@ -92,8 +92,10 @@ static void stage_vnr_and_ic(frame_data_t *frame_data)
/* Intentionally ignoring comms ch from here on out */
memcpy(frame_data->samples[0], ic_output, appconfAUDIO_PIPELINE_FRAME_ADVANCE * sizeof(int32_t));
+#if appconfAUDIO_PIPELINE_STORE_IC_AUDIO
memcpy(frame_data->aec_reference_audio_samples[0], ic_output, appconfAUDIO_PIPELINE_FRAME_ADVANCE * sizeof(int32_t)); // Store the interference cancelled audio in the first reference channel
#endif
+#endif
}
static void stage_ns(frame_data_t *frame_data)
@@ -107,8 +109,10 @@ static void stage_ns(frame_data_t *frame_data)
ns_output,
frame_data->samples[0]);
memcpy(frame_data->samples[0], ns_output, appconfAUDIO_PIPELINE_FRAME_ADVANCE * sizeof(int32_t));
+#if appconfAUDIO_PIPELINE_STORE_NS_AUDIO
memcpy(frame_data->aec_reference_audio_samples[1], ns_output, appconfAUDIO_PIPELINE_FRAME_ADVANCE * sizeof(int32_t)); // Store NS audio in the second reference channel
#endif
+#endif
}
static void stage_agc(frame_data_t *frame_data)
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1/SATELLITE1_USB.cmake b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/SATELLITE1-USB.cmake
similarity index 54%
rename from satellite-xmos-firmware/bsp_config/SATELLITE1/SATELLITE1_USB.cmake
rename to satellite-xmos-firmware/bsp_config/SATELLITE1-USB/SATELLITE1-USB.cmake
index 9e6f37e..403eb4e 100644
--- a/satellite-xmos-firmware/bsp_config/SATELLITE1/SATELLITE1_USB.cmake
+++ b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/SATELLITE1-USB.cmake
@@ -1,39 +1,48 @@
## Create custom board targets for application
-add_library(sln_voice_app_ffva_board_support_satellite1 INTERFACE)
-target_sources(sln_voice_app_ffva_board_support_satellite1
+add_library(fph_ffva_board_support_satellite1_usb INTERFACE)
+target_sources(fph_ffva_board_support_satellite1_usb
INTERFACE
- ${CMAKE_CURRENT_LIST_DIR}/platform/dac_port.c
${CMAKE_CURRENT_LIST_DIR}/platform/app_pll_ctrl.c
${CMAKE_CURRENT_LIST_DIR}/platform/driver_instances.c
${CMAKE_CURRENT_LIST_DIR}/platform/platform_init.c
${CMAKE_CURRENT_LIST_DIR}/platform/platform_start.c
)
-target_include_directories(sln_voice_app_ffva_board_support_satellite1
+target_include_directories(fph_ffva_board_support_satellite1_usb
INTERFACE
${CMAKE_CURRENT_LIST_DIR}
)
-target_link_libraries(sln_voice_app_ffva_board_support_satellite1
+target_link_libraries(fph_ffva_board_support_satellite1_usb
INTERFACE
core::general
rtos::freertos
rtos::drivers::general
- #rtos::drivers::audio
- rtos::drivers::mic_array
- fph::i2s_sync
rtos::drivers::usb
rtos::drivers::dfu_image
- sln_voice::app::ffva::dac::aic3204
+ fph::rtos_mic_array
+ fph::i2s_sync
+ fph::rtos_ws2812
)
-target_compile_options(sln_voice_app_ffva_board_support_satellite1
+target_compile_options(fph_ffva_board_support_satellite1_usb
INTERFACE
- ${CMAKE_CURRENT_LIST_DIR}/SATTELITE1.xn
+ ${CMAKE_CURRENT_LIST_DIR}/SATELLITE1.xn
)
-target_link_options(sln_voice_app_ffva_board_support_satellite1
+target_link_options(fph_ffva_board_support_satellite1_usb
INTERFACE
- ${CMAKE_CURRENT_LIST_DIR}/SATTELITE1.xn
+ ${CMAKE_CURRENT_LIST_DIR}/SATELLITE1.xn
)
-target_compile_definitions(sln_voice_app_ffva_board_support_satellite1
+
+# MICS:
+# North: 0 (pin 0 falling edge)
+# South: 1 (pin 1 falling edge)
+# East: 4 (pin 0 rising edge )
+# West: 5 (pin 1 rising edge )
+# pins 2 & 3 are not used
+
+# use East as first and West as second mic
+set(MIC_MAPPING "4, 5")
+
+target_compile_definitions(fph_ffva_board_support_satellite1_usb
INTERFACE
XCOREAI_EXPLORER=1
PLATFORM_SUPPORTS_TILE_0=1
@@ -46,7 +55,11 @@ target_compile_definitions(sln_voice_app_ffva_board_support_satellite1
MIC_ARRAY_CONFIG_MCLK_FREQ=24576000
MIC_ARRAY_CONFIG_PDM_FREQ=3072000
MIC_ARRAY_CONFIG_SAMPLES_PER_FRAME=240
+ MIC_ARRAY_CONFIG_USE_DDR=1
+ MIC_ARRAY_CONFIG_MIC_INPUT=8
MIC_ARRAY_CONFIG_MIC_COUNT=2
+ MIC_ARRAY_CONFIG_INPUT_MAPPING={${MIC_MAPPING}}
+
MIC_ARRAY_CONFIG_CLOCK_BLOCK_A=XS1_CLKBLK_1
MIC_ARRAY_CONFIG_CLOCK_BLOCK_B=XS1_CLKBLK_2
MIC_ARRAY_CONFIG_PORT_MCLK=PORT_MCLK_IN
@@ -55,4 +68,4 @@ target_compile_definitions(sln_voice_app_ffva_board_support_satellite1
)
## Create an alias
-add_library(sln_voice::app::ffva::satellite1 ALIAS sln_voice_app_ffva_board_support_satellite1)
+add_library(fph::ffva::satellite1-usb ALIAS fph_ffva_board_support_satellite1_usb)
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/SATELLITE1.xn b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/SATELLITE1.xn
new file mode 100644
index 0000000..eb6823c
--- /dev/null
+++ b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/SATELLITE1.xn
@@ -0,0 +1,84 @@
+
+
+ Board
+ FutureProofHomes Satellite1
+
+
+ tileref tile[2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/app_pll_ctrl.c b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/app_pll_ctrl.c
new file mode 100644
index 0000000..4d963ef
--- /dev/null
+++ b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/app_pll_ctrl.c
@@ -0,0 +1,51 @@
+// Copyright 2022-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+/* System headers */
+#include
+#include
+#include
+#include
+
+/* App headers */
+#include "platform/app_pll_ctrl.h"
+
+void app_pll_set_numerator(int numerator)
+{
+ const unsigned tileid = get_local_tile_id();
+ uint32_t fracval = APP_PLL_FRAC_NOM & 0xFFFF00FF;
+ uint32_t f;
+
+ if (numerator > 255) {
+ f = 255;
+ } else if (numerator < 0) {
+ f = 0;
+ } else {
+ f = numerator;
+ }
+
+ fracval |= (f << 8);
+ write_sswitch_reg_no_ack(tileid, XS1_SSWITCH_SS_APP_PLL_FRAC_N_DIVIDER_NUM, fracval);
+}
+
+void app_pll_init(void)
+{
+ unsigned tileid = get_local_tile_id();
+
+ const unsigned APP_PLL_DISABLE = 0x0201FF04;
+ const unsigned APP_PLL_DIV_0 = 0x80000004;
+
+ write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_CTL_NUM, APP_PLL_DISABLE);
+
+ hwtimer_t tmr = hwtimer_alloc();
+ {
+ xassert(tmr != 0);
+ hwtimer_delay(tmr, 100000); // 1ms with 100 MHz timer tick
+ }
+ hwtimer_free(tmr);
+
+ write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_CTL_NUM, APP_PLL_CTL_VAL);
+ write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_CTL_NUM, APP_PLL_CTL_VAL);
+ write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_FRAC_N_DIVIDER_NUM, APP_PLL_FRAC_NOM);
+ write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_CLK_DIVIDER_NUM, APP_PLL_DIV_0);
+}
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/app_pll_ctrl.h b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/app_pll_ctrl.h
new file mode 100644
index 0000000..b4f3e7c
--- /dev/null
+++ b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/app_pll_ctrl.h
@@ -0,0 +1,19 @@
+// Copyright 2022-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#ifndef APP_PLL_CTRL_H_
+#define APP_PLL_CTRL_H_
+
+#include "platform_conf.h"
+
+#if (MIC_ARRAY_CONFIG_MCLK_FREQ != 24576000)
+#error PLL values only valid if MIC_ARRAY_CONFIG_MCLK_FREQ == 24576000
+#endif
+
+#define APP_PLL_CTL_VAL 0x0A019803 // Valid for all fractional values
+#define APP_PLL_FRAC_NOM 0x800095F9 // 24.576000 MHz
+
+void app_pll_set_numerator(int numerator);
+void app_pll_init(void);
+
+#endif /* APP_PLL_CTRL_H_ */
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/driver_instances.c b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/driver_instances.c
new file mode 100644
index 0000000..c947e0d
--- /dev/null
+++ b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/driver_instances.c
@@ -0,0 +1,40 @@
+// Copyright 2022-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#include "platform/driver_instances.h"
+
+static rtos_intertile_t intertile_ctx_s;
+rtos_intertile_t *intertile_ctx = &intertile_ctx_s;
+
+static rtos_intertile_t intertile_usb_audio_ctx_s;
+rtos_intertile_t *intertile_usb_audio_ctx = &intertile_usb_audio_ctx_s;
+
+static rtos_qspi_flash_t qspi_flash_ctx_s;
+rtos_qspi_flash_t *qspi_flash_ctx = &qspi_flash_ctx_s;
+
+static rtos_gpio_t gpio_ctx_t0_s;
+rtos_gpio_t *gpio_ctx_t0 = &gpio_ctx_t0_s;
+
+static rtos_gpio_t gpio_ctx_t1_s;
+rtos_gpio_t *gpio_ctx_t1 = &gpio_ctx_t1_s;
+
+static rtos_mic_array_t mic_array_ctx_s;
+rtos_mic_array_t *mic_array_ctx = &mic_array_ctx_s;
+
+static rtos_i2s_t i2s_ctx_s;
+rtos_i2s_t *i2s_ctx = &i2s_ctx_s;
+
+static rtos_spi_slave_t spi_slave_ctx_s;
+rtos_spi_slave_t *spi_slave_ctx = &spi_slave_ctx_s;
+
+static rtos_dfu_image_t dfu_image_ctx_s;
+rtos_dfu_image_t *dfu_image_ctx = &dfu_image_ctx_s;
+
+static rtos_ws2812_t ws2812_ctx_s;
+rtos_ws2812_t *ws2812_ctx = &ws2812_ctx_s;
+
+static device_control_t device_control_spi_ctx_s;
+device_control_t *device_control_spi_ctx = &device_control_spi_ctx_s;
+
+static device_control_gpio_ctx_t device_control_gpio_ctx_s;
+device_control_gpio_ctx_t *device_control_gpio_ctx = &device_control_gpio_ctx_s;
\ No newline at end of file
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/driver_instances.h b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/driver_instances.h
new file mode 100644
index 0000000..2267c0c
--- /dev/null
+++ b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/driver_instances.h
@@ -0,0 +1,65 @@
+// Copyright 2022-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#ifndef DRIVER_INSTANCES_H_
+#define DRIVER_INSTANCES_H_
+
+#include "rtos_gpio.h"
+#include "rtos_intertile.h"
+#include "rtos_i2s.h"
+#include "rtos_mic_array.h"
+#include "rtos_qspi_flash.h"
+#include "rtos_dfu_image.h"
+#include "rtos_spi_slave.h"
+
+#include
+#include "rtos_ws2812.h"
+#include "device_control.h"
+#include "gpio/gpio_servicer.h"
+
+/* Tile specifiers */
+#define FLASH_TILE_NO 0
+#define SPI_CLIENT_TILE_NO 0
+
+#define MICARRAY_TILE_NO 1
+#define I2S_TILE_NO 1
+#define SPEAKER_PIPELINE_TILE_NO I2S_TILE_NO
+#define WS2812_TILE_NO 1
+
+
+/** TILE 0 Clock Blocks */
+#define FLASH_CLKBLK XS1_CLKBLK_1
+#define MCLK_CLKBLK XS1_CLKBLK_2
+#define SPI_CLKBLK XS1_CLKBLK_3
+#define XUD_CLKBLK_1 XS1_CLKBLK_4 /* Reserved for lib_xud */
+#define XUD_CLKBLK_2 XS1_CLKBLK_5 /* Reserved for lib_xud */
+
+/** TILE 1 Clock Blocks */
+#define PDM_CLKBLK_1 XS1_CLKBLK_1
+#define PDM_CLKBLK_2 XS1_CLKBLK_2
+#define I2S_CLKBLK XS1_CLKBLK_3
+// #define UNUSED_CLKBLK XS1_CLKBLK_4
+// #define UNUSED_CLKBLK XS1_CLKBLK_5
+
+/* Port definitions */
+#define PORT_MCLK PORT_MCLK_IN
+
+/*LED RING*/
+#define LED_RING_NUM_LEDS 24
+#define LED_RING_PORT_PIN 3
+
+extern rtos_intertile_t *intertile_ctx;
+extern rtos_intertile_t *intertile_usb_audio_ctx;
+extern rtos_qspi_flash_t *qspi_flash_ctx;
+extern rtos_gpio_t *gpio_ctx_t0;
+extern rtos_gpio_t *gpio_ctx_t1;
+extern rtos_mic_array_t *mic_array_ctx;
+extern rtos_spi_slave_t *spi_slave_ctx;
+extern rtos_i2s_t *i2s_ctx;
+extern rtos_dfu_image_t *dfu_image_ctx;
+extern rtos_ws2812_t *ws2812_ctx;
+
+extern device_control_t *device_control_spi_ctx;
+extern device_control_gpio_ctx_t *device_control_gpio_ctx;
+
+#endif /* DRIVER_INSTANCES_H_ */
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_conf.h b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_conf.h
new file mode 100644
index 0000000..c631329
--- /dev/null
+++ b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_conf.h
@@ -0,0 +1,198 @@
+// Copyright 2022-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#ifndef PLATFORM_CONF_H_
+#define PLATFORM_CONF_H_
+
+/*
+ * Board support package for FPH Satellite1
+ */
+
+#if __has_include("app_conf.h")
+#include "app_conf.h"
+#endif /* __has_include("app_conf.h") */
+
+/*****************************************/
+/* Intertile Communication Configuration */
+/*****************************************/
+
+#ifndef appconfGPIO_RPC_PRIORITY
+#define appconfGPIO_RPC_PRIORITY (configMAX_PRIORITIES/2)
+#endif /* appconfGPIO_RPC_PRIORITY */
+
+#ifndef appconfMIC_ARRAY_RPC_PORT
+#define appconfMIC_ARRAY_RPC_PORT 13
+#endif /* appconfMIC_ARRAY_RPC_PORT */
+
+#ifndef appconfMIC_ARRAY_RPC_PRIORITY
+#define appconfMIC_ARRAY_RPC_PRIORITY (configMAX_PRIORITIES-2)
+#endif /* appconfMIC_ARRAY_RPC_PRIORITY */
+
+#ifndef appconfI2S_RPC_PORT
+#define appconfI2S_RPC_PORT 14
+#endif /* appconfI2S_RPC_PORT */
+
+#ifndef appconfI2S_RPC_PRIORITY
+#define appconfI2S_RPC_PRIORITY (configMAX_PRIORITIES-2)
+#endif /* appconfI2S_RPC_PRIORITY */
+
+#ifndef appconfSPI_DEV_CTRL_PORT
+#define appconfSPI_DEV_CTRL_PORT 15
+#endif /* appconfSPI_DEV_CTRL_PORT */
+
+#ifndef appconfSPI_DEV_CTRL_PRIORITY
+#define appconfSPI_DEV_CTRL_PRIORITY (configMAX_PRIORITIES/2)
+#endif /* appconfSPI_DEV_CTRL_PRIORITY */
+
+#ifndef appconfUSB_CDC_PORT
+#define appconfUSB_CDC_PORT 16
+#endif /* appconfUSP_CDC_PORT */
+
+#ifndef appconfUSB_CDC_PRIORITY
+#define appconfUSB_CDC_PRIORITY (configMAX_PRIORITIES/2)
+#endif /* appconfSPI_DEV_CTRL_PRIORITY */
+
+
+
+/*****************************************/
+/* I/O and interrupt cores for Tile 0 */
+/*****************************************/
+#ifndef appconfSPI_IO_CORE
+#define appconfSPI_IO_CORE 1 /* Must be kept off core 0 with the RTOS tick ISR */
+#endif /* appconfSPI_IO_CORE */
+
+#ifndef appconfSPI_INTERRUPT_CORE
+#define appconfSPI_INTERRUPT_CORE 2 /* Must be kept off I/O cores. */
+#endif /* appconfSPI_INTERRUPT_CORE */
+
+
+
+
+/*****************************************/
+/* I/O and interrupt cores for Tile 1 */
+/*****************************************/
+#ifndef appconfPDM_MIC_IO_CORE
+#define appconfPDM_MIC_IO_CORE 1 /* Must be kept off I/O cores. Must be kept off core 0 with the RTOS tick ISR */
+#endif /* appconfPDM_MIC_IO_CORE */
+
+#ifndef appconfI2S_IO_CORE
+#define appconfI2S_IO_CORE 2 /* Must be kept off core 0 with the RTOS tick ISR */
+#endif /* appconfI2S_IO_CORE */
+
+#ifndef appconfPDM_MIC_INTERRUPT_CORE
+#define appconfPDM_MIC_INTERRUPT_CORE 3 /* Must be kept off I/O cores. Best kept off core 0 with the tick ISR. */
+#endif /* appconfPDM_MIC_INTERRUPT_CORE */
+
+#ifndef appconfI2S_INTERRUPT_CORE
+#define appconfI2S_INTERRUPT_CORE 4 /* Must be kept off I/O cores. Best kept off core 0 with the tick ISR. */
+#endif /* appconfI2S_INTERRUPT_CORE */
+
+
+/*****************************************/
+/* I/O Task Priorities */
+/*****************************************/
+#ifndef appconfQSPI_FLASH_TASK_PRIORITY
+#define appconfQSPI_FLASH_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
+#endif /* appconfQSPI_FLASH_TASK_PRIORITY */
+
+#ifndef appconfSPI_TASK_PRIORITY
+#define appconfSPI_TASK_PRIORITY (configMAX_PRIORITIES/2)
+#endif /* appconfSPI_TASK_PRIORITY */
+
+#ifndef appconfDEVICE_CONTROL_SPI_PRIORITY
+#define appconfDEVICE_CONTROL_SPI_PRIORITY (configMAX_PRIORITIES-2)
+#endif // appconfDEVICE_CONTROL_SPI_PRIORITY
+
+
+/*****************************************/
+/* CONFIGURATION */
+/*****************************************/
+
+#ifndef appconfAUDIO_CLOCK_FREQUENCY
+#define appconfAUDIO_CLOCK_FREQUENCY MIC_ARRAY_CONFIG_MCLK_FREQ
+#endif /* appconfAUDIO_CLOCK_FREQUENCY */
+
+#ifndef appconfPDM_CLOCK_FREQUENCY
+#define appconfPDM_CLOCK_FREQUENCY MIC_ARRAY_CONFIG_PDM_FREQ
+#endif /* appconfPDM_CLOCK_FREQUENCY */
+
+#ifndef appconfPIPELINE_AUDIO_SAMPLE_RATE
+#define appconfPIPELINE_AUDIO_SAMPLE_RATE 16000
+#endif /* appconfPIPELINE_AUDIO_SAMPLE_RATE */
+
+#ifndef appconfDEVICE_CTRL_SPI
+#define appconfDEVICE_CTRL_SPI 0
+#endif /* appconfDEVICE_CTRL_SPI */
+
+#ifndef APP_CONTROL_TRANSPORT_COUNT
+#define APP_CONTROL_TRANSPORT_COUNT (appconfDEVICE_CTRL_SPI)
+#endif // APP_CONTROL_TRANSPORT_COUNT
+
+#ifndef appconfEXTERNAL_MCLK
+#define appconfEXTERNAL_MCLK 0
+#endif /* appconfEXTERNAL_MCLK */
+
+#ifndef appconfI2S_MODE_MASTER
+#define appconfI2S_MODE_MASTER 0
+#endif /* appconfI2S_MODE_MASTER */
+#ifndef appconfI2S_MODE_SLAVE
+#define appconfI2S_MODE_SLAVE 1
+#endif /* appconfI2S_MODE_SLAVE */
+#ifndef appconfI2S_MODE
+#define appconfI2S_MODE appconfI2S_MODE_MASTER
+#endif /* appconfI2S_MODE */
+
+
+/*****************************************/
+/* DFU Settings */
+/*****************************************/
+#define FL_QUADDEVICE_W25Q64JV \
+{ \
+ 0, /* Just specify 0 as flash_id */ \
+ 256, /* page size */ \
+ 32768, /* num pages */ \
+ 3, /* address size */ \
+ 4, /* log2 clock divider */ \
+ 0x9F, /* QSPI_RDID */ \
+ 0, /* id dummy bytes */ \
+ 3, /* id size in bytes */ \
+ 0xEF4017, /* device id (determined from xflash --spi-read-id 0x9F)*/ \
+ 0x20, /* QSPI_SE */ \
+ 4096, /* Sector erase is always 4KB */ \
+ 0x06, /* QSPI_WREN */ \
+ 0x04, /* QSPI_WRDI */ \
+ PROT_TYPE_SR, /* Protection via SR */ \
+ {{0x18,0x00},{0,0}}, /* QSPI_SP, QSPI_SU */ \
+ 0x02, /* QSPI_PP */ \
+ 0xEB, /* QSPI_READ_FAST */ \
+ 1, /* 1 read dummy byte */ \
+ SECTOR_LAYOUT_REGULAR, /* mad sectors */ \
+ {4096,{0,{0}}}, /* regular sector sizes */ \
+ 0x05, /* QSPI_RDSR */ \
+ 0x01, /* QSPI_WRSR */ \
+ 0x01, /* QSPI_WIP_BIT_MASK */ \
+}
+
+#ifndef BOARD_QSPI_SPEC
+/* Set up a default SPI spec if the app has not provided
+ * one explicitly.
+ * Note: The version checks only work in XTC Tools >15.2.0
+ * By default FL_QUADDEVICE_W25Q64JV is used
+ */
+#ifdef __XMOS_XTC_VERSION_MAJOR__
+#if (__XMOS_XTC_VERSION_MAJOR__ == 15) \
+ && (__XMOS_XTC_VERSION_MINOR__ >= 2) \
+ && (__XMOS_XTC_VERSION_PATCH__ >= 0)
+/* In XTC >15.2.0 some SFDP support enables a generic
+ * default spec
+ */
+#define BOARD_QSPI_SPEC FL_QUADDEVICE_DEFAULT
+#else
+#define BOARD_QSPI_SPEC FL_QUADDEVICE_W25Q64JV
+#endif
+#else
+#define BOARD_QSPI_SPEC FL_QUADDEVICE_W25Q64JV
+#endif /* __XMOS_XTC_VERSION_MAJOR__ */
+#endif /* BOARD_QSPI_SPEC */
+
+#endif /* PLATFORM_CONF_H_ */
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_init.c b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_init.c
new file mode 100644
index 0000000..e2652d5
--- /dev/null
+++ b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_init.c
@@ -0,0 +1,260 @@
+// Copyright 2022-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+/* System headers */
+#include
+
+/* App headers */
+#include "platform_conf.h"
+#include "platform/app_pll_ctrl.h"
+#include "platform/driver_instances.h"
+#include "platform/platform_init.h"
+#include "adaptive_rate_adjust.h"
+#include "usb_support.h"
+#include "usb_cdc.h"
+
+static void mclk_init(chanend_t other_tile_c)
+{
+#if ON_TILE(1) && !appconfEXTERNAL_MCLK
+ app_pll_init();
+#endif
+#if appconfUSB_AUDIO_ENABLED && ON_TILE(USB_TILE_NO)
+ adaptive_rate_adjust_init();
+#endif
+}
+
+static void flash_init(void)
+{
+#if ON_TILE(FLASH_TILE_NO)
+ fl_QuadDeviceSpec qspi_spec = BOARD_QSPI_SPEC;
+ fl_QSPIPorts qspi_ports = {
+ .qspiCS = PORT_SQI_CS,
+ .qspiSCLK = PORT_SQI_SCLK,
+ .qspiSIO = PORT_SQI_SIO,
+ .qspiClkblk = FLASH_CLKBLK,
+ };
+
+ rtos_dfu_image_init(
+ dfu_image_ctx,
+ &qspi_ports,
+ &qspi_spec,
+ 1);
+
+ rtos_qspi_flash_init(
+ qspi_flash_ctx,
+ FLASH_CLKBLK,
+ PORT_SQI_CS,
+ PORT_SQI_SCLK,
+ PORT_SQI_SIO,
+ NULL);
+#endif
+}
+
+static void gpio_init(void)
+{
+ static rtos_driver_rpc_t gpio_rpc_config_t0;
+ static rtos_driver_rpc_t gpio_rpc_config_t1;
+ rtos_intertile_t *client_intertile_ctx[1] = {intertile_ctx};
+
+#if ON_TILE(0)
+ rtos_gpio_init(gpio_ctx_t0);
+
+ rtos_gpio_rpc_host_init(
+ gpio_ctx_t0,
+ &gpio_rpc_config_t0,
+ client_intertile_ctx,
+ 1);
+
+ rtos_gpio_rpc_client_init(
+ gpio_ctx_t1,
+ &gpio_rpc_config_t1,
+ intertile_ctx);
+#endif
+
+#if ON_TILE(1)
+ rtos_gpio_init(gpio_ctx_t1);
+
+ rtos_gpio_rpc_client_init(
+ gpio_ctx_t0,
+ &gpio_rpc_config_t0,
+ intertile_ctx);
+
+ rtos_gpio_rpc_host_init(
+ gpio_ctx_t1,
+ &gpio_rpc_config_t1,
+ client_intertile_ctx,
+ 1);
+#endif
+}
+
+
+
+static void spi_init(void)
+{
+#if appconfDEVICE_CTRL_SPI
+ rtos_intertile_t *client_intertile_ctx[1] = {intertile_ctx};
+#if ON_TILE(SPI_CLIENT_TILE_NO)
+ rtos_spi_slave_init(spi_slave_ctx,
+ (1 << appconfSPI_IO_CORE),
+ SPI_CLKBLK,
+ SPI_MODE_3,
+ PORT_XSPI_CLK,
+ PORT_XSPI_MOSI,
+ PORT_XSPI_MISO,
+ PORT_XSPI_CS);
+
+ device_control_init(device_control_spi_ctx,
+ DEVICE_CONTROL_HOST_MODE,
+ 3, //number of servicers
+ client_intertile_ctx,
+ 1);
+
+ device_control_start(device_control_spi_ctx,
+ appconfSPI_DEV_CTRL_PORT,
+ -1);
+#else
+ device_control_init(device_control_spi_ctx,
+ DEVICE_CONTROL_CLIENT_MODE,
+ 0,
+ client_intertile_ctx,
+ 1);
+
+ device_control_start(device_control_spi_ctx,
+ appconfSPI_DEV_CTRL_PORT,
+ appconfSPI_DEV_CTRL_PRIORITY);
+#endif
+#endif
+}
+
+static void mics_init(void)
+{
+ static rtos_driver_rpc_t mic_array_rpc_config;
+#if ON_TILE(MICARRAY_TILE_NO)
+ rtos_intertile_t *client_intertile_ctx[1] = {intertile_ctx};
+ rtos_mic_array_init(
+ mic_array_ctx,
+ (1 << appconfPDM_MIC_IO_CORE),
+ RTOS_MIC_ARRAY_CHANNEL_SAMPLE);
+ rtos_mic_array_rpc_host_init(
+ mic_array_ctx,
+ &mic_array_rpc_config,
+ client_intertile_ctx,
+ 1);
+#else
+ rtos_mic_array_rpc_client_init(
+ mic_array_ctx,
+ &mic_array_rpc_config,
+ intertile_ctx);
+#endif
+}
+
+static void i2s_init(void)
+{
+#if appconfI2S_ENABLED
+ static rtos_driver_rpc_t i2s_rpc_config;
+#if ON_TILE(I2S_TILE_NO)
+ rtos_intertile_t *client_intertile_ctx[1] = {intertile_ctx};
+ port_t p_i2s_dout[appconfI2S_AUDIO_OUTPUTS] = {
+ PORT_I2S_DOUT1,
+ PORT_I2S_DOUT2
+ };
+ port_t p_i2s_din[appconfI2S_AUDIO_INPUTS] = {
+ PORT_I2S_DIN
+ };
+
+ rtos_i2s_master_init(
+ i2s_ctx,
+ (1 << appconfI2S_IO_CORE),
+ p_i2s_dout,
+ appconfI2S_AUDIO_OUTPUTS,
+ p_i2s_din,
+ appconfI2S_AUDIO_INPUTS,
+ PORT_I2S_BCLK,
+ PORT_I2S_LRCLK,
+ PORT_MCLK,
+ I2S_CLKBLK);
+ rtos_i2s_rpc_host_init(
+ i2s_ctx,
+ &i2s_rpc_config,
+ client_intertile_ctx,
+ 1);
+#else
+ rtos_i2s_rpc_client_init(
+ i2s_ctx,
+ &i2s_rpc_config,
+ intertile_ctx);
+#endif
+#endif
+
+}
+
+static void usb_init(void)
+{
+#if appconfUSB_ENABLED && ON_TILE(USB_TILE_NO)
+ usb_manager_init();
+#endif
+}
+
+static void ws2812_init(void)
+{
+#if ON_TILE(WS2812_TILE_NO)
+ rtos_ws2812_init(ws2812_ctx, PORT_LED_RING, LED_RING_PORT_PIN, LED_RING_NUM_LEDS);
+#endif
+}
+
+static void servicer_init(void)
+{
+#if ON_TILE(0)
+ static device_control_gpio_ports_t gpio_res_info[GPIO_CONTROLLER_MAX_RESOURCES];
+ gpio_res_info[0].resource_idx = RESOURCE_IN_A;
+ gpio_res_info[0].writeable = false;
+ gpio_res_info[0].port_id = PORT_BUTTONS;
+ gpio_res_info[0].bit_mask = 240;
+ gpio_res_info[0].bit_shift = 4;
+ gpio_res_info[0].status_register = 1;
+
+
+ gpio_res_info[1].resource_idx = RESOURCE_IN_B;
+ gpio_res_info[1].writeable = false;
+ gpio_res_info[1].port_id = PORT_ROTARY_ENC;
+ gpio_res_info[1].bit_mask = 14;
+ gpio_res_info[1].bit_shift = 1;
+ gpio_res_info[1].status_register = 2;
+
+ gpio_servicer_init( device_control_gpio_ctx,
+ gpio_ctx_t0,
+ gpio_res_info,
+ 1 );
+#endif
+}
+
+static void usb_cdc_init(){
+#if appconfUSB_CDC_ENABLED
+#if ON_TILE(USB_TILE_NO)
+ rtos_intertile_t *client_intertile_ctx[1] = {intertile_ctx};
+ rtos_cdc_rpc_host_init(client_intertile_ctx,1);
+#else
+ rtos_cdc_rpc_client_init(intertile_ctx);
+#endif
+#endif
+}
+
+
+
+void platform_init(chanend_t other_tile_c)
+{
+ rtos_intertile_init(intertile_ctx, other_tile_c);
+#if appconfUSB_AUDIO_ENABLED
+ rtos_intertile_init(intertile_usb_audio_ctx, other_tile_c);
+#endif
+ mclk_init(other_tile_c);
+ gpio_init();
+ flash_init();
+ spi_init();
+ mics_init();
+ i2s_init();
+ usb_init();
+ ws2812_init();
+ servicer_init();
+ usb_cdc_init();
+}
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_init.h b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_init.h
new file mode 100644
index 0000000..3eeea9d
--- /dev/null
+++ b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_init.h
@@ -0,0 +1,12 @@
+// Copyright 2022-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#ifndef PLATFORM_INIT_H_
+#define PLATFORM_INIT_H_
+
+#include
+
+void platform_init(chanend_t other_tile_c);
+void platform_start(void);
+
+#endif /* PLATFORM_INIT_H_ */
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_start.c b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_start.c
new file mode 100644
index 0000000..8bb2379
--- /dev/null
+++ b/satellite-xmos-firmware/bsp_config/SATELLITE1-USB/platform/platform_start.c
@@ -0,0 +1,138 @@
+// Copyright 2022-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+/* System headers */
+#include
+
+/* FreeRTOS headers */
+#include "FreeRTOS.h"
+
+/* Library headers */
+#include "fs_support.h"
+
+/* App headers */
+#include "platform_conf.h"
+#include "platform/driver_instances.h"
+#include "usb_support.h"
+#include "usb_cdc.h"
+
+
+#if appconfDEVICE_CTRL_SPI
+#include "device_control_spi.h"
+#endif
+
+
+static void gpio_start(void)
+{
+ rtos_gpio_rpc_config(gpio_ctx_t0, appconfGPIO_T0_RPC_PORT, appconfGPIO_RPC_PRIORITY);
+ rtos_gpio_rpc_config(gpio_ctx_t1, appconfGPIO_T1_RPC_PORT, appconfGPIO_RPC_PRIORITY);
+
+#if ON_TILE(0)
+ rtos_gpio_start(gpio_ctx_t0);
+#endif
+#if ON_TILE(1)
+ rtos_gpio_start(gpio_ctx_t1);
+#endif
+}
+
+static void flash_start(void)
+{
+#if ON_TILE(FLASH_TILE_NO)
+ uint32_t flash_core_map = ~((1 << appconfUSB_INTERRUPT_CORE) | (1 << appconfUSB_SOF_INTERRUPT_CORE));
+ rtos_qspi_flash_start(qspi_flash_ctx, appconfQSPI_FLASH_TASK_PRIORITY);
+ rtos_qspi_flash_op_core_affinity_set(qspi_flash_ctx, flash_core_map);
+#endif
+}
+
+
+static void spi_start(void)
+{
+#if appconfDEVICE_CTRL_SPI && ON_TILE(SPI_CLIENT_TILE_NO)
+#if 0 //do we need this?
+ const rtos_gpio_port_id_t wifi_rst_port = rtos_gpio_port(WIFI_WUP_RST_N);
+ rtos_gpio_port_enable(gpio_ctx_t0, wifi_rst_port);
+ rtos_gpio_port_out(gpio_ctx_t0, wifi_rst_port, 0x00);
+
+ const rtos_gpio_port_id_t wifi_cs_port = rtos_gpio_port(WIFI_CS_N);
+ rtos_gpio_port_enable(gpio_ctx_t0, wifi_cs_port);
+ rtos_gpio_port_out(gpio_ctx_t0, wifi_cs_port, 0x0F);
+#endif
+ rtos_spi_slave_start(spi_slave_ctx,
+ device_control_spi_ctx,
+ (rtos_spi_slave_start_cb_t) device_control_spi_start_cb,
+ (rtos_spi_slave_xfer_done_cb_t) device_control_spi_xfer_done_cb,
+ appconfSPI_INTERRUPT_CORE,
+ appconfSPI_TASK_PRIORITY);
+#endif
+}
+
+static void mics_start(void)
+{
+ rtos_mic_array_rpc_config(mic_array_ctx, appconfMIC_ARRAY_RPC_PORT, appconfMIC_ARRAY_RPC_PRIORITY);
+
+#if ON_TILE(MICARRAY_TILE_NO)
+ rtos_mic_array_start(
+ mic_array_ctx,
+ 2 * MIC_ARRAY_CONFIG_SAMPLES_PER_FRAME,
+ appconfPDM_MIC_INTERRUPT_CORE);
+#endif
+}
+
+static void i2s_start(void)
+{
+#if appconfI2S_ENABLED
+ rtos_i2s_rpc_config(i2s_ctx, appconfI2S_RPC_PORT, appconfI2S_RPC_PRIORITY);
+
+#if ON_TILE(I2S_TILE_NO)
+ rtos_i2s_start(
+ i2s_ctx,
+ rtos_i2s_mclk_bclk_ratio(appconfAUDIO_CLOCK_FREQUENCY, appconfI2S_AUDIO_SAMPLE_RATE),
+ I2S_MODE_I2S,
+ 2.2 * MIC_ARRAY_CONFIG_SAMPLES_PER_FRAME * 3,
+ 1.2 * MIC_ARRAY_CONFIG_SAMPLES_PER_FRAME * 3,
+ appconfI2S_INTERRUPT_CORE);
+#endif
+#endif
+}
+
+static void usb_start(void)
+{
+#if appconfUSB_ENABLED && ON_TILE(USB_TILE_NO)
+ usb_manager_start(appconfUSB_MGR_TASK_PRIORITY);
+#endif
+}
+
+static void ws2812_start(void)
+{
+#if ON_TILE(WS2812_TILE_NO)
+ rtos_ws2812_start(ws2812_ctx);
+#endif
+}
+
+static void usb_cdc_start(void)
+{
+#if appconfUSB_CDC_ENABLED
+ rtos_cdc_rpc_config(appconfUSB_CDC_PORT, appconfUSB_CDC_PRIORITY);
+#if ON_TILE(USB_TILE_NO)
+ rtos_cdc_start();
+#endif
+#endif
+}
+
+
+
+void platform_start(void)
+{
+ rtos_intertile_start(intertile_ctx);
+#if appconfUSB_AUDIO_ENABLED
+ rtos_intertile_start(intertile_usb_audio_ctx);
+#endif
+ gpio_start();
+ flash_start();
+ spi_start();
+ mics_start();
+ i2s_start();
+ usb_start();
+ ws2812_start();
+ usb_cdc_start();
+}
diff --git a/satellite-xmos-firmware/bsp_config/SATELLITE1/usb_mode/dac_port.c b/satellite-xmos-firmware/bsp_config/SATELLITE1/usb_mode/dac_port.c
deleted file mode 100644
index 73f9584..0000000
--- a/satellite-xmos-firmware/bsp_config/SATELLITE1/usb_mode/dac_port.c
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2022-2023 XMOS LIMITED.
-// This Software is subject to the terms of the XMOS Public Licence: Version 1.
-
-/* System headers */
-#include
-
-/* FreeRTOS headers */
-#include "FreeRTOS.h"
-
-/* App headers */
-#include "platform_conf.h"
-#include "platform/driver_instances.h"
-#include "aic3204.h"
-
-int aic3204_reg_write(uint8_t reg, uint8_t val)
-{
- i2c_regop_res_t ret;
-
- ret = rtos_i2c_master_reg_write(i2c_master_ctx, AIC3204_I2C_DEVICE_ADDR, reg, val);
-
- if (ret == I2C_REGOP_SUCCESS) {
- return 0;
- } else {
- return -1;
- }
-}
-
-void aic3204_codec_reset(void)
-{
- const rtos_gpio_port_id_t codec_rst_port = rtos_gpio_port(PORT_CODEC_RST_N);
- rtos_gpio_port_enable(gpio_ctx_t1, codec_rst_port);
- rtos_gpio_port_out(gpio_ctx_t1, codec_rst_port, 0xF);
-}
-
-void aic3204_wait(uint32_t wait_ms)
-{
- vTaskDelay(pdMS_TO_TICKS(wait_ms));
-}
diff --git a/satellite-xmos-firmware/bsp_config/bsp_config.cmake b/satellite-xmos-firmware/bsp_config/bsp_config.cmake
index 66d1d87..c17b887 100644
--- a/satellite-xmos-firmware/bsp_config/bsp_config.cmake
+++ b/satellite-xmos-firmware/bsp_config/bsp_config.cmake
@@ -1,5 +1,6 @@
include(${CMAKE_CURRENT_LIST_DIR}/dac/dac.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/SATELLITE1/SATELLITE1.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/SATELLITE1-USB/SATELLITE1-USB.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/XCORE-AI-EXPLORER/XCORE-AI-EXPLORER.cmake)
diff --git a/satellite-xmos-firmware/firmware.cmake b/satellite-xmos-firmware/firmware.cmake
index 8b4eb2e..db0d52d 100644
--- a/satellite-xmos-firmware/firmware.cmake
+++ b/satellite-xmos-firmware/firmware.cmake
@@ -91,5 +91,6 @@ endif()
# XMOS Firmware Targets
#**********************
include(${CMAKE_CURRENT_LIST_DIR}/satellite1.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/satellite1-usb.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/explorer_devboard.cmake)
-include(${CMAKE_CURRENT_LIST_DIR}/satellite1_usb_debug.cmake)
+
diff --git a/satellite-xmos-firmware/satellite1-usb.cmake b/satellite-xmos-firmware/satellite1-usb.cmake
new file mode 100644
index 0000000..9bc7de9
--- /dev/null
+++ b/satellite-xmos-firmware/satellite1-usb.cmake
@@ -0,0 +1,214 @@
+query_tools_version()
+
+set(FFVA_FD_PIPELINE_CONFIGS
+ aec__vnr_ic__ns__agc
+ aec__vnr_ic__ns
+ aec__vnr_ic
+ vnr_ic__ns
+ vnr_ic
+ ns
+)
+
+set(FFVA_AP "fixed_delay")
+
+foreach(FFVA_PL_CFG ${FFVA_FD_PIPELINE_CONFIGS})
+
+ set(FFVA_INT_COMPILE_DEFINITIONS
+ ${APP_COMPILE_DEFINITIONS}
+ appconfDEVICE_CTRL_SPI=0
+ appconfEXTERNAL_MCLK=0
+ appconfI2S_ENABLED=1
+
+ appconfUSB_ENABLED=1
+ appconfUSB_AUDIO_ENABLED=1
+ appconfUSB_AUDIO_MODE=1
+ appconfUSB_CDC_ENABLED=1
+
+ appconfAEC_REF_DEFAULT=appconfAEC_REF_USB
+ appconfI2S_MODE=appconfI2S_MODE_MASTER
+ appconfI2S_AUDIO_SAMPLE_RATE=16000
+ appconfAUDIO_SPK_PL_SR_FACTOR=1
+
+ appconfAUDIO_PIPELINE_STORE_IC_AUDIO=0
+ appconfAUDIO_PIPELINE_STORE_NS_AUDIO=0
+
+ #appconfAUDIO_PIPELINE_SKIP_AEC=0
+ #appconfAUDIO_PIPELINE_SKIP_NS=0
+ #appconfAUDIO_PIPELINE_SKIP_IC_AND_VNR=0
+ #appconfAUDIO_PIPELINE_SKIP_AGC=1
+ )
+ if(${FFVA_PL_CFG} STREQUAL aec__vnr_ic__ns__agc)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AEC=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_NS=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_IC_AND_VNR=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AGC=0)
+ elseif(${FFVA_PL_CFG} STREQUAL aec__vnr_ic__ns)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AEC=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_NS=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_IC_AND_VNR=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AGC=1)
+ elseif(${FFVA_PL_CFG} STREQUAL aec__vnr_ic)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AEC=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_NS=1)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_IC_AND_VNR=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AGC=1)
+ elseif(${FFVA_PL_CFG} STREQUAL vnr_ic__ns)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AEC=1)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_NS=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_IC_AND_VNR=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AGC=1)
+ elseif(${FFVA_PL_CFG} STREQUAL vnr_ic)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AEC=1)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_NS=1)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_IC_AND_VNR=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AGC=1)
+ elseif(${FFVA_PL_CFG} STREQUAL ns)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AEC=1)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_NS=0)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_IC_AND_VNR=1)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfAUDIO_PIPELINE_SKIP_AGC=1)
+ endif()
+
+ if(${FFVA_AP} STREQUAL bypass )
+ set(PL_NAME fixed_delay)
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfPIPELINE_BYPASS=1)
+ else()
+ set(PL_NAME ${FFVA_AP})
+ list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfPIPELINE_BYPASS=0)
+ endif()
+
+ # message(${FFVA_INT_COMPILE_DEFINITIONS})
+
+ #**********************
+ # Tile Targets
+ #**********************
+ set(TARGET_NAME tile0_satellite1_usb_firmware_${FFVA_PL_CFG})
+ add_executable(${TARGET_NAME} EXCLUDE_FROM_ALL)
+ target_sources(${TARGET_NAME} PUBLIC ${APP_SOURCES})
+ target_include_directories(${TARGET_NAME} PUBLIC ${APP_INCLUDES})
+ target_compile_definitions(${TARGET_NAME}
+ PUBLIC
+ ${FFVA_INT_COMPILE_DEFINITIONS}
+ THIS_XCORE_TILE=0
+ )
+ target_compile_options(${TARGET_NAME} PRIVATE ${APP_COMPILER_FLAGS})
+ target_link_libraries(${TARGET_NAME}
+ PUBLIC
+ ${APP_COMMON_LINK_LIBRARIES}
+ fph::ffva::satellite1-usb
+ fph::ffva::ap::${PL_NAME}
+ sln_voice::app::ffva::sp::passthrough
+ )
+ target_link_options(${TARGET_NAME} PRIVATE ${APP_LINK_OPTIONS})
+ unset(TARGET_NAME)
+
+ set(TARGET_NAME tile1_satellite1_usb_firmware_${FFVA_PL_CFG})
+ add_executable(${TARGET_NAME} EXCLUDE_FROM_ALL)
+ target_sources(${TARGET_NAME} PUBLIC ${APP_SOURCES})
+ target_include_directories(${TARGET_NAME} PUBLIC ${APP_INCLUDES})
+ target_compile_definitions(${TARGET_NAME}
+ PUBLIC
+ ${FFVA_INT_COMPILE_DEFINITIONS}
+ THIS_XCORE_TILE=1
+ )
+ target_compile_options(${TARGET_NAME} PRIVATE ${APP_COMPILER_FLAGS})
+ target_link_libraries(${TARGET_NAME}
+ PUBLIC
+ ${APP_COMMON_LINK_LIBRARIES}
+ fph::ffva::satellite1-usb
+ fph::ffva::ap::${PL_NAME}
+ sln_voice::app::ffva::sp::passthrough
+ )
+ target_link_options(${TARGET_NAME} PRIVATE ${APP_LINK_OPTIONS})
+ unset(TARGET_NAME)
+
+ #*********************
+ # Create version.h
+ #*********************
+ SET(VERSIONING_CMD "build")
+ if(USE_DEV_TRACKING)
+ list(APPEND VERSIONING_CMD "--track")
+ endif()
+
+ add_custom_target(satellite1_usb_firmware_${FFVA_PL_CFG}_versioning
+ COMMAND ${Python3_EXECUTABLE} ${VERSIONING_SCRIPT} ${VERSIONING_CMD} satellite1_usb_firmware_${FFVA_PL_CFG}
+ COMMENT "Running versioning.py build satellite1_firmware_${FFVA_AP}"
+ VERBATIM
+ )
+ add_dependencies(tile0_satellite1_usb_firmware_${FFVA_PL_CFG} satellite1_usb_firmware_${FFVA_PL_CFG}_versioning)
+ add_dependencies(tile1_satellite1_usb_firmware_${FFVA_PL_CFG} satellite1_usb_firmware_${FFVA_PL_CFG}_versioning)
+
+ #**********************
+ # Merge binaries
+ #**********************
+ merge_binaries(satellite1_usb_firmware_${FFVA_PL_CFG} tile0_satellite1_usb_firmware_${FFVA_PL_CFG} tile1_satellite1_usb_firmware_${FFVA_PL_CFG} 1)
+
+ #**********************
+ # Create run and debug targets
+ #**********************
+ create_run_target(satellite1_usb_firmware_${FFVA_PL_CFG})
+ create_debug_target(satellite1_usb_firmware_${FFVA_PL_CFG})
+ create_upgrade_img_target(satellite1_usb_firmware_${FFVA_PL_CFG} ${XTC_VERSION_MAJOR} ${XTC_VERSION_MINOR})
+
+ #**********************
+ # Create data partition support targets
+ #**********************
+ set(TARGET_NAME satellite1_usb_firmware_${FFVA_PL_CFG})
+ set(DATA_PARTITION_FILE ${TARGET_NAME}_data_partition.bin)
+ set(FATFS_FILE ${TARGET_NAME}_fat.fs)
+ set(FATFS_CONTENTS_DIR ${TARGET_NAME}_fatmktmp)
+
+ add_custom_target(
+ ${FATFS_FILE} ALL
+ COMMAND ${CMAKE_COMMAND} -E rm -rf ${FATFS_CONTENTS_DIR}/fs/
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${FATFS_CONTENTS_DIR}/fs/
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/filesystem_support/demo.txt ${FATFS_CONTENTS_DIR}/fs/
+ COMMAND fatfs_mkimage --input=${FATFS_CONTENTS_DIR} --output=${FATFS_FILE}
+ COMMENT
+ "Create filesystem"
+ VERBATIM
+ )
+
+ set_target_properties(${FATFS_FILE} PROPERTIES
+ ADDITIONAL_CLEAN_FILES ${FATFS_CONTENTS_DIR}
+ )
+
+ # The filesystem is the only component in the data partition, copy it to
+ # the assocated data partition file which is required for CI.
+ add_custom_command(
+ OUTPUT ${DATA_PARTITION_FILE}
+ COMMAND ${CMAKE_COMMAND} -E copy ${FATFS_FILE} ${DATA_PARTITION_FILE}
+ DEPENDS
+ ${FATFS_FILE}
+ COMMENT
+ "Create data partition"
+ VERBATIM
+ )
+
+ list(APPEND DATA_PARTITION_FILE_LIST
+ ${FATFS_FILE}
+ ${DATA_PARTITION_FILE}
+ )
+
+ create_data_partition_directory(
+ #[[ Target ]] ${TARGET_NAME}
+ #[[ Copy Files ]] "${DATA_PARTITION_FILE_LIST}"
+ #[[ Dependencies ]] "${DATA_PARTITION_FILE_LIST}"
+ )
+
+ create_flash_image_target(
+ #[[ Target ]] ${TARGET_NAME}
+ #[[ Boot Partition Size ]] 0x100000
+ # #[[ Data Partition Contents ]] ${DATA_PARTITION_FILE}
+ # #[[ Dependencies ]] ${DATA_PARTITION_FILE}
+
+ )
+ create_flash_app_target(
+ #[[ Target ]] ${TARGET_NAME}
+ #[[ Boot Partition Size ]] 0x100000
+ #[[ Data Partition Contents ]] ${DATA_PARTITION_FILE}
+ #[[ Dependencies ]] ${DATA_PARTITION_FILE}
+ )
+
+ unset(DATA_PARTITION_FILE_LIST)
+endforeach()
diff --git a/satellite-xmos-firmware/satellite1_usb_debug.cmake b/satellite-xmos-firmware/satellite1_usb_debug.cmake
deleted file mode 100644
index 36eded5..0000000
--- a/satellite-xmos-firmware/satellite1_usb_debug.cmake
+++ /dev/null
@@ -1,147 +0,0 @@
-query_tools_version()
-
-set(FFVA_AP bypass)
-set(VARIANT_NAME satellite1_usb_debug)
-
-set(FFVA_INT_COMPILE_DEFINITIONS
-${APP_COMPILE_DEFINITIONS}
- appconfEXTERNAL_MCLK=0
- appconfI2S_ENABLED=1
- appconfUSB_ENABLED=1
- appconfUSB_AUDIO_MODE=1 # appconfUSB_AUDIO_TESTING (enables 6 channels)
- appconfUSB_CDC_ENABLED=1
- appconfAEC_REF_DEFAULT=appconfAEC_REF_I2S
- appconfI2S_MODE=appconfI2S_MODE_MASTER
- appconfI2S_AUDIO_SAMPLE_RATE=48000
- appconfI2S_ESP_ENABLED=1
-
- ## VK Voice uses 12288000 for RPI integration, EXPLORER Board uses default 24576000
- # MIC_ARRAY_CONFIG_MCLK_FREQ=12288000
-)
-if(${FFVA_AP} STREQUAL bypass )
- set(PL_NAME fixed_delay)
- list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfPIPELINE_BYPASS=1)
-else()
- set(PL_NAME ${FFVA_AP})
- list(APPEND FFVA_INT_COMPILE_DEFINITIONS appconfPIPELINE_BYPASS=0)
-endif()
-
-# message(${FFVA_INT_COMPILE_DEFINITIONS})
-
-#**********************
-# Tile Targets
-#**********************
-set(TARGET_NAME tile0_${VARIANT_NAME})
-add_executable(${TARGET_NAME} EXCLUDE_FROM_ALL)
-target_sources(${TARGET_NAME} PUBLIC ${APP_SOURCES})
-target_include_directories(${TARGET_NAME} PUBLIC ${APP_INCLUDES})
-target_compile_definitions(${TARGET_NAME}
- PUBLIC
- ${FFVA_INT_COMPILE_DEFINITIONS}
- THIS_XCORE_TILE=0
-)
-target_compile_options(${TARGET_NAME} PRIVATE ${APP_COMPILER_FLAGS})
-target_link_libraries(${TARGET_NAME}
- PUBLIC
- ${APP_COMMON_LINK_LIBRARIES}
- sln_voice::app::ffva::xcore_ai_explorer
- fph::ffva::ap::${PL_NAME}
- sln_voice::app::ffva::sp::passthrough
-)
-target_link_options(${TARGET_NAME} PRIVATE ${APP_LINK_OPTIONS})
-unset(TARGET_NAME)
-
-set(TARGET_NAME tile1_${VARIANT_NAME})
-add_executable(${TARGET_NAME} EXCLUDE_FROM_ALL)
-target_sources(${TARGET_NAME} PUBLIC ${APP_SOURCES})
-target_include_directories(${TARGET_NAME} PUBLIC ${APP_INCLUDES})
-target_compile_definitions(${TARGET_NAME}
- PUBLIC
- ${FFVA_INT_COMPILE_DEFINITIONS}
- THIS_XCORE_TILE=1
-)
-target_compile_options(${TARGET_NAME} PRIVATE ${APP_COMPILER_FLAGS})
-target_link_libraries(${TARGET_NAME}
- PUBLIC
- ${APP_COMMON_LINK_LIBRARIES}
- sln_voice::app::ffva::xcore_ai_explorer
- fph::ffva::ap::${PL_NAME}
- sln_voice::app::ffva::sp::passthrough
-)
-target_link_options(${TARGET_NAME} PRIVATE ${APP_LINK_OPTIONS})
-unset(TARGET_NAME)
-
-#**********************
-# Merge binaries
-#**********************
-merge_binaries(${VARIANT_NAME} tile0_${VARIANT_NAME} tile1_${VARIANT_NAME} 1)
-
-#**********************
-# Create run and debug targets
-#**********************
-create_run_target(${VARIANT_NAME})
-create_debug_target(${VARIANT_NAME})
-create_upgrade_img_target(${VARIANT_NAME} ${XTC_VERSION_MAJOR} ${XTC_VERSION_MINOR})
-
-#**********************
-# Create data partition support targets
-#**********************
-set(TARGET_NAME ${VARIANT_NAME})
-set(DATA_PARTITION_FILE ${TARGET_NAME}_data_partition.bin)
-set(FATFS_FILE ${TARGET_NAME}_fat.fs)
-set(FATFS_CONTENTS_DIR ${TARGET_NAME}_fatmktmp)
-
-add_custom_target(
- ${FATFS_FILE} ALL
- COMMAND ${CMAKE_COMMAND} -E rm -rf ${FATFS_CONTENTS_DIR}/fs/
- COMMAND ${CMAKE_COMMAND} -E make_directory ${FATFS_CONTENTS_DIR}/fs/
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/filesystem_support/demo.txt ${FATFS_CONTENTS_DIR}/fs/
- COMMAND fatfs_mkimage --input=${FATFS_CONTENTS_DIR} --output=${FATFS_FILE}
- COMMENT
- "Create filesystem"
- VERBATIM
-)
-
-set_target_properties(${FATFS_FILE} PROPERTIES
- ADDITIONAL_CLEAN_FILES ${FATFS_CONTENTS_DIR}
-)
-
-# The filesystem is the only component in the data partition, copy it to
-# the assocated data partition file which is required for CI.
-add_custom_command(
- OUTPUT ${DATA_PARTITION_FILE}
- COMMAND ${CMAKE_COMMAND} -E copy ${FATFS_FILE} ${DATA_PARTITION_FILE}
- DEPENDS
- ${FATFS_FILE}
- COMMENT
- "Create data partition"
- VERBATIM
-)
-
-list(APPEND DATA_PARTITION_FILE_LIST
- ${FATFS_FILE}
- ${DATA_PARTITION_FILE}
-)
-
-create_data_partition_directory(
- #[[ Target ]] ${TARGET_NAME}
- #[[ Copy Files ]] "${DATA_PARTITION_FILE_LIST}"
- #[[ Dependencies ]] "${DATA_PARTITION_FILE_LIST}"
-)
-
-create_flash_image_target(
- #[[ Target ]] ${TARGET_NAME}
- #[[ Boot Partition Size ]] 0x100000
-# #[[ Data Partition Contents ]] ${DATA_PARTITION_FILE}
-# #[[ Dependencies ]] ${DATA_PARTITION_FILE}
-
-)
-create_flash_app_target(
- #[[ Target ]] ${TARGET_NAME}
- #[[ Boot Partition Size ]] 0x100000
- #[[ Data Partition Contents ]] ${DATA_PARTITION_FILE}
- #[[ Dependencies ]] ${DATA_PARTITION_FILE}
-)
-
-unset(DATA_PARTITION_FILE_LIST)
-
diff --git a/satellite-xmos-firmware/src/app_conf.h b/satellite-xmos-firmware/src/app_conf.h
index 7eeb2a0..327de91 100644
--- a/satellite-xmos-firmware/src/app_conf.h
+++ b/satellite-xmos-firmware/src/app_conf.h
@@ -24,7 +24,10 @@
#define appconfPDM_CLOCK_FREQUENCY MIC_ARRAY_CONFIG_PDM_FREQ
#define appconfAUDIO_PIPELINE_SAMPLE_RATE 16000
#define appconfAUDIO_PIPELINE_CHANNELS MIC_ARRAY_CONFIG_MIC_COUNT
+
+#ifndef appconfAUDIO_SPK_PL_SR_FACTOR
#define appconfAUDIO_SPK_PL_SR_FACTOR 3
+#endif
/* If in channel sample format, appconfAUDIO_PIPELINE_FRAME_ADVANCE == MIC_ARRAY_CONFIG_SAMPLES_PER_FRAME*/
#define appconfAUDIO_PIPELINE_FRAME_ADVANCE MIC_ARRAY_CONFIG_SAMPLES_PER_FRAME
@@ -68,6 +71,14 @@
#define appconfAUDIO_PIPELINE_SKIP_AGC 0
#endif
+#ifndef appconfAUDIO_PIPELINE_STORE_IC_AUDIO
+#define appconfAUDIO_PIPELINE_STORE_IC_AUDIO 1
+#endif
+
+#ifndef appconfAUDIO_PIPELINE_STORE_NS_AUDIO
+#define appconfAUDIO_PIPELINE_STORE_NS_AUDIO 1
+#endif
+
#ifndef appconfI2S_ENABLED
#define appconfI2S_ENABLED 1
#endif
diff --git a/satellite-xmos-firmware/src/main.c b/satellite-xmos-firmware/src/main.c
index d2b5bd3..b41c3fd 100644
--- a/satellite-xmos-firmware/src/main.c
+++ b/satellite-xmos-firmware/src/main.c
@@ -37,7 +37,6 @@
volatile int mic_from_usb = appconfMIC_SRC_DEFAULT;
volatile int aec_ref_source = appconfAEC_REF_DEFAULT;
-#if appconfI2S_ENABLED
#if ON_TILE(SPEAKER_PIPELINE_TILE_NO)
rtos_osal_queue_t *ref_input_queue;
@@ -48,8 +47,8 @@ void speaker_pipeline_input(void *input_app_data,
size_t ch_count,
size_t frame_count)
{
-
- if (!appconfUSB_ENABLED || aec_ref_source == appconfAEC_REF_I2S) {
+#if ON_TILE(SPEAKER_PIPELINE_TILE_NO)
+ if (!appconfUSB_AUDIO_ENABLED || aec_ref_source == appconfAEC_REF_I2S) {
/* This shouldn't need to block given it shares a clock with the PDM mics */
xassert(frame_count == appconfAUDIO_SPK_PIPELINE_FRAME_ADVANCE);
@@ -70,6 +69,22 @@ void speaker_pipeline_input(void *input_app_data,
*(tmpptr + i + frame_count) = tmp[i][0][1];
}
}
+
+#if appconfUSB_AUDIO_ENABLED
+ int32_t **usb_mic_audio_frame = NULL;
+ if (true) {
+ usb_mic_audio_frame = input_audio_frames;
+ /*
+ * As noted above, this does not block.
+ * and expects ref L, ref R, mic 0, mic 1
+ */
+ usb_audio_recv(intertile_usb_audio_ctx,
+ frame_count,
+ usb_mic_audio_frame,
+ ch_count);
+ }
+#endif
+#endif
}
int speaker_pipeline_output(void *output_app_data,
@@ -77,6 +92,7 @@ int speaker_pipeline_output(void *output_app_data,
size_t ch_count,
size_t frame_count)
{
+#if ON_TILE(SPEAKER_PIPELINE_TILE_NO)
(void) output_app_data;
xassert(frame_count == appconfAUDIO_SPK_PIPELINE_FRAME_ADVANCE);
@@ -95,14 +111,13 @@ int speaker_pipeline_output(void *output_app_data,
frame_count,
portMAX_DELAY);
-#if ON_TILE(SPEAKER_PIPELINE_TILE_NO)
void* frame_data;
frame_data = pvPortMalloc( appconfAUDIO_PIPELINE_FRAME_ADVANCE * appconfAUDIO_PIPELINE_CHANNELS * sizeof( int32_t ));
- static int64_t sum[2];
- static int32_t src_data[2][SRC_FF3V_FIR_NUM_PHASES][SRC_FF3V_FIR_TAPS_PER_PHASE] __attribute__((aligned (8)));
// down sample reference signal to 16kHz if needed
if (appconfI2S_AUDIO_SAMPLE_RATE == 3*appconfAUDIO_PIPELINE_SAMPLE_RATE) {
+ static int64_t sum[2];
+ static int32_t src_data[2][SRC_FF3V_FIR_NUM_PHASES][SRC_FF3V_FIR_TAPS_PER_PHASE] __attribute__((aligned (8)));
int32_t tmp_out[appconfAUDIO_PIPELINE_FRAME_ADVANCE][1][appconfAUDIO_PIPELINE_CHANNELS];
for( int frame=0; frame < frame_count; frame +=3 ){
@@ -122,10 +137,11 @@ int speaker_pipeline_output(void *output_app_data,
// send to microphone pipeline as reference
(void) rtos_osal_queue_send(ref_input_queue, &frame_data, RTOS_OSAL_WAIT_FOREVER);
+
#endif
return AUDIO_PIPELINE_FREE_FRAME;
}
-#endif
+
void audio_pipeline_input(void *input_app_data,
@@ -180,28 +196,6 @@ void audio_pipeline_input(void *input_app_data,
frame_count,
portMAX_DELAY);
-#if appconfUSB_AUDIO_ENABLED
- int32_t **usb_mic_audio_frame = NULL;
- size_t ch_cnt = 2; /* ref frames */
-
- if (aec_ref_source == appconfAEC_REF_USB) {
- usb_mic_audio_frame = input_audio_frames;
- }
-
- if (mic_from_usb) {
- ch_cnt += 2; /* mic frames */
- }
-
- /*
- * As noted above, this does not block.
- * and expects ref L, ref R, mic 0, mic 1
- */
- usb_audio_recv(intertile_usb_audio_ctx,
- frame_count,
- usb_mic_audio_frame,
- ch_cnt);
-#endif
-
}
int audio_pipeline_output(void *output_app_data,
@@ -294,7 +288,10 @@ static void mem_analysis(void)
{
for (;;) {
rtos_printf("Tile[%d]:\n\tMinimum heap free: %d\n\tCurrent heap free: %d\n", THIS_XCORE_TILE, xPortGetMinimumEverFreeHeapSize(), xPortGetFreeHeapSize());
- reset_watchdog();
+ cdc_printf("Tile[%d]:\n\tMinimum heap free: %d\n\tCurrent heap free: %d\n", THIS_XCORE_TILE, xPortGetMinimumEverFreeHeapSize(), xPortGetFreeHeapSize());
+#if ON_TILE(0)
+ reset_watchdog();
+#endif
vTaskDelay(pdMS_TO_TICKS(5000));
}
}
diff --git a/satellite-xmos-firmware/src/usb/tusb_config.h b/satellite-xmos-firmware/src/usb/tusb_config.h
index 08957f4..457df10 100644
--- a/satellite-xmos-firmware/src/usb/tusb_config.h
+++ b/satellite-xmos-firmware/src/usb/tusb_config.h
@@ -99,7 +99,7 @@
#define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
// CDC Endpoint transfer buffer size, more is faster
-#define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
+#define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
#endif
//--------------------------------------------------------------------
@@ -121,7 +121,7 @@ extern const uint16_t tud_audio_desc_lengths[CFG_TUD_AUDIO];
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX 2
#else
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX 6
-#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX 4
+#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX 2
#endif
#if (appconfMIC_SRC_DEFAULT == appconfMIC_SRC_USB)
@@ -136,7 +136,13 @@ extern const uint16_t tud_audio_desc_lengths[CFG_TUD_AUDIO];
#endif
// EP and buffer sizes
-#define AUDIO_FRAMES_PER_USB_FRAME (appconfUSB_AUDIO_SAMPLE_RATE / 1000)
+#define appconfUSB_SPK_SAMPLE_RATE 16000
+#define AUDIO_FRAMES_PER_USB_SPK_FRAME (appconfUSB_SPK_SAMPLE_RATE / 1000)
+
+#define appconfUSB_MICS_SAMPLE_RATE 16000
+#define AUDIO_FRAMES_PER_USB_MICS_FRAME (appconfUSB_MICS_SAMPLE_RATE / 1000)
+
+
#if appconfUSB_AUDIO_SAMPLE_RATE == 48000
#define USB_TASK_STACK_SIZE 2000
#endif
@@ -144,12 +150,12 @@ extern const uint16_t tud_audio_desc_lengths[CFG_TUD_AUDIO];
// To support USB Adaptive/Asynchronous, maximum packet size must be large enough to accommodate an extra set of samples per frame.
// Adding 1 to AUDIO_SAMPLES_PER_USB_FRAME allows this.
#define CFG_TUD_AUDIO_ENABLE_EP_IN 1
-#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ ((AUDIO_FRAMES_PER_USB_FRAME + 1) * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX)
+#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ ((AUDIO_FRAMES_PER_USB_MICS_FRAME + 1) * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX)
#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX (CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ) // Maximum EP IN size for all AS alternate settings used
#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ
#define CFG_TUD_AUDIO_ENABLE_EP_OUT 1
-#define CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ ((AUDIO_FRAMES_PER_USB_FRAME + 1) * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX)
+#define CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ ((AUDIO_FRAMES_PER_USB_SPK_FRAME + 1) * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX)
#define CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ_MAX (CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ + 2) // Maximum EP OUT size for all AS alternate settings used. Plus 2 for CRC
#define CFG_TUD_AUDIO_FUNC_1_EP_OUT_SW_BUF_SZ CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ*3
#endif
diff --git a/satellite-xmos-firmware/src/usb/usb_audio.c b/satellite-xmos-firmware/src/usb/usb_audio.c
index 0c99e90..86d09e3 100644
--- a/satellite-xmos-firmware/src/usb/usb_audio.c
+++ b/satellite-xmos-firmware/src/usb/usb_audio.c
@@ -141,7 +141,8 @@ void usb_audio_send(rtos_intertile_t *intertile_ctx,
for(int ch=0; ch> src_32_shift;
+ const int channel_shift = (ch == 2 || ch == 3) ? src_32_shift : 16 - 6;
+ usb_audio_in_frame[i][ch] = frame_buf_ptr[i+(appconfAUDIO_PIPELINE_FRAME_ADVANCE*ch)] >> channel_shift;
}
}
}
@@ -161,7 +162,7 @@ void usb_audio_recv(rtos_intertile_t *intertile_ctx,
int32_t **frame_buffers,
size_t num_chans)
{
- static samp_t usb_audio_out_frame[appconfAUDIO_PIPELINE_FRAME_ADVANCE][CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX];
+ static samp_t usb_audio_out_frame[appconfAUDIO_SPK_PIPELINE_FRAME_ADVANCE][CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX];
size_t bytes_received;
int32_t *frame_buf_ptr = (int32_t *) frame_buffers;
@@ -170,7 +171,7 @@ void usb_audio_recv(rtos_intertile_t *intertile_ctx,
#elif CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX == 4
const int src_32_shift = 0;
#endif
- xassert(frame_count == appconfAUDIO_PIPELINE_FRAME_ADVANCE);
+ xassert(frame_count == appconfAUDIO_SPK_PIPELINE_FRAME_ADVANCE);
bytes_received = rtos_intertile_rx_len(
intertile_ctx,
@@ -190,9 +191,9 @@ void usb_audio_recv(rtos_intertile_t *intertile_ctx,
if (frame_buf_ptr != NULL) {
for(int ch=0; ch=.
*/
@@ -630,10 +631,10 @@ bool tud_audio_tx_done_pre_load_cb(uint8_t rhport,
* This buffer needs to be large enough to hold any size of transaction,
* but if it's any bigger than twice nominal then we have bigger issues
*/
- samp_t stream_buffer_audio_frames[2 * AUDIO_FRAMES_PER_USB_FRAME / RATE_MULTIPLIER][CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX];
+ samp_t stream_buffer_audio_frames[2 * AUDIO_FRAMES_PER_USB_MICS_FRAME / RATE_MULTIPLIER][CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX];
/* This buffer has to be large enough to contain any size transaction */
- samp_t usb_audio_frames[2 * RATE_MULTIPLIER * AUDIO_FRAMES_PER_USB_FRAME][CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX];
+ samp_t usb_audio_frames[2 * RATE_MULTIPLIER * AUDIO_FRAMES_PER_USB_MICS_FRAME][CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX];
/*
* Copying XUA_lite logic basically verbatim - if the host is streaming out,
@@ -642,7 +643,7 @@ bool tud_audio_tx_done_pre_load_cb(uint8_t rhport,
* This assumes (as with XUA_lite) that the host sends the same number of samples for each channel.
* This also assumes that TX and RX rates are the same, which is an assumption made elsewhere.
* This finally assumes that at nominal rate,
- * AUDIO_FRAMES_PER_USB_FRAME == prev_n_bytes_received / (CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX * sizeof(samp_t))
+ * AUDIO_FRAMES_PER_USB_MICS_FRAME == prev_n_bytes_received / (CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX * sizeof(samp_t))
*/
if (host_streaming_out && (0 != prev_n_bytes_received))
{
@@ -650,10 +651,11 @@ bool tud_audio_tx_done_pre_load_cb(uint8_t rhport,
}
else
{
- tx_size_bytes = sizeof(samp_t) * AUDIO_FRAMES_PER_USB_FRAME * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX;
+ tx_size_bytes = sizeof(samp_t) * AUDIO_FRAMES_PER_USB_MICS_FRAME * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX;
}
tx_size_frames = tx_size_bytes / (sizeof(samp_t) * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX);
+
if (!mic_interface_open) {
ready = 0;
mic_interface_open = true;
@@ -817,7 +819,7 @@ void usb_audio_init(rtos_intertile_t *intertile_ctx,
* Note: Given the way that the USB callback notifies usb_audio_out_task,
* the size of this buffer MUST NOT be greater than 2 VFE frames.
*/
- samples_from_host_stream_buf = xStreamBufferCreate(2 * sizeof(samp_t) * appconfAUDIO_PIPELINE_FRAME_ADVANCE * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX,
+ samples_from_host_stream_buf = xStreamBufferCreate(2 * sizeof(samp_t) * appconfAUDIO_SPK_PIPELINE_FRAME_ADVANCE * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX,
0);
/*
diff --git a/tests/test_hw_sat1_firmware/README.md b/tests/test_hw_sat1_firmware/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/tests/test_hw_sat1_firmware/__init__.py b/tests/test_hw_sat1_firmware/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/test_hw_sat1_firmware/conftest.py b/tests/test_hw_sat1_firmware/conftest.py
new file mode 100644
index 0000000..ccb12c9
--- /dev/null
+++ b/tests/test_hw_sat1_firmware/conftest.py
@@ -0,0 +1,67 @@
+import pytest
+from pathlib import Path
+
+from orbit.builder.xmos import build_firmware, reset_device
+from orbit.testing.xmos import run_firmware
+from orbit import BOARD_XTAG_IDS, BOARD_USB_IDS
+from tests import PROJ_ROOT
+from tests.conftest import HW_TESTS
+
+import time
+
+BOARD = "Satellite1"
+VARIANT = "satellite1_firmware_fixed_delay"
+BUILD_DIR = "build_test_satellite1_firmware_fixed_delay"
+
+@pytest.fixture(scope="session", autouse=True)
+def setup_firmware():
+ """Build Satellite1 firmware and run it using xrun."""
+
+ if HW_TESTS != "build_and_xrun":
+ yield
+ return
+
+ try:
+ build_firmware(
+ build_dir=BUILD_DIR,
+ src_dir=PROJ_ROOT,
+ variant=f"create_upgrade_img_{VARIANT}",
+ clean=False,
+ defines=[]
+ )
+ except Exception as e:
+ pytest.exit(f"Firmware build failed: {e}")
+
+ target = PROJ_ROOT / BUILD_DIR / f"{VARIANT}.upgrade.bin"
+ if not target.exists():
+ pytest.exit(f"Firmware build failed, target not found: {target}")
+
+ print("Running firmware with xrun...")
+ target_xe = PROJ_ROOT / BUILD_DIR / f"{VARIANT}.xe"
+
+ reset_device(BOARD_XTAG_IDS[BOARD])
+ pid = run_firmware(
+ firmware=target_xe,
+ xtag_id=BOARD_XTAG_IDS[BOARD],
+ )
+
+ # Wait for firmware to start
+ time.sleep(5)
+
+ yield # Tests execute here
+
+ print("Stopping xrun...")
+ pid.terminate()
+
+
+@pytest.fixture(scope="session")
+def upgrade_image() -> Path:
+ return PROJ_ROOT / BUILD_DIR / f"{VARIANT}.upgrade.bin"
+
+@pytest.fixture(scope="session")
+def xtag_id() -> str:
+ return BOARD_XTAG_IDS[BOARD]
+
+@pytest.fixture(scope="session")
+def usb_dev_id() -> str:
+ return BOARD_USB_IDS[BOARD]
\ No newline at end of file
diff --git a/tests/test_hw_sat1_firmware/test_usb_dfu.py b/tests/test_hw_sat1_firmware/test_usb_dfu.py
new file mode 100644
index 0000000..012d0db
--- /dev/null
+++ b/tests/test_hw_sat1_firmware/test_usb_dfu.py
@@ -0,0 +1,24 @@
+import pytest
+from pathlib import Path
+import filecmp
+from orbit.builder.xmos import usb_dfu_upload, usb_dfu_download
+import os
+
+from tests.conftest import HW_TESTS
+
+@pytest.mark.skipif( HW_TESTS is None, reason="Hardware tests disabled")
+def test_usb_dfu(upgrade_image:Path, usb_dev_id:str) -> None:
+ assert( upgrade_image.exists() )
+
+ usb_dfu_upload( usb_dev_id, upgrade_image, reset=False )
+ download_file = upgrade_image.with_suffix(".download.bin")
+ if download_file.exists():
+ os.remove( download_file )
+ usb_dfu_download( usb_dev_id, download_file )
+ assert( filecmp.cmp(upgrade_image, download_file) )
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/ci/firmwares.txt b/tools/ci/firmwares.txt
index f5f84eb..bbbb2f4 100644
--- a/tools/ci/firmwares.txt
+++ b/tools/ci/firmwares.txt
@@ -1 +1,2 @@
-satellite1_fixed satellite1_firmware_fixed_delay No SATELLITE1 xmos_cmake_toolchain/xs3a.cmake
\ No newline at end of file
+satellite1_fixed satellite1_firmware_fixed_delay No SATELLITE1 xmos_cmake_toolchain/xs3a.cmake
+usb_ns_only satellite1_usb_firmware_ns No SATELLITE1 xmos_cmake_toolchain/xs3a.cmake
\ No newline at end of file