Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for l71 voice board #31

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
lib_board_support change log
============================

1.2.0
-----

* ADDED: Support for XK-VOICE-L71

1.1.1
-----

Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lib_board_support: XMOS board support
#####################################

:vendor: XMOS
:version: 1.1.1
:version: 1.2.0
:scope: General Use
:description: Support library for XMOS development kits
:category: General Purpose
Expand All @@ -27,6 +27,7 @@ Features
* ``XK_EVK_XU316``
* ``XK_AUDIO_316_MC``
* ``XK_AUDIO_216_MC``
* ``XK-VOICE-L71``
* Simple examples to demonstrating usage from both `XC` and `C`.

************
Expand Down
3 changes: 3 additions & 0 deletions doc/rst/lib_board_support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The following boards are supported in this repo with interfaces provided in the
+--------------------+---------------------+
|XK_AUDIO_216_MC_AB | XC / C |
+--------------------+---------------------+
|XK-VOICE-L71 | XC / C |
+--------------------+---------------------+

The following section provides specific details of the features for each of the boards supported by this library.

Expand All @@ -32,6 +34,7 @@ The following section provides specific details of the features for each of the
xk_audio_316_mc_ab/hw_316_mc
xk_audio_216_mc_ab/hw_216_mc
xk_evk_xu316/hw_evk_xu316
xk_voice_l71/hw_xk_voice_l71.rst

*****
Usage
Expand Down
20 changes: 20 additions & 0 deletions doc/rst/xk_voice_l71/hw_xk_voice_l71.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

XK-VOICE-L71 Voice Reference Design Evaluation Kit
==================================================

OVERVIEW

The voice reference design evaluation kit can be used as a Raspberry Pi HAT for integration with example AVS client or used standalone as a USB accessory to a host system.

Features include:

- XU316-1024-QF60A-C24 xcore.ai processor
- Raspberry Pi HAT connector
- 2 x Infineon IM69D130 MEMS mics
- 71mm inter-mic spacing
- Microphone mute switch
- Speaker output (Line level)
- USB / I2S host interface support


For further information and detailed documentation please follow this link `xk-voice-l71 <https://www.xmos.com/xk-voice-l71>`_
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ project(lib_board_support)
add_subdirectory(app_xk_audio_316_mc_simple_xc)
add_subdirectory(app_evk_316_simple_c)
add_subdirectory(app_xk_audio_316_mc_simple_c)
add_subdirectory(app_xk_voice_l71_simple_c)
35 changes: 35 additions & 0 deletions examples/app_xk_voice_l71_i2s_c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(app_xk_voice_71_simple_c)

set(APP_HW_TARGET src/xk-voice-l71.xn)

include(../deps.cmake)

set(APP_COMPILER_FLAGS -Os
-g
-report
-DBOARD_SUPPORT_BOARD=XK_VOICE_L71)


# Fetch I2S from fwk_io
set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)

set(XMOS_DEP_DIR_i2s ${XMOS_SANDBOX_DIR}/fwk_io/modules)
if(NOT EXISTS ${XMOS_SANDBOX_DIR}/fwk_io)
include(FetchContent)
FetchContent_Declare(
fwk_io
GIT_REPOSITORY [email protected]:xmos/fwk_io
GIT_TAG feature/xcommon_cmake
SOURCE_DIR ${XMOS_SANDBOX_DIR}/fwk_io
)
message(STATUS Fetching fwk_io)
FetchContent_Populate(fwk_io)
endif()

list(APPEND APP_DEPENDENT_MODULES "i2s")

set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)

XMOS_REGISTER_APP()
2 changes: 2 additions & 0 deletions examples/app_xk_voice_l71_i2s_c/src/config.xscope
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<xSCOPEconfig ioMode="basic" enabled="true">
</xSCOPEconfig>
146 changes: 146 additions & 0 deletions examples/app_xk_voice_l71_i2s_c/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// Copyright 2024 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.

#include <stdio.h>
#include <xcore/channel.h>
#include "xk_voice_l71/board.h"

#include <stdlib.h>
#include <math.h>
#include <xscope.h>
#include <xs1.h>
#include <xclib.h>
#include <xcore/assert.h>
#include <platform.h>

#include "sw_pll.h"
#include "i2s.h"

#define MCLK_FREQUENCY 24576000
#define I2S_FREQUENCY 48000
#define N_SINE 16

#define NUM_I2S_CHANNELS 2
#define NUM_I2S_LINES ((NUM_I2S_CHANNELS + 1) / 2)


// Board configuration from lib_board_support
static const xk_voice_l71_config_t hw_config = {
CLK_FIXED,
1, // DAC is clock master
MCLK_FREQUENCY,
};


