MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / sys_rt_timer_create

Function sys_rt_timer_create

components/lwp/lwp_syscall.c:2860–2897  ·  view source on GitHub ↗

* @brief Creates a timer. * * This system call creates a timer that can be used to trigger events or * actions after a specified timeout or interval. The timer will operate in a * real-time manner and can be configured to trigger once or repeatedly. The * created timer can be started, stopped, or deleted as required. * * @param[in] name The name of the timer. It should be a unique string

Source from the content-addressed store, hash-verified

2858 * undesired behavior, especially if the timer is periodic.
2859 */
2860rt_timer_t sys_rt_timer_create(const char *name,
2861 void *data,
2862 rt_tick_t time,
2863 rt_uint8_t flag)
2864{
2865 int len = 0;
2866 char *kname = RT_NULL;
2867 rt_timer_t timer = RT_NULL;
2868
2869 len = lwp_user_strlen(name);
2870 if (len <= 0)
2871 {
2872 return RT_NULL;
2873 }
2874
2875 kname = (char *)kmem_get(len + 1);
2876 if (!kname)
2877 {
2878 return RT_NULL;
2879 }
2880
2881 if (lwp_get_from_user(kname, (void *)name, len + 1) != (len + 1))
2882 {
2883 kmem_put(kname);
2884 return RT_NULL;
2885 }
2886
2887 timer = rt_timer_create(kname, timer_timeout_callback, (void *)data, time, flag);
2888 if (lwp_user_object_add(lwp_self(), (rt_object_t)timer) != 0)
2889 {
2890 rt_timer_delete(timer);
2891 timer = NULL;
2892 }
2893
2894 kmem_put(kname);
2895
2896 return timer;
2897}
2898
2899/**
2900 * @brief Deletes a timer.

Callers

nothing calls this directly

Calls 8

lwp_user_strlenFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
kmem_putFunction · 0.85
rt_timer_createFunction · 0.85
lwp_user_object_addFunction · 0.85
lwp_selfFunction · 0.85
rt_timer_deleteFunction · 0.85

Tested by

no test coverage detected