sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
Sensors.cpp File Reference
#include "Arduino.h"
#include "config.h"
#include "def.h"
#include "types.h"
#include "MultiWii.h"
#include "Alarms.h"
#include "EEPROM.h"
#include "IMU.h"
#include "LCD.h"
#include "Sensors.h"

Macros

#define ACC_ORIENTATION(X, Y, Z)   {imu.accADC[ROLL] = X; imu.accADC[PITCH] = Y; imu.accADC[YAW] = Z;}
 
#define GYRO_ORIENTATION(X, Y, Z)   {imu.gyroADC[ROLL] = X; imu.gyroADC[PITCH] = Y; imu.gyroADC[YAW] = Z;}
 
#define MAG_ORIENTATION(X, Y, Z)   {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = Z;}
 
#define GYRO_DLPF_CFG   0
 
#define BME280_ADDRESS   0x77
 
#define BME280_REGISTER_DIG_T1   0x88
 
#define BME280_REGISTER_DIG_T2   0x8A
 
#define BME280_REGISTER_DIG_T3   0x8C
 
#define BME280_REGISTER_DIG_P1   0x8E
 
#define BME280_REGISTER_DIG_P2   0x90
 
#define BME280_REGISTER_DIG_P3   0x92
 
#define BME280_REGISTER_DIG_P4   0x94
 
#define BME280_REGISTER_DIG_P5   0x96
 
#define BME280_REGISTER_DIG_P6   0x98
 
#define BME280_REGISTER_DIG_P7   0x9A
 
#define BME280_REGISTER_DIG_P8   0x9C
 
#define BME280_REGISTER_DIG_P9   0x9E
 
#define BME280_REGISTER_DIG_H1   0xA1
 
#define BME280_REGISTER_DIG_H2   0xE1
 
#define BME280_REGISTER_DIG_H3   0xE3
 
#define BME280_REGISTER_DIG_H4   0xE4
 
#define BME280_REGISTER_DIG_H5   0xE5
 
#define BME280_REGISTER_DIG_H6   0xE7
 
#define BME280_REGISTER_SOFTRESET   0xE0
 
#define BME280_REGISTER_CONTROLHUMID   0xF2
 
#define BME280_REGISTER_STATUS   0XF3
 
#define BME280_REGISTER_CONTROL   0xF4
 
#define BME280_REGISTER_CONFIG   0xF5
 
#define BME280_REGISTER_PRESSUREDATA   0xF7
 
#define BME280_REGISTER_TEMPDATA   0xFA
 
#define SAMPLING_X16   0b101
 
#define MODE_NORMAL   0b11
 
#define FILTER_OFF   0b000
 
#define STANDBY_MS_0_5   0b000
 
#define LSM9DS0_ADDRESS_ACCELMAG   (0x1D)
 
#define LSM9DS0_ADDRESS_GYRO   (0x6B)
 
#define LSM9DS0_REGISTER_CTRL_REG1_G   0x20
 
#define LSM9DS0_REGISTER_CTRL_REG4_G   0x23
 
#define LSM9DS0_REGISTER_OUT_X_L_G   0x28
 
#define LSM9DS0_REGISTER_OUT_X_L_M   0x08
 
#define LSM9DS0_REGISTER_CTRL_REG1_XM   0x20
 
#define LSM9DS0_REGISTER_CTRL_REG2_XM   0x21
 
#define LSM9DS0_REGISTER_CTRL_REG5_XM   0x24
 
#define LSM9DS0_REGISTER_CTRL_REG6_XM   0x25
 
#define LSM9DS0_REGISTER_CTRL_REG7_XM   0x26
 
#define LSM9DS0_REGISTER_OUT_X_L_A   0x28
 
#define LSM9DS0_ACCELRANGE_4G   (0b001 << 3)
 
#define LSM9DS0_MAGGAIN_4GAUSS   (0b01 << 5)
 
#define LSM9DS0_GYROSCALE_2000DPS   (0b10 << 4)
 
#define ACC_DELIMITER   4
 

Functions

void i2c_init (void)
 
void __attribute__ ((noinline)) waitTransmissionI2C(uint8_t twcr)
 
void i2c_rep_start (uint8_t address)
 
void i2c_stop (void)
 
void i2c_write (uint8_t data)
 
uint8_t i2c_readAck ()
 
uint8_t i2c_readNak ()
 
void i2c_read_reg_to_buf (uint8_t add, uint8_t reg, uint8_t *buf, uint8_t size)
 
void i2c_getSixRawADC (uint8_t add, uint8_t reg)
 
void i2c_writeReg (uint8_t add, uint8_t reg, uint8_t val)
 
uint8_t i2c_readReg (uint8_t add, uint8_t reg)
 
void GYRO_Common ()
 
void ACC_Common ()
 
void i2c_BME280_readCoefficients (void)
 
void i2c_BME280_setSampling (void)
 
void i2c_BME280_UT_Start (void)
 
void i2c_BME280_UT_Read ()
 
void i2c_BME280_UP_Start ()
 
void i2c_BME280_UP_Read ()
 
void i2c_BME280_Calculate ()
 
uint8_t Baro_update ()
 
void ACC_getADC ()
 
void Gyro_getADC ()
 
void Sonar_init ()
 
void Sonar_update ()
 
void initS ()
 
void initSensors ()
 

Macro Definition Documentation

