VS1005 - Utilising the NFCE/GPIO0_11 Pin as a GPIO

Discussion about writing software for VS1005 and the VSOS Operating System. Also posts about VS1005-related hardware design and device drivers should be posted here.
Post Reply
gtc607
User
Posts: 5
Joined: Mon 2017-01-16 15:30

VS1005 - Utilising the NFCE/GPIO0_11 Pin as a GPIO

Post by gtc607 » Wed 2019-06-05 13:48

Hello,

We currently use the VS1005 on our own custom board, working as a slave to carry out all of the audio/usb/sd card related functions for our device. Historically, the NFCE/GPIO0_11 pin (26) on our schematic wasn't connected to anything (just pulled high) with the option to mount a resistor that could then be used to control another module that we use.

We made a change to the board that meant this pin is now needed to be used by our software as a general toggle high/low pin, which is when I started observing some issues. I intended to keep this pin low until required by our application, but noticed that it wouldn't persist. In particular, it would go high when loading the SD card or any USB sticks. Currently the code utilises:

Code: Select all

GpioSetPin(0x0b, 0);
to change the pin state.

Reading the datasheet, I came across this statement:
The VSOS Kernel needs to use the following pins:
•XCS0 (GPIO 1_1, the SPI flash chip select), NFCE (GPIO0_11, the NAND flash chip select) and GPIO1_15 (the LCD display chip select) for various purposes, and the kernel presumes that there is a 74HC138 address decoder connected to these pins so the kernel constantly writes to all three.
Whoops! So I now understand why it might not have been behaving correctly. I admit that the best solution would be to utilise another free pin, which we intend to implement on future boards. However, in the meantime - is there any way of working around this issue, such that the pin can be fully controlled by our application?

Many thanks in advance,

George

Hannu
Senior User
Posts: 66
Joined: Mon 2016-05-30 11:54

Re: VS1005 - Utilising the NFCE/GPIO0_11 Pin as a GPIO

Post by Hannu » Wed 2019-06-05 15:06

Hello and welcome to the VSDSP forum.

The kernel is trying to control power of your SD card and other devices It tries uses those three named pins. You need your own custom kernel. Rewrite DefaultSetPower() function from power_devboard.c.

If your drivers use iochannel features of some device drivers, then again the NFCE might toggle. So check those too.

gtc607
User
Posts: 5
Joined: Mon 2017-01-16 15:30

Re: VS1005 - Utilising the NFCE/GPIO0_11 Pin as a GPIO

Post by gtc607 » Thu 2019-06-06 17:26

Ah brilliant, that seems to have done the trick!

So as I understand it, those three pins are primarily used by the development board to control the 74HC138D, where as our custom board doesn't include this section. Therefore, the references to setting these pins in the kernel can be modified without any adverse effects?

Many thanks for your help,

George

Hannu
Senior User
Posts: 66
Joined: Mon 2016-05-30 11:54

Re: VS1005 - Utilising the NFCE/GPIO0_11 Pin as a GPIO

Post by Hannu » Fri 2019-06-07 8:42

You are quite correct. The demux controls many chip selects and one of the selction lines is the power latch. That's why the SetPower vector is changing the state of CE pin.

With a quick look I found devByteBus and devHwSpi supporting iochannels. Even if you were using those drivers, setting real CS pin, disables the iochannel feature. So not much to worry about from there then.

Actually, you don't need custom kernel. Have a look on ampbconf from root, libs and sources package for VSOS 3.57 viewtopic.php?f=13&t=680&p=12684#p12650 The SetHandler function does the trick.

gtc607
User
Posts: 5
Joined: Mon 2017-01-16 15:30

Re: VS1005 - Utilising the NFCE/GPIO0_11 Pin as a GPIO

Post by gtc607 » Fri 2019-06-07 13:11

Hannu wrote:
Fri 2019-06-07 8:42
Actually, you don't need custom kernel. Have a look on ampbconf from root, libs and sources package for VSOS 3.57 viewtopic.php?f=13&t=680&p=12684#p12650 The SetHandler function does the trick.
Even better! This seems like the best option, so that we don't have to remember to modify the Kernel every time an update arrives :lol:

Thank you for your assistance!

User avatar
Panu
VLSI Staff
Posts: 2674
Joined: Tue 2010-06-22 13:43

Re: VS1005 - Utilising the NFCE/GPIO0_11 Pin as a GPIO

Post by Panu » Sun 2019-06-09 19:00

Hi!

Hmm, the kernel initializes the external SPI flash to be at IOCHANNEL 3, so you'll at the very least need to poke the DevHwSpiHwInfo of struct device_descriptor spi to use just the XCS0 IO pin. That can be done by a custom small app that you run from the config.txt, but it's not exceedingly simple.

Here's the code from vsos_vs1005h.c for your reference. You could make a variation of it: declare a hwinfo that uses the single pin and then call DevHwSpiCreate with the first parameter from spiFlash's ph, which you can find from vo_pdevices['S'-'A']->hwInfo[0]. That would essentially recreate the spiBus device. Another alternative is to further track down the hwInfo of the spi bus device and just poke it to use the GPIO pin. But as you see, both the spi bus device and the spi flash device are declared as static; there's no global symbol that points to them: the only way is to follow the s: device pointer to find spiFlash and then spiFlash's ph (physical bus) member from the spiFlash's hwInfo to get the address of the spi bus device in memory. It's rather simple in fact, but tedious to write...

Code: Select all

		static DEVICE spiFlash; // this SPI flash device (only one flash per design is supported)
		static DEVICE spi; // the SPI bus used to connect to this SPI flash
		static const devHwSpiHwInfo hwInfo = {
			(__y spiRegisters*)SPI0_CF, // register base; spiRegisters *regs;
			CSPIN_USE_IOCHANNEL, // CS pin
			3, // io channel number (74HC138 address decoder select pattern)
			6144, // Maximum clock in kHz
		};
		SysReport("External SPI Flash");
		DevHwSpiCreate (&spi, &hwInfo, 0);
		DevSpiFlashCreate(&spiFlash, &spi, 2048); //SPI flash size 2 megabytes (2048 kilobytes)
		vo_pdevices['S'-'A'] = &spiFlash;
It's quite possible that there may be spurious calls to set iochannel idle lurking somewhere in the kernel and/or apps or drivers, please beware.

.Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

gtc607
User
Posts: 5
Joined: Mon 2017-01-16 15:30

Re: VS1005 - Utilising the NFCE/GPIO0_11 Pin as a GPIO

Post by gtc607 » Mon 2019-06-10 12:20

Hi Panu!

In our case, we are using the kernel configured to use the internal flash - will the same thought process apply?

It appears that we are having some success with using the SetHandler function to modify SetPower, as discussed earlier.I have been monitoring the GPIO0_11 pin for our use case and so far haven't observed any unexpected state changes!

George

User avatar
Panu
VLSI Staff
Posts: 2674
Joined: Tue 2010-06-22 13:43

Re: VS1005 - Utilising the NFCE/GPIO0_11 Pin as a GPIO

Post by Panu » Wed 2019-06-12 9:11

Ok, the internal flash doesn't use IOCHANNEL so that's one less thing to worry about. Great if it works for you, hopefully there will be no problems.

-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Post Reply