Ram Gandikota / Mbed OS ABCD
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers utils.hpp Source File

utils.hpp

00001 #pragma once
00002 
00003 #include "mbed.h"
00004 #include "mbedtls/entropy_poll.h"
00005 
00006 namespace utils
00007 {
00008     unsigned entropy_seed()
00009     {
00010         unsigned seed;
00011         size_t length;
00012 
00013         unsigned char* seed_bytes = reinterpret_cast<unsigned char*>(&seed);
00014         mbedtls_hardware_poll(NULL, seed_bytes, sizeof(unsigned), &length);
00015 
00016         return seed;
00017     }
00018 
00019     // Default time of 0.2 seconds is fine for this lab
00020     void pulse(DigitalOut& led, float t = 0.2f)
00021     {
00022         led = false;
00023         wait(t);
00024         led = true;
00025     }
00026 }