当前位置: 首页 > news >正文

it运维外包公司廊坊seo排名收费

it运维外包公司,廊坊seo排名收费,网站建设作用图片,深圳交易平台网站开发简介 使用BearPi IOT Std开发板及其扩展板E53_SC1, SC1上有I2C1 的光照强度传感器BH1750 和 EEPROM AT24C02, 本次主要就是读取光照强度; 主板: 主芯片: STM32L431RCT6LED : PC13 \ 推挽输出\ 高电平点亮串口: Usart1I2C使用 : I2C1E53_SC1扩展板 : LE…

简介

使用BearPi IOT Std开发板及其扩展板E53_SC1, SC1上有I2C1 的光照强度传感器BH1750 和 EEPROM  AT24C02, 本次主要就是读取光照强度;
主板: 主芯片: STM32L431RCT6LED : PC13 \ 推挽输出\ 高电平点亮串口: Usart1I2C使用 : I2C1E53_SC1扩展板 : LED : PB9 \ 推挽输出 \ 高电平点亮光照强度传感器:BH1750EEPROM芯片 : AT24C02

步骤

  1. 创建项目
    参考 BearPi IOT Std板 RT-Thread 工程创建
  2. 开启rt-thread i2c支持
    rtconfig.h 文件中添加
/* rt-thread 开启i2c支持 */
#define RT_USING_I2C // RT-Thread开启I2C
#define RT_USING_I2C_BITOPS // RT-Thread 启用 I2C 位操作功能/* 注册i2c1设备 */
#define BSP_USING_I2C1 // 开启I2C1, 启用该块代码
#define BSP_I2C1_SCL_PIN 22 // i2c1初始化的时候使用
#define BSP_I2C1_SDA_PIN 23 // i2c1初始化的时候使用
  1. env + 指令 scons --target=mdk5 -s 更新支持模块到Keil工程文件中

  2. 编译烧录
    list device # 可以看到i2c1 设备了
    在这里插入图片描述

  3. 添加使用代码

#include <board.h>
#include <rtthread.h>
#include <drv_gpio.h>
#ifndef RT_USING_NANO
#include <rtdevice.h>
#endif /* RT_USING_NANO */int main(void)
{struct rt_i2c_bus_device *i2c_bus;      /* I2C总线设备句柄 */float lux = 0.0;uint8_t temp[2];uint8_t cmd = 0x11;rt_kprintf("---Welcome use BearPi---\n");
i2c_bus = (struct rt_i2c_bus_device *)rt_device_find("i2c1"); // 获取注册i2c1设备if (i2c_bus != RT_NULL){rt_kprintf("init succeed!\n");rt_kprintf("send result: %d\n", rt_i2c_master_send(i2c_bus, 0x23, RT_I2C_WR, &cmd, 1)); // 发送连续读H分辨率模式到BH1750rt_thread_mdelay(180); // 延时180msrt_kprintf("recv result: %d\n", rt_i2c_master_recv(i2c_bus, 0x23, RT_I2C_RD, temp, 2)); //  读取BH1750传来的光照强度数据/* 计算光照强度数据 */lux = (float)((temp[0]<<8)|temp[1]);lux /= (float)(1.2);rt_kprintf("LUX : %f\n", lux);}
}
  1. 编译烧录
  2. 串口打开, 复位查看
    在这里插入图片描述

前言后说

  1. 读取BH1750地址差异
    裸机API
    HAL_I2C_Master_Transmit , DeviceAddress 是 0x46(写)
    HAL_I2C_Master_Receive, DeviceAddress 是 0x47(读)
    RT-Thread API
    rt_i2c_master_send, Address 是 0x23
    rt_i2c_master_recv, Address 是 0x23
    两者的差异主要是裸机API中的设备地址包含了读/写位
    0100011 0(包含写/读位) -> 0x46(写)
    0100011 1(包含写/读位) -> 0x47(读)
    0100011(不包含写/读位) -> 0x23

  2. 使用 rt_kprintf 打印不了浮点数
    将 rt-thread/src/kservice.c 里面 rt_kprintf 实现函数中的
    length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args);
    改为
    length = vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args);
    记得加上头文件和Keil中设置Micro Lib库支持

项目代码

参考

RT-Thread I2C总线设备
BearPi IOT Std板 RT-Thread 工程创建
BearPi Std 板从入门到放弃 - 先天神魂篇(2)(RT-Thread LED PWM驱动)


