Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CPU - Cycle Counter

CPU Cycle Counter provides an interface to the COUNT and COMPARE registers.

Modules

 

Data Structures

struct  t_cpu_time
 Structure holding private information, automatically initialized by the cpu_set_timeout() function. More...
 

Macros

#define Get_sys_compare()   ( Get_system_register(AVR32_COMPARE) )
 
#define Get_sys_count()   ( Get_system_register(AVR32_COUNT) )
 
#define Set_sys_compare(x)   ( Set_system_register(AVR32_COMPARE, (x)) )
 
#define Set_sys_count(x)   ( Set_system_register(AVR32_COUNT, (x)) )
 

Functions

static __always_inline uint32_t cpu_cy_2_ms (unsigned long cy, unsigned long fcpu_hz)
 Convert CPU cycles into milli-seconds. More...
 
static __always_inline uint32_t cpu_cy_2_us (unsigned long cy, unsigned long fcpu_hz)
 Convert CPU cycles into micro-seconds. More...
 
static __always_inline void cpu_delay_cy (unsigned long delay)
 Waits during at least the specified delay (in CPU cycles) before returning. More...
 
static __always_inline void cpu_delay_ms (unsigned long delay, unsigned long fcpu_hz)
 Waits during at least the specified delay (in millisecond) before returning. More...
 
static __always_inline void cpu_delay_us (unsigned long delay, unsigned long fcpu_hz)
 Waits during at least the specified delay (in microsecond) before returning. More...
 
static __always_inline
unsigned long 
cpu_is_timeout (t_cpu_time *cpu_time)
 Test if a timer variable reached its timeout. More...
 
static __always_inline
unsigned long 
cpu_is_timer_stopped (t_cpu_time *cpu_time)
 Test if a timer is stopped. More...
 
static __always_inline uint32_t cpu_ms_2_cy (unsigned long ms, unsigned long fcpu_hz)
 Convert milli-seconds into CPU cycles. More...
 
static __always_inline void cpu_set_timeout (unsigned long delay, t_cpu_time *cpu_time)
 Set a timer variable. More...
 
static __always_inline void cpu_stop_timeout (t_cpu_time *cpu_time)
 Stop a timeout detection. More...
 
static __always_inline uint32_t cpu_us_2_cy (unsigned long us, unsigned long fcpu_hz)
 Convert micro-seconds into CPU cycles. More...
 

#define Get_sys_compare ( )    ( Get_system_register(AVR32_COMPARE) )

Referenced by main().

#define Set_sys_compare (   x)    ( Set_system_register(AVR32_COMPARE, (x)) )

Referenced by main().

#define Set_sys_count (   x)    ( Set_system_register(AVR32_COUNT, (x)) )

static __always_inline uint32_t cpu_cy_2_ms ( unsigned long  cy,
unsigned long  fcpu_hz 
)
static

Convert CPU cycles into milli-seconds.

Parameters
cy,:Number of CPU cycles.
fcpu_hz,:CPU frequency in Hz.
Returns
the converted number of milli-second.

Referenced by time_tick_calc_delay().

static __always_inline uint32_t cpu_cy_2_us ( unsigned long  cy,
unsigned long  fcpu_hz 
)
static

Convert CPU cycles into micro-seconds.

Parameters
cy,:Number of CPU cycles.
fcpu_hz,:CPU frequency in Hz.
Returns
the converted number of micro-second.

Referenced by sensor_timestamp(), ushell_cmd_perform_access(), ushell_cmd_perform_extaccess(), and ushell_cmd_perform_transfer().

static __always_inline void cpu_delay_cy ( unsigned long  delay)
static

Waits during at least the specified delay (in CPU cycles) before returning.

Parameters
delay,:Number of CPU cycles to wait.

References cpu_is_timeout(), cpu_set_timeout(), and timer.

Referenced by qt60168_check_device_ready(), and qt60168_wait_cmd_received().

static __always_inline void cpu_delay_ms ( unsigned long  delay,
unsigned long  fcpu_hz 
)
static

Waits during at least the specified delay (in millisecond) before returning.

Parameters
delay,:Number of millisecond to wait.
fcpu_hz,:CPU frequency in Hz.

References cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), and timer.

Referenced by et024006_PowerOn(), et024006_PowerUp(), et024006_ResetDisplay(), led_task(), main(), and wdt_scheduler().

static __always_inline void cpu_delay_us ( unsigned long  delay,
unsigned long  fcpu_hz 
)
static

