int bufferPutString(CircularBuffer* buf, const char str[]) { chMtxLock(&(buf->mutex)); int i = 0; int esito = 0; for (i = 0; str[i] != '\0' && esito == 0; i++) { esito = bufferPut(buf, str[i]); } if (esito == 0) { bufferPut(buf, '\n'); esito = bufferPut(buf, '\r'); } chMtxUnlock(); return esito; }
void RNG_IRQHandler(void) { if (nrf_rng_event_get(NRF_RNG_EVENT_VALRDY) && nrf_rng_int_get(NRF_RNG_INT_VALRDY_MASK)) { nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY); bufferPut(nrf_rng_random_value_get()); if (bufferIsFull()) { generatorStop(); } } }
// Flush the current word buffer // out to the phraseBuffer static void flushWord(void){ uint8_t data; size_t wordLen = wordBuffer.datalength; // If the phrase cannot accept the entire // word then say the current phrase first if(bufferFreeSpace(&phraseBuffer) <= wordLen){ flushPhrase(); } // Write the word to the phrase buffer while(bufferGet(&wordBuffer,&data)){ bufferPut(&phraseBuffer,data); } }