Skip to content

Commit 014f83b

Browse files
committed
7.1.0-beta2
updated zephyr port
1 parent e1e4066 commit 014f83b

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

zephyr/qf_port.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
2424
============================================================================*/
2525
/*!
26-
* @date Last updated on: 2022-08-16
26+
* @date Last updated on: 2022-08-24
2727
* @version Last updated for: @ref qpc_7_1_0
2828
*
2929
* @file
@@ -42,9 +42,6 @@
4242

4343
Q_DEFINE_THIS_MODULE("qf_port")
4444

45-
/* QF_MAX_ACTIVE cannot exceed the limit in QF */
46-
Q_ASSERT_STATIC(QF_MAX_ACTIVE <= 64);
47-
4845
/*..........................................................................*/
4946
struct k_spinlock QF_spinlock;
5047

@@ -56,9 +53,13 @@ void QF_init(void) {
5653
int_t QF_run(void) {
5754
QF_onStartup();
5855
#ifdef Q_SPY
59-
// lower the priority of the main thread to the level of idle
56+
57+
#if CONFIG_NUM_PREEMPT_PRIORITIES > 0
58+
/* lower the priority of the main thread to the level of idle thread */
6059
k_thread_priority_set(k_current_get(),
6160
CONFIG_NUM_PREEMPT_PRIORITIES - 1);
61+
#endif
62+
6263
/* perform QS work... */
6364
while (true) {
6465
QS_rxParse(); /* parse any QS-RX bytes */
@@ -92,10 +93,15 @@ static void thread_entry(void *p1, void *p2, void *p3) {
9293
* set the options for the Zephyr thread (attr1) and thread name (attr2).
9394
* QActive_setAttr() needs to be called *before* QACTIVE_START() for the
9495
* given active object.
96+
*
97+
* In this Zephyr port the attributes will be used as follows (see also
98+
* Active_start_()):
99+
* - attr1 - will be used for thread options in k_thread_create()
100+
* - attr2 - will be used for thread name in k_thread_name_set()
95101
*/
96102
void QActive_setAttr(QActive *const me, uint32_t attr1, void const *attr2) {
97-
me->thread.base.order_key = attr1; /* temporarily save attr1 */
98-
me->thread.init_data = (void *)attr2; /* temporarily save attr2 */
103+
me->thread.base.order_key = attr1; /* will be used for thread options */
104+
me->thread.init_data = (void *)attr2; /* will be used for thread name */
99105
}
100106
/*..........................................................................*/
101107
void QActive_start_(QActive * const me, QPrioSpec const prio,
@@ -115,15 +121,16 @@ void QActive_start_(QActive * const me, QPrioSpec const prio,
115121
/* Zephyr uses the reverse priority numbering than QP */
116122
int zprio = (int)QF_MAX_ACTIVE - (int)prio;
117123

118-
/* create an Zephyr thread for the AO... */
124+
/* extract data temporarily saved in me->thread by QActive_setAttr() */
119125
uint32_t opt = me->thread.base.order_key;
120126
#ifdef CONFIG_THREAD_NAME
121127
char const *name = (char const *)me->thread.init_data;
122128
#endif
123-
me->thread = (struct k_thread){}; /* clear the thread storage */
124-
#ifdef CONFIG_THREAD_NAME
125-
k_thread_name_set(&me->thread, name);
126-
#endif
129+
130+
/* clear the Zephyr thread structure before creating the thread */
131+
me->thread = (struct k_thread){};
132+
133+
/* create a Zephyr thread for the AO... */
127134
k_thread_create(&me->thread,
128135
(k_thread_stack_t *)stkSto, stkSize,
129136
&thread_entry,
@@ -133,6 +140,11 @@ void QActive_start_(QActive * const me, QPrioSpec const prio,
133140
zprio, /* Zephyr priority */
134141
opt, /* thread options */
135142
K_NO_WAIT); /* start immediately */
143+
144+
#ifdef CONFIG_THREAD_NAME
145+
// set the Zephyr thread name, if configured
146+
k_thread_name_set(&me->thread, name);
147+
#endif
136148
}
137149
/*..........................................................................*/
138150
bool QActive_post_(QActive * const me, QEvt const * const e,

0 commit comments

Comments
 (0)