ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
2#include <stdint.h>
3#include <stdio.h>
4#include <string.h>
5
6int main() {
7 printf("=== Clear nonces app ===");
8
9 int status = 0;
10
11 uint32_t nonces_addr = 2200;
12
13 const size_t nonces_size = 14;
14
15 uint8_t nonces[nonces_size] = {};
16
17 // Get current value
18 status = fram_read(nonces_addr, nonces_size, nonces);
19 if (status < 0) {
20 printf("Error! Could not read current nonces.\n");
21 }
22 printf("Current nonces buffer:");
23 for (size_t i = 0; i < nonces_size; i++) {
24 printf("%02x ", nonces[i]);
25 }
26 printf("\n\n");
27
28 // Write to buffer
29 memset(nonces, 0, nonces_size);
30 status = fram_write(nonces_addr, nonces, nonces_size);
31 if (status < 0) {
32 printf("Error could not write to nonces.\n");
33 }
34
35 status = fram_read(nonces_addr, nonces_size, nonces);
36 if (status < 0) {
37 printf("Error! Could not read current nonces.\n");
38 }
39 printf("New nonces buffer:");
40 for (size_t i = 0; i < nonces_size; i++) {
41 printf("%02x ", nonces[i]);
42 }
43 printf("\n\n");
44
45 printf("New nonces buffer should be all zeros.\n");
46
47 printf("\nDone.\n");
48
49 return 0;
50}
int main()
Definition main.c:4
uint8_t i
Storage interface for onboard FRAM chips.
fram_status fram_write(fram_addr addr, const uint8_t *data, size_t len)
Write bytes at the given address.
Definition fram.c:20
fram_status fram_read(fram_addr addr, size_t len, uint8_t *data)
Read bytes at the given address.
Definition fram.c:28