#define ACC_DELIMITER   4
#define ACC_ORIENTATION (   X,
  Y,
  Z 
)    {imu.accADC[ROLL] = X; imu.accADC[PITCH] = Y; imu.accADC[YAW] = Z;}
#define BME280_ADDRESS   0x77
#define BME280_REGISTER_CONFIG   0xF5
#define BME280_REGISTER_CONTROL   0xF4
#define BME280_REGISTER_CONTROLHUMID   0xF2
#define BME280_REGISTER_DIG_H1   0xA1
#define BME280_REGISTER_DIG_H2   0xE1
#define BME280_REGISTER_DIG_H3   0xE3
#define BME280_REGISTER_DIG_H4   0xE4
#define BME280_REGISTER_DIG_H5   0xE5
#define BME280_REGISTER_DIG_H6   0xE7
#define BME280_REGISTER_DIG_P1   0x8E
#define BME280_REGISTER_DIG_P2   0x90
#define BME280_REGISTER_DIG_P3   0x92
#define BME280_REGISTER_DIG_P4   0x94
#define BME280_REGISTER_DIG_P5   0x96
#define BME280_REGISTER_DIG_P6   0x98
#define BME280_REGISTER_DIG_P7   0x9A
#define BME280_REGISTER_DIG_P8   0x9C
#define BME280_REGISTER_DIG_P9   0x9E
#define BME280_REGISTER_DIG_T1   0x88
#define BME280_REGISTER_DIG_T2   0x8A
#define BME280_REGISTER_DIG_T3   0x8C
#define BME280_REGISTER_PRESSUREDATA   0xF7
#define BME280_REGISTER_SOFTRESET   0xE0
#define BME280_REGISTER_STATUS   0XF3
#define BME280_REGISTER_TEMPDATA   0xFA
#define FILTER_OFF   0b000
#define GYRO_DLPF_CFG   0
#define GYRO_ORIENTATION (   X,
  Y,
  Z 
)    {imu.gyroADC[ROLL] = X; imu.gyroADC[PITCH] = Y; imu.gyroADC[YAW] = Z;}
#define LSM9DS0_ACCELRANGE_4G   (0b001 << 3)
#define LSM9DS0_ADDRESS_ACCELMAG   (0x1D)
#define LSM9DS0_ADDRESS_GYRO   (0x6B)
#define LSM9DS0_GYROSCALE_2000DPS   (0b10 << 4)
#define LSM9DS0_MAGGAIN_4GAUSS   (0b01 << 5)
#define LSM9DS0_REGISTER_CTRL_REG1_G   0x20
#define LSM9DS0_REGISTER_CTRL_REG1_XM   0x20
#define LSM9DS0_REGISTER_CTRL_REG2_XM   0x21
#define LSM9DS0_REGISTER_CTRL_REG4_G   0x23
#define LSM9DS0_REGISTER_CTRL_REG5_XM   0x24
#define LSM9DS0_REGISTER_CTRL_REG6_XM   0x25
#define LSM9DS0_REGISTER_CTRL_REG7_XM   0x26
#define LSM9DS0_REGISTER_OUT_X_L_A   0x28
#define LSM9DS0_REGISTER_OUT_X_L_G   0x28
#define LSM9DS0_REGISTER_OUT_X_L_M   0x08
#define MAG_ORIENTATION (   X,
  Y,
  Z 
)    {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = Z;}
#define MODE_NORMAL   0b11
#define SAMPLING_X16   0b101
#define STANDBY_MS_0_5   0b000

Function Documentation

void __attribute__ ( (noinline)  )
void ACC_Common ( )
void ACC_getADC ( )
uint8_t Baro_update ( )
void GYRO_Common ( )
void Gyro_getADC ( )
void i2c_BME280_Calculate ( )
void i2c_BME280_readCoefficients ( void  )
void i2c_BME280_setSampling ( void  )
void i2c_BME280_UP_Read ( )
void i2c_BME280_UP_Start ( )
void i2c_BME280_UT_Read ( )
void i2c_BME280_UT_Start ( void  )
void i2c_getSixRawADC ( uint8_t  add,
uint8_t  reg 
)
void i2c_init ( void  )
void i2c_read_reg_to_buf ( uint8_t  add,
uint8_t  reg,
uint8_t *  buf,
uint8_t  size 
)
uint8_t i2c_readAck ( )
uint8_t i2c_readNak ( )
uint8_t i2c_readReg ( uint8_t  add,
uint8_t  reg 
)
void i2c_rep_start ( uint8_t  address)
void i2c_stop ( void  )
void i2c_write ( uint8_t  data)
void i2c_writeReg ( uint8_t  add,
uint8_t  reg,
uint8_t  val 
)
void initS ( )
void initSensors ( )
void Sonar_init ( )
inline
void Sonar_update ( )

Variable Documentation

uint32_t deadline
uint8_t dig_H1
int16_t dig_H2
uint8_t dig_H3
int16_t dig_H4
int16_t dig_H5
int8_t dig_H6
uint16_t dig_P1
int16_t dig_P2
int16_t dig_P3
int16_t dig_P4
int16_t dig_P5
int16_t dig_P6
int16_t dig_P7
int16_t dig_P8
int16_t dig_P9
uint16_t dig_T1
int16_t dig_T2
int16_t dig_T3
int8_t raw[4]
uint8_t state
union { ... } up
union { ... } ut
int32_t val