Commit Graph

71 Commits

Author SHA1 Message Date
Damien George c62b23094f stm32/adc: Disable VBAT in read channel helper function.
Prior to this patch, if VBAT was read via ADC.read() or
ADCAll.read_channel(), then it would remain enabled and subsequent reads
of TEMPSENSOR or VREFINT would not work.  This patch makes sure that VBAT
is disabled for all cases that it could be read.
2018-08-04 13:25:43 +10:00
Damien George e1ae9939ac stm32: Support compiling with object representation D.
With this and previous patches the stm32 port can now be compiled using
object representation D (nan boxing).  Note that native code and frozen mpy
files with float constants are currently not supported with this object
representation.
2018-07-08 23:25:11 +10:00
Damien George ea7e747979 stm32: Add support for STM32F0 MCUs. 2018-05-28 21:49:49 +10:00
Tobias Badertscher 708cdb6276 stm32: Add support for STM32L496 MCU. 2018-05-18 22:37:30 +10:00
Damien George cb3456ddfe stm32: Don't use %lu or %lx for formatting, use just %u or %x.
On this 32-bit arch there's no need to use the long version of the format
specifier.  It's only there to appease the compiler which checks the type
of the args passed to printf.  Removing the "l" saves a bit of code space.
2018-05-04 15:52:03 +10:00
Damien George d4f8414ebd stm32/adc: Use mp_hal_pin_config() instead of HAL_GPIO_Init().
This makes ADCAll work correctly on L4 MCUs.
2018-05-02 12:17:45 +10:00
iabdalkader 8c12f1d916 stm32/adc: Add support for H7 MCU series.
ADC3 is used because the H7's internal ADC channels are connected to ADC3
and the uPy driver doesn't support more than one ADC.

Only 12-bit resolution is supported because 12 is hard-coded and 14/16 bits
are not recommended on some ADC3 pins (see errata).

Values from internal ADC channels are known to give wrong values at
present.
2018-05-01 15:36:11 +10:00
Damien George f1073e747d stm32/adc: Factor common ADC init code into adcx_init_periph().
The only configuration that changes with this patch is that on L4 MCUs the
clock prescaler changed from ADC_CLOCK_ASYNC_DIV2 to ADC_CLOCK_ASYNC_DIV1
for the ADCAll object.  This should be ok.
2018-04-11 14:46:13 +10:00
Damien George 1d6c155d6a stm32/adc: Fix config of EOC selection and Ext-Trig for ADC periph.
A value of DISABLE for EOCSelection is invalid.  This would have been
interpreted instead as ADC_EOC_SEQ_CONV, but really it should be
ADC_EOC_SINGLE_CONV for the uses in this code.  So this has been fixed.

ExternalTrigConv should be ADC_SOFTWARE_START because all ADC
conversions are started by software.  This is now fixed.
2018-04-11 14:29:37 +10:00
Damien George 06807c1bde stm32/adc: Factor code to optimise adc_read_channel and adc_read.
Saves 200 bytes of code space.
2018-04-11 14:28:06 +10:00
Damien George aebd9701a7 stm32/adc: Optimise read_timed_multi() by caching buffer pointers. 2018-04-11 14:09:09 +10:00
Peter Hinch 4f40fa5cf4 stm32/adc: Add read_timed_multi() static method, with docs and tests. 2018-04-11 13:36:17 +10:00
Damien George de9528d12c stm32/adc: Fix verification of ADC channel 16 for F411 MCUs. 2018-04-11 13:16:54 +10:00
Damien George 6b51eb22c8 stm32: Consolidate include of genhdr/pins.h to single location in pin.h.
genhdr/pins.h is an internal header file that defines all of the pin
objects and it's cleaner to have pin.h include it (where the struct's for
these objects are defined) rather than an explicit include by every user.
2018-03-27 20:25:24 +11:00
Damien George e37b8ba5a5 stm32: Use STM32xx macros instead of MCU_SERIES_xx to select MCU type.
The CMSIS files for the STM32 range provide macros to distinguish between
the different MCU series: STM32F4, STM32F7, STM32H7, STM32L4, etc.  Prefer
to use these instead of custom ones.
2018-03-17 10:42:50 +11:00
Damien George 60b0982bb2 stm32: Add board config option to enable/disable the ADC.
The new option is MICROPY_HW_ENABLE_ADC and is enabled by default.
2018-02-22 14:22:45 +11:00
Damien George 3eb0694b97 stm32: Update HAL macro and constant names to use newer versions.
Newer versions of the HAL use names which are cleaner and more
self-consistent amongst the HAL itself.  This patch switches to use those
names in most places so it is easier to update the HAL in the future.
2018-02-13 15:37:35 +11:00
Damien George e8a8fa77ca stm32: Improve support for STM32F722, F723, F732, F733 MCUs. 2018-02-01 13:11:32 +11:00
Damien George a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00
Tobias Badertscher bd71b3252a stm32/boards: Add new board B_L475E_IOT01A based on STM32L475. 2017-09-10 16:02:39 +10:00
Damien George 01dd7804b8 ports: Make new ports/ sub-directory and move all ports there.
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-09-06 13:40:51 +10:00