diff --git a/CHANGELOG.md b/CHANGELOG.md index a16ac26..44477e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 5.4.0 + * Add support for XVF3800 + * rename setup_dac.py to setup_io_exp_and_dac.py + * Fixed documentation to state use of 12.288MHz instead of 24.576MHz mclk * Fix and document MCLK phase issue found on raspberry pi 3b ## 5.3.0 diff --git a/README.md b/README.md index 9800028..c7983cb 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ This setup will perform the following operations: For XVF3510-INT devices these actions will be done as well: -- configure MCLK at 24576kHz from pin 7 (BCM 4) -- configure I2S BCLK at 3072kHz from pin 12 (BCM18) +- configure MCLK at 12288kHz from pin 7 (BCM 4) +- configure I2S BCLK at 3072kHz from pin 12 (BCM 18) - update the alias for Audacity - update the asoundrc file to support I2S devices - add a cron job to reset the device at boot up @@ -26,12 +26,21 @@ For XVF3510-INT devices these actions will be done as well: For XVF361x-INT devices these actions will be done as well: - configure MCLK at 12288kHz from pin 7 (BCM 4) -- configure I2S BCLK at 3072kHz from pin 12 (BCM18) +- configure I2S BCLK at 3072kHz from pin 12 (BCM 18) - update the alias for Audacity - update the asoundrc file to support I2S devices - add a cron job to reset the device at boot up - add a cron job to configure the DAC at boot up +For XVF3800(ALL) devices these actions will be done as well: + +- configure MCLK at 12288kHz from pin 7 (BCM 4) +- configure I2S BCLK at 3072kHz from pin 12 (BCM 18) +- update the alias for Audacity +- update the asoundrc file to support I2S devices +- add a cron job to reset the device at boot up +- add a cron job to configure the IO expander at boot up + For XVF3510-UA and XVF361x-UA devices these actions will be done as well: - update the asoundrc file to support USB devices @@ -101,6 +110,15 @@ For XVF3510-UA and XVF361x-UA devices these actions will be done as well: ```./setup.sh xvf3615-int``` + For XVF3800-INTDEV devices, run the installation script as follows: + + ```./setup.sh xvf3800-intdev``` + + For XVF3800-INTHOST devices, run the installation script as follows: + + ```./setup.sh xvf3800-inthost``` + + Wait for the script to complete the installation. This can take several minutes. 5. Reboot the Raspberry Pi. @@ -119,5 +137,5 @@ write it's own value to the clocks and the MCLK will no longer be phase locked. the following steps must be taken before connecting an XVF device with a different sample rate: 1. Take a short recording at the new sample rate: `arecord -c2 -fS32_LE -r{sample_rate} -s1 -Dhw:sndrpisimplecar` -2. For 48kHz `./resources/clk_dac_setup/setup_blk`, for 16kHz `./resources/clk_dac_setup/setup_blk` +2. For 48kHz `./resources/clk_dac_setup/setup_blk`, for 16kHz `./resources/clk_dac_setup/setup_blk 16000` diff --git a/resources/clk_dac_setup/setup_dac.py b/resources/clk_dac_setup/setup_io_exp_and_dac.py similarity index 78% rename from resources/clk_dac_setup/setup_dac.py rename to resources/clk_dac_setup/setup_io_exp_and_dac.py index 3c40794..4df2aab 100644 --- a/resources/clk_dac_setup/setup_dac.py +++ b/resources/clk_dac_setup/setup_io_exp_and_dac.py @@ -1,44 +1,42 @@ #!usr/bin/python -# Copyright (c) 2018-2022, XMOS Ltd, All rights reserved +# Copyright (c) 2018-2023, XMOS Ltd, All rights reserved -#run this on the raspberry pi to program the DAC +# run this on the raspberry pi to setup the IO expander and program the DAC (DAC setup for non-xvf3800 only) import argparse import smbus import time -def setup_dac(args): +def setup_io_expander(bus, args): """ - Function to configure DAC of XVF boards + Function to setup the I2C IO expander of XVF boards Args: + bus - I2C access object args - command line arguments Returns: None """ - - samFreq = 48000 - bus = smbus.SMBus(1) - + # I2C expander bus address for XVF36XX and XVF3800 with PCAL6408A expander device I2C_EXPANDER_ADDRESS = 0x20 - if "xvf36" in args.hw: + # I2C expander register addresses + I2C_EXPANDER_OUTPUT_PORT_REG = 0x01 + I2C_EXPANDER_CONFIGURATION_REG = 0x03 + I2C_EXPANDER_INTERRUPT_MASK_REG = 0x45 + + # I2C expander pin mapping + XVF_RST_N_PIN = 0 + INT_N_PIN = 1 + DAC_RST_N_PIN = 2 + BOOT_SEL_PIN = 3 + MCLK_OE_PIN = 4 + SPI_OE_PIN = 5 + I2S_OE_PIN = 6 + MUTE_PIN = 7 - # I2C expander register addresses - I2C_EXPANDER_OUTPUT_PORT_REG = 0x01 - I2C_EXPANDER_CONFIGURATION_REG = 0x03 - I2C_EXPANDER_INTERRUPT_MASK_REG = 0x45 - - # I2C expander pins - XVF_RST_N_PIN = 0 - INT_N_PIN = 1 - DAC_RST_N_PIN = 2 - BOOT_SEL_PIN = 3 - MCLK_OE_PIN = 4 - SPI_OE_PIN = 5 - I2S_OE_PIN = 6 - MUTE_PIN = 7 + if "xvf36" in args.hw: # Set pin values # set DAC_RST_N to 0 and enable level shifters on the I2C expander @@ -79,6 +77,36 @@ def setup_dac(args): bus.write_byte_data(I2C_EXPANDER_ADDRESS, I2C_EXPANDER_OUTPUT_PORT_REG, OUTPUT_PORT_MASK | (1< /dev/null make popd > /dev/null @@ -248,11 +258,11 @@ if [[ -n "$DAC_SETUP" ]]; then echo "sudo $RPI_SETUP_DIR/resources/clk_dac_setup/setup_bclk" >> $dac_and_clks_script fi # Note that only the substring xvfXXXX from $XMOS_DEVICE is used in the lines below - echo "python $RPI_SETUP_DIR/resources/clk_dac_setup/setup_dac.py $(echo $XMOS_DEVICE | cut -c1-7)" >> $dac_and_clks_script + echo "python $RPI_SETUP_DIR/resources/clk_dac_setup/setup_io_exp_and_dac.py $(echo $XMOS_DEVICE | cut -c1-7)" >> $dac_and_clks_script echo "python $RPI_SETUP_DIR/resources/clk_dac_setup/reset_xvf.py $(echo $XMOS_DEVICE | cut -c1-7)" >> $dac_and_clks_script fi -if [[ -n "$DAC_SETUP" ]]; then +if [[ -n "$IO_EXP_AND_DAC_SETUP" ]]; then audacity_script=$RPI_SETUP_DIR/resources/run_audacity.sh rm -f $audacity_script echo "#!/usr/bin/env bash" >> $audacity_script @@ -276,11 +286,11 @@ fi rm -f $crontab_file # Setup the crontab to restart I2S at reboot -if [ -n "$I2S_MODE" ] || [ -n "$DAC_SETUP" ]; then +if [ -n "$I2S_MODE" ] || [ -n "$IO_EXP_AND_DAC_SETUP" ]; then if [[ -n "$I2S_MODE" ]]; then echo "@reboot sh $i2s_driver_script" >> $crontab_file fi - if [[ -n "$DAC_SETUP" ]]; then + if [[ -n "$IO_EXP_AND_DAC_SETUP" ]]; then echo "@reboot sh $dac_and_clks_script" >> $crontab_file fi popd > /dev/null