1515
1616#ifdef UNIT_TEST
1717#define os_channel_send mock_os_channel_send
18- #define os_get_current_time_us mock_os_get_current_time_us
18+ #define os_tick_current mock_os_tick_current
19+ #define os_tick_from_us mock_os_tick_from_us
1920#define co_obj_find mock_co_obj_find
2021#define co_entry_find mock_co_entry_find
2122#define co_emcy_tx mock_co_emcy_tx
@@ -532,7 +533,7 @@ uint32_t co_od1A00_fn (
532533static void co_pdo_transmit (co_net_t * net , co_pdo_t * pdo )
533534{
534535 size_t dlc ;
535- uint32_t now = os_get_current_time_us ();
536+ os_tick_t now = os_tick_current ();
536537
537538 if (IS_EVENT (pdo -> transmission_type ) && pdo -> inhibit_time > 0 )
538539 {
@@ -549,7 +550,7 @@ static void co_pdo_transmit (co_net_t * net, co_pdo_t * pdo)
549550 pdo -> queued = false;
550551}
551552
552- int co_pdo_timer (co_net_t * net , uint32_t now )
553+ int co_pdo_timer (co_net_t * net , os_tick_t now )
553554{
554555 unsigned int ix ;
555556
@@ -659,7 +660,7 @@ int co_pdo_sync (co_net_t * net, uint8_t * msg, size_t dlc)
659660 if (net -> state != STATE_OP )
660661 return -1 ;
661662
662- net -> sync_timestamp = os_get_current_time_us ();
663+ net -> sync_timestamp = os_tick_current ();
663664
664665 /* Transmit TPDOs */
665666 for (ix = 0 ; ix < MAX_TX_PDO ; ix ++ )
@@ -735,7 +736,7 @@ int co_pdo_sync (co_net_t * net, uint8_t * msg, size_t dlc)
735736void co_pdo_rx (co_net_t * net , uint32_t id , void * msg , size_t dlc )
736737{
737738 unsigned int ix ;
738- uint32_t now ;
739+ os_tick_t now ;
739740
740741 /* Check state */
741742 if (net -> state != STATE_OP )
@@ -762,7 +763,7 @@ void co_pdo_rx (co_net_t * net, uint32_t id, void * msg, size_t dlc)
762763 /* Transmit value sampled at previous SYNC */
763764 dlc = CO_BYTELENGTH (pdo -> bitlength );
764765 os_channel_send (net -> channel , pdo -> cobid , & pdo -> frame , dlc );
765- pdo -> timestamp = os_get_current_time_us ();
766+ pdo -> timestamp = os_tick_current ();
766767 pdo -> queued = false;
767768 }
768769 }
@@ -787,14 +788,14 @@ void co_pdo_rx (co_net_t * net, uint32_t id, void * msg, size_t dlc)
787788 if (pdo -> transmission_type <= CO_PDO_TT_CYCLIC_MAX && net -> sync_window > 0 )
788789 {
789790 /* Check that sync window has not expired */
790- now = os_get_current_time_us ();
791+ now = os_tick_current ();
791792 if (co_is_expired (now , net -> sync_timestamp , net -> sync_window ))
792793 continue ;
793794 }
794795
795796 /* Buffer frame */
796797 memcpy (& pdo -> frame , msg , dlc );
797- pdo -> timestamp = os_get_current_time_us ();
798+ pdo -> timestamp = os_tick_current ();
798799
799800 if (IS_EVENT (pdo -> transmission_type ))
800801 {
0 commit comments