Automatically count EXTERNAL_FLASH_DEVICES (mk2)
Instead of counting words in make, which is slightly awful, notice that possible_devices is local to external_flash.c, so we can declare the array with an automatic bound, and then get the count as the element-count (MP_ARRAY_SIZE) of the array. Since EXTERNAL_FLASH_DEVICE_COUNT is no longer a global macro, switch a few sites to using EXTERNAL_FLASH_DEVICES in `#if` checks instead.
This commit is contained in:
parent
f1ada8e880
commit
32475ce98c
@ -31,7 +31,7 @@
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
|
||||
#ifdef EXTERNAL_FLASH_DEVICE_COUNT
|
||||
#ifdef EXTERNAL_FLASH_DEVICES
|
||||
#include "supervisor/shared/external_flash/external_flash.h"
|
||||
#else
|
||||
#include "supervisor/shared/internal_flash.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
#ifndef MICROPY_INCLUDED_SUPERVISOR_FLASH_ROOT_POINTERS_H
|
||||
#define MICROPY_INCLUDED_SUPERVISOR_FLASH_ROOT_POINTERS_H
|
||||
|
||||
#ifdef EXTERNAL_FLASH_DEVICE_COUNT
|
||||
#ifdef EXTERNAL_FLASH_DEVICES
|
||||
#include "supervisor/shared/external_flash/external_flash_root_pointers.h"
|
||||
#else
|
||||
#include "supervisor/internal_flash_root_pointers.h"
|
||||
|
@ -45,7 +45,8 @@
|
||||
// The currently cached sector in the cache, ram or flash based.
|
||||
static uint32_t current_sector;
|
||||
|
||||
const external_flash_device possible_devices[EXTERNAL_FLASH_DEVICE_COUNT] = {EXTERNAL_FLASH_DEVICES};
|
||||
STATIC const external_flash_device possible_devices[] = {EXTERNAL_FLASH_DEVICES};
|
||||
#define EXTERNAL_FLASH_DEVICE_COUNT MP_ARRAY_SIZE(possible_devices)
|
||||
|
||||
static const external_flash_device* flash_device = NULL;
|
||||
|
||||
|
@ -33,10 +33,7 @@ endif
|
||||
# (Right now INTERNAL_FLASH_FILESYSTEM and (Q)SPI_FLASH_FILESYSTEM are mutually exclusive.
|
||||
# But that might not be true in the future.)
|
||||
ifdef EXTERNAL_FLASH_DEVICES
|
||||
COMMA := ,
|
||||
EXTERNAL_FLASH_DEVICE_COUNT := $(words $(subst $(COMMA), ,$(EXTERNAL_FLASH_DEVICES)))
|
||||
CFLAGS += -DEXTERNAL_FLASH_DEVICES=$(EXTERNAL_FLASH_DEVICES) \
|
||||
-DEXTERNAL_FLASH_DEVICE_COUNT=$(EXTERNAL_FLASH_DEVICE_COUNT)
|
||||
|
||||
SRC_SUPERVISOR += supervisor/shared/external_flash/external_flash.c
|
||||
ifeq ($(SPI_FLASH_FILESYSTEM),1)
|
||||
|
Loading…
Reference in New Issue
Block a user