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.

CC3200-LAUNCHXL: File operation using FreeRTOS

Part Number: CC3200-LAUNCHXL

Hi,

Recently I need to include file operation under FreeRTOS, which means I need to start simplelink task before using API such as FsOpen, FsWrite, FsRead.

And it works fine after I combined Mqtt-Client example code and file-opertation example code.

Additionally, I want to add one function which includes push button interrupt handler.

Idea is to access FsOpen & FsWrite when press SW2 button.

I put  WriteFileToDevice API into pushButtonInterruptHandler2, but it stuck in sl_FsOpen() before sl_FsWrite(), even if I add sl_start() before sl_FsOpen(), it stuck in sl_start().

Could anyone help?  

Thanks!

void pushButtonInterruptHandler2()
{

if(WriteFileToDevice(&ulToken, &lFileHandle) < 0)
{

GPIO_IF_LedOn(MCU_RED_LED_GPIO);
}

// Restart system
MAP_PRCMHibernateIntervalSet(330);
MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);
MAP_PRCMHibernateEnter();

}

  • Hello,

    It is very reasky to use it as follows.

    The reason is that pushing a button may generate more than a single press.

    Regardless, this is an HWI and it is adviced to do as less as possible from the handler.

    I suggest using a simple que with 1-byte messages to signal what you want to do and then implement it on your main loop/task.

    You can see an example in mqtt_client example, and you should see the initialization:

    Button_IF_Init(pushButtonInterruptHandler2,pushButtonInterruptHandler3);

    The handlers are as follws:

    void pushButtonInterruptHandler2()
    {
    	event_msg msg;
    
        msg.event = PUSH_BUTTON_SW2_PRESSED;
        msg.hndl = NULL;
        //
        // write message indicating publish message
        //
        osi_MsgQWrite(&g_PBQueue,&msg,OSI_NO_WAIT);
    }

    and

    void pushButtonInterruptHandler3()
    {
    	event_msg msg;
    	msg.event = PUSH_BUTTON_SW3_PRESSED;
        msg.hndl = NULL;
        //
        // write message indicating exit from sending loop
        //
        osi_MsgQWrite(&g_PBQueue,&msg,OSI_NO_WAIT);
    
    }

    Regards,

    Shlomi

  • Hi, Shlomi,

    This solved my problem.

    I create a task in main(based on Mqtt_Client example code), and make the osi_MsgQRead() with a loop in this task.
    In the pushButtonInterruptHandler2(), signal a queue to trigger message to implement writefile operation.
    Thanks a lot!

    void pushButtonInterruptHandler2()
    {
    event_msg msg;
    msg.event = PUSH_BUTTON_SW2_PRESSED;
    msg.hndl = NULL;
    osi_MsgQWrite(&g_PBQueue,&msg,OSI_NO_WAIT);
    Button_IF_EnableInterrupt(SW2);
    }

    /*New task*/
    void NewTask(void *pvParameters)
    {
    event_msg RecvQue;

    for(;;)
    {
    osi_MsgQRead( &g_PBQueue, &RecvQue, OSI_WAIT_FOREVER);
    if(PUSH_BUTTON_SW2_PRESSED == RecvQue.event)
    {
    if(WriteFileToDevice(&ulToken, &lFileHandle) < 0)
    ...............
    }
    }
    }



    Regards,

    Lex