Starting a Zephyr thread manually

I am using Visual Studio for my creating software the nRF52840 running Zephyr.

I create a Zephyr thread using K_THREAD_DEFINE. All works fine, but I need to modify the code to start the task manually instead of after a delay, so I had planned to use a call to "k_thread_start". 

The documentation for "k_thread_start" suggests that I can use the value of  K_FOREVER for the delay parameter of K_THREAD_DEFINE.

So I tried this...

K_THREAD_DEFINE( app_GnssMsgSimulate_thread_id,
                 CONFIG_GNSSMSG_SIMULATE_STACKSIZE,
                 App_Task_GnssRxData_Process,
                 NULL /* 1st entry point parameter*/,
                 NULL /* 2nd entry point parameter*/,
                 NULL /* 3rd entry point parameter*/,
                 CONFIG_GNSSMSG_SIMULATE_PRIORITY,
                 0 /* options = 0*/,
                 K_FOREVER /*do not automatically start*/
               );

...and got the following compile message...

In file included from C:\SwTools\ncs\v2.0.2\zephyr\include\zephyr\init.h:11,
                 from C:\SwTools\ncs\v2.0.2\zephyr\include\zephyr\device.h:29,
                 from c:\Users\info\Dropbox\CoAutomation\64Seconds\XYZSensor2\src\AppXYZSensor.h:31,
                 from c:\Users\info\Dropbox\CoAutomation\64Seconds\XYZSensor2\src\AppXYZSensor.c:56:
C:\SwTools\ncs\v2.0.2\zephyr\include\zephyr\kernel.h:627:16: error: incompatible types when initializing type 'int' using type 'k_timeout_t'
  627 |  .init_delay = (delay),                                   \
      |                ^
C:\SwTools\ncs\v2.0.2\zephyr\include\zephyr\kernel.h:671:3: note: in expansion of macro 'Z_THREAD_INITIALIZER'
  671 |   Z_THREAD_INITIALIZER(&_k_thread_obj_##name,   \
      |   ^~~~~~~~~~~~~~~~~~~~
c:\Users\info\Dropbox\CoAutomation\64Seconds\XYZSensor2\src\AppXYZSensor.c:599:1: note: in expansion of macro 'K_THREAD_DEFINE'
  599 | K_THREAD_DEFINE( app_GnssMsgSimulate_thread_id,
      | ^~~~~~~~~~~~~~~

.

The problem seems to be that K_FOREVER eventually translates into a usage of K_TICKS_FOREVER, which is...
#define K_TICKS_FOREVER   ((k_ticks_t) -1)

The value of type k_ticks_t is not compatible with the value for .int_delay which is an int.

Can someone make a suggestion of how I can delay thread start "forever"?

Thank you
-Craig Goldman

Related