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

Pulse-Width Modulation Controller (PWM) HW driver header file. More...

Go to the source code of this file.

Data Structures

struct  neorv32_pwm_t
 

Functions

Prototypes
int neorv32_pwm_available (void)
 
void neorv32_pwm_setup (int prsc)
 
void neorv32_pwm_disable (void)
 
void neorv32_pwm_enable (void)
 
int neorv32_pmw_get_num_channels (void)
 
void neorv32_pwm_set (int channel, uint8_t dc)
 
uint8_t neorv32_pwm_get (int channel)
 

IO Device: Pulse Width Modulation Controller (PWM)

#define NEORV32_PWM   ((neorv32_pwm_t*) (NEORV32_PWM_BASE))
 
enum  NEORV32_PWM_CTRL_enum { PWM_CTRL_EN = 0 , PWM_CTRL_PRSC0 = 1 , PWM_CTRL_PRSC1 = 2 , PWM_CTRL_PRSC2 = 3 }
 

Detailed Description

Pulse-Width Modulation Controller (PWM) HW driver header file.

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

Macro Definition Documentation

◆ NEORV32_PWM

#define NEORV32_PWM   ((neorv32_pwm_t*) (NEORV32_PWM_BASE))

PWM module hardware access (neorv32_pwm_t)

Enumeration Type Documentation

◆ NEORV32_PWM_CTRL_enum

PWM control register bits

Enumerator
PWM_CTRL_EN 

PWM control register(0) (r/w): PWM controller enable

PWM_CTRL_PRSC0 

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

PWM_CTRL_PRSC1 

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

PWM_CTRL_PRSC2 

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

Function Documentation

◆ neorv32_pmw_get_num_channels()

int neorv32_pmw_get_num_channels ( void )

Get number of implemented channels.

Warning
This function will override all duty cycle configuration registers.
Returns
Number of implemented channels.

◆ neorv32_pwm_available()

int neorv32_pwm_available ( void )

Check if PWM unit was synthesized.

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

◆ neorv32_pwm_disable()

void neorv32_pwm_disable ( void )

Disable pulse width modulation controller.

◆ neorv32_pwm_enable()

void neorv32_pwm_enable ( void )

Enable pulse width modulation controller.

◆ neorv32_pwm_get()

uint8_t neorv32_pwm_get ( int channel)

Get duty cycle from channel.

Parameters
[in]channelChannel select (0..11).
Returns
Duty cycle (8-bit, LSB-aligned) of channel 'channel'.

◆ neorv32_pwm_set()

void neorv32_pwm_set ( int channel,
uint8_t dc )

Set duty cycle for channel.

Parameters
[in]channelChannel select (0..11).
[in]dcDuty cycle (8-bit, LSB-aligned).

◆ neorv32_pwm_setup()

void neorv32_pwm_setup ( int prsc)

Enable and configure pulse width modulation controller. The PWM control register bits are listed in NEORV32_PWM_CTRL_enum.

Parameters
[in]prscClock prescaler select (0..7). See NEORV32_CLOCK_PRSC_enum.