Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
2460888c
Commit
2460888c
authored
Mar 31, 2017
by
Damien George
Browse files
stmhal/i2c: Clean the cache so that I2C DMA works on F7 MCUs.
parent
aa7de3ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
stmhal/i2c.c
View file @
2460888c
...
...
@@ -760,12 +760,14 @@ STATIC mp_obj_t pyb_i2c_send(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
if
(
!
use_dma
)
{
status
=
HAL_I2C_Master_Transmit
(
self
->
i2c
,
i2c_addr
,
bufinfo
.
buf
,
bufinfo
.
len
,
args
[
2
].
u_int
);
}
else
{
MP_HAL_CLEAN_DCACHE
(
bufinfo
.
buf
,
bufinfo
.
len
);
status
=
HAL_I2C_Master_Transmit_DMA
(
self
->
i2c
,
i2c_addr
,
bufinfo
.
buf
,
bufinfo
.
len
);
}
}
else
{
if
(
!
use_dma
)
{
status
=
HAL_I2C_Slave_Transmit
(
self
->
i2c
,
bufinfo
.
buf
,
bufinfo
.
len
,
args
[
2
].
u_int
);
}
else
{
MP_HAL_CLEAN_DCACHE
(
bufinfo
.
buf
,
bufinfo
.
len
);
status
=
HAL_I2C_Slave_Transmit_DMA
(
self
->
i2c
,
bufinfo
.
buf
,
bufinfo
.
len
);
}
}
...
...
@@ -834,12 +836,14 @@ STATIC mp_obj_t pyb_i2c_recv(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
if
(
!
use_dma
)
{
status
=
HAL_I2C_Master_Receive
(
self
->
i2c
,
i2c_addr
,
(
uint8_t
*
)
vstr
.
buf
,
vstr
.
len
,
args
[
2
].
u_int
);
}
else
{
MP_HAL_CLEANINVALIDATE_DCACHE
(
vstr
.
buf
,
vstr
.
len
);
status
=
HAL_I2C_Master_Receive_DMA
(
self
->
i2c
,
i2c_addr
,
(
uint8_t
*
)
vstr
.
buf
,
vstr
.
len
);
}
}
else
{
if
(
!
use_dma
)
{
status
=
HAL_I2C_Slave_Receive
(
self
->
i2c
,
(
uint8_t
*
)
vstr
.
buf
,
vstr
.
len
,
args
[
2
].
u_int
);
}
else
{
MP_HAL_CLEANINVALIDATE_DCACHE
(
vstr
.
buf
,
vstr
.
len
);
status
=
HAL_I2C_Slave_Receive_DMA
(
self
->
i2c
,
(
uint8_t
*
)
vstr
.
buf
,
vstr
.
len
);
}
}
...
...
@@ -920,6 +924,7 @@ STATIC mp_obj_t pyb_i2c_mem_read(mp_uint_t n_args, const mp_obj_t *pos_args, mp_
dma_init
(
&
rx_dma
,
self
->
rx_dma_descr
,
self
->
i2c
);
self
->
i2c
->
hdmatx
=
NULL
;
self
->
i2c
->
hdmarx
=
&
rx_dma
;
MP_HAL_CLEANINVALIDATE_DCACHE
(
vstr
.
buf
,
vstr
.
len
);
status
=
HAL_I2C_Mem_Read_DMA
(
self
->
i2c
,
i2c_addr
,
mem_addr
,
mem_addr_size
,
(
uint8_t
*
)
vstr
.
buf
,
vstr
.
len
);
if
(
status
==
HAL_OK
)
{
status
=
i2c_wait_dma_finished
(
self
->
i2c
,
args
[
3
].
u_int
);
...
...
@@ -988,6 +993,7 @@ STATIC mp_obj_t pyb_i2c_mem_write(mp_uint_t n_args, const mp_obj_t *pos_args, mp
dma_init
(
&
tx_dma
,
self
->
tx_dma_descr
,
self
->
i2c
);
self
->
i2c
->
hdmatx
=
&
tx_dma
;
self
->
i2c
->
hdmarx
=
NULL
;
MP_HAL_CLEAN_DCACHE
(
bufinfo
.
buf
,
bufinfo
.
len
);
status
=
HAL_I2C_Mem_Write_DMA
(
self
->
i2c
,
i2c_addr
,
mem_addr
,
mem_addr_size
,
bufinfo
.
buf
,
bufinfo
.
len
);
if
(
status
==
HAL_OK
)
{
status
=
i2c_wait_dma_finished
(
self
->
i2c
,
args
[
3
].
u_int
);
...
...
stmhal/mphalport.h
View file @
2460888c
...
...
@@ -10,8 +10,8 @@
#define MP_HAL_CLEAN_DCACHE(addr, size)
#elif defined(MCU_SERIES_F7)
#define MP_HAL_UNIQUE_ID_ADDRESS (0x1ff0f420)
#define MP_HAL_CLEANINVALIDATE_DCACHE(addr, size) (SCB_CleanInvalidateDCache_by_Addr((uint32_t*)((uint32_t)addr & ~0x1f), ((uint32_t)(addr + size + 0x1f) & ~0x1f) - ((uint32_t)addr & ~0x1f)))
#define MP_HAL_CLEAN_DCACHE(addr, size) (SCB_CleanDCache_by_Addr((uint32_t*)((uint32_t)addr & ~0x1f), ((uint32_t)(addr + size + 0x1f) & ~0x1f) - ((uint32_t)addr & ~0x1f)))
#define MP_HAL_CLEANINVALIDATE_DCACHE(addr, size) (SCB_CleanInvalidateDCache_by_Addr((uint32_t*)((uint32_t)addr & ~0x1f), ((uint32_t)(
(uint8_t*)
addr + size + 0x1f) & ~0x1f) - ((uint32_t)addr & ~0x1f)))
#define MP_HAL_CLEAN_DCACHE(addr, size) (SCB_CleanDCache_by_Addr((uint32_t*)((uint32_t)addr & ~0x1f), ((uint32_t)(
(uint8_t*)
addr + size + 0x1f) & ~0x1f) - ((uint32_t)addr & ~0x1f)))
#elif defined(MCU_SERIES_L4)
#define MP_HAL_UNIQUE_ID_ADDRESS (0x1fff7590)
#define MP_HAL_CLEANINVALIDATE_DCACHE(addr, size)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment