diff --git a/Source/ADC.cpp b/Source/ADC.cpp index b2a80b0..339f541 100644 --- a/Source/ADC.cpp +++ b/Source/ADC.cpp @@ -64,7 +64,7 @@ extern "C" void DMA1_Channel1_IRQHandler(void) /* DMA1 Channel 1 namespace ElektronischeLast { - iADC::iADC(float voltage_gain, float current_gain) + void iADC::init(float voltage_gain, float current_gain) { this->voltage_gain = voltage_gain; this->current_gain = current_gain; @@ -212,10 +212,6 @@ namespace ElektronischeLast NVIC_SetPriority(DMA1_Channel1_IRQn, 0); NVIC_EnableIRQ(DMA1_Channel1_IRQn); } - iADC::~iADC(void) - { - - } /** * @details Die Auflösung beträgt 0,8mV pro Bit. diff --git a/Source/ADC.hpp b/Source/ADC.hpp index cbb3219..c7b4ef4 100644 --- a/Source/ADC.hpp +++ b/Source/ADC.hpp @@ -15,8 +15,7 @@ namespace ElektronischeLast class iADC { public: - iADC(float voltage_gain, float current_gain); - ~iADC(void); + void init(float voltage_gain, float current_gain); std::uint32_t get_current(void); std::uint32_t get_temperature(void); std::uint32_t get_voltage(void); diff --git a/Source/DAC.cpp b/Source/DAC.cpp index 4eb99a5..c870ae0 100644 --- a/Source/DAC.cpp +++ b/Source/DAC.cpp @@ -11,7 +11,7 @@ namespace ElektronischeLast { - iDAC::iDAC() + void iDAC::init() { /**DAC1 GPIO Configuration PA4 ------> DAC1_OUT1 @@ -48,11 +48,6 @@ namespace ElektronischeLast LL_DAC_Enable(DAC1, LL_DAC_CHANNEL_2); } - iDAC::~iDAC() - { - - } - void iDAC::write(DAC_CHANNEL channel, uint32_t data) { LL_DAC_ConvertData12RightAligned(DAC, /*(channel == CHANNEL_1) ?*/ LL_DAC_CHANNEL_1 /*: LL_DAC_CHANNEL_2*/, data); diff --git a/Source/DAC.hpp b/Source/DAC.hpp index 5ce0ab5..4fa2692 100644 --- a/Source/DAC.hpp +++ b/Source/DAC.hpp @@ -18,8 +18,7 @@ namespace ElektronischeLast CHANNEL_1, CHANNEL_2, } DAC_CHANNEL; - iDAC(); - ~iDAC(); + void init(void); void write(DAC_CHANNEL channel, uint32_t data); private: }; diff --git a/Source/Display.cpp b/Source/Display.cpp index 2faf020..993c5d9 100644 --- a/Source/Display.cpp +++ b/Source/Display.cpp @@ -17,7 +17,7 @@ namespace ElektronischeLast { - Display::Display(void) + void Display::init(void) { LL_GPIO_InitTypeDef init = { @@ -37,11 +37,6 @@ namespace ElektronischeLast this->start_timer(15UL); // 15ms Startup Delay } - Display::~Display(void) - { - - } - void Display::run(void) { switch (this->current_state) diff --git a/Source/Display.hpp b/Source/Display.hpp index 12e487f..b2eb3f5 100644 --- a/Source/Display.hpp +++ b/Source/Display.hpp @@ -88,8 +88,7 @@ namespace ElektronischeLast } State_t; - Display(void); - ~Display(void); + void init(void); void run(void); void set_backlight(bool on); void set_cursor(Line_t line, std::uint32_t position); diff --git a/Source/ElektronischeLast.cpp b/Source/ElektronischeLast.cpp index a448d08..6e57217 100644 --- a/Source/ElektronischeLast.cpp +++ b/Source/ElektronischeLast.cpp @@ -49,6 +49,12 @@ static CLI_Command_t commands[] = { "reboot", "System neu starten", reboot }, }; +static LED led = LED(500U); +static Display lcd = Display(); +static FanControl fan = FanControl(); +static iI2C eeprom = iI2C(0xA0U); +static iDAC dac = iDAC(); +static iADC adc = iADC();; static std::uint32_t i_soll = 0U; static PIDController pid = { @@ -74,10 +80,10 @@ int main (void) serial_init(); printf("\r\nElektronische Last\r\n"); CLI_Init(commands, sizeof(commands)/sizeof(commands[0])); - LED led = LED(500U); - Display lcd = Display(); - FanControl fan = FanControl(); - iI2C eeprom = iI2C(0xA0U); + led.init(); + lcd.init(); + fan.init(); + eeprom.init(); float voltage_gain = NAN; float current_gain = NAN; @@ -94,8 +100,8 @@ int main (void) current_gain = 3.685331f; } - iDAC dac = iDAC(); - iADC adc = iADC(voltage_gain, current_gain); + dac.init(); + adc.init(voltage_gain, current_gain); std::uint32_t last_tick = systick; printf("- Initialisierung erfolgreich\r\n"); diff --git a/Source/FanControl.cpp b/Source/FanControl.cpp index 7b76bd4..55b1d66 100644 --- a/Source/FanControl.cpp +++ b/Source/FanControl.cpp @@ -37,7 +37,7 @@ namespace ElektronischeLast { 80U, DUTY_TO_TIM_VALUE(100U) } }; - FanControl::FanControl(void) + void FanControl::init(void) { /* TIM3 PWM-Output * 25kHz (Vorgabe Intel). Geschwindigkeit wird über Tastverhältnis geregelt. diff --git a/Source/FanControl.hpp b/Source/FanControl.hpp index 79ec3a7..0e00271 100644 --- a/Source/FanControl.hpp +++ b/Source/FanControl.hpp @@ -17,8 +17,7 @@ namespace ElektronischeLast class FanControl { public: - FanControl(void); - ~FanControl(void); + void init(void); void run(std::uint32_t temp); std::uint32_t get_speed(void); private: diff --git a/Source/I2C.cpp b/Source/I2C.cpp index 6ba1d7c..a8d3b7b 100644 --- a/Source/I2C.cpp +++ b/Source/I2C.cpp @@ -16,6 +16,9 @@ namespace ElektronischeLast { this->device_address = device_address; + } + void iI2C::init(void) + { LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA); /**I2C2 GPIO Configuration PA11 [PA9] ------> I2C2_SCL @@ -56,10 +59,6 @@ namespace ElektronischeLast LL_I2C_SetMasterAddressingMode(I2C2, LL_I2C_ADDRESSING_MODE_7BIT); LL_I2C_Enable(I2C2); - } - iI2C::~iI2C(void) - { - } bool iI2C::read(std::uint32_t address, std::uint32_t length, std::uint8_t buffer[]) { diff --git a/Source/I2C.hpp b/Source/I2C.hpp index e88ce18..c83da0a 100644 --- a/Source/I2C.hpp +++ b/Source/I2C.hpp @@ -16,7 +16,7 @@ namespace ElektronischeLast { public: iI2C(std::uint8_t device_address); - ~iI2C(void); + void init(void); bool read(std::uint32_t address, std::uint32_t length, std::uint8_t buffer[]); bool write(std::uint32_t address, std::uint32_t length, std::uint8_t buffer[]); private: diff --git a/Source/LED.cpp b/Source/LED.cpp index 0474c20..b395dea 100644 --- a/Source/LED.cpp +++ b/Source/LED.cpp @@ -12,6 +12,11 @@ namespace ElektronischeLast { LED::LED(std::uint32_t interval) + { + this->interval = interval; + } + + void LED::init(void) { LL_GPIO_InitTypeDef GPIO_InitStruct = { .Pin = LL_GPIO_PIN_10, @@ -25,12 +30,6 @@ namespace ElektronischeLast LL_GPIO_Init(GPIOA, &GPIO_InitStruct); this->last_toggle = systick; - this->interval = interval; - } - - LED::~LED() - { - } void LED::blink(void) diff --git a/Source/LED.hpp b/Source/LED.hpp index 5eac93d..3c6aa54 100644 --- a/Source/LED.hpp +++ b/Source/LED.hpp @@ -16,7 +16,7 @@ namespace ElektronischeLast { public: LED(std::uint32_t interval); - ~LED(); + void init(void); void blink(void); void toggle(void); private: