//Reset button pushed int gpioCheckResetButton() { unsigned int reset; int reset_list[] = SETTINGS_ZERO_LIST; unsigned long time; unsigned long t_time; //Check GPIO pin 0 for the reset button push if ( NAgetGPIOpin( 0, &reset ) != SUCCESS ) return 0; //Check if the reset button is pushed if ( !reset ) { //Shoot out some debug data debugPrint( "Reset switch is being pushed" ); //Tell the user visually that this happened time = tx_time_get(); do { NALedOn( 0xFFFFFFFF ); t_time = tx_time_get(); } while ( t_time - time <= BSP_TICKS_PER_SECOND && t_time - time >= 0 ); //Reset the settings in the flash memory settingsZeroList(); //Do anything else } return 1; }
/* A portable version of get random seed */ unsigned int __mg_os_get_random_seed (void) { #if defined (__UCOSII__) return OSTimeGet (); #elif defined (__THREADX__) /* system clock ticks*/ return tx_time_get(); #elif defined (__NUCLEUS__) /* TODO */ return 0; #elif defined (__UCOSII__) return 0; #else /*other os use time, for example: linux, OSE, etc.*/ return time (NULL); #endif }
void Slow_Thread_entry(ULONG thread_input) { ULONG current_time; while(1) { /* Activity 5 - 12 timer-ticks *** critical section *** */ /* Get the mutex with suspension */ tx_mutex_get(&my_mutex, TX_WAIT_FOREVER); tx_thread_sleep(12); /* Release the mutex */ tx_mutex_put(&my_mutex); /* Activity 6 - 8 timer-ticks */ tx_thread_sleep(8); /* Activity 7 - 11 timer-ticks *** critical section *** */ /* Get the mutex with suspension */ tx_mutex_get(&my_mutex, TX_WAIT_FOREVER); tx_thread_sleep(11); /* Release the mutex */ tx_mutex_put(&my_mutex); /* Activity 8 - 9 timer-ticks */ tx_thread_sleep(9); current_time = tx_time_get(); printf("Current Time: %5lu Slow_Thread finished a cycle¡\n", current_time); } }
void Speedy_Thread_entry(ULONG thread_input) { ULONG current_time; while (1) { /* Activity 1: 2 timer-ticks */ tx_thread_sleep(2); /* Get the mutex with suspension */ tx_mutex_get(&my_mutex, TX_WAIT_FOREVER); /* Activity 2: 5 timer-ticks *** critical section *** */ tx_thread_sleep(5); /* Release the mutex */ tx_mutex_put(&my_mutex); /* Activity 3: 4 timer-ticks */ tx_thread_sleep(4); /* Get the mutex with suspension */ tx_mutex_get(&my_mutex, TX_WAIT_FOREVER); /* Activity 4: 3 timer-ticks *** critical section *** */ tx_thread_sleep(3); /* Release the mutex */ tx_mutex_put(&my_mutex); current_time = tx_time_get(); printf(" Current Time: %5lu Speedy_Thread finished a cycle¡\n", current_time); } }
/** * Gets time in milliseconds since RTOS start * * @Note: since this is only 32 bits, it will roll over every 49 days, 17 hours. * * @returns Time in milliseconds since RTOS started. */ wwd_time_t host_rtos_get_time( void ) /*@modifies internalState@*/ { return (wwd_time_t) ( tx_time_get( ) * ( 1000 / SYSTICK_FREQUENCY ) ); }
wiced_result_t wiced_time_get_time( wiced_time_t* time_ptr ) { *time_ptr = (wiced_time_t) ( tx_time_get( ) * ms_to_tick_ratio ); return WICED_SUCCESS; }