Wykres commitów

30 Commity (master)

Autor SHA1 Wiadomość Data
Angus Gratton decf8e6a8b all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a.  The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.

This STATIC feature is rarely (if ever) used.  And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.

So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing.  For example, newcomers don't have
to learn what the STATIC macro is and why it exists.  Reading the code is
also less "loud" with a lowercase static.

One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.

Methodology for this commit was:

1) git ls-files | egrep '\.[ch]$' | \
   xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"

2) Do some manual cleanup in the diff by searching for the word STATIC in
   comments and changing those back.

3) "git-grep STATIC docs/", manually fixed those cases.

4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-07 14:20:42 +11:00
Jim Mussared b4236c7368 stm32: Rename pin_obj_t to machine_pin_obj_t.
This is now consistent with other ports.

Also renamed `pin_{board/cpu}_pins_locals_dict` to
`machine_pin_{board/cpu}_pins_locals_dict`.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03 14:09:08 +11:00
Damien George 95d8b5fd55 extmod/machine_adc: Factor ports' ADC Python bindings to common code.
No functional change, just code factoring to have the Python bindings in
one location, and all the ports use those same bindings.

Signed-off-by: Damien George <damien@micropython.org>
2023-10-23 17:16:45 +11:00
Rene Straub 72ef2e6291 stm32/machine_adc: Fix and improve STM32H5 support.
Changes are:
- Run ADC on PCLK/16.
- Verify and optimize timings (ADC_STAB_DELAY_US, ADC_SAMPLETIME_DEFAULT).
- Add support for STM32H5 VBAT and COREVDD channels on ADC2.
- Replace ADC constants in machine_adc_locals_dict_table.
- Convert STM32 literal to channel numbers in adc_config_channel with
  corresponding STM32 LL library functions (__LL_ADC_IS_CHANNEL_INTERNAL(),
  __LL_ADC_CHANNEL_TO_DECIMAL_NB()).

Reasoning for the second last point: the STM32 driver literals are uint32_t
that don't work with MP_ROM_INT() which handles signed 31 bit integers
only.  Introduce enumerator machine_adc_internal_ch_t to define external
channels (0..19), internal channels (256..) and the special channel VREF
(0xffff).  Values are converted to STM32 literals with adc_ll_channel()
when required in adc_config_and_read_u16().

Signed-off-by: Rene Straub <rene@see5.ch>
2023-09-27 16:58:10 +10:00
Yuuki NAGAO cb38f77918 stm32/adc: Add workaround for ADC errata with G4 MCUs.
For STM32G4, there is a errata on ADC that may get wrong ADC result.
According to the errata sheet, this can be avoid by performing two
consecutive ADC conversions and keep second result.

Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
2023-07-13 12:40:52 +10:00
Yuuki NAGAO 0a31b9bf78 stm32/machine_adc: Fix machine.ADC to work on G4 MCUs.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
2023-07-13 12:39:12 +10:00
Damien George 61339aa506 stm32: Add initial support for H5 MCUs.
This commit adds initial support for STM32H5xx MCUs.  The following
features have been confirmed to be working on an STM32H573:
- UART over REPL and USB CDC
- USB CDC and MSC
- internal flash filesystem
- machine.Pin
- machine.SPI transfers with DMA
- machine.ADC
- machine.RTC
- pyb.LED
- pyb.Switch
- pyb.rng
- mboot

Signed-off-by: Damien George <damien@micropython.org>
2023-06-15 11:09:20 +10:00
Damien George f7f8332ddf stm32/machine_adc: Handle ADC resolution less than 8 bits on all MCUs.
All MCUs can have 6-bit resolution; see adc_cr_to_bits_table.

Signed-off-by: Damien George <damien@micropython.org>
2023-06-15 11:02:55 +10:00
Damien George 13fcd8440e stm32: Add support for STM32H723 MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-21 14:02:49 +11:00
yn386 427d72667f stm32: Add support for STM32L1 MCUs.
This change adds STM32L1 support to the STM32 port.
2022-09-25 23:56:41 +10:00
Jim Mussared 94beeabd2e py/obj: Convert make_new into a mp_obj_type_t slot.
Instead of being an explicit field, it's now a slot like all the other
methods.

This is a marginal code size improvement because most types have a make_new
(100/138 on PYBV11), however it improves consistency in how types are
declared, removing the special case for make_new.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:15 +10:00
Jim Mussared 9dce82776d all: Remove unnecessary locals_dict cast.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10:00
Jim Mussared 662b9761b3 all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.
In preparation for upcoming rework of mp_obj_type_t layout.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10:00
Jim Mussared 0e7bfc88c6 all: Use mp_obj_malloc everywhere it's applicable.
This replaces occurences of

    foo_t *foo = m_new_obj(foo_t);
    foo->base.type = &foo_type;

