// --------------------------------------------------------------------------------------
//
// SB_ServoSet
//
// --------------------------------------------------------------------------------------
void SB_ZeroToTenOutput (ui8 slaveMask, ui8 *outputLevels )
{
ui32 tempLong = 0;

	// CS the Slave
	SB_CS_Select( slaveMask );

	SSIDataPutNonBlocking(SSI0_BASE, (ui16)('#'<<8 | SB_ZEROTEN_UPDATE));

	// Pack the update
	SSIDataPutNonBlocking(SSI0_BASE, (ui16)(outputLevels[0]<<8 | outputLevels[1]));
	SSIDataPutNonBlocking(SSI0_BASE, (ui16)(outputLevels[2]<<8 | outputLevels[3]));
	SSIDataPutNonBlocking(SSI0_BASE, (ui16)(outputLevels[4]<<8 | outputLevels[5]));
	SSIDataPutNonBlocking(SSI0_BASE, (ui16)(outputLevels[6]<<8 | 0x00));

	// Make sure it's all sent
	while ( SSIBusy(SSI0_BASE) )
	{
		// TODO : Time out
	}

	// Clear data read in
	while(SSIDataGetNonBlocking(SSI0_BASE, &tempLong))
	{

	}

	// Deselect the Slave
	SB_CS_DeSelect( slaveMask );
}
Exemple #2
0
//--------------------------------
void ssi_peripheral::LoadTxFIFO() {
	int32_t nResult = 1;
	for (int nIndex = 0; nResult && (BufferSize > nIndex); nIndex++) {
		nResult = SSIDataPutNonBlocking(m_rSpecification.m_nSSIBase,
				m_nDataTx[nIndex]);
	}
}
int spi_Read(Fd_t fd, unsigned char *pBuff, int len)
{
    int i = 0;
    unsigned long ulBuff;

    ASSERT_CS();

    for(i=0; i< len; i++)
    {
        while(SSIDataPutNonBlocking(SPI_BASE, 0xFF) != TRUE);
        while(SSIDataGetNonBlocking(SPI_BASE, &ulBuff) != TRUE);
        pBuff[i] = (unsigned char)ulBuff;
    }
    DEASSERT_CS();

    return len;
}
int spi_Write(Fd_t fd, unsigned char *pBuff, int len)
{
    int len_to_return = len;
    unsigned long ulDummy;

    ASSERT_CS();

    while(len)
    {
        while(SSIDataPutNonBlocking(SPI_BASE, (unsigned long)*pBuff) != TRUE);
        while(SSIDataGetNonBlocking(SPI_BASE, &ulDummy) != TRUE);
        pBuff++;
        len--;
    }
    DEASSERT_CS();

    return len_to_return;
}
Exemple #5
0
/*
 * Funcion principal
 */
