iSensor-SPI-Buffer  1.15
Firmware for the iSensor-SPI-Buffer board to enable full throughput buffered data capture on Analog Devices IMUs
Functions | Variables
timer.c File Reference

Implementation for for iSensor-SPI-Buffer timer module. Covers microsecond timer and PPS timer. More...

#include "reg.h"
#include "timer.h"
#include "dio.h"
#include "main.h"
Include dependency graph for timer.c:

Functions

static void InitTIM2 (uint32_t timerfreq)
 Enables IMU sample timestamp timer. More...
 
static void InitTIM8 ()
 Enables TIM8 as general 1MHz timer.
 
static void ConfigurePPSPins (uint32_t enable)
 Configure PPS timer based on DIO_INPUT_CONFIG value. More...
 
static void DWT_Init ()
 Init DWT peripheral. More...
 
void Timer_Init ()
 Initialize all timers for operation. More...
 
void Timer_Check_PPS_Unlock ()
 Check if the PPS signal is unlocked (greater than 1100ms since last PPS strobe) More...
 
void Timer_Sleep_Microseconds (uint32_t microseconds)
 Blocking sleep function call. More...
 
uint32_t Timer_Get_Microsecond_Timestamp ()
 Gets the current 32-bit value from the IMU sample timestamp timer. More...
 
uint32_t Timer_Get_PPS_Timestamp ()
 Gets the current 32-bit value from PPS timestamp registers. More...
 
void Timer_Clear_Microsecond_Timer ()
 Reset TIM2 counter to 0. More...
 
void Timer_Enable_PPS ()
 Enable PPS input for time stamp synchronization (improved long term stability over 20ppm crystal). More...
 
void Timer_Disable_PPS ()
 Disable PPS timer functionality. More...
 
void Timer_Increment_PPS_Time ()
 Increment PPS timestamp by 1. More...
 

Variables

uint32_t g_PPSInterruptMask = 0
 
static TIM_HandleTypeDef htim2
 
static TIM_HandleTypeDef htim8
 
static uint32_t PPS_TickCount
 
static uint32_t PPS_MaxTickCount
 

Detailed Description

Implementation for for iSensor-SPI-Buffer timer module. Covers microsecond timer and PPS timer.

Copyright (c) Analog Devices Inc, 2020 All Rights Reserved.

Date
6/26/2020
Author
A. Nolan (alex..nosp@m.nola.nosp@m.n@ana.nosp@m.log..nosp@m.com)

Function Documentation

◆ ConfigurePPSPins()

static void ConfigurePPSPins ( uint32_t  enable)
static

Configure PPS timer based on DIO_INPUT_CONFIG value.

Parameters
enableBool flagging if PPS functionality is being enabled or disabled

This function sets up the PPS input pin, as well as the expected "PPS" period.

Here is the caller graph for this function:

◆ DWT_Init()

static void DWT_Init ( )
static

Init DWT peripheral.

Returns
void

This peripheral is used to count microseconds for the timer module.

Here is the caller graph for this function:

◆ InitTIM2()

static void InitTIM2 ( uint32_t  timerfreq)
static

Enables IMU sample timestamp timer.

Parameters
timerfreqThe desired timer freq (in Hz)
Returns
void

This function should be called as part of the buffered data acquisition startup process. The enabled timer is TIM2 (32 bit)

Here is the caller graph for this function:

◆ Timer_Check_PPS_Unlock()

void Timer_Check_PPS_Unlock ( )

Check if the PPS signal is unlocked (greater than 1100ms since last PPS strobe)

Returns
void

This function should be periodically called as part of the firmware housekeeping process

Here is the call graph for this function:

◆ Timer_Clear_Microsecond_Timer()

void Timer_Clear_Microsecond_Timer ( )

Reset TIM2 counter to 0.

Returns
void
Here is the caller graph for this function:

◆ Timer_Disable_PPS()

void Timer_Disable_PPS ( )

Disable PPS timer functionality.

Returns
void
Here is the call graph for this function:

◆ Timer_Enable_PPS()

void Timer_Enable_PPS ( )

Enable PPS input for time stamp synchronization (improved long term stability over 20ppm crystal).

Returns
void

The PPS input can be on any of the DIOx_Slave pins (host processor the iSensor-SPI-Buffer). The selected pin is configured by the PPS_SELECT field in the DIO_INPUT_CONFIG register. The trigger polarity for the PPS signal is configured by the PPS_POLARITY field in the DIO_INPUT_CONFIG register.

Pins:

DIO1: PB4 -> EXTI4 interrupt DIO2: PB8 -> EXTI9_5 interrupt, mask (1 << 8) DIO3: PC7 -> EXTI9_5 interrupt, mask (1 << 7) DIO4: PA8 -> EXTI9_5 interrupt, mask (1 << 8)

Here is the call graph for this function:

◆ Timer_Get_Microsecond_Timestamp()

uint32_t Timer_Get_Microsecond_Timestamp ( )

Gets the current 32-bit value from the IMU sample timestamp timer.

Returns
The timer value
Here is the caller graph for this function:

◆ Timer_Get_PPS_Timestamp()

uint32_t Timer_Get_PPS_Timestamp ( )

Gets the current 32-bit value from PPS timestamp registers.

Returns
The PPS counter value
Here is the caller graph for this function:

◆ Timer_Increment_PPS_Time()

void Timer_Increment_PPS_Time ( )

Increment PPS timestamp by 1.

Returns
void

This function should be called whenever a PPS interrupt is generated. It handles PPS tick count incrementation, and resetting the microsecond timestamp every time one second has elapsed.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Timer_Init()

void Timer_Init ( )

Initialize all timers for operation.

Returns
void

Timer 2 is used as a 1MHz timer for the timestamp measurements Timer 8 is used as a timeout timer, also at 1MHz

The DWT timer is used for a polling based timer

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Timer_Sleep_Microseconds()

void Timer_Sleep_Microseconds ( uint32_t  microseconds)

Blocking sleep function call.

Parameters
microsecondsThe number of microseconds to sleep
Returns
void

This function uses TIM6 to perform delay.

Here is the caller graph for this function:

Variable Documentation

◆ g_PPSInterruptMask

uint32_t g_PPSInterruptMask = 0

PPS interrupt source. Global scope

◆ htim2

TIM_HandleTypeDef htim2
static

TIM2 handle

◆ htim8

TIM_HandleTypeDef htim8
static

TIM8 handle for init

◆ PPS_MaxTickCount

uint32_t PPS_MaxTickCount
static

Number of PPS ticks per sec

◆ PPS_TickCount

uint32_t PPS_TickCount
static

Track number of "PPS" ticks which have occurred in last second