src/occ_405/rtls/test/main.c
// Function Specification
//
// Name: rtl_run_max_ticks
//
// Description:
// Run the RTLS IRQ handler for at least MAX_NUM_TICKS, then stop.
// Note: This function does not guarantee that the IRQ handler will run for
// exactly MAX_NUM_TICKS ticks.  It does guarantee that the IRQ handler will
// run for _at_least_ MAX_NUM_TICKS ticks (but could run for more).
//
// End Function Specification
Function Specification
Name: rtl_run_max_ticks

Run the RTLS IRQ handler for at least MAX_NUM_TICKS, then stop.
Note: This function does not guarantee that the IRQ handler will run for
exactly MAX_NUM_TICKS ticks.  It does guarantee that the IRQ handler will
run for _at_least_ MAX_NUM_TICKS ticks (but could run for more).

End Function Specification
Function Specification Name : rtl_run_max_ticks Run the RTLS IRQ handler for at least MAX_NUM_TICKS then stop . Note : This function does not guarantee that the IRQ handler will run for exactly MAX_NUM_TICKS ticks . It does guarantee that the IRQ handler will run for _at_least_ MAX_NUM_TICKS ticks ( but could run for more ) . End Function Specification
int rtl_run_max_ticks(void)
{
#define MAX_WAIT_CYCLES 10000
    int  i = 0;  
    int rc = 0;  
    ssx_irq_enable( PGP_IRQ_OCC_TIMER0 );
    for( i = 0; i < MAX_WAIT_CYCLES; i++) {
        ssx_sleep(1);
        if( (CURRENT_TICK >= MAX_NUM_TICKS) && (CURRENT_TICK < 0xFFFFFFFF) ) {
            ssx_irq_disable(PGP_IRQ_OCC_TIMER0);
            CURRENT_TICK = 0xFFFFFFFF;
            break;
        }
    }
    if( i >= MAX_WAIT_CYCLES ) {
        printf("  ERROR: %s: %d: Timed-out waiting for CURRENT_TICK to reach %d.\n\n", __FILE__, __LINE__, MAX_NUM_TICKS);
        rc = -1;
    }
    return rc;
}
int rtl_run_max_ticks ( void ) { #define MAX_WAIT_CYCLES  10000 int i = 0 ; int rc = 0 ; ssx_irq_enable ( PGP_IRQ_OCC_TIMER0 ) ; for ( i = 0 ; i < MAX_WAIT_CYCLES ; i ++ ) { ssx_sleep ( 1 ) ; if ( ( CURRENT_TICK >= MAX_NUM_TICKS ) && ( CURRENT_TICK < 0xFFFFFFFF ) ) { ssx_irq_disable ( PGP_IRQ_OCC_TIMER0 ) ; CURRENT_TICK = 0xFFFFFFFF ; break ; } } if ( i >= MAX_WAIT_CYCLES ) { printf ( " \n \n " , __FILE__ , __LINE__ , MAX_NUM_TICKS ) ; rc = -1 ; } return rc ; }
Function Specification
Name: rtl_run_max_ticks
Function Specification Name : rtl_run_max_ticks
// If we can loop this many cycles without seeing our IRQ stop condition, // then something is broken. // Counter // Return Code // Start the RTLS IRQ timer. // Wait for the timer to hit MAX_NUM_TICKS ticks. // Note: When we enter this loop, CURRENT_TICK may still equal 0xFFFFFFFF, // so handle that condition appropriately. // Warning: ssx_sleep only works if called from a thread OTHER than the one that // calls ocb_timer_setup (function called by rtl_ocb_init).  If this rule is not // followed, the OCB IRQ handler will run a trap instruction and hang. // We timed-out waiting for CURRENT_TICK to equal MAX_NUM_TICKS.  Make noise & exit.