aboutsummaryrefslogtreecommitdiff
path: root/stmhal/led.c
AgeCommit message (Collapse)Author
2017-09-06ports: Make new ports/ sub-directory and move all ports there.Damien George
This is to keep the top-level directory clean, to make it clear what is core and what is a port, and to allow the repository to grow with new ports in a sustainable way.
2017-08-30all: Convert remaining "mp_uint_t n_args" to "size_t n_args".Damien George
This is to have consistency across the whole repository.
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-06-15stmhal: Make error messages more consistent across peripherals.Damien George
2017-05-06stmhal: Convert all module and method tables to use MP_ROM macros.Damien George
2017-03-02stmhal: Use mp_hal_delay_ms instead of HAL_Delay.Damien George
2017-01-04all: Consistently update signatures of .make_new and .call methods.Paul Sokolovsky
Otherwise, they serve reoccurring source of copy-paste mistakes and breaking nanbox build.
2016-12-22stmhal/led: Use mp_hal_pin_config function instead of HAL_GPIO_Init.Damien George
2016-12-22stmhal/led: Properly initialise timer handle to zero before using it.Damien George
Without this the timer will have random values for its State and Lock entries. The object can then be in a locked state leading to some HAL functions returning immediately with an error code (which is unchecked). This patch fixes such a bug which did manifest itself as PWM not working correctly for LEDs.
2016-10-18stmhal/led: Refactor LED to use mp_hal_pin_output() init function.Damien George
As part of this patch the MICROPY_HW_LED_OTYPE setting is removed because it is now unused (all boards anyway had this as OUTPUT_PP).
2016-05-13stmhal/led: Allow LEDs to be in PWM mode with TIM1 and channels 1-4.Damien George
This allows PYBv3 to use PWM for LED(1) and LED(2).
2016-01-29stmhal: Add PWM capability for LED(3) and LED(4) on pyboards.Damien George
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-29stmhal: Make TIM3 available for use by the user.Damien George
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-11py: Change first arg of type.make_new from mp_obj_t to mp_obj_type_t*.Damien George
The first argument to the type.make_new method is naturally a uPy type, and all uses of this argument cast it directly to a pointer to a type structure. So it makes sense to just have it a pointer to a type from the very beginning (and a const pointer at that). This patch makes such a change, and removes all unnecessary casting to/from mp_obj_t.
2015-10-31all: Add py/mphal.h and use it in all ports.Damien George
py/mphal.h contains declarations for generic mp_hal_XXX functions, such as stdio and delay/ticks, which ports should provide definitions for. A port will also provide mphalport.h with further HAL declarations.
2015-08-03stmhal: Factor GPIO clock enable logic into mp_hal_gpio_clock_enable.Damien George
Extracted GPIO clock enable logic into mp_hal_gpio_clock_enable and called from anyplace which might need to use GPIO functions on ports other than A-D. Thanks to Dave Hylands for the patch.
2015-07-30stmhal: Replace #include "stm32f4xx_hal.h" with #include STM32_HAL_H.Dave Hylands
2015-04-18stmhal: Make a HW config option for LED4 being controlled by PWM.Damien George
2015-04-16py: Overhaul and simplify printf/pfenv mechanism.Damien George
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.
2015-04-11stmhal: Make LED object print LED(x) for consistency with constructor.Damien George
2015-01-21stmhal: Add support for FEZ Cerb40 II board from ghielectronics.com.Dave Hylands
2015-01-01stmhal: Prefix includes with py/; remove need for -I../py.Damien George
2014-08-30Change some parts of the core API to use mp_uint_t instead of uint/int.Damien George
Addressing issue #50, still some way to go yet.
2014-07-03Rename machine_(u)int_t to mp_(u)int_t.Damien George
See discussion in issue #50.
2014-06-20Merge pull request #707 from eblot/master-v1.1.1-build-fixesPaul Sokolovsky
Fix missing declaration of assert() Replace ARRAY_SIZE with MP_ARRAY_SIZE
2014-06-19Prefix ARRAY_SIZE with micropython prefix MP_Emmanuel Blot
2014-06-17stmhal: Toggle LED using ODR ^= pin_mask.Damien George
2014-05-03Add license header to (almost) all files.Damien George
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-02unix,stmhal: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky
2014-04-30stmhal: Make LED.intensity return the same value it was set to.Damien George
Also give proper error message when trying to construct a non-existent LED. Addresses issue #530.
2014-04-29stmhal: Add documentation in comments, and script to generate HTML.Damien George
Decided to write own script to pull documentation from comments in C code. Style for writing auto generated documentation is: start line with /// and then use standard markdown to write the comment. Keywords recognised by the scraper begin with backslash. See code for examples. Running: python gendoc.py modpyb.c accel.c adc.c dac.c extint.c i2c.c led.c pin.c rng.c servo.c spi.c uart.c usrsw.c, will generate a HTML structure in gendoc-out/. gendoc.py is crude but functional. Needed something quick, and this was it.
2014-04-26Add ARRAY_SIZE macro, and use it where possible.Damien George
2014-04-20stmhal: Add SPI class.Damien George
Also some updates to compile with latest changes to core py.
2014-04-19stmhal: Rename pyb.Led to pyb.LED to conform to naming rules.Damien George
It's Light Emitting Diode, so should be LED.
2014-04-17build: Simplify build directory layout by putting all headers in genhdr.Damien George
Any generated headers go in $(BUILD)/genhdr/, and are #included as 'genhdr/xxx.h'.
2014-04-05py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George
This does not affect code size or performance when debugging turned off. To address issue #420.
2014-04-02stmhal: Add timer module; move servo PWM from TIM2 to TIM5.Damien George
As per issue #257, servo is better on TIM5 because TIM2 is connected to more GPIO.
2014-04-01Fix pyb.Led(n) code to work properly.Dave Hylands
2014-03-30Merge map.h into obj.h.Damien George
Pretty much everyone needs to include map.h, since it's such an integral part of the Micro Python object implementation. Thus, the definitions are now in obj.h instead. map.h is removed.
2014-03-30Rename rt_* to mp_*.Damien George
Mostly just a global search and replace. Except rt_is_true which becomes mp_obj_is_true. Still would like to tidy up some of the names, but this will do for now.
2014-03-30stmhal: Unify naming of HW config; make SD detect configurable.Damien George
All board config macros now begin with MICROPY_HW_. Renamed PYBv10 to PYBV10, since macros should be all uppercase. Made SDCARD_DETECT configurable in mpconfigport.h, so that the SD detect pin can be easily configured.
2014-03-30stmhal: Implement selector for USB device mode; improve boot up.Damien George
Can now choose at boot up whether the USB device is CDC+MSC or CDC+HID. Choice is made by an option in boot.py, with default being CDC+MSC. HID+MSC is not currently supported, but should be easy to implement. Boot up now has ability to change the reset mode: hold down USR switch while booting and LEDs will count from 1 to 7 to indicate the boot mode. Release USR when correct mode is selected. Current modes are 1 (normal boot), 2 (safe mode), 3 (reset FS mode).
2014-03-26stmhal: Use rt_check_nargs to check number of arguments.Damien George
2014-03-26Remove mp_obj_type_t.methods entry and use .locals_dict instead.Damien George
Originally, .methods was used for methods in a ROM class, and locals_dict for methods in a user-created class. That distinction is unnecessary, and we can use locals_dict for ROM classes now that we have ROMable maps. This removes an entry in the bloated mp_obj_type_t struct, saving a word for each ROM object and each RAM object. ROM objects that have a methods table (now a locals_dict) need an extra word in total (removed the methods pointer (1 word), no longer need the sentinel (2 words), but now need an mp_obj_dict_t wrapper (4 words)). But RAM objects save a word because they never used the methods entry. Overall the ROM usage is down by a few hundred bytes, and RAM usage is down 1 word per user-defined type/class. There is less code (no need to check 2 tables), and now consistent with the way ROM modules have their tables initialised. Efficiency is very close to equivaluent.
2014-03-26Change mp_method_t.name from const char * to qstr.Damien George
Addresses issue #377.
2014-03-24stmhal: Make Led, Servo and Accel their class, not a function.Damien George
2014-03-23stmhal: Improve LED intensity get/set method.Damien George
2014-03-22stmhal: Add intensity method for blue LED.Damien George
As part of this, rejig the way TIM3 is initialised, since it's now shared by USB CDC and the blue LED PWM.
2014-03-20stmhal: Add accelerometer driver; fix bug with LFN.Damien George
2014-03-14stmhal - add led support. Add netduino_plus_2 supportDave Hylands
Tweaked a couple of the USB files to compile if neither dev nor host was defined. Tested on netduiono plus 2 and stm32f4discovery boards