Merge pull request #14031 from arduino/blockdevices_namespaces

BlockDevices: specify mbed namespace where needed
pull/14238/head
Martin Kojtal 2021-02-04 20:08:07 +00:00 committed by GitHub
commit e6565a4486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 39 additions and 36 deletions

View File

@ -76,7 +76,7 @@ public:
* @param product_id Your product_id * @param product_id Your product_id
* @param product_release Your preoduct_release * @param product_release Your preoduct_release
*/ */
USBMSD(BlockDevice *bd, bool connect_blocking = true, uint16_t vendor_id = 0x0703, uint16_t product_id = 0x0104, uint16_t product_release = 0x0001); USBMSD(mbed::BlockDevice *bd, bool connect_blocking = true, uint16_t vendor_id = 0x0703, uint16_t product_id = 0x0104, uint16_t product_release = 0x0001);
/** /**
* Fully featured constructor * Fully featured constructor
@ -95,7 +95,7 @@ public:
* @param product_id Your product_id * @param product_id Your product_id
* @param product_release Your preoduct_release * @param product_release Your preoduct_release
*/ */
USBMSD(USBPhy *phy, BlockDevice *bd, uint16_t vendor_id, uint16_t product_id, uint16_t product_release); USBMSD(USBPhy *phy, mbed::BlockDevice *bd, uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
/** /**
* Destroy this object * Destroy this object
@ -263,7 +263,7 @@ private:
events::Task<void(const setup_packet_t *)> _control_task; events::Task<void(const setup_packet_t *)> _control_task;
events::Task<void()> _configure_task; events::Task<void()> _configure_task;
BlockDevice *_bd; mbed::BlockDevice *_bd;
rtos::Mutex _mutex_init; rtos::Mutex _mutex_init;
rtos::Mutex _mutex; rtos::Mutex _mutex;

View File

@ -21,17 +21,17 @@
#include "platform/Callback.h" #include "platform/Callback.h"
PolledQueue::PolledQueue(mbed::Callback<void()> cb): _cb(cb) events::PolledQueue::PolledQueue(mbed::Callback<void()> cb): _cb(cb)
{ {
} }
PolledQueue::~PolledQueue() events::PolledQueue::~PolledQueue()
{ {
} }
void PolledQueue::dispatch() void events::PolledQueue::dispatch()
{ {
core_util_critical_section_enter(); core_util_critical_section_enter();
uint64_t buf[MBED_MAX_TASK_SIZE / sizeof(uint64_t)]; uint64_t buf[MBED_MAX_TASK_SIZE / sizeof(uint64_t)];
@ -60,7 +60,7 @@ void PolledQueue::dispatch()
core_util_critical_section_exit(); core_util_critical_section_exit();
} }
void PolledQueue::attach(mbed::Callback<void()> cb) void events::PolledQueue::attach(mbed::Callback<void()> cb)
{ {
core_util_critical_section_enter(); core_util_critical_section_enter();
@ -69,7 +69,7 @@ void PolledQueue::attach(mbed::Callback<void()> cb)
core_util_critical_section_exit(); core_util_critical_section_exit();
} }
void PolledQueue::post(TaskBase *task) void events::PolledQueue::post(TaskBase *task)
{ {
core_util_critical_section_enter(); core_util_critical_section_enter();
@ -83,7 +83,7 @@ void PolledQueue::post(TaskBase *task)
core_util_critical_section_exit(); core_util_critical_section_exit();
} }
void PolledQueue::cancel(TaskBase *task) void events::PolledQueue::cancel(TaskBase *task)
{ {
core_util_critical_section_enter(); core_util_critical_section_enter();

View File

@ -21,6 +21,8 @@
#include "rtos/Semaphore.h" #include "rtos/Semaphore.h"
#include "platform/mbed_critical.h" #include "platform/mbed_critical.h"
namespace events {
TaskBase::TaskBase(TaskQueue *q) TaskBase::TaskBase(TaskQueue *q)
: _queue(q), _posted(false), _start_count(0), _flush_sem(NULL) : _queue(q), _posted(false), _start_count(0), _flush_sem(NULL)
{ {
@ -150,3 +152,4 @@ void TaskBase::_wake_check()
_flush_sem = NULL; _flush_sem = NULL;
} }
} }
}

View File

@ -65,7 +65,7 @@ enum Status {
CSW_ERROR, CSW_ERROR,
}; };
USBMSD::USBMSD(BlockDevice *bd, bool connect_blocking, uint16_t vendor_id, uint16_t product_id, uint16_t product_release) USBMSD::USBMSD(mbed::BlockDevice *bd, bool connect_blocking, uint16_t vendor_id, uint16_t product_id, uint16_t product_release)
: USBDevice(get_usb_phy(), vendor_id, product_id, product_release), : USBDevice(get_usb_phy(), vendor_id, product_id, product_release),
_initialized(false), _media_removed(false), _initialized(false), _media_removed(false),
_addr(0), _length(0), _mem_ok(false), _block_size(0), _memory_size(0), _block_count(0), _addr(0), _length(0), _mem_ok(false), _block_size(0), _memory_size(0), _block_count(0),
@ -81,7 +81,7 @@ USBMSD::USBMSD(BlockDevice *bd, bool connect_blocking, uint16_t vendor_id, uint1
} }
} }
USBMSD::USBMSD(USBPhy *phy, BlockDevice *bd, uint16_t vendor_id, uint16_t product_id, uint16_t product_release) USBMSD::USBMSD(USBPhy *phy, mbed::BlockDevice *bd, uint16_t vendor_id, uint16_t product_id, uint16_t product_release)
: USBDevice(phy, vendor_id, product_id, product_release), : USBDevice(phy, vendor_id, product_id, product_release),
_initialized(false), _media_removed(false), _initialized(false), _media_removed(false),
_addr(0), _length(0), _mem_ok(false), _block_size(0), _memory_size(0), _block_count(0), _addr(0), _length(0), _mem_ok(false), _block_size(0), _memory_size(0), _block_count(0),
@ -230,15 +230,15 @@ bool USBMSD::media_removed()
int USBMSD::disk_read(uint8_t *data, uint64_t block, uint8_t count) int USBMSD::disk_read(uint8_t *data, uint64_t block, uint8_t count)
{ {
bd_addr_t addr = block * _bd->get_erase_size(); mbed::bd_addr_t addr = block * _bd->get_erase_size();
bd_size_t size = count * _bd->get_erase_size(); mbed::bd_size_t size = count * _bd->get_erase_size();
return _bd->read(data, addr, size); return _bd->read(data, addr, size);
} }
int USBMSD::disk_write(const uint8_t *data, uint64_t block, uint8_t count) int USBMSD::disk_write(const uint8_t *data, uint64_t block, uint8_t count)
{ {
bd_addr_t addr = block * _bd->get_erase_size(); mbed::bd_addr_t addr = block * _bd->get_erase_size();
bd_size_t size = count * _bd->get_erase_size(); mbed::bd_size_t size = count * _bd->get_erase_size();
int ret = _bd->erase(addr, size); int ret = _bd->erase(addr, size);
if (ret != 0) { if (ret != 0) {
return ret; return ret;

View File

@ -197,7 +197,7 @@ private:
void _write_enable(bool enable); void _write_enable(bool enable);
int _sync(void); int _sync(void);
int _write_page(const uint8_t *buffer, uint32_t addr, uint32_t offset, uint32_t size); int _write_page(const uint8_t *buffer, uint32_t addr, uint32_t offset, uint32_t size);
uint32_t _translate_address(bd_addr_t addr); uint32_t _translate_address(mbed::bd_addr_t addr);
// Mutex for thread safety // Mutex for thread safety
mutable PlatformMutex _mutex; mutable PlatformMutex _mutex;

View File

@ -134,7 +134,7 @@ public:
* @param size Size to erase in bytes * @param size Size to erase in bytes
* @return True if erase is valid for underlying block device * @return True if erase is valid for underlying block device
*/ */
virtual bool is_valid_erase(bd_addr_t addr, bd_size_t size) const; virtual bool is_valid_erase(mbed::bd_addr_t addr, mbed::bd_size_t size) const;
private: private:

View File

@ -72,7 +72,7 @@ public:
*/ */
I2CEEBlockDevice( I2CEEBlockDevice(
PinName sda, PinName scl, uint8_t address, PinName sda, PinName scl, uint8_t address,
bd_size_t size, bd_size_t block = 32, mbed::bd_size_t size, mbed::bd_size_t block = 32,
int bus_speed = 400000, int bus_speed = 400000,
bool address_is_eight_bit = false); bool address_is_eight_bit = false);
@ -89,7 +89,7 @@ public:
*/ */
I2CEEBlockDevice( I2CEEBlockDevice(
mbed::I2C *i2c_obj, uint8_t address, mbed::I2C *i2c_obj, uint8_t address,
bd_size_t size, bd_size_t block = 32, mbed::bd_size_t size, mbed::bd_size_t block = 32,
bool address_is_eight_bit = false); bool address_is_eight_bit = false);
/** Destructor of I2CEEBlockDevice /** Destructor of I2CEEBlockDevice
@ -116,7 +116,7 @@ public:
* @param size Size to read in bytes, must be a multiple of read block size * @param size Size to read in bytes, must be a multiple of read block size
* @return 0 on success, negative error code on failure * @return 0 on success, negative error code on failure
*/ */
virtual int read(void *buffer, bd_addr_t addr, bd_size_t size); virtual int read(void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
/** Program blocks to a block device /** Program blocks to a block device
* *
@ -127,7 +127,7 @@ public:
* @param size Size to write in bytes, must be a multiple of program block size * @param size Size to write in bytes, must be a multiple of program block size
* @return 0 on success, negative error code on failure * @return 0 on success, negative error code on failure
*/ */
virtual int program(const void *buffer, bd_addr_t addr, bd_size_t size); virtual int program(const void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
/** Erase blocks on a block device /** Erase blocks on a block device
* *
@ -137,33 +137,33 @@ public:
* @param size Size to erase in bytes, must be a multiple of erase block size * @param size Size to erase in bytes, must be a multiple of erase block size
* @return 0 on success, negative error code on failure * @return 0 on success, negative error code on failure
*/ */
virtual int erase(bd_addr_t addr, bd_size_t size); virtual int erase(mbed::bd_addr_t addr, mbed::bd_size_t size);
/** Get the size of a readable block /** Get the size of a readable block
* *
* @return Size of a readable block in bytes * @return Size of a readable block in bytes
*/ */
virtual bd_size_t get_read_size() const; virtual mbed::bd_size_t get_read_size() const;
/** Get the size of a programable block /** Get the size of a programable block
* *
* @return Size of a programable block in bytes * @return Size of a programable block in bytes
* @note Must be a multiple of the read size * @note Must be a multiple of the read size
*/ */
virtual bd_size_t get_program_size() const; virtual mbed::bd_size_t get_program_size() const;
/** Get the size of a eraseable block /** Get the size of a eraseable block
* *
* @return Size of a eraseable block in bytes * @return Size of a eraseable block in bytes
* @note Must be a multiple of the program size * @note Must be a multiple of the program size
*/ */
virtual bd_size_t get_erase_size() const; virtual mbed::bd_size_t get_erase_size() const;
/** Get the total size of the underlying device /** Get the total size of the underlying device
* *
* @return Size of the underlying device in bytes * @return Size of the underlying device in bytes
*/ */
virtual bd_size_t size() const; virtual mbed::bd_size_t size() const;
/** Get the BlockDevice class type. /** Get the BlockDevice class type.
* *
@ -189,7 +189,7 @@ private:
* @param address An address in the requested page. * @param address An address in the requested page.
* @return The device's I2C address for that page * @return The device's I2C address for that page
*/ */
uint8_t get_paged_device_address(bd_addr_t address); uint8_t get_paged_device_address(mbed::bd_addr_t address);
}; };

View File

@ -68,7 +68,7 @@
*/ */
enum ospif_bd_error { enum ospif_bd_error {
OSPIF_BD_ERROR_OK = 0, /*!< no error */ OSPIF_BD_ERROR_OK = 0, /*!< no error */
OSPIF_BD_ERROR_DEVICE_ERROR = BD_ERROR_DEVICE_ERROR, /*!< device specific error -4001 */ OSPIF_BD_ERROR_DEVICE_ERROR = mbed::BD_ERROR_DEVICE_ERROR, /*!< device specific error -4001 */
OSPIF_BD_ERROR_PARSING_FAILED = -4002, /* SFDP Parsing failed */ OSPIF_BD_ERROR_PARSING_FAILED = -4002, /* SFDP Parsing failed */
OSPIF_BD_ERROR_READY_FAILED = -4003, /* Wait for Mem Ready failed */ OSPIF_BD_ERROR_READY_FAILED = -4003, /* Wait for Mem Ready failed */
OSPIF_BD_ERROR_WREN_FAILED = -4004, /* Write Enable Failed */ OSPIF_BD_ERROR_WREN_FAILED = -4004, /* Write Enable Failed */
@ -331,7 +331,7 @@ private:
ospi_status_t _ospi_set_frequency(int freq); ospi_status_t _ospi_set_frequency(int freq);
// Update the 4-byte addressing extension register with the MSB of the address if it is in use // Update the 4-byte addressing extension register with the MSB of the address if it is in use
ospi_status_t _ospi_update_4byte_ext_addr_reg(bd_addr_t addr); ospi_status_t _ospi_update_4byte_ext_addr_reg(mbed::bd_addr_t addr);
/*********************************/ /*********************************/
/* Flash Configuration Functions */ /* Flash Configuration Functions */

View File

@ -53,7 +53,7 @@
*/ */
enum qspif_bd_error { enum qspif_bd_error {
QSPIF_BD_ERROR_OK = 0, /*!< no error */ QSPIF_BD_ERROR_OK = 0, /*!< no error */
QSPIF_BD_ERROR_DEVICE_ERROR = BD_ERROR_DEVICE_ERROR, /*!< device specific error -4001 */ QSPIF_BD_ERROR_DEVICE_ERROR = mbed::BD_ERROR_DEVICE_ERROR, /*!< device specific error -4001 */
QSPIF_BD_ERROR_PARSING_FAILED = -4002, /* SFDP Parsing failed */ QSPIF_BD_ERROR_PARSING_FAILED = -4002, /* SFDP Parsing failed */
QSPIF_BD_ERROR_READY_FAILED = -4003, /* Wait for Mem Ready failed */ QSPIF_BD_ERROR_READY_FAILED = -4003, /* Wait for Mem Ready failed */
QSPIF_BD_ERROR_WREN_FAILED = -4004, /* Write Enable Failed */ QSPIF_BD_ERROR_WREN_FAILED = -4004, /* Write Enable Failed */
@ -289,7 +289,7 @@ private:
qspi_status_t _qspi_set_frequency(int freq); qspi_status_t _qspi_set_frequency(int freq);
// Update the 4-byte addressing extension register with the MSB of the address if it is in use // Update the 4-byte addressing extension register with the MSB of the address if it is in use
qspi_status_t _qspi_update_4byte_ext_addr_reg(bd_addr_t addr); qspi_status_t _qspi_update_4byte_ext_addr_reg(mbed::bd_addr_t addr);
/*********************************/ /*********************************/
/* Flash Configuration Functions */ /* Flash Configuration Functions */

View File

@ -280,7 +280,7 @@ private:
mbed::sfdp_hdr_info _sfdp_info; mbed::sfdp_hdr_info _sfdp_info;
unsigned int _page_size_bytes; // Page size - 256 Bytes default unsigned int _page_size_bytes; // Page size - 256 Bytes default
bd_size_t _device_size_bytes; mbed::bd_size_t _device_size_bytes;
// Bus configuration // Bus configuration
unsigned int _address_size; // number of bytes for address unsigned int _address_size; // number of bytes for address

View File

@ -147,7 +147,7 @@ int _storage_config_filesystem_common();
* *
* @returns pointer to other block device. * @returns pointer to other block device.
*/ */
BlockDevice *get_other_blockdevice(); mbed::BlockDevice *get_other_blockdevice();
static const char *filesystemstore_folder_path = NULL; static const char *filesystemstore_folder_path = NULL;
@ -559,10 +559,10 @@ BlockDevice *_get_blockdevice_default(bd_addr_t start_address, bd_size_t size)
* get_other_blockdevice() */ * get_other_blockdevice() */
BlockDevice *_get_blockdevice_other(bd_addr_t start_address, bd_size_t size) BlockDevice *_get_blockdevice_other(bd_addr_t start_address, bd_size_t size)
{ {
bd_addr_t aligned_end_address; mbed::bd_addr_t aligned_end_address;
bd_addr_t aligned_start_address; mbed::bd_addr_t aligned_start_address;
BlockDevice *bd = get_other_blockdevice(); mbed::BlockDevice *bd = get_other_blockdevice();
if (bd == NULL) { if (bd == NULL) {
tr_error("KV Config: \"other\" block device init fail"); tr_error("KV Config: \"other\" block device init fail");
return NULL; return NULL;