Ley de Ohm

Fork of FastPWM by Erik -

Embed: (wiki syntax)

« Back to documentation index

FastPWM Class Reference

FastPWM Class Reference

Library that allows faster and/or higher resolution PWM output. More...

#include <FastPWM.h>

Public Member Functions

 FastPWM (PinName pin, int prescaler=-1)
 Create a FastPWM object connected to the specified pin.
void period (double seconds)
 Set the PWM period, specified in seconds (double), keeping the pulsewidth the same.
void period_ms (int ms)
 Set the PWM period, specified in milli-seconds (int), keeping the pulsewidth the same.
void period_us (int us)
 Set the PWM period, specified in micro-seconds (int), keeping the pulsewidth the same.
void period_us (double us)
 Set the PWM period, specified in micro-seconds (double), keeping the pulsewidth the same.
void period_ticks (uint32_t ticks)
 Set the PWM period, specified in clock ticks, keeping _pulse width_ the same.
void pulsewidth (double seconds)
 Set the PWM pulsewidth, specified in seconds (double), keeping the period the same.
void pulsewidth_ms (int ms)
 Set the PWM pulsewidth, specified in milli-seconds (int), keeping the period the same.
void pulsewidth_us (int us)
 Set the PWM pulsewidth, specified in micro-seconds (int), keeping the period the same.
void pulsewidth_us (double us)
 Set the PWM pulsewidth, specified in micro-seconds (double), keeping the period the same.
void pulsewidth_ticks (uint32_t ticks)
 Set the PWM period, specified in clock ticks, keeping the period the same.
void write (double duty)
 Set the ouput duty-cycle, specified as a percentage (double)
double read (void)
 Return the ouput duty-cycle, specified as a percentage (double)
FastPWMoperator= (double value)
 An operator shorthand for write()
 operator double ()
 An operator shorthand for read()
int prescaler (int value)
 Set the PWM prescaler.

Detailed Description

Library that allows faster and/or higher resolution PWM output.

Library can directly replace standard mbed PWM library.

Contrary to the default mbed library, this library takes doubles instead of floats. The compiler will autocast if needed, but do take into account it is done for a reason, your accuracy will otherwise be limitted by the floating point precision.

Definition at line 30 of file FastPWM.h.


Constructor & Destructor Documentation

FastPWM ( PinName  pin,
int  prescaler = -1 
)

Create a FastPWM object connected to the specified pin.

Parameters:
pin- PWM pin to connect to
prescaler- Clock prescaler, -1 is dynamic (default), 0 is bit random, everything else normal

Definition at line 3 of file FastPWM_common.cpp.


Member Function Documentation

operator double (  )

An operator shorthand for read()

Definition at line 78 of file FastPWM_common.cpp.

FastPWM & operator= ( double  value )

An operator shorthand for write()

Definition at line 73 of file FastPWM_common.cpp.

void period ( double  seconds )

Set the PWM period, specified in seconds (double), keeping the pulsewidth the same.

Definition at line 20 of file FastPWM_common.cpp.

void period_ms ( int  ms )

Set the PWM period, specified in milli-seconds (int), keeping the pulsewidth the same.

Definition at line 27 of file FastPWM_common.cpp.

void period_ticks ( uint32_t  ticks )

Set the PWM period, specified in clock ticks, keeping _pulse width_ the same.

This function can be used if low overhead is required. Do take into account the result is board (clock frequency) dependent, and this does not keep an equal duty cycle!

Definition at line 13 of file FastPWM_KLXX_K20D50M.cpp.

void period_us ( double  us )

Set the PWM period, specified in micro-seconds (double), keeping the pulsewidth the same.

Definition at line 41 of file FastPWM_common.cpp.

void period_us ( int  us )

Set the PWM period, specified in micro-seconds (int), keeping the pulsewidth the same.

Definition at line 34 of file FastPWM_common.cpp.

int prescaler ( int  value )

Set the PWM prescaler.

The period of all PWM pins on the same PWM unit have to be reset after using this!

Parameters:
value- The required prescaler. Special values: 0 = lock current prescaler, -1 = use dynamic prescaler
return- The prescaler which was set (can differ from requested prescaler if not possible)

Definition at line 82 of file FastPWM_common.cpp.

void pulsewidth ( double  seconds )

Set the PWM pulsewidth, specified in seconds (double), keeping the period the same.

Definition at line 48 of file FastPWM_common.cpp.

void pulsewidth_ms ( int  ms )

Set the PWM pulsewidth, specified in milli-seconds (int), keeping the period the same.

Definition at line 52 of file FastPWM_common.cpp.

void pulsewidth_ticks ( uint32_t  ticks )

Set the PWM period, specified in clock ticks, keeping the period the same.

This function can be used if low overhead is required. Do take into account the result is board (clock frequency) dependent!

Definition at line 9 of file FastPWM_KLXX_K20D50M.cpp.

void pulsewidth_us ( int  us )

Set the PWM pulsewidth, specified in micro-seconds (int), keeping the period the same.

Definition at line 56 of file FastPWM_common.cpp.

void pulsewidth_us ( double  us )

Set the PWM pulsewidth, specified in micro-seconds (double), keeping the period the same.

Definition at line 60 of file FastPWM_common.cpp.

double read ( void   )

Return the ouput duty-cycle, specified as a percentage (double)

Parameters:
return- A double value representing the output duty-cycle, specified as a percentage.

Definition at line 69 of file FastPWM_common.cpp.

void write ( double  duty )

Set the ouput duty-cycle, specified as a percentage (double)

Parameters:
duty- A double value representing the output duty-cycle, specified as a percentage. The value should lie between 0.0 (representing on 0%) and 1.0 (representing on 100%).

Definition at line 64 of file FastPWM_common.cpp.