Migration to new chThdCreateI

Discussions and support about ChibiOS/RT, the free embedded RTOS.
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Migration to new chThdCreateI

Postby vrollei » Thu Jan 25, 2018 3:15 pm

Hi,

What is the right way to migrate form old chThdCreateI API?

Old:

Code: Select all

osCreateTask(const char_t *name, OsTaskCode taskCode,
   void *params, size_t stackSize, int_t priority)
{
  void *wa;
  thread_t *tp;
  stackSize *= sizeof(uint_t);
  wa = osAllocMem(THD_WORKING_AREA_SIZE(stackSize));
  tp = chThdCreateI(wa, THD_WORKING_AREA_SIZE(stackSize), priority, (tfunc_t) taskCode, params);
  chSchWakeupS(tp, MSG_OK);
}


New:

Code: Select all

osCreateTask(const char_t *name, OsTaskCode taskCode,
   void *params, size_t stackSize, int_t priority)
{
  void *wa;
  thread_t *tp;
  stackSize *= sizeof(uint_t);
  wa = osAllocMem(THD_WORKING_AREA_SIZE(stackSize));
  thread_descriptor_t td = {name, THD_WORKING_AREA_BASE(wa), THD_WORKING_AREA_BASE(wa) + THD_WORKING_AREA_SIZE(stackSize) / sizeof (stkalign_t), priority,  (tfunc_t) taskCode, params};
  tp = chThdCreateI(&td)
  chSchRescheduleS();
}
Vitaly

Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 8 guests