Ram Gandikota
/
ABCD
A metronome using the FRDM K64F board
Diff: utils.hpp
- Revision:
- 0:a7a43371b306
diff -r 000000000000 -r a7a43371b306 utils.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils.hpp Sun May 14 18:40:18 2017 +0000 @@ -0,0 +1,26 @@ +#pragma once + +#include "mbed.h" +#include "mbedtls/entropy_poll.h" + +namespace utils +{ + unsigned entropy_seed() + { + unsigned seed; + size_t length; + + unsigned char* seed_bytes = reinterpret_cast<unsigned char*>(&seed); + mbedtls_hardware_poll(NULL, seed_bytes, sizeof(unsigned), &length); + + return seed; + } + + // Default time of 0.2 seconds is fine for this lab + void pulse(DigitalOut& led, float t = 0.2f) + { + led = false; + wait(t); + led = true; + } +}