Exemple #1
0
/*!
    \brief closes an opened spi communication port

	\param	 		fd			-	file descriptor of an opened SPI channel

	\return			upon successful completion, the function shall return 0.
					Otherwise, -1 shall be returned

    \sa             spi_Open
	\note
    \warning
*/
int spi_Close(Fd_t fd)
{
    unsigned long ulBase = LSPI_BASE;

    g_SpiFd = 0;
if(g_ucDMAEnabled)
{
    //Simplelink_UDMADeInit();
    #ifdef SL_PLATFORM_MULTI_THREADED
      osi_InterruptDeRegister(INT_LSPI);
      osi_MsgQDelete(&DMAMsgQ);
    #else
      SPIIntUnregister(ulBase);
      g_cDummy = 0;
    #endif
    SPIFIFODisable(ulBase,SPI_RX_FIFO);
    SPIFIFODisable(ulBase,SPI_TX_FIFO);
    SPIDmaDisable(ulBase,SPI_RX_DMA);
    SPIDmaDisable(ulBase,SPI_TX_DMA);
}
    //Disable Chip Select
    SPICSDisable(LSPI_BASE);


    //Disable SPI Channel
    SPIDisable(ulBase);

    // Reset SPI
    SPIReset(ulBase);

    // Enable SPI Peripheral
    PRCMPeripheralClkDisable(PRCM_LSPI,PRCM_RUN_MODE_CLK|PRCM_SLP_MODE_CLK);

    return 0;
}
Exemple #2
0
//*****************************************************************************
//
//! Control Destroy Routine
//!
//! \param None
//!
//! \return                     0 - Success
//!                               -1 - Error
//
//*****************************************************************************
long ControlTaskDestroy()
{
    long lRetVal = -1;

    lRetVal = osi_MsgQDelete(&g_ControlMsgQueue);
    ASSERT_ON_ERROR(lRetVal);

    osi_TaskDelete(&g_AudioControlTask);

    g_ControlMsgQueue = NULL;
    g_AudioControlTask = NULL;

    return SUCCESS;
}
Exemple #3
0
//*****************************************************************************
//
//! \brief Task Created by main fucntion. This task creates a udp server and
//!        wait for packets. Upon receiving the packet, signals the other task.
//!
//! \param pvParameters is a general void pointer (not used here).
//!
//! \return none
//
//*****************************************************************************
void UDPServerTask(void *pvParameters)
{
    unsigned char ucSyncMsg;
    unsigned char ucQueueMsg = 3;
    int iSockDesc = 0;
    int iRetVal = 0;
    sockaddr_in sLocalAddr;
    sockaddr_in sClientAddr;
    unsigned int iAddrSize = 0;
       
    //
    // waiting for the other task to start simplelink and connection to the AP
    //
    osi_MsgQRead(&g_tConnectionFlag, &ucSyncMsg, OSI_WAIT_FOREVER);
    osi_MsgQDelete(&g_tConnectionFlag);
    
    //
    // configure the Server
    //
    sLocalAddr.sin_family = SL_AF_INET;
    sLocalAddr.sin_port = sl_Htons((unsigned short)APP_UDP_PORT);
    sLocalAddr.sin_addr.s_addr = 0;
    
    iAddrSize = sizeof(sockaddr_in);
    
    //
    // creating a UDP socket
    //
    iSockDesc = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);

    if(iSockDesc < 0)
    {
        UART_PRINT("sock error\n\r");
        LOOP_FOREVER();
    }
    
    //
    // binding the socket
    //
    iRetVal = sl_Bind(iSockDesc, (SlSockAddr_t *)&sLocalAddr, iAddrSize);
    if(iRetVal < 0)
    {
        UART_PRINT("bind error\n\r");
        LOOP_FOREVER();
    }
    
    while(FOREVER)
    {
        //
        // waiting on a UDP packet
        //
        iRetVal = sl_RecvFrom(iSockDesc, g_cBuffer, BUFF_SIZE, 0,
                              ( SlSockAddr_t *)&sClientAddr,
                              (SlSocklen_t*)&iAddrSize );
        if(iRetVal > 0)
        {
            //
            // signal the other task about receiving the UDP packet
            //
            osi_MsgQWrite(&g_tWkupSignalQueue, &ucQueueMsg, OSI_WAIT_FOREVER);
        }
        else
        {
            UART_PRINT("recv error\n\r");
            LOOP_FOREVER();
        }
    }  
}