2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file rusefi_types.h
|
|
|
|
*
|
|
|
|
* @date Jan 12, 2015
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2019-12-02 07:03:50 -08:00
|
|
|
|
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-12-08 12:51:45 -08:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdbool.h>
|
2018-12-08 13:00:36 -08:00
|
|
|
#include <float.h>
|
2015-07-10 06:01:56 -07:00
|
|
|
#include <stdint.h>
|
2016-07-25 21:03:50 -07:00
|
|
|
#if defined __GNUC__
|
|
|
|
// GCC
|
2016-07-14 20:02:55 -07:00
|
|
|
#include <sys/types.h>
|
2016-07-25 21:03:50 -07:00
|
|
|
#else
|
|
|
|
// IAR
|
2022-04-25 17:38:16 -07:00
|
|
|
using time_t = uint32_t;
|
2016-07-25 21:03:50 -07:00
|
|
|
#endif
|
|
|
|
|
2020-05-21 21:00:16 -07:00
|
|
|
#include "rusefi_generated.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "rusefi_enums.h"
|
2018-09-29 07:39:21 -07:00
|
|
|
#include "firing_order.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-11-05 18:55:33 -07:00
|
|
|
#if __cplusplus
|
2022-09-04 20:11:19 -07:00
|
|
|
#include "efi_scaled_channel.h"
|
2021-11-05 18:55:33 -07:00
|
|
|
#endif
|
|
|
|
|
2019-06-10 12:45:18 -07:00
|
|
|
#define DEFAULT_FUEL_LOAD_COUNT 16
|
|
|
|
#define DEFAULT_IGN_LOAD_COUNT 16
|
|
|
|
|
2021-11-06 21:03:16 -07:00
|
|
|
#define TWO_STROKE_CYCLE_DURATION 360
|
|
|
|
#define FOUR_STROKE_CYCLE_DURATION 720
|
|
|
|
|
2021-05-19 23:36:55 -07:00
|
|
|
// gasoline E0
|
|
|
|
#define STOICH_RATIO 14.7f
|
2022-01-14 18:18:51 -08:00
|
|
|
#define CONST_PI 3.14159265358979323846
|
|
|
|
|
2021-05-19 23:36:55 -07:00
|
|
|
|
2016-07-14 20:02:55 -07:00
|
|
|
// time in seconds
|
2022-04-25 17:38:16 -07:00
|
|
|
using efitimesec_t = time_t;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* We use a signed type here so that subtraction result is a proper negative value.
|
|
|
|
* A typical use-case negative result is when we do 'timeNow() - timeOfEvent' where timeOfEvent
|
|
|
|
* is actually after timeNow() due to interrupt context switches
|
2017-12-05 20:45:31 -08:00
|
|
|
*
|
|
|
|
* See getTimeNowNt()
|
2019-08-18 12:53:38 -07:00
|
|
|
* See US2NT
|
|
|
|
* See MS2US
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2022-09-11 13:08:11 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* platform-dependent tick since boot
|
|
|
|
* in case of stm32f4 that's 32-bit timer ticks (SCHEDULER_TIMER_DEVICE == TIM5) extended to 64 bits
|
|
|
|
*/
|
|
|
|
using efitick_t = int64_t;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
/**
|
2019-12-21 18:11:09 -08:00
|
|
|
* 64 bit time in microseconds (1/1_000_000 of a second), since boot
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2022-09-11 13:08:11 -07:00
|
|
|
using efitimeus_t = int64_t;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-12-21 18:11:09 -08:00
|
|
|
/**
|
|
|
|
* 64 bit time in milliseconds (1/1_000 of a second), since boot
|
|
|
|
*/
|
2022-09-11 13:08:11 -07:00
|
|
|
using efitimems64_t = int64_t;
|
2019-12-21 18:11:09 -08:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
2022-09-11 13:08:11 -07:00
|
|
|
* integer time in milliseconds (1/1_000 of a second)
|
|
|
|
* 32 bit 4B / 1000 = 4M seconds = 1111.11 hours = 23(or46?) days.
|
|
|
|
* Please restart your ECU every 23(or46?) days? :) See issue https://github.com/rusefi/rusefi/issues/4554 tag#4554
|
|
|
|
* See getTimeNowUs()
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2022-09-11 13:08:11 -07:00
|
|
|
using efitimems_t = uint32_t;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2022-04-25 17:38:16 -07:00
|
|
|
using angle_t = float;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2022-09-26 02:34:05 -07:00
|
|
|
using engineSyncCam_e = uint8_t;
|
|
|
|
|
2021-12-26 09:33:32 -08:00
|
|
|
// mass in grams
|
2022-04-25 17:38:16 -07:00
|
|
|
using mass_t = float;
|
2021-12-26 09:33:32 -08:00
|
|
|
|
2019-06-19 18:24:09 -07:00
|
|
|
// temperature, in Celsius
|
2022-04-25 17:38:16 -07:00
|
|
|
using temperature_t = float;
|
|
|
|
using floatms_t = float;
|
|
|
|
using floatus_t = float;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* numeric value from 0 to 100
|
|
|
|
*/
|
2022-04-25 17:38:16 -07:00
|
|
|
using percent_t = float;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
typedef void (*Void)(void);
|
|
|
|
|
2022-04-25 17:38:16 -07:00
|
|
|
using lua_script_t = char[LUA_SCRIPT_SIZE];
|
2021-05-18 10:58:39 -07:00
|
|
|
|
2022-04-25 17:38:16 -07:00
|
|
|
using error_message_t = char[ERROR_BUFFER_SIZE];
|
2020-03-28 17:14:17 -07:00
|
|
|
|
2022-04-25 17:38:16 -07:00
|
|
|
using vehicle_info_t = char[VEHICLE_INFO_SIZE];
|
2020-05-05 12:47:14 -07:00
|
|
|
|
2022-09-09 22:05:31 -07:00
|
|
|
using vin_number_t = char[VIN_NUMBER_SIZE];
|
|
|
|
|
2022-04-25 17:38:16 -07:00
|
|
|
using gppwm_note_t = char[GPPWM_NOTE_SIZE];
|
2021-09-26 20:36:08 -07:00
|
|
|
|
2022-04-25 17:38:16 -07:00
|
|
|
using le_formula_t = char[LE_COMMAND_LENGTH];
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
using brain_pin_e = Gpio;
|
|
|
|
|
2022-04-25 17:38:16 -07:00
|
|
|
using egt_cs_array_t = brain_pin_e[EGT_CHANNEL_COUNT];
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2022-04-25 17:38:16 -07:00
|
|
|
using pwm_freq_t = int16_t;
|
2016-03-01 21:02:17 -08:00
|
|
|
|
2022-04-25 17:38:16 -07:00
|
|
|
using script_setting_t = float;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2022-04-25 17:38:16 -07:00
|
|
|
using brain_input_pin_e = brain_pin_e;
|
|
|
|
using switch_input_pin_e = brain_pin_e;
|
2022-04-28 14:32:39 -07:00
|
|
|
using output_pin_e = brain_pin_e;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
typedef void (*VoidPtr)(void*);
|
|
|
|
|
|
|
|
typedef void (*VoidInt)(int);
|
|
|
|
typedef void (*VoidIntVoidPtr)(int, void*);
|
|
|
|
typedef void (*VoidFloat)(float);
|
|
|
|
typedef void (*VoidFloatFloat)(float, float);
|
2022-02-26 13:58:10 -08:00
|
|
|
typedef void (*VoidFloatFloatFloat)(float, float, float);
|
|
|
|
typedef void (*VoidFloatFloatFloatFloatFloat)(float, float, float, float, float);
|
2015-07-10 06:01:56 -07:00
|
|
|
typedef void (*VoidFloatFloatVoidPtr)(float, float, void*);
|
|
|
|
typedef void (*VoidIntInt)(int, int);
|
|
|
|
typedef void (*VoidIntIntVoidPtr)(int, int, void*);
|
2019-09-21 11:33:38 -07:00
|
|
|
typedef void (*VoidIntFloat)(int, float);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
typedef void (*VoidCharPtr)(const char *);
|
|
|
|
typedef void (*VoidCharPtrVoidPtr)(const char *, void*);
|
|
|
|
|
|
|
|
typedef void (*VoidCharPtrCharPtr)(const char *, const char *);
|
|
|
|
typedef void (*VoidCharPtrCharPtrVoidPtr)(const char *, const char *, void*);
|
|
|
|
|
|
|
|
typedef void (*VoidCharPtrCharPtrCharPtr)(const char *, const char *, const char *);
|
|
|
|
typedef void (*VoidCharPtrCharPtrCharPtrCharPtrCharPtr)(const char *, const char *, const char *, const char *, const char *);
|