Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
NXP 微控制器
【FRDM-MCXA156测评】- P3T1755模块
发布于 2025-02-26 10:24:35 浏览:18
订阅该版
[tocm] # 【FRDM-MCXA156测评】- P3T1755模块 # 前言 在测试i2c的过程中,发现用逻辑分析仪测出来的地址跟实际上的地址不一致,排查了一下原因,在i2c对接的时候,nxp的库中i2c的地址只是7bit,所以对接的时候需要把i2c的地址<<一位。 # 配置过程 ## 使能板载模块  ## 配置i2c引脚 ~~~c /* LPI2C0 peripheral is released from reset */ RESET_ReleasePeripheralReset(kLPI2C0_RST_SHIFT_RSTn); const port_pin_config_t port0_16_pin83_config = {/* Internal pull-up resistor is enabled */ .pullSelect = kPORT_PullUp, /* Low internal pull resistor value is selected. */ .pullValueSelect = kPORT_LowPullResistor, /* Fast slew rate is configured */ .slewRate = kPORT_FastSlewRate, /* Passive input filter is disabled */ .passiveFilterEnable = kPORT_PassiveFilterDisable, /* Open drain output is disabled */ .openDrainEnable = kPORT_OpenDrainDisable, /* Low drive strength is configured */ .driveStrength = kPORT_LowDriveStrength, /* Normal drive strength is configured */ .driveStrength1 = kPORT_NormalDriveStrength, /* Pin is configured as LPI2C0_SDA */ .mux = kPORT_MuxAlt2, /* Digital input enabled */ .inputBuffer = kPORT_InputBufferEnable, /* Digital input is not inverted */ .invertInput = kPORT_InputNormal, /* Pin Control Register fields [15:0] are not locked */ .lockRegister = kPORT_UnlockRegister}; /* PORT0_16 (pin 83) is configured as LPI2C0_SDA */ PORT_SetPinConfig(PORT0, 16U, &port0_16_pin83_config); const port_pin_config_t port0_17_pin84_config = {/* Internal pull-up resistor is enabled */ .pullSelect = kPORT_PullUp, /* Low internal pull resistor value is selected. */ .pullValueSelect = kPORT_LowPullResistor, /* Fast slew rate is configured */ .slewRate = kPORT_FastSlewRate, /* Passive input filter is disabled */ .passiveFilterEnable = kPORT_PassiveFilterDisable, /* Open drain output is disabled */ .openDrainEnable = kPORT_OpenDrainDisable, /* Low drive strength is configured */ .driveStrength = kPORT_LowDriveStrength, /* Normal drive strength is configured */ .driveStrength1 = kPORT_NormalDriveStrength, /* Pin is configured as LPI2C0_SCL */ .mux = kPORT_MuxAlt2, /* Digital input enabled */ .inputBuffer = kPORT_InputBufferEnable, /* Digital input is not inverted */ .invertInput = kPORT_InputNormal, /* Pin Control Register fields [15:0] are not locked */ .lockRegister = kPORT_UnlockRegister}; /* PORT0_17 (pin 84) is configured as LPI2C0_SCL */ PORT_SetPinConfig(PORT0, 17U, &port0_17_pin84_config); ~~~ # 生成工程 ~~~c scons --target=mdk5 ~~~ # 示例代码 * 不使用sensor框架 ~~~c #include "P3T1755.h" static void p3t1755_test(int argc, char *argv[]) { p3t1755_init(); float temp = 0; if (p3t1755_read_temp(&temp) == RT_EOK) { rt_kprintf("temp:%.2f\n", temp); } } MSH_CMD_EXPORT(p3t1755_test, i2c p3t1755 sample); ~~~ * 使用sensor 框架 使能sensor框架  ~~~c #include "nxp_p3t1755_sensor_v2.h" static void p3t1755_sensor_test(void) { rt_device_t dev; struct rt_sensor_data data; struct rt_sensor_config config; rt_hw_p3t1755_init("p3t1755",&config); /* 查找传感器设备 */ dev = rt_device_find("tm-p3t1755"); /* 以只读及轮询模式打开传感器设备 */ rt_device_open(dev, RT_DEVICE_FLAG_RDONLY); if (rt_device_read(dev, 0, &data, 1) == 1) { rt_kprintf("temp: %.3f, timestamp:%5d\n", data.data.temp, data.timestamp); } rt_device_close(dev); } MSH_CMD_EXPORT(p3t1755_sensor_test, p3t1755 sensor test); ~~~ # 运行结果  使用sensor框架 
0
条评论
默认排序
按发布时间排序
登录
注册新账号
关于作者
CYFS
这家伙很懒,什么也没写!
文章
7
回答
3
被采纳
0
关注TA
发私信
相关文章
1
试贴-消灭0主题
2
LPC M4的一些资料
3
LPC4088的临时分支
4
lpc1788 ad 不稳定
5
1788 LCD控制器缓冲区字节问题
6
一起来学习LPC4088吧
7
上传LPC4088的realtouch主工程
8
RealBoard 4088预定帖 [第一批板子不多,预定提前结束]
9
晒RealBoard LPC4088开箱照啦,速带小板凳前来围观
10
4088主程序需要的SD卡资源
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
DMA
USB
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
rt-smart
FAL
I2C_IIC
UART
ESP8266
cubemx
WIZnet_W5500
ota在线升级
PWM
BSP
flash
freemodbus
packages_软件包
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
编译报错
socket
中断
Debug
rt_mq_消息队列_msg_queue
keil_MDK
ulog
SFUD
msh
C++_cpp
MicroPython
本月问答贡献
RTT_逍遥
10
个答案
3
次被采纳
xiaorui
3
个答案
3
次被采纳
踩姑娘的小蘑菇
6
个答案
2
次被采纳
winfeng
2
个答案
2
次被采纳
KunYi
9
个答案
1
次被采纳
本月文章贡献
catcatbing
3
篇文章
5
次点赞
lizimu
2
篇文章
9
次点赞
jinchanchan
2
篇文章
2
次点赞
alight
1
篇文章
5
次点赞
swet123
1
篇文章
4
次点赞
回到
顶部
发布
问题
投诉
建议
回到
底部