HPM SDK
HPMicro Software Development Kit
GPTMR driver APIs

GPTMR driver APIs. More...

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...
 

Detailed Description

GPTMR driver APIs.

Macro Definition Documentation

◆ GPTMR_CH_CAP_IRQ_MASK

#define GPTMR_CH_CAP_IRQ_MASK (   ch)    (1 << (ch * 4 + 1))

◆ GPTMR_CH_CAP_STAT_MASK

#define GPTMR_CH_CAP_STAT_MASK (   ch)    (1 << (ch * 4 + 1))

◆ GPTMR_CH_CMP_COUNT

#define GPTMR_CH_CMP_COUNT   (2U)

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR one channel support output comparator count.

◆ GPTMR_CH_CMP_IRQ_MASK

#define GPTMR_CH_CMP_IRQ_MASK (   ch,
  cmp 
)    (1 << (ch * 4 + 2 + cmp))

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR channel IRQ mask.

◆ GPTMR_CH_CMP_STAT_MASK

#define GPTMR_CH_CMP_STAT_MASK (   ch,
  cmp 
)    (1 << (ch * 4 + 2 + cmp))

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR channel status.

◆ GPTMR_CH_GCR_SWSYNCT_MASK

#define GPTMR_CH_GCR_SWSYNCT_MASK (   ch)    (1 << ch)

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR channel swsynct mask.

◆ GPTMR_CH_RLD_IRQ_MASK

#define GPTMR_CH_RLD_IRQ_MASK (   ch)    (1 << (ch * 4))

◆ GPTMR_CH_RLD_STAT_MASK

#define GPTMR_CH_RLD_STAT_MASK (   ch)    (1 << (ch * 4))

Typedef Documentation

◆ gptmr_channel_config_t

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR counter mode.

GPTMR channel config

◆ gptmr_counter_type_t

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR counter type.

◆ gptmr_dma_request_event_t

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR DMA request event.

◆ gptmr_synci_edge_t

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR synci valid edge.

◆ gptmr_work_mode_t

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR work mode.

Enumeration Type Documentation

◆ gptmr_counter_type

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR counter type.

Enumerator
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_dma_request_event

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR DMA request event.

Enumerator
gptmr_dma_request_on_cmp0 
gptmr_dma_request_on_cmp1 
gptmr_dma_request_on_input_signal_toggle 
gptmr_dma_request_on_reload 
gptmr_dma_request_disabled 

◆ gptmr_synci_edge

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR synci valid edge.

Enumerator
gptmr_synci_edge_none 
gptmr_synci_edge_falling 
gptmr_synci_edge_rising 
gptmr_synci_edge_both 

◆ gptmr_work_mode

#include <drivers/inc/hpm_gptmr_drv.h>

GPTMR work mode.

Enumerator
gptmr_work_mode_no_capture 
gptmr_work_mode_capture_at_rising_edge 
gptmr_work_mode_capture_at_falling_edge 
gptmr_work_mode_capture_at_both_edge 
gptmr_work_mode_measure_width 

Function Documentation

◆ gptmr_channel_config()

hpm_stat_t gptmr_channel_config ( GPTMR_Type ptr,
uint8_t  ch_index,
gptmr_channel_config_t config,
bool  enable 
)

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel config

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
[in]configgptmr_channel_config_t
[in]enable
  • true: enable
  • false: disable
Return values
hpm_stat_tstatus_invalid_argument or status_success

◆ gptmr_channel_config_update_reload()

