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:
parent
ff1a96ce2c
commit
97a0846af9
@ -5,6 +5,7 @@
|
|||||||
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (0)
|
#define MICROPY_HW_HAS_SWITCH (0)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (0)
|
#define MICROPY_HW_HAS_SDCARD (0)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (0)
|
#define MICROPY_HW_HAS_MMA7660 (0)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (0)
|
#define MICROPY_HW_HAS_SDCARD (0)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (0)
|
#define MICROPY_HW_HAS_MMA7660 (0)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define MICROPY_HW_MCU_NAME "STM32F4"
|
#define MICROPY_HW_MCU_NAME "STM32F4"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (1)
|
#define MICROPY_HW_HAS_SDCARD (1)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (0)
|
#define MICROPY_HW_HAS_MMA7660 (0)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#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
|
// 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
|
// SPI, so the driver needs to be converted to support that before
|
||||||
// we can turn this on.
|
// we can turn this on.
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (1)
|
#define MICROPY_HW_HAS_SDCARD (1)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (1)
|
#define MICROPY_HW_HAS_MMA7660 (1)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (1)
|
#define MICROPY_HW_HAS_SDCARD (1)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (1)
|
#define MICROPY_HW_HAS_MMA7660 (1)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (1)
|
#define MICROPY_HW_HAS_SDCARD (1)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (1)
|
#define MICROPY_HW_HAS_MMA7660 (1)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define MICROPY_HW_MCU_NAME "STM32F405RG"
|
#define MICROPY_HW_MCU_NAME "STM32F405RG"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (1)
|
#define MICROPY_HW_HAS_SDCARD (1)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (1)
|
#define MICROPY_HW_HAS_MMA7660 (1)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (1)
|
#define MICROPY_HW_HAS_SDCARD (1)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (1)
|
#define MICROPY_HW_HAS_MMA7660 (1)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
#define MICROPY_PY_SYS_PLATFORM "pyboard"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (0)
|
#define MICROPY_HW_HAS_SDCARD (0)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (0)
|
#define MICROPY_HW_HAS_MMA7660 (0)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define MICROPY_HW_MCU_NAME "STM32F429"
|
#define MICROPY_HW_MCU_NAME "STM32F429"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (0)
|
#define MICROPY_HW_HAS_SDCARD (0)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (0)
|
#define MICROPY_HW_HAS_MMA7660 (0)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define MICROPY_HW_MCU_NAME "STM32F407"
|
#define MICROPY_HW_MCU_NAME "STM32F407"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (0)
|
#define MICROPY_HW_HAS_SDCARD (0)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (0)
|
#define MICROPY_HW_HAS_MMA7660 (0)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (1)
|
#define MICROPY_HW_HAS_LIS3DSH (1)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define MICROPY_HW_MCU_NAME "STM32F746"
|
#define MICROPY_HW_MCU_NAME "STM32F746"
|
||||||
|
|
||||||
#define MICROPY_HW_HAS_SWITCH (1)
|
#define MICROPY_HW_HAS_SWITCH (1)
|
||||||
|
#define MICROPY_HW_HAS_FLASH (1)
|
||||||
#define MICROPY_HW_HAS_SDCARD (1)
|
#define MICROPY_HW_HAS_SDCARD (1)
|
||||||
#define MICROPY_HW_HAS_MMA7660 (0)
|
#define MICROPY_HW_HAS_MMA7660 (0)
|
||||||
#define MICROPY_HW_HAS_LIS3DSH (0)
|
#define MICROPY_HW_HAS_LIS3DSH (0)
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include STM32_HAL_H
|
#include "py/mphal.h"
|
||||||
|
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "lib/fatfs/ff.h" /* FatFs lower layer API */
|
#include "lib/fatfs/ff.h" /* FatFs lower layer API */
|
||||||
@ -60,9 +60,11 @@ DSTATUS disk_initialize (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
switch (pdrv) {
|
switch (pdrv) {
|
||||||
|
#if MICROPY_HW_HAS_FLASH
|
||||||
case PD_FLASH:
|
case PD_FLASH:
|
||||||
storage_init();
|
storage_init();
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MICROPY_HW_HAS_SDCARD
|
#if MICROPY_HW_HAS_SDCARD
|
||||||
case PD_SDCARD:
|
case PD_SDCARD:
|
||||||
@ -130,6 +132,7 @@ DRESULT disk_read (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
switch (pdrv) {
|
switch (pdrv) {
|
||||||
|
#if MICROPY_HW_HAS_FLASH
|
||||||
case PD_FLASH:
|
case PD_FLASH:
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (!storage_read_block(buff + i * FLASH_BLOCK_SIZE, sector + i)) {
|
if (!storage_read_block(buff + i * FLASH_BLOCK_SIZE, sector + i)) {
|
||||||
@ -137,6 +140,7 @@ DRESULT disk_read (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MICROPY_HW_HAS_SDCARD
|
#if MICROPY_HW_HAS_SDCARD
|
||||||
case PD_SDCARD:
|
case PD_SDCARD:
|
||||||
@ -173,6 +177,7 @@ DRESULT disk_write (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
switch (pdrv) {
|
switch (pdrv) {
|
||||||
|
#if MICROPY_HW_HAS_FLASH
|
||||||
case PD_FLASH:
|
case PD_FLASH:
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (!storage_write_block(buff + i * FLASH_BLOCK_SIZE, sector + i)) {
|
if (!storage_write_block(buff + i * FLASH_BLOCK_SIZE, sector + i)) {
|
||||||
@ -180,6 +185,7 @@ DRESULT disk_write (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MICROPY_HW_HAS_SDCARD
|
#if MICROPY_HW_HAS_SDCARD
|
||||||
case PD_SDCARD:
|
case PD_SDCARD:
|
||||||
@ -221,6 +227,7 @@ DRESULT disk_ioctl (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
switch (pdrv) {
|
switch (pdrv) {
|
||||||
|
#if MICROPY_HW_HAS_FLASH
|
||||||
case PD_FLASH:
|
case PD_FLASH:
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case CTRL_SYNC:
|
case CTRL_SYNC:
|
||||||
@ -232,6 +239,7 @@ DRESULT disk_ioctl (
|
|||||||
return RES_OK;
|
return RES_OK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MICROPY_HW_HAS_SDCARD
|
#if MICROPY_HW_HAS_SDCARD
|
||||||
case PD_SDCARD:
|
case PD_SDCARD:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user