VS1000 Audio Module SPI application

Writing software that controls the system and peripherals such as displays, SD cards, Buttons, LEDs, Serial Ports etc.
Post Reply
ilamar
User
Posts: 4
Joined: Tue 2015-11-10 14:16

VS1000 Audio Module SPI application

Post by ilamar » Mon 2015-11-23 12:18

Hi
I need to set the device(VS1000 Audio Module) to control a display by SPI.
I saw that I have to use these pins: 12,13,14,17.

May show me the lines of code for the pin configuration (SPI)?
May show me the lines of code to send one byte of data?
There is a library for spi ?

Thanks.

User avatar
pasi
VLSI Staff
Posts: 1416
Joined: Thu 2010-07-15 16:04

Re: VS1000 Audio Module SPI application

Post by pasi » Fri 2015-11-27 14:39

Pin 12 (xCS) is used for the boot SPI FLASH, so it is not adviceable to use it for display.

Are you using the uSD card for audio?

If not, you can use CS2 / SDCD (SD card detect) for the chip select for the display.

Then see the header file dev1000.h for documentation of the display routines (LcdInit through LcdEol) that are provided in the vs1000 developer library (libdev1000.a). They use CS2 for the display.

All of the Lcd routines use the low-level primitive SpiSendReceive().

Here is an example of LcdInit:

Code: Select all

#include <string.h>
#include <dev1000.h>
void LcdInit(register __i0 unsigned char *init) {
    memset(&lcdControl, 0, sizeof(lcdControl));

    PERIP(SPI0_FSYNC) = -1; // keep SPI CS high during transfer!
    PERIP(SPI0_CONFIG) = SPI_CF_MASTER | SPI_CF_DLEN8 | SPI_CF_FSIDLE1; //8-bit mode
    PERIP(SPI0_CLKCONFIG) = SPI_CC_CLKDIV * (1-1); //fastest possible
    PERIP(GPIO1_MODE) |= 0x0e; /* enable SPI pins, except xCS */
    PERIP(GPIO0_MODE) &= ~GPIO0_CS2; //CS2 is GPIO (Display Chip Select)
    PERIP(GPIO0_DDR)  |= GPIO0_CS2; //CS2 is Output
    PERIP(GPIO1_MODE) &= ~GPIO1_SI; //SI is GPIO (Display Command/Data)
    PERIP(GPIO1_DDR)  |= GPIO1_SI; //SI is Output

    LCD_SET_COMMAND_MODE;
    LCD_SELECT;
    while ((short)*init >= 0) {
	SpiSendReceive(*init++);
    }
    LCD_END;
}
lcdControl contains screen position. LCD_SET_COMMAND_MODE is a macro to set a GPIO pin high for command mode, LCD_SELECT asserts chip select of the display and LCD_END deasserts the chip select. (These are defined in dev1000.h .)

The above uses SI for command select. (The code never reads from the display, so MISO of the display is not connected.)

If you use uSD, then you need to use some other pin for chip select (or stop using CS2 as card detect).
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

Post Reply