NEORV32 - Software Framework Documentation
Loading...
Searching...
No Matches
Functions
neorv32_gptmr.c File Reference

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

#include "neorv32.h"
#include "neorv32_gptmr.h"

Functions

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)
 

Detailed Description

General purpose timer (GPTMR) HW driver source file.

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

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.