HPM SDK
HPMicro Software Development Kit
hpm_ptpc_drv.h File Reference
#include "hpm_common.h"
#include "hpm_ptpc_regs.h"

Go to the source code of this file.

Data Structures

struct  ptpc_config_t
 Timer config. More...
 

Macros

#define PTPC_EVENT_COMPARE0_MASK   PTPC_INT_STS_COMP_INT_STS0_MASK
 
#define PTPC_EVENT_CAPTURE0_MASK   PTPC_INT_STS_CAPTURE_INT_STS0_MASK
 
#define PTPC_EVENT_PPS0_MASK   PTPC_INT_STS_PPS_INT_STS0_MASK
 
#define PTPC_EVENT_COMPARE1_MASK   PTPC_INT_STS_COMP_INT_STS1_MASK
 
#define PTPC_EVENT_CAPTURE1_MASK   PTPC_INT_STS_CAPTURE_INT_STS1_MASK
 
#define PTPC_EVENT_PPS1_MASK   PTPC_INT_STS_PPS_INT_STS1_MASK
 
#define PTPC_MAX_NS_COUNTER   (0x3B9ACA00UL)
 

Typedefs

typedef enum ptpc_ns_counter_rollover_type ptpc_ns_counter_rollover_type_t
 Counter types. More...
 
typedef enum ptpc_capture_trigger_type ptpc_capture_trigger_type_t
 Capture trigger types. More...
 
typedef enum ptpc_counting_mode ptpc_counting_mode
 Capture trigger types. More...
 

Enumerations

enum  ptpc_ns_counter_rollover_type { ptpc_ns_counter_rollover_binary = 0 , ptpc_ns_counter_rollover_digital = 1 }
 Counter types. More...
 
enum  ptpc_capture_trigger_type { ptpc_capture_trigger_none = 0 , ptpc_capture_trigger_on_rising_edge = PTPC_PTPC_CTRL0_CAPT_SNAP_POS_EN_MASK , ptpc_capture_trigger_on_failing_edge = PTPC_PTPC_CTRL0_CAPT_SNAP_NEG_EN_MASK , ptpc_capture_trigger_on_both_edges }
 Capture trigger types. More...
 
enum  ptpc_counting_mode { ptpc_counting_increment = 0 , ptpc_counting_decrement = 1 }
 Capture trigger types. More...
 

Functions

static void ptpc_set_ns_counter_rollover (PTPC_Type *ptr, uint8_t index, ptpc_ns_counter_rollover_type_t rollover)
 Configure ns counter rollover mode. More...
 
static void ptpc_enable_capture_keep (PTPC_Type *ptr, uint8_t index)
 Enable capture keep. More...
 
static void ptpc_disable_capture_keep (PTPC_Type *ptr, uint8_t index)
 Disable capture keep. More...
 
static void ptpc_set_ns_counter_update_type (PTPC_Type *ptr, uint8_t index, bool coarse_update)
 Update ns counter update type. More...
 
static void ptpc_set_ns_counter_step (PTPC_Type *ptr, uint8_t index, uint32_t ns_step)
 Set ns counter increment step. More...
 
static void ptpc_set_second_update (PTPC_Type *ptr, uint8_t index, uint32_t sec)
 Set Second portion update value. More...
 
hpm_stat_t ptpc_set_ns_update (PTPC_Type *ptr, uint8_t index, uint32_t ns, ptpc_counting_mode mode)
 Set ns portion update value. More...
 
static uint32_t ptpc_get_timestamp_second (PTPC_Type *ptr, uint8_t index)
 Get current timestamp Second portion. More...
 
static uint32_t ptpc_get_timestamp_ns (PTPC_Type *ptr, uint8_t index)
 Get timestamp ns portion. More...
 
static void ptpc_config_compare (PTPC_Type *ptr, uint8_t index, uint32_t sec, uint32_t ns)
 Config compare. More...
 
static void ptpc_update_timestamp_second (PTPC_Type *ptr, uint8_t index, uint32_t sec)
 Update Second portion. More...
 
static void ptpc_update_timestamp_ns (PTPC_Type *ptr, uint8_t index, uint32_t ns, ptpc_counting_mode mode)
 Update Ns portion. More...
 
static void ptpc_enable_timer (PTPC_Type *ptr, uint8_t index)
 Enable timer. More...
 
static void ptpc_disable_timer (PTPC_Type *ptr, uint8_t index)
 Disable timer. More...
 
static void ptpc_config_capture (PTPC_Type *ptr, uint8_t index, ptpc_capture_trigger_type_t trigger)
 Config capture trigger event. More...
 
static uint32_t ptpc_get_capture_ns (PTPC_Type *ptr, uint8_t index)
 Get snapped ns value. More...
 
static uint32_t ptpc_get_capture_second (PTPC_Type *ptr, uint8_t index)
 Get captured second. More...
 
static void ptpc_clear_irq_status (PTPC_Type *ptr, uint32_t mask)
 Clear interrupt status. More...
 
static uint32_t ptpc_get_irq_status (PTPC_Type *ptr)
 Get interrupt status. More...
 
static void ptpc_irq_disable (PTPC_Type *ptr, uint32_t mask)
 Disable interrupt with mask. More...
 
static void ptpc_irq_enable (PTPC_Type *ptr, uint32_t mask)
 Enable interrupt with mask. More...
 
hpm_stat_t ptpc_init (PTPC_Type *ptr, uint8_t index, ptpc_config_t *config)
 Initialize PTPC module. More...
 
hpm_stat_t ptpc_set_timer_output (PTPC_Type *ptr, uint8_t can_index, bool use_ptpc1)
 Set PTPC output destination. More...
 
void ptpc_get_default_config (PTPC_Type *ptr, ptpc_config_t *config)
 Get default config. More...
 
void ptpc_init_timer (PTPC_Type *ptr, uint8_t index)
 Initialize timer to count from 0. More...
 
hpm_stat_t ptpc_init_timer_with_initial (PTPC_Type *ptr, uint8_t index, uint32_t sec, uint32_t ns, ptpc_counting_mode mode)
 Initialize timer with initial values. More...
 
hpm_stat_t ptpc_update_timer (PTPC_Type *ptr, uint8_t index, uint32_t sec, uint32_t ns, ptpc_counting_mode mode)
 Update timestamp counter. More...
 
hpm_stat_t ptpc_set_pps (PTPC_Type *ptr, uint8_t index, uint8_t p)
 Set period of pulse generated per second. More...