KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ahrs.h File Reference

This driver is to read and configure the AHRS I2C sensor. More...

#include "types.h"
#include "util/float.h"
#include "drv/wb/i2c.h"
#include "errorcode.h"

Go to the source code of this file.

Macros

#define E_AHRS_REGSDIFFER   ( E_AHRS + 1 )
 
#define E_AHRS_REGSDIFFER_DESCR   "Returned register differs"
 
#define AHRS_VALID_CNT_NUM   5000
 Number of measure to do before receiving accurate results.
 
#define AHRS_REG_DATA   0x00
 
#define AHRS_REG_KALMAN_ENABLED   0x32
 
#define AHRS_REG_VERSION   0x33
 

Functions

void ahrsOn ()
 Switch on the AHRS.
 
void ahrsOff ()
 Switch off the AHRS.
 
bool ahrsWriteReg (I2C_Device *dev, uint8_t addr, uint8_t reg_addr, f32_t newvalue, f32_t *readback)
 Writes an AHRS register. More...
 
bool ahrsReadReg (I2C_Device *dev, uint8_t addr, uint8_t reg_addr, f32_t *value)
 Reads an AHRS register. More...
 
bool ahrsGetVersion (I2C_Device *dev, uint8_t addr, uint8_t *version)
 Reads the AHRS version. More...
 
bool ahrsRead (I2C_Device *dev, uint8_t addr, CompassData *data)
 Reads all data from the AHRS. More...
 

Detailed Description

This driver is to read and configure the AHRS I2C sensor.

Usage:

AHRS_Data_Struct data;
if (ahrsRead(I2C2, AHRS_I2C_ADDR, AHRS_DATA_ID, (uint8_t *)&data, sizeof(data))) {
printf("\n\nYaw: %x %x %x %x \n", data.Yaw[0], data.Yaw[1], data.Yaw[2], data.Yaw[3]);
printf("\n\nPitch: %x %x %x %x \n", data.Pitch[0], data.Pitch[1], data.Pitch[2], data.Pitch[3]);
printf...
}else{
//print the error
printf("Error reading AHRS:\n");
if (errHas()){
errPrint(true);
}
}

Definition in file ahrs.h.

Function Documentation

bool ahrsGetVersion ( I2C_Device dev,
uint8_t  addr,
uint8_t *  version 
)

Reads the AHRS version.

Parameters
devI2C device
addrThe I2C address version 8 bit integer to fill. First digit is the major version, second digit the minor
Return values
trueSuccess
falseFailure, see err module for error.

Definition at line 86 of file ahrs.c.

bool ahrsRead ( I2C_Device dev,
uint8_t  addr,
CompassData data 
)

Reads all data from the AHRS.

Parameters
devI2C device
addrThe I2C address
dataPointer to the AHR Data structure to fill.
Return values
trueSuccess
falseFailure, see err module for error.

Definition at line 99 of file ahrs.c.

bool ahrsReadReg ( I2C_Device dev,
uint8_t  addr,
uint8_t  reg_addr,
f32_t value 
)

Reads an AHRS register.

Parameters
devI2C device
addrThe I2C address
reg_addrThe AHRS register address
valuePointer to float to place the register value in.
Return values
trueSuccess
falseFailure, see err module for error.

Definition at line 68 of file ahrs.c.

bool ahrsWriteReg ( I2C_Device dev,
uint8_t  addr,
uint8_t  reg_addr,
f32_t  newvalue,
f32_t readback 
)

Writes an AHRS register.

Parameters
devI2C device
addrThe I2C address
reg_addrThe AHRS register address
newvalueThe value to set
readbackPointer to float to place the resulting value in. Pointer may be NULL.
Return values
trueSuccess
falseFailure, see err module for error.

Definition at line 53 of file ahrs.c.