typedef struct i2s_callback_args_t {
bool did_restart; // Set by init
int sine_table[N_SINE];
unsigned counter;
} i2s_callback_args_t;



I2S_CALLBACK_ATTR
static void i2s_init(void *app_data, i2s_config_t *i2s_config){
printf("I2S init\n");
i2s_callback_args_t *cb_args = app_data;

i2s_config->mode = I2S_MODE_I2S;
i2s_config->mclk_bclk_ratio = (MCLK_FREQUENCY / (I2S_FREQUENCY * 32 * 2));
printf("I2S mclk:bclk Ratio: %u\n", i2s_config->mclk_bclk_ratio);

for(int i = 0; i < N_SINE; i++){
cb_args->sine_table[i] = (1 << 30) * sin(6.2831853072 * i / N_SINE);
}

cb_args->did_restart = true;
}

I2S_CALLBACK_ATTR
static i2s_restart_t i2s_restart_check(void *app_data){
i2s_callback_args_t *cb_args = app_data;
(void)cb_args;

return I2S_NO_RESTART;
}


I2S_CALLBACK_ATTR
static void i2s_send(void *app_data, size_t num_out, int32_t *i2s_sample_buf){
i2s_callback_args_t *cb_args = app_data;

for(int i = 0; i < num_out; i++){
i2s_sample_buf[i] = cb_args->sine_table[cb_args->counter];
// printf("%ld\n", clz(i2s_sample_buf[i]));
}
if(++(cb_args->counter) == N_SINE){
cb_args->counter = 0;
}
}

I2S_CALLBACK_ATTR
static void i2s_receive(void *app_data, size_t num_in, const int32_t *i2s_sample_buf){
i2s_callback_args_t *cb_args = app_data;
(void)cb_args;
}


void i2s_tone_gen(void){

// I2S resources
port_t p_i2s_dout[NUM_I2S_LINES] = {PORT_I2S_DAC0};
port_t p_i2s_din[NUM_I2S_LINES] = {PORT_I2S_ADC0};
port_t p_bclk = PORT_I2S_BCLK;
port_t p_mclk = PORT_MCLK_IN;
port_t p_lrclk = PORT_I2S_LRCLK;
xclock_t i2s_ck_bclk = XS1_CLKBLK_1;

port_enable(p_bclk);
// NOTE: p_lrclk does not need to be enabled by the caller



// Initialise app_data
i2s_callback_args_t app_data = {
.did_restart = false,
.sine_table = {0},
.counter = 0
};

// Initialise callback function pointers
i2s_callback_group_t i2s_cb_group;
i2s_cb_group.init = i2s_init;
i2s_cb_group.restart_check = i2s_restart_check;
i2s_cb_group.receive = i2s_receive;
i2s_cb_group.send = i2s_send;
i2s_cb_group.app_data = &app_data;

printf("Starting I2S master\n");

i2s_master(
&i2s_cb_group,
p_i2s_dout,
NUM_I2S_LINES,
p_i2s_din,
NUM_I2S_LINES,
p_bclk,
p_lrclk,
p_mclk,
i2s_ck_bclk);
}

void tile_0_main(chanend_t c){
printf("Hello from tile[0]\n");
xk_voice_l71_AudioHwRemote(c); // Startup remote I2C master server task
printf("Bye from tile[0]\n");
}

void tile_1_main(chanend_t c){
printf("Hello from tile[1]\n");
xk_voice_l71_AudioHwChanInit(c);
xk_voice_l71_AudioHwInit(&hw_config);
// xk_voice_l71_AudioHwConfig(&hw_config, I2S_FREQUENCY, MCLK_FREQUENCY);
i2s_tone_gen();
chan_out_word(c, AUDIOHW_CMD_EXIT); // Kill the remote config task
printf("Bye from tile[1]\n");
}
17 changes: 17 additions & 0 deletions examples/app_xk_voice_l71_i2s_c/src/top_level.xc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2024 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.

#include <platform.h>

extern void tile_0_main(chanend c);
extern void tile_1_main(chanend c);

int main(void){
chan c;
par{
on tile[0]: tile_0_main(c);
on tile[1]: tile_1_main(c);
}

return 0;
}
103 changes: 103 additions & 0 deletions examples/app_xk_voice_l71_i2s_c/src/xk-voice-l71.xn
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
<Declarations>
<Declaration>tileref tile[2]</Declaration>
<Declaration>tileref usb_tile</Declaration>
</Declarations>

