Merge branch 'fix_astyle_error' of ssh://github.com/0xc0170/mbed-os into rollup-b.1

pull/8763/head
Cruz Monrreal II 2018-11-15 18:26:09 -06:00
commit 5c1c7bf71f
84 changed files with 792 additions and 671 deletions

View File

@ -16,6 +16,7 @@ hal/storage_abstraction
TESTS/mbed_hal/trng/pithy
features/nanostack/coap-service
features/nanostack/sal-stack-nanostack
features/nanostack/targets
rtos/TARGET_CORTEX/rtx5
TESTS/mbed_hal/trng/pithy
targets

View File

@ -132,7 +132,9 @@ matrix:
- git diff --name-only $TRAVIS_BRANCH | grep '.*\.\(h\|c\|hpp\|cpp\)' | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-files-changed.out;
if [ $(cat astyle-files-changed.out | grep Formatted | wc -l) -ne 0 ]; then
git --no-pager diff;
echo "Please fix style issues as shown above";
echo "";
echo "AStyle check failed, please fix style issues as shown above";
(exit 1);
else
echo "Coding style check OK";
fi
@ -155,7 +157,6 @@ matrix:
STATUSM="$STATUSM ($(python -c "print '%+d' % ($CURR-$PREV)") files)"
fi
- bash -c "$STATUS" success "$STATUSM"
- env:
- NAME=events
- EVENTS=events

View File

@ -183,7 +183,7 @@ void test_set_time_twice()
/* Set the time to NEW_TIME and check it */
set_time(NEW_TIME);
current_time = time(NULL);
TEST_ASSERT_EQUAL (true, (current_time == NEW_TIME));
TEST_ASSERT_EQUAL(true, (current_time == NEW_TIME));
/* Wait 2 seconds */
wait_ms(2000);
@ -191,7 +191,7 @@ void test_set_time_twice()
/* set the time to NEW_TIME again and check it */
set_time(NEW_TIME);
current_time = time(NULL);
TEST_ASSERT_EQUAL (true, (current_time == NEW_TIME));
TEST_ASSERT_EQUAL(true, (current_time == NEW_TIME));
}
Case cases[] = {

View File

@ -26,7 +26,8 @@ class stubInternetSocket : public InternetSocket {
protected:
nsapi_error_t return_value;
public:
stubInternetSocket() {
stubInternetSocket()
{
return_value = 0;
}
virtual nsapi_error_t connect(const SocketAddress &address)

View File

@ -20,8 +20,8 @@
using namespace mbed;
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
AT_CellularBase(at), _ip_stack_type_requested(DEFAULT_STACK), _is_connected(false), _is_blocking(true),
_current_op(OP_INVALID), _device(device), _nw(0), _fh(0)
AT_CellularBase(at), _ip_stack_type_requested(DEFAULT_STACK), _is_connected(false), _is_blocking(true),
_current_op(OP_INVALID), _device(device), _nw(0), _fh(0)
{
_stack = NULL;
_ip_stack_type = DEFAULT_STACK;
@ -115,7 +115,7 @@ void AT_CellularContext::set_sim_pin(const char *sim_pin)
}
nsapi_error_t AT_CellularContext::connect(const char *sim_pin, const char *apn, const char *uname,
const char *pwd)
const char *pwd)
{
return NSAPI_ERROR_OK;
}
@ -173,7 +173,7 @@ bool AT_CellularContext::set_new_context(int cid)
nsapi_error_t AT_CellularContext::do_activate_context()
{
return NSAPI_ERROR_OK;
return NSAPI_ERROR_OK;
}
void AT_CellularContext::do_connect()

View File

@ -26,8 +26,8 @@ MBED_WEAK CellularDevice *CellularDevice::get_default_instance()
return NULL;
}
CellularDevice::CellularDevice(FileHandle *fh) : _network_ref_count(0), _sms_ref_count(0),_power_ref_count(0), _sim_ref_count(0),
_info_ref_count(0), _fh(fh), _queue(5 * EVENTS_EVENT_SIZE), _state_machine(0), _nw(0)
CellularDevice::CellularDevice(FileHandle *fh) : _network_ref_count(0), _sms_ref_count(0), _power_ref_count(0), _sim_ref_count(0),
_info_ref_count(0), _fh(fh), _queue(5 * EVENTS_EVENT_SIZE), _state_machine(0), _nw(0)
{
}
@ -41,11 +41,11 @@ events::EventQueue *CellularDevice::get_queue()
return NULL;
}
void CellularDevice::set_plmn(char const*)
void CellularDevice::set_plmn(char const *)
{
}
void CellularDevice::set_sim_pin(char const*)
void CellularDevice::set_sim_pin(char const *)
{
}

View File

