1 Reply Latest reply on Sep 19, 2019 11:51 PM by AnjanaM_61

    Create a thread of rtos, but it doesn't work!

    waer_4412851

      Hi,

      I create a thread,but it doesn't work in ble_remote part of sdk20735B1,code as following,

      (ble_remote.c)

      #include "wiced_rtos.h"

      wiced_thread_t * ir_led_thread;

      wiced_queue_t * button_queue;

       

      /* Thread function to control the LED */

      void IrLedControl( uint32_t arg )

      {

          uint8_t key_state;

       

          while(1)

          {

              WICED_BT_TRACE("IrLedControl wait\n");

              /* Wait for button press semaphore */

              wiced_rtos_pop_from_queue( button_queue, &key_state, WICED_WAIT_FOREVER );

       

              KeyMatrixHandle(key_state);

            

              WICED_BT_TRACE("IrLedControl\n");

          }

      }

       

      void bleremoteapp_create(void)

      {

          uint8_t thread_init_result;

        

          WICED_BT_TRACE("bleremoteapp_create\n");

        

          /* Setup the semaphore */

          button_queue = wiced_rtos_create_queue();

          wiced_rtos_init_queue(button_queue, "queue", 1, 10);

       

          /* Start a thread to control LED blinking */

          ir_led_thread = wiced_rtos_create_thread();       // Get memory for the thread handle

          thread_init_result = wiced_rtos_init_thread(

                                  ir_led_thread,                  // Thread handle

                                  5,                // Priority

                                  "LED Toggle",                   // Name

                                  IrLedControl,                   // Function

                                  1024,          // Stack

                                  NULL );

        

          WICED_BT_TRACE("thread_init_result=%d\n", thread_init_result);  

       

      static void KeyMatrixInterruptHandler(void* user_data, uint8_t value)

      {

          uint8_t read_data;  

        

          read_data = KeyMatrixReadByte(INPORT_REG_ADDR);        //read inport register status

          WICED_BT_TRACE("KeyMatrixInterruptHandler read_data = %02x\n", read_data);

        

          key_state = read_data;

          wiced_rtos_push_to_queue( button_queue, &key_state, WICED_NO_WAIT );

      }

       

      1. the result of wiced_rtos_create_thread() is '0'

      2.the KeyMatrixInterruptHandler() was executed, and the value of key_state is 0x7b

      3.KeyMatrixHandle(key_state) can't be executed.

       

      Is there setting error?

      Looking forward to reply´╝î thanks