rearragned some code
This commit is contained in:
parent
0aae5a742c
commit
ed6f4e488a
@ -14,6 +14,8 @@
|
||||
#ifndef _COMMON_H_
|
||||
#define _COMMON_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define Q(x) #x
|
||||
#define QUOTE(x) Q(x)
|
||||
#define SET_BIT(value, bitPosition) ((value) |= (1U << (bitPosition)))
|
||||
@ -64,6 +66,53 @@
|
||||
// -> 6.90µl / Pulse
|
||||
#define DEFAULT_PUMP_DOSE 7
|
||||
|
||||
typedef enum eSystem_Status
|
||||
{
|
||||
sysStat_Startup,
|
||||
sysStat_Normal,
|
||||
sysStat_Rain,
|
||||
sysStat_Purge,
|
||||
sysStat_Error,
|
||||
sysStat_Shutdown
|
||||
} tSystem_Status;
|
||||
|
||||
// Enum for different sources of speed input
|
||||
typedef enum SpeedSource_e
|
||||
{
|
||||
#ifdef FEATURE_ENABLE_TIMER
|
||||
SOURCE_TIME,
|
||||
#endif
|
||||
SOURCE_IMPULSE,
|
||||
SOURCE_GPS,
|
||||
SOURCE_CAN
|
||||
} SpeedSource_t;
|
||||
|
||||
// String representation of SpeedSource enum
|
||||
extern const char *SpeedSourceString[];
|
||||
extern const size_t SpeedSourceString_Elements;
|
||||
|
||||
// Enum for GPS baud rates
|
||||
typedef enum GPSBaudRate_e
|
||||
{
|
||||
BAUD_9600,
|
||||
BAUD_115200
|
||||
} GPSBaudRate_t;
|
||||
|
||||
// String representation of GPSBaudRate enum
|
||||
extern const char *GPSBaudRateString[];
|
||||
extern const size_t GPSBaudRateString_Elements;
|
||||
|
||||
// Enum for CAN bus sources
|
||||
typedef enum CANSource_e
|
||||
{
|
||||
KTM_890_ADV_R_2021,
|
||||
KTM_1290_SD_R_2023
|
||||
} CANSource_t;
|
||||
|
||||
// String representation of CANSource enum
|
||||
extern const char *CANSourceString[];
|
||||
extern const size_t CANSourceString_Elements;
|
||||
|
||||
#define STARTUP_DELAY 5000
|
||||
#define SHUTDOWN_DELAY_MS 5000
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <I2C_eeprom.h>
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "common.h"
|
||||
|
||||
@ -28,56 +27,19 @@
|
||||
#define EEPROM_SIZE_BYTES I2C_DEVICESIZE_24LC256
|
||||
#endif
|
||||
|
||||
// Enum for different sources of speed input
|
||||
typedef enum SpeedSource_e
|
||||
typedef enum EERequest_e
|
||||
{
|
||||
#ifdef FEATURE_ENABLE_TIMER
|
||||
SOURCE_TIME,
|
||||
#endif
|
||||
SOURCE_IMPULSE,
|
||||
SOURCE_GPS,
|
||||
SOURCE_CAN
|
||||
} SpeedSource_t;
|
||||
EE_IDLE,
|
||||
EE_CFG_SAVE,
|
||||
EE_CFG_LOAD,
|
||||
EE_CFG_FORMAT,
|
||||
EE_PDS_SAVE,
|
||||
EE_PDS_LOAD,
|
||||
EE_PDS_FORMAT,
|
||||
EE_FORMAT_ALL,
|
||||
EE_ALL_SAVE
|
||||
|
||||
// String representation of SpeedSource enum
|
||||
const char SpeedSourceString[][8] = {
|
||||
#ifdef FEATURE_ENABLE_TIMER
|
||||
"Timer",
|
||||
#endif
|
||||
"Impuls",
|
||||
"GPS",
|
||||
"CAN-Bus"
|
||||
};
|
||||
|
||||
const size_t SpeedSourceString_Elements = sizeof(SpeedSourceString) / sizeof(SpeedSourceString[0]);
|
||||
|
||||
// Enum for GPS baud rates
|
||||
typedef enum GPSBaudRate_e
|
||||
{
|
||||
BAUD_9600,
|
||||
BAUD_115200
|
||||
} GPSBaudRate_t;
|
||||
|
||||
// String representation of GPSBaudRate enum
|
||||
const char GPSBaudRateString[][7] = {
|
||||
"9600",
|
||||
"115200"};
|
||||
|
||||
const size_t GPSBaudRateString_Elements = sizeof(GPSBaudRateString) / sizeof(GPSBaudRateString[0]);
|
||||
|
||||
// Enum for CAN bus sources
|
||||
typedef enum CANSource_e
|
||||
{
|
||||
KTM_890_ADV_R_2021,
|
||||
KTM_1290_SD_R_2023
|
||||
} CANSource_t;
|
||||
|
||||
// String representation of CANSource enum
|
||||
const char CANSourceString[][30] = {
|
||||
"KTM 890 Adventure R (2021)",
|
||||
"KTM 1290 Superduke R (2023)"};
|
||||
|
||||
const size_t CANSourceString_Elements = sizeof(CANSourceString) / sizeof(CANSourceString[0]);
|
||||
} EERequest_t;
|
||||
|
||||
// Structure for persistence data stored in EEPROM
|
||||
typedef struct
|
||||
|
@ -15,30 +15,8 @@
|
||||
#define _GLOBALS_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
typedef enum eSystem_Status
|
||||
{
|
||||
sysStat_Startup,
|
||||
sysStat_Normal,
|
||||
sysStat_Rain,
|
||||
sysStat_Purge,
|
||||
sysStat_Error,
|
||||
sysStat_Shutdown
|
||||
} tSystem_Status;
|
||||
|
||||
typedef enum eEERequest
|
||||
{
|
||||
EE_IDLE,
|
||||
EE_CFG_SAVE,
|
||||
EE_CFG_LOAD,
|
||||
EE_CFG_FORMAT,
|
||||
EE_PDS_SAVE,
|
||||
EE_PDS_LOAD,
|
||||
EE_PDS_FORMAT,
|
||||
EE_FORMAT_ALL,
|
||||
EE_ALL_SAVE
|
||||
|
||||
} tEERequest;
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
|
||||
typedef struct Globals_s
|
||||
{
|
||||
@ -46,7 +24,7 @@ typedef struct Globals_s
|
||||
tSystem_Status resumeStatus = sysStat_Startup; /**< Status to resume after rain mode */
|
||||
char systemStatustxt[16] = ""; /**< Text representation of system status */
|
||||
uint16_t purgePulses = 0; /**< Number of purge pulses */
|
||||
eEERequest requestEEAction = EE_IDLE;; /**< EEPROM-related request */
|
||||
EERequest_t requestEEAction = EE_IDLE;; /**< EEPROM-related request */
|
||||
char DeviceName[33]; /**< Device name */
|
||||
char FlashVersion[10]; /**< Flash version */
|
||||
uint16_t eePersistanceAdress; /**< EEPROM persistence address */
|
||||
|
32
Software/src/common.cpp
Normal file
32
Software/src/common.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "common.h"
|
||||
|
||||
// String representation of SpeedSource enum
|
||||
const char *SpeedSourceString[] = {
|
||||
#ifdef FEATURE_ENABLE_TIMER
|
||||
"Timer",
|
||||
#endif
|
||||
"Impuls",
|
||||
"GPS",
|
||||
"CAN-Bus"
|
||||
};
|
||||
|
||||
const size_t SpeedSourceString_Elements = sizeof(SpeedSourceString) / sizeof(SpeedSourceString[0]);
|
||||
|
||||
// String representation of GPSBaudRate enum
|
||||
const char *GPSBaudRateString[] = {
|
||||
"4800",
|
||||
"9600",
|
||||
"19200",
|
||||
"38400",
|
||||
"57600",
|
||||
"115200"
|
||||
};
|
||||
|
||||
const size_t GPSBaudRateString_Elements = sizeof(GPSBaudRateString) / sizeof(GPSBaudRateString[0]);
|
||||
|
||||
// String representation of CANSource enum
|
||||
const char *CANSourceString[] = {
|
||||
"KTM 890 Adventure R (2021)",
|
||||
"KTM 1290 Superduke R (2023)"};
|
||||
|
||||
const size_t CANSourceString_Elements = sizeof(CANSourceString) / sizeof(CANSourceString[0]);
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "debugger.h"
|
||||
#include "globals.h"
|
||||
|
||||
// Instance of I2C_eeprom for EEPROM access
|
||||
I2C_eeprom ee(0x50, EEPROM_SIZE_BYTES);
|
||||
|
Loading…
x
Reference in New Issue
Block a user