with

    foo_t *foo = mp_obj_malloc(foo_t, &foo_type);

Excludes any places where base is a sub-field or when new0/memset is used.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-03 22:28:14 +10:00
Asensio Lorenzo Sempere 010012c7c3 stm32: Add support for G0 MCUs.
This commit adds support for the STM32G0 series of MCUs.

Signed-off-by: Asensio Lorenzo Sempere <asensio.aerospace@gmail.com>
2022-04-28 11:56:15 +10:00
Damien George e0a0719416 stm32: Add initial support for STM32WL MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2022-02-04 09:43:43 +11:00
Herwin Grobben 8f68e26f79 stm32: Add support for G4 MCUs, and add NUCLEO_G474RE board defn.
This commit adds support for the STM32G4 series of MCUs, and a board
definition for NUCLEO_G474RE.  This board has the REPL on LPUART1 which is
connected to the on-board ST-link USB-UART.
2022-02-01 16:21:01 +11:00
Damien George 88ac5a3116 stm32: Update L4 code to build with latest stm32lib and L4 HAL 1.17.0.
Signed-off-by: Damien George <damien@micropython.org>
2021-12-14 10:48:01 +11:00
Jan Staal 9e2423e730 stm32: Add support for H7A3(Q)/H7B3(Q), and STM32H73B3I_DK board defn.
This commit is based upon prior work of @dpgeorge and @koendv.

MCU support for the STM32H7A3 and B3 families MCUs:
- STM32H7A3xx
- STM32H7A3xxQ (SMPS)
- STM32H7B3xx
- STM32H7B3xxQ (SMPS)

Support has been added for the STM32H7B3I_DK board.

Signed-off-by: Jan Staal <info@janstaal.com>
2021-09-16 12:29:28 +10:00
Damien George fd01b6c779 stm32/adc: Allow mboot to use basic ADC functions.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 00:42:59 +10:00
Damien George 80883a82c0 stm32/adc: Deselect VBAT after reading to prevent battery drain.
Signed-off-by: Damien George <damien@micropython.org>
2020-12-18 13:32:02 +11:00
Damien George 0118c07916 stm32/machine_adc: Fix ADC auto-calibration to run when ADC not enabled.
Prior to this commit, the ADC calibration code was never executing because
ADVREGEN bit was set making the CR register always non-zero.

This commit changes the logic so that ADC calibration is always run when
the ADC is disabled and an ADC channel is initialised.  It also uses the LL
API functions to do the calibration, to make sure it is done correctly on
each MCU variant.

Signed-off-by: Damien George <damien@micropython.org>
2020-10-29 11:09:43 +11:00
Damien George 0f7b5cceea stm32/machine_adc: Make setting of ADC1_COMMON->CCR clearer on STM32WB. 2020-06-02 10:48:49 +10:00
Jim Mussared def76fe4d9 all: Use MP_ERROR_TEXT for all error messages. 2020-04-05 15:02:06 +10:00
Damien George 69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Damien George ad7213d3c3 py: Add mp_raise_msg_varg helper and use it where appropriate.
This commit adds mp_raise_msg_varg(type, fmt, ...) as a helper for
nlr_raise(mp_obj_new_exception_msg_varg(type, fmt, ...)).  It makes the
C-level API for raising exceptions more consistent, and reduces code size
on most ports:

   bare-arm:   +28 +0.042%
minimal x86:  +100 +0.067%
   unix x64:   -56 -0.011%
unix nanbox:  -300 -0.068%
      stm32:  -204 -0.054% PYBV10
     cc3200:    +0 +0.000%
    esp8266:   -64 -0.010% GENERIC
      esp32:  -104 -0.007% GENERIC
        nrf:  -136 -0.094% pca10040
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
2020-02-13 11:52:40 +11:00
Chris Mason 0096041c99 stm32/{adc,machine_adc}: Change ADC clock and sampling time for F0 MCUs.
STM32F0 has PCLK=48MHz and maximum ADC clock is 14MHz so use PCLK/4=12MHz
to stay within spec of the ADC peripheral.  In pyb.ADC set common sampling
time to approx 4uS for internal and external sources.  In machine.ADC
reduce sample time to approx 1uS for external source, leave internal at
maximum sampling time.
2019-10-04 21:39:17 +10:00
Damien George 22099ab88f stm32/machine_adc: Fix build for F4 and L4 MCUs that only have ADC1. 2019-09-12 19:10:12 +10:00
Damien George 62fe013a5f stm32/machine_adc: Improve operation of ADC for H7, L4 and WB MCUs. 2019-09-06 17:55:12 +10:00
Damien George ebacdfabb6 stm32/machine_adc: Add machine.ADC class. 2019-09-04 15:40:24 +10:00