Skip to content

Commit

Permalink
Merge pull request #12082 from ARMmbed/release-candidate
Browse files Browse the repository at this point in the history
Release candidate for mbed-os-5.15.0-rc2
  • Loading branch information
adbridge authored Dec 12, 2019
2 parents b14f495 + 5d94703 commit 5d7f5bd
Show file tree
Hide file tree
Showing 45 changed files with 321 additions and 234 deletions.
13 changes: 6 additions & 7 deletions TESTS/configs/baremetal.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"requires": [
"bare-metal",
{
"requires": [
"bare-metal",
"rtos-api",
"greentea-client",
"utest",
"greentea-client",
"utest",
"unity",
"psa",
"mbed-crypto",
"mbed-crypto",
"mbedtls",
"psa-compliance-framework",
"filesystem",
Expand Down Expand Up @@ -37,7 +37,6 @@
],
"target_overrides": {
"*": {
"target.device_has_remove": ["EMAC", "USBDEVICE"],
"mbed-trace.fea-ipv6": false
}
}
Expand Down
3 changes: 0 additions & 3 deletions TESTS/integration/COMMON/common_defines_fs_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mbed_trace.h"

#define TRACE_GROUP "GRNT"

#define FS_FAT 1
#define FS_LFS 2
Expand Down
2 changes: 1 addition & 1 deletion TESTS/integration/COMMON/download_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "unity/unity.h"
#include "greentea-client/test_env.h"
#include <string>
#include "common_defines_test.h"
#include "download_test.h"

#define MAX_THREADS 5

Expand Down
4 changes: 4 additions & 0 deletions TESTS/integration/COMMON/download_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
/*
* Based on mbed-stress-test by Marcus Chang @ Arm Mbed - http://github.com/ARMmbed/mbed-stress-test
*/

#include "mbed_trace.h"

#define TRACE_GROUP "GRNT"
size_t download_test(NetworkInterface *interface, const unsigned char *data, size_t data_length, size_t buff_size, uint32_t thread_id = 0);

2 changes: 1 addition & 1 deletion TESTS/integration/COMMON/file_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "mbed.h"
#include "unity/unity.h"
#include "common_defines_test.h"
#include "file_test.h"

void file_test_write(const char *file, size_t offset, const unsigned char *data, size_t data_length, size_t block_size)
{
Expand Down
4 changes: 4 additions & 0 deletions TESTS/integration/COMMON/file_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
/*
* Based on mbed-stress-test by Marcus Chang @ Arm Mbed - http://github.com/ARMmbed/mbed-stress-test
*/
#include "mbed_trace.h"

#define TRACE_GROUP "GRNT"

void file_test_write(const char *file, size_t offset, const unsigned char *data, size_t data_length, size_t block_size);

void file_test_read(const char *file, size_t offset, const unsigned char *data, size_t data_length, size_t block_size);
22 changes: 22 additions & 0 deletions components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,28 @@ SDBlockDevice::SDBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName c
_erase_size = BLOCK_SIZE_HC;
}

#if MBED_CONF_SD_CRC_ENABLED
SDBlockDevice::SDBlockDevice(const spi_pinmap_t &spi_pinmap, PinName cs, uint64_t hz, bool crc_on)
: _sectors(0), _spi(spi_pinmap), _cs(cs), _is_initialized(0),
_init_ref_count(0), _crc_on(crc_on)
#else
SDBlockDevice::SDBlockDevice(const spi_pinmap_t &spi_pinmap, PinName cs, uint64_t hz, bool crc_on)
: _sectors(0), _spi(spi_pinmap), _cs(cs), _is_initialized(0),
_init_ref_count(0)
#endif
{
_cs = 1;
_card_type = SDCARD_NONE;

// Set default to 100kHz for initialisation and 1MHz for data transfer
MBED_STATIC_ASSERT(((MBED_CONF_SD_INIT_FREQUENCY >= 100000) && (MBED_CONF_SD_INIT_FREQUENCY <= 400000)),
"Initialization frequency should be between 100KHz to 400KHz");
_init_sck = MBED_CONF_SD_INIT_FREQUENCY;
_transfer_sck = hz;

_erase_size = BLOCK_SIZE_HC;
}

SDBlockDevice::~SDBlockDevice()
{
if (_is_initialized) {
Expand Down
12 changes: 11 additions & 1 deletion components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
#include "drivers/DigitalOut.h"
#include "platform/platform.h"
#include "platform/PlatformMutex.h"
#include "hal/static_pinmap.h"

/** SDBlockDevice class
*
* Access an SD Card using SPI bus
*/
class SDBlockDevice : public mbed::BlockDevice {
public:
/** Creates an SDBlockDevice on a SPI bus specified by pins
/** Creates an SDBlockDevice on a SPI bus specified by pins (using dynamic pin-map)
*
* @param mosi SPI master out, slave in pin
* @param miso SPI master in, slave out pin
Expand All @@ -44,6 +45,15 @@ class SDBlockDevice : public mbed::BlockDevice {
* @param crc_on Enable cyclic redundancy check (defaults to disabled)
*/
SDBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName cs, uint64_t hz = 1000000, bool crc_on = 0);

/** Creates an SDBlockDevice on a SPI bus specified by pins (using static pin-map)
*
* @param spi_pinmap Static SPI pin-map
* @param hz Clock speed of the SPI bus (defaults to 1MHz)
* @param crc_on Enable cyclic redundancy check (defaults to disabled)
*/
SDBlockDevice(const spi_pinmap_t &spi_pinmap, PinName cs, uint64_t hz = 1000000, bool crc_on = 0);

virtual ~SDBlockDevice();

/** Initialize a block device
Expand Down
27 changes: 17 additions & 10 deletions drivers/SerialBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ class SerialBase : private NonCopyable<SerialBase> {
/** Initialize serial port
*/
void _init();
void _init_direct();
/* Pointer to serial init function */
void (SerialBase::*_init_func)();

/** Deinitialize serial port
*/
Expand All @@ -345,18 +348,22 @@ class SerialBase : private NonCopyable<SerialBase> {
bool _rx_asynch_set = false;
#endif

serial_t _serial {};
Callback<void()> _irq[IrqCnt];
int _baud;
bool _rx_enabled = true;
bool _tx_enabled = true;
const PinName _tx_pin;
const PinName _rx_pin;
serial_t _serial {};
Callback<void()> _irq[IrqCnt];
int _baud;
bool _rx_enabled = true;
bool _tx_enabled = true;
const PinName _tx_pin;
const PinName _rx_pin;
const serial_pinmap_t *_static_pinmap = NULL;
void (SerialBase::*_set_flow_control_dp_func)(Flow, PinName, PinName) = NULL;

#if DEVICE_SERIAL_FC
Flow _flow_type = Disabled;
PinName _flow1 = NC;
PinName _flow2 = NC;
Flow _flow_type = Disabled;
PinName _flow1 = NC;
PinName _flow2 = NC;
const serial_fc_pinmap_t *_static_pinmap_fc = NULL;
void (SerialBase::*_set_flow_control_sp_func)(Flow, const serial_fc_pinmap_t &) = NULL;
#endif

#endif
Expand Down
41 changes: 31 additions & 10 deletions drivers/source/SerialBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ SerialBase::SerialBase(PinName tx, PinName rx, int baud) :
#endif
_baud(baud),
_tx_pin(tx),
_rx_pin(rx)
_rx_pin(rx),
_init_func(&SerialBase::_init)
{
// No lock needed in the constructor

for (size_t i = 0; i < sizeof _irq / sizeof _irq[0]; i++) {
_irq[i] = NULL;
}

_init();
(this->*_init_func)();
}

SerialBase::SerialBase(const serial_pinmap_t &static_pinmap, int baud) :
Expand All @@ -50,17 +51,17 @@ SerialBase::SerialBase(const serial_pinmap_t &static_pinmap, int baud) :
_serial(),
_baud(baud),
_tx_pin(static_pinmap.tx_pin),
_rx_pin(static_pinmap.rx_pin)
_rx_pin(static_pinmap.rx_pin),
_static_pinmap(&static_pinmap),
_init_func(&SerialBase::_init_direct)
{
// No lock needed in the constructor

for (size_t i = 0; i < sizeof _irq / sizeof _irq[0]; i++) {
_irq[i] = NULL;
}

serial_init_direct(&_serial, &static_pinmap);
serial_baud(&_serial, _baud);
serial_irq_handler(&_serial, SerialBase::_irq_handler, (uint32_t)this);
(this->*_init_func)();
}

void SerialBase::baud(int baudrate)
Expand Down Expand Up @@ -150,7 +151,21 @@ void SerialBase::_init()
{
serial_init(&_serial, _tx_pin, _rx_pin);
#if DEVICE_SERIAL_FC
set_flow_control(_flow_type, _flow1, _flow2);
if (_set_flow_control_dp_func) {
(this->*_set_flow_control_dp_func)(_flow_type, _flow1, _flow2);
}
#endif
serial_baud(&_serial, _baud);
serial_irq_handler(&_serial, SerialBase::_irq_handler, (uint32_t)this);
}

void SerialBase::_init_direct()
{
serial_init_direct(&_serial, _static_pinmap);
#if DEVICE_SERIAL_FC
if (_static_pinmap_fc && _set_flow_control_dp_func) {
(this->*_set_flow_control_sp_func)(_flow_type, *_static_pinmap_fc);
}
#endif
serial_baud(&_serial, _baud);
serial_irq_handler(&_serial, SerialBase::_irq_handler, (uint32_t)this);
Expand All @@ -166,7 +181,7 @@ void SerialBase::enable_input(bool enable)
lock();
if (_rx_enabled != enable) {
if (enable && !_tx_enabled) {
_init();
(this->*_init_func)();
}

core_util_critical_section_enter();
Expand Down Expand Up @@ -203,7 +218,7 @@ void SerialBase::enable_output(bool enable)
lock();
if (_tx_enabled != enable) {
if (enable && !_rx_enabled) {
_init();
(this->*_init_func)();
}

core_util_critical_section_enter();
Expand Down Expand Up @@ -289,6 +304,8 @@ SerialBase::~SerialBase()
#if DEVICE_SERIAL_FC
void SerialBase::set_flow_control(Flow type, PinName flow1, PinName flow2)
{
MBED_ASSERT(_static_pinmap == NULL); // this function must be used when serial object has been created using dynamic pin-map constructor
_set_flow_control_dp_func = &SerialBase::set_flow_control;
lock();

_flow_type = type;
Expand Down Expand Up @@ -318,9 +335,13 @@ void SerialBase::set_flow_control(Flow type, PinName flow1, PinName flow2)

void SerialBase::set_flow_control(Flow type, const serial_fc_pinmap_t &static_pinmap)
{
MBED_ASSERT(_static_pinmap != NULL); // this function must be used when serial object has been created using static pin-map constructor
_set_flow_control_sp_func = &SerialBase::set_flow_control;
lock();
_static_pinmap_fc = &static_pinmap;
_flow_type = type;
FlowControl flow_type = (FlowControl)type;
serial_set_flow_control_direct(&_serial, flow_type, &static_pinmap);
serial_set_flow_control_direct(&_serial, flow_type, _static_pinmap_fc);
unlock();
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cb_uint32 handleWlanTargetGetDataFrameSize(cbWLANTARGET_dataFrame* frame);
cb_uint8 handleWlanTargetGetDataFrameTID(cbWLANTARGET_dataFrame* frame);
void handleWlanStatusIndication(void *dummy, cbWLAN_StatusIndicationInfo status, void *data);
void handleWlanPacketIndication(void *dummy, cbWLAN_PacketIndicationInfo *packetInfo);
void send_wlan_packet(void *buf);
void send_wlan_packet(OdinWiFiEMAC *ptr, void *buf);

static const cbWLANTARGET_Callback _wlanTargetCallback =
{
Expand Down Expand Up @@ -202,9 +202,19 @@ OdinWiFiEMAC::OdinWiFiEMAC()
cbWLANTARGET_registerCallbacks((cbWLANTARGET_Callback*)&_wlanTargetCallback);
}

void send_wlan_packet(void *buf)
cbWLAN_Handle OdinWiFiEMAC::get_wifi_emac_handle()
{
cbWLAN_sendPacket(cbWLAN_DEFAULT_HANDLE, buf);
return this->handle;
}

void OdinWiFiEMAC::set_wifi_emac_handle(cbWLAN_Handle _handle)
{
this->handle = _handle;
}

void send_wlan_packet(OdinWiFiEMAC *ptr, void *buf)
{
cbWLAN_sendPacket(ptr->handle, buf);
}

bool OdinWiFiEMAC::link_out(emac_mem_buf_t *buf)
Expand All @@ -215,7 +225,7 @@ bool OdinWiFiEMAC::link_out(emac_mem_buf_t *buf)
emac_mem_buf_t *new_buf = mem->alloc_pool(mem->get_total_len(buf), 0);
if (new_buf != NULL) {
mem->copy(new_buf, buf);
int id = cbMAIN_getEventQueue()->call(send_wlan_packet, new_buf);
int id = cbMAIN_getEventQueue()->call(send_wlan_packet, this, new_buf);
if (id != 0) {
cbMAIN_dispatchEventQueue();
} else {
Expand Down Expand Up @@ -262,9 +272,8 @@ void OdinWiFiEMAC::set_hwaddr(const uint8_t *addr)
void OdinWiFiEMAC::set_link_input_cb(emac_link_input_cb_t input_cb)
{
emac_link_input_cb = input_cb;

cbMAIN_driverLock();
cbWLAN_registerPacketIndicationCallback(cbWLAN_DEFAULT_HANDLE, handleWlanPacketIndication, NULL);
cbWLAN_registerPacketIndicationCallback(get_wifi_emac_handle(), handleWlanPacketIndication, NULL);
cbMAIN_driverUnlock();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@ class OdinWiFiEMAC : public EMAC {
virtual void remove_multicast_group(const uint8_t *address);
virtual void set_all_multicast(bool all);

cbWLAN_Handle get_wifi_emac_handle();
void set_wifi_emac_handle(cbWLAN_Handle _handle);

private:

cbWLAN_Handle handle = cbWLAN_DEFAULT_HANDLE;

emac_link_input_cb_t emac_link_input_cb; /**< Callback for incoming data */
emac_link_state_change_cb_t emac_link_state_cb; /**< Link state change callback */
EMACMemoryManager *memory_manager;
Expand All @@ -138,7 +143,7 @@ class OdinWiFiEMAC : public EMAC {

friend void handleWlanStatusIndication(void *dummy, cbWLAN_StatusIndicationInfo status, void *data);
friend void handleWlanPacketIndication(void *dummy, cbWLAN_PacketIndicationInfo *packetInfo);
friend void send_wlan_packet(void *buf);
friend void send_wlan_packet(OdinWiFiEMAC *ptr, void *buf);
};

#endif /* WIFI_EMAC_H_ */
11 changes: 11 additions & 0 deletions features/storage/kvstore/conf/kv_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@

#if COMPONENT_SD
#include "components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h"

#if (STATIC_PINMAP_READY)
constexpr spi_pinmap_t static_spi_pinmap = get_spi_pinmap(MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, NC);
#endif
#endif

/**
Expand Down Expand Up @@ -564,12 +568,19 @@ BlockDevice *_get_blockdevice_SD(bd_addr_t start_address, bd_size_t size)
bd_addr_t aligned_end_address;
bd_addr_t aligned_start_address;

#if (STATIC_PINMAP_READY)
static SDBlockDevice bd(
static_spi_pinmap,
MBED_CONF_SD_SPI_CS
);
#else
static SDBlockDevice bd(
MBED_CONF_SD_SPI_MOSI,
MBED_CONF_SD_SPI_MISO,
MBED_CONF_SD_SPI_CLK,
MBED_CONF_SD_SPI_CS
);
#endif

if (bd.init() != MBED_SUCCESS) {
tr_error("KV Config: SDBlockDevice init fail");
Expand Down
Loading

0 comments on commit 5d7f5bd

Please sign in to comment.