初始版本
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
# ---> uVision
|
||||
# git ignore file for Keil µVision Project
|
||||
|
||||
# µVision 5 and µVision 4 Project screen layout file
|
||||
*.uvguix.*
|
||||
*.uvgui.*
|
||||
|
||||
# Listing Files
|
||||
*.i
|
||||
*.lst
|
||||
*.m51
|
||||
*.m66
|
||||
*.map
|
||||
|
||||
# Object Files
|
||||
*.axf
|
||||
*.b[0-2][0-9]
|
||||
*.b3[0-1]
|
||||
*.bak
|
||||
*.build_log.htm
|
||||
*.crf
|
||||
*.d
|
||||
*.dep
|
||||
*.elf
|
||||
*.htm
|
||||
*.iex
|
||||
*.lnp
|
||||
*.o
|
||||
*.obj
|
||||
*.sbr
|
||||
|
||||
# Firmware Files
|
||||
*.bin
|
||||
*.h86
|
||||
*.hex
|
||||
|
||||
# Build Files
|
||||
.bat
|
||||
|
||||
# Debugger Files
|
||||
.ini
|
||||
|
||||
# JLink Files
|
||||
JLinkLog.txt
|
||||
|
||||
# Other Files
|
||||
|
||||
# ---> VisualStudioCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
# ---> IAR
|
||||
# Compiled binaries
|
||||
*.o
|
||||
*.bin
|
||||
*.elf
|
||||
*.hex
|
||||
*.map
|
||||
*.out
|
||||
*.obj
|
||||
|
||||
# Trash
|
||||
*.bak
|
||||
thumbs.db
|
||||
*.~*
|
||||
|
||||
# IAR Settings
|
||||
**/settings/*.crun
|
||||
**/settings/*.dbgdt
|
||||
**/settings/*.cspy
|
||||
**/settings/*.cspy.*
|
||||
**/settings/*.xcl
|
||||
**/settings/*.dni
|
||||
**/settings/*.wsdt
|
||||
**/settings/*.wspos
|
||||
|
||||
# IAR Debug Exe
|
||||
**/Exe/*.sim
|
||||
|
||||
# IAR Debug Obj
|
||||
**/Obj/*.pbd
|
||||
**/Obj/*.pbd.*
|
||||
**/Obj/*.pbi
|
||||
**/Obj/*.pbi.*
|
||||
|
||||
# IAR project "Debug" directory
|
||||
Debug/
|
||||
|
||||
# IAR project "Release" directory
|
||||
Release/
|
||||
|
||||
# IAR project settings directory
|
||||
settings/
|
||||
|
||||
# IAR backup files
|
||||
Backup*
|
||||
|
||||
# IAR .dep files
|
||||
*.dep
|
||||
# ---> IAR_EWARM
|
||||
# gitignore template for the IAR EWARM
|
||||
# website: https://www.iar.com/knowledge/support/technical-notes/ide/which-files-should-be-version-controlled/
|
||||
|
||||
# Some tools will put the EWARM files
|
||||
# under a subdirectory with the same name
|
||||
# as the configuration.
|
||||
# Example
|
||||
# EWARM/Config1/Obj /List /Exe
|
||||
# EWARM/Config2/Obj /List /Exe
|
||||
EWARM/**/Obj
|
||||
EWARM/**/List
|
||||
EWARM/**/Exe
|
||||
|
||||
# Autogenerated project files
|
||||
*.dep
|
||||
*.ewt
|
||||
|
||||
# Autogenerated folder for debugger
|
||||
EWARM/settings
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# MMC5983
|
||||
|
||||
MMC5983驱动代码
|
||||
@@ -0,0 +1,343 @@
|
||||
#include "main.h"
|
||||
#include "mmc5983.h"
|
||||
#include "UartDebug.h"
|
||||
#include "i2c.h"
|
||||
#include "Algorithm.h"
|
||||
|
||||
static int32_t max_in[XYZ];
|
||||
static int32_t min_in[XYZ];
|
||||
static bool InitFlag;
|
||||
static bool MMC5983IntFlag;
|
||||
static MMC5983Var_t MMC5983Var;
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: MMC5983_Write_Reg
|
||||
* 功能描述: MMC5983写寄存器
|
||||
* 参 数: reg 寄存器地址
|
||||
val 寄存器数据
|
||||
* 返 回 值: 成功返回true,失败返回false
|
||||
*****************************************************************************************/
|
||||
static bool MMC5983_Write_Reg(uint8_t reg, uint8_t val)
|
||||
{
|
||||
return I2C_MasterWriteData(M0P_I2C0, MMC5983_ADDRESS, reg, &val, 1);
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: MMC5983_Read_Reg
|
||||
* 功能描述: MMC5983读寄存器
|
||||
* 参 数: reg 寄存器地址
|
||||
* 返 回 值: 返回寄存器值
|
||||
*****************************************************************************************/
|
||||
static uint8_t MMC5983_Read_Reg(uint8_t reg)
|
||||
{
|
||||
uint8_t res;
|
||||
if(I2C_MasterReadData(M0P_I2C0, MMC5983_ADDRESS, reg, &res, 1) == false)
|
||||
res = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: MMC5983_Read_Buffer
|
||||
* 功能描述: MMC5983读数据
|
||||
* 参 数: reg 寄存器地址
|
||||
buffer 读取数据输出缓存入口
|
||||
len 读取长度
|
||||
* 返 回 值: 成功返回true,失败返回false
|
||||
*****************************************************************************************/
|
||||
static bool MMC5983_Read_Buffer(uint8_t reg, void *buffer, uint8_t len)
|
||||
{
|
||||
return I2C_MasterReadData(M0P_I2C0, MMC5983_ADDRESS, reg, buffer, len);
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: MMC5983StartCov
|
||||
* 功能描述: MMC5983开启连续转换
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void MMC5983StartCov(void)
|
||||
{
|
||||
MMC5983RegCtrl2 Ctrl2Reg; //开启/关闭连续转换
|
||||
Ctrl2Reg.Byte = 0x00;
|
||||
Ctrl2Reg.Bit.Cm_freq = 0x04;
|
||||
Ctrl2Reg.Bit.Cmm_en = 1; //连续设1,单次设0
|
||||
Ctrl2Reg.Bit.Prd_set = 3;
|
||||
Ctrl2Reg.Bit.En_prd_set = 1; //连续设1,单次设0
|
||||
MMC5983_Write_Reg(MMC5983_CTRL_2, Ctrl2Reg.Byte);
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: MMC5983_Init
|
||||
* 功能描述: MMC5983初始化
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void MMC5983_Init(void)
|
||||
{
|
||||
uint8_t id;
|
||||
|
||||
id = MMC5983_Read_Reg(MMC5983_ID);
|
||||
//DBG_LOG("MMC5983 id=0x%x\r\n",id);
|
||||
MMC5983Var.MMC5983Delay1mSCnt = 100;
|
||||
while(id != 0x30){
|
||||
if(MMC5983Var.MMC5983Delay1mSCnt <= 0) {
|
||||
DBG_LOG("LEFT MMC5983 INIT Err...\r\n");
|
||||
InitFlag = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MMC5983RegCtrl1 Ctrl1Reg;
|
||||
Ctrl1Reg.Byte = 0x00;
|
||||
Ctrl1Reg.Bit.SW_RST = 1;
|
||||
MMC5983_Write_Reg(MMC5983_CTRL_1, Ctrl1Reg.Byte);
|
||||
MMC5983Delay(15);
|
||||
|
||||
MMC5983RegCtrl2 Ctrl2Reg; //开启/关闭连续转换
|
||||
Ctrl2Reg.Byte = 0x00;
|
||||
Ctrl2Reg.Bit.Cm_freq = 0x04;
|
||||
Ctrl2Reg.Bit.Cmm_en = 0; //连续设1,单次设0
|
||||
Ctrl2Reg.Bit.Prd_set = 3;
|
||||
Ctrl2Reg.Bit.En_prd_set = 0; //连续设1,单次设0
|
||||
MMC5983_Write_Reg(MMC5983_CTRL_2, Ctrl2Reg.Byte);
|
||||
|
||||
MMC5983RegCtrl3 Ctrl3Reg;
|
||||
Ctrl3Reg.Byte = 0x00;
|
||||
Ctrl3Reg.Bit.St_enm = 1;
|
||||
Ctrl3Reg.Bit.St_enp = 1;
|
||||
MMC5983_Write_Reg(MMC5983_CTRL_3, Ctrl3Reg.Byte);
|
||||
|
||||
MMC5983RegCtrl0 Ctrl0Reg;
|
||||
Ctrl0Reg.Byte = 0x00;
|
||||
Ctrl0Reg.Bit.TM_M = 1;
|
||||
Ctrl0Reg.Bit.Auto_SR_en = 1;
|
||||
Ctrl0Reg.Bit.NT_meas_done_en = 1;
|
||||
MMC5983_Write_Reg(MMC5983_CTRL_0, Ctrl0Reg.Byte);
|
||||
|
||||
if(InitFlag == false){
|
||||
DBG_LOG("MMC5983 INIT OK...\r\n");
|
||||
InitFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: MMC5983_Read
|
||||
* 功能描述: MMC5983读取原始数据
|
||||
* 参 数: MagAdcX X轴数据
|
||||
MagAdcY Y轴数据
|
||||
MagAdcZ Z轴数据
|
||||
* 返 回 值: 成功返回true,失败返回false
|
||||
*****************************************************************************************/
|
||||
static bool MMC5983_Read(int32_t *MagAdcX, int32_t *MagAdcY, int32_t *MagAdcZ)
|
||||
{
|
||||
static uint8_t buff[7];
|
||||
|
||||
if (MMC5983_Read_Buffer(MMC5983_X_OUT_H, buff, 7) == false)
|
||||
return false;
|
||||
|
||||
*MagAdcX = (buff[0] << 10) | (buff[1] << 2) | ((buff[6] & 0xC0) >> 6);
|
||||
*MagAdcY = (buff[2] << 10) | (buff[3] << 2) | ((buff[6] & 0x30) >> 4);
|
||||
*MagAdcZ = (buff[4] << 10) | (buff[5] << 2) | ((buff[6] & 0x0C) >> 2);// Turn the 18 bits into unsigned 32-bit value
|
||||
return true;
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: MMC5983_Get_Mag
|
||||
* 功能描述: 外部获取MMC5983磁场强度数据
|
||||
* 参 数: mag 读取数据输出缓存入口
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void MMC5983_Get_Mag(float *mag)
|
||||
{
|
||||
if(mag == NULL)
|
||||
return;
|
||||
|
||||
float ADVal[XYZ];
|
||||
|
||||
ADVal[X] = MMC5983Var.Mag_Original[X] - 131072.0f;
|
||||
ADVal[Y] = MMC5983Var.Mag_Original[Y] - 131072.0f;
|
||||
ADVal[Z] = MMC5983Var.Mag_Original[Z] - 131072.0f;
|
||||
|
||||
mag[0] = (float) (ADVal[X] * MMC5983_MAG_SCALE_18BIT);
|
||||
mag[1] = (float) (ADVal[Y] * MMC5983_MAG_SCALE_18BIT);
|
||||
mag[2] = (float) (ADVal[Z] * MMC5983_MAG_SCALE_18BIT);
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: MMC5983LoopHandler
|
||||
* 功能描述: MMC5983循环处理函数
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
extern void MmcDataProcessCallBack(float *Mag);
|
||||
|
||||
void MMC5983LoopHandler(void)
|
||||
{
|
||||
static int32_t mag_array[XYZ][10];
|
||||
static uint8_t magcnt;
|
||||
static uint8_t TimeOutMagcnt;
|
||||
|
||||
switch(MMC5983Var.Status) {
|
||||
case MMC5983_STATUS_IDLE:{
|
||||
break;}
|
||||
|
||||
case MMC5983_STATUS_START:{
|
||||
for(int i = 0; i < 10; i++) {
|
||||
mag_array[X][i] = 0;
|
||||
mag_array[Y][i] = 0;
|
||||
mag_array[Z][i] = 0;
|
||||
}
|
||||
magcnt = 0;
|
||||
TimeOutMagcnt = 0;
|
||||
memset(&MMC5983Var, NULL, sizeof(MMC5983Var));
|
||||
MMC5983Var.Status = MMC5983_STATUS_DELAY;
|
||||
break;}
|
||||
|
||||
case MMC5983_STATUS_DELAY:{
|
||||
MMC5983StartRead();
|
||||
MMC5983Var.MMC5983Delay1mSCnt = 50;
|
||||
MMC5983Var.Status = MMC5983_STATUS_WAIT_DELAY;
|
||||
break;}
|
||||
|
||||
case MMC5983_STATUS_WAIT_DELAY:{
|
||||
if(MMC5983Var.MMC5983Delay1mSCnt <= 0){
|
||||
MMC5983Var.Status = MMC5983_STATUS_READ;
|
||||
}
|
||||
break;}
|
||||
|
||||
case MMC5983_STATUS_READ:{
|
||||
MMC5983Var.MMC5983Delay1mSCnt = 50;
|
||||
MMC5983Var.Status = MMC5983_STATUS_WAIT_READ;
|
||||
break;}
|
||||
|
||||
case MMC5983_STATUS_WAIT_READ:{
|
||||
if(MMC5983Var.MMC5983Delay1mSCnt <= 0){
|
||||
MMC5983Var.Status = MMC5983_STATUS_DELAY;
|
||||
TimeOutMagcnt++;
|
||||
}
|
||||
if(MMC5983IntFlag == true){
|
||||
MMC5983IntFlag = false;
|
||||
MMC5983_Read(&mag_array[X][magcnt], &mag_array[Y][magcnt], &mag_array[Z][magcnt]);
|
||||
magcnt++;
|
||||
MMC5983Var.Status = MMC5983_STATUS_DELAY;
|
||||
}
|
||||
if(TimeOutMagcnt >= 10){
|
||||
TimeOutMagcnt = 0;
|
||||
if(magcnt > 0){
|
||||
MMC5983Var.Mag_Original[X] = AverageFilter_32t(mag_array[X], magcnt);
|
||||
MMC5983Var.Mag_Original[Y] = AverageFilter_32t(mag_array[Y], magcnt);
|
||||
MMC5983Var.Mag_Original[Z] = AverageFilter_32t(mag_array[Z], magcnt);
|
||||
magcnt = 0;
|
||||
MMC5983_Get_Mag(MMC5983Var.Mag);
|
||||
MmcDataProcessCallBack(MMC5983Var.Mag);
|
||||
MMC5983Var.Status = MMC5983_STATUS_STOP;
|
||||
}
|
||||
else{
|
||||
MMC5983Var.Status = MMC5983_STATUS_STOP;
|
||||
// DBG_LOG("LEFT MMC5983 TimeOut...\r\n");
|
||||
}
|
||||
}
|
||||
if(magcnt >= 10){
|
||||
MMC5983Var.Mag_Original[X] = AverageFilter_32t(mag_array[X], magcnt);
|
||||
MMC5983Var.Mag_Original[Y] = AverageFilter_32t(mag_array[Y], magcnt);
|
||||
MMC5983Var.Mag_Original[Z] = AverageFilter_32t(mag_array[Z], magcnt);
|
||||
magcnt = 0;
|
||||
MMC5983_Get_Mag(MMC5983Var.Mag);
|
||||
MmcDataProcessCallBack(MMC5983Var.Mag);
|
||||
MMC5983Var.Status = MMC5983_STATUS_STOP;
|
||||
}
|
||||
break;}
|
||||
|
||||
case MMC5983_STATUS_STOP:{
|
||||
MMC5983Stop();
|
||||
MMC5983Var.Status = MMC5983_STATUS_IDLE;
|
||||
//MMC5983Var.Status = MMC5983_STATUS_START;//持续工作
|
||||
break;}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: LeftMMC59831mSRoutine
|
||||
* 功能描述: MMC59831ms时基循环处理函数
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void MMC59831mSRoutine(void)
|
||||
{
|
||||
if(MMC5983Var.MMC5983Delay1mSCnt > 0)
|
||||
MMC5983Var.MMC5983Delay1mSCnt--;
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: LeftMMC5983Init
|
||||
* 功能描述: MMC5983初始化
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void MMC5983Init(void)
|
||||
{
|
||||
if(!InitFlag){
|
||||
MMC5983_Init();
|
||||
return;
|
||||
}
|
||||
|
||||
MMC5983Var.Status = MMC5983_STATUS_START;
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: LeftMMC5983Start
|
||||
* 功能描述: MMC5983启动
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void MMC5983Start(void)
|
||||
{
|
||||
if(!InitFlag){
|
||||
MMC5983_Init();
|
||||
return;
|
||||
}
|
||||
|
||||
MMC5983Var.Status = MMC5983_STATUS_START;
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: LeftMMC5983StartRead
|
||||
* 功能描述: MMC5983启动读取
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void MMC5983StartRead(void)
|
||||
{
|
||||
MMC5983_Init();//读取时重新初始化
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: MMC5983Stop
|
||||
* 功能描述: MMC5983停止
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void MMC5983Stop(void)
|
||||
{
|
||||
MMC5983RegCtrl0 Ctrl0Reg;
|
||||
Ctrl0Reg.Byte = 0x00;
|
||||
MMC5983_Write_Reg(MMC5983_CTRL_0, Ctrl0Reg.Byte);
|
||||
|
||||
MMC5983RegStatus StatusReg;
|
||||
StatusReg.Byte = MMC5983_Read_Reg(MMC5983_STATUS);
|
||||
if(StatusReg.Bit.Meas_M_Done == 1){
|
||||
MMC5983_Write_Reg(MMC5983_STATUS, StatusReg.Byte);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* 函数名称: LeftMMC5983IntCallBack
|
||||
* 功能描述: MMC5983中断回调
|
||||
* 参 数: 无
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
void MMC5983IntCallBack(void)
|
||||
{
|
||||
MMC5983IntFlag = true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
*****************************************************************************
|
||||
* @file ak8975.h
|
||||
* @author WWJ
|
||||
* @version v1.0
|
||||
* @date 2019/04/09
|
||||
* @environment stm32f407
|
||||
* @brief
|
||||
*****************************************************************************
|
||||
**/
|
||||
|
||||
#ifndef _MMC5983_H
|
||||
#define _MMC5983_H
|
||||
#include "bsp.h"
|
||||
|
||||
#define X 0
|
||||
#define Y 1
|
||||
#define Z 2
|
||||
#define XYZ 3
|
||||
|
||||
#define MAX(A, B) (A > B) ? A : B;
|
||||
#define MIN(A, B) (A < B) ? A : B;
|
||||
|
||||
#define MMC5983_X_OUT_H 0X00 //Device ID = 0x48
|
||||
#define MMC5983_X_OUT_L 0X01
|
||||
#define MMC5983_Y_OUT_H 0X02
|
||||
#define MMC5983_Y_OUT_L 0X03
|
||||
#define MMC5983_Z_OUT_H 0X04
|
||||
#define MMC5983_Z_OUT_L 0X05
|
||||
#define MMC5983_XYZ_OUT 0X06
|
||||
#define MMC5983_TMP_OUT 0X07
|
||||
#define MMC5983_STATUS 0X08
|
||||
#define MMC5983_CTRL_0 0X09
|
||||
#define MMC5983_CTRL_1 0X0A
|
||||
#define MMC5983_CTRL_2 0X0B
|
||||
#define MMC5983_CTRL_3 0X0C
|
||||
#define MMC5983_ID 0X2F
|
||||
|
||||
#define MMC5983_ADDRESS 0x30
|
||||
#define MMC5983_MAG_SCALE_16BIT 0.24414f
|
||||
#define MMC5983_MAG_SCALE_18BIT 0.061035f
|
||||
|
||||
#define MMC5983Delay(x) delay_ms(x)
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t Meas_M_Done: 1;
|
||||
uint8_t Meas_T_Done: 1;
|
||||
uint8_t Res0: 2;
|
||||
uint8_t OTP_Read_Done: 1;
|
||||
uint8_t Res1: 3;
|
||||
}Bit;
|
||||
uint8_t Byte;
|
||||
}MMC5983RegStatus;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t TM_M: 1;
|
||||
uint8_t TM_T: 1;
|
||||
uint8_t NT_meas_done_en: 1;
|
||||
uint8_t Set: 1;
|
||||
uint8_t Reset: 1;
|
||||
uint8_t Auto_SR_en: 1;
|
||||
uint8_t OTP_Read: 1;
|
||||
uint8_t Res0: 1;
|
||||
}Bit;
|
||||
uint8_t Byte;
|
||||
}MMC5983RegCtrl0;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t BW: 2;
|
||||
uint8_t X_Inhibit: 1;
|
||||
uint8_t YZ_Inhibit: 2;
|
||||
uint8_t Res0: 2;
|
||||
uint8_t SW_RST: 1;
|
||||
}Bit;
|
||||
uint8_t Byte;
|
||||
}MMC5983RegCtrl1;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t Cm_freq: 3;
|
||||
uint8_t Cmm_en: 1;
|
||||
uint8_t Prd_set: 3;
|
||||
uint8_t En_prd_set: 1;
|
||||
}Bit;
|
||||
uint8_t Byte;
|
||||
}MMC5983RegCtrl2;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t Res0: 1;
|
||||
uint8_t St_enp: 1;
|
||||
uint8_t St_enm: 1;
|
||||
uint8_t Res1: 3;
|
||||
uint8_t Spi_3w: 1;
|
||||
uint8_t Res2: 1;
|
||||
}Bit;
|
||||
uint8_t Byte;
|
||||
}MMC5983RegCtrl3;
|
||||
|
||||
typedef enum{
|
||||
MMC5983_STATUS_IDLE,
|
||||
MMC5983_STATUS_START,
|
||||
MMC5983_STATUS_DELAY,
|
||||
MMC5983_STATUS_WAIT_DELAY,
|
||||
MMC5983_STATUS_READ,
|
||||
MMC5983_STATUS_WAIT_READ,
|
||||
MMC5983_STATUS_STOP,
|
||||
}MMC5983Status_m;
|
||||
|
||||
|
||||
typedef struct {
|
||||
MMC5983Status_m Status;
|
||||
uint16_t MMC5983Delay1mSCnt;
|
||||
float Mag[3];
|
||||
int32_t Mag_Original[XYZ];
|
||||
}MMC5983Var_t;
|
||||
|
||||
void MMC5983LoopHandler(void);
|
||||
void MMC59831mSRoutine(void);
|
||||
void MMC5983Init(void);
|
||||
void MMC5983Start(void);
|
||||
void MMC5983Stop(void);
|
||||
void MMC5983IntCallBack(void);
|
||||
|
||||
void MMC5983Calib(void);
|
||||
void MMC5983GetADValue(int32_t *Mag);
|
||||
void MMC5983_Get_Mag(float *mag);
|
||||
MMC5983Status_m GetMMC5983Status(void);
|
||||
void MMC5983StartRead(void);
|
||||
bool GetMMC5983CalibStatus(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* end of ak8975.h */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user