Speeduino
Loading...
Searching...
No Matches
Macros | Typedefs | Functions | Variables
crankMaths.cpp File Reference
#include <avr-fast-shift.h>
#include "globals.h"
#include "crankMaths.h"
#include "preprocessor.h"

Macros

#define SECOND_DERIV_ENABLED   0
 

Typedefs

typedef uint32_t UQ24X8_t
 

Functions

angle_converter_factors_t calculateAngleConverterFactors (uint32_t revolutionTime) noexcept
 Calculate the angle<-->time conversion factors for a crank revolution time.
 
void applyAngleConverterFactors (const angle_converter_factors_t &factors) noexcept
 Set the factors used by the degree<-->angle conversions.
 
void setAngleConverterRevolutionTime (uint32_t revolutionTime) noexcept
 Set the revolution time, from which some of the degree<-->angle conversions are derived.
 
 BEGIN_LTO_ALWAYS_INLINE (uint32_t) angleToTime(uint16_t angle) noexcept
 
 BEGIN_LTO_ALWAYS_INLINE (COMPARE_TYPE) angleToTimerTicks(uint16_t angle) noexcept
 

Variables

int16_t CRANK_ANGLE_MAX_IGN = 360
 The number of crank degrees that the system tracks ignition over.
 
int16_t CRANK_ANGLE_MAX_INJ = 360
 The number of crank degrees that the system tracks fuel injection over.
 
static constexpr uint8_t UQ24X8_Shift = 8U
 
static constexpr uint8_t microsPerDegree_Shift = UQ24X8_Shift
 
static constexpr uint8_t UQ1X15_Shift = 15U
 
static constexpr uint8_t degreesPerMicro_Shift = UQ1X15_Shift
 
static angle_converter_factors_t angleConverterFactors
 The factors used by the angle<->time conversion functions.
 

Macro Definition Documentation

◆ SECOND_DERIV_ENABLED

#define SECOND_DERIV_ENABLED   0

Typedef Documentation

◆ UQ24X8_t

typedef uint32_t UQ24X8_t

Function Documentation

◆ applyAngleConverterFactors()

void applyAngleConverterFactors ( const angle_converter_factors_t &  factors)
noexcept

Set the factors used by the degree<-->angle conversions.

Note
If an ISR could be converting angles, call this from within an ATOMIC() block.
Parameters
factorsThe factors to use. See calculateAngleConverterFactors()

◆ BEGIN_LTO_ALWAYS_INLINE() [1/2]

BEGIN_LTO_ALWAYS_INLINE ( COMPARE_TYPE  )
noexcept

◆ BEGIN_LTO_ALWAYS_INLINE() [2/2]

BEGIN_LTO_ALWAYS_INLINE ( uint32_t  )
noexcept

◆ calculateAngleConverterFactors()

angle_converter_factors_t calculateAngleConverterFactors ( uint32_t  revolutionTime)
noexcept

Calculate the angle<-->time conversion factors for a crank revolution time.

This does not change the factors in use (see applyAngleConverterFactors()), so the (relatively slow) divisions can be done outside of a critical section.

Parameters
revolutionTimeThe crank revolution time in uS. Zero results in zero factors.

◆ setAngleConverterRevolutionTime()

void setAngleConverterRevolutionTime ( uint32_t  revolutionTime)
noexcept

Set the revolution time, from which some of the degree<-->angle conversions are derived.

Shorthand for applyAngleConverterFactors(calculateAngleConverterFactors(revolutionTime))

Parameters
revolutionTimeThe crank revolution time.

Variable Documentation

◆ angleConverterFactors

angle_converter_factors_t angleConverterFactors
static

The factors used by the angle<->time conversion functions.

◆ CRANK_ANGLE_MAX_IGN

int16_t CRANK_ANGLE_MAX_IGN = 360

The number of crank degrees that the system tracks ignition over.

◆ CRANK_ANGLE_MAX_INJ

int16_t CRANK_ANGLE_MAX_INJ = 360

The number of crank degrees that the system tracks fuel injection over.

◆ degreesPerMicro_Shift

constexpr uint8_t degreesPerMicro_Shift = UQ1X15_Shift
staticconstexpr

◆ microsPerDegree_Shift

constexpr uint8_t microsPerDegree_Shift = UQ24X8_Shift
staticconstexpr

◆ UQ1X15_Shift

constexpr uint8_t UQ1X15_Shift = 15U
staticconstexpr

◆ UQ24X8_Shift

constexpr uint8_t UQ24X8_Shift = 8U
staticconstexpr