MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/schematic/BitmapU16ToSignal.hpp
2024-06-07 11:12:56 +03:00

42 lines
1004 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Bitmap2Signal.hpp
*
* Created on: 13 авг. 2020 г.
* Author: s.maksimenko
*/
#ifndef UMLIBRARY_SCHEMATIC_BITMAPU16TOSIGNAL_HPP_
#define UMLIBRARY_SCHEMATIC_BITMAPU16TOSIGNAL_HPP_
#include <cstddef>
#include <stdint.h>
#include "../systemic/ISignal.hh"
namespace schematic {
class BitmapU16ToSignal : public systemic::ISignal
{
public:
struct Setting {
uint16_t iFirstBit;// Индекс первого значащего бита
uint16_t nBits;// Число значащих битов
bool bInvCode;// Признак инверсного кода
};
private:
Setting mSett;
volatile uint16_t& mBitmap;
public:
BitmapU16ToSignal( volatile uint16_t& bitmapU16, const Setting& sett) :
mBitmap(bitmapU16), mSett(sett){}
operator float() const {
return ((mBitmap ^ (mSett.bInvCode ? ~0: 0)) >> mSett.iFirstBit) & ((1u << mSett.nBits) - 1);
}
};// !BitmapU16ToSignal
} // namespace schematic
#endif /* UMLIBRARY_SCHEMATIC_BITMAPU16TOSIGNAL_HPP_ */