Contiki-NG
|
Macros | |
#define | CLOCK_SIZE 8 |
The clock size (in bytes). | |
#define | CLOCK_SECOND |
A second, measured in system clock time. | |
Functions | |
void | clock_init (void) |
Initialize the clock library. | |
clock_time_t | clock_time (void) |
Get the current clock time. | |
unsigned long | clock_seconds (void) |
Get the current value of the platform seconds. | |
void | clock_set_seconds (unsigned long sec) |
Set the value of the platform seconds. | |
void | clock_wait (clock_time_t t) |
Wait for a given number of ticks. | |
void | clock_delay_usec (uint16_t dt) |
Delay a given number of microseconds. | |
int | clock_fine_max (void) |
Deprecated platform-specific routines. | |
void | clock_delay (unsigned int delay) |
Obsolete delay function but we implement it here since some code still uses it. | |
The clock library is the interface between Contiki and the platform specific clock functionality. The clock library defines a macro, CLOCK_SECOND, to convert seconds into the tick resolution of the platform. Typically this is 1-10 milliseconds, e.g. 4*CLOCK_SECOND could be 512. A 16 bit counter would thus overflow every 1-10 minutes. Platforms use the tick interrupt to maintain a long term count of seconds since startup.
Platforms may also implement rtimers for greater time resolution and for real-time interrupts, These use a corresponding RTIMER_SECOND.
void clock_delay | ( | unsigned int | i | ) |
Obsolete delay function but we implement it here since some code still uses it.
Obsolete delay function but we implement it here since some code still uses it.
Definition at line 164 of file clock.c.
References clock_delay_usec().
void clock_delay_usec | ( | uint16_t | dt | ) |
Delay a given number of microseconds.
dt | How many microseconds to delay. |
< GPTIMER0
< GPTM Timer A interval load
< GPTIMER0
< GPTM control
< Timer A enable
< GPTIMER0
< GPTM control
< Timer A enable
Definition at line 150 of file clock.c.
References GPT_0_BASE, GPTIMER_CTL, GPTIMER_CTL_TAEN, and GPTIMER_TAILR.
Referenced by clock_delay(), clock_wait(), dht22_read(), i2c_init(), i2c_master_command(), mp3_wtv020sd_gpio_next(), mp3_wtv020sd_reset(), pm_reset_system(), and rtcc_set_autocalibration().
void clock_init | ( | void | ) |
Initialize the clock library.
This function initializes the clock library and should be called from the main() function of the system.
Initialize the clock library.
We initialise the SysTick to fire 128 interrupts per second, giving us a value of 128 for CLOCK_SECOND
We also initialise GPT0:Timer A, which is used by clock_delay_usec(). We use 16-bit range (individual), count-down, one-shot, no interrupts. The prescaler is computed according to the system clock in order to get 1 tick per usec.
< GPT[3:0] clocks - active mode
< GPT0 clock enable, CPU running
< GPTIMER0
< GPTM control
< GPTIMER0
< GPTM configuration
< GPTIMER0
< GPTM Timer A mode
< GPTIMER0
< GPTM Timer A prescale
Definition at line 93 of file clock.c.
References CLOCK_SECOND, count, GPT_0_BASE, GPTIMER_CFG, GPTIMER_CTL, GPTIMER_TAMR, GPTIMER_TAPR, lfclk_config(), lfclk_config(), rtc_config(), rtc_config(), SYS_CTRL_RCGCGPT, and SYS_CTRL_RCGCGPT_GPT0.
Referenced by soc_init().
unsigned long clock_seconds | ( | void | ) |
Get the current value of the platform seconds.
This could be the number of seconds since startup, or since a standard epoch.
Definition at line 130 of file clock.c.
References CLOCK_SECOND, and RTIMER_SECOND.
Referenced by newdata(), resolv_lookup(), resolv_query(), stimer_elapsed(), stimer_expired(), stimer_remaining(), stimer_restart(), stimer_set(), tsch_cs_channel_stats_updated(), tsch_cs_process(), and uip_nameserver_update().
void clock_set_seconds | ( | unsigned long | sec | ) |
Set the value of the platform seconds.
sec | The value to set. |
Definition at line 124 of file clock.c.
References RTIMER_SECOND.
clock_time_t clock_time | ( | void | ) |
Get the current clock time.
This function returns the current system clock time.
Definition at line 118 of file clock.c.
References CLOCK_SECOND, and count.
Referenced by clock_wait(), mac_sequence_is_duplicate(), mac_sequence_register_seqno(), rpl_dag_update_state(), rpl_neighbor_snprint(), rtimer_arch_schedule(), timer_expired(), timer_remaining(), timer_restart(), timer_set(), tsch_get_network_uptime_ticks(), tsch_rx_slot(), tsch_slot_operation_sync(), tsch_tx_slot(), and tz_api_poll().
void clock_wait | ( | clock_time_t | t | ) |
Wait for a given number of ticks.
t | How many ticks. |
Definition at line 136 of file clock.c.
References clock_delay_usec(), CLOCK_SECOND, clock_time(), and start().
Referenced by platform_init_stage_two().