Skip to content

Commit

Permalink
SW MAC new API for read current timestamp
Browse files Browse the repository at this point in the history
Change-Id: Id72fec33bbaa2ebbddfc83317253fa398411b975
  • Loading branch information
Juha Heiskanen committed Jun 25, 2019
1 parent 6a44829 commit 9ed97eb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nanostack/sw_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ extern struct fhss_api *ns_sw_mac_get_fhss_api(struct mac_api_s *mac_api);
*/
extern int ns_sw_mac_statistics_start(struct mac_api_s *mac_api, struct mac_statistics_s *mac_statistics);

/**
* @brief Read current timestamp for compared storaged data timestamp.
* @param mac_api MAC instance.
* @param time_stamp_buffer pointer for staorage time stamp
* @return 0 on succeess, < 0 on fail
*/
int ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api, uint32_t *time_stamp_buffer);

#ifdef __cplusplus
}
#endif
Expand Down
15 changes: 15 additions & 0 deletions source/MAC/IEEE802_15_4/sw_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,3 +699,18 @@ void sw_mac_stats_update(protocol_interface_rf_mac_setup_s *setup, mac_stats_typ
}
}
}

int ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api, uint32_t *time_stamp_buffer)
{
if (!mac_api) {
return -1;
}

// Get a pointer to MAC setup structure
protocol_interface_rf_mac_setup_s *mac_setup = get_sw_mac_ptr_by_mac_api(mac_api);
if (!mac_setup) {
return -2;
}
mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_GET_TIMESTAMP, (uint8_t *)&time_stamp_buffer);
return 0;
}
5 changes: 5 additions & 0 deletions test/nanostack/unittest/stub/sw_mac_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ void sw_mac_stats_update(protocol_interface_rf_mac_setup_s *setup, mac_stats_typ
{

}

int ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api, uint32_t *time_stamp_buffer)
{
return -1;
}

0 comments on commit 9ed97eb

Please sign in to comment.