sink struct

This commit is contained in:
Wolfgang Hottgenroth 2021-02-08 14:43:23 +01:00
parent 9caa23814f
commit 4bf1152175
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
3 changed files with 25 additions and 18 deletions

View File

@ -2,9 +2,6 @@
#define _CONFIG_H_
#include <stdint.h>
#include <spi.h>
#include <assert.h>
#include <sha256.h>
#define CONFIG_MAGIC 0xdead0006

View File

@ -0,0 +1,22 @@
#ifndef _SINKSTRUCT_H_
#define _SINKSTRUCT_H_
#include <stdint.h>
#include <sha256.h>
#include <config.h>
typedef struct __attribute__((__packed__)) {
uint64_t timestamp;
uint32_t frequency;
} t_event;
#define SECONDS_PER_MINUTE 60
typedef struct __attribute__((__packed__)) {
char deviceId[sizeof(((t_configBlock*)0)->deviceId)];
char location[sizeof(((t_configBlock*)0)->location)];
uint8_t hash[SHA256_BLOCK_SIZE];
uint8_t done;
t_event events[SECONDS_PER_MINUTE];
} t_minuteStruct;
#endif // _SINKSTRUCT_H_

View File

@ -10,9 +10,11 @@
#include <wizHelper.h>
#include <config.h>
#include <socket.h>
#include <sinkStruct.h>
#include <sha256.h>
const uint32_t COUNTER_FREQUENCY = 1.0e6;
// 100: 2 digits behind decimal point
@ -24,20 +26,6 @@ volatile static uint32_t mainsCntCnt = 0;
static t_seconds *seconds;
typedef struct __attribute__((__packed__)) {
uint64_t timestamp;
uint32_t frequency;
} t_event;
#define SECONDS_PER_MINUTE 60
typedef struct __attribute__((__packed__)) {
char deviceId[sizeof(((t_configBlock*)0)->deviceId)];
char location[sizeof(((t_configBlock*)0)->location)];
uint8_t hash[SHA256_BLOCK_SIZE];
uint8_t done;
t_event events[SECONDS_PER_MINUTE];
} t_minuteStruct;
typedef union {
t_minuteStruct s;