From 233ec783c1b902af25f1376d6fcdc9f4b0bccf53 Mon Sep 17 00:00:00 2001 From: Arto Kinnunen Date: Wed, 8 Dec 2021 13:47:01 +0200 Subject: [PATCH] Squashed 'connectivity/drivers/802.15.4_RF/atmel-rf-driver/' changes from 834c5357c6..ccba775217 ccba775217 Merge pull request #110 from PelionIoT/sync_from_mbed_os 301b184ba4 Update copyright 3c9927a4e8 Sync from Mbed OS 68a243c432 Merge pull request #109 from PelionIoT/IOTTHD-4839 55004765bd Read received packet length in RX done callback git-subtree-dir: connectivity/drivers/802.15.4_RF/atmel-rf-driver git-subtree-split: ccba7752172988f2c50a646af09dd0c1e91d4fc8 --- CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ source/NanostackRfPhyAT86RF215.cpp | 9 +++++---- 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000000..8184174715c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,30 @@ +################################################################################# +## Copyright 2020-2021 Pelion. +## +## SPDX-License-Identifier: Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +################################################################################# + +target_include_directories(mbed-802.15.4-rf + INTERFACE + atmel-rf-driver + source +) + +target_sources(mbed-802.15.4-rf + INTERFACE + source/NanostackRfPhyAT86RF215.cpp + source/NanostackRfPhyAtmel.cpp + source/at24mac.cpp +) diff --git a/source/NanostackRfPhyAT86RF215.cpp b/source/NanostackRfPhyAT86RF215.cpp index 5aea0a7c229..42387c57f79 100644 --- a/source/NanostackRfPhyAT86RF215.cpp +++ b/source/NanostackRfPhyAT86RF215.cpp @@ -703,7 +703,8 @@ static void rf_handle_rx_done(void) rf_state = RF_IDLE; } if (rf_read_bbc_register(BBC_PC, rf_module) & FCSOK) { - if (!rf_read_rx_buffer(cur_rx_packet_len, rf_module)) { + uint16_t rx_packet_len = rf_read_rx_frame_length(rf_module); + if (!rf_read_rx_buffer(rx_packet_len, rf_module)) { uint8_t version = ((rx_buffer[1] & VERSION_FIELD_MASK) >> SHIFT_VERSION_FIELD); if (((rx_buffer[0] & MAC_FRAME_TYPE_MASK) == MAC_TYPE_ACK) && (version < MAC_FRAME_VERSION_2)) { rf_handle_ack(rx_buffer[2], rx_buffer[0] & MAC_DATA_PENDING); @@ -711,11 +712,11 @@ static void rf_handle_rx_done(void) int8_t rssi = (int8_t) rf_read_rf_register(RF_EDV, rf_module); // Cut CRC bytes if (mac_mode == IEEE_802_15_4_2011) { - cur_rx_packet_len -= 2; + rx_packet_len -= 2; } else { - cur_rx_packet_len -= 4; + rx_packet_len -= 4; } - device_driver.phy_rx_cb(rx_buffer, cur_rx_packet_len, 0xf0, rssi, rf_radio_driver_id); + device_driver.phy_rx_cb(rx_buffer, rx_packet_len, 0xf0, rssi, rf_radio_driver_id); // If auto ack used, must wait until RF returns to RF_TXPREP state if ((version != MAC_FRAME_VERSION_2) && (rx_buffer[0] & FC_AR)) { wait_us(100);