You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.3 KiB
C
61 lines
1.3 KiB
C
7 months ago
|
/*
|
||
|
* FRAMVariant.h
|
||
|
*
|
||
|
* Author: Aleksey Gerasimenko
|
||
|
* gerasimenko.aleksey.n@gmail.com
|
||
|
*/
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include "SYSCTRL/SystemDefinitions.h"
|
||
|
|
||
|
|
||
|
#ifndef FRAM_FRAMVARIANT_H_
|
||
|
#define FRAM_FRAMVARIANT_H_
|
||
|
|
||
|
namespace FRAM
|
||
|
{
|
||
|
|
||
|
typedef unsigned char uint8_t;
|
||
|
|
||
|
enum fram_variant_type_t {FRAM_VARIANT_UNDEFINED, FRAM_VARIANT_FLOAT, FRAM_VARIANT_INT16, FRAM_VARIANT_INT32, FRAM_VARIANT_UINT16, FRAM_VARIANT_UINT32, FRAM_VARIANT_BOOL};
|
||
|
|
||
|
class FRAMVariant
|
||
|
{
|
||
|
private:
|
||
|
union
|
||
|
{
|
||
|
float f;
|
||
|
int16_t i16;
|
||
|
int32_t i32;
|
||
|
uint16_t u16;
|
||
|
uint32_t u32;
|
||
|
bool b;
|
||
|
SYSCTRL::Register16 r16;
|
||
|
SYSCTRL::Register32 r32;
|
||
|
};
|
||
|
private:
|
||
|
fram_variant_type_t t;
|
||
|
public:
|
||
|
FRAMVariant();
|
||
|
fram_variant_type_t get_type() const;
|
||
|
//setters
|
||
|
void set_float(float v);
|
||
|
void set_int16(int16_t v);
|
||
|
void set_int32(int32_t v);
|
||
|
void set_uint16(uint16_t v);
|
||
|
void set_uint32(uint32_t v);
|
||
|
void set_bool(bool v);
|
||
|
//getters
|
||
|
float get_float() const;
|
||
|
int16_t get_int16() const;
|
||
|
int32_t get_int32() const;
|
||
|
uint16_t get_uint16() const;
|
||
|
uint32_t get_uint32() const;
|
||
|
bool get_bool() const;
|
||
|
//
|
||
|
};//class fram_variant_t
|
||
|
//
|
||
|
}/* namespace FRAM */
|
||
|
|
||
|
#endif /* FRAM_FRAMVARIANT_H_ */
|