HPM SDK
HPMicro Software Development Kit
hpm_gptmr_drv.h File Reference
#include "hpm_common.h"
#include "hpm_gptmr_regs.h"
#include "hpm_soc_feature.h"

Go to the source code of this file.

Data Structures

struct  gptmr_channel_config
 GPTMR counter mode. More...
 

Macros

#define GPTMR_CH_CMP_IRQ_MASK(ch, cmp)   (1 << (ch * 4 + 2 + cmp))
 GPTMR channel IRQ mask. More...
 
#define GPTMR_CH_CAP_IRQ_MASK(ch)   (1 << (ch * 4 + 1))
 
#define GPTMR_CH_RLD_IRQ_MASK(ch)   (1 << (ch * 4))
 
#define GPTMR_CH_CMP_STAT_MASK(ch, cmp)   (1 << (ch * 4 + 2 + cmp))
 GPTMR channel status. More...
 
#define GPTMR_CH_CAP_STAT_MASK(ch)   (1 << (ch * 4 + 1))
 
#define GPTMR_CH_RLD_STAT_MASK(ch)   (1 << (ch * 4))
 
#define GPTMR_CH_GCR_SWSYNCT_MASK(ch)   (1 << ch)
 GPTMR channel swsynct mask. More...
 
#define GPTMR_CH_CMP_COUNT   (2U)
 GPTMR one channel support output comparator count. More...
 

Typedefs

typedef enum gptmr_synci_edge gptmr_synci_edge_t
 GPTMR synci valid edge. More...
 
typedef enum gptmr_work_mode gptmr_work_mode_t
 GPTMR work mode. More...
 
typedef enum gptmr_dma_request_event gptmr_dma_request_event_t
 GPTMR DMA request event. More...
 
typedef enum gptmr_counter_type gptmr_counter_type_t
 GPTMR counter type. More...
 
typedef struct gptmr_channel_config gptmr_channel_config_t
 GPTMR counter mode. More...
 

Enumerations

enum  gptmr_synci_edge { gptmr_synci_edge_none = 0 , gptmr_synci_edge_falling = GPTMR_CHANNEL_CR_SYNCIFEN_MASK , gptmr_synci_edge_rising = GPTMR_CHANNEL_CR_SYNCIREN_MASK , gptmr_synci_edge_both = gptmr_synci_edge_falling | gptmr_synci_edge_rising }
 GPTMR synci valid edge. More...
 
enum  gptmr_work_mode {
  gptmr_work_mode_no_capture = 0 , gptmr_work_mode_capture_at_rising_edge = 1 , gptmr_work_mode_capture_at_falling_edge = 2 , gptmr_work_mode_capture_at_both_edge = 3 ,
  gptmr_work_mode_measure_width = 4
}
 GPTMR work mode. More...
 
enum  gptmr_dma_request_event {
  gptmr_dma_request_on_cmp0 = 0 , gptmr_dma_request_on_cmp1 = 1 , gptmr_dma_request_on_input_signal_toggle = 2 , gptmr_dma_request_on_reload = 3 ,
  gptmr_dma_request_disabled = 0xFF
}
 GPTMR DMA request event. More...
 
enum  gptmr_counter_type {
  gptmr_counter_type_rising_edge , gptmr_counter_type_falling_edge , gptmr_counter_type_measured_period , gptmr_counter_type_measured_duty_cycle ,
  gptmr_counter_type_normal
}
 GPTMR counter type. More...
 

Functions

static void gptmr_channel_enable (GPTMR_Type *ptr, uint8_t ch_index, bool enable)
 gptmr channel enable More...
 
static void gptmr_channel_reset_count (GPTMR_Type *ptr, uint8_t ch_index)
 gptmr channel reset counter More...
 
static void gptmr_channel_update_count (GPTMR_Type *ptr, uint8_t ch_index, uint32_t value)
 gptmr channel update counter More...
 
static void gptmr_channel_select_synci_valid_edge (GPTMR_Type *ptr, uint8_t ch_index, gptmr_synci_edge_t edge)
 gptmr channel slect synci valid edge More...
 
static void gptmr_channel_enable_dma_request (GPTMR_Type *ptr, uint8_t ch_index, bool enable)
 gptmr channel enable dma request More...
 
static uint32_t gptmr_channel_get_counter (GPTMR_Type *ptr, uint8_t ch_index, gptmr_counter_type_t capture)
 gptmr channel get counter value More...
 
static void gptmr_trigger_channel_software_sync (GPTMR_Type *ptr, uint32_t ch_index_mask)
 gptmr trigger channel software sync More...
 
static void gptmr_enable_irq (GPTMR_Type *ptr, uint32_t irq_mask)
 gptmr enable irq More...
 
static void gptmr_disable_irq (GPTMR_Type *ptr, uint32_t irq_mask)
 gptmr disable irq More...
 
static bool gptmr_check_status (GPTMR_Type *ptr, uint32_t mask)
 gptmr check status More...
 
static void gptmr_clear_status (GPTMR_Type *ptr, uint32_t mask)
 gptmr clear status More...
 
static uint32_t gptmr_get_status (GPTMR_Type *ptr)
 gptmr get status More...
 
static void gptmr_stop_counter (GPTMR_Type *ptr, uint8_t ch_index)
 gptmr channel stop counter More...
 
static void gptmr_enable_cmp_output (GPTMR_Type *ptr, uint8_t ch_index)
 gptmr channel enable compare output More...
 
static void gptmr_disable_cmp_output (GPTMR_Type *ptr, uint8_t ch_index)
 gptmr channel disable compare output More...
 
static void gptmr_channel_set_capmode (GPTMR_Type *ptr, uint8_t ch_index, gptmr_work_mode_t mode)
 gptmr channel set capmode More...
 
static gptmr_work_mode_t gptmr_channel_get_capmode (GPTMR_Type *ptr, uint8_t ch_index)
 gptmr channel get capmode More...
 
static void gptmr_update_cmp (GPTMR_Type *ptr, uint8_t ch_index, uint8_t cmp_index, uint32_t cmp)
 gptmr channel update comparator More...
 
static uint32_t gptmr_channel_get_reload (GPTMR_Type *ptr, uint8_t ch_index)
 gptmr channel get reload More...
 
static void gptmr_channel_config_update_reload (GPTMR_Type *ptr, uint8_t ch_index, uint32_t reload)
 gptmr channel update reload More...
 
static gptmr_dma_request_event_t gptmr_channel_get_dma_request_event (GPTMR_Type *ptr, uint8_t ch_index)
 gptmr channel get dma request event More...
 
hpm_stat_t gptmr_channel_config (GPTMR_Type *ptr, uint8_t ch_index, gptmr_channel_config_t *config, bool enable)
 gptmr channel config More...
 
void gptmr_channel_get_default_config (GPTMR_Type *ptr, gptmr_channel_config_t *config)
 gptmr channel get default config More...
 
static void gptmr_start_counter (GPTMR_Type *ptr, uint8_t ch_index)
 gptmr channel start counter More...