aboutsummaryrefslogtreecommitdiff
path: root/stmhal/adc.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-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-07stmhal: Add support for NUCLEO_F446RE board.Dave Hylands
2017-05-06stmhal: Convert all module and method tables to use MP_ROM macros.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-13stmhal: Add STM32F769DISC board files.Rami Ali
With minor changes to adc.c and storage.c to support the F769.
2016-12-05stmhal/adc: Use constants from new HAL version.Damien George
2016-11-30stmhal/adc: Make channel "16" always map to the temperature sensor.Damien George
The temperature sensor on F4 and F7 MCUs is mostly, but not always, on channel 16. To retain compatibility across all these MCUs this patch maps the user-facing channel 16 to the internal temperature sensor.
2016-11-30stmhal/adc: Add support for F767 MCU.Damien George
2016-11-30stmhal/adc: Add ADCAll.read_vref method, returning "3.3v" value.Damien George
2016-11-30stmhal/adc: Make ADCAll.read_core_temp return accurate float value.Damien George
It now uses factory calibration values to get a more accurate value, and returns a float instead of an integer.
2016-11-30stmhal/adc: Provide more accurate measure of VBAT and VREFINT.Damien George
By using factory calibration values.
2016-11-29stmhal/adc: Add "mask" selection parameter to pyb.ADCAll constructor.Damien George
The "mask" parameter is used to select which pins the ADCAll constructor will initialise to analog mode. It defaults to all pins (0xffffffff), which is backwards compatible with previous behaviour.
2016-08-25stmhal: Make ADC channel 16 available on L4 MCUs.Matt Brejza
2016-08-11stmhal/adc.c: Get ADC working on STM32L4 MCUs.Tobias Badertscher
Fixing Issue #2243. Main problems were: - HAL_ADC_GetState(adcHandle) may return other bits set (not only HAL_ADC_STATE_EOC_REG) when called - so I AND-ed it out as proposed by mattbrejza in Issue #2243. - ADC Pin has to be configured as GPIO_MODE_ANALOG_ADC_CONTROL not only GPIO_MODE_ANALOG. - Resolved ADC resolution L4 specific (Use L4 define ADC_RESOLUTION_12B). - Changed setting of Init.EOCSelection toADC_EOC_SINGLE_CONV for L4. - Added call to ADC_MultiModeTypeDef as this is done on a STM32Cube generated project too. - Clean up: Configuration of ADC is done only in ONE function not the same is done in two functions. Test is done on PA5 pin of STM32L4Discovery-Kit which is connected to the DOWN button. Thanks to mattbrejza for discovering the bug.
2016-04-16stmhal: L4: Modify adc.c to add support for STM32L4 series.Tobias Badertscher
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: Add STM32F7DISC and associated changes.Dave Hylands
2015-07-30stmhal: Replace #include "stm32f4xx_hal.h" with #include STM32_HAL_H.Dave Hylands
2015-07-22stmhal: Allow ADC.read_timed to take Timer object in place of freq.Damien George
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-05-17py/binary: Make return type of mp_binary_get_size size_t instead of int.Kaspar Schleiser
Fixes sign-compare warning.
2015-04-18stmhal: Add support for STM32F411 MCU.Damien George
2015-04-18stmhal: Exclude code for those timers that don't exist in the hardware.Damien George
2015-04-16stmhal: Use new %q format to print qstr's in a few more places.blmorris
Saves 68 bytes.
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-03-23stmhal: Optimise ADC.read_timed() so that it can sample up to 750kHz.Damien George
2015-03-13stmhal: Fix adc.read_timed so buffer store respects element size.Damien George
Addresses issue #1154.
2015-02-11stmhal: Fix ADC multiplier from 4096 to 4095; optimise fp operation.Damien George
2015-02-06stmhal/adc.c: Fix calculation of read_core_vref()blmorris
There was a stray factor of 2 (VBAT_DIV) that looks like it was copied incorrectly from the read_core_vbat() function. The factor exists in read_core_vbat() because VBAT is measured through a 2:1 voltage divider. read_core_vref now returns values around 1.21V (assuming that external reference voltage is 3.3V) which is in line with the datasheet values. See comment at http://forum.micropython.org/viewtopic.php?f=6&t=533&p=2991#p2991
2015-01-01stmhal: Prefix includes with py/; remove need for -I../py.Damien George
2014-09-27Fix timer overflow code.Dave Hylands
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.
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-08-16stmhal: Fix printing of pin name in error message.Damien George
2014-06-29stmhal: pyb.adc: Clarify that buffer with elements of any size can be used.Paul Sokolovsky
Based on forum post: http://forum.micropython.org/viewtopic.php?f=6&t=193
2014-06-16Fix problem with ADC reads and multiple channelsDave Hylands
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-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-20stmhal: Add SPI class.Damien George
Also some updates to compile with latest changes to core py.
2014-04-19stmhal: Update for mp_binary_get_size() refactor.Paul Sokolovsky
2014-04-18stmhal: Update ADC, DAC and I2C objects to use new buffer protocol.Damien George
Main reason for expanding buffer protocol API was to support writes to a buffer in ADC module (see read_timed). With this change you can now create an array of arbitrary type and ADC.read_timed will store into that array in the correct format (byte, int, float). I wonder though if all these changes were really worth it to support just this function. Hopefully this enhanced buffer protocol API (with typecode specified) will be used elsewhere.
2014-04-18stmhal: Big cleanup; merge gpio into Pin; make names consistent.Damien George
This is an attempt to clean up the Micro Python API on the pyboard. Gpio functionality is now in the Pin object, which seems more natural. Constants for MODE and PULL are now in pyb.Pin. Names of some classes have been adjusted to conform to CamelCase. Other miscellaneous changes and clean up here and there.
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-15stmhal: Add ADC function to read data at a given frequency.Damien George
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-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-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-26stmhal: Use rt_check_nargs to check number of arguments.Damien George