From 290644b92e41f4385a5214676195ff09e40ac936 Mon Sep 17 00:00:00 2001 From: Ebersold Andre Date: Tue, 21 Dec 2021 20:02:27 +0100 Subject: [PATCH] Make DCmotor compile for 328p target. Still works needs to be done for a proper implementation of AvrPwm --- Application/DCMotor/328p_DCMotor.cpp | 3 +- Application/DCMotor/Led0.h | 4 +++ Application/DCMotor/main.cpp | 1 + HAL/AVR/328p_Pwm.cpp | 45 ++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Application/DCMotor/328p_DCMotor.cpp b/Application/DCMotor/328p_DCMotor.cpp index 19d897a..3f7fa1e 100644 --- a/Application/DCMotor/328p_DCMotor.cpp +++ b/Application/DCMotor/328p_DCMotor.cpp @@ -10,7 +10,6 @@ #include #include -#include "Led0.h" #include "DCMotor.h" #if defined (__AVR_ATmega32U4__) @@ -109,7 +108,7 @@ Motor::onWriteValue(const uint8_t paramID,const Float32_t _val) void Motor::enable(bool _val) - +{ if ( _val != 0 ) { (*m_Port) |= _BV( PIN_MOTOR_ENABLE); diff --git a/Application/DCMotor/Led0.h b/Application/DCMotor/Led0.h index e8f4209..9c88c45 100644 --- a/Application/DCMotor/Led0.h +++ b/Application/DCMotor/Led0.h @@ -1,3 +1,6 @@ +#ifndef __LED0_H__ +#define __LED0_H__ + /** * \brief simple class for port access for LEDs * @@ -50,3 +53,4 @@ class Led0 IParameterHandler *m_Param; }; +#endif diff --git a/Application/DCMotor/main.cpp b/Application/DCMotor/main.cpp index 6d313af..3d14737 100644 --- a/Application/DCMotor/main.cpp +++ b/Application/DCMotor/main.cpp @@ -171,6 +171,7 @@ int main(void) AvrPwm pwmA; #else Led0 led(&PORTB, &DDRB, PINB5,&gParam); + AvrPwm pwmA; #endif AvrUart uart(IUart::BAUD_9600,IUart::PARITY_NONE,IUart::STB_ONE); AvrADC gAdc; diff --git a/HAL/AVR/328p_Pwm.cpp b/HAL/AVR/328p_Pwm.cpp index e69de29..f5a96e5 100644 --- a/HAL/AVR/328p_Pwm.cpp +++ b/HAL/AVR/328p_Pwm.cpp @@ -0,0 +1,45 @@ +#include "HAL/Abstract/IPwm.h" + + +#if 0 +static Motor::pinMapping_t GmA = {PINB7,PINB6,0}; + + , m_MotorA(&OCR0A,&TCCR0A,GmA,COM0A0,_p) +#if ! defined (__AVR_ATmega32U4__) + , m_MotorB(&OCR2B,&TCCR2A,GmB,COM2B0,_p) +#endif +#endif + +#define USE_T1 1 +/// +AvrPwm::AvrPwm() + : IPwm() +{ + //_init(); +} + +/// From Interface +void +AvrPwm::enable(const Bool_t _OnOff) const +{ +} + + +/// From Interface +void +AvrPwm::setFreq(Uint16_t freq) const +{ +} + + +/// From Interface +void +AvrPwm::setDutyCycle(const Uint8_t _d) const +{ +#ifdef USE_T1 + //OCR1C = (4 * _d); +#else + //OCR0A = _d; +#endif +} + -- 2.30.2