NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_gptmr.h File Reference

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

#include <stdint.h>

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 cont_mode)
 
void neorv32_gptmr_disable (void)
 
void neorv32_gptmr_enable (void)
 
void neorv32_gptmr_irq_ack (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_MODE = 4 , GPTMR_CTRL_IRQ_CLR = 30 , GPTMR_CTRL_IRQ_PND = 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).
See also
https://stnolting.github.io/neorv32/sw/files.html

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_MODE 

GPTMR control register(4) (r/w): Operation mode (0=single-shot, 1=continuous)

GPTMR_CTRL_IRQ_CLR 

GPTMR control register(30) (-/w): Set to clear timer-match interrupt

GPTMR_CTRL_IRQ_PND 

GPTMR control register(31) (r/-): Timer-match interrupt pending

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_disable()

void neorv32_gptmr_disable ( void )

Disable general purpose timer.

◆ neorv32_gptmr_enable()

void neorv32_gptmr_enable ( void )

Enable general purpose timer.

◆ neorv32_gptmr_irq_ack()

void neorv32_gptmr_irq_ack ( void )

Clear pending timer interrupt.

◆ neorv32_gptmr_setup()

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

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]cont_modeSet to operate timer in continuous mode (instead of single-shot mode).