fprime/Svc/RateGroupDriver/RateGroupDriver.hpp
Thomas Boyer-Chammard 564cb5773b
Add Os::RawTime OSAL implementation, refactor Os::IntervalTimer (#2923)
* Add Os::RawTime and preliminary rule-based tests

* Implement Stubs and stub tests tests + misc improvements

* Update delay functions to use Fw::TimeInterval instead of Fw::Time

* Replace TimerVal with Os::RawTime FPP type, SERIALIZED_SIZE fixed to 2*sizeof(U32)

* Fix spelling and legacy code

* Fix test import

* Remove TimerVal files and misc clean up

* Add Fw/Time as dependency of Os module

* Fix include guards

* Fix default constructors and missing getHandle stub

* Add Handle and Serialization size to FpConfig, refactor interface for less vtable calls, refactor IntervalTimer

* Fixes for new OS CMake API

* Add RawTime FPP Model

* Rename getRawTime to now(), better error handling, added docs for all functions

* Correct handle size, spelling, and more robust test IntervalTimer test

* Peer review changes

* Move `Os.RawTime` to `Os/Types.fpp`

* Fix unused variable

* Fix spelling and comments

* spelling extravaganza

* Update metadata

check-spelling run (pull_request_target) for os-interval-timer

Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
on-behalf-of: @check-spelling <check-spelling-bot@check-spelling.dev>

* Reference based approach to minuend and subtrahend

---------

Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
Co-authored-by: Thomas Boyer-Chammard <thomas-bc@users.noreply.github.com>
Co-authored-by: M Starch <LeStarch@googlemail.com>
2024-10-14 10:06:45 -07:00

102 lines
3.1 KiB
C++

/**
* \file
* \author T. Canham
* \brief RateGroupDivider component implementation
*
* This component implements a divider function. A primary tick is invoked
* via the CycleIn port. The divider array then divides down the tick into
* CycleOut ports. The ports are called at the rate of
* input rate/divider[port]
*
* \copyright
* Copyright 2009-2015, by the California Institute of Technology.
* ALL RIGHTS RESERVED. United States Government Sponsorship
* acknowledged.
* <br /><br />
*/
#ifndef SVC_RATEGROUPDRIVER_HPP
#define SVC_RATEGROUPDRIVER_HPP
#include <Svc/RateGroupDriver/RateGroupDriverComponentAc.hpp>
#include <FpConfig.hpp>
namespace Svc {
//! \class RateGroupDriver
//! \brief Implementation class for RateGroupDriver
//!
//! Takes the input from CycleIn and divides it.
//! Output rate is CycleIn rate/divider[port]
//!
class RateGroupDriver : public RateGroupDriverComponentBase {
public:
//! Size of the divider table, provided as a constants to users passing the table in
static const NATIVE_UINT_TYPE DIVIDER_SIZE = NUM_CYCLEOUT_OUTPUT_PORTS;
//! \class Divider
//! \brief Struct describing a divider
struct Divider{
//! Initializes divisor and offset to 0 (unused)
Divider() : divisor(0), offset(0)
{}
//! Initializes divisor and offset to passed-in pair
Divider(NATIVE_INT_TYPE divisorIn, NATIVE_INT_TYPE offsetIn) :
divisor(divisorIn), offset(offsetIn)
{}
//! Divisor
NATIVE_INT_TYPE divisor;
//! Offset
NATIVE_INT_TYPE offset;
};
//! \class DividerSet
//! \brief Struct containing an array of dividers
struct DividerSet {
//! Dividers
Divider dividers[Svc::RateGroupDriver::DIVIDER_SIZE];
};
//! \brief RateGroupDriver constructor
//!
//! The constructor takes the divider array and stores it
//! for use when the CycleIn port is called.
//!
//! \param compName component name
//!
RateGroupDriver(const char* compName);
//! \brief RateGroupDriver configuration function
//! \param dividersSet set of dividers used to divide down input tick
void configure(const DividerSet& dividersSet);
//! \brief RateGroupDriverImpl destructor
~RateGroupDriver();
PRIVATE:
//! downcall for input port
//! NOTE: This port can execute in ISR context.
void CycleIn_handler(NATIVE_INT_TYPE portNum, Os::RawTime& cycleStart);
//! divider array
Divider m_dividers[NUM_CYCLEOUT_OUTPUT_PORTS];
//! tick counter
NATIVE_INT_TYPE m_ticks;
//! rollover counter
NATIVE_INT_TYPE m_rollover;
//! has the configure method been called
bool m_configured;
};
}
#endif