This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3120: porting CC3120 SDK to NORTOS environment

Part Number: CC3120
Other Parts Discussed in Thread: CC3100SDK, , CC3100,

Hello,

I'm using a Cypress MCU with the C3120 in a NORTOS environment.

I made the same changes as Shubham Kant Dubey did in his post

https://e2e.ti.com/support/wireless-connectivity/wifi/f/968/t/748675

However, it seems the program is stuck in a while loop within _SlNonOsSemGet() when I call sl_Start(NULL, NULL, NULL);

Shubham, can you please describe how you resolved your issue?

I'm using CC3120 SDK 2_30_00_10 and merged the nonos.c/.h files from CC3100SDK_1.3.0

Thanks,

Wai

  • Hi Wai,

    Please check SPI driver working properly. Did you implement timestamp? Check SPI Bit order that must be MSBit first?

    You have to keep some function of CC3120 nonos.c without changing them, after merging with cc3100.

    Could you just attached your user.h, nonos.h and nonos.c, ccpal.h, ccpal.c in this post. I will go through it and compare with my files. Might be you are missing something.

    Regards,

    Shubham
  • Hello Shubham,

    I am actually using UART.

    Please find requested files attached.

    Thanks,

    Wai

    /*
     * nonos.c - CC31xx/CC32xx Host Driver Implementation
     *
     * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
     *
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    
    /*****************************************************************************/
    /* Include files                                                             */
    /*****************************************************************************/
    #include <ti/drivers/net/wifi/simplelink.h>
    #include <ti/drivers/net/wifi/source/protocol.h>
    #include <ti/drivers/net/wifi/source/driver.h>
    
    #ifndef SL_PLATFORM_MULTI_THREADED
    
    #include "nonos.h"
    
    _SlNonOsCB_t g__SlNonOsCB;
    
        _SlNonOsRetVal_t _SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Value)
    {
        *pSemObj = Value;
        return NONOS_RET_OK;
    }
    
    _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout)
    {
    #if (!defined (SL_TINY)) && (defined(sl_GetTimestamp))
          _SlTimeoutParams_t      TimeoutInfo={0};
    #endif
    
    	 /* If timeout 0 configured, just detect the value and return */
          if ((Timeout ==0) && (WaitValue == *((volatile _u8 *)pSyncObj)) )
    	  {
    		  *pSyncObj = SetValue;
    		  return NONOS_RET_OK;
    	  }
    
    #if (!defined (SL_TINY)) && (defined(sl_GetTimestamp))
          if ((Timeout != NONOS_WAIT_FOREVER) && (Timeout != NONOS_NO_WAIT))
          {
        	  _SlDrvStartMeasureTimeout(&TimeoutInfo, Timeout);
          }
    #endif
    
    #ifdef _SlSyncWaitLoopCallback
        _SlNonOsTime_t timeOutRequest = Timeout; 
    #endif
        while (Timeout>0)
        {
            if (WaitValue == *((volatile _u8 *)pSyncObj))
            {
                *pSyncObj = SetValue;
                break;
            }
    #if (!defined (sl_GetTimestamp)) ||  (defined (SL_TINY_EXT))
            if (Timeout != NONOS_WAIT_FOREVER)
            {		
                Timeout--;
            }
    #else        
            if ((Timeout != NONOS_WAIT_FOREVER) && (Timeout != NONOS_NO_WAIT))
            {
                if (_SlDrvIsTimeoutExpired(&TimeoutInfo))
                {
                	return (_SlNonOsRetVal_t)NONOS_RET_ERR;
                }
    
            }
     #endif       
    
            /* If we are in cmd context and waiting for its cmd response
             * do not handle spawn async events as the global lock was already taken */
            if (FALSE == g_pCB->WaitForCmdResp)
            {
            (void)_SlNonOsHandleSpawnTask();
            }
    #ifdef _SlSyncWaitLoopCallback
            if( (__NON_OS_SYNC_OBJ_SIGNAL_VALUE == WaitValue) && (timeOutRequest != NONOS_NO_WAIT) )
            {
                if (WaitValue == *((volatile _u8 *)pSyncObj))
                {
                    *pSyncObj = SetValue;
                    break;
                }
                _SlSyncWaitLoopCallback();
            }
    #endif
        }
    
        if (0 == Timeout)
        {
            return NONOS_RET_ERR;
        }
        else
        {
            return NONOS_RET_OK;
        }
    }
    
    _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry,
                                   void* pValue,
                                   _u32 flags)
    {
        _i8 i = 0;
    
        /* The parameter is currently not in use */
        (void)flags;
    
    #ifndef SL_TINY
        for(i = 0; i < NONOS_MAX_SPAWN_ENTRIES; i++)
    #endif
        {
            _SlNonOsSpawnEntry_t* pE = &g__SlNonOsCB.SpawnEntries[i];
    
            if(pE->IsAllocated == FALSE)
            {
                pE->pValue = pValue;
                pE->pEntry = pEntry;
                pE->IsAllocated = TRUE;
    #ifndef SL_TINY
                break;
    #endif
            }
        }
    
        return(NONOS_RET_OK);
    }
    
    _SlNonOsRetVal_t _SlNonOsHandleSpawnTask(void)
    {
        _i8 i = 0;
        void*  pValue;
    
    #ifndef SL_TINY
        for(i = 0; i < NONOS_MAX_SPAWN_ENTRIES; i++)
    #endif
        {
            _SlNonOsSpawnEntry_t* pE = &g__SlNonOsCB.SpawnEntries[i];
    
            if(pE->IsAllocated == TRUE)
            {
                _SlSpawnEntryFunc_t pF = pE->pEntry;
                pValue = pE->pValue;
    
                /* Clear the entry */
                pE->pEntry = NULL;
                pE->pValue = NULL;
                pE->IsAllocated = FALSE;
    
                /* execute the spawn function */
                pF(pValue);
            }
        }
        return(NONOS_RET_OK);
    }
    
    void tiDriverSpawnCallback(void)
    {
        /* If we are in cmd context and waiting for its cmd response
         * do not handle async events from spawn, as the global lock was already taken when sending the command,
         * and the Async event would be handled in read cmd context, so we do nothing.
         */
        if(FALSE == g_pCB->WaitForCmdResp)
        {
            (void)_SlNonOsHandleSpawnTask();
        }
    }
    
    #endif
    
    8787.nonos.h
    /*
     * Copyright (c) 2017-2018, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    /******************************************************************************
    *     cc_pal.c
    *
    *    Simplelink Wi-Fi platform abstraction file for MSP432
    ******************************************************************************/
    //#include <ti/drivers/SPI.h>
    //#include <ti/drivers/GPIO.h>
    #include <ti/drivers/net/wifi/porting/cc_pal.h>
    #include <ti/drivers/net/wifi/porting/SIMPLELINKWIFI.h>
    #include <ti/drivers/net/wifi/simplelink.h>
    
    typedef void(* GPIO_CallbackFxn) (uint_least8_t);
    
    /****************************************************************************
       GLOBAL VARIABLES
    ****************************************************************************/
    volatile Fd_t g_SpiFd = 0;
    SL_P_EVENT_HANDLER g_Host_irq_Hndlr = NULL;
    
    /****************************************************************************
       CONFIGURATION VARIABLES
    ****************************************************************************/
    extern const WiFi_Config WiFi_config[];
    extern const uint_least8_t WiFi_count;
    static SIMPLELINKWIFI_HWAttrsV1* curDeviceConfiguration;
    
    /****************************************************************************
       CONFIGURATION FUNCTION DEFINITION
    ****************************************************************************/
    void WiFi_init()
    {
        /* We need to have at least one WiFi module. */
        if(WiFi_count == 0)
        {
            return;
        }
    
        curDeviceConfiguration = (SIMPLELINKWIFI_HWAttrsV1*) WiFi_config[0].hwAttrs;
    }
    
    void GPIO_disableInt(uint_least8_t hostIRQPin)
    {}
    void GPIO_clearInt(uint_least8_t hostIRQPin) {}
    void GPIO_setCallback(uint_least8_t hostIRQPin, GPIO_CallbackFxn callback) {}
    void GPIO_enableInt(uint_least8_t hostIRQPin) {}
    
    
    /****************************************************************************
       LOCAL FUNCTION DEFINITIONS
    ****************************************************************************/
    Fd_t spi_Open(char *ifName,
                  unsigned long flags)
    {
    #ifndef CY_PORT
        void *lspi_hndl;
        SPI_Params SPI_Config;
    
        /* Initialize the WiFi driver */
        WiFi_init();
    
        /* If we could not initialize the device bail out with an error code */
        if(curDeviceConfiguration == NULL)
        {
            return (-1);
        }
    
        /* Initialize the SPI config structure */
        SPI_Params_init(&SPI_Config);
        SPI_Config.transferMode = SPI_MODE_BLOCKING;
        SPI_Config.mode = SPI_MASTER;
        SPI_Config.bitRate = curDeviceConfiguration->spiBitRate;
        SPI_Config.dataSize = 8;
        SPI_Config.frameFormat = SPI_POL0_PHA0;
    
        /* Open SPI interface with SPI_Config parameters */
        lspi_hndl = SPI_open(curDeviceConfiguration->spiIndex, &SPI_Config);
    
        if(NULL == lspi_hndl)
        {
            return (-1);
        }
        else
        {
            return ((Fd_t) lspi_hndl);
        }
    #else
        return (-1);
    
    #endif // CY_PORT 
    }
    
    int spi_Close(Fd_t fd)
    {
    #ifndef CY_PORT
        SPI_close((void *) fd);
    #endif // CY_PORT 
        return (0);
    }
    
    int spi_Read(Fd_t fd,
                 unsigned char *pBuff,
                 int len)
    {
    #ifndef CY_PORT
        SPI_Transaction transact_details;
        int read_size = 0;
    
        ASSERT_CS();
    
        /* check if the link SPI has been initialized successfully */
        if(fd < 0)
        {
            DEASSERT_CS();
            return (-1);
        }
    
        transact_details.txBuf = NULL;
        transact_details.arg = NULL;
        transact_details.rxBuf = (void*) (pBuff);
    
        while(len > 0)
        {
            if(len > curDeviceConfiguration->maxDMASize)
            {
                transact_details.count = curDeviceConfiguration->maxDMASize;
            }
            else
            {
                transact_details.count = len;
            }
    
            if(SPI_transfer((SPI_Handle) fd, &transact_details))
            {
                read_size += transact_details.count;
                len = len - transact_details.count;
                transact_details.rxBuf = ((unsigned char *) (transact_details.rxBuf)
                                          + transact_details.count);
            }
            else
            {
                DEASSERT_CS();
                return (-1);
            }
        }
    
        DEASSERT_CS();
    
        return (read_size);
    #else
        return (-1);
    #endif // CY_PORT 
    }
    
    int spi_Write(Fd_t fd,
                  unsigned char *pBuff,
                  int len)
    {
    #ifndef CY_PORT
        SPI_Transaction transact_details;
        int write_size = 0;
    
        ASSERT_CS();
    
        /* check if the link SPI has been initialized successfully */
        if(fd < 0)
        {
            DEASSERT_CS();
            return (-1);
        }
    
        transact_details.rxBuf = NULL;
        transact_details.arg = NULL;
        transact_details.txBuf = (void*) (pBuff);
    
        while(len > 0)
        {
            if(len > curDeviceConfiguration->maxDMASize)
            {
                transact_details.count = curDeviceConfiguration->maxDMASize;
            }
            else
            {
                transact_details.count = len;
            }
    
            if(SPI_transfer((SPI_Handle) fd, &transact_details))
            {
                write_size += transact_details.count;
                len = len - transact_details.count;
                transact_details.txBuf = ((unsigned char *) (transact_details.txBuf)
                                          + transact_details.count);
            }
            else
            {
                DEASSERT_CS();
                return (-1);
            }
        }
    
        DEASSERT_CS();
    
        return (write_size);
    #else
        return (-1);
    #endif // CY_PORT 
    }
    Fd_t uart_Open(char *ifName,
                  unsigned long flags)
    {
        UART_1_Start();
        return NONOS_RET_OK;
    }
    
    int uart_Close(Fd_t fd)
    {
        UART_1_Stop();
        return NONOS_RET_OK;
    }
    
    int uart_Read(Fd_t fd,
                 unsigned char *pBuff,
                 int len)
    {
    	int i = 0;
    
    	for(i=0; i< len; i++)
    	{
    		pBuff[i] = (unsigned char)UART_1_GetChar();
    	}
    
    	return len;
        
    }
    
    int uart_Write(Fd_t fd,
                  unsigned char *pBuff,
                  int len)
    {
    	int len_to_return = len;
    
        while (len)
        {
            UART_1_PutChar((uint8) *pBuff);         
            len--;
            pBuff++;
        }
    
        return len_to_return;
    }
    
    
    int NwpRegisterInterruptHandler(P_EVENT_HANDLER InterruptHdl,
                                    void* pValue)
    {
    
        g_Host_irq_Hndlr = InterruptHdl;
        #ifdef CYPORT
            
        /* Check for unregister condition */
        if(NULL == InterruptHdl)
        {
            GPIO_disableInt(curDeviceConfiguration->hostIRQPin);
            GPIO_clearInt(curDeviceConfiguration->hostIRQPin);
            g_Host_irq_Hndlr = NULL;
            return (0);
        }
        else if(NULL == g_Host_irq_Hndlr)
        {
            g_Host_irq_Hndlr = InterruptHdl;
            GPIO_setCallback(curDeviceConfiguration->hostIRQPin,
                             HostIrqGPIO_callback);
            GPIO_clearInt(curDeviceConfiguration->hostIRQPin);
            GPIO_enableInt(curDeviceConfiguration->hostIRQPin);
            return (0);
        }
        else
        {
            /* An error occurred */
            return (-1);
        }
        #endif // CYPORT
    }
    
    void HostIrqGPIO_callback(uint_least8_t index)
    {
        if((index == curDeviceConfiguration->hostIRQPin)
           && (NULL != g_Host_irq_Hndlr))
        {
            g_Host_irq_Hndlr(0);
        }
    }
    
    void NwpMaskInterrupt()
    {
    }
    
    void NwpUnMaskInterrupt()
    {
    }
    
    void NwpPowerOnPreamble(void)
    {
        /* Maybe start timer here? */
    }
    
    void NwpPowerOn(void)
    {
    #ifndef CY_PORT
        GPIO_write(curDeviceConfiguration->nHIBPin, 1);
        /* wait 5msec */
        ClockP_usleep(5000);
    #else
      //  
    #endif // CY_PORT
    
    }
    
    void NwpPowerOff(void)
    {
    #ifndef CY_PORT
        GPIO_write(curDeviceConfiguration->nHIBPin, 0);
        /* wait 5msec */
        ClockP_usleep(5000);
    #else
    #endif // CY_PORT
    }
    
    #ifndef CY_PORT
    
    int Semaphore_create_handle(SemaphoreP_Handle* pSemHandle)
    {
        SemaphoreP_Params params;
    
        SemaphoreP_Params_init(&params);
    #ifndef SL_PLATFORM_MULTI_THREADED
        params.callback = tiDriverSpawnCallback;
    #endif
        (*(pSemHandle)) = SemaphoreP_create(1, &params);
    
        if(!(*(pSemHandle)))
        {
            return(-1);
        }
    
        return(SemaphoreP_OK);
    }
    
    int SemaphoreP_delete_handle(SemaphoreP_Handle* pSemHandle)
    {
        SemaphoreP_delete(*(pSemHandle));
        return(SemaphoreP_OK);
    }
    
    int SemaphoreP_post_handle(SemaphoreP_Handle* pSemHandle)
    {
        SemaphoreP_post(*(pSemHandle));
        return(SemaphoreP_OK);
    }
    
    int Mutex_create_handle(MutexP_Handle* pMutexHandle)
    {
        MutexP_Params params;
    
        MutexP_Params_init(&params);
    #ifndef SL_PLATFORM_MULTI_THREADED
        params.callback = tiDriverSpawnCallback;
    #endif
    
        (*(pMutexHandle)) = MutexP_create(&params);
    
        if(!(*(pMutexHandle)))
        {
            return(MutexP_FAILURE);
        }
    
        return(MutexP_OK);
    }
    
    int MutexP_delete_handle(MutexP_Handle* pMutexHandle)
    {
        MutexP_delete(*(pMutexHandle));
        return (MutexP_OK);
    }
    
    int Mutex_unlock(MutexP_Handle pMutexHandle)
    {
        MutexP_unlock(pMutexHandle, 0);
        return (MutexP_OK);
    }
    
    int Mutex_lock(MutexP_Handle pMutexHandle)
    {
        MutexP_lock(pMutexHandle);
        return (MutexP_OK);
    }
    #endif // CY_PORT
    
    unsigned long TimerGetCurrentTimestamp()
    {
        return (CySysTickGetValue());
    }
    
    2425.cc_pal.h3005.user.h

  • Hi Wai,

    Were you able to make any further progress on your issue?

    If not, can you add source/ti/drivers/net/wifi/source/device.c to your project and step through sl_Start so we can be sure of where you are waiting?

    Best regards,
    Sarah
  • Hi Shubham,
    Thanks for PM'ing me with your comments. I appreciate your help with this.
    Cheers,
    Wai
  • Hi Sarah,

    Thanks for the follow up.

    I've made some progress since my last post.  I started with not having nHib and the Host IRQ lines connected as from what I understood from TI documentation those lines were not necessary as long as my MCU was not going to go to a lower power mode and my application did not require the TI chip to do so either (ie with nHib) which is the case case in my project.

    But after stepping through the code, it was designed more for a Host IRQ than an RX IRQ, so I connected the Host IRQ.  Also just so i can controlling when the TI started up, I connected nHib. After doing so I was able to get a message from the TI chip that was ASYNC_EVT_CLASS.  Is there any documentation regarding the protocol sequence?

    Now I'm stuck with getting an HOST IRQ as soon as I unmask it which is odd because I have the MCU to trigger on a rising edge (ie not level) for the HOST IRQ.

    Note that I"m using he BOOSTXL-CC3120MOD board for my development.  It is only powered by USB On the TI board,the following are jumpered: J8 (2-3), J4 and J3.  The TI board's TX, RX, CTS, RTS, nHib and IRQ (host) pins are connected to my MCU's dev board.  Please let me know if I should be connecting more power.

    Cheers,

    Wai

    These are my updated files:

    /*
     * Copyright (c) 2017-2018, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    /******************************************************************************
    *     cc_pal.c
    *
    *    Simplelink Wi-Fi platform abstraction file for MSP432
    ******************************************************************************/
    //#include <ti/drivers/SPI.h>
    //#include <ti/drivers/GPIO.h>
    #include <ti/drivers/net/wifi/porting/cc_pal.h>
    #include <ti/drivers/net/wifi/porting/SIMPLELINKWIFI.h>
    #include <ti/drivers/net/wifi/simplelink.h>
    
    typedef void(* GPIO_CallbackFxn) (uint_least8_t);
    
    /****************************************************************************
       GLOBAL VARIABLES
    ****************************************************************************/
    volatile Fd_t g_SpiFd = 0;
    SL_P_EVENT_HANDLER g_Host_irq_Hndlr = NULL;
    
    _u8 IntIsMasked;
    
    /****************************************************************************
       CONFIGURATION VARIABLES
    ****************************************************************************/
    extern const WiFi_Config WiFi_config[];
    extern const uint_least8_t WiFi_count;
    static SIMPLELINKWIFI_HWAttrsV1* curDeviceConfiguration;
    
    /****************************************************************************
       CONFIGURATION FUNCTION DEFINITION
    ****************************************************************************/
    void WiFi_init()
    {
        /* We need to have at least one WiFi module. */
        if(WiFi_count == 0)
        {
            return;
        }
    
        curDeviceConfiguration = (SIMPLELINKWIFI_HWAttrsV1*) WiFi_config[0].hwAttrs;
    }
    
    
    
    /****************************************************************************
       LOCAL FUNCTION DEFINITIONS
    ****************************************************************************/
    Fd_t spi_Open(char *ifName,
                  unsigned long flags)
    {
    #ifndef CY_PORT
        void *lspi_hndl;
        SPI_Params SPI_Config;
    
        /* Initialize the WiFi driver */
        WiFi_init();
    
        /* If we could not initialize the device bail out with an error code */
        if(curDeviceConfiguration == NULL)
        {
            return (-1);
        }
    
        /* Initialize the SPI config structure */
        SPI_Params_init(&SPI_Config);
        SPI_Config.transferMode = SPI_MODE_BLOCKING;
        SPI_Config.mode = SPI_MASTER;
        SPI_Config.bitRate = curDeviceConfiguration->spiBitRate;
        SPI_Config.dataSize = 8;
        SPI_Config.frameFormat = SPI_POL0_PHA0;
    
        /* Open SPI interface with SPI_Config parameters */
        lspi_hndl = SPI_open(curDeviceConfiguration->spiIndex, &SPI_Config);
    
        if(NULL == lspi_hndl)
        {
            return (-1);
        }
        else
        {
            return ((Fd_t) lspi_hndl);
        }
    #else
        return (-1);
    
    #endif // CY_PORT 
    }
    
    int spi_Close(Fd_t fd)
    {
    #ifndef CY_PORT
        SPI_close((void *) fd);
    #endif // CY_PORT 
        return (0);
    }
    
    int spi_Read(Fd_t fd,
                 unsigned char *pBuff,
                 int len)
    {
    #ifndef CY_PORT
        SPI_Transaction transact_details;
        int read_size = 0;
    
        ASSERT_CS();
    
        /* check if the link SPI has been initialized successfully */
        if(fd < 0)
        {
            DEASSERT_CS();
            return (-1);
        }
    
        transact_details.txBuf = NULL;
        transact_details.arg = NULL;
        transact_details.rxBuf = (void*) (pBuff);
    
        while(len > 0)
        {
            if(len > curDeviceConfiguration->maxDMASize)
            {
                transact_details.count = curDeviceConfiguration->maxDMASize;
            }
            else
            {
                transact_details.count = len;
            }
    
            if(SPI_transfer((SPI_Handle) fd, &transact_details))
            {
                read_size += transact_details.count;
                len = len - transact_details.count;
                transact_details.rxBuf = ((unsigned char *) (transact_details.rxBuf)
                                          + transact_details.count);
            }
            else
            {
                DEASSERT_CS();
                return (-1);
            }
        }
    
        DEASSERT_CS();
    
        return (read_size);
    #else
        return (-1);
    #endif // CY_PORT 
    }
    
    int spi_Write(Fd_t fd,
                  unsigned char *pBuff,
                  int len)
    {
    #ifndef CY_PORT
        SPI_Transaction transact_details;
        int write_size = 0;
    
        ASSERT_CS();
    
        /* check if the link SPI has been initialized successfully */
        if(fd < 0)
        {
            DEASSERT_CS();
            return (-1);
        }
    
        transact_details.rxBuf = NULL;
        transact_details.arg = NULL;
        transact_details.txBuf = (void*) (pBuff);
    
        while(len > 0)
        {
            if(len > curDeviceConfiguration->maxDMASize)
            {
                transact_details.count = curDeviceConfiguration->maxDMASize;
            }
            else
            {
                transact_details.count = len;
            }
    
            if(SPI_transfer((SPI_Handle) fd, &transact_details))
            {
                write_size += transact_details.count;
                len = len - transact_details.count;
                transact_details.txBuf = ((unsigned char *) (transact_details.txBuf)
                                          + transact_details.count);
            }
            else
            {
                DEASSERT_CS();
                return (-1);
            }
        }
    
        DEASSERT_CS();
    
        return (write_size);
    #else
        return (-1);
    #endif // CY_PORT 
    }
    Fd_t uart_Open(char *ifName,
                  unsigned long flags)
    {
        UART_1_Start();
        return NONOS_RET_OK;
    }
    
    int uart_Close(Fd_t fd)
    {
        UART_1_Stop();
        return NONOS_RET_OK;
    }
    
    int uart_Read(Fd_t fd,
                 unsigned char *pBuff,
                 int len)
    {
    	int i = 0;
    
    	for(i=0; i< len; i++)
    	{
    		pBuff[i] = (unsigned char)UART_1_GetChar();
    	}
    
    	return len;
        
    }
    
    int uart_Write(Fd_t fd,
                  unsigned char *pBuff,
                  int len)
    {
    	int len_to_return = len;
    
        while (len)
        {
            UART_1_PutChar((uint8) *pBuff);         
            len--;
            pBuff++;
        }
    
        return len_to_return;
    }
    
    
    int NwpRegisterInterruptHandler(P_EVENT_HANDLER InterruptHdl,
                                    void* pValue)
    {
    
        /* Check for unregister condition */
        if(NULL == InterruptHdl)
        {
            isr_HOST_IRQ_Disable();
            isr_HOST_IRQ_ClearPending();
            g_Host_irq_Hndlr = NULL;
            return (0);
        }
        else if(NULL == g_Host_irq_Hndlr)
        {
            g_Host_irq_Hndlr = InterruptHdl;
            isr_HOST_IRQ_ClearPending();
            isr_HOST_IRQ_Enable();
            return (0);
        }
        else
        {
            /* An error occurred */
            return (-1);
        }
    
    }
    
    void HostIrqGPIO_callback(uint_least8_t index)
    {
    //    if((index == curDeviceConfiguration->hostIRQPin)
    //       && (NULL != g_Host_irq_Hndlr))
        if( (NULL != g_Host_irq_Hndlr))
        {
            g_Host_irq_Hndlr(0);
        }
    }
    
    void NwpMaskInterrupt()
    {
        IntIsMasked = TRUE;
        isr_HOST_IRQ_Disable();
    }
    
    void NwpUnMaskInterrupt()
    {
    	IntIsMasked = FALSE;
    
        isr_HOST_IRQ_Enable();
    }
    
    void NwpPowerOnPreamble(void)
    {
        /* Maybe start timer here? */
    }
    
    void NwpPowerOn(void)
    {
    
    #ifndef CY_PORT
        GPIO_write(curDeviceConfiguration->nHIBPin, 1);
        /* wait 5msec */
        ClockP_usleep(5000);
    #else
        nHib_Write(1);
        CyDelay(10);  // delay 10 ms; may not need this
    
     
    #endif // CY_PORT
    
    }
    
    void NwpPowerOff(void)
    {
    #ifndef CY_PORT
        GPIO_write(curDeviceConfiguration->nHIBPin, 0);
        /* wait 5msec */
        ClockP_usleep(5000);
    #else
        nHib_Write(0);
        // according to TI Minimum Hibernate time required	10 ms
        CyDelay(10);  // delay 10 ms
    #endif // CY_PORT
    }
    
    #ifndef CY_PORT
    
    int Semaphore_create_handle(SemaphoreP_Handle* pSemHandle)
    {
        SemaphoreP_Params params;
    
        SemaphoreP_Params_init(&params);
    #ifndef SL_PLATFORM_MULTI_THREADED
        params.callback = tiDriverSpawnCallback;
    #endif
        (*(pSemHandle)) = SemaphoreP_create(1, &params);
    
        if(!(*(pSemHandle)))
        {
            return(-1);
        }
    
        return(SemaphoreP_OK);
    }
    
    int SemaphoreP_delete_handle(SemaphoreP_Handle* pSemHandle)
    {
        SemaphoreP_delete(*(pSemHandle));
        return(SemaphoreP_OK);
    }
    
    int SemaphoreP_post_handle(SemaphoreP_Handle* pSemHandle)
    {
        SemaphoreP_post(*(pSemHandle));
        return(SemaphoreP_OK);
    }
    
    int Mutex_create_handle(MutexP_Handle* pMutexHandle)
    {
        MutexP_Params params;
    
        MutexP_Params_init(&params);
    #ifndef SL_PLATFORM_MULTI_THREADED
        params.callback = tiDriverSpawnCallback;
    #endif
    
        (*(pMutexHandle)) = MutexP_create(&params);
    
        if(!(*(pMutexHandle)))
        {
            return(MutexP_FAILURE);
        }
    
        return(MutexP_OK);
    }
    
    int MutexP_delete_handle(MutexP_Handle* pMutexHandle)
    {
        MutexP_delete(*(pMutexHandle));
        return (MutexP_OK);
    }
    
    int Mutex_unlock(MutexP_Handle pMutexHandle)
    {
        MutexP_unlock(pMutexHandle, 0);
        return (MutexP_OK);
    }
    
    int Mutex_lock(MutexP_Handle pMutexHandle)
    {
        MutexP_lock(pMutexHandle);
        return (MutexP_OK);
    }
    #endif // CY_PORT
    
    unsigned long TimerGetCurrentTimestamp()
    {
        unsigned long timestamp_secs;
        
    
    
        return (timestamp_secs);
    }
    

    4377.cc_pal.h

    3782.user.h

    /*
     * nonos.c - CC31xx/CC32xx Host Driver Implementation
     *
     * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
     *
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    
    /*****************************************************************************/
    /* Include files                                                             */
    /*****************************************************************************/
    #include <ti/drivers/net/wifi/simplelink.h>
    #include <ti/drivers/net/wifi/source/protocol.h>
    #include <ti/drivers/net/wifi/source/driver.h>
    
    #ifndef SL_PLATFORM_MULTI_THREADED
    
    #include "nonos.h"
    
    _SlNonOsCB_t g__SlNonOsCB;
    
        _SlNonOsRetVal_t _SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Value)
    {
        *pSemObj = Value;
        return NONOS_RET_OK;
    }
    
    _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout)
    {
    #if (!defined (SL_TINY)) && (defined(sl_GetTimestamp))
          _SlTimeoutParams_t      TimeoutInfo={0};
    #endif
    
    	 /* If timeout 0 configured, just detect the value and return */
          if ((Timeout ==0) && (WaitValue == *((volatile _u8 *)pSyncObj)) )
    	  {
    		  *pSyncObj = SetValue;
    		  return NONOS_RET_OK;
    	  }
    
    #if (!defined (SL_TINY)) && (defined(sl_GetTimestamp))
          if ((Timeout != NONOS_WAIT_FOREVER) && (Timeout != NONOS_NO_WAIT))
          {
        	  _SlDrvStartMeasureTimeout(&TimeoutInfo, Timeout);
          }
    #endif
    
    #ifdef _SlSyncWaitLoopCallback
        _SlNonOsTime_t timeOutRequest = Timeout; 
    #endif
        while (Timeout>0)
        {
            if (WaitValue == *((volatile _u8 *)pSyncObj))
            {
                *pSyncObj = SetValue;
                break;
            }
    #if (!defined (sl_GetTimestamp)) ||  (defined (SL_TINY_EXT))
            if (Timeout != NONOS_WAIT_FOREVER)
            {		
                Timeout--;
            }
    #else        
            if ((Timeout != NONOS_WAIT_FOREVER) && (Timeout != NONOS_NO_WAIT))
            {
                if (_SlDrvIsTimeoutExpired(&TimeoutInfo))
                {
                	return (_SlNonOsRetVal_t)NONOS_RET_ERR;
                }
    
            }
     #endif       
    
            /* If we are in cmd context and waiting for its cmd response
             * do not handle spawn async events as the global lock was already taken */
            if (FALSE == g_pCB->WaitForCmdResp)
            {
            (void)_SlNonOsHandleSpawnTask();
            }
    #ifdef _SlSyncWaitLoopCallback
            if( (__NON_OS_SYNC_OBJ_SIGNAL_VALUE == WaitValue) && (timeOutRequest != NONOS_NO_WAIT) )
            {
                if (WaitValue == *((volatile _u8 *)pSyncObj))
                {
                    *pSyncObj = SetValue;
                    break;
                }
                _SlSyncWaitLoopCallback();
            }
    #endif
        }
    
        if (0 == Timeout)
        {
            return NONOS_RET_ERR;
        }
        else
        {
            return NONOS_RET_OK;
        }
    }
    
    _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry,
                                   void* pValue,
                                   _u32 flags)
    {
        _i8 i = 0;
    
        /* The parameter is currently not in use */
        (void)flags;
    
    #ifndef SL_TINY
        for(i = 0; i < NONOS_MAX_SPAWN_ENTRIES; i++)
    #endif
        {
            _SlNonOsSpawnEntry_t* pE = &g__SlNonOsCB.SpawnEntries[i];
    
            if(pE->IsAllocated == FALSE)
            {
                pE->pValue = pValue;
                pE->pEntry = pEntry;
                pE->IsAllocated = TRUE;
    #ifndef SL_TINY
                break;
    #endif
            }
        }
    
        return(NONOS_RET_OK);
    }
    
    _SlNonOsRetVal_t _SlNonOsHandleSpawnTask(void)
    {
        _i8 i = 0;
        void*  pValue;
    
    #ifndef SL_TINY
        for(i = 0; i < NONOS_MAX_SPAWN_ENTRIES; i++)
    #endif
        {
            _SlNonOsSpawnEntry_t* pE = &g__SlNonOsCB.SpawnEntries[i];
    
            if(pE->IsAllocated == TRUE)
            {
                _SlSpawnEntryFunc_t pF = pE->pEntry;
                pValue = pE->pValue;
    
                /* Clear the entry */
                pE->pEntry = NULL;
                pE->pValue = NULL;
                pE->IsAllocated = FALSE;
    
                /* execute the spawn function */
                pF(pValue);
            }
        }
        return(NONOS_RET_OK);
    }
    
    void tiDriverSpawnCallback(void)
    {
        /* If we are in cmd context and waiting for its cmd response
         * do not handle async events from spawn, as the global lock was already taken when sending the command,
         * and the Async event would be handled in read cmd context, so we do nothing.
         */
        if(FALSE == g_pCB->WaitForCmdResp)
        {
            (void)_SlNonOsHandleSpawnTask();
        }
    }
    
    #endif
    

    7041.nonos.h

    /*
     * device.c - CC31xx/CC32xx Host Driver Implementation
     *
     * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
     *
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    
    /*****************************************************************************/
    /* Include files                                                             */
    /*****************************************************************************/
    #include <ti/drivers/net/wifi/simplelink.h>
    #include <ti/drivers/net/wifi/source/protocol.h>
    #include <ti/drivers/net/wifi/source/driver.h>
    #include <ti/drivers/net/wifi/source/flowcont.h>
    
    /*****************************************************************************/
    /* Internal functions                                                        */
    /*****************************************************************************/
    
    static _i16 _SlDeviceGetStartResponseConvert(_i32 Status);
    void _SlDeviceHandleResetRequestInternally(void);
    void _SlDeviceResetRequestInitCompletedCB(_u32 Status,
                                              SlDeviceInitInfo_t *DeviceInitInfo);
    
    #define RESET_REQUEST_STOP_TIMEOUT (300)
    
    #ifndef SL_IF_OPEN_FLAGS
    #define SL_IF_OPEN_FLAGS (0x0)
    #endif
    
    #ifndef SL_IF_UART_REOPEN_FLAGS
    #define SL_IF_UART_REOPEN_FLAGS (0x1)
    #endif
    
    typedef struct
    {
        const void    *pIfHdl;   /* Holds the last opened interface handle */
        _i8         *pDevName; /* Holds the last opened interface parameters */
        _u32 ResetRequestSessionNumber;         /* Special session number to be verified upon every reset request during provisioning */
    } _SlDeviceCb_t;
    
    _SlDeviceCb_t DeviceCB; /* the device control block */
    
    static const _i16 StartResponseLUT[16] =
    {
        ROLE_RESERVED,
        ROLE_STA,
        SL_ERROR_ROLE_STA_ERR,
        ROLE_AP,
        SL_ERROR_ROLE_AP_ERR,
        ROLE_P2P,
        SL_ERROR_ROLE_P2P_ERR,
        SL_ERROR_CALIB_FAIL,
        SL_ERROR_FS_CORRUPTED_ERR,
        SL_ERROR_FS_ALERT_ERR,
        SL_ERROR_RESTORE_IMAGE_COMPLETE,
        SL_ERROR_INCOMPLETE_PROGRAMMING,
        ROLE_RESERVED2,
        SL_ERROR_GENERAL_ERR,
        SL_ERROR_GENERAL_ERR,
        SL_ERROR_GENERAL_ERR
    };
    
    static _i16 _SlDeviceGetStartResponseConvert(_i32 Status)
    {
        return(StartResponseLUT[Status & 0xF]);
    }
    
    /*****************************************************************************/
    /* API Functions                                                             */
    /*****************************************************************************/
    
    /*****************************************************************************/
    /* sl_Task                                                                   */
    /*****************************************************************************/
    #if _SL_INCLUDE_FUNC(sl_Task)
    void* sl_Task(void* pEntry)
    {
    #ifdef _SlTaskEntry
        return((void*)_SlTaskEntry());
    #else
        return((void*)0);
    #endif
    }
    
    #endif
    
    /*****************************************************************************/
    /* sl_Start                                                                  */
    /*****************************************************************************/
    #if _SL_INCLUDE_FUNC(sl_Start)
    _i16 sl_Start(const void* pIfHdl,
                  _i8*  pDevName,
                  const P_INIT_CALLBACK pInitCallBack)
    {
        _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
        InitComplete_t AsyncRsp;
    
        _SlDrvMemZero(&AsyncRsp, sizeof(InitComplete_t));
    
        /* verify no error handling in progress. if in progress than
           ignore the API execution and return immediately with an error */
        VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
        if(SL_IS_DEVICE_STARTED)
        {
            return(SL_RET_CODE_DEV_ALREADY_STARTED);
        }
        /* Perform any preprocessing before enable networking services */
    #ifdef sl_DeviceEnablePreamble
        sl_DeviceEnablePreamble();
    #endif
    
        /* ControlBlock init */
        (void)_SlDrvDriverCBInit();
    
        /* open the interface: usually SPI or UART */
        if(NULL == pIfHdl)
        {
            g_pCB->FD = sl_IfOpen((void *)pDevName, SL_IF_OPEN_FLAGS);
        }
        else
        {
            g_pCB->FD = (_SlFd_t)pIfHdl;
        }
    
        ObjIdx = _SlDrvProtectAsyncRespSetting((_u8 *)&AsyncRsp, START_STOP_ID,
                                               SL_MAX_SOCKETS);
    
        if(MAX_CONCURRENT_ACTIONS == ObjIdx)
        {
            return(SL_POOL_IS_EMPTY);
        }
    
        if(g_pCB->FD >= (_SlFd_t)0)
        {
            /* store the interface parameters for the internal call of the
               sl_start to be called upon reset request handling */
            DeviceCB.pIfHdl = pIfHdl;
            DeviceCB.pDevName = pDevName;
    
            /* Mark that device is in progress! */
            SL_SET_DEVICE_START_IN_PROGRESS;
    
            sl_DeviceDisable();
    
            sl_IfRegIntHdlr((SL_P_EVENT_HANDLER)_SlDrvRxIrqHandler, NULL);
    
            g_pCB->pInitCallback = pInitCallBack;
            sl_DeviceEnable();
    
            if(NULL == pInitCallBack)
            {
    #ifdef SL_TINY
                _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
    #else
    
                VERIFY_RET_OK(_SlDrvWaitForInternalAsyncEvent(ObjIdx,
                                                              INIT_COMPLETE_TIMEOUT,
                                                              SL_OPCODE_DEVICE_INITCOMPLETE));
    #endif
    
                SL_UNSET_DEVICE_START_IN_PROGRESS;
    
                SL_SET_DEVICE_STARTED;
    
                /* release Pool Object */
                _SlDrvReleasePoolObj(g_pCB->FunctionParams.AsyncExt.ActionIndex);
                return(_SlDeviceGetStartResponseConvert(AsyncRsp.Status));
            }
            else
            {
                return(SL_RET_CODE_OK);
            }
        }
        return(SL_BAD_INTERFACE);
    }
    
    #endif
    
    /***************************************************************************
       _SlDeviceHandleAsync_InitComplete - handles init complete signalling to
       a waiting object
     ****************************************************************************/
    _SlReturnVal_t _SlDeviceHandleAsync_InitComplete(void *pVoidBuf)
    {
        InitComplete_t     *pMsgArgs = (InitComplete_t *)_SL_RESP_ARGS_START(
            pVoidBuf);
        SlDeviceInitInfo_t DeviceInitInfo;
    
        SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
    
        if(g_pCB->pInitCallback)
        {
            DeviceInitInfo.ChipId = pMsgArgs->ChipId;
            DeviceInitInfo.MoreData = pMsgArgs->MoreData;
            g_pCB->pInitCallback(_SlDeviceGetStartResponseConvert(
                                     pMsgArgs->Status), &DeviceInitInfo);
        }
        else
        {
            sl_Memcpy(
                g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].
                pRespArgs,
                pMsgArgs, sizeof(InitComplete_t));
            SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.
                                                   ActionIndex].SyncObj);
        }
    
        SL_DRV_PROTECTION_OBJ_UNLOCK();
        if(g_pCB->pInitCallback)
        {
            SL_SET_DEVICE_STARTED;
            SL_UNSET_DEVICE_START_IN_PROGRESS;
            _SlDrvReleasePoolObj(g_pCB->FunctionParams.AsyncExt.ActionIndex);
        }
    
        return(SL_OS_RET_CODE_OK);
    }
    
    /***************************************************************************
       _SlDeviceHandleAsync_Stop - handles stop signalling to
       a waiting object
     ****************************************************************************/
    void _SlDeviceHandleAsync_Stop(void *pVoidBuf)
    {
        _BasicResponse_t     *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(
            pVoidBuf);
    
        VERIFY_SOCKET_CB(NULL != g_pCB->StopCB.pAsyncRsp);
    
        SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
    
        if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs !=
           NULL)
        {
            sl_Memcpy(
                g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].
                pRespArgs,
                pMsgArgs, sizeof(_BasicResponse_t));
            SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.
                                                   ActionIndex].SyncObj);
        }
    
        SL_DRV_PROTECTION_OBJ_UNLOCK();
    
        return;
    }
    
    /*****************************************************************************
       sl_stop
     ******************************************************************************/
    typedef union
    {
        SlDeviceStopCommand_t Cmd;
        _BasicResponse_t Rsp;
    }_SlStopMsg_u;
    
    static const _SlCmdCtrl_t _SlStopCmdCtrl =
    {
        SL_OPCODE_DEVICE_STOP_COMMAND,
        (_SlArgSize_t)sizeof(SlDeviceStopCommand_t),
        (_SlArgSize_t)sizeof(_BasicResponse_t)
    };
    
    #if _SL_INCLUDE_FUNC(sl_Stop)
    _i16 sl_Stop(const _u16 Timeout)
    {
        _i16 RetVal = 0;
        _SlStopMsg_u Msg;
        _BasicResponse_t AsyncRsp;
        _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
        _u8 ReleasePoolObject = FALSE;
        _u8 IsProvInProgress = FALSE;
    
        /* NOTE: don't check VERIFY_API_ALLOWED(), this command is not
         * filtered in error handling and also not filtered in NWP lock state.
         * If we are in the middle of assert handling than ignore stopping
         * the device with timeout and force immediate shutdown as we would like
         * to avoid any additional commands to the NWP */
        if((Timeout != 0) && (SL_IS_DEVICE_STARTED)
    #ifndef SL_TINY
           && (!SL_IS_RESTART_REQUIRED)
    #endif
           )
        {
            /* Clear the Async response structure */
            _SlDrvMemZero(&AsyncRsp, sizeof(_BasicResponse_t));
    
            /* let the device make the shutdown using the defined timeout */
            Msg.Cmd.Timeout = Timeout;
    
            IsProvInProgress = SL_IS_PROVISIONING_IN_PROGRESS;
    
            /* if provisioning in progress do not take pool object as we are not going to wait for it  */
            if(!IsProvInProgress)
            {
                ObjIdx =
                    _SlDrvProtectAsyncRespSetting((_u8 *)&AsyncRsp, START_STOP_ID,
                                                  SL_MAX_SOCKETS);
                if(MAX_CONCURRENT_ACTIONS == ObjIdx)
                {
                    return(SL_POOL_IS_EMPTY);
                }
    
                ReleasePoolObject = TRUE;
            }
    
            /* Set the stop-in-progress flag */
            SL_SET_DEVICE_STOP_IN_PROGRESS;
    
            VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlStopCmdCtrl, &Msg, NULL));
    
            /* Do not wait for stop async event if provisioning is in progress */
            if((SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status) && (!(IsProvInProgress)))
            {
    #ifdef SL_TINY
                _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
                /* Wait for sync object to be signaled */
    #else
    
                VERIFY_RET_OK(_SlDrvWaitForInternalAsyncEvent(ObjIdx,
                                                              STOP_DEVICE_TIMEOUT,
                                                              SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE));
    #endif
                Msg.Rsp.status = AsyncRsp.status;
                RetVal = Msg.Rsp.status;
            }
    
            /* Release pool object only if taken */
            if(ReleasePoolObject == TRUE)
            {
                _SlDrvReleasePoolObj(ObjIdx);
            }
    
            /* This macro wait for the NWP to raise a ready for shutdown indication.
             * This function is unique for the CC32XX family, and expected to return
             * in less than 600 mSec, which is the time takes for NWP to gracefully shutdown. */
            WAIT_NWP_SHUTDOWN_READY;
        }
        else
        {
            if((!SL_IS_DEVICE_STARTED)
    #ifndef SL_TINY
               && (!SL_IS_RESTART_REQUIRED)
    #endif
               )
            {
                sl_DeviceDisable();
                return(SL_RET_CODE_DEV_NOT_STARTED);
            }
            /* Set the stop-in-progress flag */
            SL_SET_DEVICE_STOP_IN_PROGRESS;
        }
        /* Release (signal) all active and pending commands */
        _SlDrvReleaseAllActivePendingPoolObj();
    
    #ifdef SL_PLATFORM_MULTI_THREADED
        /* Do not continue until all sync object deleted (in relevant context) */
        while(g_pCB->NumOfDeletedSyncObj < MAX_CONCURRENT_ACTIONS)
        {
            usleep(100000);
        }
    #endif
    
        /* Lock during stopping the interface */
        SL_DRV_LOCK_GLOBAL_LOCK_FOREVER(GLOBAL_LOCK_FLAGS_NONE);
    
        sl_IfRegIntHdlr(NULL, NULL);
        sl_DeviceDisable();
        RetVal = sl_IfClose(g_pCB->FD);
    
        (void)_SlDrvDriverCBDeinit();
    
        /* clear the stop-in-progress flag */
        SL_UNSET_DEVICE_STOP_IN_PROGRESS;
    
        /* clear the device started flag */
        SL_UNSET_DEVICE_STARTED;
    
        SL_DRV_LOCK_GLOBAL_UNLOCK(FALSE);
    
        return(RetVal);
    }
    
    #endif
    
    /*****************************************************************************
       sl_DeviceEventMaskSet
    *****************************************************************************/
    typedef union
    {
        SlDeviceMaskEventSetCommand_t Cmd;
        _BasicResponse_t Rsp;
    }_SlEventMaskSetMsg_u;
    
    #if _SL_INCLUDE_FUNC(sl_DeviceEventMaskSet)
    
    static const _SlCmdCtrl_t _SlEventMaskSetCmdCtrl =
    {
        SL_OPCODE_DEVICE_EVENTMASKSET,
        (_SlArgSize_t)sizeof(SlDeviceMaskEventSetCommand_t),
        (_SlArgSize_t)sizeof(_BasicResponse_t)
    };
    
    _i16 sl_DeviceEventMaskSet(const _u8 EventClass,
                               const _u32 Mask)
    {
        _SlEventMaskSetMsg_u Msg;
    
        /* verify that this api is allowed. if not allowed then
           ignore the API execution and return immediately with an error */
        VERIFY_API_ALLOWED(SL_OPCODE_SILO_DEVICE);
    
        Msg.Cmd.Group = EventClass;
        Msg.Cmd.Mask = Mask;
    
        VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlEventMaskSetCmdCtrl, &Msg,
                                  NULL));
    
        return((_i16)Msg.Rsp.status);
    }
    
    #endif
    
    /******************************************************************************
       sl_EventMaskGet
    ******************************************************************************/
    typedef union
    {
        SlDeviceMaskEventGetCommand_t Cmd;
        SlDeviceMaskEventGetResponse_t Rsp;
    }_SlEventMaskGetMsg_u;
    
    #if _SL_INCLUDE_FUNC(sl_DeviceEventMaskGet)
    
    static const _SlCmdCtrl_t _SlEventMaskGetCmdCtrl =
    {
        SL_OPCODE_DEVICE_EVENTMASKGET,
        (_SlArgSize_t)sizeof(SlDeviceMaskEventGetCommand_t),
        (_SlArgSize_t)sizeof(SlDeviceMaskEventGetResponse_t)
    };
    
    _i16 sl_DeviceEventMaskGet(const _u8 EventClass,
                               _u32 *pMask)
    {
        _SlEventMaskGetMsg_u Msg;
    
        /* verify that this api is allowed. if not allowed then
           ignore the API execution and return immediately with an error */
        VERIFY_API_ALLOWED(SL_OPCODE_SILO_DEVICE);
    
        Msg.Cmd.Group = EventClass;
    
        VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlEventMaskGetCmdCtrl, &Msg,
                                  NULL));
    
        *pMask = Msg.Rsp.Mask;
    
        return(SL_RET_CODE_OK);
    }
    
    #endif
    
    /******************************************************************************
       sl_DeviceGet
    ******************************************************************************/
    
    typedef union
    {
        SlDeviceSetGet_t Cmd;
        SlDeviceSetGet_t Rsp;
    }_SlDeviceMsgGet_u;
    
    #if _SL_INCLUDE_FUNC(sl_DeviceGet)
    
    static const _SlCmdCtrl_t _SlDeviceGetCmdCtrl =
    {
        SL_OPCODE_DEVICE_DEVICEGET,
        (_SlArgSize_t)sizeof(SlDeviceSetGet_t),
        (_SlArgSize_t)sizeof(SlDeviceSetGet_t)
    };
    
    _i16 sl_DeviceGet(const _u8 DeviceGetId,
                      _u8 *pOption,
                      _u16 *pConfigLen,
                      _u8 *pValues)
    {
        _SlDeviceMsgGet_u Msg;
        _SlCmdExt_t CmdExt;
    
        /* verify that this api is allowed. if not allowed then
           ignore the API execution and return immediately with an error */
        VERIFY_API_ALLOWED(SL_OPCODE_SILO_DEVICE);
    
        if(*pConfigLen == 0)
        {
            return(SL_EZEROLEN);
        }
    
        if(pOption)
        {
            _SlDrvResetCmdExt(&CmdExt);
            CmdExt.RxPayloadLen = (_i16) * pConfigLen;
            CmdExt.pRxPayload = (_u8 *)pValues;
    
            Msg.Cmd.DeviceSetId = DeviceGetId;
    
            Msg.Cmd.Option = (_u16) * pOption;
    
            VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlDeviceGetCmdCtrl, &Msg,
                                      &CmdExt));
    
            if(pOption)
            {
                *pOption = (_u8)Msg.Rsp.Option;
            }
    
            if(CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen)
            {
                *pConfigLen = (_u16)CmdExt.RxPayloadLen;
    
                return(SL_ESMALLBUF);
            }
            else
            {
                *pConfigLen = (_u16)CmdExt.ActualRxPayloadLen;
            }
    
            return((_i16)Msg.Rsp.Status);
        }
        else
        {
            return(SL_RET_CODE_INVALID_INPUT);
        }
    }
    
    #endif
    
    /******************************************************************************
       sl_DeviceSet
    ******************************************************************************/
    typedef union
    {
        SlDeviceSetGet_t Cmd;
        _BasicResponse_t Rsp;
    }_SlDeviceMsgSet_u;
    
    #if _SL_INCLUDE_FUNC(sl_DeviceSet)
    
    static const _SlCmdCtrl_t _SlDeviceSetCmdCtrl =
    {
        SL_OPCODE_DEVICE_DEVICESET,
        (_SlArgSize_t)sizeof(SlDeviceSetGet_t),
        (_SlArgSize_t)sizeof(_BasicResponse_t)
    };
    
    _i16 sl_DeviceSet(const _u8 DeviceSetId,
                      const _u8 Option,
                      const _u16 ConfigLen,
                      const _u8 *pValues)
    {
        _SlDeviceMsgSet_u Msg;
        _SlCmdExt_t CmdExt;
    
        /* verify that this api is allowed. if not allowed then
           ignore the API execution and return immediately with an error */
        VERIFY_API_ALLOWED(SL_OPCODE_SILO_DEVICE);
    
        _SlDrvResetCmdExt(&CmdExt);
    
        CmdExt.TxPayload1Len = (ConfigLen + 3) & (~3);
        CmdExt.pTxPayload1 = (_u8 *)pValues;
    
        Msg.Cmd.DeviceSetId = DeviceSetId;
        Msg.Cmd.ConfigLen = ConfigLen;
        Msg.Cmd.Option = Option;
    
        VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlDeviceSetCmdCtrl, &Msg,
                                  &CmdExt));
    
        return((_i16)Msg.Rsp.status);
    }
    
    #endif
    
    /******************************************************************************
       _SlDeviceEventHandler - handles internally device async events
    ******************************************************************************/
    _SlReturnVal_t _SlDeviceEventHandler(void* pEventInfo)
    {
        DeviceEventInfo_t*    pInfo = (DeviceEventInfo_t*)pEventInfo;
        _SlResponseHeader_t*  pHdr = (_SlResponseHeader_t *)pInfo->pAsyncMsgBuff;
        _BasicResponse_t     *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(
            pHdr);
        SlDeviceEvent_t DeviceEvent;
    
        _SlDrvMemZero(&DeviceEvent, sizeof(DeviceEvent));
    
        switch(pHdr->GenHeader.Opcode)
        {
        case SL_OPCODE_DEVICE_INITCOMPLETE:
            _SlDeviceHandleAsync_InitComplete(pHdr);
            break;
        case SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE:
            _SlDeviceHandleAsync_Stop(pHdr);
            break;
        case SL_OPCODE_DEVICE_RESET_REQUEST_ASYNC_EVENT:
        {
            SlDeviceResetRequestData_t *pResetRequestData =
                (SlDeviceResetRequestData_t*)pMsgArgs;
    
    #if defined(slcb_DeviceGeneralEvtHdlr) || \
            defined (EXT_LIB_REGISTERED_GENERAL_EVENTS)
            if(pResetRequestData->Caller ==
               SL_DEVICE_RESET_REQUEST_CALLER_PROVISIONING_EXTERNAL_CONFIGURATION)
            {
                /* call the registered events handlers (application/external lib) */
                DeviceEvent.Id = SL_DEVICE_EVENT_RESET_REQUEST;
                DeviceEvent.Data.ResetRequest.Status = 0;
                DeviceEvent.Data.ResetRequest.Caller = pResetRequestData->Caller;
                _SlDrvHandleGeneralEvents(&DeviceEvent);
                break;
            }
    #endif
    
            if(!_SlDrvIsApiInProgress() && SL_IS_PROVISIONING_IN_PROGRESS)
            {
                if(pResetRequestData->SessionNumber !=
                   DeviceCB.ResetRequestSessionNumber)
                {
                    /* store the last session number */
                    DeviceCB.ResetRequestSessionNumber =
                        pResetRequestData->SessionNumber;
    
                    /* perform the reset request */
                    _SlDeviceHandleResetRequestInternally();
                }
            }
        }
        break;
    
        case SL_OPCODE_DEVICE_ABORT:
        {
            /* release global lock of cmd context */
            if(pInfo->bInCmdContext == TRUE)
            {
                SL_DRV_LOCK_GLOBAL_UNLOCK(TRUE);
            }
    
    #ifndef SL_TINY
            _SlDrvHandleFatalError(SL_DEVICE_EVENT_FATAL_DEVICE_ABORT,
                                   *((_u32*)pMsgArgs - 1),     /* Abort type */
                                   *((_u32*)pMsgArgs));        /* Abort data */
    #endif
        }
        break;
    
        case  SL_OPCODE_DEVICE_DEVICE_ASYNC_GENERAL_ERROR:
        {
    #if defined(slcb_DeviceGeneralEvtHdlr) || \
            defined (EXT_LIB_REGISTERED_GENERAL_EVENTS)
    
            DeviceEvent.Id = SL_DEVICE_EVENT_ERROR;
            DeviceEvent.Data.Error.Code = pMsgArgs->status;
            DeviceEvent.Data.Error.Source = (SlDeviceSource_e)pMsgArgs->sender;
            _SlDrvHandleGeneralEvents(&DeviceEvent);
    #endif
        }
        break;
    
        case SL_OPCODE_DEVICE_FLOW_CTRL_ASYNC_EVENT:
            _SlFlowContSet((void *)pHdr);
            break;
        default:
            SL_ERROR_TRACE2(
                MSG_306,
                "ASSERT: _SlDeviceEventHandler : invalid opcode = 0x%x = %1",
                pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode);
        }
    
        return(SL_OS_RET_CODE_OK);
    }
    
    void _SlDeviceResetRequestInitCompletedCB(_u32 Status,
                                              SlDeviceInitInfo_t *DeviceInitInfo)
    {
        /* Do nothing...*/
    }
    
    void _SlDeviceHandleResetRequestInternally(void)
    {
        _u8 irqCountLast = RxIrqCnt;
    #if (!defined (SL_TINY)) && (defined(slcb_GetTimestamp))
        _SlTimeoutParams_t TimeoutInfo = {0};
    
        _SlDrvStartMeasureTimeout(&TimeoutInfo, 2 * RESET_REQUEST_STOP_TIMEOUT);
    #endif
    
        /* Here we send stop command with timeout, but the API will not blocked
           Till the stop complete event is received as we in the middle of async event handling */
        sl_Stop(RESET_REQUEST_STOP_TIMEOUT);
    
        /* wait till the stop complete cmd & async
           event messages are received (2 Irqs) */
        do
        {
    #if (!defined (SL_TINY)) && (defined(slcb_GetTimestamp))
            if(_SlDrvIsTimeoutExpired(&TimeoutInfo))
            {
                break;
            }
    #endif
        }
        while((RxIrqCnt - irqCountLast) < 2);
    
        /* start the device again */
        sl_Start(DeviceCB.pIfHdl, DeviceCB.pDevName,
                 _SlDeviceResetRequestInitCompletedCB);
    }
    
    /******************************************************************************
       sl_DeviceUartSetMode
    ******************************************************************************/
    #ifdef SL_IF_TYPE_UART
    typedef union
    {
        SlDeviceUartSetModeCommand_t Cmd;
        SlDeviceUartSetModeResponse_t Rsp;
    }_SlUartSetModeMsg_u;
    
    #if _SL_INCLUDE_FUNC(sl_DeviceUartSetMode)
    
    const _SlCmdCtrl_t _SlUartSetModeCmdCtrl =
    {
        SL_OPCODE_DEVICE_SETUARTMODECOMMAND,
        (_SlArgSize_t)sizeof(SlDeviceUartSetModeCommand_t),
        (_SlArgSize_t)sizeof(SlDeviceUartSetModeResponse_t)
    };
    
    _i16 sl_DeviceUartSetMode(const SlDeviceUartIfParams_t *pUartParams)
    {
        _SlUartSetModeMsg_u Msg;
        _u32 magicCode = (_u32)0xFFFFFFFF;
    
        Msg.Cmd.BaudRate = pUartParams->BaudRate;
        Msg.Cmd.FlowControlEnable = pUartParams->FlowControlEnable;
    
        VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlUartSetModeCmdCtrl, &Msg,
                                  NULL));
    
        /* cmd response OK, we can continue with the handshake */
        if(SL_RET_CODE_OK == Msg.Rsp.status)
        {
            sl_IfMaskIntHdlr();
    
            /* Close the comm port */
            sl_IfClose(g_pCB->FD);
    
            /* Re-open the comm port */
            sl_IfOpen((void * )pUartParams, SL_IF_UART_REOPEN_FLAGS);
    
            sl_IfUnMaskIntHdlr();
    
            /* send the magic code and wait for the response */
            sl_IfWrite(g_pCB->FD, (_u8* )&magicCode, 4);
    
            magicCode = UART_SET_MODE_MAGIC_CODE;
            sl_IfWrite(g_pCB->FD, (_u8* )&magicCode, 4);
    
            /* clear magic code */
            magicCode = 0;
    
            /* wait (blocking) till the magic code to be returned from device */
            sl_IfRead(g_pCB->FD, (_u8* )&magicCode, 4);
    
            /* check for the received magic code matching */
            if(UART_SET_MODE_MAGIC_CODE != magicCode)
            {
                _SL_ASSERT(0);
            }
        }
    
        return((_i16)Msg.Rsp.status);
    }
    
    #endif
    #endif
    

  • Hi Wai,

    The CC3100 documentation does a better job of summarizing the UART host command flow, but it's the same sequence as CC3120: processors.wiki.ti.com/.../CC3100_UART_Host_Interface

    If also looks like you've commented out your slcb_GetTimestamp define in user.h at line 712. Can you verify you have slcb_GetTimestamp and SL_TIMESTAMP_TICKS_IN_10_MILLISECONDS (at the top of user.h) defined accurately?

    Best regards,
    Sarah
  • Hi Sarah,

    Thanks for reviewing the files.

    From the documentation it seemed to indicate that slcb_GetTimestamp didn't necessarily needed to be defined.  I'll define them and update this post with my findings.

    Cheers,

    Wai

  • Hello Sarah,

    I've defined slcb_GetTimestamp and verified SL_TIMESTAMP_TICKS_IN_10_MILLISECONDS is defined correctly, but I have the same issue.

    I scoped the IRQ and the CC3120_TX lines and see that there is activity on CC3120_TX before IRQ becomes active (delta of about 26 microseconds) which is not what I expected when I look at the timing diagram on http://processors.wiki.ti.com/index.php/CC3100_UART_Host_Interface 

    Can you explain why that would be?

    Edit Also, the Host_RTS doesn't toggle high in the middle of the short sync bytes.

    Thanks,

    Wai

  • Hello Sarah,

    I am getting a SL_ERROR_ROLE_AP_ERR value returned from sl_Start().

    Also I inserted a break point after the sl_Start() call and I get the following values:
    RxIrqCnt = 0x02
    g_pCB.RxDonCnt = 0x01
    g__SlNonOsCB.SpawnEntries[0].pEntry = <address of _SlDrvMsgReadSpawnCtx>

    Are these correct?

    Thanks,
    Wai
  • Hello Sarah,

    I am getting a ROLE_AP value returned from sl_Start().

    Also I inserted a break point after the sl_Start() call and I get the following values:
    RxIrqCnt = 0x01
    g_pCB.RxDoneCnt = 0x01

    The issue was how I was reading the bytes off the UART HW FIFO.

    However, after sl_Start() is complete, Host IRQ line is stuck high. Do you know why that might be?

    Thanks,
    Wai
  • Hi Wai,

    It looks Michael has given a more recent response to this issue. Please continue support on one thread: e2e.ti.com/.../2902118

    Best regards,
    Sarah