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

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

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  neorv32_pwm_t
 

Functions

Prototypes
int neorv32_pwm_available (void)
 
int neorv32_pmw_get_num_channels (void)
 
void neorv32_pwm_ch_enable (int channel)
 
void neorv32_pwm_ch_disable (int channel)
 
void neorv32_pwm_ch_set_clock (int channel, int prsc, int cdiv)
 
void neorv32_pwm_ch_set_duty (int channel, int duty)
 

IO Device: Pulse Width Modulation Controller (PWM)

#define NEORV32_PWM   ((neorv32_pwm_t*) (NEORV32_PWM_BASE))
 
enum  CHANNEL_CFG_enum {
  PWM_CFG_DUTY_LSB = 0 , PWM_CFG_DUTY_MSB = 7 , PWM_CFG_CDIV_LSB = 8 , PWM_CFG_CDIV_MSB = 17 ,
  PWM_CFG_PRSC_LSB = 28 , PWM_CFG_PRSC_MSB = 30 , PWM_CFG_EN = 31
}
 

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).
See also
https://stnolting.github.io/neorv32/sw/files.html

Macro Definition Documentation

◆ NEORV32_PWM

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

PWM module hardware access (neorv32_pwm_t)

Enumeration Type Documentation

◆ CHANNEL_CFG_enum

PWM channel configuration bits

Enumerator
PWM_CFG_DUTY_LSB 

PWM configuration register(0) (r/w): Duty cycle (8-bit), LSB

PWM_CFG_DUTY_MSB 

PWM configuration register(7) (r/w): Duty cycle (8-bit), MSB

PWM_CFG_CDIV_LSB 

PWM configuration register(8) (r/w): Clock divider (10-bit), LSB

PWM_CFG_CDIV_MSB 

PWM configuration register(17) (r/w): Clock divider (10-bit), MSB

PWM_CFG_PRSC_LSB 

PWM configuration register(28) (r/w): Clock prescaler select (3-bit), LSB

PWM_CFG_PRSC_MSB 

PWM configuration register(30) (r/w): Clock prescaler select (3-bit), MSB

PWM_CFG_EN 

PWM configuration register(31) (r/w): channel enable

Function Documentation

◆ neorv32_pmw_get_num_channels()

int neorv32_pmw_get_num_channels ( void )

Get number of implemented PWM channels.

Warning
This function will override all channel configuration registers.
Returns
Number of implemented PWM 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_ch_disable()

void neorv32_pwm_ch_disable ( int channel)

Disable PWM channel.

Parameters
[in]channelChannel select (0..15).

◆ neorv32_pwm_ch_enable()

void neorv32_pwm_ch_enable ( int channel)

Enable PWM channel.

Parameters
[in]channelChannel select (0..15).

◆ neorv32_pwm_ch_set_clock()

void neorv32_pwm_ch_set_clock ( int channel,
int prsc,
int cdiv )

Set PWM channel's clock configuration.

Parameters
[in]channelChannel select (0..15).
[in]prscCoarse clock prescaler select (3-bit, LSB-aligned). See NEORV32_CLOCK_PRSC_enum.
[in]cdivFine clock divider value (10-bit, LSB-aligned).

◆ neorv32_pwm_ch_set_duty()

void neorv32_pwm_ch_set_duty ( int channel,
int duty )

Set PWM channel's duty cycle.

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