<Packages>
<Package id="0" Type="XS3-UnA-1024-QF60A">
<Nodes>
<!-- Note that this clock setting is overridden by the app by writing directly to the PLL -->
<Node Id="0" InPackageId="0" Type="XS3-L16A-1024" SystemFrequency="800MHz" Oscillator="24MHz" referencefrequency="100MHz">
<Boot>
<Source Location="bootFlash"/>
</Boot>
<!-- <Extmem sizeMbit="1024" Frequency="175MHz">
<Padctrl clk="0x0" cke="0x0" cs_n="0x0" we_n="0x0" cas_n="0x0" ras_n="0x0" addr="0x0" ba="0x0" dq="0x0" dqs="0x0" dm="0x0"/>
<Lpddr lmr_opcode="0x0" emr_opcode="0x0"/>
</Extmem> -->
<Tile Number="0" Reference="tile[0]">
<!-- QSPI ports -->
<Port Location="XS1_PORT_1B" Name="PORT_SQI_CS_0"/>
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK_0"/>
<Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO_0"/>

<!-- SPI ports -->
<Port Location="XS1_PORT_1A" Name="PORT_SSB"/>
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK_0"/>
<!--
<Port Location="XS1_PORT_1D" Name="PORT_SPI_MOSI"/>
-->

<Port Location="XS1_PORT_1P" Name="PORT_SPI_MISO"/>

<!-- I2C ports -->
<Port Location="XS1_PORT_1N" Name="PORT_I2C_SCL"/>
<Port Location="XS1_PORT_1O" Name="PORT_I2C_SDA"/>

<!-- GPIO ports -->
<Port Location="XS1_PORT_8C" Name="PORT_GPO"/>
<Port Location="XS1_PORT_8D" Name="PORT_GPI"/>

<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT"/>
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN_USB"/>

<!-- Used for keeping XUA happy only -->
<Port Location="XS1_PORT_1G" Name="PORT_NOT_IN_PACKAGE_0"/>

</Tile>
<Tile Number="1" Reference="tile[1]">

<!-- MIC related ports -->
<!--
<Port Location="XS1_PORT_1G" Name="PORT_PDM_CLK"/>
<Port Location="XS1_PORT_1F" Name="PORT_PDM_DATA"/>
-->

<!-- Audio ports -->
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN"/> <!-- follow MC naming -->
<Port Location="XS1_PORT_1C" Name="PORT_I2S_BCLK"/>
<Port Location="XS1_PORT_1B" Name="PORT_I2S_LRCLK"/>
<!--
<Port Location="XS1_PORT_1A" Name="I2S_MIC_DATA"/>
-->
<Port Location="XS1_PORT_1G" Name="PORT_I2S_ADC0"/> <!-- follow MC naming -->
<Port Location="XS1_PORT_1K" Name="PORT_I2S_DAC0"/> <!-- K follow MC naming -->

<!-- Used for looping back clocks -->
<Port Location="XS1_PORT_1N" Name="PORT_NOT_IN_PACKAGE_1"/>
</Tile>
</Node>
</Nodes>
</Package>
</Packages>
<Nodes>
<Node Id="2" Type="device:" RoutingId="0x8000">
<Service Id="0" Proto="xscope_host_data(chanend c);">
<Chanend Identifier="c" end="3"/>
</Service>
</Node>
</Nodes>
<Links>
<Link Encoding="2wire" Delays="5clk" Flags="XSCOPE">
<LinkEndpoint NodeId="0" Link="XL0"/>
<LinkEndpoint NodeId="2" Chanend="1"/>
</Link>
</Links>
<ExternalDevices>
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" Type="S25FL116K" PageSize="256" SectorSize="4096" NumPages="32768">
<Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS_0"/>
<Attribute Name="PORT_SQI_SCLK" Value="PORT_SQI_SCLK_0"/>
<Attribute Name="PORT_SQI_SIO" Value="PORT_SQI_SIO_0"/>
<Attribute Name="QE_REGISTER" Value="flash_qe_location_status_reg_0"/>
<!-- <Attribute Name="QE_BIT" Value="flash_qe_bit_6"/> -->
</Device>
</ExternalDevices>
<JTAGChain>
<JTAGDevice NodeId="0"/>
</JTAGChain>

</Network>
5 changes: 4 additions & 1 deletion lib_board_support/api/boards/boards_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
/** Define representing XK-EVK-XU316 board */
#define XK_EVK_XU316 3

/** Define representing XK-EVK-XU316 board */
#define XK_VOICE_L71 4

/** Total number of boards supported by the library */
#define BOARD_SUPPORT_N_BOARDS 4 // max board + 1
#define BOARD_SUPPORT_N_BOARDS 5 // max board + 1

/** Define that should be set to the current board type in use
*
Expand Down
Loading