IceCube display
LED display to show IceCube event data
All Data Structures Files Functions Variables Enumerations Enumerator Macros Modules Pages
Frame timing

Periodic interrupt timer to initiate frame drawing. More...

Data Structures

struct  display_frame_usb_phase_t
 Display frame counter and USB frame counter values at frame draw time. More...
 

Macros

#define MS_PER_FRAME   (1000/DEVICE_FPS)
 Time interval between frame displays expressed in milliseconds.
 

Frame timing tracking

void new_sof_received (const uint16_t usb_frame_counter)
 Function to be called upon receival of a USB SOF token with the new USB frame counter value.
 
bool get_display_frame_usb_phase (struct display_frame_usb_phase_t *usb_phase)
 Latest display frame counter phase. More...
 
bool correct_display_frame_counter (const int16_t frame_diff)
 Correct the display frame counter. More...
 
void correct_display_frame_phase (const int8_t ms_shift)
 Shift the frame display phase with respect to the USB frame counter. More...
 

Frame draw triggering

void init_frame_timer ()
 Initialise the frame timer.
 
bool should_draw_frame ()
 Whether a new frame should be displayed or if the device is allowed to idle.
 
void clear_draw_frame ()
 Acknowledge that a frame has been drawn.
 

Frame timer backend

void init_frame_timer_backend (void(*timer_callback)())
 Initialise the frame timer. More...
 
int8_t get_counter_direction ()
 Counter direction. More...
 
timer_count_t get_counts_max ()
 The maximum (roll-over/reset) value of the timer.
 
timer_count_t get_counts_current ()
 Get the current counter value of the timer.
 
void correct_counts_max (timer_diff_t diff)
 Add diff to the current maximum value of the counter. More...
 

Detailed Description

Periodic interrupt timer to initiate frame drawing.

Frame timing is split up in a platform independent interface (frame_timer.h) that should be used by other firmware modules, and the timer backend (frame_timer_backend.h) that is only used by the frame timer interface. All hardware specific details of the timer are implemented in this backend, so this is the only part that actually changes between implementation.

Function Documentation

◆ correct_counts_max()

void correct_counts_max ( timer_diff_t  diff)

Add diff to the current maximum value of the counter.

The new value will be applied after the counter has rolled over. Therefore, although possible, it doesn't really make sense to call this function more often than once per frame draw cycle.

◆ correct_display_frame_counter()

bool correct_display_frame_counter ( const int16_t  frame_diff)

Correct the display frame counter.

Returns
Whether the frame counter value was actually corrected or not.

◆ correct_display_frame_phase()

void correct_display_frame_phase ( const int8_t  ms_shift)

Shift the frame display phase with respect to the USB frame counter.

The absolute value of ms_shift should be smaller than or equal to half the number of milliseconds per display frame interval. The provided ms shift can be performed only once per frame cycle, so if multiple calls are performed, only the last correction of the cycle will be used.

◆ get_counter_direction()

int8_t get_counter_direction ( )

Counter direction.

Differences between counter values have the same sign as the value returned by this function, except when the timer has rolled over.

Returns
1 for up-counter, -1 for down-counter.

◆ get_display_frame_usb_phase()

bool get_display_frame_usb_phase ( struct display_frame_usb_phase_t usb_phase)

Latest display frame counter phase.

Copy the latest display frame phase into the provided pointer.

Returns
The return value indicates whether the value stored in counter_phase is valid.

◆ init_frame_timer_backend()

void init_frame_timer_backend ( void(*)()  timer_callback)

Initialise the frame timer.

Parameters
timer_callbackThe function to be called when the timer trips.