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

@ -26,7 +26,7 @@ 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),
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

@ -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;
@ -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) {
@ -602,7 +602,7 @@ int QSPIFBlockDevice::_sfdp_parse_sector_map_table(uint32_t sector_map_table_add
}
// 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;
}
@ -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,8 +780,8 @@ 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:
@ -884,7 +884,7 @@ 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
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");
@ -904,7 +904,7 @@ 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
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;
}
@ -922,7 +922,7 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr)
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
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,7 +948,7 @@ 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 &erase4k_inst,
unsigned int *erase_type_inst_arr, unsigned int *erase_type_size_arr)
{
erase4k_inst = 0xff;
@ -970,7 +970,7 @@ int QSPIFBlockDevice::_sfdp_detect_erase_types_inst_and_size(uint8_t *basic_para
// 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");
@ -1151,7 +1151,7 @@ bool QSPIFBlockDevice::_is_mem_ready()
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,7 +1172,7 @@ int QSPIFBlockDevice::_set_write_enable()
break;
}
if ( false == _is_mem_ready()) {
if (false == _is_mem_ready()) {
tr_error("Device not ready, write failed");
break;
}
@ -1208,7 +1208,7 @@ 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
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");
@ -1228,7 +1228,7 @@ 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
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;
}
@ -1245,7 +1245,7 @@ int QSPIFBlockDevice::_enable_fast_mdoe()
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
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;
@ -1320,7 +1320,7 @@ qspi_status_t QSPIFBlockDevice::_qspi_send_read_command(unsigned int read_inst,
// 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;
}

View File

@ -121,7 +121,10 @@ public:
/** Desctruct QSPIFBlockDevie
*/
~QSPIFBlockDevice() {deinit();}
~QSPIFBlockDevice()
{
deinit();
}
/** Read blocks from a block device
*
@ -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,7 +293,7 @@ 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 &erase4k_inst,
unsigned int *erase_type_inst_arr, unsigned int *erase_type_size_arr);
/***********************/
@ -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

@ -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);

View File

@ -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

@ -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

@ -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

@ -134,7 +134,7 @@ void Nanostack::Interface::network_handler(mesh_connection_status_t status)
&& (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,23 +33,23 @@ static EMACPhy *single_phy;
extern "C"
{
static int8_t emac_phy_address_write(phy_address_type_e address_type, uint8_t *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)
{
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)
{
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)
{
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;
@ -65,18 +64,18 @@ EMACPhy::EMACPhy(NanostackMemoryManager &mem, EMAC &m) : memory_manager(mem), em
/* 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)
{
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));
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
@ -92,7 +91,7 @@ void EMACPhy::emac_phy_rx(emac_mem_buf_t *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;
@ -155,7 +154,7 @@ int8_t EMACPhy::phy_register()
device_id = arm_net_phy_register(&phy);
// 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,7 +44,7 @@ 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,

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

@ -197,9 +197,10 @@ 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);
}
}
}
/*

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

@ -272,7 +272,7 @@ void nd_tasklet_configure_and_connect_to_network(void)
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,
@ -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));

View File

@ -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) {
} 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);
}
@ -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));
@ -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

@ -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,16 +96,15 @@ 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 =
{
ARM_CFSTORE_DRIVER cfstore_driver = {
.Close = test_cfstore_close,
.Create = test_cfstore_create,
.Delete= test_cfstore_delete,
.Delete = test_cfstore_delete,
.Find = test_cfstore_find,
.Flush = test_cfstore_flush,
.GetCapabilities = test_cfstore_get_capabilities,

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,27 +17,21 @@ 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);
}
}

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

@ -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,16 +104,21 @@ 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;
}
}
@ -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;
@ -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;
@ -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;
@ -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

@ -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,7 +402,7 @@ 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",

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

@ -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.
@ -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.
@ -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

@ -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,18 +33,18 @@
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)
{
// 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();
@ -53,46 +53,46 @@ void OS_Tick_Enable(void)
// set to fire interrupt on next tick
os_timer->schedule_tick();
}
}
/// Disable System Timer.
void OS_Tick_Disable(void)
{
// Disable System Timer.
void OS_Tick_Disable(void)
{
os_timer->cancel_tick();
}
}
/// Acknowledge System Timer IRQ.
void OS_Tick_AcknowledgeIRQ(void)
{
// Acknowledge System Timer IRQ.
void OS_Tick_AcknowledgeIRQ(void)
{
}
}
/// Get System Timer count.
uint32_t OS_Tick_GetCount(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)
{
// Get OS Tick IRQ number.
int32_t OS_Tick_GetIRQn(void)
{
return -1;
}
}
// Get OS Tick overflow status.
uint32_t OS_Tick_GetOverflow(void)
{
// Get OS Tick overflow status.
uint32_t OS_Tick_GetOverflow(void)
{
return 0;
}
}
// Get OS Tick interval.
uint32_t OS_Tick_GetInterval(void)
{
// Get OS Tick interval.
uint32_t OS_Tick_GetInterval(void)
{
return 1000;
}
}
static void default_idle_hook(void)
{
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;
@ -123,41 +123,41 @@ static void default_idle_hook(void)
}
osKernelResume(os_timer->resume());
}
}
#else
static void default_idle_hook(void)
{
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))
{
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)
{
MBED_NORETURN void rtos_idle_loop(void)
{
//Continuously call the idle hook function pointer
while (1) {
idle_hook_fptr();
}
}
}
} // extern "C"