NEORV32 - Software Framework Documentation
Loading...
Searching...
No Matches
Data Structures
neorv32_gptmr.h File Reference

General purpose timer (GPTMR) HW driver header file. More...

Go to the source code of this file.

Data Structures

struct  neorv32_gptmr_t
 

Functions

Prototypes
int neorv32_gptmr_available (void)
 
void neorv32_gptmr_setup (int prsc, uint32_t threshold, int match_irq)
 
void neorv32_gptmr_capture (int rising, int falling, int filter, int capture_irq)
 
void neorv32_gptmr_disable (void)
 
void neorv32_gptmr_enable (void)
 
int neorv32_gptmr_trigger_matched (void)
 
int neorv32_gptmr_trigger_captured (void)
 
void neorv32_gptmr_restart (void)
 
uint32_t neorv32_gptmr_counter_get (void)
 
uint32_t neorv32_gptmr_capture_get (void)
 

IO Device: General Purpose Timer (GPTMR)

#define NEORV32_GPTMR   ((neorv32_gptmr_t*) (NEORV32_GPTMR_BASE))
 
enum  NEORV32_GPTMR_CTRL_enum {
  GPTMR_CTRL_EN = 0 , GPTMR_CTRL_PRSC0 = 1 , GPTMR_CTRL_PRSC1 = 2 , GPTMR_CTRL_PRSC2 = 3 ,
  GPTMR_CTRL_IRQM = 4 , GPTMR_CTRL_IRQC = 5 , GPTMR_CTRL_RISE = 6 , GPTMR_CTRL_FALL = 7 ,
  GPTMR_CTRL_FILTER = 8 , GPTMR_CTRL_TRIGM = 30 , GPTMR_CTRL_TRIGC = 31
}
 

Detailed Description

General purpose timer (GPTMR) HW driver header file.

Note
These functions should only be used if the GPTMR unit was synthesized (IO_GPTMR_EN = true).

Macro Definition Documentation

◆ NEORV32_GPTMR

#define NEORV32_GPTMR   ((neorv32_gptmr_t*) (NEORV32_GPTMR_BASE))

GPTMR module hardware access (neorv32_gptmr_t)

Enumeration Type Documentation

◆ NEORV32_GPTMR_CTRL_enum

GPTMR control register bits

Enumerator
GPTMR_CTRL_EN 

GPTMR control register(0) (r/w): GPTMR enable

GPTMR_CTRL_PRSC0 

GPTMR control register(1) (r/w): Clock prescaler select bit 0

GPTMR_CTRL_PRSC1 

GPTMR control register(2) (r/w): Clock prescaler select bit 1

GPTMR_CTRL_PRSC2 

GPTMR control register(3) (r/w): Clock prescaler select bit 2

GPTMR_CTRL_IRQM 

GPTMR control register(4) (r/w): Enable interrupt on timer match

GPTMR_CTRL_IRQC 

GPTMR control register(5) (r/w): Enable interrupt on capture trigger

GPTMR_CTRL_RISE 

GPTMR control register(6) (r/w): Capture on rising edge; capture-mode only

GPTMR_CTRL_FALL 

GPTMR control register(7) (r/w): Capture on falling edge; capture-mode only

GPTMR_CTRL_FILTER 

GPTMR control register(8) (r/w): Filter capture input; capture-mode only

GPTMR_CTRL_TRIGM 

GPTMR control register(30) (r/c): Timer-match has fired, cleared by writing 0

GPTMR_CTRL_TRIGC 

GPTMR control register(31) (r/c): Capture-trigger has fired, cleared by writing 0

Function Documentation

◆ neorv32_gptmr_available()

int neorv32_gptmr_available ( void )

Check if general purpose timer unit was synthesized.

Returns
0 if GPTMR was not synthesized, 1 if GPTMR is available.

◆ neorv32_gptmr_capture()

void neorv32_gptmr_capture ( int rising,
int falling,
int filter,
int capture_irq )

Configure timer capture feature.

Note
This function needs to be called after the general GPTMR setup neorv32_gptmr_setup.
Parameters
[in]risingCapture on rising edge.
[in]fallingCapture on falling edge.
[in]filterEnable filtering of capture input.
[in]capture_irqFire interrupt when on capture trigger.

◆ neorv32_gptmr_capture_get()

uint32_t neorv32_gptmr_capture_get ( void )

Get latest capture value.

Returns
Capture timer value.

◆ neorv32_gptmr_counter_get()

uint32_t neorv32_gptmr_counter_get ( void )

Get current counter value.

Returns
Current counter value.

◆ neorv32_gptmr_disable()

void neorv32_gptmr_disable ( void )

Disable general purpose timer.

◆ neorv32_gptmr_enable()

void neorv32_gptmr_enable ( void )

Enable general purpose timer.

◆ neorv32_gptmr_restart()

void neorv32_gptmr_restart ( void )

Reset general purpose timer's counter register (timer-mode only).

◆ neorv32_gptmr_setup()

void neorv32_gptmr_setup ( int prsc,
uint32_t threshold,
int match_irq )

Reset, enable and configure general purpose timer.

Parameters
[in]prscClock prescaler select (0..7). See NEORV32_CLOCK_PRSC_enum.
[in]thresholdThreshold value, counter will reset to zero when reaching this.
[in]match_irqFire interrupt when counter matches threshold value.

◆ neorv32_gptmr_trigger_captured()

int neorv32_gptmr_trigger_captured ( void )

Check if capture input has triggered. Clear trigger flag in that case.

Returns
1 if capture trigger has fired, 0 if not.

◆ neorv32_gptmr_trigger_matched()

int neorv32_gptmr_trigger_matched ( void )

Check if timer match has triggered. Clear trigger flag in that case.

Returns
1 if match trigger has fired, 0 if not.