rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Private Attributes
DcHardware Class Reference

#include <dc_motors.h>

Collaboration diagram for DcHardware:
Collaboration graph
[legend]

Public Member Functions

 DcHardware ()
 
void start (bool useTwoWires, brain_pin_e pinEnable, brain_pin_e pinDir1, brain_pin_e pinDir2, const char *disPinMsg, brain_pin_e pinDisable, bool isInverted, Scheduler *executor, int frequency)
 
void setFrequency (int frequency)
 
const charmsg ()
 
void stop ()
 

Data Fields

TwoPinDcMotor dcMotor
 

Private Attributes

OutputPin m_pinEnable
 
OutputPin m_pinDir1
 
OutputPin m_pinDir2
 
OutputPin m_disablePin
 
PwmWrapper wrappedEnable {m_pinEnable}
 
PwmWrapper wrappedDir1 {m_pinDir1}
 
PwmWrapper wrappedDir2 {m_pinDir2}
 
SimplePwm m_pwm1
 
SimplePwm m_pwm2
 
bool isStarted = false
 

Detailed Description

Definition at line 34 of file dc_motors.h.

Constructor & Destructor Documentation

◆ DcHardware()

DcHardware::DcHardware ( )
inline

Definition at line 51 of file dc_motors.h.

OutputPin m_disablePin
Definition dc_motors.h:39
TwoPinDcMotor dcMotor
Definition dc_motors.h:63

Member Function Documentation

◆ msg()

const char * DcHardware::msg ( )
inline

Definition at line 70 of file dc_motors.h.

70 {
71 return dcMotor.msg();
72 }
const char * msg() const
Definition dc_motor.h:40

Referenced by showDcMotorInfo(), and updateTunerStudioState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFrequency()

void DcHardware::setFrequency ( int  frequency)
inline

Definition at line 65 of file dc_motors.h.

65 {
68 }
SimplePwm m_pwm2
Definition dc_motors.h:46
SimplePwm m_pwm1
Definition dc_motors.h:45
void setFrequency(float frequency)
static float frequency
Definition init_flex.cpp:21

Referenced by setDcMotorFrequency().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

void DcHardware::start ( bool  useTwoWires,
brain_pin_e  pinEnable,
brain_pin_e  pinDir1,
brain_pin_e  pinDir2,
const char disPinMsg,
brain_pin_e  pinDisable,
bool  isInverted,
Scheduler executor,
int  frequency 
)

Definition at line 12 of file dc_motors.cpp.

20 {
21
22 if (isStarted) {
23 // actually implement stop()
24 return;
25 }
26 isStarted = true;
27
28 dcMotor.setType(useTwoWires ? TwoPinDcMotor::ControlType::PwmDirectionPins : TwoPinDcMotor::ControlType::PwmEnablePin);
29
30 // Configure the disable pin first - ensure things are in a safe state
31 m_disablePin.initPin(disPinMsg, pinDisable);
33
34 // Clamp to >100hz
35 int clampedFrequency = maxI(100, frequency);
36
37 if (clampedFrequency > ETB_HW_MAX_FREQUENCY) {
38 criticalError("Electronic throttle frequency too high, maximum %d hz", ETB_HW_MAX_FREQUENCY);
39 return;
40 }
41
42 if (useTwoWires) {
43 m_pinEnable.initPin("ETB Enable", pinEnable);
44
45// no need to complicate event queue with ETB PWM in unit tests
46#if ! EFI_UNIT_TEST
47 startSimplePwmHard(&m_pwm1, "ETB Dir 1",
48 executor,
49 pinDir1,
50 &m_pinDir1,
51 clampedFrequency,
52 /*dutyCycle*/0
53 );
54
55 startSimplePwmHard(&m_pwm2, "ETB Dir 2",
56 executor,
57 pinDir2,
58 &m_pinDir2,
59 clampedFrequency,
60 /*dutyCycle*/0
61 );
62#endif // EFI_UNIT_TEST
63
65 } else {
66 m_pinDir1.initPin("ETB Dir 1", pinDir1);
67 m_pinDir2.initPin("ETB Dir 2", pinDir2);
68
69// no need to complicate event queue with ETB PWM in unit tests
70#if ! EFI_UNIT_TEST
71 startSimplePwmHard(&m_pwm1, "ETB Enable",
72 executor,
73 pinEnable,
75 clampedFrequency,
76 /*dutyCycle*/0
77 );
78#endif // EFI_UNIT_TEST
79
81 }
82 }
OutputPin m_pinDir2
Definition dc_motors.h:38
OutputPin m_pinEnable
Definition dc_motors.h:36
PwmWrapper wrappedDir1
Definition dc_motors.h:42
OutputPin m_pinDir1
Definition dc_motors.h:37
bool isStarted
Definition dc_motors.h:48
PwmWrapper wrappedDir2
Definition dc_motors.h:43
PwmWrapper wrappedEnable
Definition dc_motors.h:41
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:711
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
Represents a DC motor controller (H-bridge) with some combination of PWM and on/off control pins....
Definition dc_motor.h:56
void setType(ControlType type)
Definition dc_motor.h:106
void configure(IPwm &enable, IPwm &dir1, IPwm &dir2, bool isInverted)
Definition dc_motor.cpp:19
void startSimplePwmHard(SimplePwm *state, const char *msg, Scheduler *executor, brain_pin_e brainPin, OutputPin *output, float frequency, float dutyCycle)

Referenced by initDcMotor(), and initDcMotor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

void DcHardware::stop ( )
inline

Definition at line 74 of file dc_motors.h.

74 {
75 // todo: replace 'isStarted' with 'stop'
76 }

Field Documentation

◆ dcMotor

TwoPinDcMotor DcHardware::dcMotor

Definition at line 63 of file dc_motors.h.

Referenced by msg(), setDcMotorDuty(), showDcMotorInfo(), start(), and updateTunerStudioState().

◆ isStarted

bool DcHardware::isStarted = false
private

Definition at line 48 of file dc_motors.h.

Referenced by start().

◆ m_disablePin

OutputPin DcHardware::m_disablePin
private

Definition at line 39 of file dc_motors.h.

Referenced by start().

◆ m_pinDir1

OutputPin DcHardware::m_pinDir1
private

Definition at line 37 of file dc_motors.h.

Referenced by start().

◆ m_pinDir2

OutputPin DcHardware::m_pinDir2
private

Definition at line 38 of file dc_motors.h.

Referenced by start().

◆ m_pinEnable

OutputPin DcHardware::m_pinEnable
private

Definition at line 36 of file dc_motors.h.

Referenced by start().

◆ m_pwm1

SimplePwm DcHardware::m_pwm1
private

Definition at line 45 of file dc_motors.h.

Referenced by setFrequency(), and start().

◆ m_pwm2

SimplePwm DcHardware::m_pwm2
private

Definition at line 46 of file dc_motors.h.

Referenced by setFrequency(), and start().

◆ wrappedDir1

PwmWrapper DcHardware::wrappedDir1 {m_pinDir1}
private

Definition at line 42 of file dc_motors.h.

42{m_pinDir1};

Referenced by start().

◆ wrappedDir2

PwmWrapper DcHardware::wrappedDir2 {m_pinDir2}
private

Definition at line 43 of file dc_motors.h.

43{m_pinDir2};

Referenced by start().

◆ wrappedEnable

PwmWrapper DcHardware::wrappedEnable {m_pinEnable}
private

Definition at line 41 of file dc_motors.h.

Referenced by start().


The documentation for this class was generated from the following files: