static inline void bufferPut(uint8_t val) { if (!bufferIsFull()) { sBuffer[(sWritePosition++) % RNG_BUFFER_SIZE] = val; } }
static int bufferPut(CircularBuffer* buf, char ch) { if (bufferIsFull(buf)) { chprintf((BaseChannel*) &SD2, "BUFFER PIENO!!! ERRORE!!!"); return -1; } buf->content[buf->end] = ch; buf->end = (buf->end + 1) % BUFFER_LENGTH; return 0; }
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(); } } }
/**bufferPut * Put packet pkt onto bufferpacket bp. * \param pkt : Packet to put * \param bp : buffer to put the packet onto * \return 0 if OK 1 if full. */ uint8_t bufferPut(bufferpacket *bp, char *pkt) { int i; char *p; char *q; if (bufferIsFull(bp)) return 1; p=bp->pkt+bp->head*PACKETSIZE; // Destination q=pkt; // Source // Copy the packet for (i=0;i<PACKETSIZE;i++) *p++=*q++; // Update the head pointer bp->head=(bp->head+1) % bp->count; return 0; }