CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
Loading...
Searching...
No Matches
PWMCore.h
Go to the documentation of this file.
1#ifndef PWMCORE_H
2#define PWMCORE_H
3
4#include "OutputDefinition.h"
5#include "Debug.h"
6#include "CANTramCore.h"
7#include "HardwareResource.h"
8
17
18// Base Class for PWM functionality, platform specific implementations should derive from this
19class PWMCore : public HardwareResource {
20 public:
21
29 virtual void begin();
30
39 virtual bool addChannel(OutputDefinition* def)=0; //Returns true if channel was added successfully
40
49 virtual void setDuty(OutputDefinition* def, uint16_t duty)=0; //Duty cycle between 0 and 4095 for 12 bit resolution
50
57
58 private:
59
60
61 protected:
67 PWMCore() = default;
68
73 bool _initialized=false;
74
81 virtual uint8_t getMaxUsages() override { return 1; } //PWMCore can only be used by one module (the main module)
82};
83
84#endif
This class serves as the core manager for the CANTram modular system. It handles module attachment,...
Logging and debug macro definitions for CANTramCore.
Base class for hardware resources.
Definitions for GPIO/output descriptors and provider interfaces.
HardwareResource()=default
Default constructor.
Type
Enumeration of hardware resource types.
Definition HardwareResource.h:26
@ PWM
PWM type.
Definition HardwareResource.h:30
Describes an available output (GPIO or shift register bit).
Definition OutputDefinition.h:24
virtual bool addChannel(OutputDefinition *def)=0
Add/allocate a PWM channel for the given output definition.
HardwareResource::Type getType() override
Get the hardware resource type.
Definition PWMCore.h:56
virtual void begin()
Initialize PWM core resources.
virtual uint8_t getMaxUsages() override
Get the maximum simultaneous usages allowed for this resource.
Definition PWMCore.h:81
bool _initialized
Internal initialized flag.
Definition PWMCore.h:73
virtual void setDuty(OutputDefinition *def, uint16_t duty)=0
Set PWM duty cycle for a registered output.
PWMCore()=default
Protected default constructor.