Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaobo07
rt-thread
提交
307671e2
R
rt-thread
项目概览
Xiaobo07
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
307671e2
编写于
2月 28, 2021
作者:
B
Bernard Xiong
提交者:
GitHub
2月 28, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4392 from Jackistang/master
[bsp/max32660] add the driver of i2c
上级
2bf53d31
8c7dd035
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
247 addition
and
4 deletion
+247
-4
bsp/maxim/MAX32660_EVSYS/.config
bsp/maxim/MAX32660_EVSYS/.config
+31
-2
bsp/maxim/MAX32660_EVSYS/README.md
bsp/maxim/MAX32660_EVSYS/README.md
+1
-1
bsp/maxim/MAX32660_EVSYS/board/Kconfig
bsp/maxim/MAX32660_EVSYS/board/Kconfig
+16
-0
bsp/maxim/MAX32660_EVSYS/rtconfig.h
bsp/maxim/MAX32660_EVSYS/rtconfig.h
+1
-1
bsp/maxim/libraries/HAL_Drivers/SConscript
bsp/maxim/libraries/HAL_Drivers/SConscript
+3
-0
bsp/maxim/libraries/HAL_Drivers/drv_i2c.c
bsp/maxim/libraries/HAL_Drivers/drv_i2c.c
+179
-0
bsp/maxim/libraries/HAL_Drivers/drv_i2c.h
bsp/maxim/libraries/HAL_Drivers/drv_i2c.h
+16
-0
未找到文件。
bsp/maxim/MAX32660_EVSYS/.config
浏览文件 @
307671e2
...
...
@@ -14,7 +14,7 @@ CONFIG_RT_ALIGN_SIZE=4
CONFIG_RT_THREAD_PRIORITY_32
=
y
# CONFIG_RT_THREAD_PRIORITY_256 is not set
CONFIG_RT_THREAD_PRIORITY_MAX
=
32
CONFIG_RT_TICK_PER_SECOND
=
100
CONFIG_RT_TICK_PER_SECOND
=
100
0
CONFIG_RT_USING_OVERFLOW_CHECK
=
y
CONFIG_RT_USING_HOOK
=
y
CONFIG_RT_USING_IDLE_HOOK
=
y
...
...
@@ -272,6 +272,7 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_PDULIB is not set
# CONFIG_PKG_USING_BTSTACK is not set
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
#
# security packages
...
...
@@ -300,6 +301,7 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_HELIX is not set
# CONFIG_PKG_USING_AZUREGUIX is not set
# CONFIG_PKG_USING_TOUCHGFX2RTT is not set
# CONFIG_PKG_USING_LVGL is not set
#
# tools packages
...
...
@@ -311,6 +313,8 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_RDB is not set
# CONFIG_PKG_USING_QRCODE is not set
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
# CONFIG_PKG_USING_ULOG_FILE is not set
# CONFIG_PKG_USING_LOGMGR is not set
# CONFIG_PKG_USING_ADBD is not set
# CONFIG_PKG_USING_COREMARK is not set
# CONFIG_PKG_USING_DHRYSTONE is not set
...
...
@@ -324,6 +328,16 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_UMCN is not set
# CONFIG_PKG_USING_LWRB2RTT is not set
# CONFIG_PKG_USING_CPU_USAGE is not set
# CONFIG_PKG_USING_GBK2UTF8 is not set
# CONFIG_PKG_USING_VCONSOLE is not set
# CONFIG_PKG_USING_KDB is not set
# CONFIG_PKG_USING_WAMR is not set
# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set
# CONFIG_PKG_USING_LWLOG is not set
# CONFIG_PKG_USING_ANV_TRACE is not set
# CONFIG_PKG_USING_ANV_MEMLEAK is not set
# CONFIG_PKG_USING_ANV_TESTSUIT is not set
# CONFIG_PKG_USING_ANV_BENCH is not set
#
# system packages
...
...
@@ -361,6 +375,13 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_UC_COMMON is not set
# CONFIG_PKG_USING_UC_MODBUS is not set
# CONFIG_PKG_USING_PPOOL is not set
# CONFIG_PKG_USING_OPENAMP is not set
# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set
# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
# CONFIG_PKG_USING_QFPLIB_M3 is not set
# CONFIG_PKG_USING_LPM is not set
#
# peripheral libraries and drivers
...
...
@@ -369,6 +390,7 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
# CONFIG_PKG_USING_SHT2X is not set
# CONFIG_PKG_USING_SHT3X is not set
# CONFIG_PKG_USING_AS7341 is not set
# CONFIG_PKG_USING_STM32_SDIO is not set
# CONFIG_PKG_USING_ICM20608 is not set
# CONFIG_PKG_USING_U8G2 is not set
...
...
@@ -418,7 +440,10 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_SSD1306 is not set
# CONFIG_PKG_USING_QKEY is not set
# CONFIG_PKG_USING_RS485 is not set
# CONFIG_PKG_USING_BSAL is not set
# CONFIG_PKG_USING_NES is not set
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
# CONFIG_PKG_USING_VDEVICE is not set
# CONFIG_PKG_USING_SGM706 is not set
#
# miscellaneous packages
...
...
@@ -468,6 +493,9 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_TETRIS is not set
# CONFIG_PKG_USING_LWGPS is not set
# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
# CONFIG_PKG_USING_STATE_MACHINE is not set
# CONFIG_PKG_USING_MCURSES is not set
# CONFIG_PKG_USING_COWSAY is not set
#
# Hardware Drivers Config
...
...
@@ -485,3 +513,4 @@ CONFIG_BSP_USING_UART1=y
# CONFIG_BSP_UART1_RX_USING_DMA is not set
# CONFIG_BSP_USING_SPI is not set
# CONFIG_BSP_USING_ON_CHIP_FLASH is not set
# CONFIG_BSP_USING_I2C is not set
bsp/maxim/MAX32660_EVSYS/README.md
浏览文件 @
307671e2
...
...
@@ -78,7 +78,7 @@ MAX32660-EVSYS开发板常用 **板载资源** 如下:
| SPI | 支持 | SPI0, SPI1 |
| RTC | | |
| I2S | | |
| I2C |
|
|
| I2C |
支持 | I2C0, I2C1
|
| TIMER | | |
| Watchdog | | |
...
...
bsp/maxim/MAX32660_EVSYS/board/Kconfig
浏览文件 @
307671e2
...
...
@@ -66,6 +66,22 @@ menu "On-chip Peripheral Drivers"
select PKG_USING_FAL
bool "Enable on-chip FLASH"
default n
config BSP_USING_I2C
bool "Enable I2C"
select RT_USING_I2C
default n
if BSP_USING_I2C
config BSP_USING_I2C0
bool "Enable I2C0 bus [SCL P0.8; SDA P0.9]"
default y
config BSP_USING_I2C1
bool "Enable I2C1 bus [SCL P0.2; SDA P0.3]"
default n
endif
endmenu
...
...
bsp/maxim/MAX32660_EVSYS/rtconfig.h
浏览文件 @
307671e2
...
...
@@ -10,7 +10,7 @@
#define RT_ALIGN_SIZE 4
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 100
#define RT_TICK_PER_SECOND 100
0
#define RT_USING_OVERFLOW_CHECK
#define RT_USING_HOOK
#define RT_USING_IDLE_HOOK
...
...
bsp/maxim/libraries/HAL_Drivers/SConscript
浏览文件 @
307671e2
...
...
@@ -20,6 +20,9 @@ if GetDepend(['RT_USING_PWM']):
if
GetDepend
([
'RT_USING_SPI'
]):
src
+=
[
'drv_spi.c'
]
if
GetDepend
([
'RT_USING_I2C'
]):
src
+=
[
'drv_i2c.c'
]
if
GetDepend
([
'RT_USING_I2C'
,
'RT_USING_I2C_BITOPS'
]):
src
+=
[
'drv_soft_i2c.c'
]
...
...
bsp/maxim/libraries/HAL_Drivers/drv_i2c.c
0 → 100644
浏览文件 @
307671e2
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-02-26 Jackistang first version
*
*/
#include "drv_i2c.h"
#include "i2c.h"
#include <rtdevice.h>
#include <rtthread.h>
#include "board.h"
#ifdef RT_USING_I2C
#if !defined(BSP_USING_I2C0) && !defined(BSP_USING_I2C1)
#error "Please define at least one BSP_USING_I2Cx"
/* this driver can be disabled at menuconfig -> Hardware Drivers Config -> On-chip Peripheral Drivers -> Enable I2C */
#endif
#define DBG_LEVEL DBG_LOG
#include <rtdbg.h>
#define LOG_TAG "drv.i2c"
/* mxc config class */
struct
mxc_i2c_config
{
const
char
*
name
;
mxc_i2c_regs_t
*
i2c_periph
;
i2c_speed_t
speed
;
IRQn_Type
irq_type
;
};
struct
mxc_i2c
{
struct
rt_i2c_bus_device
bus
;
struct
mxc_i2c_config
*
config
;
};
static
struct
mxc_i2c_config
i2c_config
[]
=
{
#ifdef BSP_USING_I2C0
{
.
name
=
"i2c0"
,
.
i2c_periph
=
MXC_I2C_GET_I2C
(
0
),
.
irq_type
=
MXC_I2C_GET_IRQ
(
0
),
.
speed
=
I2C_STD_MODE
,
/*I2C_STD_MODE: 100KHz, I2C_FAST_MODE: 400KHz, I2C_FASTPLUS_MODE: 1MHz, I2C_HS_MODE: 3.4MHz */
},
#endif
#ifdef BSP_USING_I2C1
{
.
name
=
"i2c1"
,
.
i2c_periph
=
MXC_I2C_GET_I2C
(
1
),
.
irq_type
=
MXC_I2C_GET_IRQ
(
1
),
.
speed
=
I2C_STD_MODE
,
/*I2C_STD_MODE: 100KHz, I2C_FAST_MODE: 400KHz, I2C_FASTPLUS_MODE: 1MHz, I2C_HS_MODE: 3.4MHz */
},
#endif
};
static
struct
mxc_i2c
i2c_obj
[
sizeof
(
i2c_config
)
/
sizeof
(
i2c_config
[
0
])]
=
{
0
};
static
rt_size_t
mxc_i2c_mst_xfer
(
struct
rt_i2c_bus_device
*
bus
,
struct
rt_i2c_msg
msgs
[],
rt_uint32_t
num
)
{
rt_uint32_t
i
,
ret
;
rt_uint16_t
addr
;
int
error
;
int
restart
=
0
;
struct
rt_i2c_msg
*
msg
;
struct
mxc_i2c
*
obj
=
(
struct
mxc_i2c
*
)
bus
;
for
(
i
=
0
;
i
<
num
;
i
++
)
{
msg
=
&
msgs
[
i
];
if
(
msg
->
flags
&
RT_I2C_ADDR_10BIT
||
msg
->
flags
&
RT_I2C_NO_START
||
msg
->
flags
&
RT_I2C_IGNORE_NACK
||
msg
->
flags
&
RT_I2C_NO_READ_ACK
)
{
LOG_E
(
"Not support RT_I2C_ADDR_10BIT or RT_I2C_NO_START or RT_I2C_IGNORE_NACK or RT_I2C_NO_READ_ACK"
);
return
0
;
}
if
(
msg
->
flags
&
RT_I2C_NO_STOP
)
{
restart
=
1
;
}
if
(
msg
->
flags
&
RT_I2C_RD
)
{
addr
=
msg
->
addr
<<
1
;
if
((
error
=
I2C_MasterRead
(
obj
->
config
->
i2c_periph
,
(
uint8_t
)
addr
,
msg
->
buf
,
msg
->
len
,
restart
))
!=
msg
->
len
)
{
LOG_E
(
"Error writing %d"
,
error
);
return
0
;
}
}
else
/* RT_I2C_WR */
{
addr
=
msg
->
addr
<<
1
;
if
((
error
=
I2C_MasterWrite
(
obj
->
config
->
i2c_periph
,
(
uint8_t
)
addr
,
msg
->
buf
,
msg
->
len
,
restart
))
!=
msg
->
len
)
{
LOG_E
(
"Error writing %d"
,
error
);
return
0
;
}
}
}
ret
=
i
;
return
ret
;
}
static
const
struct
rt_i2c_bus_device_ops
mxc_i2c_ops
=
{
mxc_i2c_mst_xfer
,
RT_NULL
,
RT_NULL
,
};
int
rt_hw_i2c_init
(
void
)
{
rt_size_t
obj_num
;
int
index
;
rt_err_t
result
=
0
;
#ifdef BSP_USING_I2C0
NVIC_EnableIRQ
(
I2C0_IRQn
);
#endif
#ifdef BSP_USING_I2C1
NVIC_EnableIRQ
(
I2C1_IRQn
);
#endif
obj_num
=
sizeof
(
i2c_obj
)
/
sizeof
(
struct
mxc_i2c
);
for
(
index
=
0
;
index
<
obj_num
;
index
++
)
{
/* init i2c object */
i2c_obj
[
index
].
config
=
&
i2c_config
[
index
];
i2c_obj
[
index
].
bus
.
ops
=
&
mxc_i2c_ops
;
/* init i2c device */
I2C_Shutdown
(
i2c_config
[
index
].
i2c_periph
);
I2C_Init
(
i2c_config
[
index
].
i2c_periph
,
i2c_config
[
index
].
speed
,
RT_NULL
);
/* register i2c device */
result
=
rt_i2c_bus_device_register
(
&
i2c_obj
[
index
].
bus
,
i2c_obj
[
index
].
config
->
name
);
RT_ASSERT
(
result
==
RT_EOK
);
}
return
0
;
}
INIT_DEVICE_EXPORT
(
rt_hw_i2c_init
);
#ifdef BSP_USING_I2C0
void
I2C0_IRQHandler
(
void
)
{
rt_interrupt_enter
();
I2C_Handler
(
MXC_I2C0
);
rt_interrupt_leave
();
}
#endif
#ifdef BSP_USING_I2C1
void
I2C1_IRQHandler
(
void
)
{
rt_interrupt_enter
();
I2C_Handler
(
MXC_I2C1
);
rt_interrupt_leave
();
}
#endif
#endif
/* RT_USING_I2C */
bsp/maxim/libraries/HAL_Drivers/drv_i2c.h
0 → 100644
浏览文件 @
307671e2
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-02-26 Jackistang first version
*
*/
#ifndef __DRV_I2C_H__
#define __DRV_I2C_H__
#endif
/* __DRV_I2C_H__ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录