Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
Pwm.h
Go to the documentation of this file.
1 /*
2  * Pwm.h
3  *
4  * Created on: Mar 19, 2019
5  * Author: jcormier
6  *
7  * Documentation: http://wanda/svn/camera/soc_camera/trunk/hw/fpga/ip/pwm/PWM Design.docx
8  */
9 
10 #ifndef PWM_H_
11 #define PWM_H_
12 
13 #include <chrono>
14 #include <string>
15 #include <libfpga/fpgaregister.h>
16 
17 #include "UioIrq.h"
18 
19 class tcPwm {
20 public:
21  tcPwm(uint32_t anAddress, double anRefClkMhz, std::string acUioName = std::string());
22  virtual ~tcPwm();
23 
24  bool initialized();
25 
26  void setRefClkMhz(double anRefClkMhz) { mnRefClkMhz = anRefClkMhz; }
27 
28  uint32_t readVersion();
29 
30  bool readCoreEnable();
31  void enableCore(bool abEnable);
32 
33  bool readInvertPulse();
34  void setInvertPulse(bool abPulseLow);
35 
36  void setPeriodTime(std::chrono::microseconds anPeriod);
37  void setPeriodFreq(uint32_t anFreqHz);
38  void setPeriodClks(uint64_t anPeriodClks);
39 
40  void setDutyTime(std::chrono::microseconds anDuty);
41  void setDutyPercent(double anDutyPercent);
42  void setDutyClks(uint32_t anDutyClks);
43 
44  void dumpRegisters();
45 
46  void enableInterrupts(bool abDeAssert, bool abEnable);
47  bool interruptPending(void);
48  void clearInterruptStatus(void);
49  int waitForInterrupt(std::chrono::microseconds anTimeout);
50 
51 private:
52  uint16_t readClockDivider();
53  void setClockDivider(uint16_t anClkDivider);
54 
55  uint32_t readPulseActiveTime();
56  void setPulseActiveTime(uint32_t anPulseTime);
57 
58  uint32_t readPulsePeriod();
59  void setPulsePeriod(uint32_t anPulsePeriod);
60 
61  tcFPGARegister<uint32_t> mhRegister;
62  double mnRefClkMhz;
63 
64  tcUioIrq mcUioIrq;
65 };
66 
67 #endif /* PWM_H_ */
tcPwm::setPeriodTime
void setPeriodTime(std::chrono::microseconds anPeriod)
tcPwm::setPeriodTime Configures prescalar and pulse period registers
Definition: Pwm.cpp:123
tcPwm::enableInterrupts
void enableInterrupts(bool abDeAssert, bool abEnable)
tcPwm::enableInterrupts Enables the PWM core to generate interrupts
Definition: Pwm.cpp:305
tcPwm::initialized
bool initialized()
Definition: Pwm.cpp:50
tcPwm::waitForInterrupt
int waitForInterrupt(std::chrono::microseconds anTimeout)
tcPwm::waitForInterrupt Wait for the PWM to trigger and interrupt condition
Definition: Pwm.cpp:353
tcPwm::setPeriodFreq
void setPeriodFreq(uint32_t anFreqHz)
tcPwm::setPeriodFreq Configures prescalar and pulse period registers
Definition: Pwm.cpp:134
tcPwm::enableCore
void enableCore(bool abEnable)
tcPwm::enableCore Enable/Disable the pulse output When disabled the output will be in the inactive st...
Definition: Pwm.cpp:87
tcPwm::tcPwm
tcPwm(uint32_t anAddress, double anRefClkMhz, std::string acUioName=std::string())
tcPwm::tcPwm Class Constructor.
Definition: Pwm.cpp:35
tcPwm::setDutyTime
void setDutyTime(std::chrono::microseconds anDuty)
tcPwm::setDutyTime Configures pulse active time register
Definition: Pwm.cpp:176
tcPwm
Definition: Pwm.h:19
tcPwm::readInvertPulse
bool readInvertPulse()
tcPwm::readInvertPulse True is pulse active low and inactive high. False is pulse active high and ina...
Definition: Pwm.cpp:100
UioIrq.h
tcPwm::setRefClkMhz
void setRefClkMhz(double anRefClkMhz)
Definition: Pwm.h:26
tcUioIrq
Definition: UioIrq.h:16
tcPwm::clearInterruptStatus
void clearInterruptStatus(void)
tcPwm::clearInterruptStatus Cleas the interrupt pending status.
Definition: Pwm.cpp:336
tcPwm::setDutyClks
void setDutyClks(uint32_t anDutyClks)
tcPwm::setDutyClks Configures pulse active time register
Definition: Pwm.cpp:204
tcPwm::dumpRegisters
void dumpRegisters()
tcPwm::dumpRegisters Print various registers to console
Definition: Pwm.cpp:288
tcPwm::readVersion
uint32_t readVersion()
tcPwm::readVersion of the fpga core
Definition: Pwm.cpp:68
tcPwm::setPeriodClks
void setPeriodClks(uint64_t anPeriodClks)
tcPwm::setPeriodClks Configures prescalar and pulse period registers
Definition: Pwm.cpp:146
tcPwm::~tcPwm
virtual ~tcPwm()
Definition: Pwm.cpp:46
tcPwm::setDutyPercent
void setDutyPercent(double anDutyPercent)
tcPwm::setDutyPercent Configures pulse active time register
Definition: Pwm.cpp:188
tcPwm::setInvertPulse
void setInvertPulse(bool abPulseLow)
tcPwm::setInvertPulse True is pulse active low and inactive high. False is pulse active high and inac...
Definition: Pwm.cpp:112
tcPwm::interruptPending
bool interruptPending(void)
tcPwm::interruptPending
Definition: Pwm.cpp:328
tcPwm::readCoreEnable
bool readCoreEnable()
tcPwm::readCoreEnable
Definition: Pwm.cpp:77