Skip to content

Commit 9ed97eb

Browse files
author
Juha Heiskanen
committed
SW MAC new API for read current timestamp
Change-Id: Id72fec33bbaa2ebbddfc83317253fa398411b975
1 parent 6a44829 commit 9ed97eb

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

nanostack/sw_mac.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ extern struct fhss_api *ns_sw_mac_get_fhss_api(struct mac_api_s *mac_api);
8181
*/
8282
extern int ns_sw_mac_statistics_start(struct mac_api_s *mac_api, struct mac_statistics_s *mac_statistics);
8383

84+
/**
85+
* @brief Read current timestamp for compared storaged data timestamp.
86+
* @param mac_api MAC instance.
87+
* @param time_stamp_buffer pointer for staorage time stamp
88+
* @return 0 on succeess, < 0 on fail
89+
*/
90+
int ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api, uint32_t *time_stamp_buffer);
91+
8492
#ifdef __cplusplus
8593
}
8694
#endif

source/MAC/IEEE802_15_4/sw_mac.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,3 +699,18 @@ void sw_mac_stats_update(protocol_interface_rf_mac_setup_s *setup, mac_stats_typ
699699
}
700700
}
701701
}
702+
703+
int ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api, uint32_t *time_stamp_buffer)
704+
{
705+
if (!mac_api) {
706+
return -1;
707+
}
708+
709+
// Get a pointer to MAC setup structure
710+
protocol_interface_rf_mac_setup_s *mac_setup = get_sw_mac_ptr_by_mac_api(mac_api);
711+
if (!mac_setup) {
712+
return -2;
713+
}
714+
mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_GET_TIMESTAMP, (uint8_t *)&time_stamp_buffer);
715+
return 0;
716+
}

test/nanostack/unittest/stub/sw_mac_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,8 @@ void sw_mac_stats_update(protocol_interface_rf_mac_setup_s *setup, mac_stats_typ
7474
{
7575

7676
}
77+
78+
int ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api, uint32_t *time_stamp_buffer)
79+
{
80+
return -1;
81+
}

0 commit comments

Comments
 (0)