Commit Graph

9 Commits

Author SHA1 Message Date
Damien George a8a4b01af6 stmhal: Add PWM capability for LED(3) and LED(4) on pyboards.
USB CDC no longer needs TIM3 (which was originally used for LED(4) PWM)
and so TIM3 has been freed for general purpose use by the user.  Hence
LED(4) lost its PWM capabilities.

This patch reinstates the PWM capabilities using a semi-generic piece
of code which allows to configure a timer and PWM channel to use for any
LED.  But the PWM capability is only configured if the LED is set to an
intensity between 1 and 254 (ie only when needed).  In that case the
relevant timer is configured for PWM.  It's up to the user to make sure
the timers are not used if PWM is active.

This patch also makes sure that PWM LEDs are turned off using standard
GPIO when calling led.off() or led.intensity(0), instead of just setting
the PWM counter to zero.
2016-01-29 22:44:43 +00:00
Damien George ea89b80ff4 stmhal: Make TIM3 available for use by the user.
TIM3 is no longer used by USB CDC for triggering outgoing data, so we
can now make it available to the user.

PWM fading on LED(4) is now gone, but will be reinstated in a new way.
2016-01-29 22:31:56 +00:00
Damien George 7693ef3bd6 stmhal: Allow ADC.read_timed to take Timer object in place of freq.
This allows a user-specified Timer for the triggering of the ADC read,
mirroring the new behaviour of DAC.write_timed.

Addresses issue #1129.
2015-07-22 19:41:13 +01:00
Damien George abc24c1876 stmhal: Allow DAC.write_timed to take Timer object in place of freq.
This allows the DAC to use a user-specified Timer for the triggering
(instead of the default Timer(6)), while still supporting original
behaviour.

Addresses issues #1129 and #1388.
2015-07-21 23:39:49 +01:00
Dave Hylands 0d81c133b3 Add timer_deinit and call it just before doing a soft-restart
This fixes #733.
2014-06-30 08:07:38 -07:00
Damien George 04b9147e15 Add license header to (almost) all files.
Blanket wide to all .c and .h files.  Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.

Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-05-03 23:27:38 +01:00
Damien George 7fdfa93700 stmhal: Add Timer class: simple TIM control, incl callback on IRQ.
Simple but functional timer control.  More sophistication will
eventually be added, or for now just use direct register access :)

Also added pyb.freq() function to get MCU clock frequencies.
2014-04-21 16:48:16 +01:00
Damien George 4d7f4eb6a9 stmhal: Add ADC function to read data at a given frequency.
Reads ADC values into a bytearray (or similar) at a fixed rate.  Needs a
better name and improved API.  Also fix up DAC dma function (which also
needs a better name and API).
2014-04-15 19:52:56 +01:00
Damien George a12be917a4 stmhal: Add timer module; move servo PWM from TIM2 to TIM5.
As per issue #257, servo is better on TIM5 because TIM2 is connected to
more GPIO.
2014-04-02 15:09:36 +01:00