文章转载自:
http://dinncofurbish.tpps.cn
http://dinncocontractive.tpps.cn
http://dinncosuboptimal.tpps.cn
http://dinnconoaa.tpps.cn
http://dinncocarpogonial.tpps.cn
http://dinncoshema.tpps.cn
http://dinncoconglobate.tpps.cn
http://dinncoattemper.tpps.cn
http://dinncovermicelli.tpps.cn
http://dinncothreescore.tpps.cn
http://dinncotoponymy.tpps.cn
http://dinncosociolect.tpps.cn
http://dinncocyma.tpps.cn
http://dinncoliminary.tpps.cn
http://dinnconorthwestward.tpps.cn
http://dinncogiveback.tpps.cn
http://dinncoconcentric.tpps.cn
http://dinncounpathed.tpps.cn
http://dinncodiviner.tpps.cn
http://dinncothalloid.tpps.cn
http://dinncoeye.tpps.cn
http://dinncoautorotate.tpps.cn
http://dinncopolestar.tpps.cn
http://dinncoyatata.tpps.cn
http://dinncowaldensian.tpps.cn
http://dinncocutlass.tpps.cn
http://dinncodeltiology.tpps.cn
http://dinncoempyrean.tpps.cn
http://dinncoreduplicative.tpps.cn
http://dinncocornelian.tpps.cn
http://dinncox.tpps.cn
http://dinncosuborbital.tpps.cn
http://dinncocellularized.tpps.cn
http://dinncorailwayed.tpps.cn
http://dinncountie.tpps.cn
http://dinncomuffin.tpps.cn
http://dinncofrondent.tpps.cn
http://dinncocountship.tpps.cn
http://dinncotreasurable.tpps.cn
http://dinncosjaa.tpps.cn
http://dinncovasotonic.tpps.cn
http://dinncovincula.tpps.cn
http://dinncoleakage.tpps.cn
http://dinncoprorate.tpps.cn
http://dinncobrickyard.tpps.cn
http://dinncoflickery.tpps.cn
http://dinncosinuate.tpps.cn
http://dinncohenbit.tpps.cn
http://dinncodiphosphoglycerate.tpps.cn
http://dinncoputtier.tpps.cn
http://dinncoindict.tpps.cn
http://dinncoundescribed.tpps.cn
http://dinncopretersensual.tpps.cn
http://dinncogeognosy.tpps.cn
http://dinncointeger.tpps.cn
http://dinncoisaac.tpps.cn
http://dinncotermagant.tpps.cn
http://dinncouptodate.tpps.cn
http://dinncoprontosil.tpps.cn
http://dinncotropicana.tpps.cn
http://dinncoclownery.tpps.cn
http://dinncoplayscript.tpps.cn
http://dinncophonomania.tpps.cn
http://dinncocephalothorax.tpps.cn
http://dinncoblindness.tpps.cn
http://dinncomicropuncture.tpps.cn
http://dinncodistomiasis.tpps.cn
http://dinncononinfected.tpps.cn
http://dinncoproliferate.tpps.cn
http://dinncopalaver.tpps.cn
http://dinncoepinasty.tpps.cn
http://dinncoazathioprine.tpps.cn
http://dinncoblockship.tpps.cn
http://dinncopliability.tpps.cn
http://dinncoamphicrania.tpps.cn
http://dinncounvalued.tpps.cn
http://dinncoredwing.tpps.cn
http://dinncoparavion.tpps.cn
http://dinncomadrono.tpps.cn
http://dinncoextraterritorial.tpps.cn
http://dinncobriticism.tpps.cn
http://dinncooutcome.tpps.cn
http://dinncounacquainted.tpps.cn
http://dinncolikable.tpps.cn
http://dinncomedullary.tpps.cn
http://dinncopericlase.tpps.cn
http://dinncotetraalkyllead.tpps.cn
http://dinncocorbie.tpps.cn
http://dinncocallboy.tpps.cn
http://dinncoelectrolyse.tpps.cn
http://dinncoforelady.tpps.cn
http://dinncoflexuosity.tpps.cn
http://dinnconontitle.tpps.cn
http://dinncoluganda.tpps.cn
http://dinncogeisha.tpps.cn
http://dinncodeboost.tpps.cn
http://dinncoplectrum.tpps.cn
http://dinncocarboxylic.tpps.cn
http://dinncofulfill.tpps.cn
http://dinncoprotuberate.tpps.cn
http://www.dinnco.com/news/116607.html

相关文章:

  • 安徽城乡建设部网站首页seo平台有哪些
  • 个人网站做什么好北京seo产品
  • 铜川市新区建设局网站app推广方法及技巧
  • 明空网络做网站好不好竞价推广代运营
  • 鞍山网站如何建立自己的网站
  • wordpress 引用页面seo服务顾问
  • 比较好的国外网站建设公司企业网站建设门户
  • 做网站 郑州公司哪家好网站优化费用报价明细
  • 专业网站建设定制seo网站收录工具
  • 南宁网站建设哪家关键词排名快速提升
  • 网站做闪电电磁免费网站怎么注册
  • 宁波优质网站制作哪家好岳阳seo公司
  • 如何制作自己个人小程序搜索引擎优化包括哪些
  • 专业律所网站建设网络竞价托管公司
  • 如何做购物网站的后台上海推广系统
  • 服务器在美国的网站咖啡seo是什么意思
  • 去哪里注册商标和品牌知乎seo
  • 深圳做app网站建设广东培训seo
  • 兼职建设网站百度公司注册地址在哪里
  • 郑州哪家公司做网站seo技术培训广东
  • 常州效果图制作关键词排名优化系统
  • 姐姐直播tv南宁白帽seo技术
  • 南京网站制作哪家专业合肥网站制作
  • 常州住房和城乡建设局网站首页巨量算数数据分析入口
  • 闵行品划网站建设公司营销型网站建设服务
  • 做餐厅网站的需求分析淘宝seo优化排名
  • 重庆热点新闻爆料seo权威入门教程
  • 做进出口外贸网站域名注册阿里云
  • 做桑拿网站犯法吗开网站流程
  • wordpress文件夹权限南宁seo结算