STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
main.cpp File Reference
#include <Arduino.h>
#include <Wire.h>
Include dependency graph for main.cpp:

Go to the source code of this file.

Macros

#define SDA_PIN   4
#define SCL_PIN   5
#define AS5600_ADDR   0x36
#define REG_ZMCO   0x00
#define REG_CONF_HI   0x07
#define REG_CONF_LO   0x08
#define REG_STATUS   0x0B
#define REG_RAW_MSB   0x0C
#define REG_RAW_LSB   0x0D
#define REG_AGC   0x1A
#define REG_MAG_HI   0x1B
#define REG_MAG_LO   0x1C
#define STATUS_MH   0x08
#define STATUS_ML   0x10
#define STATUS_MD   0x20
#define READ_ERROR   0xFFFF

Functions

bool i2cReadBytes (uint8_t reg, uint8_t *buf, uint8_t len)
bool as5600Ping ()
void dumpDiagnostics ()
uint16_t readRawAngle ()
float rawToDegrees (uint16_t raw)
bool checkMagnetPresence ()
void correctAngle ()
void setup ()
void loop ()

Variables

float startAngle = 0.0f
float degAngle = 0.0f
float correctedAngle = 0.0f
bool sensorOk = false

Macro Definition Documentation

◆ AS5600_ADDR

#define AS5600_ADDR   0x36

Definition at line 9 of file main.cpp.

Referenced by as5600Ping(), i2cReadBytes(), and i2cReadBytes().

◆ READ_ERROR

#define READ_ERROR   0xFFFF

Definition at line 23 of file main.cpp.

Referenced by loop(), readRawAngle(), readRawAngle(), and setup().

◆ REG_AGC

#define REG_AGC   0x1A

Definition at line 16 of file main.cpp.

Referenced by dumpDiagnostics().

◆ REG_CONF_HI

#define REG_CONF_HI   0x07

Definition at line 11 of file main.cpp.

Referenced by dumpDiagnostics().

◆ REG_CONF_LO

#define REG_CONF_LO   0x08

Definition at line 12 of file main.cpp.

◆ REG_MAG_HI

#define REG_MAG_HI   0x1B

Definition at line 17 of file main.cpp.

Referenced by dumpDiagnostics().

◆ REG_MAG_LO

#define REG_MAG_LO   0x1C

Definition at line 18 of file main.cpp.

◆ REG_RAW_LSB

#define REG_RAW_LSB   0x0D

Definition at line 15 of file main.cpp.

◆ REG_RAW_MSB

#define REG_RAW_MSB   0x0C

Definition at line 14 of file main.cpp.

Referenced by dumpDiagnostics(), readRawAngle(), and readRawAngle().

◆ REG_STATUS

#define REG_STATUS   0x0B

◆ REG_ZMCO

#define REG_ZMCO   0x00

Definition at line 10 of file main.cpp.

Referenced by dumpDiagnostics().

◆ SCL_PIN

#define SCL_PIN   5

Definition at line 6 of file main.cpp.

Referenced by setup().

◆ SDA_PIN

#define SDA_PIN   4

Definition at line 5 of file main.cpp.

Referenced by setup().

◆ STATUS_MD

#define STATUS_MD   0x20

Definition at line 22 of file main.cpp.

Referenced by checkMagnetPresence(), checkMagnetPresence(), and dumpDiagnostics().

◆ STATUS_MH

#define STATUS_MH   0x08

Definition at line 20 of file main.cpp.

Referenced by checkMagnetPresence(), checkMagnetPresence(), and dumpDiagnostics().

◆ STATUS_ML

#define STATUS_ML   0x10

Definition at line 21 of file main.cpp.

Referenced by checkMagnetPresence(), checkMagnetPresence(), and dumpDiagnostics().

Function Documentation

◆ as5600Ping()

bool as5600Ping ( )

Definition at line 45 of file main.cpp.

References AS5600_ADDR.

Referenced by loop(), and setup().

◆ checkMagnetPresence()

bool checkMagnetPresence ( )

Definition at line 120 of file main.cpp.

References delay(), i2cReadBytes(), millis(), REG_STATUS, Serial, start(), STATUS_MD, STATUS_MH, and STATUS_ML.

Referenced by loop(), and setup().

◆ correctAngle()

void correctAngle ( )

Definition at line 149 of file main.cpp.

References correctedAngle, degAngle, and startAngle.

Referenced by loop().

◆ dumpDiagnostics()

void dumpDiagnostics ( )

Definition at line 50 of file main.cpp.

References i2cReadBytes(), REG_AGC, REG_CONF_HI, REG_MAG_HI, REG_RAW_MSB, REG_STATUS, REG_ZMCO, Serial, STATUS_MD, STATUS_MH, and STATUS_ML.

Referenced by loop(), and setup().

◆ i2cReadBytes()

bool i2cReadBytes ( uint8_t reg,
uint8_t * buf,
uint8_t len )

◆ loop()

◆ rawToDegrees()

float rawToDegrees ( uint16_t raw)

Definition at line 116 of file main.cpp.

Referenced by loop(), and setup().

◆ readRawAngle()

uint16_t readRawAngle ( )

Definition at line 109 of file main.cpp.

References i2cReadBytes(), READ_ERROR, and REG_RAW_MSB.

Referenced by loop(), and setup().

◆ setup()

Variable Documentation

◆ correctedAngle

float correctedAngle = 0.0f

Definition at line 27 of file main.cpp.

Referenced by correctAngle(), and loop().

◆ degAngle

float degAngle = 0.0f

Definition at line 26 of file main.cpp.

Referenced by correctAngle(), and loop().

◆ sensorOk

bool sensorOk = false

Definition at line 28 of file main.cpp.

Referenced by loop(), and setup().

◆ startAngle

float startAngle = 0.0f

Definition at line 25 of file main.cpp.

Referenced by correctAngle(), and setup().