EPPL example libraries  0.1 alpha
 All Files Functions Variables Groups Pages
<spwm> Software Pulse Width Modulation

Modules

 SPWM configuration
 
 SPWM library variables
 Variable type for main counter.
 

Macros

#define SPWM_PINCONFIG   EPPL_PROCESSEVERYARG(SPWM_PIN_SC_GENERATE, com, SPWM_OUTPUTS_ALL)
 SPWM pin initialization data. More...
 
#define SPWM_HOTPINS   EPPL_PROCESSEVERYARG(SPWM_PIN_HOTPINS_GENERATE, com, SPWM_OUTPUTS_ALL)
 SPWM HOTPINS. More...
 

Functions

static void spwm_set (uint8_t ch, spwm_val_T val)
 Function that sets value for selected channel. More...
 
static void spwm_set_FromISR (uint8_t ch, spwm_val_T val)
 Function that sets value for selected channel from ISR. More...
 
static void spwm_onTick (void)
 Function to be called on every tick. More...
 

Internal generation macros

Internal macros used for code generation

#define SPWM_PIN_SC(pin, off, on)   EPPL_SC(pin, off)
 Macro used for pin config. More...
 
#define SPWM_PIN_SC_GENERATE(n, arg)   SPWM_PIN_SC arg
 Macro used for pin config generation. More...
 
#define SPWM_PIN_HOTPIN(pin, off, on)   EPPL_SR(pin, off, on)
 Macro used for hotpin. More...
 
#define SPWM_PIN_HOTPINS_GENERATE(n, arg)   SPWM_PIN_HOTPIN arg
 Macro used for hotpins generation. More...
 
#define SPWM_PIN_ONRESET(pin, off, on)
 Macro used on counter reset. More...
 
#define SPWM_PIN_ONRESET_GENERATE(n, arg)   SPWM_PIN_ONRESET arg
 Macro used for code generation for all pins on counter reset. More...
 
#define SPWM_PIN_ONTICK(pin, off, on)
 Macro used on every tick. More...
 
#define SPWM_PIN_ONTICK_GENERATE(n, arg)   SPWM_PIN_ONTICK arg
 Macro used for code generation for all pins on timer tick. More...
 

Detailed Description

Driver for generating software PWM outputs. This driver needs just fast interrupts from timer. All outputs are generated in software. Becouse it is rather slow its main usage area would be a light driving.

Macro Definition Documentation

SPWM HOTPINS.

Use this constant for EPPL_HOTPINS constant There are listed all pins reconfigurations that may happen inside SPWM library.

#define SPWM_PIN_HOTPIN (   pin,
  off,
  on 
)    EPPL_SR(pin, off, on)

Macro used for hotpin.

Macro that takes one PWM output configuration and then changes it to EPPL reinit balue. To be used in EPPL_HOTPINS

#define SPWM_PIN_HOTPINS_GENERATE (   n,
  arg 
)    SPWM_PIN_HOTPIN arg

Macro used for hotpins generation.

Macro that is used by EPPL_PROCESSEVERYARG to generate posible reconfiguration of all defined outputs.

See Also
SPWM_PIN_HOTPIN
#define SPWM_PIN_ONRESET (   pin,
  off,
  on 
)
Value:
if(0 != *pval++) { \
eppl_reinitFromISR(EPPL_SR(pin, off, on)); \
}

Macro used on counter reset.

Macro used for code generation for single pin when main counter is reset.

#define SPWM_PIN_ONRESET_GENERATE (   n,
  arg 
)    SPWM_PIN_ONRESET arg

Macro used for code generation for all pins on counter reset.

Macro is used by EPPL_REPEATONEVERYARG to generate code on main counter reset.

#define SPWM_PIN_ONTICK (   pin,
  off,
  on 
)
Value:
if(spwm_cnt >= *pval++) { \
eppl_reinitFromISR(EPPL_SR(pin, on, off)); \
}

Macro used on every tick.

Macro is used on every timer tick to generate code for one pin. This part of code would be not called in the tick when main counter is reset.

#define SPWM_PIN_ONTICK_GENERATE (   n,
  arg 
)    SPWM_PIN_ONTICK arg

Macro used for code generation for all pins on timer tick.

Macro is used by EPPL_REPEATONEVERYARG to generate code on every tick but the one when counter is reset.

#define SPWM_PIN_SC (   pin,
  off,
  on 
)    EPPL_SC(pin, off)

Macro used for pin config.

Macro that takes one PWM output configuration and then changes it to EPPL config value. To be used in eppl_init.

#define SPWM_PIN_SC_GENERATE (   n,
  arg 
)    SPWM_PIN_SC arg

Macro used for pin config generation.

Macro that is used by EPPL_PROCESSEVERYARG to generate configuration of all defined outputs.

See Also
SPWM_PIN_SC
#define SPWM_PINCONFIG   EPPL_PROCESSEVERYARG(SPWM_PIN_SC_GENERATE, com, SPWM_OUTPUTS_ALL)

SPWM pin initialization data.

Use this constant for eppl_init function in your main code.

Example:

eppl_init(EPPL_mode_inPU,
EPPL_SC(LED, EPPL_mode_outPP_0),
EPPL_SC(BUTTON, EPPL_mode_inPU)
);
Examples:
base/main.c.

Function Documentation

static void spwm_onTick ( void  )
inlinestatic

Function to be called on every tick.

Function that has to be called on timer tick.

Examples:
base/main.c.
static void spwm_set ( uint8_t  ch,
spwm_val_T  val 
)
inlinestatic

Function that sets value for selected channel.

Function sets the value on channel.

Parameters
chChannel index to set
valValue to set on selected channel.
Examples:
base/main.c.
static void spwm_set_FromISR ( uint8_t  ch,
spwm_val_T  val 
)
inlinestatic

Function that sets value for selected channel from ISR.

Function sets the value on channel from ISR. From ISR we do not have to worry about operation to be atomic.

Parameters
chChannel index to set
valValue to set on selected channel.