15
15
16
16
#ifdef UNIT_TEST
17
17
#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
19
20
#define co_obj_find mock_co_obj_find
20
21
#define co_entry_find mock_co_entry_find
21
22
#define co_emcy_tx mock_co_emcy_tx
@@ -532,7 +533,7 @@ uint32_t co_od1A00_fn (
532
533
static void co_pdo_transmit (co_net_t * net , co_pdo_t * pdo )
533
534
{
534
535
size_t dlc ;
535
- uint32_t now = os_get_current_time_us ();
536
+ os_tick_t now = os_tick_current ();
536
537
537
538
if (IS_EVENT (pdo -> transmission_type ) && pdo -> inhibit_time > 0 )
538
539
{
@@ -549,7 +550,7 @@ static void co_pdo_transmit (co_net_t * net, co_pdo_t * pdo)
549
550
pdo -> queued = false;
550
551
}
551
552
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 )
553
554
{
554
555
unsigned int ix ;
555
556
@@ -659,7 +660,7 @@ int co_pdo_sync (co_net_t * net, uint8_t * msg, size_t dlc)
659
660
if (net -> state != STATE_OP )
660
661
return -1 ;
661
662
662
- net -> sync_timestamp = os_get_current_time_us ();
663
+ net -> sync_timestamp = os_tick_current ();
663
664
664
665
/* Transmit TPDOs */
665
666
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)
735
736
void co_pdo_rx (co_net_t * net , uint32_t id , void * msg , size_t dlc )
736
737
{
737
738
unsigned int ix ;
738
- uint32_t now ;
739
+ os_tick_t now ;
739
740
740
741
/* Check state */
741
742
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)
762
763
/* Transmit value sampled at previous SYNC */
763
764
dlc = CO_BYTELENGTH (pdo -> bitlength );
764
765
os_channel_send (net -> channel , pdo -> cobid , & pdo -> frame , dlc );
765
- pdo -> timestamp = os_get_current_time_us ();
766
+ pdo -> timestamp = os_tick_current ();
766
767
pdo -> queued = false;
767
768
}
768
769
}
@@ -787,14 +788,14 @@ void co_pdo_rx (co_net_t * net, uint32_t id, void * msg, size_t dlc)
787
788
if (pdo -> transmission_type <= CO_PDO_TT_CYCLIC_MAX && net -> sync_window > 0 )
788
789
{
789
790
/* Check that sync window has not expired */
790
- now = os_get_current_time_us ();
791
+ now = os_tick_current ();
791
792
if (co_is_expired (now , net -> sync_timestamp , net -> sync_window ))
792
793
continue ;
793
794
}
794
795
795
796
/* Buffer frame */
796
797
memcpy (& pdo -> frame , msg , dlc );
797
- pdo -> timestamp = os_get_current_time_us ();
798
+ pdo -> timestamp = os_tick_current ();
798
799
799
800
if (IS_EVENT (pdo -> transmission_type ))
800
801
{
0 commit comments