Difference between revisions of "Zephyr rtos threads"
From Wiki at Neela Nurseries
m (→^ Example Zephyr Thread Creation) |
m (→^ Specific Function Associated With Zephyr Thread) |
||
Line 92: | Line 92: | ||
168 } | 168 } | ||
</pre> | </pre> | ||
+ | |||
+ | <pre> | ||
+ | 150:static void connect_work_fn(struct k_work *work) | ||
+ | 338: k_work_init_delayable(&connect_work, connect_work_fn); | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | |||
+ | z |
Revision as of 23:22, 28 September 2021
Some Zephyr RTOS API functions to learn:
- k_sem_take(<e_connected, K_FOREVER);
- k_work_schedule(&connect_work, K_NO_WAIT);
Unsure whether this routine a Zephyr one:
work_init();
Following non-function entities from aws_iot main.c appear important:
77 static struct k_work_delayable shadow_update_work; 78 static struct k_work_delayable connect_work; 79 static struct k_work shadow_update_version_work;
^ Specific Zephyr documentation pages
^ Example Zephyr Thread Creation
Rough search narrowing in on specific thread creation and use in aws_iot sample project from nRF Connect SDK:
cpguest@ubuntu-vm-0p2:/mnt/host-os-dev-area/pulse-pro/firmware-stage1/aws-iot-stand-alone/src$ grep -nr k_ ./*.c 30:static struct k_work_delayable shadow_update_work; 31:static struct k_work_delayable connect_work; 32:static struct k_work shadow_update_version_work; 150:static void connect_work_fn(struct k_work *work) 166: k_work_schedule(&connect_work, 170:static void shadow_update_work_fn(struct k_work *work) 186: k_work_schedule(&shadow_update_work, 190:static void shadow_update_version_work_fn(struct k_work *work) 242: (void)k_work_cancel_delayable(&connect_work); 258: k_work_submit(&shadow_update_version_work); 262: k_work_schedule(&shadow_update_work, 283: (void)k_work_cancel_delayable(&shadow_update_work); 284: k_work_schedule(&connect_work, K_NO_WAIT); 335:static void work_init(void) 337: k_work_init_delayable(&shadow_update_work, shadow_update_work_fn); 338: k_work_init_delayable(&connect_work, connect_work_fn); 339: k_work_init(&shadow_update_version_work, shadow_update_version_work_fn); 356: k_sem_give(<e_connected); 513: work_init(); 523: k_sem_take(<e_connected, K_FOREVER); 528: k_work_schedule(&connect_work, K_NO_WAIT); cpguest@ubuntu-vm-0p2:/mnt/host-os-dev-area/pulse-pro/firmware-stage1/aws-iot-stand-alone/src$ grep -n connect_work ./*.c 31:static struct k_work_delayable connect_work; 150:static void connect_work_fn(struct k_work *work) 166: k_work_schedule(&connect_work, 242: (void)k_work_cancel_delayable(&connect_work); 284: k_work_schedule(&connect_work, K_NO_WAIT); 338: k_work_init_delayable(&connect_work, connect_work_fn); 528: k_work_schedule(&connect_work, K_NO_WAIT); cpguest@ubuntu-vm-0p2:/mnt/host-os-dev-area/pulse-pro/firmware-stage1/aws-iot-stand-alone/src$
. . .
^ Specific Function Associated With Zephyr Thread
150 static void connect_work_fn(struct k_work *work) 151 { 152 int err; 153 154 if (cloud_connected) { 155 return; 156 } 157 158 err = aws_iot_connect(NULL); 159 if (err) { 160 printk("aws_iot_connect, error: %d\n", err); 161 } 162 163 printk("Next connection retry in %d seconds\n", 164 CONFIG_CONNECTION_RETRY_TIMEOUT_SECONDS); 165 166 k_work_schedule(&connect_work, 167 K_SECONDS(CONFIG_CONNECTION_RETRY_TIMEOUT_SECONDS)); 168 }
150:static void connect_work_fn(struct k_work *work) 338: k_work_init_delayable(&connect_work, connect_work_fn);
z