STM32F10x library
Functions | Variables
hmc5883l.c File Reference

Honeywell HMC5883L 3-Axis digital compass functions. More...

#include "stm32f10x.h"
#include "i2c.h"
#include "hmc5883l.h"
#include <math.h>

Functions

uint8_t hmc_init (uint8_t cra, uint8_t crb, uint8_t mode)
 Init HMC5883L. More...
 
uint8_t hmc_read (int16_t *x, int16_t *y, int16_t *z)
 Read acc. values. More...
 
float hmc_heading (int16_t x, int16_t y)
 Convert x,y to heading. More...
 
uint8_t hmc_present (void)
 Check for HMC5883L presence on I2C. More...
 

Variables

const uint8_t HMC_I2C_ADDR = 0x3c
 
uint8_t hmcDev = 1
 

Detailed Description

Honeywell HMC5883L 3-Axis digital compass functions.

Author
Matej Kogovsek (matej.nosp@m.@ham.nosp@m.radio.nosp@m..si)
Note
This file is part of mat-stm32f1-lib
Warning
Not thoroughly tested.

Function Documentation

float hmc_heading ( int16_t  x,
int16_t  y 
)

Convert x,y to heading.

Parameters
[in]xx from HMC
[in]yy from HMC
Returns
Heading
uint8_t hmc_init ( uint8_t  cra,
uint8_t  crb,
uint8_t  mode 
)

Init HMC5883L.

Parameters
[in]craControl register A
[in]crbControl register B
[in]modeMode
Returns
Same as i2c_wr
uint8_t hmc_present ( void  )

Check for HMC5883L presence on I2C.

Returns
True on present, false otherwise
uint8_t hmc_read ( int16_t *  x,
int16_t *  y,
int16_t *  z 
)

Read acc. values.

Parameters
[out]xPointer to x
[out]yPointer to y
[out]zPointer to z
Returns
True on success, false otherwise

Variable Documentation

const uint8_t HMC_I2C_ADDR = 0x3c

HMC5883L I2C address

uint8_t hmcDev = 1

I2C peripheral number to use