From 076f7bbe1d6c817fcb1068dfe468c1c97c0581f5 Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Tue, 21 Jul 2015 00:37:43 +0200 Subject: [PATCH] comm struct assert --- stm32f103/inc/common.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/stm32f103/inc/common.h b/stm32f103/inc/common.h index fcc1272d..c6ede68c 100644 --- a/stm32f103/inc/common.h +++ b/stm32f103/inc/common.h @@ -1,22 +1,29 @@ #pragma once -#define DATABAUD 2000000; +#define STATIC_ASSERT(COND, MSG) extern char MSG[(COND)?1:-1] + +#define DATABAUD 2000000 #define TOFIXED(a) ((int16_t)(a*64)) #define TOFLOAT(a) ((float)(a/64.0)) typedef struct{ - int16_t amp; - int16_t volt; - int16_t temp; + int16_t amp; + int16_t volt; + int16_t temp; } from_hv_t; typedef struct{ - int16_t a; - int16_t b; + int16_t a; + int16_t b; } to_hv_t; +STATIC_ASSERT(sizeof(to_hv_t) <= DATABAUD / 11 / 5000 - 1 - 5, to_hv_struct_to_large); +STATIC_ASSERT(sizeof(from_hv_t) <= DATABAUD / 11 / 5000 - 1 - 5, from_hv_struct_to_large); + +//#error foo bar + // struct f1tof4{ // int16 ia; // int16 ib;