Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tools-mirror
Micropython
提交
0c54d0c2
M
Micropython
项目概览
tools-mirror
/
Micropython
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Micropython
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0c54d0c2
编写于
4月 24, 2018
作者:
D
Damien George
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stm32: Rename legacy pyb.I2C helper functions to start with pyb_i2c_.
上级
b73adcc3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
16 deletion
+16
-16
ports/stm32/accel.c
ports/stm32/accel.c
+1
-1
ports/stm32/i2c.h
ports/stm32/i2c.h
+3
-3
ports/stm32/machine_i2c.c
ports/stm32/machine_i2c.c
+2
-2
ports/stm32/pyb_i2c.c
ports/stm32/pyb_i2c.c
+10
-10
未找到文件。
ports/stm32/accel.c
浏览文件 @
0c54d0c2
...
...
@@ -70,7 +70,7 @@ STATIC void accel_start(void) {
I2CHandle1
.
Init
.
NoStretchMode
=
I2C_NOSTRETCH_DISABLE
;
I2CHandle1
.
Init
.
OwnAddress1
=
PYB_I2C_MASTER_ADDRESS
;
I2CHandle1
.
Init
.
OwnAddress2
=
0xfe
;
// unused
i2c_init
(
&
I2CHandle1
);
pyb_
i2c_init
(
&
I2CHandle1
);
// turn off AVDD, wait 30ms, turn on AVDD, wait 30ms again
mp_hal_pin_low
(
MICROPY_HW_MMA_AVDD_PIN
);
// turn off
...
...
ports/stm32/i2c.h
浏览文件 @
0c54d0c2
...
...
@@ -47,9 +47,9 @@ extern const mp_obj_type_t pyb_i2c_type;
extern
const
pyb_i2c_obj_t
pyb_i2c_obj
[
4
];
void
i2c_init0
(
void
);
void
i2c_init
(
I2C_HandleTypeDef
*
i2c
);
void
i2c_init_freq
(
const
pyb_i2c_obj_t
*
self
,
mp_int_t
freq
);
uint32_t
i2c_get_baudrate
(
I2C_HandleTypeDef
*
i2c
);
void
pyb_
i2c_init
(
I2C_HandleTypeDef
*
i2c
);
void
pyb_
i2c_init_freq
(
const
pyb_i2c_obj_t
*
self
,
mp_int_t
freq
);
uint32_t
pyb_
i2c_get_baudrate
(
I2C_HandleTypeDef
*
i2c
);
void
i2c_ev_irq_handler
(
mp_uint_t
i2c_id
);
void
i2c_er_irq_handler
(
mp_uint_t
i2c_id
);
...
...
ports/stm32/machine_i2c.c
浏览文件 @
0c54d0c2
...
...
@@ -87,13 +87,13 @@ STATIC void machine_hard_i2c_print(const mp_print_t *print, mp_obj_t self_in, mp
machine_hard_i2c_obj_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
mp_printf
(
print
,
"I2C(%u, freq=%u, timeout=%u)"
,
self
-
&
machine_hard_i2c_obj
[
0
]
+
1
,
i2c_get_baudrate
(
self
->
pyb
->
i2c
),
pyb_
i2c_get_baudrate
(
self
->
pyb
->
i2c
),
*
self
->
timeout
);
}
STATIC
void
machine_hard_i2c_init
(
const
machine_hard_i2c_obj_t
*
self
,
uint32_t
freq
,
uint32_t
timeout
)
{
*
self
->
timeout
=
timeout
;
i2c_init_freq
(
self
->
pyb
,
freq
);
pyb_
i2c_init_freq
(
self
->
pyb
,
freq
);
}
// this function is based on STM code
...
...
ports/stm32/pyb_i2c.c
浏览文件 @
0c54d0c2
...
...
@@ -201,7 +201,7 @@ STATIC void i2c_set_baudrate(I2C_InitTypeDef *init, uint32_t baudrate) {
"Unsupported I2C baudrate: %lu"
,
baudrate
));
}
uint32_t
i2c_get_baudrate
(
I2C_HandleTypeDef
*
i2c
)
{
uint32_t
pyb_
i2c_get_baudrate
(
I2C_HandleTypeDef
*
i2c
)
{
for
(
int
i
=
0
;
i
<
NUM_BAUDRATE_TIMINGS
;
i
++
)
{
if
(
pyb_i2c_baudrate_timing
[
i
].
timing
==
i2c
->
Init
.
Timing
)
{
return
pyb_i2c_baudrate_timing
[
i
].
baudrate
;
...
...
@@ -220,7 +220,7 @@ STATIC void i2c_set_baudrate(I2C_InitTypeDef *init, uint32_t baudrate) {
init
->
DutyCycle
=
I2C_DUTYCYCLE_16_9
;
}
uint32_t
i2c_get_baudrate
(
I2C_HandleTypeDef
*
i2c
)
{
uint32_t
pyb_
i2c_get_baudrate
(
I2C_HandleTypeDef
*
i2c
)
{
uint32_t
pfreq
=
i2c
->
Instance
->
CR2
&
0x3f
;
uint32_t
ccr
=
i2c
->
Instance
->
CCR
&
0xfff
;
if
(
i2c
->
Instance
->
CCR
&
0x8000
)
{
...
...
@@ -251,7 +251,7 @@ void i2c_init0(void) {
#endif
}
void
i2c_init
(
I2C_HandleTypeDef
*
i2c
)
{
void
pyb_
i2c_init
(
I2C_HandleTypeDef
*
i2c
)
{
int
i2c_unit
;
const
pin_obj_t
*
scl_pin
;
const
pin_obj_t
*
sda_pin
;
...
...
@@ -372,7 +372,7 @@ void i2c_deinit(I2C_HandleTypeDef *i2c) {
}
}
void
i2c_init_freq
(
const
pyb_i2c_obj_t
*
self
,
mp_int_t
freq
)
{
void
pyb_
i2c_init_freq
(
const
pyb_i2c_obj_t
*
self
,
mp_int_t
freq
)
{
I2C_InitTypeDef
*
init
=
&
self
->
i2c
->
Init
;
init
->
AddressingMode
=
I2C_ADDRESSINGMODE_7BIT
;
...
...
@@ -389,7 +389,7 @@ void i2c_init_freq(const pyb_i2c_obj_t *self, mp_int_t freq) {
// init the I2C bus
i2c_deinit
(
self
->
i2c
);
i2c_init
(
self
->
i2c
);
pyb_
i2c_init
(
self
->
i2c
);
}
STATIC
void
i2c_reset_after_error
(
I2C_HandleTypeDef
*
i2c
)
{
...
...
@@ -403,7 +403,7 @@ STATIC void i2c_reset_after_error(I2C_HandleTypeDef *i2c) {
}
// bus was/is busy, need to reset the peripheral to get it to work again
i2c_deinit
(
i2c
);
i2c_init
(
i2c
);
pyb_
i2c_init
(
i2c
);
}
void
i2c_ev_irq_handler
(
mp_uint_t
i2c_id
)
{
...
...
@@ -563,7 +563,7 @@ STATIC void pyb_i2c_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki
mp_printf
(
print
,
"I2C(%u)"
,
i2c_num
);
}
else
{
if
(
in_master_mode
(
self
))
{
mp_printf
(
print
,
"I2C(%u, I2C.MASTER, baudrate=%u)"
,
i2c_num
,
i2c_get_baudrate
(
self
->
i2c
));
mp_printf
(
print
,
"I2C(%u, I2C.MASTER, baudrate=%u)"
,
i2c_num
,
pyb_
i2c_get_baudrate
(
self
->
i2c
));
}
else
{
mp_printf
(
print
,
"I2C(%u, I2C.SLAVE, addr=0x%02x)"
,
i2c_num
,
(
self
->
i2c
->
Instance
->
OAR1
>>
1
)
&
0x7f
);
}
...
...
@@ -612,7 +612,7 @@ STATIC mp_obj_t pyb_i2c_init_helper(const pyb_i2c_obj_t *self, size_t n_args, co
// init the I2C bus
i2c_deinit
(
self
->
i2c
);
i2c_init
(
self
->
i2c
);
pyb_
i2c_init
(
self
->
i2c
);
return
mp_const_none
;
}
...
...
@@ -680,10 +680,10 @@ STATIC mp_obj_t pyb_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_
return
(
mp_obj_t
)
i2c_obj
;
}
STATIC
mp_obj_t
pyb_i2c_init
(
size_t
n_args
,
const
mp_obj_t
*
args
,
mp_map_t
*
kw_args
)
{
STATIC
mp_obj_t
pyb_i2c_init
_
(
size_t
n_args
,
const
mp_obj_t
*
args
,
mp_map_t
*
kw_args
)
{
return
pyb_i2c_init_helper
(
args
[
0
],
n_args
-
1
,
args
+
1
,
kw_args
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_KW
(
pyb_i2c_init_obj
,
1
,
pyb_i2c_init
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_KW
(
pyb_i2c_init_obj
,
1
,
pyb_i2c_init
_
);
/// \method deinit()
/// Turn off the I2C bus.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录