summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/timer.c
Commit message (Collapse)AuthorAge
* stmhal: Replace #include "stm32f4xx_hal.h" with #include STM32_HAL_H.Dave Hylands2015-07-30
|
* stmhal: Allow ADC.read_timed to take Timer object in place of freq.Damien George2015-07-22
| | | | | | | This allows a user-specified Timer for the triggering of the ADC read, mirroring the new behaviour of DAC.write_timed. Addresses issue #1129.
* stmhal: Allow DAC.write_timed to take Timer object in place of freq.Damien George2015-07-21
| | | | | | | | 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.
* stmhal: Actually disable unhandled timer interrupts.Dave Hylands2015-04-28
|
* stmhal: Reset the timer counter to zero after changing the auto reload.Dave Hylands2015-04-22
| | | | | Because if the counter is above the new value of the auto-reload register then it may be a long time until the timer wraps around.
* stmhal: Exclude code for those timers that don't exist in the hardware.Damien George2015-04-18
|
* stmhal: Use new %q format to print qstr's in a few more places.blmorris2015-04-16
| | | | Saves 68 bytes.
* py: Overhaul and simplify printf/pfenv mechanism.Damien George2015-04-16
| | | | | | | | | | | | | | | | | | | | | | Previous to this patch the printing mechanism was a bit of a tangled mess. This patch attempts to consolidate printing into one interface. All (non-debug) printing now uses the mp_print* family of functions, mainly mp_printf. All these functions take an mp_print_t structure as their first argument, and this structure defines the printing backend through the "print_strn" function of said structure. Printing from the uPy core can reach the platform-defined print code via two paths: either through mp_sys_stdout_obj (defined pert port) in conjunction with mp_stream_write; or through the mp_plat_print structure which uses the MP_PLAT_PRINT_STRN macro to define how string are printed on the platform. The former is only used when MICROPY_PY_IO is defined. With this new scheme printing is generally more efficient (less layers to go through, less arguments to pass), and, given an mp_print_t* structure, one can call mp_print_str for efficiency instead of mp_printf("%s", ...). Code size is also reduced by around 200 bytes on Thumb2 archs.
* stmhal: Fix a bug related to unhandled channel interrupts.Dave Hylands2015-03-20
| | | | | This also cleans up spurious interrupts which happen at timer initilaization time.
* stmhal: Add support for quadrature encoder mode to pyb.TimerChannel.Dave Hylands2015-03-09
|
* stmhal: Reset state of timer when deinit is called.Damien George2015-02-23
|
* stmhal: Fix problem when passing callback= to timer init function.Dave Hylands2015-02-22
| | | | | | In particular, make sure that the globals are all initialized before enabling the interrupt, and also make sure that the timer interrupt has been initialied before enabling the NVIC.
* stmhal: Properly deinit timer object.Damien George2015-02-13
| | | | Addresses issue #1113.
* stmhal: Allow to build without float support if wanted.Damien George2015-01-08
|
* stmhal: Collect all root pointers together in 1 place.Damien George2015-01-07
| | | | | A GC in stmhal port now only scans true root pointers, not entire BSS. This reduces base GC time from 1700ms to 900ms.
* stmhal: Prefix includes with py/; remove need for -I../py.Damien George2015-01-01
|
* modsys: Add sys.print_exception(exc, file=sys.stdout) function.Paul Sokolovsky2014-12-08
| | | | | | | | | | | | The function is modeled after traceback.print_exception(), but unbloated, and put into existing module to save overhead on adding another module. Compliant traceback.print_exception() is intended to be implemented in micropython-lib in terms of sys.print_exception(). This change required refactoring mp_obj_print_exception() to take pfenv_t interface arguments. Addresses #751.
* Add support for complimentary channel output and deadtime.Dave Hylands2014-10-10
| | | | | | | This patch enables output on the complimentary channels (TIMx_CHyN). For timers 1 and 8, deadtime can also be inserted when the channels transition. For the pyboard, TIM8_CH1/CH1N and TIM8_CH2/CH2N can take advantage of this.
* stmhal: Use mp_uint_t where appropriate.Damien George2014-10-05
| | | | | | Found these by compiling stmhal with mp_uint_t of type uint32_t instead of unsigned int. This actually makes a difference to the code, but just a curiosity.
* stmhal, timer: Fix timer.chanel so mode can be a keyword.Damien George2014-10-05
|
* stmhal, timer: Improve accuracy of freq computation.Damien George2014-10-05
|
* stmhal, timer: Set freq from float; get timer source freq.Damien George2014-10-05
| | | | | | | | Timers now have the following new features: - can init freq using floating point; eg tim.init(freq=0.1) - tim.source_freq() added to get freq of timer clock source - tim.freq() added to get/set freq - print(tim) now prints freq
* stmhal: Allow pyb.freq() function to change SYSCLK frequency.Damien George2014-10-04
| | | | | | | | | | | | | Eg pyb.freq(120000000) sets the CPU to 120MHz. The frequency can be set at any point in the code, and can be changed as many times as you like. Note that any active timers will need to be reconfigured after a freq change. Valid range is 24MHz to 168MHz (but not all freqs are supported). The code maintains a 48MHz clock for the USB at all times and it's possible to change the frequency at a USB REPL and keep the REPL alive (well, most of the time it stays, sometimes it resets the USB for some reason). Note that USB does not work with pyb.freq of 24MHz.
* stmhal: Fix edge case for timer PWM of 100%.Damien George2014-09-29
| | | | | Also improve precision of calculating PWM percent in integer mode. Also update teensy with edge case fix.
* Fix timer overflow code.Dave Hylands2014-09-27
| | | | | | | | | | | | | | | | Teensy doesn't need to worry about overflows since all of its timers are only 16-bit. For PWM, the pulse width needs to be able to vary from 0..period+1 (pulse-width == period+1 corresponds to 100% PWM) I couldn't test the 0xffffffff cases since we can't currently get a period that big in python. With a prescaler of 0, that corresponds to a freq of 0.039 (i.e. cycle every 25.56 seconds), and we can't set that using freq or period. I also tested both stmhal and teensy with floats disabled, which required a few other code changes to compile.
* stmhal, timer: Factor code to compute PWM percent; improve 32bit case.Damien George2014-09-25
| | | | Also do the same for teensy timer code.
* Add pulse_width_percent to teensy.Dave Hylands2014-09-23
| | | | | | Fix stmhal and teensy print routines to report actual prescaler an period. Fix teensy build to use soft-float Add USE_ARDUINO_TOOLCHAIN option to teensy build
* stmhal: Add pulse_width_ratio to timer channel object.Damien George2014-09-21
| | | | | | | This allows to set the pulse width (for PWM mode) as a ratio relative to the period of the timer. Eg, 0.5 is a 50% duty cycle. You can set the ratio in the channel init, or using channel.pulse_width_ratio; the latter can also read the pulse width as a ratio.
* Add Timer support (PWM, OC, IC) for stmhal and teensyDave Hylands2014-09-19
|
* Change some parts of the core API to use mp_uint_t instead of uint/int.Damien George2014-08-30
| | | | Addressing issue #50, still some way to go yet.
* stmhal: Resolve question in comment about timer clock.Damien George2014-08-14
|
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* stmhal: Some reordering of code/functions.Damien George2014-07-02
|
* Add timer_deinit and call it just before doing a soft-restartDave Hylands2014-06-30
| | | | This fixes #733.
* Prefix ARRAY_SIZE with micropython prefix MP_Emmanuel Blot2014-06-19
|
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | 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/.
* stmhal: Remove #include <stdint.h> from mpconfigport.h.Damien George2014-05-03
| | | | | Make include dependencies neater, and adheres to the coding convention that headers should not include headers.
* stmhal: Add documentation for DAC and Timer classes.Damien George2014-05-02
|
* Simplify names for argcheck.c / arg parsing.Damien George2014-04-26
|
* Add ARRAY_SIZE macro, and use it where possible.Damien George2014-04-26
|
* stmhal, timer: Remove obsolete global variable.Damien George2014-04-21
|
* stmhal: Add Timer class: simple TIM control, incl callback on IRQ.Damien George2014-04-21
| | | | | | | 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.
* stmhal: Improve flash storage cache management.Damien George2014-04-16
| | | | | | | | | | | | | | | | Internal flash used for the filesystem is now written (from the cache) only after a 5s delay, or when a file is closed, or when the drive is unmounted from the host. This delay means that multiple writes can accumulate in the cache, and leads to less writes to the flash, making it last longer. It's implemented by a high-priority interrupt that takes care of flash erase and write, and flushing the cache. This is still only an interim solution for the flash filesystem. It eventually needs to be replaced with something that uses less RAM for the cache, something that can use more of the flash, and something that does proper wear levelling.
* stmhal: Add ADC function to read data at a given frequency.Damien George2014-04-15
| | | | | | 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).
* py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George2014-04-05
| | | | | | This does not affect code size or performance when debugging turned off. To address issue #420.
* stmhal: Add timer module; move servo PWM from TIM2 to TIM5.Damien George2014-04-02
As per issue #257, servo is better on TIM5 because TIM2 is connected to more GPIO.