@ -23,7 +23,7 @@
namespace mbed {
CellularStateMachine::CellularStateMachine(CellularDevice &device, events::EventQueue &queue) :
_cellularDevice(device), _queue(queue)
_cellularDevice(device), _queue(queue)
{
}

View File

@ -26,7 +26,8 @@ public:
std::list<nsapi_error_t> return_values;
nsapi_error_t return_value;
NetworkStackstub() {
NetworkStackstub()
{
return_value = 0;
}

View File

@ -182,7 +182,7 @@ int QSPIFBlockDevice::init()
}
// Soft Reset
if ( -1 == _reset_flash_mem()) {
if (-1 == _reset_flash_mem()) {
tr_error("Init - Unable to initialize flash memory, tests failed");
status = QSPIF_BD_ERROR_DEVICE_ERROR;
goto exit_point;
@ -192,7 +192,7 @@ int QSPIFBlockDevice::init()
/* Read Manufacturer ID (1byte), and Device ID (2bytes)*/
qspi_status = _qspi_send_general_command(QSPIF_RDID, QSPI_NO_ADDRESS_COMMAND, NULL, 0, (char *)vendor_device_ids,
data_length);
data_length);
if (qspi_status != QSPI_STATUS_OK) {
tr_error("Init - Read Vendor ID Failed");
status = QSPIF_BD_ERROR_DEVICE_ERROR;
@ -211,21 +211,21 @@ int QSPIFBlockDevice::init()
}
//Synchronize Device
if ( false == _is_mem_ready()) {
if (false == _is_mem_ready()) {
tr_error("Init - _is_mem_ready Failed");
status = QSPIF_BD_ERROR_READY_FAILED;
goto exit_point;
}
/**************************** Parse SFDP Header ***********************************/
if ( 0 != _sfdp_parse_sfdp_headers(basic_table_addr, basic_table_size, sector_map_table_addr, sector_map_table_size)) {
if (0 != _sfdp_parse_sfdp_headers(basic_table_addr, basic_table_size, sector_map_table_addr, sector_map_table_size)) {
tr_error("Init - Parse SFDP Headers Failed");
status = QSPIF_BD_ERROR_PARSING_FAILED;
goto exit_point;
}
/**************************** Parse Basic Parameters Table ***********************************/
if ( 0 != _sfdp_parse_basic_param_table(basic_table_addr, basic_table_size) ) {
if (0 != _sfdp_parse_basic_param_table(basic_table_addr, basic_table_size)) {
tr_error("Init - Parse Basic Param Table Failed");
status = QSPIF_BD_ERROR_PARSING_FAILED;
goto exit_point;
@ -236,10 +236,10 @@ int QSPIFBlockDevice::init()
_device_size_bytes; // If there's no region map, we have a single region sized the entire device size
_region_high_boundary[0] = _device_size_bytes - 1;
if ( (sector_map_table_addr != 0) && (0 != sector_map_table_size) ) {
if ((sector_map_table_addr != 0) && (0 != sector_map_table_size)) {
tr_info("Init - Parsing Sector Map Table - addr: 0x%lxh, Size: %d", sector_map_table_addr,
sector_map_table_size);
if (0 != _sfdp_parse_sector_map_table(sector_map_table_addr, sector_map_table_size) ) {
if (0 != _sfdp_parse_sector_map_table(sector_map_table_addr, sector_map_table_size)) {
tr_error("Init - Parse Sector Map Table Failed");
status = QSPIF_BD_ERROR_PARSING_FAILED;
goto exit_point;
@ -348,7 +348,7 @@ int QSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
}
result = _qspi_send_program_command(_prog_instruction, buffer, addr, &written_bytes);
if ( (result != QSPI_STATUS_OK) || (chunk != written_bytes) ) {
if ((result != QSPI_STATUS_OK) || (chunk != written_bytes)) {
tr_error("Write failed");
program_failed = true;
status = QSPIF_BD_ERROR_DEVICE_ERROR;
@ -359,7 +359,7 @@ int QSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
addr += chunk;
size -= chunk;
if ( false == _is_mem_ready()) {
if (false == _is_mem_ready()) {
tr_error("Device not ready after write, failed");
program_failed = true;
status = QSPIF_BD_ERROR_READY_FAILED;
@ -397,7 +397,7 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
return QSPIF_BD_ERROR_INVALID_ERASE_PARAMS;
}
if ( ((addr % get_erase_size(addr)) != 0 ) || (((addr + in_size) % get_erase_size(addr + in_size - 1)) != 0 ) ) {
if (((addr % get_erase_size(addr)) != 0) || (((addr + in_size) % get_erase_size(addr + in_size - 1)) != 0)) {
tr_error("Invalid erase - unaligned address and size");
return QSPIF_BD_ERROR_INVALID_ERASE_PARAMS;
}
@ -409,7 +409,7 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
type = _utils_iterate_next_largest_erase_type(bitfield, size, (int)addr, _region_high_boundary[region]);
cur_erase_inst = _erase_type_inst_arr[type];
offset = addr % _erase_type_size_arr[type];
chunk = ( (offset + size) < _erase_type_size_arr[type]) ? size : (_erase_type_size_arr[type] - offset);
chunk = ((offset + size) < _erase_type_size_arr[type]) ? size : (_erase_type_size_arr[type] - offset);
tr_debug("Erase - addr: %llu, size:%d, Inst: 0x%xh, chunk: %lu ",
addr, size, cur_erase_inst, chunk);
@ -425,7 +425,7 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
goto exit_point;
}
if (QSPI_STATUS_OK != _qspi_send_erase_command(cur_erase_inst, addr, size) ) {
if (QSPI_STATUS_OK != _qspi_send_erase_command(cur_erase_inst, addr, size)) {
tr_error("QSPI Erase command failed!");
erase_failed = true;
status = QSPIF_BD_ERROR_DEVICE_ERROR;
@ -435,13 +435,13 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
addr += chunk;
size -= chunk;
if ( (size > 0) && (addr > _region_high_boundary[region]) ) {
if ((size > 0) && (addr > _region_high_boundary[region])) {
// erase crossed to next region
region++;
bitfield = _region_erase_types_bitfield[region];
}
if ( false == _is_mem_ready()) {
if (false == _is_mem_ready()) {
tr_error("QSPI After Erase Device not ready - failed");
erase_failed = true;
status = QSPIF_BD_ERROR_READY_FAILED;
@ -525,7 +525,7 @@ int QSPIFBlockDevice::get_erase_value() const
static PinName *generate_initialized_active_qspif_csel_arr()
{
PinName *init_arr = new PinName[QSPIF_MAX_ACTIVE_FLASH_DEVICES];
for ( int i_ind = 0; i_ind < QSPIF_MAX_ACTIVE_FLASH_DEVICES; i_ind++ ) {
for (int i_ind = 0; i_ind < QSPIF_MAX_ACTIVE_FLASH_DEVICES; i_ind++) {
init_arr[i_ind] = NC;
}
return init_arr;
@ -535,13 +535,13 @@ int QSPIFBlockDevice::add_new_csel_instance(PinName csel)
{
int status = 0;
_devices_mutex->lock();
if (_number_of_active_qspif_flash_csel >= QSPIF_MAX_ACTIVE_FLASH_DEVICES ) {
if (_number_of_active_qspif_flash_csel >= QSPIF_MAX_ACTIVE_FLASH_DEVICES) {
status = -2;
goto exit_point;
}
// verify the device is unique(no identical csel already exists)
for ( int i_ind = 0; i_ind < QSPIF_MAX_ACTIVE_FLASH_DEVICES; i_ind++ ) {
for (int i_ind = 0; i_ind < QSPIF_MAX_ACTIVE_FLASH_DEVICES; i_ind++) {
if (_active_qspif_flash_csel_arr[i_ind] == csel) {
status = -1;
goto exit_point;
@ -549,7 +549,7 @@ int QSPIFBlockDevice::add_new_csel_instance(PinName csel)
}
// Insert new csel into existing device list
for ( int i_ind = 0; i_ind < QSPIF_MAX_ACTIVE_FLASH_DEVICES; i_ind++ ) {
for (int i_ind = 0; i_ind < QSPIF_MAX_ACTIVE_FLASH_DEVICES; i_ind++) {
if (_active_qspif_flash_csel_arr[i_ind] == NC) {
_active_qspif_flash_csel_arr[i_ind] = csel;
break;
@ -567,7 +567,7 @@ int QSPIFBlockDevice::remove_csel_instance(PinName csel)
int status = -1;
_devices_mutex->lock();
// remove the csel from existing device list
for ( int i_ind = 0; i_ind < QSPIF_MAX_ACTIVE_FLASH_DEVICES; i_ind++ ) {
for (int i_ind = 0; i_ind < QSPIF_MAX_ACTIVE_FLASH_DEVICES; i_ind++) {
if (_active_qspif_flash_csel_arr[i_ind] == csel) {
_active_qspif_flash_csel_arr[i_ind] = NC;
if (_number_of_active_qspif_flash_csel > 0) {
@ -595,14 +595,14 @@ int QSPIFBlockDevice::_sfdp_parse_sector_map_table(uint32_t sector_map_table_add
qspi_status_t status = _qspi_send_read_command(QSPIF_SFDP, (char *)sector_map_table, sector_map_table_addr /*address*/,
sector_map_table_size);
sector_map_table_size);
if (status != QSPI_STATUS_OK) {
tr_error("Init - Read SFDP First Table Failed");
return -1;
}
// Currently we support only Single Map Descriptor
if (! ( (sector_map_table[0] & 0x3) == 0x03 ) && (sector_map_table[1] == 0x0) ) {
if (!((sector_map_table[0] & 0x3) == 0x03) && (sector_map_table[1] == 0x0)) {
tr_error("Sector Map - Supporting Only Single! Map Descriptor (not map commands)");
return -1;
}
@ -648,7 +648,7 @@ int QSPIFBlockDevice::_sfdp_parse_basic_param_table(uint32_t basic_table_addr, s
uint8_t param_table[SFDP_DEFAULT_BASIC_PARAMS_TABLE_SIZE_BYTES]; /* Up To 16 DWORDS = 64 Bytes */
qspi_status_t status = _qspi_send_read_command(QSPIF_SFDP, (char *)param_table, basic_table_addr /*address*/,
basic_table_size);
basic_table_size);
if (status != QSPI_STATUS_OK) {
tr_error("Init - Read SFDP First Table Failed");
return -1;
@ -664,8 +664,8 @@ int QSPIFBlockDevice::_sfdp_parse_basic_param_table(uint32_t basic_table_addr, s
uint32_t density_bits = (
(param_table[7] << 24) |
(param_table[6] << 16) |
(param_table[5] << 8 ) |
param_table[4] );
(param_table[5] << 8) |
param_table[4]);
_device_size_bytes = (density_bits + 1) / 8;
// Set Default read/program/erase Instructions
@ -704,8 +704,8 @@ int QSPIFBlockDevice::_sfdp_parse_basic_param_table(uint32_t basic_table_addr, s
return 0;
}
int QSPIFBlockDevice::_sfdp_parse_sfdp_headers(uint32_t& basic_table_addr, size_t& basic_table_size,
uint32_t& sector_map_table_addr, size_t& sector_map_table_size)
int QSPIFBlockDevice::_sfdp_parse_sfdp_headers(uint32_t &basic_table_addr, size_t &basic_table_size,
uint32_t &sector_map_table_addr, size_t &sector_map_table_size)
{
uint8_t sfdp_header[QSPIF_SFDP_HEADER_SIZE];
uint8_t param_header[QSPIF_PARAM_HEADER_SIZE];
@ -758,14 +758,14 @@ int QSPIFBlockDevice::_sfdp_parse_sfdp_headers(uint32_t& basic_table_addr, size_
if ((param_header[0] == 0) && (param_header[7] == 0xFF)) {
// Found Basic Params Table: LSB=0x00, MSB=0xFF
tr_debug("Found Basic Param Table at Table: %d", i_ind + 1);
basic_table_addr = ( (param_header[6] << 16) | (param_header[5] << 8) | (param_header[4]) );
basic_table_addr = ((param_header[6] << 16) | (param_header[5] << 8) | (param_header[4]));
// Supporting up to 64 Bytes Table (16 DWORDS)
basic_table_size = ((param_header[3] * 4) < SFDP_DEFAULT_BASIC_PARAMS_TABLE_SIZE_BYTES) ? (param_header[3] * 4) : 64;
} else if ((param_header[0] == 81) && (param_header[7] == 0xFF)) {
// Found Sector Map Table: LSB=0x81, MSB=0xFF
tr_debug("Found Sector Map Table at Table: %d", i_ind + 1);
sector_map_table_addr = ( (param_header[6] << 16) | (param_header[5] << 8) | (param_header[4]) );
sector_map_table_addr = ((param_header[6] << 16) | (param_header[5] << 8) | (param_header[4]));
sector_map_table_size = param_header[3] * 4;
}
@ -780,43 +780,43 @@ int QSPIFBlockDevice::_sfdp_set_qpi_enabled(uint8_t *basic_param_table_ptr)
uint8_t config_reg[1];
// QPI 4-4-4 Enable Procedure is specified in 5 Bits
uint8_t en_seq_444_value = ( ((basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_444_MODE_EN_SEQ_BYTE] & 0xF0) >> 4) | ((
basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_444_MODE_EN_SEQ_BYTE + 1] & 0x01) << 4 ));
uint8_t en_seq_444_value = (((basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_444_MODE_EN_SEQ_BYTE] & 0xF0) >> 4) | ((
basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_444_MODE_EN_SEQ_BYTE + 1] & 0x01) << 4));
switch (en_seq_444_value) {
case 1:
case 2:
tr_debug("_sfdp_set_qpi_enabled - send command 38h");
if (QSPI_STATUS_OK != _qspi_send_general_command(0x38, QSPI_NO_ADDRESS_COMMAND, NULL, 0, NULL, 0)) {
if (QSPI_STATUS_OK != _qspi_send_general_command(0x38, QSPI_NO_ADDRESS_COMMAND, NULL, 0, NULL, 0)) {
tr_error("_sfdp_set_qpi_enabled - send command 38h Failed");
}
break;
case 4:
tr_debug("_sfdp_set_qpi_enabled - send command 35h");
if (QSPI_STATUS_OK != _qspi_send_general_command(0x35, QSPI_NO_ADDRESS_COMMAND, NULL, 0, NULL, 0)) {
if (QSPI_STATUS_OK != _qspi_send_general_command(0x35, QSPI_NO_ADDRESS_COMMAND, NULL, 0, NULL, 0)) {
tr_error("_sfdp_set_qpi_enabled - send command 35h Failed");
}
break;
case 8:
tr_debug("_sfdp_set_qpi_enabled - set config bit 6 and send command 71h");
if (QSPI_STATUS_OK != _qspi_send_general_command(0x65, 0x800003, NULL, 0, (char *)config_reg, 1)) {
if (QSPI_STATUS_OK != _qspi_send_general_command(0x65, 0x800003, NULL, 0, (char *)config_reg, 1)) {
tr_error("_sfdp_set_qpi_enabled - set config bit 6 command 65h Failed");
}
config_reg[0] |= 0x40; //Set Bit 6
if (QSPI_STATUS_OK != _qspi_send_general_command(0x71, 0x800003, NULL, 0, (char *)config_reg, 1)) {
if (QSPI_STATUS_OK != _qspi_send_general_command(0x71, 0x800003, NULL, 0, (char *)config_reg, 1)) {
tr_error("_sfdp_set_qpi_enabled - send command 71h Failed");
}
break;
case 16:
tr_debug("_sfdp_set_qpi_enabled - reset config bits 0-7 and send command 61h");
if (QSPI_STATUS_OK != _qspi_send_general_command(0x65, QSPI_NO_ADDRESS_COMMAND, NULL, 0, (char *)config_reg, 1)) {
if (QSPI_STATUS_OK != _qspi_send_general_command(0x65, QSPI_NO_ADDRESS_COMMAND, NULL, 0, (char *)config_reg, 1)) {
tr_error("_sfdp_set_qpi_enabled - send command 65h Failed");
}
config_reg[0] &= 0x7F; //Reset Bit 7 of CR
if (QSPI_STATUS_OK != _qspi_send_general_command(0x61, QSPI_NO_ADDRESS_COMMAND, NULL, 0, (char *)config_reg, 1)) {
if (QSPI_STATUS_OK != _qspi_send_general_command(0x61, QSPI_NO_ADDRESS_COMMAND, NULL, 0, (char *)config_reg, 1)) {
tr_error("_sfdp_set_qpi_enabled - send command 61 Failed");
}
break;
@ -883,8 +883,8 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr)
// Read Status Register
if (QSPI_STATUS_OK == _qspi_send_general_command(_read_register_inst, QSPI_NO_ADDRESS_COMMAND, NULL, 0,
status_reg,
sr_read_size) ) { // store received values in status_value
status_reg,
sr_read_size)) { // store received values in status_value
tr_debug("Reading Status Register Success: value = 0x%x", (int)status_reg[0]);
} else {
tr_error("Reading Status Register failed");
@ -903,8 +903,8 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr)
}
if (QSPI_STATUS_OK == _qspi_send_general_command(_write_register_inst, QSPI_NO_ADDRESS_COMMAND, (char *)status_reg,
sr_write_size, NULL,
0) ) { // Write QE to status_register
sr_write_size, NULL,
0)) { // Write QE to status_register
tr_debug("_setQuadEnable - Writing Status Register Success: value = 0x%x",
(int)status_reg[0]);
} else {
@ -912,7 +912,7 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr)
return -1;
}
if ( false == _is_mem_ready()) {
if (false == _is_mem_ready()) {
tr_error("Device not ready after write, failed");
return -1;
}
@ -921,8 +921,8 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr)
// For Debug
memset(status_reg, 0, QSPI_MAX_STATUS_REGISTER_SIZE);
if (QSPI_STATUS_OK == _qspi_send_general_command(_read_register_inst, QSPI_NO_ADDRESS_COMMAND, NULL, 0,
(char *)status_reg,
sr_read_size) ) { // store received values in status_value
(char *)status_reg,
sr_read_size)) { // store received values in status_value
tr_debug("Reading Status Register Success: value = 0x%x", (int)status_reg[0]);
} else {
tr_error("Reading Status Register failed");
@ -938,7 +938,7 @@ int QSPIFBlockDevice::_sfdp_detect_page_size(uint8_t *basic_param_table_ptr, int
if (basic_param_table_size > QSPIF_BASIC_PARAM_TABLE_PAGE_SIZE_BYTE) {
// Page Size is specified by 4 Bits (N), calculated by 2^N
int page_to_power_size = ( (int)basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_PAGE_SIZE_BYTE]) >> 4;
int page_to_power_size = ((int)basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_PAGE_SIZE_BYTE]) >> 4;
page_size = local_math_power(2, page_to_power_size);
tr_debug("Detected Page Size: %d", page_size);
} else {
@ -948,8 +948,8 @@ int QSPIFBlockDevice::_sfdp_detect_page_size(uint8_t *basic_param_table_ptr, int
}
int QSPIFBlockDevice::_sfdp_detect_erase_types_inst_and_size(uint8_t *basic_param_table_ptr, int basic_param_table_size,
unsigned int& erase4k_inst,
unsigned int *erase_type_inst_arr, unsigned int *erase_type_size_arr)
unsigned int &erase4k_inst,
unsigned int *erase_type_inst_arr, unsigned int *erase_type_size_arr)
{
erase4k_inst = 0xff;
bool found_4Kerase_type = false;
@ -963,14 +963,14 @@ int QSPIFBlockDevice::_sfdp_detect_erase_types_inst_and_size(uint8_t *basic_para
for (int i_ind = 0; i_ind < 4; i_ind++) {
erase_type_inst_arr[i_ind] = 0xff; //0xFF default for unsupported type
erase_type_size_arr[i_ind] = local_math_power(2,
basic_param_table_ptr[QSPIF_BASIC_PARAM_ERASE_TYPE_1_SIZE_BYTE + 2 * i_ind]); // Size given as 2^N
basic_param_table_ptr[QSPIF_BASIC_PARAM_ERASE_TYPE_1_SIZE_BYTE + 2 * i_ind]); // Size given as 2^N
tr_info("Erase Type(A) %d - Inst: 0x%xh, Size: %d", (i_ind + 1), erase_type_inst_arr[i_ind],
erase_type_size_arr[i_ind]);
if (erase_type_size_arr[i_ind] > 1) {
// if size==1 type is not supported
erase_type_inst_arr[i_ind] = basic_param_table_ptr[QSPIF_BASIC_PARAM_ERASE_TYPE_1_BYTE + 2 * i_ind];
if ((erase_type_size_arr[i_ind] < _min_common_erase_size) || (_min_common_erase_size == 0) ) {
if ((erase_type_size_arr[i_ind] < _min_common_erase_size) || (_min_common_erase_size == 0)) {
//Set default minimal common erase for singal region
_min_common_erase_size = erase_type_size_arr[i_ind];
}
@ -1001,8 +1001,8 @@ int QSPIFBlockDevice::_sfdp_detect_erase_types_inst_and_size(uint8_t *basic_para
}
int QSPIFBlockDevice::_sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table_ptr, int basic_param_table_size,
bool& set_quad_enable,
bool& is_qpi_mode, unsigned int& read_inst)
bool &set_quad_enable,
bool &is_qpi_mode, unsigned int &read_inst)
{
set_quad_enable = false;
is_qpi_mode = false;
@ -1100,7 +1100,7 @@ int QSPIFBlockDevice::_reset_flash_mem()
tr_info("_reset_flash_mem:");
//Read the Status Register from device
if (QSPI_STATUS_OK == _qspi_send_general_command(QSPIF_RDSR, QSPI_NO_ADDRESS_COMMAND, NULL, 0, status_value,
QSPI_MAX_STATUS_REGISTER_SIZE) ) { // store received values in status_value
QSPI_MAX_STATUS_REGISTER_SIZE)) { // store received values in status_value
tr_debug("Reading Status Register Success: value = 0x%x", (int)status_value[0]);
} else {
tr_error("Reading Status Register failed: value = 0x%x", (int)status_value[0]);
@ -1110,7 +1110,7 @@ int QSPIFBlockDevice::_reset_flash_mem()
if (0 == status) {
//Send Reset Enable
if (QSPI_STATUS_OK == _qspi_send_general_command(QSPIF_RSTEN, QSPI_NO_ADDRESS_COMMAND, NULL, 0, NULL,
0) ) { // store received values in status_value
0)) { // store received values in status_value
tr_debug("Sending RSTEN Success");
} else {
tr_error("Sending RSTEN failed");
@ -1121,7 +1121,7 @@ int QSPIFBlockDevice::_reset_flash_mem()
if (0 == status) {
//Send Reset
if (QSPI_STATUS_OK == _qspi_send_general_command(QSPIF_RST, QSPI_NO_ADDRESS_COMMAND, NULL, 0, NULL,
0)) { // store received values in status_value
0)) { // store received values in status_value
tr_debug("Sending RST Success");
} else {
tr_error("Sending RST failed");
@ -1148,10 +1148,10 @@ bool QSPIFBlockDevice::_is_mem_ready()
//Read the Status Register from device
memset(status_value, 0xFF, QSPI_MAX_STATUS_REGISTER_SIZE);
if (QSPI_STATUS_OK != _qspi_send_general_command(QSPIF_RDSR, QSPI_NO_ADDRESS_COMMAND, NULL, 0, status_value,
QSPI_MAX_STATUS_REGISTER_SIZE)) { // store received values in status_value
QSPI_MAX_STATUS_REGISTER_SIZE)) { // store received values in status_value
tr_error("Reading Status Register failed");
}
} while ( (status_value[0] & QSPIF_STATUS_BIT_WIP) != 0 && retries < IS_MEM_READY_MAX_RETRIES );
} while ((status_value[0] & QSPIF_STATUS_BIT_WIP) != 0 && retries < IS_MEM_READY_MAX_RETRIES);
if ((status_value[0] & QSPIF_STATUS_BIT_WIP) != 0) {
tr_error("_is_mem_ready FALSE: status value = 0x%x ", (int)status_value[0]);
@ -1172,14 +1172,14 @@ int QSPIFBlockDevice::_set_write_enable()
break;
}
if ( false == _is_mem_ready()) {
if (false == _is_mem_ready()) {
tr_error("Device not ready, write failed");
break;
}
memset(status_value, 0, QSPI_MAX_STATUS_REGISTER_SIZE);
if (QSPI_STATUS_OK != _qspi_send_general_command(QSPIF_RDSR, QSPI_NO_ADDRESS_COMMAND, NULL, 0, status_value,
QSPI_MAX_STATUS_REGISTER_SIZE)) { // store received values in status_value
QSPI_MAX_STATUS_REGISTER_SIZE)) { // store received values in status_value
tr_error("Reading Status Register failed");
break;
}
@ -1207,8 +1207,8 @@ int QSPIFBlockDevice::_enable_fast_mdoe()
// Read Status Register
if (QSPI_STATUS_OK == _qspi_send_general_command(read_conf_register_inst, QSPI_NO_ADDRESS_COMMAND, NULL, 0,
&status_reg[1],
QSPI_MAX_STATUS_REGISTER_SIZE - 1) ) { // store received values in status_value
&status_reg[1],
QSPI_MAX_STATUS_REGISTER_SIZE - 1)) { // store received values in status_value
tr_debug("Reading Config Register Success: value = 0x%x", (int)status_reg[2]);
} else {
tr_error("Reading Config Register failed");
@ -1227,8 +1227,8 @@ int QSPIFBlockDevice::_enable_fast_mdoe()
}
if (QSPI_STATUS_OK == _qspi_send_general_command(_write_register_inst, QSPI_NO_ADDRESS_COMMAND, status_reg,
QSPI_MAX_STATUS_REGISTER_SIZE, NULL,
0) ) { // Write Fast mode bit to status_register
QSPI_MAX_STATUS_REGISTER_SIZE, NULL,
0)) { // Write Fast mode bit to status_register
tr_debug("fast mode enable - Writing Config Register Success: value = 0x%x",
(int)status_reg[2]);
} else {
@ -1236,7 +1236,7 @@ int QSPIFBlockDevice::_enable_fast_mdoe()
return -1;
}
if ( false == _is_mem_ready()) {
if (false == _is_mem_ready()) {
tr_error("Device not ready after write, failed");
return -1;
}
@ -1244,8 +1244,8 @@ int QSPIFBlockDevice::_enable_fast_mdoe()
// For Debug
memset(status_reg, 0, QSPI_MAX_STATUS_REGISTER_SIZE);
if (QSPI_STATUS_OK == _qspi_send_general_command(read_conf_register_inst, QSPI_NO_ADDRESS_COMMAND, NULL, 0,
&status_reg[1],
QSPI_MAX_STATUS_REGISTER_SIZE - 1) ) { // store received values in status_value
&status_reg[1],
QSPI_MAX_STATUS_REGISTER_SIZE - 1)) { // store received values in status_value
tr_debug("Verifying Config Register Success: value = 0x%x", (int)status_reg[2]);
} else {
tr_error("Verifying Config Register failed");
@ -1279,7 +1279,7 @@ int QSPIFBlockDevice::_utils_find_addr_region(bd_size_t offset)
}
int QSPIFBlockDevice::_utils_iterate_next_largest_erase_type(uint8_t& bitfield, int size, int offset, int boundry)
int QSPIFBlockDevice::_utils_iterate_next_largest_erase_type(uint8_t &bitfield, int size, int offset, int boundry)
{
// Iterate on all supported Erase Types of the Region to which the offset belong to.
// Iterates from highest type to lowest
@ -1289,8 +1289,8 @@ int QSPIFBlockDevice::_utils_iterate_next_largest_erase_type(uint8_t& bitfield,
for (i_ind = 3; i_ind >= 0; i_ind--) {
if (bitfield & type_mask) {
largest_erase_type = i_ind;
if ( (size > (int)(_erase_type_size_arr[largest_erase_type])) &&
((boundry - offset) > (int)(_erase_type_size_arr[largest_erase_type])) ) {
if ((size > (int)(_erase_type_size_arr[largest_erase_type])) &&
((boundry - offset) > (int)(_erase_type_size_arr[largest_erase_type]))) {
break;
} else {
bitfield &= ~type_mask;
@ -1315,12 +1315,12 @@ qspi_status_t QSPIFBlockDevice::_qspi_set_frequency(int freq)
}
qspi_status_t QSPIFBlockDevice::_qspi_send_read_command(unsigned int read_inst, void *buffer, bd_addr_t addr,
bd_size_t size)
bd_size_t size)
{
// Send Read command to device driver
size_t buf_len = size;
if (_qspi.read(read_inst, -1, (unsigned int )addr, (char *)buffer, &buf_len) != QSPI_STATUS_OK ) {
if (_qspi.read(read_inst, -1, (unsigned int)addr, (char *)buffer, &buf_len) != QSPI_STATUS_OK) {
tr_error("Read failed");
return QSPI_STATUS_ERROR;
}
@ -1330,7 +1330,7 @@ qspi_status_t QSPIFBlockDevice::_qspi_send_read_command(unsigned int read_inst,
}
qspi_status_t QSPIFBlockDevice::_qspi_send_program_command(unsigned int progInst, const void *buffer, bd_addr_t addr,
bd_size_t *size)
bd_size_t *size)
{
// Send Program (write) command to device driver
qspi_status_t result = QSPI_STATUS_OK;
@ -1366,8 +1366,8 @@ qspi_status_t QSPIFBlockDevice::_qspi_send_erase_command(unsigned int erase_inst
}
qspi_status_t QSPIFBlockDevice::_qspi_send_general_command(unsigned int instruction, bd_addr_t addr,
const char *tx_buffer,
size_t tx_length, const char *rx_buffer, size_t rx_length)
const char *tx_buffer,
size_t tx_length, const char *rx_buffer, size_t rx_length)
{
// Send a general command Instruction to driver
qspi_status_t status = _qspi.command_transfer(instruction, (int)addr, tx_buffer, tx_length, rx_buffer, rx_length);
@ -1380,12 +1380,12 @@ qspi_status_t QSPIFBlockDevice::_qspi_send_general_command(unsigned int instruct
}
qspi_status_t QSPIFBlockDevice::_qspi_configure_format(qspi_bus_width_t inst_width, qspi_bus_width_t address_width,
qspi_address_size_t address_size, qspi_bus_width_t alt_width, qspi_alt_size_t alt_size, qspi_bus_width_t data_width,
int dummy_cycles)
qspi_address_size_t address_size, qspi_bus_width_t alt_width, qspi_alt_size_t alt_size, qspi_bus_width_t data_width,
int dummy_cycles)
{
// Configure QSPI driver Bus format
qspi_status_t status = _qspi.configure_format(inst_width, address_width, address_size, alt_width, alt_size, data_width,
dummy_cycles);
dummy_cycles);
return status;
}

View File

@ -43,7 +43,7 @@ enum qspif_polarity_mode {
QSPIF_POLARITY_MODE_1 /* CPOL=1, CPHA=1 */
};
#define QSPIF_MAX_REGIONS 10
#define QSPIF_MAX_REGIONS 10
#define MAX_NUM_OF_ERASE_TYPES 4
#define QSPIF_MAX_ACTIVE_FLASH_DEVICES 10
@ -121,7 +121,10 @@ public:
/** Desctruct QSPIFBlockDevie
*/
~QSPIFBlockDevice() {deinit();}
~QSPIFBlockDevice()
{
deinit();
}
/** Read blocks from a block device
*
@ -227,7 +230,7 @@ private:
/********************************/
// 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);
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);
@ -237,7 +240,7 @@ private:
// 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,
size_t tx_length, const char *rx_buffer, size_t rx_length);
size_t tx_length, const char *rx_buffer, size_t rx_length);
// Send Bus configure_format command to Driver
qspi_status_t _qspi_configure_format(qspi_bus_width_t inst_width, qspi_bus_width_t address_width,
@ -266,8 +269,8 @@ private:
/* SFDP Detection and Parsing Functions */
/****************************************/
// Parse SFDP Headers and retrieve Basic Param and Sector Map Tables (if exist)
int _sfdp_parse_sfdp_headers(uint32_t& basic_table_addr, size_t& basic_table_size,
uint32_t& sector_map_table_addr, size_t& sector_map_table_size);
int _sfdp_parse_sfdp_headers(uint32_t &basic_table_addr, size_t &basic_table_size,
uint32_t &sector_map_table_addr, size_t &sector_map_table_size);
// Parse and Detect required Basic Parameters from Table
int _sfdp_parse_basic_param_table(uint32_t basic_table_addr, size_t basic_table_size);
@ -276,8 +279,8 @@ private:
int _sfdp_parse_sector_map_table(uint32_t sector_map_table_addr, size_t sector_map_table_size);
// Detect fastest read Bus mode supported by device
int _sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table_ptr, int basic_param_table_size, bool& set_quad_enable,
bool& is_qpi_mode, unsigned int& read_inst);
int _sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table_ptr, int basic_param_table_size, bool &set_quad_enable,
bool &is_qpi_mode, unsigned int &read_inst);
// Enable Quad mode if supported (1-1-4, 1-4-4, 4-4-4 bus modes)
int _sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr);
@ -290,8 +293,8 @@ private:
// Detect all supported erase types
int _sfdp_detect_erase_types_inst_and_size(uint8_t *basic_param_table_ptr, int basic_param_table_size,
unsigned int& erase4k_inst,
unsigned int *erase_type_inst_arr, unsigned int *erase_type_size_arr);
unsigned int &erase4k_inst,
unsigned int *erase_type_inst_arr, unsigned int *erase_type_size_arr);
/***********************/
/* Utilities Functions */
@ -301,7 +304,7 @@ private:
// Iterate on all supported Erase Types of the Region to which the offset belong to.
// Iterates from highest type to lowest
int _utils_iterate_next_largest_erase_type(uint8_t& bitfield, int size, int offset, int boundry);
int _utils_iterate_next_largest_erase_type(uint8_t &bitfield, int size, int offset, int boundry);
private:
// Internal Members

View File

@ -43,7 +43,7 @@ static SingletonPtr<PlatformMutex> _mutex;
// Mutex is protecting rand() per srand for buffer writing and verification.
// Mutex is also protecting printouts for clear logs.
// Mutex is NOT protecting Block Device actions: erase/program/read - which is the purpose of the multithreaded test!
void basic_erase_program_read_test(QSPIFBlockDevice& blockD, bd_size_t block_size, uint8_t *write_block,
void basic_erase_program_read_test(QSPIFBlockDevice &blockD, bd_size_t block_size, uint8_t *write_block,
uint8_t *read_block, unsigned addrwidth)
{
int err = 0;
@ -79,10 +79,10 @@ void basic_erase_program_read_test(QSPIFBlockDevice& blockD, bd_size_t block_siz
int val_rand;
for (bd_size_t i_ind = 0; i_ind < block_size; i_ind++) {
val_rand = rand();
if ( (0xff & val_rand) != read_block[i_ind] ) {
if ((0xff & val_rand) != read_block[i_ind]) {
utest_printf("\n Assert Failed Buf Read - block:size: %llx:%llu \n", block, block_size);
utest_printf("\n pos: %llu, exp: %02x, act: %02x, wrt: %02x \n", i_ind, (0xff & val_rand), read_block[i_ind],
write_block[i_ind] );
write_block[i_ind]);
}
TEST_ASSERT_EQUAL(0xff & val_rand, read_block[i_ind]);
}
@ -208,7 +208,7 @@ static void test_qspif_thread_job(void *vBlockD/*, int thread_num*/)
uint8_t *write_block = new (std::nothrow) uint8_t[block_size];
uint8_t *read_block = new (std::nothrow) uint8_t[block_size];
if (!write_block || !read_block ) {
if (!write_block || !read_block) {
utest_printf("\n Not enough memory for test");
goto end;
}

View File

@ -100,7 +100,7 @@ int SPIFReducedBlockDevice::init()
uint32_t table_addr = (
(header[14] << 24) |
(header[13] << 16) |
(header[12] << 8 ));
(header[12] << 8));
uint8_t table[8];
_cmdread(SPIF_SFDP, 4, 8, table_addr, table);
@ -121,8 +121,8 @@ int SPIFReducedBlockDevice::init()
uint32_t density = (
(table[7] << 24) |
(table[6] << 16) |
(table[5] << 8 ) |
(table[4] << 0 ));
(table[5] << 8) |
(table[4] << 0));
// Table bytes 5-8 : Bits 0|30 indicate Flash Density (size) in bits (divide by 8 for Bytes)
_size = (density / 8) + 1;

View File

@ -114,7 +114,7 @@ public:
}
protected:
#if !defined(DOXYGEN_ONLY)
#if !defined(DOXYGEN_ONLY)
virtual void lock()
{
_mutex->lock();
@ -127,7 +127,7 @@ protected:
analogin_t _adc;
static SingletonPtr<PlatformMutex> _mutex;
#endif //!defined(DOXYGEN_ONLY)
#endif //!defined(DOXYGEN_ONLY)
};
} // namespace mbed

View File

@ -141,7 +141,7 @@ public:
}
protected:
#if !defined(DOXYGEN_ONLY)
#if !defined(DOXYGEN_ONLY)
virtual void lock()
{
_mutex.lock();
@ -154,7 +154,7 @@ protected:
dac_t _dac;
PlatformMutex _mutex;
#endif //!defined(DOXYGEN_ONLY)
#endif //!defined(DOXYGEN_ONLY)
};
} // namespace mbed

View File

@ -121,9 +121,9 @@ public:
}
protected:
#if !defined(DOXYGEN_ONLY)
#if !defined(DOXYGEN_ONLY)
gpio_t gpio;
#endif //!defined(DOXYGEN_ONLY)
#endif //!defined(DOXYGEN_ONLY)
};
} // namespace mbed

View File

@ -165,9 +165,9 @@ public:
}
protected:
#if !defined(DOXYGEN_ONLY)
#if !defined(DOXYGEN_ONLY)
gpio_t gpio;
#endif //!defined(DOXYGEN_ONLY)
#endif //!defined(DOXYGEN_ONLY)
};
} // namespace mbed

View File

@ -144,9 +144,9 @@ public:
}
protected:
#if !defined(DOXYGEN_ONLY)
#if !defined(DOXYGEN_ONLY)
gpio_t gpio;
#endif //!defined(DOXYGEN_ONLY)
#endif //!defined(DOXYGEN_ONLY)
};
} // namespace mbed

View File

@ -185,7 +185,7 @@ public:
#if defined(DOXYGEN_ONLY)
#if defined(DOXYGEN_ONLY)
/** Calls an event on the queue
*
* The specified callback will be executed in the context of the event
@ -266,8 +266,11 @@ public:
* }
* @endcode
*/
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
template <typename T, typename R, typename ...Args>
int call(T *obj, R (T::*method)(Args ...args), Args ...args);
// *INDENT-ON*
/** Calls an event on the queue after a specified delay
*
@ -346,8 +349,11 @@ public:
* }
* @endcode
*/
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
template <typename T, typename R, typename ...Args>
int call_in(int ms, T *obj, R (T::*method)(Args ...args), Args ...args);
// *INDENT-ON*
/** Calls an event on the queue periodically
*
@ -440,8 +446,11 @@ public:
* }
* @endcode
*/
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
template <typename T, typename R, typename ...Args>
int call_every(int ms, T *obj, R (T::*method)(Args ...args), Args ...args);
// *INDENT-ON*
/** Creates an event bound to the event queue
*
@ -483,8 +492,11 @@ public:
* }
* @endcode
*/
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
template <typename R, typename ...BoundArgs, typename ...Args>
Event<void(Args...)> event(R (*func)(BoundArgs...), Args ...args);
// *INDENT-ON*
/** Creates an event bound to the event queue
*
@ -528,8 +540,11 @@ public:
* }
* @endcode
*/
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
template <typename T, typename R, typename ...BoundArgs, typename ...ContextArgs, typename ...Args>
Event<void(Args...)> event(T *obj, R (T::*method)(BoundArgs..., Args...), ContextArgs ...context_args);
// *INDENT-ON*
/** Creates an event bound to the event queue
*
@ -569,7 +584,7 @@ public:
template <typename R, typename ...BoundArgs, typename ...ContextArgs, typename ...Args>
Event<void(Args...)> event(mbed::Callback<R(BoundArgs..., Args...)> cb, ContextArgs ...context_args);
#else
#else
/** Calls an event on the queue
*
@ -2800,10 +2815,10 @@ public:
*/
template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3, typename A4>
Event<void(A0, A1, A2, A3, A4)> event(mbed::Callback<R(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4)> cb, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4);
#endif
#endif
protected:
#if !defined(DOXYGEN_ONLY)
#if !defined(DOXYGEN_ONLY)
template <typename F>
friend class Event;
struct equeue _equeue;
@ -3380,7 +3395,7 @@ protected:
f(c0, c1, c2, c3, c4, a0, a1, a2, a3, a4);
}
};
#endif //!defined(DOXYGEN_ONLY)
#endif //!defined(DOXYGEN_ONLY)
};
}

View File

@ -208,7 +208,7 @@ int equeue_timeleft(equeue_t *q, int id);
// of hardware timers or even other event loops, allowing an event queue to
// be effectively backgrounded.
void equeue_background(equeue_t *queue,
void (*update)(void *timer, int ms), void *timer);
void (*update)(void *timer, int ms), void *timer);
// Chain an event queue onto another event queue
//

View File

@ -70,7 +70,7 @@ static void test_sim_interface()
nsapi_error_t err = sim->set_pin(MBED_CONF_APP_CELLULAR_SIM_PIN);
MBED_ASSERT(err == NSAPI_ERROR_OK);
// 2. test set_pin_query
// 2. test set_pin_query
wait(1);
err = sim->set_pin_query(MBED_CONF_APP_CELLULAR_SIM_PIN, false);
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);

View File

@ -112,7 +112,7 @@ static void test_sms_initialize_text_mode()
{
nsapi_error_t err = sms->initialize(CellularSMS::CellularSMSMmodeText);
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
}
@ -120,40 +120,40 @@ static void test_sms_initialize_pdu_mode()
{
nsapi_error_t err = sms->initialize(CellularSMS::CellularSMSMmodePDU);
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
}
static void test_set_cscs()
{
nsapi_error_t err = sms->set_cscs("IRA");
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
err = sms->set_cscs("UCS2");
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
err = sms->set_cscs("GSM");
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
}
static void test_set_csca()
{
nsapi_error_t err = sms->set_csca("55555", 129);
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
err = sms->set_csca("+35855555", 145);
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
err = sms->set_csca(service_center_address, service_address_type);
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
}
static void test_set_cpms_me()
{
nsapi_error_t err = sms->set_cpms("ME", "ME", "ME");
TEST_ASSERT(err == NSAPI_ERROR_OK || (err == NSAPI_ERROR_DEVICE_ERROR &&
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
}
#ifdef MBED_CONF_APP_CELLULAR_PHONE_NUMBER

View File

@ -41,8 +41,8 @@ using namespace mbed_cellular_util;
using namespace mbed;
AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
AT_CellularBase(at), _ip_stack_type_requested(DEFAULT_STACK), _is_connected(false), _is_blocking(true),
_current_op(OP_INVALID), _device(device), _nw(0), _fh(0)
AT_CellularBase(at), _ip_stack_type_requested(DEFAULT_STACK), _is_connected(false), _is_blocking(true),
_current_op(OP_INVALID), _device(device), _nw(0), _fh(0)
{
tr_debug("AT_CellularContext::AT_CellularContext(): apn: %s", apn);
_stack = NULL;
@ -218,7 +218,7 @@ void AT_CellularContext::set_sim_pin(const char *sim_pin)
}
nsapi_error_t AT_CellularContext::connect(const char *sim_pin, const char *apn, const char *uname,
const char *pwd)
const char *pwd)
{
set_sim_pin(sim_pin);
set_credentials(apn, uname, pwd);
@ -458,7 +458,7 @@ bool AT_CellularContext::set_new_context(int cid)
nsapi_error_t AT_CellularContext::do_activate_context()
{
_at.lock();
_at.lock();
nsapi_error_t err = NSAPI_ERROR_OK;
@ -536,7 +536,7 @@ void AT_CellularContext::do_connect()
#if !NSAPI_PPP_AVAILABLE
// in PPP mode we did not activate any context, just searched the correct _cid
if (_status_cb) {
_status_cb((nsapi_event_t)CellularActivatePDPContext, (intptr_t )&_cb_data);
_status_cb((nsapi_event_t)CellularActivatePDPContext, (intptr_t)&_cb_data);
}
#endif // !NSAPI_PPP_AVAILABLE
}
@ -810,7 +810,7 @@ nsapi_error_t AT_CellularContext::get_pdpcontext_params(pdpContextList_t &params
void AT_CellularContext::cellular_callback(nsapi_event_t ev, intptr_t ptr)
{
if (ev >= NSAPI_EVENT_CELLULAR_STATUS_BASE && ev <= NSAPI_EVENT_CELLULAR_STATUS_END) {
cell_callback_data_t* data = (cell_callback_data_t*)ptr;
cell_callback_data_t *data = (cell_callback_data_t *)ptr;
cellular_connection_status_t st = (cellular_connection_status_t)ev;
_cb_data.error = data->error;
tr_debug("AT_CellularContext::cellular_callback, network_callback called with event: %d, err: %d, data: %d", ev, data->error, data->status_data);
@ -853,16 +853,16 @@ void AT_CellularContext::cellular_callback(nsapi_event_t ev, intptr_t ptr)
_semaphore.release();
} else {
if ((st == CellularDeviceReady && _current_op == OP_DEVICE_READY) ||
(st == CellularSIMStatusChanged && _current_op == OP_SIM_READY &&
data->status_data == CellularSIM::SimStateReady)) {
(st == CellularSIMStatusChanged && _current_op == OP_SIM_READY &&
data->status_data == CellularSIM::SimStateReady)) {
// target reached, release semaphore
_semaphore.release();
} else if (st == CellularRegistrationStatusChanged && (data->status_data == CellularNetwork::RegisteredHomeNetwork ||
data->status_data == CellularNetwork::RegisteredRoaming || data->status_data == CellularNetwork::AlreadyRegistered) && _current_op == OP_REGISTER) {
data->status_data == CellularNetwork::RegisteredRoaming || data->status_data == CellularNetwork::AlreadyRegistered) && _current_op == OP_REGISTER) {
// target reached, release semaphore
_semaphore.release();
} else if (st == CellularAttachNetwork && (_current_op == OP_ATTACH || _current_op == OP_CONNECT) &&
data->status_data == CellularNetwork::Attached) {
data->status_data == CellularNetwork::Attached) {
// target reached, release semaphore
_semaphore.release();
}

View File

@ -34,14 +34,14 @@ using namespace mbed;
#define DEFAULT_AT_TIMEOUT 1000 // at default timeout in milliseconds
AT_CellularDevice::AT_CellularDevice(FileHandle *fh) : CellularDevice(fh), _atHandlers(0), _network(0), _sms(0),
_sim(0), _power(0), _information(0), _context_list(0), _default_timeout(DEFAULT_AT_TIMEOUT),
_modem_debug_on(false)
_sim(0), _power(0), _information(0), _context_list(0), _default_timeout(DEFAULT_AT_TIMEOUT),
_modem_debug_on(false)
{
}
AT_CellularDevice::~AT_CellularDevice()
{
delete _state_machine;
delete _state_machine;
// make sure that all is deleted even if somewhere close was not called and reference counting is messed up.
_network_ref_count = 1;
@ -56,10 +56,10 @@ AT_CellularDevice::~AT_CellularDevice()
close_sim();
close_information();
AT_CellularContext* curr = _context_list;
AT_CellularContext* next;
AT_CellularContext *curr = _context_list;
AT_CellularContext *next;
while (curr) {
next = (AT_CellularContext*)curr->_next;
next = (AT_CellularContext *)curr->_next;
delete curr;
curr = next;
}
@ -134,17 +134,17 @@ CellularContext *AT_CellularDevice::create_context(FileHandle *fh, const char *a
ATHandler *atHandler = get_at_handler(fh);
if (atHandler) {
AT_CellularContext *ctx = create_context_impl(*atHandler, apn);
AT_CellularContext* curr = _context_list;
AT_CellularContext *curr = _context_list;
if (_context_list == NULL) {
_context_list = ctx;
return ctx;
}
AT_CellularContext* prev;
AT_CellularContext *prev;
while (curr) {
prev = curr;
curr = (AT_CellularContext*)curr->_next;
curr = (AT_CellularContext *)curr->_next;
}
prev->_next = ctx;
@ -160,20 +160,20 @@ AT_CellularContext *AT_CellularDevice::create_context_impl(ATHandler &at, const
void AT_CellularDevice::delete_context(CellularContext *context)
{
AT_CellularContext* curr = _context_list;
AT_CellularContext* prev = NULL;
AT_CellularContext *curr = _context_list;
AT_CellularContext *prev = NULL;
while (curr) {
if (curr == context) {
if (prev == NULL) {
_context_list = (AT_CellularContext*)curr->_next;
_context_list = (AT_CellularContext *)curr->_next;
} else {
prev->_next = curr->_next;
}
}
prev = curr;
curr = (AT_CellularContext*)curr->_next;
curr = (AT_CellularContext *)curr->_next;
}
delete (AT_CellularContext*)context;
delete (AT_CellularContext *)context;
}
CellularNetwork *AT_CellularDevice::open_network(FileHandle *fh)

View File

@ -21,7 +21,7 @@
namespace mbed {
GEMALTO_CINTERION_CellularContext::GEMALTO_CINTERION_CellularContext(ATHandler &at, CellularDevice *device,
const char *apn) : AT_CellularContext(at, device, apn)
const char *apn) : AT_CellularContext(at, device, apn)
{
}

View File

@ -19,7 +19,7 @@
namespace mbed {
SARA4_PPP_CellularContext::SARA4_PPP_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
AT_CellularContext(at, device, apn)
AT_CellularContext(at, device, apn)
{
}

View File

@ -20,7 +20,7 @@
namespace mbed {
QUECTEL_BC95_CellularContext::QUECTEL_BC95_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
AT_CellularContext(at, device, apn)
AT_CellularContext(at, device, apn)
{
}

View File

@ -20,7 +20,7 @@
namespace mbed {
QUECTEL_BG96_CellularContext::QUECTEL_BG96_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
AT_CellularContext(at, device, apn)
AT_CellularContext(at, device, apn)
{
}

View File

@ -19,7 +19,7 @@
namespace mbed {
QUECTEL_UG96_CellularContext::QUECTEL_UG96_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
AT_CellularContext(at, device, apn)
AT_CellularContext(at, device, apn)
{
}

View File

@ -19,7 +19,7 @@
namespace mbed {
TELIT_HE910_CellularContext::TELIT_HE910_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
AT_CellularContext(at, device, apn)
AT_CellularContext(at, device, apn)
{
}

View File

@ -21,7 +21,7 @@
namespace mbed {
UBLOX_AT_CellularContext::UBLOX_AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
AT_CellularContext(at, device, apn)
AT_CellularContext(at, device, apn)
{
// The authentication to use
_auth = NSAPI_SECURITY_UNKNOWN;
@ -75,9 +75,9 @@ nsapi_error_t UBLOX_AT_CellularContext::open_data_channel()
{
bool success = false;
int active = 0;
char * config = NULL;
char *config = NULL;
nsapi_error_t err = NSAPI_ERROR_NO_CONNECTION;
char imsi[MAX_IMSI_LENGTH+1];
char imsi[MAX_IMSI_LENGTH + 1];
// do check for stack to validate that we have support for stack
_stack = get_stack();
@ -98,14 +98,14 @@ nsapi_error_t UBLOX_AT_CellularContext::open_data_channel()
if (_apn == NULL) {
err = get_imsi(imsi);
if (err == NSAPI_ERROR_OK) {
config = (char*)apnconfig(imsi);
config = (char *)apnconfig(imsi);
}
}
// Attempt to connect
do {
get_next_credentials(&config);
if(_uname && _pwd) {
if (_uname && _pwd) {
_auth = (*_uname && *_pwd) ? _auth : NSAPI_SECURITY_NONE;
} else {
_auth = NSAPI_SECURITY_NONE;
@ -122,9 +122,9 @@ nsapi_error_t UBLOX_AT_CellularContext::open_data_channel()
return err;
}
bool UBLOX_AT_CellularContext::activate_profile(const char* apn,
const char* username,
const char* password)
bool UBLOX_AT_CellularContext::activate_profile(const char *apn,
const char *username,
const char *password)
{
bool activated = false;
bool success = false;
@ -253,7 +253,7 @@ bool UBLOX_AT_CellularContext::disconnect_modem_stack()
return success;
}
nsapi_error_t UBLOX_AT_CellularContext::get_imsi(char* imsi)
nsapi_error_t UBLOX_AT_CellularContext::get_imsi(char *imsi)
{
_at.lock();
_at.cmd_start("AT+CIMI");
@ -269,7 +269,7 @@ nsapi_error_t UBLOX_AT_CellularContext::get_imsi(char* imsi)
}
// Get the next set of credentials, based on IMSI.
void UBLOX_AT_CellularContext::get_next_credentials(char ** config)
void UBLOX_AT_CellularContext::get_next_credentials(char **config)
{
if (*config) {
_apn = _APN_GET(*config);

View File

@ -59,7 +59,7 @@ private:
* NSAPI_SECURITY_CHAP or NSAPI_SECURITY_UNKNOWN).
* @return True if successful, otherwise false.
*/
bool activate_profile(const char* apn, const char* username, const char* password);
bool activate_profile(const char *apn, const char *username, const char *password);
/** Convert nsapi_security_t to the modem security numbers.
*
@ -76,11 +76,11 @@ private:
/** Read IMSI of modem.
*/
nsapi_error_t get_imsi(char* imsi);
nsapi_error_t get_imsi(char *imsi);
/** Get the next set of credentials from the database.
*/
void get_next_credentials(char ** config);
void get_next_credentials(char **config);
};
} /* namespace mbed */

View File

@ -19,7 +19,7 @@
namespace mbed {
UBLOX_PPP_CellularContext::UBLOX_PPP_CellularContext(ATHandler &at, CellularDevice *device, const char *apn) :
AT_CellularContext(at, device, apn)
AT_CellularContext(at, device, apn)
{
}

View File

@ -32,7 +32,10 @@ public:
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
virtual nsapi_connection_status_t get_connection_status() const;
void get_mac_address(uint8_t *buf) const { interface_phy.get_mac_address(buf); }
void get_mac_address(uint8_t *buf) const
{
interface_phy.get_mac_address(buf);
}
/**
* \brief Callback from C-layer
@ -40,15 +43,24 @@ public:
* */
void network_handler(mesh_connection_status_t status);
int8_t get_interface_id() const { return interface_id; }
int8_t get_driver_id() const { return _device_id; }
int8_t get_interface_id() const
{
return interface_id;
}
int8_t get_driver_id() const
{
return _device_id;
}
private:
NanostackPhy &interface_phy;
protected:
Interface(NanostackPhy &phy);
virtual nsapi_error_t register_phy();
NanostackPhy &get_phy() const { return interface_phy; }
NanostackPhy &get_phy() const
{
return interface_phy;
}
int8_t interface_id;
int8_t _device_id;
rtos::Semaphore connect_semaphore;
@ -62,7 +74,10 @@ protected:
class Nanostack::MeshInterface : public Nanostack::Interface {
protected:
MeshInterface(NanostackRfPhy &phy) : Interface(phy) { }
NanostackRfPhy &get_phy() const { return static_cast<NanostackRfPhy &>(Interface::get_phy()); }
NanostackRfPhy &get_phy() const
{
return static_cast<NanostackRfPhy &>(Interface::get_phy());
}
};
@ -116,12 +131,18 @@ public:
/** Get the interface ID
/return Interface identifier
*/
int8_t get_interface_id() const { return _interface->get_interface_id(); }
int8_t get_interface_id() const
{
return _interface->get_interface_id();
}
protected:
InterfaceNanostack();
virtual Nanostack *get_stack(void);
Nanostack::Interface *get_interface() const { return _interface; }
Nanostack::Interface *get_interface() const
{
return _interface;
}
virtual nsapi_error_t do_initialize() = 0;
Nanostack::Interface *_interface;
@ -147,7 +168,10 @@ public:
protected:
MeshInterfaceNanostack() : _phy(NULL) { }
MeshInterfaceNanostack(NanostackRfPhy *phy) : _phy(phy) { }
Nanostack::MeshInterface *get_interface() const { return static_cast<Nanostack::MeshInterface *>(_interface); }
Nanostack::MeshInterface *get_interface() const
{
return static_cast<Nanostack::MeshInterface *>(_interface);
}
NanostackRfPhy *_phy;
};

View File

@ -35,7 +35,10 @@ private:
EthernetInterface(NanostackEthernetPhy &phy) : Interface(phy) {}
nsapi_error_t initialize();
protected:
NanostackEthernetPhy &get_phy() const { return static_cast<NanostackEthernetPhy &>(Interface::get_phy()); }
NanostackEthernetPhy &get_phy() const
{
return static_cast<NanostackEthernetPhy &>(Interface::get_phy());
}
};
/** Ethernet interface for Nanostack.
@ -50,7 +53,10 @@ public:
nsapi_error_t initialize(NanostackEthernetPhy *phy);
protected:
Nanostack::EthernetInterface *get_interface() const { return static_cast<Nanostack::EthernetInterface *>(_interface); }
Nanostack::EthernetInterface *get_interface() const
{
return static_cast<Nanostack::EthernetInterface *>(_interface);
}
virtual nsapi_error_t do_initialize();
};

View File

@ -8,8 +8,7 @@
#include "ns_trace.h"
#define TRACE_GROUP "nslp"
class Nanostack::LoWPANNDInterface : public Nanostack::MeshInterface
{
class Nanostack::LoWPANNDInterface : public Nanostack::MeshInterface {
public:
virtual nsapi_error_t bringup(bool dhcp, const char *ip,
const char *netmask, const char *gw,
@ -29,7 +28,7 @@ private:
Nanostack::LoWPANNDInterface *LoWPANNDInterface::get_interface() const
{
return static_cast<Nanostack::LoWPANNDInterface*>(_interface);
return static_cast<Nanostack::LoWPANNDInterface *>(_interface);
}
nsapi_error_t LoWPANNDInterface::do_initialize()

View File

@ -69,7 +69,7 @@ void Nanostack::Interface::attach(
}
Nanostack::Interface::Interface(NanostackPhy &phy) : interface_phy(phy), interface_id(-1), _device_id(-1),
_connect_status(NSAPI_STATUS_DISCONNECTED), _previous_connection_status(NSAPI_STATUS_DISCONNECTED), _blocking(true)
_connect_status(NSAPI_STATUS_DISCONNECTED), _previous_connection_status(NSAPI_STATUS_DISCONNECTED), _blocking(true)
{
mesh_system_init();
}
@ -119,7 +119,7 @@ nsapi_error_t MeshInterfaceNanostack::initialize(NanostackRfPhy *phy)
void Nanostack::Interface::network_handler(mesh_connection_status_t status)
{
if ((status == MESH_CONNECTED || status == MESH_CONNECTED_LOCAL ||
status == MESH_CONNECTED_GLOBAL) && _blocking) {
status == MESH_CONNECTED_GLOBAL) && _blocking) {
connect_semaphore.release();
}
@ -131,10 +131,10 @@ void Nanostack::Interface::network_handler(mesh_connection_status_t status)
_connect_status = NSAPI_STATUS_LOCAL_UP;
}
if (arm_net_address_get(interface_id, ADDR_IPV6_GP, temp_ipv6_global) == 0
&& (memcmp(temp_ipv6_global, temp_ipv6_local, 16) != 0)) {
&& (memcmp(temp_ipv6_global, temp_ipv6_local, 16) != 0)) {
_connect_status = NSAPI_STATUS_GLOBAL_UP;
}
} else if (status == MESH_CONNECTED_LOCAL ) {
} else if (status == MESH_CONNECTED_LOCAL) {
_connect_status = NSAPI_STATUS_LOCAL_UP;
} else if (status == MESH_CONNECTED_GLOBAL) {
_connect_status = NSAPI_STATUS_GLOBAL_UP;

View File

@ -8,16 +8,15 @@
#include "arm_hal_phy.h"
#include "EMAC.h"
class EMACPhy : public NanostackEthernetPhy
{
class EMACPhy : public NanostackEthernetPhy {
public:
EMACPhy(NanostackMemoryManager &mem, EMAC &m);
virtual int8_t phy_register();
virtual void get_mac_address(uint8_t *mac);
virtual void set_mac_address(uint8_t *mac);
int8_t address_write(phy_address_type_e , uint8_t *);
int8_t tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle,data_protocol_e data_flow);
int8_t address_write(phy_address_type_e, uint8_t *);
int8_t tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle, data_protocol_e data_flow);
void emac_phy_rx(emac_mem_buf_t *mem);
@ -34,65 +33,65 @@ static EMACPhy *single_phy;
extern "C"
{
static int8_t emac_phy_address_write(phy_address_type_e address_type, uint8_t *address_ptr)
{
return single_phy->address_write(address_type, address_ptr);
}
static int8_t emac_phy_address_write(phy_address_type_e address_type, uint8_t *address_ptr)
{
return single_phy->address_write(address_type, address_ptr);
}
static int8_t emac_phy_interface_state_control(phy_interface_state_e, uint8_t)
{
return -1;
}
static int8_t emac_phy_interface_state_control(phy_interface_state_e, uint8_t)
{
return -1;
}
static int8_t emac_phy_tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle,data_protocol_e data_flow)
{
return single_phy->tx(data_ptr, data_len, tx_handle, data_flow);
}
static int8_t emac_phy_tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle, data_protocol_e data_flow)
{
return single_phy->tx(data_ptr, data_len, tx_handle, data_flow);
}
EMACPhy::EMACPhy(NanostackMemoryManager &mem, EMAC &m) : memory_manager(mem), emac(m), device_id(-1)
{
/* Same default address logic as lwIP glue uses */
EMACPhy::EMACPhy(NanostackMemoryManager &mem, EMAC &m) : memory_manager(mem), emac(m), device_id(-1)
{
/* Same default address logic as lwIP glue uses */
#if (MBED_MAC_ADDRESS_SUM != MBED_MAC_ADDR_INTERFACE)
mac_addr[0] = MBED_MAC_ADDR_0;
mac_addr[1] = MBED_MAC_ADDR_1;
mac_addr[2] = MBED_MAC_ADDR_2;
mac_addr[3] = MBED_MAC_ADDR_3;
mac_addr[4] = MBED_MAC_ADDR_4;
mac_addr[5] = MBED_MAC_ADDR_5;
mac_addr[0] = MBED_MAC_ADDR_0;
mac_addr[1] = MBED_MAC_ADDR_1;
mac_addr[2] = MBED_MAC_ADDR_2;
mac_addr[3] = MBED_MAC_ADDR_3;
mac_addr[4] = MBED_MAC_ADDR_4;
mac_addr[5] = MBED_MAC_ADDR_5;
#else
mbed_mac_address((char *) mac_addr);
mbed_mac_address((char *) mac_addr);
#endif
/* We have a default MAC address, so do don't force them to supply one */
/* They may or may not update hwaddr with their address */
emac.get_hwaddr(mac_addr);
}
/* We have a default MAC address, so do don't force them to supply one */
/* They may or may not update hwaddr with their address */
emac.get_hwaddr(mac_addr);
}
void EMACPhy::emac_phy_rx(emac_mem_buf_t *mem)
{
const uint8_t *ptr = NULL;
uint8_t *tmpbuf = NULL;
uint32_t total_len;
void EMACPhy::emac_phy_rx(emac_mem_buf_t *mem)
{
const uint8_t *ptr = NULL;
uint8_t *tmpbuf = NULL;
uint32_t total_len;
if (memory_manager.get_next(mem) == NULL) {
// Easy contiguous case
ptr = static_cast<const uint8_t*>(memory_manager.get_ptr(mem));
total_len = memory_manager.get_len(mem);
} else {
// Nanostack can't accept chunked data - make temporary contiguous copy
total_len = memory_manager.get_total_len(mem);
ptr = tmpbuf = static_cast<uint8_t *>(ns_dyn_mem_temporary_alloc(total_len));
if (tmpbuf) {
memory_manager.copy_from_buf(tmpbuf, total_len, mem);
if (memory_manager.get_next(mem) == NULL) {
// Easy contiguous case
ptr = static_cast<const uint8_t *>(memory_manager.get_ptr(mem));
total_len = memory_manager.get_len(mem);
} else {
// Nanostack can't accept chunked data - make temporary contiguous copy
total_len = memory_manager.get_total_len(mem);
ptr = tmpbuf = static_cast<uint8_t *>(ns_dyn_mem_temporary_alloc(total_len));
if (tmpbuf) {
memory_manager.copy_from_buf(tmpbuf, total_len, mem);
}
}
}
if (ptr && phy.phy_rx_cb) {
phy.phy_rx_cb(ptr, total_len, 0xff, 0, device_id);
if (ptr && phy.phy_rx_cb) {
phy.phy_rx_cb(ptr, total_len, 0xff, 0, device_id);
}
ns_dyn_mem_free(tmpbuf);
memory_manager.free(mem);
}
ns_dyn_mem_free(tmpbuf);
memory_manager.free(mem);
}
} // extern "C"
@ -106,7 +105,7 @@ int8_t EMACPhy::address_write(phy_address_type_e address_type, uint8_t *address_
return 0;
}
int8_t EMACPhy::tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle,data_protocol_e data_flow)
int8_t EMACPhy::tx(uint8_t *data_ptr, uint16_t data_len, uint8_t tx_handle, data_protocol_e data_flow)
{
emac_mem_buf_t *mem = memory_manager.alloc_pool(data_len, 0);
if (!mem) {
@ -126,7 +125,7 @@ int8_t EMACPhy::phy_register()
phy.PHY_MAC = mac_addr;
phy.address_write = emac_phy_address_write;
phy.driver_description = const_cast<char*>("ETH");
phy.driver_description = const_cast<char *>("ETH");
phy.link_type = PHY_LINK_ETHERNET_TYPE;
phy.phy_MTU = 0;
phy.phy_header_length = 0;
@ -153,9 +152,9 @@ int8_t EMACPhy::phy_register()
emac.set_all_multicast(true);
device_id = arm_net_phy_register(&phy);
// driver_readiness_status_callback = driver_status_cb;
// driver_readiness_status_callback = driver_status_cb;
if (device_id < 0){
if (device_id < 0) {
//tr_error("Ethernet Driver failed to register with Stack. RetCode=%i", eth_driver_enabled);
//driver_readiness_status_callback(0, eth_interface_id);
emac.power_down();
@ -188,7 +187,7 @@ nsapi_error_t Nanostack::add_ethernet_interface(EMAC &emac, bool default_if, Nan
}
if (mac_addr) {
single_phy->set_mac_address(const_cast<uint8_t*>(mac_addr));
single_phy->set_mac_address(const_cast<uint8_t *>(mac_addr));
}
Nanostack::EthernetInterface *interface;

View File

@ -44,11 +44,11 @@ nsapi_error_t NanostackEthernetInterface::initialize(NanostackEthernetPhy *phy)
}
return get_interface()->initialize();
}
}
nsapi_error_t Nanostack::EthernetInterface::bringup(bool dhcp, const char *ip,
const char *netmask, const char *gw,
nsapi_ip_stack_t stack, bool blocking)
const char *netmask, const char *gw,
nsapi_ip_stack_t stack, bool blocking)
{
if (stack == IPV4_STACK) {
return NSAPI_ERROR_UNSUPPORTED;

View File

@ -19,8 +19,7 @@
#include "mbed_assert.h"
#include "NanostackMemoryManager.h"
struct ns_stack_mem_t
{
struct ns_stack_mem_t {
ns_stack_mem_t *next;
void *payload;
uint32_t len;

View File

@ -7,8 +7,7 @@
#include "ns_trace.h"
#define TRACE_GROUP "nsth"
class Nanostack::ThreadInterface : public Nanostack::MeshInterface
{
class Nanostack::ThreadInterface : public Nanostack::MeshInterface {
public:
virtual nsapi_error_t bringup(bool dhcp, const char *ip,
const char *netmask, const char *gw,
@ -73,7 +72,7 @@ private:
Nanostack::ThreadInterface *ThreadInterface::get_interface() const
{
return static_cast<Nanostack::ThreadInterface*>(_interface);
return static_cast<Nanostack::ThreadInterface *>(_interface);
}
nsapi_error_t ThreadInterface::do_initialize()

View File

@ -189,7 +189,7 @@ static void enet_tasklet_poll_network_status(void *param)
memcpy(tasklet_data_ptr->ip, temp_ipv6, 16);
uint8_t temp_ipv6_local[16];
if (arm_net_address_get(tasklet_data_ptr->network_interface_id, ADDR_IPV6_LL, temp_ipv6_local) == 0
&& (memcmp(temp_ipv6, temp_ipv6_local, 16) != 0)) {
&& (memcmp(temp_ipv6, temp_ipv6_local, 16) != 0)) {
enet_tasklet_network_state_changed(MESH_CONNECTED_GLOBAL);
} else {
enet_tasklet_network_state_changed(MESH_CONNECTED_LOCAL);;
@ -197,8 +197,9 @@ static void enet_tasklet_poll_network_status(void *param)
}
} else {
if (tasklet_data_ptr->connection_status != MESH_DISCONNECTED &&
tasklet_data_ptr->connection_status != MESH_BOOTSTRAP_STARTED)
tasklet_data_ptr->connection_status != MESH_BOOTSTRAP_STARTED) {
enet_tasklet_network_state_changed(MESH_DISCONNECTED);
}
}
}
@ -242,7 +243,7 @@ int8_t enet_tasklet_connect(mesh_interface_cb callback, int8_t nwk_interface_id)
if (re_connecting == false) {
tasklet_data_ptr->tasklet = eventOS_event_handler_create(&enet_tasklet_main,
ARM_LIB_TASKLET_INIT_EVENT);
ARM_LIB_TASKLET_INIT_EVENT);
if (tasklet_data_ptr->tasklet < 0) {
// -1 handler already used by other tasklet
// -2 memory allocation failure

View File

@ -54,7 +54,7 @@ void mesh_system_init(void)
{
if (mesh_initialized == false) {
#if MBED_CONF_MBED_MESH_API_USE_MALLOC_FOR_HEAP
app_stack_heap = malloc(MBED_CONF_MBED_MESH_API_HEAP_SIZE+1);
app_stack_heap = malloc(MBED_CONF_MBED_MESH_API_HEAP_SIZE + 1);
MBED_ASSERT(app_stack_heap);
#endif
ns_hal_init(app_stack_heap, MBED_CONF_MBED_MESH_API_HEAP_SIZE,

View File

@ -214,7 +214,7 @@ void nd_tasklet_parse_network_event(arm_event_s *event)
}
if (tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_READY &&
tasklet_data_ptr->network_interface_id != INVALID_INTERFACE_ID) {
tasklet_data_ptr->network_interface_id != INVALID_INTERFACE_ID) {
// Set 5s timer for new network scan
eventOS_event_timer_request(TIMER_EVENT_START_BOOTSTRAP,
ARM_LIB_SYSTEM_TIMER_EVENT,
@ -268,15 +268,15 @@ void nd_tasklet_configure_and_connect_to_network(void)
tasklet_data_ptr->network_interface_id, NULL);
arm_nwk_6lowpan_link_panid_filter_for_nwk_scan(
tasklet_data_ptr->network_interface_id,
MBED_CONF_MBED_MESH_API_6LOWPAN_ND_PANID_FILTER);
tasklet_data_ptr->network_interface_id,
MBED_CONF_MBED_MESH_API_6LOWPAN_ND_PANID_FILTER);
// Enable MPL by default
const uint8_t all_mpl_forwarders[16] = {0xff, 0x03, [15]=0xfc};
const uint8_t all_mpl_forwarders[16] = {0xff, 0x03, [15] = 0xfc};
multicast_mpl_domain_subscribe(tasklet_data_ptr->network_interface_id,
all_mpl_forwarders,
MULTICAST_MPL_SEED_ID_DEFAULT,
NULL);
all_mpl_forwarders,
MULTICAST_MPL_SEED_ID_DEFAULT,
NULL);
status = arm_nwk_interface_up(tasklet_data_ptr->network_interface_id);
if (status >= 0) {
@ -327,7 +327,7 @@ void nd_tasklet_trace_bootstrap_info()
tr_error("MAC Address read fail\n");
} else {
uint8_t temp[2];
common_write_16_bit(app_link_address_info.mac_short,temp);
common_write_16_bit(app_link_address_info.mac_short, temp);
tr_debug("MAC 16-bit: %s", trace_array(temp, 2));
common_write_16_bit(app_link_address_info.PANId, temp);
tr_debug("PAN ID: %s", trace_array(temp, 2));
@ -378,7 +378,7 @@ int8_t nd_tasklet_connect(mesh_interface_cb callback, int8_t nwk_interface_id)
if (re_connecting == false) {
tasklet_data_ptr->tasklet = eventOS_event_handler_create(&nd_tasklet_main,
ARM_LIB_TASKLET_INIT_EVENT);
ARM_LIB_TASKLET_INIT_EVENT);
if (tasklet_data_ptr->tasklet < 0) {
// -1 handler already used by other tasklet
// -2 memory allocation failure

View File

@ -218,7 +218,7 @@ void thread_tasklet_parse_network_event(arm_event_s *event)
}
if (thread_tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_READY &&
thread_tasklet_data_ptr->nwk_if_id != INVALID_INTERFACE_ID) {
thread_tasklet_data_ptr->nwk_if_id != INVALID_INTERFACE_ID) {
// Set 5s timer for a new network scan
eventOS_event_timer_request(TIMER_EVENT_START_BOOTSTRAP,
ARM_LIB_SYSTEM_TIMER_EVENT,
@ -246,12 +246,14 @@ void thread_tasklet_poll_network_status(void *param)
}
} else {
if (thread_tasklet_data_ptr->connection_status != MESH_DISCONNECTED &&
thread_tasklet_data_ptr->connection_status != MESH_BOOTSTRAP_STARTED)
thread_tasklet_data_ptr->connection_status != MESH_BOOTSTRAP_STARTED) {
thread_tasklet_network_state_changed(MESH_DISCONNECTED);
}
}
}
void read_link_configuration() {
void read_link_configuration()
{
thread_tasklet_data_ptr->link_config.panId = MBED_CONF_MBED_MESH_API_THREAD_CONFIG_PANID;
TRACE_DETAIL("PANID %x", thread_tasklet_data_ptr->link_config.panId);
@ -300,13 +302,12 @@ void read_link_configuration() {
void thread_tasklet_configure_and_connect_to_network(void)
{
int8_t status;
link_configuration_s* temp_link_config=NULL;
link_configuration_s *temp_link_config = NULL;
if (MBED_CONF_MBED_MESH_API_THREAD_DEVICE_TYPE == MESH_DEVICE_TYPE_THREAD_MINIMAL_END_DEVICE) {
thread_tasklet_data_ptr->operating_mode = NET_6LOWPAN_HOST;
}
else if (MBED_CONF_MBED_MESH_API_THREAD_DEVICE_TYPE == MESH_DEVICE_TYPE_THREAD_SLEEPY_END_DEVICE) {
thread_tasklet_data_ptr->operating_mode = NET_6LOWPAN_HOST;
} else if (MBED_CONF_MBED_MESH_API_THREAD_DEVICE_TYPE == MESH_DEVICE_TYPE_THREAD_SLEEPY_END_DEVICE) {
thread_tasklet_data_ptr->operating_mode = NET_6LOWPAN_SLEEPY_HOST;
} else {
thread_tasklet_data_ptr->operating_mode = NET_6LOWPAN_ROUTER;
@ -325,7 +326,7 @@ void thread_tasklet_configure_and_connect_to_network(void)
// PSKd
const char PSKd[] = MBED_CONF_MBED_MESH_API_THREAD_PSKD;
if(device_configuration.PSKd_len==0) {
if (device_configuration.PSKd_len == 0) {
int ret = thread_tasklet_device_pskd_set(PSKd);
MBED_ASSERT(!ret);
}
@ -336,9 +337,9 @@ void thread_tasklet_configure_and_connect_to_network(void)
}
thread_management_node_init(thread_tasklet_data_ptr->nwk_if_id,
&thread_tasklet_data_ptr->channel_list,
&device_configuration,
temp_link_config);
&thread_tasklet_data_ptr->channel_list,
&device_configuration,
temp_link_config);
status = arm_nwk_interface_up(thread_tasklet_data_ptr->nwk_if_id);
@ -382,7 +383,7 @@ void thread_tasklet_trace_bootstrap_info()
tr_error("MAC Address read fail\n");
} else {
uint8_t temp[2];
common_write_16_bit(app_link_address_info.mac_short,temp);
common_write_16_bit(app_link_address_info.mac_short, temp);
tr_debug("MAC 16-bit: %s", trace_array(temp, 2));
common_write_16_bit(app_link_address_info.PANId, temp);
tr_debug("PAN ID: %s", trace_array(temp, 2));
@ -414,7 +415,7 @@ int8_t thread_tasklet_connect(mesh_interface_cb callback, int8_t nwk_interface_i
if (re_connecting == false) {
thread_tasklet_data_ptr->tasklet = eventOS_event_handler_create(&thread_tasklet_main,
ARM_LIB_TASKLET_INIT_EVENT);
ARM_LIB_TASKLET_INIT_EVENT);
if (thread_tasklet_data_ptr->tasklet < 0) {
// -1 handler already used by other tasklet
// -2 memory allocation failure
@ -486,16 +487,16 @@ void thread_tasklet_device_eui64_get(uint8_t *eui64)
uint8_t thread_tasklet_device_pskd_set(const char *pskd)
{
int len = strlen(pskd);
if(len < 6 || len > 32) {
if (len < 6 || len > 32) {
return MESH_ERROR_PARAM;
}
char *dyn_buf = ns_dyn_mem_alloc(strlen(pskd)+1);
char *dyn_buf = ns_dyn_mem_alloc(strlen(pskd) + 1);
if (!dyn_buf) {
return MESH_ERROR_MEMORY;
}
strcpy(dyn_buf, pskd);
ns_dyn_mem_free(device_configuration.PSKd_ptr);
device_configuration.PSKd_ptr = (uint8_t*)dyn_buf;
device_configuration.PSKd_ptr = (uint8_t *)dyn_buf;
device_configuration.PSKd_len = strlen(pskd);
return 0;
}

View File

@ -36,8 +36,7 @@ static const fhss_api_t *fhss_active_handle = NULL;
static EventQueue *equeue;
#endif
struct fhss_timeout_s
{
struct fhss_timeout_s {
void (*fhss_timer_callback)(const fhss_api_t *fhss_api, uint16_t);
uint32_t start_time;
uint32_t stop_time;

View File

@ -39,10 +39,10 @@ static uint8_t sys_irq_disable_counter;
static mbed_rtos_storage_mutex_t critical_mutex;
static const osMutexAttr_t critical_mutex_attr = {
.name = "nanostack_critical_mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
.cb_mem = &critical_mutex,
.cb_size = sizeof critical_mutex,
.name = "nanostack_critical_mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
.cb_mem = &critical_mutex,
.cb_size = sizeof critical_mutex,
};
static osMutexId_t critical_mutex_id;

View File

@ -94,7 +94,7 @@ uint16_t platform_timer_get_remaining_slots(void)
{
uint32_t elapsed = timer->read_us();
if (elapsed < due) {
return (uint16_t) ((due - elapsed) / 50);
return (uint16_t)((due - elapsed) / 50);
} else {
return 0;
}

View File

@ -99,9 +99,9 @@ static void nvm_fsm_timer_cb(void *arg);
static void configuration_store_cb(int32_t status, ARM_CFSTORE_OPCODE cmd_code, void *ctx, ARM_CFSTORE_HANDLE handle)
{
tr_debug("configuration_store_cb status=%d, cmd_code=%d, ctx=%x, hndl=%x", (int)status, (int)cmd_code, (unsigned int)ctx, (unsigned int)handle);
cs_context_t *cf_context = (cs_context_t*)ctx;
cs_context_t *cf_context = (cs_context_t *)ctx;
switch(cmd_code) {
switch (cmd_code) {
case CFSTORE_OPCODE_INITIALIZE:
tr_debug("CFSTORE_OPCODE_INITIALIZE %d", (int)status);
cf_context->state = NVM_STATE_INIT_DONE;
@ -229,8 +229,7 @@ static int nvm_fsm_update(cs_context_t *cs_context)
int ret_val = 0;
tr_debug("nvm_fsm_update() state=%d", (int)cs_context->state);
switch (cs_context->state)
{
switch (cs_context->state) {
case NVM_STATE_UNINIT_DONE:
cs_context->client_cb(cs_context->client_status, cs_context->client_context);
cs_context->state = NVM_STATE_NONE;
@ -288,7 +287,7 @@ platform_nvm_status platform_nvm_init(nvm_callback *callback, void *context)
cs_context_ptr->capabilities = drv->GetCapabilities();
tr_debug("mode: %s", IS_SYNC_MODE(cs_context_ptr) ? "sync": "async" );
tr_debug("mode: %s", IS_SYNC_MODE(cs_context_ptr) ? "sync" : "async");
ret = drv->Initialize(configuration_store_cb, cs_context_ptr);
if (ret < ARM_DRIVER_OK) {
@ -367,14 +366,14 @@ platform_nvm_status platform_nvm_key_create(nvm_callback *callback, const char *
keydesc.drl = ARM_RETENTION_NVM;
ret = drv->Create(key_name, value_len, &keydesc, cs_context_ptr->hkey);
if(ret < ARM_DRIVER_OK) {
if (ret < ARM_DRIVER_OK) {
if (ret == ARM_CFSTORE_DRIVER_ERROR_PREEXISTING_KEY) {
tr_debug("adjust value len to %d", value_len);
ret = drv->Create(key_name, value_len, NULL, cs_context_ptr->hkey);
}
}
if(ret < ARM_DRIVER_OK) {
if (ret < ARM_DRIVER_OK) {
tr_error("Key creation failed %d", (int)ret);
cs_context_ptr->state = NVM_STATE_CREATE_DONE;
cs_context_ptr->client_status = nvm_error_map(ret);
@ -413,7 +412,7 @@ platform_nvm_status platform_nvm_key_delete(nvm_callback *callback, const char *
flags.write = 1;
ret = drv->Open(key_name, flags, cs_context_ptr->hkey);
if(ret < ARM_DRIVER_OK) {
if (ret < ARM_DRIVER_OK) {
tr_error("Key delete, open failed %d", (int)ret);
cs_context_ptr->state = NVM_STATE_DELETE_DONE;
cs_context_ptr->client_status = nvm_error_map(ret);
@ -455,7 +454,7 @@ platform_nvm_status platform_nvm_read(nvm_callback *callback, const char *key_na
flags.read = 1;
ret = drv->Open(key_name, flags, cs_context_ptr->hkey);
if(ret < ARM_DRIVER_OK) {
if (ret < ARM_DRIVER_OK) {
tr_error("Read failed to open handle %d", (int)ret);
cs_context_ptr->state = NVM_STATE_READ_DONE;
cs_context_ptr->client_status = nvm_error_map(ret);
@ -485,7 +484,7 @@ platform_nvm_status platform_nvm_write(nvm_callback *callback, const char *key_n
}
cs_context_ptr->client_cb = callback;
cs_context_ptr->client_context = context;
cs_context_ptr->client_buf = (void*)data;
cs_context_ptr->client_buf = (void *)data;
cs_context_ptr->client_buf_len = data_len;
cs_context_ptr->data_len = *data_len;
cs_context_ptr->client_status = PLATFORM_NVM_OK;
@ -496,7 +495,7 @@ platform_nvm_status platform_nvm_write(nvm_callback *callback, const char *key_n
flags.write = 1;
ret = drv->Open(key_name, flags, cs_context_ptr->hkey);
if(ret < ARM_DRIVER_OK) {
if (ret < ARM_DRIVER_OK) {
tr_error("Write failed %d", (int)ret);
cs_context_ptr->state = NVM_STATE_WRITE_DONE;
cs_context_ptr->client_status = nvm_error_map(ret);
@ -532,7 +531,7 @@ platform_nvm_status platform_nvm_flush(nvm_callback *callback, void *context)
ret = drv->Flush();
if(ret < ARM_DRIVER_OK) {
if (ret < ARM_DRIVER_OK) {
cs_context_ptr->state = NVM_STATE_FLUSH_DONE;
cs_context_ptr->client_status = nvm_error_map(ret);
}
@ -547,9 +546,9 @@ static bool nvm_write_internal(cs_context_t *cf_context)
{
int32_t ret;
cf_context->state = NVM_STATE_WRITING;
ret = drv->Write(cf_context->hkey, (const char*)cf_context->client_buf, &cf_context->data_len);
ret = drv->Write(cf_context->hkey, (const char *)cf_context->client_buf, &cf_context->data_len);
if(ret >= ARM_DRIVER_OK) {
if (ret >= ARM_DRIVER_OK) {
return true;
} else {
tr_error("Write failed %d", (int)ret);
@ -561,9 +560,9 @@ static bool nvm_read_internal(cs_context_t *cf_context)
{
int32_t ret;
cf_context->state = NVM_STATE_READING;
ret = drv->Read(cf_context->hkey, (void*)cf_context->client_buf, &cf_context->data_len);
ret = drv->Read(cf_context->hkey, (void *)cf_context->client_buf, &cf_context->data_len);
if(ret >= ARM_DRIVER_OK) {
if (ret >= ARM_DRIVER_OK) {
return true;
} else {
tr_error("Read failed %d", (int)ret);
@ -577,7 +576,7 @@ static bool nvm_delete_internal(cs_context_t *cf_context)
cf_context->state = NVM_STATE_DELETING;
ret = drv->Delete(cf_context->hkey);
if(ret >= ARM_DRIVER_OK) {
if (ret >= ARM_DRIVER_OK) {
return true;
} else {
tr_error("Delete failed %d", (int)ret);
@ -591,7 +590,7 @@ static bool nvm_close_internal(cs_context_t *cf_context)
cf_context->state = NVM_STATE_CLOSING;
ret = drv->Close(cf_context->hkey);
if(ret >= ARM_DRIVER_OK) {
if (ret >= ARM_DRIVER_OK) {
return true;
} else {
tr_error("Close failed %d", (int)ret);
@ -626,7 +625,7 @@ static platform_nvm_status nvm_error_map(int32_t cs_error)
return PLATFORM_NVM_OK;
}
switch(cs_error) {
switch (cs_error) {
case ARM_CFSTORE_DRIVER_ERROR_KEY_NOT_FOUND:
client_error = PLATFORM_NVM_KEY_NOT_FOUND;
break;
@ -641,7 +640,7 @@ static platform_nvm_status nvm_error_map(int32_t cs_error)
static void nvm_fsm_timer_cb(void *args)
{
(void) args;
switch(nvm_fsm_update(cs_context_ptr)) {
switch (nvm_fsm_update(cs_context_ptr)) {
case 0:
// Nothing processed, restart timer
tr_debug("nvm_fsm_timer_cb not handled event in () %d", (int)cs_context_ptr->state);

View File

@ -22,8 +22,7 @@ uint8_t buf[100];
uint16_t buf_len;
uint16_t data_len;
typedef struct
{
typedef struct {
platform_nvm_status status;
void *ctx;
} test_platform_nvm_api_callback_t;
@ -187,7 +186,7 @@ bool test_cs_nvm_init_finalize()
}
// finalize NVM - OK
if (!test_nvm_finalize()){
if (!test_nvm_finalize()) {
return false;
}
@ -300,7 +299,7 @@ bool test_cs_nvm_key_create()
}
// finalize NVM - OK
if (!test_nvm_finalize()){
if (!test_nvm_finalize()) {
return false;
}

View File

@ -16,7 +16,7 @@ static int32_t test_cfstore_close(ARM_CFSTORE_HANDLE hkey)
return cfstore_stub.close_ret_val;
}
static int32_t test_cfstore_create(const char* key_name, ARM_CFSTORE_SIZE value_len, const ARM_CFSTORE_KEYDESC* kdesc, ARM_CFSTORE_HANDLE hkey)
static int32_t test_cfstore_create(const char *key_name, ARM_CFSTORE_SIZE value_len, const ARM_CFSTORE_KEYDESC *kdesc, ARM_CFSTORE_HANDLE hkey)
{
return cfstore_stub.ret_val;
}
@ -26,7 +26,7 @@ static int32_t test_cfstore_delete(ARM_CFSTORE_HANDLE hkey)
return cfstore_stub.delete_ret_val;
}
static int32_t test_cfstore_find(const char* key_name_query, const ARM_CFSTORE_HANDLE previous, ARM_CFSTORE_HANDLE next)
static int32_t test_cfstore_find(const char *key_name_query, const ARM_CFSTORE_HANDLE previous, ARM_CFSTORE_HANDLE next)
{
return ARM_DRIVER_OK;
}
@ -42,7 +42,7 @@ ARM_CFSTORE_CAPABILITIES test_cfstore_get_capabilities(void)
return cfstore_caps_g;
}
static int32_t test_cfstore_get_key_name(ARM_CFSTORE_HANDLE hkey, char* key_name, uint8_t *key_name_len)
static int32_t test_cfstore_get_key_name(ARM_CFSTORE_HANDLE hkey, char *key_name, uint8_t *key_name_len)
{
return ARM_DRIVER_OK;
}
@ -64,14 +64,14 @@ ARM_DRIVER_VERSION test_cfstore_get_version(void)
return cfstore_driver_version_g;
}
static int32_t test_cfstore_initialise(ARM_CFSTORE_CALLBACK callback, void* client_context)
static int32_t test_cfstore_initialise(ARM_CFSTORE_CALLBACK callback, void *client_context)
{
cfstore_stub.callback = callback;
cfstore_stub.client_context = client_context;
return cfstore_stub.ret_val;
}
static int32_t test_cfstore_open(const char* key_name, ARM_CFSTORE_FMODE flags, ARM_CFSTORE_HANDLE hkey)
static int32_t test_cfstore_open(const char *key_name, ARM_CFSTORE_FMODE flags, ARM_CFSTORE_HANDLE hkey)
{
return cfstore_stub.ret_val;
}
@ -81,7 +81,7 @@ static int32_t test_cfstore_power_control(ARM_POWER_STATE state)
return ARM_DRIVER_OK;
}
static int32_t test_cfstore_read(ARM_CFSTORE_HANDLE hkey, void* data, ARM_CFSTORE_SIZE* len)
static int32_t test_cfstore_read(ARM_CFSTORE_HANDLE hkey, void *data, ARM_CFSTORE_SIZE *len)
{
return cfstore_stub.read_ret_val;
}
@ -96,30 +96,29 @@ static int32_t test_cfstore_uninitialise(void)
return cfstore_stub.ret_val;
}
static int32_t test_cfstore_write(ARM_CFSTORE_HANDLE hkey, const char* data, ARM_CFSTORE_SIZE* len)
static int32_t test_cfstore_write(ARM_CFSTORE_HANDLE hkey, const char *data, ARM_CFSTORE_SIZE *len)
{
return cfstore_stub.write_ret_val;
}
ARM_CFSTORE_DRIVER cfstore_driver =
{
.Close = test_cfstore_close,
.Create = test_cfstore_create,
.Delete= test_cfstore_delete,
.Find = test_cfstore_find,
.Flush = test_cfstore_flush,
.GetCapabilities = test_cfstore_get_capabilities,
.GetKeyName = test_cfstore_get_key_name,
.GetStatus = test_cfstore_get_status,
.GetValueLen = test_cfstore_get_value_len,
.GetVersion = test_cfstore_get_version,
.Initialize = test_cfstore_initialise,
.Open = test_cfstore_open,
.PowerControl = test_cfstore_power_control,
.Read = test_cfstore_read,
.Rseek = test_cfstore_rseek,
.Uninitialize = test_cfstore_uninitialise,
.Write = test_cfstore_write,
ARM_CFSTORE_DRIVER cfstore_driver = {
.Close = test_cfstore_close,
.Create = test_cfstore_create,
.Delete = test_cfstore_delete,
.Find = test_cfstore_find,
.Flush = test_cfstore_flush,
.GetCapabilities = test_cfstore_get_capabilities,
.GetKeyName = test_cfstore_get_key_name,
.GetStatus = test_cfstore_get_status,
.GetValueLen = test_cfstore_get_value_len,
.GetVersion = test_cfstore_get_version,
.Initialize = test_cfstore_initialise,
.Open = test_cfstore_open,
.PowerControl = test_cfstore_power_control,
.Read = test_cfstore_read,
.Rseek = test_cfstore_rseek,
.Uninitialize = test_cfstore_uninitialise,
.Write = test_cfstore_write,
};

View File

@ -190,7 +190,7 @@ void debug_int(int i)
{
}
void printf_array(const void *buf , uint16_t len)
void printf_array(const void *buf, uint16_t len)
{
}

View File

@ -17,32 +17,26 @@ void ns_dyn_mem_init(uint8_t *heap, uint16_t h_size, void (*passed_fptr)(heap_fa
void *ns_dyn_mem_alloc(int16_t alloc_size)
{
if (nsdynmemlib_stub.returnCounter > 0)
{
if (nsdynmemlib_stub.returnCounter > 0) {
nsdynmemlib_stub.returnCounter--;
return malloc(alloc_size);
}
else
{
return(nsdynmemlib_stub.expectedPointer);
} else {
return (nsdynmemlib_stub.expectedPointer);
}
}
void *ns_dyn_mem_temporary_alloc(int16_t alloc_size)
{
if (nsdynmemlib_stub.returnCounter > 0)
{
if (nsdynmemlib_stub.returnCounter > 0) {
nsdynmemlib_stub.returnCounter--;
return malloc(alloc_size);
}
else
{
return(nsdynmemlib_stub.expectedPointer);
} else {
return (nsdynmemlib_stub.expectedPointer);
}
}
void ns_dyn_mem_free(void *block)
{
free(block);
free(block);
}

View File

@ -12,7 +12,7 @@ extern "C" {
typedef struct {
uint8_t returnCounter;
void* expectedPointer;
void *expectedPointer;
} nsdynmemlib_stub_data_t;
extern nsdynmemlib_stub_data_t nsdynmemlib_stub;

View File

@ -19,7 +19,8 @@ void eventOS_timeout_cancel(timeout_t *t)
}
void test_eventOS_timeout_trigger() {
void test_eventOS_timeout_trigger()
{
test_callback(test_args);
}

View File

@ -47,7 +47,7 @@ static osEventFlagsId_t event_flag_id;
static void event_loop_thread(void *arg);
static uint64_t event_thread_stk[MBED_CONF_NANOSTACK_HAL_EVENT_LOOP_THREAD_STACK_SIZE/8];
static uint64_t event_thread_stk[MBED_CONF_NANOSTACK_HAL_EVENT_LOOP_THREAD_STACK_SIZE / 8];
static mbed_rtos_storage_thread_t event_thread_tcb;
static const osThreadAttr_t event_thread_attr = {
.name = "nanostack_event_thread",

View File

@ -28,10 +28,10 @@
static mbed_rtos_storage_mutex_t event_mutex;
static const osMutexAttr_t event_mutex_attr = {
.name = "nanostack_event_mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
.cb_mem = &event_mutex,
.cb_size = sizeof event_mutex,
.name = "nanostack_event_mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
.cb_mem = &event_mutex,
.cb_size = sizeof event_mutex,
};
static osMutexId_t event_mutex_id;
static osThreadId_t event_mutex_owner_id = NULL;

View File

@ -143,7 +143,7 @@ platform_nvm_status platform_nvm_key_create(nvm_callback *callback, const char *
tr_debug("platform_nvm_key_create() %s len=%d", key_name, (int)value_len);
ns_list_foreach(nvm_data_entry_t, current_entry, &nvm_entry_list) {
if (strcmp(current_entry->key, key_name)==0) {
if (strcmp(current_entry->key, key_name) == 0) {
// resizing existing key
ns_list_remove(&nvm_entry_list, current_entry);
nvm_ram_free_entry(current_entry);
@ -182,7 +182,7 @@ platform_nvm_status platform_nvm_key_delete(nvm_callback *callback, const char *
tr_debug("platform_nvm_key_delete() %s", key_name);
ns_list_foreach(nvm_data_entry_t, current_entry, &nvm_entry_list) {
if (strcmp(current_entry->key, key_name)==0) {
if (strcmp(current_entry->key, key_name) == 0) {
client_status = PLATFORM_NVM_OK;
ns_list_remove(&nvm_entry_list, current_entry);
nvm_ram_free_entry(current_entry);
@ -199,7 +199,7 @@ platform_nvm_status platform_nvm_write(nvm_callback *callback, const char *key_n
tr_debug("platform_nvm_write() %s len=%d", key_name, (int)*data_len);
ns_list_foreach(nvm_data_entry_t, current_entry, &nvm_entry_list) {
if (strcmp(current_entry->key, key_name)==0) {
if (strcmp(current_entry->key, key_name) == 0) {
if (current_entry->data_len >= *data_len) {
memcpy(current_entry->data, data, *data_len);
} else {
@ -211,7 +211,7 @@ platform_nvm_status platform_nvm_write(nvm_callback *callback, const char *key_n
}
}
return create_client_request(callback, context, (void*)data, data_len, client_status);
return create_client_request(callback, context, (void *)data, data_len, client_status);
}
platform_nvm_status platform_nvm_read(nvm_callback *callback, const char *key_name, void *buf, uint16_t *buf_len, void *context)
@ -220,7 +220,7 @@ platform_nvm_status platform_nvm_read(nvm_callback *callback, const char *key_na
tr_debug("platform_nvm_read() %s len=%d", key_name, (int)*buf_len);
ns_list_foreach(nvm_data_entry_t, current_entry, &nvm_entry_list) {
if (strcmp(current_entry->key, key_name)==0) {
if (strcmp(current_entry->key, key_name) == 0) {
if (*buf_len >= current_entry->data_len) {
memcpy(buf, current_entry->data, current_entry->data_len);
*buf_len = current_entry->data_len;

View File

@ -61,15 +61,18 @@ enum socket_mode_t {
class NanostackSocket {
public:
static void socket_callback(void *cb);
static void* operator new(std::size_t sz);
static void operator delete(void* ptr);
static void *operator new (std::size_t sz);
static void operator delete (void *ptr);
NanostackSocket(int8_t protocol);
~NanostackSocket(void);
bool open(void);
int accept(NanostackSocket *accepted_socket, ns_address_t *addr);
void close(void);
bool closed(void) {return SOCKET_MODE_CLOSED == mode;}
bool closed(void)
{
return SOCKET_MODE_CLOSED == mode;
}
bool is_connecting(void);
void set_connecting(ns_address_t *addr);
bool is_connected(void);
@ -101,21 +104,26 @@ private:
socket_mode_t mode;
};
static NanostackSocket * socket_tbl[NS_INTERFACE_SOCKETS_MAX];
static NanostackSocket *socket_tbl[NS_INTERFACE_SOCKETS_MAX];
nsapi_error_t map_mesh_error(mesh_error_t err)
{
switch (err) {
case MESH_ERROR_NONE: return 0;
case MESH_ERROR_MEMORY: return NSAPI_ERROR_NO_MEMORY;
case MESH_ERROR_PARAM: return NSAPI_ERROR_UNSUPPORTED;
case MESH_ERROR_STATE: return NSAPI_ERROR_DEVICE_ERROR;
default: return NSAPI_ERROR_DEVICE_ERROR;
case MESH_ERROR_NONE:
return 0;
case MESH_ERROR_MEMORY:
return NSAPI_ERROR_NO_MEMORY;
case MESH_ERROR_PARAM:
return NSAPI_ERROR_UNSUPPORTED;
case MESH_ERROR_STATE:
return NSAPI_ERROR_DEVICE_ERROR;
default:
return NSAPI_ERROR_DEVICE_ERROR;
}
}
static void convert_mbed_addr_to_ns(ns_address_t *ns_addr,
const SocketAddress *s_addr)
const SocketAddress *s_addr)
{
ns_addr->type = ADDRESS_IPV6;
ns_addr->identifier = s_addr->get_port();
@ -142,10 +150,12 @@ static int8_t find_interface_by_address(const uint8_t target_addr[16])
return -1;
}
void* NanostackSocket::operator new(std::size_t sz) {
void *NanostackSocket::operator new (std::size_t sz)
{
return MALLOC(sz);
}
void NanostackSocket::operator delete(void* ptr) {
void NanostackSocket::operator delete (void *ptr)
{
FREE(ptr);
}
@ -296,7 +306,8 @@ void NanostackSocket::signal_event()
}
}
void NanostackSocket::socket_callback(void *cb) {
void NanostackSocket::socket_callback(void *cb)
{
nanostack_assert_locked();
socket_callback_t *sock_cb = (socket_callback_t *) cb;
@ -304,7 +315,7 @@ void NanostackSocket::socket_callback(void *cb) {
MBED_ASSERT(socket != NULL);
tr_debug("socket_callback() sock=%d, event=%d, interface=%d, data len=%d",
sock_cb->socket_id, sock_cb->event_type, sock_cb->interface_id, sock_cb->d_len);
sock_cb->socket_id, sock_cb->event_type, sock_cb->interface_id, sock_cb->d_len);
switch (sock_cb->event_type) {
case SOCKET_DATA:
@ -506,7 +517,7 @@ Nanostack::call_in_callback_cb_t Nanostack::get_call_in_callback()
return cb;
}
const char * Nanostack::get_ip_address()
const char *Nanostack::get_ip_address()
{
NanostackLockGuard lock;
@ -539,11 +550,11 @@ nsapi_error_t Nanostack::socket_open(void **handle, nsapi_protocol_t protocol)
MBED_ASSERT(false);
return NSAPI_ERROR_UNSUPPORTED;
}
*handle = (void*)NULL;
*handle = (void *)NULL;
NanostackLockGuard lock;
NanostackSocket * socket = new NanostackSocket(ns_proto);
NanostackSocket *socket = new NanostackSocket(ns_proto);
if (socket == NULL) {
tr_debug("socket_open() ret=%i", NSAPI_ERROR_NO_MEMORY);
return NSAPI_ERROR_NO_MEMORY;
@ -553,7 +564,7 @@ nsapi_error_t Nanostack::socket_open(void **handle, nsapi_protocol_t protocol)
tr_debug("socket_open() ret=%i", NSAPI_ERROR_NO_MEMORY);
return NSAPI_ERROR_NO_MEMORY;
}
*handle = (void*)socket;
*handle = (void *)socket;
tr_debug("socket_open() socket=%p, sock_id=%d, ret=0", socket, socket->socket_id);
@ -564,7 +575,7 @@ nsapi_error_t Nanostack::socket_close(void *handle)
{
NanostackLockGuard lock;
// Validate parameters
NanostackSocket * socket = static_cast<NanostackSocket *>(handle);
NanostackSocket *socket = static_cast<NanostackSocket *>(handle);
if (NULL == handle) {
MBED_ASSERT(false);
return NSAPI_ERROR_NO_SOCKET;
@ -580,7 +591,7 @@ nsapi_error_t Nanostack::socket_close(void *handle)
nsapi_size_or_error_t Nanostack::do_sendto(void *handle, const ns_address_t *address, const void *data, nsapi_size_t size)
{
// Validate parameters
NanostackSocket * socket = static_cast<NanostackSocket *>(handle);
NanostackSocket *socket = static_cast<NanostackSocket *>(handle);
if (handle == NULL) {
MBED_ASSERT(false);
return NSAPI_ERROR_NO_SOCKET;
@ -604,7 +615,7 @@ nsapi_size_or_error_t Nanostack::do_sendto(void *handle, const ns_address_t *add
int retcode;
#if 0
retcode = ::socket_sendto(socket->socket_id, address,
data, size);
data, size);
#else
// Use sendmsg purely to get the new return style
// of returning data written rather than 0 on success,
@ -616,7 +627,7 @@ nsapi_size_or_error_t Nanostack::do_sendto(void *handle, const ns_address_t *add
iov.iov_base = const_cast<void *>(data);
iov.iov_len = size;
msg.msg_name = const_cast<ns_address_t *>(address);
msg.msg_namelen = address ? sizeof *address : 0;
msg.msg_namelen = address ? sizeof * address : 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = NULL;
@ -771,7 +782,7 @@ nsapi_error_t Nanostack::setsockopt(void *handle, int level, int optname, const
/* Check address types are IPv6, or unspecified for interface */
if (imr->imr_multiaddr.version != NSAPI_IPv6 ||
(imr->imr_interface.version != NSAPI_UNSPEC && imr->imr_interface.version != NSAPI_IPv6)) {
(imr->imr_interface.version != NSAPI_UNSPEC && imr->imr_interface.version != NSAPI_IPv6)) {
return NSAPI_ERROR_PARAMETER;
}
@ -841,7 +852,7 @@ nsapi_error_t Nanostack::socket_listen(void *handle, int backlog)
NanostackLockGuard lock;
if(::socket_listen(socket->socket_id, backlog) < 0) {
if (::socket_listen(socket->socket_id, backlog) < 0) {
ret = NSAPI_ERROR_PARAMETER;
} else {
socket->set_listening();
@ -904,7 +915,7 @@ out:
nsapi_error_t Nanostack::socket_accept(void *server, void **handle, SocketAddress *address)
{
NanostackSocket * socket = static_cast<NanostackSocket *>(server);
NanostackSocket *socket = static_cast<NanostackSocket *>(server);
NanostackSocket *accepted_sock = NULL;
nsapi_error_t ret;
@ -965,7 +976,7 @@ nsapi_size_or_error_t Nanostack::socket_recv(void *handle, void *data, nsapi_siz
void Nanostack::socket_attach(void *handle, void (*callback)(void *), void *id)
{
// Validate parameters
NanostackSocket * socket = static_cast<NanostackSocket *>(handle);
NanostackSocket *socket = static_cast<NanostackSocket *>(handle);
if (handle == NULL) {
MBED_ASSERT(false);
return;
@ -979,7 +990,8 @@ void Nanostack::socket_attach(void *handle, void (*callback)(void *), void *id)
tr_debug("socket_attach(socket=%p) sock_id=%d", socket, socket->socket_id);
}
Nanostack &Nanostack::get_instance() {
Nanostack &Nanostack::get_instance()
{
static Nanostack nanostack;
return nanostack;
}
@ -989,7 +1001,8 @@ Nanostack &Nanostack::get_instance() {
#define NANOSTACK 0x99119911
#if MBED_CONF_NSAPI_DEFAULT_STACK == NANOSTACK
#undef NANOSTACK
OnboardNetworkStack &OnboardNetworkStack::get_default_instance() {
OnboardNetworkStack &OnboardNetworkStack::get_default_instance()
{
return Nanostack::get_instance();
}
#endif

View File

@ -27,17 +27,19 @@
class NanostackLockGuard {
public:
NanostackLockGuard() {
NanostackLockGuard()
{
eventOS_scheduler_mutex_wait();
}
~NanostackLockGuard() {
~NanostackLockGuard()
{
eventOS_scheduler_mutex_release();
}
private:
NanostackLockGuard(const NanostackLockGuard&);
NanostackLockGuard& operator=(const NanostackLockGuard&);
NanostackLockGuard(const NanostackLockGuard &);
NanostackLockGuard &operator=(const NanostackLockGuard &);
};
#endif /* NANOSTACK_LOCK_GUARD_H_ */

View File

@ -48,12 +48,18 @@ public:
* @return Device driver ID or a negative error
* code on failure
*/
virtual int8_t phy_register() { return rf_register();}
virtual int8_t phy_register()
{
return rf_register();
}
/** Unregister this physical interface
*
*/
virtual void unregister() { rf_unregister(); }
virtual void unregister()
{
rf_unregister();
}
};
#endif /* NANOSTACK_RF_PHY_H_ */

View File

@ -78,14 +78,16 @@ static timeout_t *eventOS_timeout_at_(void (*callback)(void *), void *arg, uint3
.data_ptr = timeout
};
if (period)
if (period) {
storage = eventOS_event_timer_request_every(&event, period);
else
} else {
storage = eventOS_event_timer_request_at(&event, at);
}
timeout->event = storage;
if (storage)
if (storage) {
return timeout;
}
FAIL:
ns_dyn_mem_free(timeout);
return NULL;
@ -93,7 +95,7 @@ FAIL:
timeout_t *eventOS_timeout_ms(void (*callback)(void *), uint32_t ms, void *arg)
{
return eventOS_timeout_at_(callback, arg, eventOS_event_timer_ms_to_ticks(ms)+eventOS_event_timer_ticks(), 0);
return eventOS_timeout_at_(callback, arg, eventOS_event_timer_ms_to_ticks(ms) + eventOS_event_timer_ticks(), 0);
}
timeout_t *eventOS_timeout_every_ms(void (*callback)(void *), uint32_t every, void *arg)
@ -103,8 +105,9 @@ timeout_t *eventOS_timeout_every_ms(void (*callback)(void *), uint32_t every, vo
void eventOS_timeout_cancel(timeout_t *t)
{
if (!t)
if (!t) {
return;
}
eventOS_cancel(t->event);

View File

@ -53,7 +53,7 @@ static int8_t platform_tick_timer_start(uint32_t period_ms);
/* Implement platform tick timer using eventOS timer */
// platform tick timer callback function
static void (*tick_timer_callback)(void);
static int8_t tick_timer_id = -1; // eventOS timer id for tick timer
static int8_t tick_timer_id = -1; // eventOS timer id for tick timer
// EventOS timer callback function
static void tick_timer_eventOS_callback(int8_t timer_id, uint16_t slots)
@ -299,7 +299,7 @@ int8_t eventOS_event_timer_request(uint8_t event_id, uint8_t event_type, int8_t
platform_enter_critical();
arm_event_storage_t *ret = eventOS_event_timer_request_at_(&event, timer_sys_ticks + time, 0);
platform_exit_critical();
return ret?0:-1;
return ret ? 0 : -1;
}
int8_t eventOS_event_timer_cancel(uint8_t event_id, int8_t tasklet_id)

View File

@ -20,32 +20,69 @@
#ifdef CELLULAR_DEVICE
using namespace mbed;
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This API will be deprecated, use CellularBase::get_default_instance() instead.")
class OnboardCellularInterface : public CellularBase
{
class OnboardCellularInterface : public CellularBase {
public:
OnboardCellularInterface() {
OnboardCellularInterface()
{
context = CellularContext::get_default_instance();
MBED_ASSERT(context != NULL);
}
public: // from NetworkInterface
virtual nsapi_error_t set_blocking(bool blocking) {return context->set_blocking(blocking);}
virtual NetworkStack *get_stack() {return context->get_stack();}
virtual const char *get_ip_address() {return context->get_ip_address();}
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb) {context->attach(status_cb);}
virtual nsapi_error_t connect() {return context->connect();}
virtual nsapi_error_t disconnect() {return context->disconnect();}
virtual nsapi_error_t set_blocking(bool blocking)
{
return context->set_blocking(blocking);
}
virtual NetworkStack *get_stack()
{
return context->get_stack();
}
virtual const char *get_ip_address()
{
return context->get_ip_address();
}
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb)
{
context->attach(status_cb);
}
virtual nsapi_error_t connect()
{
return context->connect();
}
virtual nsapi_error_t disconnect()
{
return context->disconnect();
}
// from CellularBase
virtual void set_plmn(const char *plmn) {context->set_plmn(plmn);}
virtual void set_sim_pin(const char *sim_pin) {context->set_sim_pin(sim_pin);}
virtual void set_plmn(const char *plmn)
{
context->set_plmn(plmn);
}
virtual void set_sim_pin(const char *sim_pin)
{
context->set_sim_pin(sim_pin);
}
virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0, const char *uname = 0,
const char *pwd = 0)
{return context->connect(sim_pin, apn, uname, pwd);}
{
return context->connect(sim_pin, apn, uname, pwd);
}
virtual void set_credentials(const char *apn, const char *uname = 0, const char *pwd = 0)
{context->set_credentials(apn, uname, pwd);}
virtual const char *get_netmask() {return context->get_netmask();}
virtual const char *get_gateway() {return context->get_gateway();}
virtual bool is_connected() {return context->is_connected();}
{
context->set_credentials(apn, uname, pwd);
}
virtual const char *get_netmask()
{
return context->get_netmask();
}
virtual const char *get_gateway()
{
return context->get_gateway();
}
virtual bool is_connected()
{
return context->is_connected();
}
private:
CellularContext *context;

View File

@ -253,16 +253,16 @@ void test_get_erase_value()
utest_printf("\nstart_address=0x%016" PRIx64, start_address);
// Allocate buffer for read test data
uint8_t *data_buf = (uint8_t*)malloc(data_buf_size);
uint8_t *data_buf = (uint8_t *)malloc(data_buf_size);
TEST_ASSERT_NOT_NULL(data_buf);
// Write random data to selected region to make sure data is not accidentally set to "erased" value.
// With this pre-write, the test case will fail even if block_device->erase() is broken.
for (bd_size_t i=0; i<data_buf_size; i++) {
for (bd_size_t i = 0; i < data_buf_size; i++) {
data_buf[i] = (uint8_t) rand();
}
utest_printf("\nwriting given memory region");
err = block_device->program((const void*)data_buf, start_address, data_buf_size);
err = block_device->program((const void *)data_buf, start_address, data_buf_size);
TEST_ASSERT_EQUAL(0, err);
// Erase given memory region
@ -272,12 +272,12 @@ void test_get_erase_value()
// Read erased memory region
utest_printf("\nreading erased memory region");
err = block_device->read((void*)data_buf, start_address, data_buf_size);
err = block_device->read((void *)data_buf, start_address, data_buf_size);
TEST_ASSERT_EQUAL(0, err);
// Verify erased memory region
utest_printf("\nverifying erased memory region");
for (bd_size_t i=0; i<data_buf_size; i++) {
for (bd_size_t i = 0; i < data_buf_size; i++) {
TEST_ASSERT_EQUAL(erase_value, data_buf[i]);
}
@ -323,8 +323,8 @@ void test_contiguous_erase_write_read()
write_read_buf_size = 10000;
}
// 2 program_size blocks is minimum for contiguous write/read test
if (write_read_buf_size < program_size*2) {
write_read_buf_size = program_size*2; // going over 10k
if (write_read_buf_size < program_size * 2) {
write_read_buf_size = program_size * 2; // going over 10k
}
bd_size_t contiguous_write_read_blocks_per_region = write_read_buf_size / program_size; // 2 is minimum to test contiguous write
write_read_buf_size = contiguous_write_read_blocks_per_region * program_size;
@ -352,7 +352,7 @@ void test_contiguous_erase_write_read()
utest_printf("\nstop_address=0x%016" PRIx64, stop_address);
// Allocate write/read buffer
uint8_t *write_read_buf = (uint8_t*)malloc(write_read_buf_size);
uint8_t *write_read_buf = (uint8_t *)malloc(write_read_buf_size);
if (write_read_buf == NULL) {
block_device->deinit();
TEST_SKIP_MESSAGE("\nnot enough memory for test");
@ -361,12 +361,12 @@ void test_contiguous_erase_write_read()
// Pre-fill the to-be-erased region. By pre-filling the region,
// we can be sure the test will not pass if the erase doesn't work.
for (bd_size_t offset=0; start_address+offset < stop_address; offset+=write_read_buf_size) {
for (size_t i=0; i<write_read_buf_size; i++) {
for (bd_size_t offset = 0; start_address + offset < stop_address; offset += write_read_buf_size) {
for (size_t i = 0; i < write_read_buf_size; i++) {
write_read_buf[i] = (uint8_t)rand();
}
utest_printf("\npre-filling memory, from 0x%" PRIx64 " of size 0x%" PRIx64, start_address+offset, write_read_buf_size);
err = block_device->program((const void*)write_read_buf, start_address+offset, write_read_buf_size);
utest_printf("\npre-filling memory, from 0x%" PRIx64 " of size 0x%" PRIx64, start_address + offset, write_read_buf_size);
err = block_device->program((const void *)write_read_buf, start_address + offset, write_read_buf_size);
TEST_ASSERT_EQUAL(0, err);
}
@ -377,20 +377,20 @@ void test_contiguous_erase_write_read()
// Loop through all write/read regions
int region = 0;
for (; start_address < stop_address; start_address+=write_read_buf_size) {
for (; start_address < stop_address; start_address += write_read_buf_size) {
utest_printf("\n\nregion #%d start_address=0x%016" PRIx64, region++, start_address);
// Generate test data
unsigned int seed = rand();
utest_printf("\ngenerating test data, seed=%u", seed);
srand(seed);
for (size_t i=0; i<write_read_buf_size; i++) {
for (size_t i = 0; i < write_read_buf_size; i++) {
write_read_buf[i] = (uint8_t)rand();
}
// Write test data
utest_printf("\nwriting test data");
err = block_device->program((const void*)write_read_buf, start_address, write_read_buf_size);
err = block_device->program((const void *)write_read_buf, start_address, write_read_buf_size);
TEST_ASSERT_EQUAL(0, err);
// Read test data
@ -402,11 +402,11 @@ void test_contiguous_erase_write_read()
// Verify read data
utest_printf("\nverifying test data");
srand(seed);
for (size_t i=0; i<write_read_buf_size; i++) {
for (size_t i = 0; i < write_read_buf_size; i++) {
uint8_t expected_value = (uint8_t)rand();
if (write_read_buf[i] != expected_value) {
utest_printf("\ndata verify failed, write_read_buf[%d]=%" PRIu8 " and not %" PRIu8 "\n",
i, write_read_buf[i], expected_value);
i, write_read_buf[i], expected_value);
}
TEST_ASSERT_EQUAL(write_read_buf[i], expected_value);
}

View File

@ -104,7 +104,7 @@ public:
inline void context(uint32_t context)
{
_context = (void*)context;
_context = (void *)context;
}
inline uint32_t entry(void)

View File

@ -61,28 +61,28 @@ MBED_STATIC_ASSERT(MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX > 0, "MBED_CONF_PLATFORM_
const CThunkEntry CThunkBase::_thunk_table[MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX] = {
#if ENABLE_N(128)
DECLARE_THUNK128(START_128),
DECLARE_THUNK128(START_128),
#endif
#if ENABLE_N(64)
DECLARE_THUNK64(START_64),
DECLARE_THUNK64(START_64),
#endif
#if ENABLE_N(32)
DECLARE_THUNK32(START_32),
DECLARE_THUNK32(START_32),
#endif
#if ENABLE_N(16)
DECLARE_THUNK16(START_16),
DECLARE_THUNK16(START_16),
#endif
#if ENABLE_N(8)
DECLARE_THUNK8(START_8),
DECLARE_THUNK8(START_8),
#endif
#if ENABLE_N(4)
DECLARE_THUNK4(START_4),
DECLARE_THUNK4(START_4),
#endif
#if ENABLE_N(2)
DECLARE_THUNK2(START_2),
DECLARE_THUNK2(START_2),
#endif
#if ENABLE_N(1)
DECLARE_THUNK1(START_1)
DECLARE_THUNK1(START_1)
#endif
};

View File

@ -22,7 +22,7 @@ typedef void (*CThunkEntry)(void);
class CThunkBase {
protected:
typedef void (*Trampoline)(CThunkBase*);
typedef void (*Trampoline)(CThunkBase *);
Trampoline _trampoline;

View File

@ -39,12 +39,13 @@ namespace span_detail {
// If From type is convertible to To type, then the compilation constant value is
// true; otherwise, it is false.
template<typename From, typename To>
class is_convertible
{
struct true_type { char x[512]; };
class is_convertible {
struct true_type {
char x[512];
};
struct false_type { };
static const From& generator();
static const From &generator();
static true_type sink(const To &);
static false_type sink(...);
@ -293,6 +294,8 @@ struct Span {
MBED_ASSERT(Extent == 0 || first != NULL);
}
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/**
* Construct a Span from the reference to an array.
*
@ -322,6 +325,7 @@ struct Span {
"OtherElementType(*)[] should be convertible to ElementType (*)[]"
);
}
// *INDENT-ON*
/**
* Return the size of the sequence viewed.
@ -409,6 +413,8 @@ struct Span {
return Span<element_type, Count>(_data + (Extent - Count), Count);
}
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/**
* Create a subspan that is a view of other Count elements; the view starts at
* element Offset.
@ -439,6 +445,7 @@ struct Span {
Count == SPAN_DYNAMIC_EXTENT ? Extent - Offset : Count
);
}
// *INDENT-ON*
/**
* Create a new Span over the first @p count elements of the existing view.
@ -464,9 +471,9 @@ struct Span {
{
MBED_ASSERT(0 <= count && count <= Extent);
return Span<element_type, SPAN_DYNAMIC_EXTENT>(
_data + (Extent - count),
count
);
_data + (Extent - count),
count
);
}
/**
@ -491,9 +498,9 @@ struct Span {
(0 <= count && (count + offset) <= Extent)
);
return Span<element_type, SPAN_DYNAMIC_EXTENT>(
_data + offset,
count == SPAN_DYNAMIC_EXTENT ? Extent - offset : count
);
_data + offset,
count == SPAN_DYNAMIC_EXTENT ? Extent - offset : count
);
}
private:
@ -579,6 +586,8 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
MBED_ASSERT(first != NULL || (last - first) == 0);
}
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/**
* Construct a Span from the reference to an array.
*
@ -611,6 +620,7 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
"OtherElementType(*)[] should be convertible to ElementType (*)[]"
);
}
// *INDENT-ON*
/**
* Return the size of the array viewed.
@ -713,9 +723,9 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
(0 <= Count && (Count + Offset) <= _size)
);
return Span<element_type, Count>(
_data + Offset,
Count == SPAN_DYNAMIC_EXTENT ? _size - Offset : Count
);
_data + Offset,
Count == SPAN_DYNAMIC_EXTENT ? _size - Offset : Count
);
}
/**
@ -742,9 +752,9 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
{
MBED_ASSERT(0 <= count && count <= _size);
return Span<element_type, SPAN_DYNAMIC_EXTENT>(
_data + (_size - count),
count
);
_data + (_size - count),
count
);
}
/**
@ -769,9 +779,9 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
(0 <= count && (count + offset) <= _size)
);
return Span<element_type, SPAN_DYNAMIC_EXTENT>(
_data + offset,
count == SPAN_DYNAMIC_EXTENT ? _size - offset : count
);
_data + offset,
count == SPAN_DYNAMIC_EXTENT ? _size - offset : count
);
}
private:
@ -804,6 +814,8 @@ bool operator==(const Span<T, LhsExtent> &lhs, const Span<U, RhsExtent> &rhs)
return std::equal(lhs.data(), lhs.data() + lhs.size(), rhs.data());
}
// AStyle ignore, not handling correctly below
// *INDENT-OFF*
/**
* Equality operation between a Span and a reference to a C++ array.
*
@ -959,7 +971,7 @@ Span<const T, Extent> make_const_Span(const T (&elements)[Extent])
{
return Span<const T, Extent>(elements);
}
// *INDENT-ON*
/**
* Generate a Span to a const content from a pointer to a C/C++ array.
*

View File

@ -168,7 +168,7 @@ void mbed_error_puts(const char *str);
/** @deprecated Renamed to mbed_error_vprintf to match functionality */
MBED_DEPRECATED_SINCE("mbed-os-5.11",
"Renamed to mbed_error_vprintf to match functionality.")
"Renamed to mbed_error_vprintf to match functionality.")
void mbed_error_vfprintf(const char *format, va_list arg) MBED_PRINTF(1, 0);
/** @}*/

View File

@ -96,7 +96,8 @@ public:
*
* @note You may call this function from ISR context.
*/
T* alloc(uint32_t millisec=0) {
T *alloc(uint32_t millisec = 0)
{
return _pool.alloc();
}
@ -108,7 +109,8 @@ public:
*
* @note You may call this function from ISR context.
*/
T* calloc(uint32_t millisec=0) {
T *calloc(uint32_t millisec = 0)
{
return _pool.calloc();
}
@ -120,7 +122,8 @@ public:
*
* @note You may call this function from ISR context.
*/
osStatus put(T *mptr) {
osStatus put(T *mptr)
{
return _queue.put(mptr);
}
@ -136,7 +139,8 @@ public:
*
* @note You may call this function from ISR context if the millisec parameter is set to 0.
*/
osEvent get(uint32_t millisec=osWaitForever) {
osEvent get(uint32_t millisec = osWaitForever)
{
osEvent evt = _queue.get(millisec);
if (evt.status == osEventMessage) {
evt.status = osEventMail;
@ -152,7 +156,8 @@ public:
*
* @note You may call this function from ISR context.
*/
osStatus free(T *mptr) {
osStatus free(T *mptr)
{
return _pool.free(mptr);
}

View File

@ -143,7 +143,8 @@ public:
* parameter is set to 0.
*
*/
osStatus put(T* data, uint32_t millisec=0, uint8_t prio=0) {
osStatus put(T *data, uint32_t millisec = 0, uint8_t prio = 0)
{
return osMessageQueuePut(_id, &data, prio, millisec);
}
@ -182,7 +183,8 @@ public:
* @note You may call this function from ISR context if the millisec
* parameter is set to 0.
*/
osEvent get(uint32_t millisec=osWaitForever) {
osEvent get(uint32_t millisec = osWaitForever)
{
osEvent event;
T *data = NULL;
osStatus_t res = osMessageQueueGet(_id, &data, NULL, millisec);

View File

@ -33,131 +33,131 @@
extern "C" {
#include "rtx_lib.h"
using namespace mbed;
using namespace mbed;
#if (defined(MBED_TICKLESS) && defined(DEVICE_LPTICKER))
#include "rtos/TARGET_CORTEX/SysTimer.h"
static rtos::internal::SysTimer *os_timer;
static uint64_t os_timer_data[sizeof(rtos::internal::SysTimer) / 8];
static rtos::internal::SysTimer *os_timer;
static uint64_t os_timer_data[sizeof(rtos::internal::SysTimer) / 8];
/// Enable System Timer.
void OS_Tick_Enable(void)
{
// Do not use SingletonPtr since this relies on the RTOS
if (NULL == os_timer) {
os_timer = new (os_timer_data) rtos::internal::SysTimer();
os_timer->setup_irq();
}
// set to fire interrupt on next tick
os_timer->schedule_tick();
}
/// Disable System Timer.
void OS_Tick_Disable(void)
{
os_timer->cancel_tick();
}
/// Acknowledge System Timer IRQ.
void OS_Tick_AcknowledgeIRQ(void)
{
}
/// Get System Timer count.
uint32_t OS_Tick_GetCount(void)
{
return os_timer->get_time() & 0xFFFFFFFF;
}
// Get OS Tick IRQ number.
int32_t OS_Tick_GetIRQn(void)
{
return -1;
}
// Get OS Tick overflow status.
uint32_t OS_Tick_GetOverflow(void)
{
return 0;
}
// Get OS Tick interval.
uint32_t OS_Tick_GetInterval(void)
{
return 1000;
}
static void default_idle_hook(void)
{
uint32_t ticks_to_sleep = osKernelSuspend();
const bool block_deep_sleep = ticks_to_sleep <= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
if (block_deep_sleep) {
sleep_manager_lock_deep_sleep();
} else {
ticks_to_sleep -= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
}
os_timer->suspend(ticks_to_sleep);
bool event_pending = false;
while (!os_timer->suspend_time_passed() && !event_pending) {
core_util_critical_section_enter();
if (osRtxInfo.kernel.pendSV) {
event_pending = true;
} else {
sleep();
// Enable System Timer.
void OS_Tick_Enable(void)
{
// Do not use SingletonPtr since this relies on the RTOS
if (NULL == os_timer) {
os_timer = new (os_timer_data) rtos::internal::SysTimer();
os_timer->setup_irq();
}
core_util_critical_section_exit();
// Ensure interrupts get a chance to fire
__ISB();
// set to fire interrupt on next tick
os_timer->schedule_tick();
}
if (block_deep_sleep) {
sleep_manager_unlock_deep_sleep();
// Disable System Timer.
void OS_Tick_Disable(void)
{
os_timer->cancel_tick();
}
osKernelResume(os_timer->resume());
}
// Acknowledge System Timer IRQ.
void OS_Tick_AcknowledgeIRQ(void)
{
}
// Get System Timer count.
uint32_t OS_Tick_GetCount(void)
{
return os_timer->get_time() & 0xFFFFFFFF;
}
// Get OS Tick IRQ number.
int32_t OS_Tick_GetIRQn(void)
{
return -1;
}
// Get OS Tick overflow status.
uint32_t OS_Tick_GetOverflow(void)
{
return 0;
}
// Get OS Tick interval.
uint32_t OS_Tick_GetInterval(void)
{
return 1000;
}
static void default_idle_hook(void)
{
uint32_t ticks_to_sleep = osKernelSuspend();
const bool block_deep_sleep = ticks_to_sleep <= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
if (block_deep_sleep) {
sleep_manager_lock_deep_sleep();
} else {
ticks_to_sleep -= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
}
os_timer->suspend(ticks_to_sleep);
bool event_pending = false;
while (!os_timer->suspend_time_passed() && !event_pending) {
core_util_critical_section_enter();
if (osRtxInfo.kernel.pendSV) {
event_pending = true;
} else {
sleep();
}
core_util_critical_section_exit();
// Ensure interrupts get a chance to fire
__ISB();
}
if (block_deep_sleep) {
sleep_manager_unlock_deep_sleep();
}
osKernelResume(os_timer->resume());
}
#else
static void default_idle_hook(void)
{
// critical section to complete sleep with locked deepsleep
core_util_critical_section_enter();
sleep_manager_lock_deep_sleep();
sleep();
sleep_manager_unlock_deep_sleep();
core_util_critical_section_exit();
}
static void default_idle_hook(void)
{
// critical section to complete sleep with locked deepsleep
core_util_critical_section_enter();
sleep_manager_lock_deep_sleep();
sleep();
sleep_manager_unlock_deep_sleep();
core_util_critical_section_exit();
}
#endif // (defined(MBED_TICKLESS) && defined(DEVICE_LPTICKER))
static void (*idle_hook_fptr)(void) = &default_idle_hook;
static void (*idle_hook_fptr)(void) = &default_idle_hook;
void rtos_attach_idle_hook(void (*fptr)(void))
{
//Attach the specified idle hook, or the default idle hook in case of a NULL pointer
if (fptr != NULL) {
idle_hook_fptr = fptr;
} else {
idle_hook_fptr = default_idle_hook;
void rtos_attach_idle_hook(void (*fptr)(void))
{
//Attach the specified idle hook, or the default idle hook in case of a NULL pointer
if (fptr != NULL) {
idle_hook_fptr = fptr;
} else {
idle_hook_fptr = default_idle_hook;
}
}
}
MBED_NORETURN void rtos_idle_loop(void)
{
//Continuously call the idle hook function pointer
while (1) {
idle_hook_fptr();
MBED_NORETURN void rtos_idle_loop(void)
{
//Continuously call the idle hook function pointer
while (1) {
idle_hook_fptr();
}
}
}
} // extern "C"