From f70fb1e7607bdc5eb61d642b7f64cdfb32f02ba2 Mon Sep 17 00:00:00 2001 From: Michael Balzer Date: Sun, 5 Mar 2023 08:43:30 +0100 Subject: [PATCH] Support 32 bit platforms (ESP32) --- TwizyCfg/CANopen.h | 4 ++-- TwizyCfg/Tuning.h | 8 ++++---- TwizyCfg/utils.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/TwizyCfg/CANopen.h b/TwizyCfg/CANopen.h index 8d351c1..f0e8a20 100644 --- a/TwizyCfg/CANopen.h +++ b/TwizyCfg/CANopen.h @@ -28,13 +28,13 @@ // 3 = subindex // 4..7 = data (little endian) -union sdo_buffer { +union __attribute__ ((__packed__)) sdo_buffer { // raw / segment data: UINT8 byte[8]; // request / expedited: - struct { + struct __attribute__ ((__packed__)) { UINT8 control; UINT index; UINT8 subindex; diff --git a/TwizyCfg/Tuning.h b/TwizyCfg/Tuning.h index 4f88bb0..e654e8d 100644 --- a/TwizyCfg/Tuning.h +++ b/TwizyCfg/Tuning.h @@ -21,11 +21,11 @@ #define OVMS_TWIZY_CFG_BRAKELIGHT 1 -union cfg_status { +union __attribute__ ((__packed__)) cfg_status { UINT8 drivemode; - struct { + struct __attribute__ ((__packed__)) { unsigned type:1; // CFG: 0=Twizy80, 1=Twizy45 unsigned profile_user:2; // CFG: user selected profile: 0=Default, 1..3=Custom unsigned profile_cfgmode:2; // CFG: profile, cfgmode params were last loaded from @@ -43,12 +43,12 @@ extern cfg_status twizy_cfg; // 1 kept in RAM (working set) // 3 stored in binary EEPROM param slots PARAM_PROFILE1 /2 /3 -struct cfg_profile { +struct __attribute__ ((__packed__)) cfg_profile { UINT8 checksum; UINT8 speed, warn; UINT8 torque, power_low, power_high; UINT8 drive, neutral, brake; - struct tsmap { + struct __attribute__ ((__packed__)) tsmap { UINT8 spd1, spd2, spd3, spd4; UINT8 prc1, prc2, prc3, prc4; } tsmap[3]; // 0=D 1=N 2=B diff --git a/TwizyCfg/utils.h b/TwizyCfg/utils.h index 8b753ad..404b275 100644 --- a/TwizyCfg/utils.h +++ b/TwizyCfg/utils.h @@ -22,8 +22,8 @@ // Type shortcuts: typedef unsigned char UINT8; -typedef unsigned int UINT; -typedef unsigned int WORD; +typedef unsigned short UINT; +typedef unsigned short WORD; typedef unsigned long UINT32; typedef signed char INT8;