Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
7ce2a082
Commit
7ce2a082
authored
Apr 01, 2019
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stm32: Add support for MMC driver, exposed via pyb.MMCard class.
Enable it via MICROPY_HW_ENABLE_MMCARD.
parent
9670b265
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
357 additions
and
81 deletions
+357
-81
ports/stm32/Makefile
ports/stm32/Makefile
+1
-0
ports/stm32/dma.c
ports/stm32/dma.c
+8
-6
ports/stm32/modpyb.c
ports/stm32/modpyb.c
+3
-0
ports/stm32/mpconfigboard_common.h
ports/stm32/mpconfigboard_common.h
+5
-0
ports/stm32/sdcard.c
ports/stm32/sdcard.c
+339
-75
ports/stm32/sdcard.h
ports/stm32/sdcard.h
+1
-0
No files found.
ports/stm32/Makefile
View file @
7ce2a082
...
...
@@ -329,6 +329,7 @@ endif
ifeq
($(MCU_SERIES),$(filter $(MCU_SERIES),f4 f7 h7))
SRC_HAL
+=
$(
addprefix
$(HAL_DIR)
/Src/stm32
$(MCU_SERIES)
xx_,
\
hal_mmc.c
\
hal_sdram.c
\
hal_dma_ex.c
\
hal_dcmi.c
\
...
...
ports/stm32/dma.c
View file @
7ce2a082
...
...
@@ -39,6 +39,8 @@
#define DMA_IDLE_TICK_MAX (8) // 8*8 = 64 msec
#define DMA_IDLE_TICK(tick) (((tick) & ~(SYSTICK_DISPATCH_NUM_SLOTS - 1) & DMA_SYSTICK_MASK) == 0)
#define ENABLE_SDIO (MICROPY_HW_ENABLE_SDCARD || MICROPY_HW_ENABLE_MMCARD)
typedef
enum
{
dma_id_not_defined
=-
1
,
dma_id_0
,
...
...
@@ -100,7 +102,7 @@ static const DMA_InitTypeDef dma_init_struct_spi_i2c = {
#endif
};
#if
MICROPY_HW_ENABLE_SDCARD
&& !defined(STM32H7)
#if
ENABLE_SDIO
&& !defined(STM32H7)
// Parameters to dma_init() for SDIO tx and rx.
static
const
DMA_InitTypeDef
dma_init_struct_sdio
=
{
#if defined(STM32F4) || defined(STM32F7)
...
...
@@ -256,7 +258,7 @@ const dma_descr_t dma_I2C_1_TX = { DMA1_Stream6, DMA_CHANNEL_1, dma_id_6, &dma
*/
// DMA2 streams
#if defined(STM32F7) && defined(SDMMC2) &&
MICROPY_HW_ENABLE_SDCARD
#if defined(STM32F7) && defined(SDMMC2) &&
ENABLE_SDIO
const
dma_descr_t
dma_SDMMC_2
=
{
DMA2_Stream0
,
DMA_CHANNEL_11
,
dma_id_8
,
&
dma_init_struct_sdio
};
#endif
#if MICROPY_HW_ENABLE_DCMI
...
...
@@ -264,7 +266,7 @@ const dma_descr_t dma_DCMI_0 = { DMA2_Stream1, DMA_CHANNEL_1, dma_id_9, &dma_in
#endif
const
dma_descr_t
dma_SPI_1_RX
=
{
DMA2_Stream2
,
DMA_CHANNEL_3
,
dma_id_10
,
&
dma_init_struct_spi_i2c
};
const
dma_descr_t
dma_SPI_5_RX
=
{
DMA2_Stream3
,
DMA_CHANNEL_2
,
dma_id_11
,
&
dma_init_struct_spi_i2c
};
#if
MICROPY_HW_ENABLE_SDCARD
#if
ENABLE_SDIO
const
dma_descr_t
dma_SDIO_0
=
{
DMA2_Stream3
,
DMA_CHANNEL_4
,
dma_id_11
,
&
dma_init_struct_sdio
};
#endif
const
dma_descr_t
dma_SPI_4_RX
=
{
DMA2_Stream3
,
DMA_CHANNEL_5
,
dma_id_11
,
&
dma_init_struct_spi_i2c
};
...
...
@@ -272,11 +274,11 @@ const dma_descr_t dma_SPI_5_TX = { DMA2_Stream4, DMA_CHANNEL_2, dma_id_12, &dma
const
dma_descr_t
dma_SPI_4_TX
=
{
DMA2_Stream4
,
DMA_CHANNEL_5
,
dma_id_12
,
&
dma_init_struct_spi_i2c
};
const
dma_descr_t
dma_SPI_6_TX
=
{
DMA2_Stream5
,
DMA_CHANNEL_1
,
dma_id_13
,
&
dma_init_struct_spi_i2c
};
const
dma_descr_t
dma_SPI_1_TX
=
{
DMA2_Stream5
,
DMA_CHANNEL_3
,
dma_id_13
,
&
dma_init_struct_spi_i2c
};
//#if defined(STM32F7) && defined(SDMMC2) &&
MICROPY_HW_ENABLE_SDCARD
//#if defined(STM32F7) && defined(SDMMC2) &&
ENABLE_SDIO
//const dma_descr_t dma_SDMMC_2 = { DMA2_Stream5, DMA_CHANNEL_11, dma_id_13, &dma_init_struct_sdio };
//#endif
const
dma_descr_t
dma_SPI_6_RX
=
{
DMA2_Stream6
,
DMA_CHANNEL_1
,
dma_id_14
,
&
dma_init_struct_spi_i2c
};
//#if
MICROPY_HW_ENABLE_SDCARD
//#if
ENABLE_SDIO
//const dma_descr_t dma_SDIO_0 = { DMA2_Stream6, DMA_CHANNEL_4, dma_id_14, &dma_init_struct_sdio };
//#endif
/* not preferred streams
...
...
@@ -352,7 +354,7 @@ const dma_descr_t dma_ADC_2_RX = { DMA2_Channel4, DMA_REQUEST_0, dma_id_10, NUL
const dma_descr_t dma_DAC_1_TX = { DMA2_Channel4, DMA_REQUEST_3, dma_id_10, &dma_init_struct_dac };
const dma_descr_t dma_SPI_1_TX = { DMA2_Channel4, DMA_REQUEST_4, dma_id_10, &dma_init_struct_spi_i2c };
*/
#if
MICROPY_HW_ENABLE_SDCARD
#if
ENABLE_SDIO
const
dma_descr_t
dma_SDIO_0
=
{
DMA2_Channel4
,
DMA_REQUEST_7
,
dma_id_10
,
&
dma_init_struct_sdio
};
#endif
/* not preferred streams
...
...
ports/stm32/modpyb.c
View file @
7ce2a082
...
...
@@ -200,6 +200,9 @@ STATIC const mp_rom_map_elem_t pyb_module_globals_table[] = {
#endif
{
MP_ROM_QSTR
(
MP_QSTR_SDCard
),
MP_ROM_PTR
(
&
pyb_sdcard_type
)
},
#endif
#if MICROPY_HW_ENABLE_MMCARD
{
MP_ROM_QSTR
(
MP_QSTR_MMCard
),
MP_ROM_PTR
(
&
pyb_mmcard_type
)
},
#endif
#if defined(MICROPY_HW_LED1)
{
MP_ROM_QSTR
(
MP_QSTR_LED
),
MP_ROM_PTR
(
&
pyb_led_type
)
},
...
...
ports/stm32/mpconfigboard_common.h
View file @
7ce2a082
...
...
@@ -97,6 +97,11 @@
#define MICROPY_HW_ENABLE_SDCARD (0)
#endif
// Whether to enable the MMC interface, exposed as pyb.MMCard
#ifndef MICROPY_HW_ENABLE_MMCARD
#define MICROPY_HW_ENABLE_MMCARD (0)
#endif
// Whether to automatically mount (and boot from) the SD card if it's present
#ifndef MICROPY_HW_SDCARD_MOUNT_AT_BOOT
#define MICROPY_HW_SDCARD_MOUNT_AT_BOOT (MICROPY_HW_ENABLE_SDCARD)
...
...
ports/stm32/sdcard.c
View file @
7ce2a082
This diff is collapsed.
Click to expand it.
ports/stm32/sdcard.h
View file @
7ce2a082
...
...
@@ -40,6 +40,7 @@ mp_uint_t sdcard_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_blo
mp_uint_t
sdcard_write_blocks
(
const
uint8_t
*
src
,
uint32_t
block_num
,
uint32_t
num_blocks
);
extern
const
struct
_mp_obj_type_t
pyb_sdcard_type
;
extern
const
struct
_mp_obj_type_t
pyb_mmcard_type
;
extern
const
struct
_mp_obj_base_t
pyb_sdcard_obj
;
struct
_fs_user_mount_t
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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