I need to add SPI capability (transmit only) to the USB Audio 2 DJ Kit. This is to implement digital gain control for 4 x TI PGA2500 microphone preamp ICs. I've imported the spi_master library into the DJ Kit reference design software (version 6.6.0) but am having a problem with the port assignments for the SPI peripheral. It seems that in the spi_master library, the SPI pins (MOSI, MISO, SCLK) need to be assigned separately to individual ports. However, all single-bit ports (1A - 1L) are currently assigned to other critical functions for I2S audio data and clocking. Is there a way to map all of the SPI pins + SSEL to a single 4-bit port such as port 4C or port 4D? If not, then i'm S.O.L with my current design based on the XS1-U8A-64 and will need to scrap it and find another approach (or another vendor!). For cost and board density reasons, it is not possible to upgrade to a higher pin-count part such as the XS1-U8A-128.
Any help with this would be greatly appreciated.
USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)
Can an SPI port be added to DJ Kit?
-
- Newbie
- Posts: 1
- Joined: Thu Dec 20, 2012 10:58 am
-
- XCore Legend
- Posts: 1126
- Joined: Thu May 27, 2010 10:08 am
Each Xmos logical port has a single direction bit. That means a 4b port is either all input or all output. So it's not possible to have MISO, MOSI, SS and SCLK all on the same port (not unless you do some horrible port turn around sampling with series resistors etc..)
So there are some options:
- Use 3b of a 4b port for SS, SCLK and MOSI and ignore MISO (may be OK - the PGA2500 looks pretty simple). Basically a blind write. We do something similar on i2c_single_port
- Use 3b of a 4b port for SS, SCLK and MOSI and use another port (1b of an unused 4b port for example) for MISO
However, as you notice, the XMOS standard IP for SPI assumes 1b ports. Using 1b ports allows for high performance using the built in shift registers.
But in you case speed is not so critical so a "wide port" implementation is OK. But it does mean you will need to write your own SPI master routine using a 4b ports (and maybe another port to read MISO if needed). This shouldn't be too hard and could be done with a FSM (finite state machine) and a timer. Have a look at i2c-sp.xc in i2c_single_port...
The USB audio ref design functions "updateMasterVol" and "updateVol" may be a good place to add this control - they live in endpoint 0.
So there are some options:
- Use 3b of a 4b port for SS, SCLK and MOSI and ignore MISO (may be OK - the PGA2500 looks pretty simple). Basically a blind write. We do something similar on i2c_single_port
- Use 3b of a 4b port for SS, SCLK and MOSI and use another port (1b of an unused 4b port for example) for MISO
However, as you notice, the XMOS standard IP for SPI assumes 1b ports. Using 1b ports allows for high performance using the built in shift registers.
But in you case speed is not so critical so a "wide port" implementation is OK. But it does mean you will need to write your own SPI master routine using a 4b ports (and maybe another port to read MISO if needed). This shouldn't be too hard and could be done with a FSM (finite state machine) and a timer. Have a look at i2c-sp.xc in i2c_single_port...
The USB audio ref design functions "updateMasterVol" and "updateVol" may be a good place to add this control - they live in endpoint 0.