5#define TLV493D_DEFAULTMODE POWERDOWNMODE
7#define TLV493D_ADDRESS1 0x5E
8#define TLV493D_ADDRESS2 0x1F
9#define TLV493D_BUSIF_READSIZE 10
10#define TLV493D_BUSIF_WRITESIZE 4
11#define TLV493D_NUM_OF_REGMASKS 25
12#define TLV493D_DEFAULTMODE POWERDOWNMODE
13#define TLV493D_MEASUREMENT_READOUT 7
15#define TLV493D_B_MULT 0.098f
16#define TLV493D_TEMP_MULT 1.1
17#define TLV493D_TEMP_OFFSET 315
20#define REGMASK_WRITE 1
112template <
typename Transport>
247 return GetTransportErr();
269 return GetFromRegs(
mask, regReadData);
273 return GetFromRegs(
mask, regWriteData);
285 prev_sample_period_ =
now;
337 *
sqrt(
pow(
static_cast<float>(mXdata), 2)
338 +
pow(
static_cast<float>(mYdata), 2)
339 +
pow(
static_cast<float>(mZdata), 2));
346 return atan2(
static_cast<float>(mYdata),
static_cast<float>(mXdata));
353 return atan2(
static_cast<float>(mZdata),
354 sqrt(
pow(
static_cast<float>(mXdata), 2)
355 +
pow(
static_cast<float>(mYdata), 2)));
382 y ^= regWriteData[
i];
415 int16_t mXdata, mYdata, mZdata, mTempdata, mExpectedFrameCount, mMode;
441 transport_.WriteAddress(0x00, &data, 1);
444 uint8_t GetFromRegs(
const RegMask_t *mask, uint8_t *regData)
446 return (regData[mask->byteAdress] & mask->bitMask) >> mask->shift;
450 void SetToRegs(
const RegMask_t *mask, uint8_t *regData, uint8_t toWrite)
454 uint8_t regValue = regData[mask->byteAdress];
455 regValue &= ~(mask->bitMask);
456 regValue |= (toWrite << mask->shift) & mask->bitMask;
457 regData[mask->byteAdress] = regValue;
Result Init(const Config &config)
Result ReceiveBlocking(uint16_t address, uint8_t *data, uint16_t size, uint32_t timeout)
Result TransmitBlocking(uint16_t address, uint8_t *data, uint16_t size, uint32_t timeout)
Definition leddriver.h:33
void Init(I2CHandle i2c, const uint8_t(&addresses)[numDrivers], DmaBuffer dma_buffer_a, DmaBuffer dma_buffer_b, Pin oe_pin=Pin(PORTX, 0))
Definition leddriver.h:65
static void Delay(uint32_t delay_ms)
Device support for TLV493D Magnetic Sensor.
Definition tlv493d.h:114
float GetY()
Definition tlv493d.h:320
void SetInterrupt(bool enable)
Definition tlv493d.h:303
float GetX()
Definition tlv493d.h:317
void UpdateData()
Definition tlv493d.h:280
void CalcParity()
Definition tlv493d.h:371
Result
Definition tlv493d.h:216
@ ERR
Definition tlv493d.h:218
@ OK
Definition tlv493d.h:217
Tlv493d()
Definition tlv493d.h:116
float GetTemp()
Definition tlv493d.h:326
float GetZ()
Definition tlv493d.h:323
AccessMode_e
Definition tlv493d.h:165
@ MASTERCONTROLLEDMODE
Definition tlv493d.h:170
@ ULTRALOWPOWERMODE
Definition tlv493d.h:169
@ POWERDOWNMODE
Definition tlv493d.h:166
@ FASTMODE
Definition tlv493d.h:167
@ LOWPOWERMODE
Definition tlv493d.h:168
void SetRegBits(uint8_t regMaskIndex, uint8_t data)
Definition tlv493d.h:254
const RegMask_t RegMasks[25]
Definition tlv493d.h:181
float GetAmount()
Definition tlv493d.h:333
uint8_t GetRegBits(uint8_t regMaskIndex)
Definition tlv493d.h:262
float GetPolar()
Definition tlv493d.h:350
void EnableTemp(bool enable)
Definition tlv493d.h:310
uint16_t GetMeasurementDelay()
Definition tlv493d.h:358
float GetAzimuth()
Definition tlv493d.h:343
Result Init(Config config)
Definition tlv493d.h:224
const AccessMode_t accModes[5]
Definition tlv493d.h:173
int16_t ConcatResults(uint8_t upperByte, uint8_t lowerByte, bool upperFull)
Definition tlv493d.h:392
void ReadOut()
Definition tlv493d.h:250
void WriteOut()
Definition tlv493d.h:252
Registers_e
Definition tlv493d.h:120
@ W_INT
Definition tlv493d.h:137
@ W_LOWPOWER
Definition tlv493d.h:139
@ R_BX1
Definition tlv493d.h:121
@ R_RES2
Definition tlv493d.h:133
@ R_BZ2
Definition tlv493d.h:126
@ R_CHANNEL
Definition tlv493d.h:130
@ W_PARITY_EN
Definition tlv493d.h:142
@ R_POWERDOWNFLAG
Definition tlv493d.h:131
@ W_RES3
Definition tlv493d.h:145
@ R_BY2
Definition tlv493d.h:124
@ R_TEMP2
Definition tlv493d.h:128
@ R_TEMP1
Definition tlv493d.h:127
@ W_RES2
Definition tlv493d.h:144
@ R_RES1
Definition tlv493d.h:132
@ R_BY1
Definition tlv493d.h:123
@ W_LP_PERIOD
Definition tlv493d.h:141
@ W_TEMP_NEN
Definition tlv493d.h:140
@ W_FAST
Definition tlv493d.h:138
@ W_RES1
Definition tlv493d.h:143
@ R_FRAMECOUNTER
Definition tlv493d.h:129
@ W_ADDR
Definition tlv493d.h:136
@ W_PARITY
Definition tlv493d.h:135
@ R_BZ1
Definition tlv493d.h:125
@ R_BX2
Definition tlv493d.h:122
@ R_RES3
Definition tlv493d.h:134
~Tlv493d()
Definition tlv493d.h:117
void SetAccessMode(AccessMode_e mode)
Definition tlv493d.h:360
~Tlv493dI2CTransport()
Definition tlv493d.h:33
Tlv493dI2CTransport()
Definition tlv493d.h:32
void Write(uint8_t *data, uint16_t size)
Definition tlv493d.h:79
void WriteAddress(uint8_t add, uint8_t *data, uint16_t size)
Definition tlv493d.h:74
uint8_t GetAddress()
Definition tlv493d.h:99
void Read(uint8_t *data, uint16_t size)
Definition tlv493d.h:85
bool GetError()
Definition tlv493d.h:91
void Init(Config config)
Definition tlv493d.h:56
Hardware defines and helpers for daisy field platform.
Definition index.h:2
@ PORTB
Definition daisy_core.h:178
struct daisy::I2CHandle::Config::@15 pin_config
Mode mode
Definition i2c.h:65
Speed speed
Definition i2c.h:64
Peripheral periph
Definition i2c.h:57
Peripheral
Definition i2c.h:40
representation of hardware port/pin combination
Definition daisy_core.h:193
uint16_t measurementTime
Definition tlv493d.h:161
uint8_t lp
Definition tlv493d.h:159
uint8_t fast
Definition tlv493d.h:158
uint8_t lpPeriod
Definition tlv493d.h:160
Config()
Definition tlv493d.h:212
Transport::Config transport_config
Definition tlv493d.h:211
uint8_t shift
Definition tlv493d.h:153
uint8_t rw
Definition tlv493d.h:150
uint8_t byteAdress
Definition tlv493d.h:151
uint8_t bitMask
Definition tlv493d.h:152
Config()
Definition tlv493d.h:44
I2CHandle::Config::Speed speed
Definition tlv493d.h:38
uint8_t address
Definition tlv493d.h:42
Pin sda
Definition tlv493d.h:40
I2CHandle::Config::Peripheral periph
Definition tlv493d.h:37
Pin scl
Definition tlv493d.h:39
#define TLV493D_B_MULT
Definition tlv493d.h:15
#define TLV493D_BUSIF_READSIZE
Definition tlv493d.h:9
#define REGMASK_READ
Definition tlv493d.h:19
#define TLV493D_ADDRESS1
Definition tlv493d.h:7
#define REGMASK_WRITE
Definition tlv493d.h:20
#define TLV493D_TEMP_MULT
Definition tlv493d.h:16
#define TLV493D_BUSIF_WRITESIZE
Definition tlv493d.h:10
#define TLV493D_NUM_OF_REGMASKS
Definition tlv493d.h:11
#define TLV493D_TEMP_OFFSET
Definition tlv493d.h:17