|
Contiki 3.x
|
The clock library is the interface between Contiki and the platform specific clock functionality. More...
Macros | |
| #define | CLOCK_SECOND |
| A second, measured in system clock time. | |
Functions | |
| void | clock_init (void) |
| Initialize the clock library. More... | |
| CCIF clock_time_t | clock_time (void) |
| Get the current clock time. More... | |
| CCIF unsigned long | clock_seconds (void) |
| Get the current value of the platform seconds. More... | |
| void | clock_set_seconds (unsigned long sec) |
| Set the value of the platform seconds. More... | |
| void | clock_wait (clock_time_t t) |
| Wait for a given number of ticks. More... | |
| void | clock_delay_usec (uint16_t dt) |
| Delay a given number of microseconds. More... | |
| 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. More... | |
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.
|
inline |
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 60 of file clock.c.
References clock_delay_usec(), and watchdog_periodic().
Referenced by clock_delay_usec(), and leds_blink().
| void clock_delay_usec | ( | uint16_t | dt | ) |
Delay a given number of microseconds.
| dt | How many microseconds to delay. |
Delay a given number of microseconds.
Definition at line 94 of file clock.c.
References clock_delay(), GPT_0_BASE, GPTIMER_CTL, GPTIMER_CTL_TAEN, GPTIMER_TAILR, pic32_clock_get_system_clock(), and SysTick.
Referenced by clock_delay(), clock_delay_msec(), i2c_init(), i2c_master_command(), main(), mp3_wtv020sd_gpio_next(), mp3_wtv020sd_reset(), mrf24j40_init(), rtcc_set_autocalibration(), and wake().
| 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.
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.
set Timer/Counter0 to be asynchronous from the CPU clock with a second external clock(32,768kHz) driving it.
Wait for TCN0UB, OCR0UB, and TCR0UB.
Definition at line 76 of file clock.c.
References ATOMIC, BIT, CLOCK_SECOND, count, gpio_clr_pin(), gpio_set_output(), GPT_0_BASE, GPTIMER_CFG, GPTIMER_CTL, GPTIMER_TAMR, GPTIMER_TAPR, lfclk_config(), NULL, NVIC_SET_SYSTICK_PRI(), NVIC_SetPriority(), port_conf_pin(), port_pin_to_mask(), rtc_config(), RTIMER_NOW, rtimer_set(), SYS_CTRL_RCGCGPT, SYS_CTRL_RCGCGPT_GPT0, SysTick, SysTick_CLKSourceConfig(), SysTick_Config(), SysTick_CounterCmd(), SysTick_ITConfig(), SysTick_SetReload(), TPM0_IRQn, and update_ticks().
Referenced by main().
| CCIF 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.
Get the current value of the platform seconds.
The comparison avoids the need to disable clock interrupts for an atomic read of the four-byte variable.
Definition at line 54 of file clock.c.
References CLOCK_SECOND, clock_time(), and NULL.
Referenced by main(), newdata(), resolv_lookup(), resolv_query(), stimer_elapsed(), stimer_expired(), stimer_remaining(), stimer_restart(), stimer_set(), and uip_nameserver_update().
| void clock_set_seconds | ( | unsigned long | sec | ) |
| CCIF clock_time_t clock_time | ( | void | ) |
Get the current clock time.
This function returns the current system clock time.
Get the current clock time.
When 16 bit it typically wraps every 10 minutes. The comparison avoids the need to disable clock interrupts for an atomic read of the multi-byte variable.
Definition at line 41 of file clock.c.
Referenced by button_press_handler(), clock_seconds(), clock_wait(), gpiote_event_handler(), main(), rtimer_arch_schedule(), timer_expired(), timer_remaining(), timer_restart(), and timer_set().
| void clock_wait | ( | clock_time_t | t | ) |
Wait for a given number of ticks.
| t | How many ticks. |
Wait for a given number of ticks.
Definition at line 162 of file clock.c.
References clock_time(), start(), and watchdog_periodic().
1.8.6