
Im trying to use the vs1010d devboard to comunicate to other microcontroller via SPI comunnication.
The other microcontroller is set as MASTER and im trying to set de vs1010d as slave.
To make the comunnication between the two controllers work, first i disable de tv, configure the vs1010d as slave, and enable the SPI1 interrupts, i then tried using the spi interrupt as shown in the code bellow i learned from the forum. The code is meant to read the spi1 receiving data and storing it to a buffer.
Code: Select all
#include <vo_stdio.h>
#include <volink.h> // Linker directives like DLLENTRY
#include <apploader.h> // RunLibraryFunction etc
#include <vs1010dRom.h>
#include <vo_gpio.h>
#include <vs1010c.h>
#include <playerinfo.h>
#include <string.h>
#include <protocol.h>
#include <spitv.h>
#include <vs1010_pins.h>
#include <lcd.h>
#include <devboard.h>
#include <audio.h>
int cnt=0;
#define SPI_BUF_SIZE 128
u_int16 spi_buf[SPI_BUF_SIZE] = {0};
u_int16 bufhead = 0;
u_int16 buftail = 0;
u_int16 rx_dat;
void InitSpiSlave()
{
GpioSetAsPeripheral(0x14); //Set GPIO1.4 as MOSI1
GpioSetAsPeripheral(0x15);
GpioSetAsPeripheral(0x16);
GpioSetAsPeripheral(0x17);
PERIP(SPI1_CF) = SPI_CF_SRESET|SPI_CF_RXFIFO_ENA|SPI_CF_SLAVE|SPI_CF_DLEN16;
PERIP(SPI1_DATA) = 0;
PERIP(INT_ENABLE0_HP)|= INTF_SPI1; //Enable interrupt
PERIP(INT_ENABLE0_LP)|= INTF_SPI1; //Enable interrupt
}
#pragma interrupt y 0x24
void SPI1_INT(void) {
while(SPI_ST_RXFULL & PERIP(SPI1_STATUS)){
rx_dat = PERIP(SPI1_DATA);
cnt=cnt+2;
if ((buftail + 1) % SPI_BUF_SIZE != bufhead) {
spi_buf[buftail] = rx_dat;
buftail = (buftail + 1) % SPI_BUF_SIZE;
}
}
}
void print_spi_buf(void)
{
while (buftail != bufhead) {
printf("SPI MOSI-->%x\n",spi_buf[bufhead]);
bufhead = (bufhead + 1)% SPI_BUF_SIZE;// % SPI_BUF_SIZE;
printf("cnt-->%d\n",cnt);
}
cnt=0;
}
ioresult main (char *params) ///Função main
{
PERIP(INT_ENABLE0_HP)&= ~(INTF_SPI1);
PERIP(INT_ENABLE0_LP)&= ~ (INTF_SPI1);
SetJmpiHookFunction((void*)102,VoidVoid);
lcd0.clipy2 = 0; // Disable tv buffer and tv-out
InitSpiSlave();
while(1){
DelayL(10);
print_spi_buf();
}
return S_OK;///Return OK
}
Did anybody came across with this problem, the spi1 interruption not working? Is it possible to set the vs1010 as SLAVE using the custom hardware driver for the SPI1?