91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

STM32單片機通過IIC通信方式讀取兩個JY-901模塊的數據,代碼可用,注釋清晰方便學習

資源截圖

代碼片段和文件信息

/*
編寫者:Kevin
網址:http://RobotControl.taobao.com
作者E-mail:1609370741@qq.com
編譯環境:MDK-Lite??Version:?5.17
初版時間:?2016-1-31
測試:?本程序已在【君悅智控】的STM32Core平臺上完成測試
功能:
用STM32Core平臺IIC接口讀取JY901的數據,然后通過串口1打印到串口助手。
接線
USB-TTL工具?????????????????STM32Core??????????????JY901
VCC??????????-----???????????VCC????????----????????VCC
TX???????????-----???????????RX1?????
RX???????????-----???????????TX1
GND??????????-----???????????GND????????----????????GND
?????????????????????????????SDA2???????----????????SDA
?SCL2???????----????????SCL
------------------------------------
?*/
#include?
#include?
#include?“Main.h“
#include?“REG.h“
#include?“stm32f10x_rcc.h“
#include?“stm32f10x_gpio.h“
#include?“UART1.h“
#include?“delay.h“
#include?“IOI2C.h“
#include?“hw_config.h“

void?ShortToChar(short?sDataunsigned?char?cData[])
{
cData[0]=sData&0xff;
cData[1]=sData>>8;
}
short?CharToShort(unsigned?char?cData[])
{
return?((short)cData[1]<<8)|cData[0];
}

int?main(void)
{??
??unsigned?char?chrTemp[30];
unsigned?char?str[100];
float?a[3]w[3]h[3]Angle[3];

USB_Config();
SysTick_init(7210);
Initial_UART1(115200);
IIC_Init();

while?(1)
{
delay_ms(100);
IICreadBytes(0x50?AX?24&chrTemp[0]);
a[0]?=?(float)CharToShort(&chrTemp[0])/32768*16;
a[1]?=?(float)CharToShort(&chrTemp[2])/32768*16;
a[2]?=?(float)CharToShort(&chrTemp[4])/32768*16;
w[0]?=?(float)CharToShort(&chrTemp[6])/32768*2000;
w[1]?=?(float)CharToShort(&chrTemp[8])/32768*2000;
w[2]?=?(float)CharToShort(&chrTemp[10])/32768*2000;
h[0]?=?CharToShort(&chrTemp[12]);
h[1]?=?CharToShort(&chrTemp[14]);
h[2]?=?CharToShort(&chrTemp[16]);
Angle[0]?=?(float)CharToShort(&chrTemp[18])/32768*180;
Angle[1]?=?(float)CharToShort(&chrTemp[20])/32768*180;
Angle[2]?=?(float)CharToShort(&chrTemp[22])/32768*180;

sprintf((char*)str“0x50:??a:%.3f?%.3f?%.3f?w:%.3f?%.3f?%.3f??h:%.0f?%.0f?%.0f??Angle:%.3f?%.3f?%.3f?\r\n“a[0]a[1]a[2]w[0]w[1]w[2]h[0]h[1]h[2]Angle[0]Angle[1]Angle[2]);
UART1_Put_String(str);
USB_TxWrite(str?strlen((char*)str));


IICreadBytes(0x51?AX?24&chrTemp[0]);
a[0]?=?(float)CharToShort(&chrTemp[0])/32768*16;
a[1]?=?(float)CharToShort(&chrTemp[2])/32768*16;
a[2]?=?(float)CharToShort(&chrTemp[4])/32768*16;
w[0]?=?(float)CharToShort(&chrTemp[6])/32768*2000;
w[1]?=?(float)CharToShort(&chrTemp[8])/32768*2000;
w[2]?=?(float)CharToShort(&chrTemp[10])/32768*2000;
h[0]?=?CharToShort(&chrTemp[12]);
h[1]?=?CharToShort(&chrTemp[14]);
h[2]?=?CharToShort(&chrTemp[16]);
Angle[0]?=?(float)CharToShort(&chrTemp[18])/32768*180;
Angle[1]?=?(float)CharToShort(&chrTemp[20])/32768*180;
Angle[2]?=?(float)CharToShort(&chrTemp[22])/32768*180;

sprintf((char*)str“0x51:??a:%.3f?%.3f?%.3f?w:%.3f?%.3f?%.3f??h:%.0f?%.0f?%.0f??Angle:%.3f?%.3f?%.3f?\r\n“a[0]a[1]a[2]w[0]w[1]w[2]h[0]h[1]h[2]Angle[0]Angle[1]Angle[2]);
UART1_Put_String

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????836??2014-11-26?23:17??STM32Core?IIC讀取兩個模塊\DOC\Note.h

?????文件?????181137??2016-08-13?11:46??STM32Core?IIC讀取兩個模塊\MDK\JlinkLog.txt

?????文件????????671??2015-12-22?12:51??STM32Core?IIC讀取兩個模塊\MDK\JlinkSettings.ini

?????文件?????185336??2016-08-13?11:45??STM32Core?IIC讀取兩個模塊\MDK\List\Project.map

?????文件??????55946??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\List\startup_stm32f10x_hd.lst

?????文件?????236329??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\delay.crf

?????文件????????659??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\delay.d

?????文件?????261896??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\delay.o

?????文件?????286980??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\hw_config.crf

?????文件???????1812??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\hw_config.d

?????文件?????335876??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\hw_config.o

?????文件?????254088??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\ioi2c.crf

?????文件????????768??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\ioi2c.d

?????文件?????288348??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\ioi2c.o

?????文件?????274770??2016-08-13?11:45??STM32Core?IIC讀取兩個模塊\MDK\Obj\main.crf

?????文件???????1393??2016-08-13?11:45??STM32Core?IIC讀取兩個模塊\MDK\Obj\main.d

?????文件?????304460??2016-08-13?11:45??STM32Core?IIC讀取兩個模塊\MDK\Obj\main.o

?????文件?????235781??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\misc.crf

?????文件????????619??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\misc.d

?????文件?????259456??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\misc.o

?????文件?????443084??2016-08-13?11:45??STM32Core?IIC讀取兩個模塊\MDK\Obj\Project.axf

?????文件???????1961??2016-08-13?11:45??STM32Core?IIC讀取兩個模塊\MDK\Obj\Project.build_log.htm

?????文件??????47563??2016-08-13?11:45??STM32Core?IIC讀取兩個模塊\MDK\Obj\Project.hex

?????文件??????87294??2016-08-13?11:45??STM32Core?IIC讀取兩個模塊\MDK\Obj\Project.htm

?????文件???????1148??2016-08-13?11:45??STM32Core?IIC讀取兩個模塊\MDK\Obj\Project.lnp

?????文件????????479??2016-01-31?14:25??STM32Core?IIC讀取兩個模塊\MDK\Obj\Project.sct

?????文件??????64258??2016-08-13?11:45??STM32Core?IIC讀取兩個模塊\MDK\Obj\Project_Project.dep

?????文件??????16102??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\queue.crf

?????文件????????245??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\queue.d

?????文件??????35364??2016-08-13?11:35??STM32Core?IIC讀取兩個模塊\MDK\Obj\queue.o

............此處省略234個文件信息

評論

共有 條評論