static void gptmr_channel_config_update_reload ( GPTMR_Type ptr,
uint8_t  ch_index,
uint32_t  reload 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel update reload

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
[in]reloadreload value

◆ gptmr_channel_enable()

static void gptmr_channel_enable ( GPTMR_Type ptr,
uint8_t  ch_index,
bool  enable 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel enable

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
[in]enable
  • true: enable
  • false: disable

◆ gptmr_channel_enable_dma_request()

static void gptmr_channel_enable_dma_request ( GPTMR_Type ptr,
uint8_t  ch_index,
bool  enable 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel enable dma request

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
[in]enable
  • true: enable
  • false: disable

◆ gptmr_channel_get_capmode()

static gptmr_work_mode_t gptmr_channel_get_capmode ( GPTMR_Type ptr,
uint8_t  ch_index 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel get capmode

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
Return values
gptmr_work_mode_tenum gptmr_work_mode_capture_at_rising_edge or gptmr_work_mode_capture_at_falling_edge

◆ gptmr_channel_get_counter()

static uint32_t gptmr_channel_get_counter ( GPTMR_Type ptr,
uint8_t  ch_index,
gptmr_counter_type_t  capture 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel get counter value

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
[in]capturegptmr_counter_type_t

◆ gptmr_channel_get_default_config()

void gptmr_channel_get_default_config ( GPTMR_Type ptr,
gptmr_channel_config_t config 
)

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel get default config

Parameters
[in]ptrGPTMR base address
[out]configgptmr_channel_config_t

◆ gptmr_channel_get_dma_request_event()

static gptmr_dma_request_event_t gptmr_channel_get_dma_request_event ( GPTMR_Type ptr,
uint8_t  ch_index 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel get dma request event

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
Return values
gptmr_dma_request_event_tgptmr_dma_request_on_cmp0 or gptmr_dma_request_on_reload

◆ gptmr_channel_get_reload()

static uint32_t gptmr_channel_get_reload ( GPTMR_Type ptr,
uint8_t  ch_index 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel get reload

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
Return values
RLDregister value

◆ gptmr_channel_reset_count()

static void gptmr_channel_reset_count ( GPTMR_Type ptr,
uint8_t  ch_index 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel reset counter

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index

◆ gptmr_channel_select_synci_valid_edge()

static void gptmr_channel_select_synci_valid_edge ( GPTMR_Type ptr,
uint8_t  ch_index,
gptmr_synci_edge_t  edge 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel slect synci valid edge

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
[in]edgegptmr_synci_edge_t

◆ gptmr_channel_set_capmode()

static void gptmr_channel_set_capmode ( GPTMR_Type ptr,
uint8_t  ch_index,
gptmr_work_mode_t  mode 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel set capmode

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
[in]modeenum gptmr_work_mode_capture_at_rising_edge or gptmr_work_mode_capture_at_falling_edge and so on

◆ gptmr_channel_update_count()

static void gptmr_channel_update_count ( GPTMR_Type ptr,
uint8_t  ch_index,
uint32_t  value 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel update counter

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
[in]valueupdated vaue

◆ gptmr_check_status()

static bool gptmr_check_status ( GPTMR_Type ptr,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr check status

Parameters
[in]ptrGPTMR base address
[in]maskchannel flag mask

◆ gptmr_clear_status()

static void gptmr_clear_status ( GPTMR_Type ptr,
uint32_t  mask 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr clear status

Parameters
[in]ptrGPTMR base address
[in]maskchannel flag mask

◆ gptmr_disable_cmp_output()

static void gptmr_disable_cmp_output ( GPTMR_Type ptr,
uint8_t  ch_index 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel disable compare output

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index

◆ gptmr_disable_irq()

static void gptmr_disable_irq ( GPTMR_Type ptr,
uint32_t  irq_mask 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr disable irq

Parameters
[in]ptrGPTMR base address
[in]irq_maskirq mask

◆ gptmr_enable_cmp_output()

static void gptmr_enable_cmp_output ( GPTMR_Type ptr,
uint8_t  ch_index 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel enable compare output

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index

◆ gptmr_enable_irq()

static void gptmr_enable_irq ( GPTMR_Type ptr,
uint32_t  irq_mask 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr enable irq

Parameters
[in]ptrGPTMR base address
[in]irq_maskirq mask

◆ gptmr_get_status()

static uint32_t gptmr_get_status ( GPTMR_Type ptr)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr get status

Parameters
[in]ptrGPTMR base address
Return values
SRregister value

◆ gptmr_start_counter()

static void gptmr_start_counter ( GPTMR_Type ptr,
uint8_t  ch_index 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel start counter

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index

◆ gptmr_stop_counter()

static void gptmr_stop_counter ( GPTMR_Type ptr,
uint8_t  ch_index 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel stop counter

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index

◆ gptmr_trigger_channel_software_sync()

static void gptmr_trigger_channel_software_sync ( GPTMR_Type ptr,
uint32_t  ch_index_mask 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr trigger channel software sync

Parameters
[in]ptrGPTMR base address
[in]ch_index_maskchannel index mask

◆ gptmr_update_cmp()

static void gptmr_update_cmp ( GPTMR_Type ptr,
uint8_t  ch_index,
uint8_t  cmp_index,
uint32_t  cmp 
)
inlinestatic

#include <drivers/inc/hpm_gptmr_drv.h>

gptmr channel update comparator

Parameters
[in]ptrGPTMR base address
[in]ch_indexchannel index
[in]cmp_indexcomparator index
[in]cmpcomparator value