Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: utils.hpp
- Revision:
- 0:06ee5f8a484a
diff -r 000000000000 -r 06ee5f8a484a utils.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/utils.hpp Sat Mar 18 22:37:16 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;
+ }
+}