Skip to content

Commit

Permalink
Merge pull request #35 from xmos/feature/refactor_i2c_gpio_setup
Browse files Browse the repository at this point in the history
Rename vars and add comments
  • Loading branch information
xluciano authored Nov 5, 2021
2 parents 3dc8d93 + b2ee3bb commit e454db1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# VocalFusion Raspberry Pi Setup Change Log

## 4.3.1

* Fix comments and reg names in setup_dac.py

## 4.3.0

* Added support for xvf3610 EVK board
Expand Down
12 changes: 6 additions & 6 deletions resources/clk_dac_setup/setup_dac.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def setup_dac(args):
if args.hw == "xvf3600" or args.hw == "xvf3610" :

# I2C expander register addresses
I2C_EXPANDER_INPUT_PORT_REG = 0x01
I2C_EXPANDER_OUTPUT_PORT_REG = 0x02
I2C_EXPANDER_OUTPUT_PORT_REG = 0x01
I2C_EXPANDER_CONFIGURATION_REG = 0x03
I2C_EXPANDER_INTERRUPT_MASK_REG = 0x45

Expand All @@ -43,17 +42,18 @@ def setup_dac(args):

# Set pin values
# set DAC_RST_N to 0 and enable level shifters on the I2C expander
INPUT_PORT_MASK = (1<<XVF_RST_N_PIN) | \
OUTPUT_PORT_MASK= (1<<XVF_RST_N_PIN) | \
(1<<INT_N_PIN) | \
(1<<BOOT_SEL_PIN) | \
(1<<MCLK_OE_PIN) | \
(1<<SPI_OE_PIN) | \
(1<<I2S_OE_PIN) | \
(1<<MUTE_PIN)

bus.write_byte_data(I2C_EXPANDER_ADDRESS, I2C_EXPANDER_INPUT_PORT_REG, INPUT_PORT_MASK)
bus.write_byte_data(I2C_EXPANDER_ADDRESS, I2C_EXPANDER_OUTPUT_PORT_REG, OUTPUT_PORT_MASK)
time.sleep(0.1)
# Configure pin directions:
# Configure pin directions. Setting to 1 means input, or Hi-Z. So anything not mentioned
# below will be an output. Note reset, int and boot_sel NOT driven because they are set high in the mask
# use DAC_RST_N and level shift OE as driven outputs
# Configure the mute pin as input only for XVF3610
if args.hw == "xvf3600":
Expand All @@ -76,7 +76,7 @@ def setup_dac(args):
bus.write_byte_data(I2C_EXPANDER_ADDRESS, I2C_EXPANDER_INTERRUPT_MASK_REG, INTERRUPT_MASK)

# Reset the DAC
bus.write_byte_data(I2C_EXPANDER_ADDRESS, I2C_EXPANDER_INPUT_PORT_REG, INPUT_PORT_MASK | (1<<DAC_RST_N_PIN))
bus.write_byte_data(I2C_EXPANDER_ADDRESS, I2C_EXPANDER_OUTPUT_PORT_REG, OUTPUT_PORT_MASK | (1<<DAC_RST_N_PIN))
time.sleep(0.1)

else:
Expand Down

0 comments on commit e454db1

Please sign in to comment.