* @brief This function will initialize a thread. It's used to initialize a * static thread object. * * @param thread Thread handle. Thread handle is provided by the user and * points to the corresponding thread control block memory address. * * @param name Name of the thread (shall be unique); the maximum length of the * thread name is specified
| 337 | * If the return value is any other values, it means this operation failed. |
| 338 | */ |
| 339 | rt_err_t rt_thread_init(struct rt_thread *thread, |
| 340 | const char *name, |
| 341 | void (*entry)(void *parameter), |
| 342 | void *parameter, |
| 343 | void *stack_start, |
| 344 | rt_uint32_t stack_size, |
| 345 | rt_uint8_t priority, |
| 346 | rt_uint32_t tick) |
| 347 | { |
| 348 | /* parameter check */ |
| 349 | RT_ASSERT(thread != RT_NULL); |
| 350 | RT_ASSERT(stack_start != RT_NULL); |
| 351 | RT_ASSERT(tick != 0); |
| 352 | |
| 353 | /* clean memory data of thread */ |
| 354 | rt_memset(thread, 0x0, sizeof(struct rt_thread)); |
| 355 | |
| 356 | /* initialize thread object */ |
| 357 | rt_object_init((rt_object_t)thread, RT_Object_Class_Thread, name); |
| 358 | |
| 359 | return _thread_init(thread, |
| 360 | name, |
| 361 | entry, |
| 362 | parameter, |
| 363 | stack_start, |
| 364 | stack_size, |
| 365 | priority, |
| 366 | tick); |
| 367 | } |
| 368 | RTM_EXPORT(rt_thread_init); |
| 369 | |
| 370 | /** |