Waits during at least the specified delay (in microsecond) before returning.

Parameters
delay,:Number of microsecond to wait.
fcpu_hz,:CPU frequency in Hz.

References cpu_is_timeout(), cpu_set_timeout(), cpu_us_2_cy(), and timer.

Referenced by at42qt1060_read_reg(), et024006_ResetDisplay(), and usb_suspend_action().

static __always_inline unsigned long cpu_is_timeout ( t_cpu_time cpu_time)
static

Test if a timer variable reached its timeout.

Once the timeout is reached, the function will always return true, until the cpu_stop_timeout() function is called.

Ex: t_cpu_time timer; cpu_set_timeout( 10, FOSC0, &timer ); // timeout in 10 ms if( cpu_is_timeout(&timer) ) cpu_stop_timeout(&timer); ../..

Parameters
cpu_time,:(input) internal information used by the timer API.
Returns
true if timeout occurred, otherwise false.

References CPU_TIMER_STATE_REACHED, CPU_TIMER_STATE_STOPPED, t_cpu_time::delay_end_cycle, t_cpu_time::delay_start_cycle, Get_system_register, and t_cpu_time::timer_state.

Referenced by check_device_task(), com_task(), cpu_delay_cy(), cpu_delay_ms(), cpu_delay_us(), gui_task(), main(), mmi_activity_display(), mmi_display(), playback_task(), usb_host_task(), usb_stream_input(), and usb_stream_resync().

static __always_inline unsigned long cpu_is_timer_stopped ( t_cpu_time cpu_time)
static

Test if a timer is stopped.

Parameters
cpu_time,:(input) internal information used by the timer API.
Returns
true if timer is stopped, otherwise false.

References CPU_TIMER_STATE_STOPPED, and t_cpu_time::timer_state.

Referenced by check_device_task(), and usb_stream_input().

static __always_inline uint32_t cpu_ms_2_cy ( unsigned long  ms,
unsigned long  fcpu_hz 
)
static

Convert milli-seconds into CPU cycles.

Parameters
ms,:Number of millisecond.
fcpu_hz,:CPU frequency in Hz.
Returns
the converted number of CPU cycles.

Referenced by check_device_task(), com_task(), cpu_delay_ms(), device_hid_task_init(), gui_change_update_fs(), gui_task(), main(), mmi_activity_display(), mmi_display(), playback_task(), usb_stream_init(), usb_stream_input(), and usb_stream_resync().

static __always_inline void cpu_set_timeout ( unsigned long  delay,
t_cpu_time cpu_time 
)
static

Set a timer variable.

Ex: t_cpu_time timer; cpu_set_timeout( cpu_ms_2_cy(10, FOSC0), &timer ); // timeout in 10 ms if( cpu_is_timeout(&timer) ) cpu_stop_timeout(&timer); ../..

Parameters
delay,:(input) delay in CPU cycles before timeout.
cpu_time,:(output) internal information used by the timer API.

References CPU_TIMER_STATE_STARTED, t_cpu_time::delay_end_cycle, t_cpu_time::delay_start_cycle, Get_system_register, and t_cpu_time::timer_state.

Referenced by check_device_task(), com_task(), cpu_delay_cy(), cpu_delay_ms(), cpu_delay_us(), device_hid_task_init(), gui_change_update_fs(), gui_task(), main(), mmi_activity_display(), mmi_display(), playback_task(), usb_stream_init(), usb_stream_input(), and usb_stream_resync().

static __always_inline void cpu_stop_timeout ( t_cpu_time cpu_time)
static

Stop a timeout detection.

Ex: t_cpu_time timer; cpu_set_timeout( 10, FOSC0, &timer ); // timeout in 10 ms if( cpu_is_timeout(&timer) ) cpu_stop_timeout(&timer); ../..

Parameters
cpu_time,:(input) internal information used by the timer API.

References CPU_TIMER_STATE_STOPPED, and t_cpu_time::timer_state.

Referenced by check_device_task(), com_task(), com_task_init(), mmi_display(), usb_stream_init(), and usb_stream_input().

static __always_inline uint32_t cpu_us_2_cy ( unsigned long  us,
unsigned long  fcpu_hz 
)
static

Convert micro-seconds into CPU cycles.

Parameters
us,:Number of microsecond.
fcpu_hz,:CPU frequency in Hz.
Returns
the converted number of CPU cycles.

Referenced by cpu_delay_us(), qt60168_check_device_ready(), qt60168_wait_cmd_received(), and usb_stream_input().