Skip to content

Give an option to remove 'using namespace' #7760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <inttypes.h>

using namespace mbed;

/* constants */
#define DATAFLASH_READ_SIZE 1
#define DATAFLASH_PROG_SIZE 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
* }
* @endcode
*/
class DataFlashBlockDevice : public BlockDevice {
class DataFlashBlockDevice : public mbed::BlockDevice {
public:
/** Creates a DataFlashBlockDevice on a SPI bus specified by pins
*
Expand Down Expand Up @@ -96,7 +96,7 @@ class DataFlashBlockDevice : public BlockDevice {
* @param size Size to read in bytes, must be a multiple of read block size
* @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
*
Expand All @@ -107,7 +107,7 @@ class DataFlashBlockDevice : public BlockDevice {
* @param size Size to write in bytes, must be a multiple of program block size
* @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
*
Expand All @@ -117,47 +117,47 @@ class DataFlashBlockDevice : public BlockDevice {
* @param size Size to erase in bytes, must be a multiple of erase block size
* @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
*
* @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
*
* @return Size of a programable block in bytes
* @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
*
* @return Size of a eraseable block in bytes
* @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 size of an erasable block given address
*
* @param addr Address within the erasable block
* @return Size of an erasable block in bytes
* @note Must be a multiple of the program size
*/
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr) const;

/** Get the total size of the underlying device
*
* @return Size of the underlying device in bytes
*/
virtual bd_size_t size() const;
virtual mbed::bd_size_t size() const;

private:
// Master side hardware
SPI _spi;
DigitalOut _cs;
DigitalOut _nwp;
mbed::SPI _spi;
mbed::DigitalOut _cs;
mbed::DigitalOut _nwp;

// Device configuration
uint32_t _device_size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "mbed_critical.h"

#include "mbed.h"

using namespace mbed;
#include <inttypes.h>

#define FLASHIAP_READ_SIZE 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/** BlockDevice using the FlashIAP API
*
*/
class FlashIAPBlockDevice : public BlockDevice {
class FlashIAPBlockDevice : public mbed::BlockDevice {
public:

/** Creates a FlashIAPBlockDevice
Expand Down Expand Up @@ -58,7 +58,7 @@ class FlashIAPBlockDevice : public BlockDevice {
* @param size Size to read in bytes, must be a multiple of read block size
* @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
*
Expand All @@ -69,7 +69,7 @@ class FlashIAPBlockDevice : public BlockDevice {
* @param size Size to write in bytes, must be a multiple of program block size
* @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
*
Expand All @@ -79,35 +79,35 @@ class FlashIAPBlockDevice : public BlockDevice {
* @param size Size to erase in bytes, must be a multiple of erase block size
* @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
*
* @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
*
* @return Size of a programable block in bytes
* @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
*
* @return Size of a eraseable block in bytes
* @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 size of an erasable block given address
*
* @param addr Address within the erasable block
* @return Size of an erasable block in bytes
* @note Must be a multiple of the program size
*/
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr) const;

/** Get the value of storage when erased
*
Expand All @@ -119,13 +119,13 @@ class FlashIAPBlockDevice : public BlockDevice {
*
* @return Size of the underlying device in bytes
*/
virtual bd_size_t size() const;
virtual mbed::bd_size_t size() const;

private:
// Device configuration
mbed::FlashIAP _flash;
bd_addr_t _base;
bd_size_t _size;
mbed::bd_addr_t _base;
mbed::bd_size_t _size;
bool _is_initialized;
uint32_t _init_ref_count;
};
Expand Down
30 changes: 15 additions & 15 deletions components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ enum qspif_polarity_mode {
* }
* @endcode
*/
class QSPIFBlockDevice : public BlockDevice {
class QSPIFBlockDevice : public mbed::BlockDevice {
public:
/** Create QSPIFBlockDevice - An SFDP based Flash Block Device over QSPI bus
*
Expand Down Expand Up @@ -134,7 +134,7 @@ class QSPIFBlockDevice : public BlockDevice {
* @return QSPIF_BD_ERROR_OK(0) - success
* QSPIF_BD_ERROR_DEVICE_ERROR - device driver transaction failed
*/
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
*
Expand All @@ -149,7 +149,7 @@ class QSPIFBlockDevice : public BlockDevice {
* QSPIF_BD_ERROR_WREN_FAILED - Write Enable failed
* QSPIF_BD_ERROR_PARSING_FAILED - unexpected format or values in one of the SFDP tables
*/
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
*
Expand All @@ -164,35 +164,35 @@ class QSPIFBlockDevice : public BlockDevice {
* QSPIF_BD_ERROR_PARSING_FAILED - unexpected format or values in one of the SFDP tables
* QSPIF_BD_ERROR_INVALID_ERASE_PARAMS - Trying to erase unaligned address or size
*/
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
*
* @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
*
* @return Size of a program block size in bytes
* @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
*
* @return Size of a minimal erase block, common to all regions, in bytes
* @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 size of minimal eraseable sector size of given address
*
* @param addr Any address within block queried for erase sector size (can be any address within flash size offset)
* @return Size of minimal erase sector size, in given address region, in bytes
* @note Must be a multiple of the program size
*/
virtual bd_size_t get_erase_size(bd_addr_t addr);
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr);

/** Get the value of storage byte after it was erased
*
Expand All @@ -209,7 +209,7 @@ class QSPIFBlockDevice : public BlockDevice {
*
* @return Size of the underlying device in bytes
*/
virtual bd_size_t size() const;
virtual mbed::bd_size_t size() const;

private:
// Internal functions
Expand All @@ -229,17 +229,17 @@ class QSPIFBlockDevice : public BlockDevice {
/* Calls to QSPI Driver APIs */
/********************************/
// Send Program => Write command to Driver
qspi_status_t _qspi_send_program_command(unsigned int prog_instruction, const void *buffer, bd_addr_t addr,
bd_size_t *size);
qspi_status_t _qspi_send_program_command(unsigned int prog_instruction, const void *buffer, mbed::bd_addr_t addr,
mbed::bd_size_t *size);

// Send Read command to Driver
qspi_status_t _qspi_send_read_command(unsigned int read_instruction, void *buffer, bd_addr_t addr, bd_size_t size);
qspi_status_t _qspi_send_read_command(unsigned int read_instruction, void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);

// Send Erase Instruction using command_transfer command to Driver
qspi_status_t _qspi_send_erase_command(unsigned int erase_instruction, bd_addr_t addr, bd_size_t size);
qspi_status_t _qspi_send_erase_command(unsigned int erase_instruction, mbed::bd_addr_t addr, mbed::bd_size_t size);

// Send Generic command_transfer command to Driver
qspi_status_t _qspi_send_general_command(unsigned int instruction_int, bd_addr_t addr, const char *tx_buffer,
qspi_status_t _qspi_send_general_command(unsigned int instruction_int, mbed::bd_addr_t addr, const char *tx_buffer,
size_t tx_length, const char *rx_buffer, size_t rx_length);

// Send Bus configure_format command to Driver
Expand Down Expand Up @@ -300,7 +300,7 @@ class QSPIFBlockDevice : public BlockDevice {
/* Utilities Functions */
/***********************/
// Find the region to which the given offset belong to
int _utils_find_addr_region(bd_size_t offset);
int _utils_find_addr_region(mbed::bd_size_t offset);

// Iterate on all supported Erase Types of the Region to which the offset belong to.
// Iterates from highest type to lowest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "SPIFReducedBlockDevice.h"
#include "mbed_wait_api.h"

using namespace mbed;

// Read/write/erase sizes
#define SPIF_READ_SIZE 1
#define SPIF_PROG_SIZE 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* }
* @endcode
*/
class SPIFReducedBlockDevice : public BlockDevice {
class SPIFReducedBlockDevice : public mbed::BlockDevice {
public:
/** Creates a SPIFReducedBlockDevice on a SPI bus specified by pins
*
Expand Down Expand Up @@ -87,7 +87,7 @@ class SPIFReducedBlockDevice : public BlockDevice {
* @param size Size to read in bytes, must be a multiple of read block size
* @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
*
Expand All @@ -98,7 +98,7 @@ class SPIFReducedBlockDevice : public BlockDevice {
* @param size Size to write in bytes, must be a multiple of program block size
* @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
*
Expand All @@ -108,35 +108,35 @@ class SPIFReducedBlockDevice : public BlockDevice {
* @param size Size to erase in bytes, must be a multiple of erase block size
* @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
*
* @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
*
* @return Size of a programable block in bytes
* @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
*
* @return Size of a eraseable block in bytes
* @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 size of a eraseable block
*
* @param addr Address of block to query erase size
* @return Size of a eraseable block in bytes
* @note Must be a multiple of the program size
*/
virtual bd_size_t get_erase_size(bd_addr_t addr) const;
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr) const;

/** Get the value of storage byte after it was erased
*
Expand All @@ -153,15 +153,15 @@ class SPIFReducedBlockDevice : public BlockDevice {
*
* @return Size of the underlying device in bytes
*/
virtual bd_size_t size() const;
virtual mbed::bd_size_t size() const;

private:
// Master side hardware
mbed::SPI _spi;
mbed::DigitalOut _cs;

// Device configuration discovered through sfdp
bd_size_t _size;
mbed::bd_size_t _size;

// Internal functions
int _wren();
Expand Down
2 changes: 2 additions & 0 deletions components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
#include <inttypes.h>
#include <errno.h>

using namespace mbed;

#ifndef MBED_CONF_SD_CMD_TIMEOUT
#define MBED_CONF_SD_CMD_TIMEOUT 5000 /*!< Timeout in ms for response */
#endif
Expand Down
Loading