int main(void) {
	// Configuracion del reloj a 40MHz
	SysCtlClockSet(SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ | SYSCTL_USE_PLL | SYSCTL_SYSDIV_5);

	// Configurar la interfaz SSI
	SSI0_Init();

	while (1) {
		// Enviar un dato
		DAC_Out(100);
		SysCtlDelay(26666666);
		DAC_Out(500);
		SysCtlDelay(26666666);
		DAC_Out(1000);
		SysCtlDelay(26666666);
		DAC_Out(2000);
		SysCtlDelay(26666666);
		SSIDataPutNonBlocking(SSI0_BASE, 2500);
		SysCtlDelay(26666666);
	}
}
// --------------------------------------------------------------------------------------
// SB_ServoSet
// Set 12 Servo positions
// --------------------------------------------------------------------------------------
void SB_ServoSet (ui8 slaveMask, ui8 *positions, ui8 servoOffset, ui8 servoCnt )
{
ui32 tempLong = 0;
ui16 *tempShort ;

	// TODO : Finish this function
	// CS the Slave
	SB_CS_Select( slaveMask );

	SSIDataPutNonBlocking(SSI0_BASE, (ui16)('#'<<8 | SB_SERVO_MOVE));
	SSIDataPutNonBlocking(SSI0_BASE, (ui16)(servoOffset<<8 | servoCnt));
	tempShort = (ui16 *)positions;

	/*
	for (i=0; i<servoCnt; i++)
	{
		SSIDataPut(SSI0_BASE, tempShort[i]);
	}
	*/

	SSIDataPutNonBlocking(SSI0_BASE, tempShort[0]);
	SSIDataPutNonBlocking(SSI0_BASE, tempShort[1]);
	SSIDataPutNonBlocking(SSI0_BASE, tempShort[2]);
	SSIDataPutNonBlocking(SSI0_BASE, tempShort[3]);
	SSIDataPutNonBlocking(SSI0_BASE, tempShort[4]);
	SSIDataPut(SSI0_BASE, tempShort[5]);

	// Make sure it's all sent
	while ( SSIBusy(SSI0_BASE) )
	{
		// TODO : Time out
	}

	// Clear data read in
	while(SSIDataGetNonBlocking(SSI0_BASE, &tempLong))
	{

	}

	// De-select the Slave
	SB_CS_DeSelect( slaveMask );
}
Exemple #7
0
int AcquireRun(void)
{
	unsigned long ulindex;

    if(g_ulADCCount != ulLastADCCount)
    {
    	ulLastADCCount=g_ulADCCount;



        if(ind2 <0)
        ind2=ind2+buffer_size;
        else
        ind2=ind2%buffer_size;
        buffer[0][ind2]=(unsigned long)(g_ulADCData[0]&0xfff);
        //max1=max1+buffer[0][ind2];
        buffer[1][ind2]=(unsigned long)g_ulADCData[1];
        //prev_index=ind2;
        ind2++;



        rcount++;

        if(0==0)
        {

        	   //
        	    // Initialize the data to send.
        	    //
        	    ulDataTx[0] = 's';
        	    ulDataTx[1] = 'p';
        	    ulDataTx[2] = 'i';

        	    //
        	    // Display indication that the SSI is transmitting data.
        	    //
  //      	    UARTprintf("Sent:\n  ");

        	    //
        	    // Send 3 bytes of data.
        	    //
        	    for(ulindex = 0; ulindex < NUM_SSI_DATA; ulindex++)
        	    {
        	        //
        	        // Display the data that SSI is transferring.
        	        //
        	        ///UARTprintf("'%c' ", ulDataTx[ulindex]);

        	        //
        	        // Send the data using the "blocking" put function.  This function
        	        // will wait until there is room in the send FIFO before returning.
        	        // This allows you to assure that all the data you send makes it into
        	        // the send FIFO.
        	        //
        	        SSIDataPutNonBlocking(SSI0_BASE, ulDataTx[ulindex]);
            	    /*while(SSIBusy(SSI0_BASE))
            	    {
            	    }*/

        	    }

        	    //
        	    // Wait until SSI0 is done transferring all the data in the transmit FIFO.
        	    //

        }

        rem=rcount%((int)PULSE_SAMPLE);

    	if(rem==0)
    	{

    	    mode1=(mode1+1)%2;
    	    if(mode1==0)
    	    	led_on();
    	    else
    	    	led_off();


    	/*    int angle=0;
    	    if(max2>0 && max1>0 && abs(maxi1-maxi2)<PULSE_SAMPLE)
    	    {
    	    angle=abs(maxi1-maxi2);
    	    }

    	    acount++;


    	    max1=max1*20.0/4095;
    	    max2=max2*20.0/4095;
    	    //max1=max1/(2*buffer_increment);
    		snprintf(text,sizeof(text),"%ld,%ld",max1,max2);
*/

    	    /*GrContextForegroundSet(&sDisplayContext, ClrDarkBlue);
    	    GrRectFill(&sDisplayContext, &sRect1);
    	    GrContextForegroundSet(&sDisplayContext, ClrWhite);
    	    //GrRectDraw(&sDisplayContext, &sRect1);
    	    GrContextFontSet(&sDisplayContext, g_pFontCm12);
    	    GrStringDrawCentered(&sDisplayContext,text, -1,
    	                         GrContextDpyWidthGet(&sDisplayContext) / 2, 10, 0);
*/
    	    GrContextForegroundSet(&sDisplayContext, ClrDarkBlue);
    	    GrRectFill(&sDisplayContext, &sRect2);
    	    GrContextForegroundSet(&sDisplayContext, ClrWhite);
    	    sprintf(text,"%4d,%4d",rcount,g_ulADCCount);
    	    rcount=0;
    	    g_ulADCCount=0;
    	    GrContextFontSet(&sDisplayContext, g_pFontCm12/*g_pFontFixed6x8*/);
    	    GrStringDrawCentered(&sDisplayContext, text, -1,
    	                         GrContextDpyWidthGet(&sDisplayContext) / 2,
    	                         ((GrContextDpyHeightGet(&sDisplayContext) - 24) / 2) + 24,
    	                         0);
    	    GrFlush(&sDisplayContext);

    	    /*
    		max1=0;
    	    max2=0;
    	    res=0;
    	    res1=0;
    	    maxi1=0;
    	    maxi2=0;
    	    buffer_index=0;

    	    for(i=0;i<buffer_size;i++)
    	    {
        		buffer[0][i]=0;
    	    	buffer[1][i]=0;
    	    }
    	    i=0;
    	    j=0;
    	    ind2=buffer_index-buffer_increment+1;
    	    buffer_index=0;
    	    */
    	}

    }


}