基本信息
源码名称:HMC5883L范例
源码大小:0.07M
文件格式:.zip
开发语言:C/C++
更新时间:2020-11-02
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 4 元×
微信扫码支付:4 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
/*
******************************************************************************
* @file : main.c
* @Copyright: ViewTool
* @Revision : ver 1.0
* @Date : 2014/12/19 11:14
* @brief : MPU6050 demo
******************************************************************************
* @attention
*
* Copyright 2009-2014, ViewTool
* http://www.viewtool.com/
* All Rights Reserved
*
******************************************************************************
*/
#include <stdio.h>
#include "HMC5883L.h"
#include "ControlI2C.h"
int main(void)
{
enum Status status;
status = HMC5883L_Init();
if(status != SUCCESS){
printf("Initialize HMC5883L failed!\n");
return 0;
}
// if config failed, please step into this function, give each function call a short delay time, it will work.
status = HMC5883L_Config();
if(status != SUCCESS){
printf("Config HMC5883L failed!\n");
return 0;
}
while (1)
{
int16_t XMagnetic, YMagnetic, ZMagnetic;
//Get data
status = HMC5883L_ReadMagnetic(&XMagnetic, &YMagnetic, &ZMagnetic);
if(status != SUCCESS){
printf("Get Magnetic failed!\n");
return 0;
}
//Display data
// system("cls");
printf("XMagnetic= %d\n" , XMagnetic);
printf("YMagnetic= %d\n" , YMagnetic);
printf("ZMagnetic= %d\n" , ZMagnetic);
Sleep(100);
}
return 0;
}