Пример #1
0
/**
 * \brief wlan stop
 *
 * Stop WLAN device by putting it into reset state. 
 *  
 * \return    None     
 *
 * \sa wlan_start 
 * \note        
 * \warning     
 */
void
wlan_stop(void)
{
    //
    // ASIC 1273 chip disable
    //
    tSLInformation.WriteWlanPin( WLAN_DISABLE );

    //
    // Wait till IRQ line goes high...
    //
	while(tSLInformation.ReadWlanInterruptPin() == 0)
	{
	}
	
    
	//
	// Free the used by WLAN Driver memory
	//
	if (tSLInformation.pucTxCommandBuffer)
	{
	//	OS_free (tSLInformation.pucTxCommandBuffer);
		tSLInformation.pucTxCommandBuffer = 0;
	}

	SpiClose();
}
    /* init io callback */
    tSLInformation.ReadWlanInterruptPin = sReadWlanInterruptPin;
    tSLInformation.WlanInterruptEnable  = sWlanInterruptEnable;
    tSLInformation.WlanInterruptDisable = sWlanInterruptDisable;
    tSLInformation.WriteWlanPin = sWriteWlanPin;

    //init asynchronous events callback
    tSLInformation.sWlanCB= sWlanCB;

    // By default TX Complete events are routed to host too
    tSLInformation.InformHostOnTxComplete = 1;
}

//*****************************************************************************
//
//!  SpiReceiveHandler
//!
//!  @param         pvBuffer - pointer to the received data buffer
//!                      The function triggers Received event/data processing
//!
//!  @param         Pointer to the received data
//!  @return        none
//!
//!  @brief         The function triggers Received event/data processing. It is
//!                       called from the SPI library to receive the data
//
//*****************************************************************************
void SpiReceiveHandler(void *pvBuffer)
{
    tSLInformation.usEventOrDataReceived = 1;
    tSLInformation.pucReceivedData = (unsigned char     *)pvBuffer;

    hci_unsolicited_event_handler();
}


//*****************************************************************************
//
//!  wlan_start
//!
//!  @param   usPatchesAvailableAtHost -  flag to indicate if patches available
//!                                    from host or from EEPROM. Due to the
//!                                    fact the patches are burn to the EEPROM
//!                                    using the patch programmer utility, the
//!                                    patches will be available from the EEPROM
//!                                    and not from the host.
//!
//!  @return        none
//!
//!  @brief        Start WLAN device. This function asserts the enable pin of
//!                the device (WLAN_EN), starting the HW initialization process.
//!                The function blocked until device Initialization is completed.
//!                Function also configure patches (FW, driver or bootloader)
//!                and calls appropriate device callbacks.
//!
//!  @Note          Prior calling the function wlan_init shall be called.
//!  @Warning       This function must be called after wlan_init and before any
//!                 other wlan API
//!  @sa            wlan_init , wlan_stop
//!
//
//*****************************************************************************

#ifdef __ENABLE_MULTITHREADED_SUPPORT__
void c_wlan_start(unsigned short usPatchesAvailableAtHost)
#else /* __ENABLE_MULTITHREADED_SUPPORT__ */
void wlan_start(unsigned short usPatchesAvailableAtHost)
#endif /* __ENABLE_MULTITHREADED_SUPPORT__ */
{

    unsigned long ulSpiIRQState;

    tSLInformation.NumberOfSentPackets = 0;
    tSLInformation.NumberOfReleasedPackets = 0;
    tSLInformation.usRxEventOpcode = 0;
    tSLInformation.usNumberOfFreeBuffers = 0;
    tSLInformation.usSlBufferLength = 0;
    tSLInformation.usBufferSize = 0;
    tSLInformation.usRxDataPending = 0;
    tSLInformation.slTransmitDataError = 0;
    tSLInformation.usEventOrDataReceived = 0;
    tSLInformation.pucReceivedData = 0;

    // Allocate the memory for the RX/TX data transactions
    tSLInformation.pucTxCommandBuffer = (unsigned char *)wlan_tx_buffer;

    // init spi
    SpiOpen(SpiReceiveHandler);

    // Check the IRQ line
    ulSpiIRQState = tSLInformation.ReadWlanInterruptPin();

    // ASIC 1273 chip enable: toggle WLAN EN line
    tSLInformation.WriteWlanPin( WLAN_ENABLE );

    if (ulSpiIRQState)
    {
        // wait till the IRQ line goes low
        while(tSLInformation.ReadWlanInterruptPin() != 0)
        {
        }
    }
    else
    {
        // Wait till the IRQ line goes high and then low.
        while(tSLInformation.ReadWlanInterruptPin() == 0)
        {
        }

        while(tSLInformation.ReadWlanInterruptPin() != 0)
        {
        }
    }

    SimpleLink_Init_Start(usPatchesAvailableAtHost);

    // Read Buffer's size and finish
    hci_command_send(HCI_CMND_READ_BUFFER_SIZE, tSLInformation.pucTxCommandBuffer, 0);
    SimpleLinkWaitEvent(HCI_CMND_READ_BUFFER_SIZE, 0);
}


//*****************************************************************************
//
//!  wlan_stop
//!
//!  @param         none
//!
//!  @return        none
//!
//!  @brief         Stop WLAN device by putting it into reset state.
//!
//!  @sa            wlan_start
//
//*****************************************************************************
#ifdef __ENABLE_MULTITHREADED_SUPPORT__
void c_wlan_stop(void)
#else /* __ENABLE_MULTITHREADED_SUPPORT__ */
void wlan_stop(void)
#endif /* __ENABLE_MULTITHREADED_SUPPORT__ */
{
    // ASIC 1273 chip disable
    tSLInformation.WriteWlanPin( WLAN_DISABLE );

    // Wait till IRQ line goes high...
    while(tSLInformation.ReadWlanInterruptPin() == 0)
    {
    }

    // Free the used by WLAN Driver memory
    if (tSLInformation.pucTxCommandBuffer)
    {
        tSLInformation.pucTxCommandBuffer = 0;
    }

    SpiClose();
}