Skip to content

Commit

Permalink
Fix warning and add n-bit rand
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlohr committed Jan 13, 2025
1 parent 0f30d56 commit 9fd7d6a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions extralibs/lib_rand.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,27 @@ uint32_t _rand_gen_32b(void)
}



/// @brief Generates a Random n-bit number, using the LFSR - by generating
/// a random bit from LFSR taps, n times.
/// @param None
/// @return a (psuedo)random n-bit value
uint32_t _rand_gen_nb( int bits)
{
uint32_t rand_out = 0;

while(bits--)
{
// Shift the current rand value for the new LSB
rand_out = rand_out << 1;
// Append the LSB
rand_out |= _rand_lfsr_update();
}

return rand_out;
}


/*** API Functions ***********************************************************/
/*****************************************************************************/
/// @brief seeds the Random LFSR to the value passed
Expand Down
2 changes: 1 addition & 1 deletion extralibs/ssd1306_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ uint8_t ssd1306_pkt_send(uint8_t *data, uint8_t sz, uint8_t cmd)
}

// wait for not busy before exiting
while(SPI1->STATR & SPI_STATR_BSY);
while(SPI1->STATR & SPI_STATR_BSY) { }

funDigitalWrite( SSD1306_CS_PIN, FUN_HIGH );

Expand Down

0 comments on commit 9fd7d6a

Please sign in to comment.