/*..........................................................................*/ void QS_str_ROM(char_t const Q_ROM *s) { uint8_t b = (uint8_t)Q_ROM_BYTE(*s); uint8_t chksum = (uint8_t)(QS_priv_.chksum + (uint8_t)QS_STR_T); uint8_t *buf = QS_priv_.buf; /* put in a temporary (register) */ QSCtr head = QS_priv_.head; /* put in a temporary (register) */ QSCtr end = QS_priv_.end; /* put in a temporary (register) */ QSCtr used = QS_priv_.used; /* put in a temporary (register) */ used += (QSCtr)2; /* account for the format byte and the terminating-0 */ QS_INSERT_BYTE((uint8_t)QS_STR_T) while (b != (uint8_t)(0)) { /* ASCII characters don't need escaping */ chksum = (uint8_t)(chksum + b); /* update checksum */ QS_INSERT_BYTE(b) QS_PTR_INC_(s); b = (uint8_t)Q_ROM_BYTE(*s); ++used; } QS_INSERT_BYTE((uint8_t)0) /* zero-terminate the string */ QS_priv_.head = head; /* save the head */ QS_priv_.chksum = chksum; /* save the checksum */ QS_priv_.used = used; /* save # of used buffer space */ }
/*..........................................................................*/ void QActive_unsubscribeAll(QActive const *me) { uint8_t p = me->prio; uint8_t i; QSignal sig; Q_REQUIRE(((uint8_t)0 < p) && (p <= (uint8_t)QF_MAX_ACTIVE) && (QF_active_[p] == me)); i = QF_div8Lkup[p]; for (sig = (QSignal)Q_USER_SIG; sig < QF_maxSignal_; ++sig) { QF_CRIT_STAT_ QF_CRIT_ENTRY_(); if ((QF_PTR_AT_(QF_subscrList_, sig).bits[i] & Q_ROM_BYTE(QF_pwr2Lkup[p])) != (uint8_t)0) { QS_BEGIN_NOCRIT_(QS_QF_ACTIVE_UNSUBSCRIBE, QS_aoObj_, me) QS_TIME_(); /* timestamp */ QS_SIG_(sig); /* the signal of this event */ QS_OBJ_(me); /* this active object */ QS_END_NOCRIT_() /* clear the priority bit */ QF_PTR_AT_(QF_subscrList_, sig).bits[i] &= Q_ROM_BYTE(QF_invPwr2Lkup[p]); } QF_CRIT_EXIT_(); } }
void QF_publish_(QEvt const * const e, void const * const sender) #endif { QF_CRIT_STAT_ /* make sure that the published signal is within the configured range */ Q_REQUIRE(e->sig < (QSignal)QF_maxSignal_); QF_CRIT_ENTRY_(); QS_BEGIN_NOCRIT_(QS_QF_PUBLISH, (void *)0, (void *)0) QS_TIME_(); /* the timestamp */ QS_OBJ_(sender); /* the sender object */ QS_SIG_(e->sig); /* the signal of the event */ QS_2U8_(e->poolId_, e->refCtr_);/* pool Id & ref Count of the event */ QS_END_NOCRIT_() if (e->poolId_ != (uint8_t)0) { /* is it a dynamic event? */ QF_EVT_REF_CTR_INC_(e); /* increment reference counter, NOTE01 */ } QF_CRIT_EXIT_(); #if (QF_MAX_ACTIVE <= 8) { uint8_t tmp = QF_subscrList_[e->sig].bits[0]; while (tmp != (uint8_t)0) { uint8_t p = QF_LOG2(tmp); tmp &= Q_ROM_BYTE(QF_invPwr2Lkup[p]); /* clear subscriber bit */ Q_ASSERT(QF_active_[p] != (QActive *)0); /* must be registered */ /* QACTIVE_POST() asserts internally if the queue overflows */ QACTIVE_POST(QF_active_[p], e, sender); } } #else { uint_t i = (uint_t)Q_DIM(QF_subscrList_[0].bits); do { /* go through all bytes in the subscription list */ uint8_t tmp; --i; tmp = QF_PTR_AT_(QF_subscrList_, e->sig).bits[i]; while (tmp != (uint8_t)0) { uint8_t p = QF_LOG2(tmp); tmp &= Q_ROM_BYTE(QF_invPwr2Lkup[p]);/*clear subscriber bit */ p = (uint8_t)(p + (uint8_t)(i << 3));/* adjust the priority */ Q_ASSERT(QF_active_[p] != (QActive *)0);/*must be registered*/ /* QACTIVE_POST() asserts internally if the queue overflows */ QACTIVE_POST(QF_active_[p], e, sender); } } while (i != (uint_t)0); } #endif QF_gc(e); /* run the garbage collector, see NOTE01 */ }
static void send_morse_char(const Q_ROM struct MorseChar *mc) { uint8_t nsymbols = Q_ROM_BYTE(mc->nsymbols); uint8_t symbols = Q_ROM_BYTE(mc->symbols); while (nsymbols) { if (symbols & 0b10000000) dah(); else dit(); BSP_delay_ms( DIT_LENGTH ); symbols <<= 1; nsymbols--; } }
/*..........................................................................*/ void QActive_subscribe(QActive const *me, QSignal sig) { uint8_t p = me->prio; uint8_t i = Q_ROM_BYTE(QF_div8Lkup[p]); QF_INT_LOCK_KEY_ Q_REQUIRE(((QSignal)Q_USER_SIG <= sig) && (sig < QF_maxSignal_) && ((uint8_t)0 < p) && (p <= (uint8_t)QF_MAX_ACTIVE) && (QF_active_[p] == me)); QF_INT_LOCK_(); QS_BEGIN_NOLOCK_(QS_QF_ACTIVE_SUBSCRIBE, QS_aoObj_, me) QS_TIME_(); /* timestamp */ QS_SIG_(sig); /* the signal of this event */ QS_OBJ_(me); /* this active object */ QS_END_NOLOCK_() /* set the priority bit */ QF_subscrList_[sig].bits[i] |= Q_ROM_BYTE(QF_pwr2Lkup[p]); QF_INT_UNLOCK_(); }
/*..........................................................................*/ void QActive_subscribe(QActive const * const me, enum_t const sig) { uint8_t p = me->prio; uint8_t i = Q_ROM_BYTE(QF_div8Lkup[p]); QF_CRIT_STAT_ Q_REQUIRE(((enum_t)Q_USER_SIG <= sig) && (sig < QF_maxSignal_) && ((uint8_t)0 < p) && (p <= (uint8_t)QF_MAX_ACTIVE) && (QF_active_[p] == me)); QF_CRIT_ENTRY_(); QS_BEGIN_NOCRIT_(QS_QF_ACTIVE_SUBSCRIBE, QS_aoObj_, me) QS_TIME_(); /* timestamp */ QS_SIG_((QSignal)sig); /* the signal of this event */ QS_OBJ_(me); /* this active object */ QS_END_NOCRIT_() /* set the priority bit */ QF_PTR_AT_(QF_subscrList_, sig).bits[i] |= Q_ROM_BYTE(QF_pwr2Lkup[p]); QF_CRIT_EXIT_(); }
static const Q_ROM struct MorseChar *find_morse_char(const char c) { const struct MorseChar *mc; char cup; if (c >= 'a' && c <= 'z') { cup = c - 0x20; } else { cup = c; } mc = morseChars; while (1) { char mcc = Q_ROM_BYTE(mc->ch); if (! mcc) break; if (mcc == cup) return mc; mc++; } return 0; }