stmhal/diskio: Introduce MICROPY_HW_HAS_FLASH setting.

To allow to reuse stmhal/diskio for ports which don't have flash but have
other storage devices.
This commit is contained in:
Paul Sokolovsky 2016-02-06 14:48:58 +02:00
parent ff1a96ce2c
commit 97a0846af9
14 changed files with 22 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#define MICROPY_PY_SYS_PLATFORM "pyboard"
#define MICROPY_HW_HAS_SWITCH (0)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (0)
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -3,6 +3,7 @@
#define MICROPY_PY_SYS_PLATFORM "pyboard"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (0)
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -4,6 +4,7 @@
#define MICROPY_HW_MCU_NAME "STM32F4"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (1)
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -5,6 +5,7 @@
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
// On the netuino, the sdcard appears to be wired up as a 1-bit
// SPI, so the driver needs to be converted to support that before
// we can turn this on.

View File

@ -3,6 +3,7 @@
#define MICROPY_PY_SYS_PLATFORM "pyboard"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (1)
#define MICROPY_HW_HAS_MMA7660 (1)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -3,6 +3,7 @@
#define MICROPY_PY_SYS_PLATFORM "pyboard"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (1)
#define MICROPY_HW_HAS_MMA7660 (1)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -3,6 +3,7 @@
#define MICROPY_PY_SYS_PLATFORM "pyboard"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (1)
#define MICROPY_HW_HAS_MMA7660 (1)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -2,6 +2,7 @@
#define MICROPY_HW_MCU_NAME "STM32F405RG"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (1)
#define MICROPY_HW_HAS_MMA7660 (1)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -3,6 +3,7 @@
#define MICROPY_PY_SYS_PLATFORM "pyboard"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (1)
#define MICROPY_HW_HAS_MMA7660 (1)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -3,6 +3,7 @@
#define MICROPY_PY_SYS_PLATFORM "pyboard"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (0)
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -4,6 +4,7 @@
#define MICROPY_HW_MCU_NAME "STM32F429"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (0)
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -4,6 +4,7 @@
#define MICROPY_HW_MCU_NAME "STM32F407"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (0)
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (1)

View File

@ -4,6 +4,7 @@
#define MICROPY_HW_MCU_NAME "STM32F746"
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_HAS_SDCARD (1)
#define MICROPY_HW_HAS_MMA7660 (0)
#define MICROPY_HW_HAS_LIS3DSH (0)

View File

@ -30,7 +30,7 @@
#include <stdint.h>
#include <stdio.h>
#include STM32_HAL_H
#include "py/mphal.h"
#include "py/runtime.h"
#include "lib/fatfs/ff.h" /* FatFs lower layer API */
@ -60,9 +60,11 @@ DSTATUS disk_initialize (
)
{
switch (pdrv) {
#if MICROPY_HW_HAS_FLASH
case PD_FLASH:
storage_init();
return 0;
#endif
#if MICROPY_HW_HAS_SDCARD
case PD_SDCARD:
@ -130,6 +132,7 @@ DRESULT disk_read (
)
{
switch (pdrv) {
#if MICROPY_HW_HAS_FLASH
case PD_FLASH:
for (int i = 0; i < count; i++) {
if (!storage_read_block(buff + i * FLASH_BLOCK_SIZE, sector + i)) {
@ -137,6 +140,7 @@ DRESULT disk_read (
}
}
return RES_OK;
#endif
#if MICROPY_HW_HAS_SDCARD
case PD_SDCARD:
@ -173,6 +177,7 @@ DRESULT disk_write (
)
{
switch (pdrv) {
#if MICROPY_HW_HAS_FLASH
case PD_FLASH:
for (int i = 0; i < count; i++) {
if (!storage_write_block(buff + i * FLASH_BLOCK_SIZE, sector + i)) {
@ -180,6 +185,7 @@ DRESULT disk_write (
}
}
return RES_OK;
#endif
#if MICROPY_HW_HAS_SDCARD
case PD_SDCARD:
@ -221,6 +227,7 @@ DRESULT disk_ioctl (
)
{
switch (pdrv) {
#if MICROPY_HW_HAS_FLASH
case PD_FLASH:
switch (cmd) {
case CTRL_SYNC:
@ -232,6 +239,7 @@ DRESULT disk_ioctl (
return RES_OK;
}
break;
#endif
#if MICROPY_HW_HAS_SDCARD
case PD_SDCARD: