Commit Graph

10674 Commits

Author SHA1 Message Date
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 0096a4bd00 tests/pyb/adc.py: Fix test so that it really does test ADC values.
Reading into a bytearray will truncate values to 0xff so the assertions
checking read_timed() would previously always succeed.

Thanks to @peterhinch for finding this problem and providing the solution.
2018-04-11 13:21:57 +10:00
Damien George de9528d12c stm32/adc: Fix verification of ADC channel 16 for F411 MCUs. 2018-04-11 13:16:54 +10:00
Peter D. Gray 59dda71038 stm32/main: Guard usb_mode lines in default boot.py by relevant #if. 2018-04-10 23:52:51 +10:00
Damien George 4ff05ae4e9 esp32/machine_uart: Remove UART event queue object.
This event queue has UART events posted to it and they need to be drained
for it to operate without error.  The queue is not used by the uPy UART
class so it should be removed to prevent the IDF emitting errors.

Fixes #3704.
2018-04-10 15:24:10 +10:00
Damien George ef12a4bd05 py: Refactor how native emitter code is compiled with a file per arch.
Instead of emitnative.c having configuration code for each supported
architecture, and then compiling this file multiple times with different
macros defined, this patch adds a file per architecture with the necessary
code to configure the native emitter.  These files then #include the
emitnative.c file.

This simplifies emitnative.c (which is already very large), and simplifies
the build system because emitnative.c no longer needs special handling for
compilation and qstr extraction.
2018-04-10 15:06:47 +10:00
Damien George 5ad27d4b8b tests: Move recursive tests to the tests/stress/ subdir.
Keeping all the stress related tests in one place makes it easier to
stress-test a given port, and to also not run such tests on ports that
can't handle them.
2018-04-10 14:43:52 +10:00
Damien George 605fdcf754 tests/stress/recursive_gen: Add test for recursive gen with iter. 2018-04-10 14:39:51 +10:00
Damien George 22f1414abb stm32/i2c: Fully support peripheral I2C4. 2018-04-10 14:33:18 +10:00
Damien George 69bf23c9cf stm32/i2c: Update HAL macros to use new __HAL_RCC prefix. 2018-04-10 14:28:39 +10:00
iabdalkader e1e49adb86 stm32/boards/NUCLEO_H743ZI: Enable DAC peripheral. 2018-04-10 14:21:26 +10:00
iabdalkader 90bb98e83d stm32/dac: Add support for H7 MCUs.
Includes a fix for H7 DAC DMA requests.
2018-04-10 14:21:26 +10:00
Jeff Epler cbf981f330 py/objgenerator: Check stack before resuming a generator.
This turns a hard crash in a recursive generator into a 'maximum recursion
depth exceeded' exception.
2018-04-10 14:06:26 +10:00
armink 6a693db71d extmod/re1.5: Fix compilecode.c compile problem on IAR tool chain.
The 2nd and 3rd args of the ternary operator are treated like they are in
the same expression and must have similar types.  void is not compatible
with int so that's why the compiler is complaining.
2018-04-10 13:54:22 +10:00
Damien George cf31d384f1 py/stream: Switch stream close operation from method to ioctl.
This patch moves the implementation of stream closure from a dedicated
method to the ioctl of the stream protocol, for each type that implements
closing.  The benefits of this are:

1. Rounds out the stream ioctl function, which already includes flush,
   seek and poll (among other things).

2. Makes calling mp_stream_close() on an object slightly more efficient
   because it now no longer needs to lookup the close method and call it,
   rather it just delegates straight to the ioctl function (if it exists).

3. Reduces code size and allows future types that implement the stream
   protocol to be smaller because they don't need a dedicated close method.

Code size reduction is around 200 bytes smaller for x86 archs and around
30 bytes smaller for the bare-metal archs.
2018-04-10 13:41:32 +10:00
T S 8f11d0b532 docs/library/pyb.ADC.rst: Document new features for ADCAll. 2018-04-10 13:06:26 +10:00
Jeff Epler d6cf5c6749 py/objstr: In find/rfind, don't crash when end < start. 2018-04-05 16:14:17 +10:00
Damien George b9c78425a6 tests/micropython/extreme_exc.py: Allow to run without any emg exc buf. 2018-04-05 03:03:16 +10:00
Damien George 4caadc3c01 tests/micropython/extreme_exc.py: Fix test to run on more ports/configs. 2018-04-05 02:33:48 +10:00
Damien George f1df86a017 py/objint: Simplify LHS arg type checking in int binary op functions.
The LHS passed to mp_obj_int_binary_op() will always be an integer, either
a small int or a big int, so the test for this type doesn't need to include
an "other, unsupported type" case.
2018-04-05 01:11:26 +10:00
Damien George 5995a199a3 tests/micropython: Add set of tests for extreme cases of raising exc's. 2018-04-05 01:06:40 +10:00
Damien George 1bfc774a08 tests/basics/string_compare.py: Add test with string that hashes to 0.
The string "Q+?" is special in that it hashes to zero with the djb2
algorithm (among other strings), and a zero hash should be incremented to a
hash of 1.
2018-04-05 01:04:38 +10:00
Damien George 22161acf47 tests/basics/class_super.py: Add tests for store/delete of super attr. 2018-04-05 01:03:57 +10:00
Damien George 7b7bbd0ee7 tests/basics: Add tests for edge cases of nan-box's 47-bit small int. 2018-04-05 00:59:49 +10:00
Damien George dd48ccb1e3 tests/basics: Add test for subclassing an iterable native type. 2018-04-04 15:26:18 +10:00
Damien George df02f5620a tests/basics/int_big1.py: Add test for big int in mp_obj_get_int_maybe. 2018-04-04 15:23:32 +10:00
Damien George 3f420c0c27 py: Don't include mp_optimise_value or opt_level() if compiler disabled.
Without the compiler enabled the mp_optimise_value is unused, and the
micropython.opt_level() function is not useful, so exclude these from the
build to save RAM and code size.
2018-04-04 14:24:03 +10:00
Damien George 323b5f7270 py/modsys: Don't compile getsizeof function if feature is disabled. 2018-04-04 14:23:25 +10:00
Damien George a45a34ec31 tests/stress: Add test to verify the GC can trace nested objects. 2018-04-04 14:22:54 +10:00
Damien George 7d5c753b17 tests/basics: Modify int-big tests to prevent constant folding.
So that these tests test the runtime behaviour, not the compiler (which may
be executed offline).
2018-04-04 13:57:22 +10:00
Damien George f684e9e1ab tests/basics/int_big1.py: Add test converting str with non-print chars. 2018-04-04 13:56:00 +10:00
Damien George 430efb0444 tests/basics: Add test for use of return within try-except.
The case of a return statement in the try suite of a try-except statement
was previously only tested by builtin_compile.py, and only then in the part
of this test which checked for the existence of the compile builtin.  So
this patch adds an explicit unit test for this case.
2018-04-04 01:43:16 +10:00
Damien George bc36521386 py/vm: Optimise handling of stackless mode when pystack is enabled.
When pystack is enabled mp_obj_fun_bc_prepare_codestate() will always
return a valid pointer, and if there is no more pystack available then it
will raise an exception (a RuntimeError).  So having pystack enabled with
stackless enabled automatically gives strict stackless mode.  There is
therefore no need to have code for strict stackless mode when pystack is
enabled, and this patch optimises the VM for such a case.
2018-04-04 00:51:10 +10:00
Damien George c7f880eda3 py/vm: Don't do unnecessary updates of ip and sp variables.
Neither the ip nor sp variables are used again after the execution of the
RAISE_VARARGS opcode, so they don't need to be updated.
2018-04-04 00:46:31 +10:00
Damien George bcfff4fc98 tests/basics/iter1.py: Add more tests for walking a user-defined iter.
Some code in mp_iternext() was only tested by the native emitter, so the
tests added here test this function using just the bytecode emitter.
2018-03-30 14:23:13 +11:00
Damien George f50b64cab5 py/runtime: Be sure that non-intercepted thrown object is an exception.
The VM expects that, if mp_resume() returns MP_VM_RETURN_EXCEPTION, then
the returned value is an exception instance (eg to add a traceback to it).
It's possible that a value passed to a generator's throw() is not an
exception so must be explicitly checked for if the thrown value is not
intercepted by the generator.

Thanks to @jepler for finding the bug.
2018-03-30 12:43:38 +11:00
Damien George 3280788195 py/runtime: Check that keys in dicts passed as ** args are strings.
Prior to this patch the code would crash if a key in a ** dict was anything
other than a str or qstr.  This is because mp_setup_code_state() assumes
that keys in kwargs are qstrs (for efficiency).

Thanks to @jepler for finding the bug.
2018-03-30 11:13:32 +11:00
Damien George bc3a5f1917 stm32/mphalport: Use MCU regs to detect if cycle counter is started.
Instead of using a dedicated variable in RAM it's simpler to use the
relevant bits in the DWT register.
2018-03-29 16:23:52 +11:00
Damien George b833f170c3 stm32/main: Only update reset_mode if board doesn't use a bootloader.
If the board is configured to use a bootloader then that bootloader will
pass through the reset_mode.
2018-03-29 16:16:58 +11:00
Damien George 7856a416bd stm32/main: Rename main to stm32_main and pass through first argument.
The main() function has a predefined type in C which is not so useful for
embedded contexts.  This patch renames main() to stm32_main() so we can
define our own type signature for this function.  The type signature is
defined to have a single argument which is the "reset_mode" and is passed
through as r0 from Reset_Handler.  This allows, for example, a bootloader
to pass through information into the main application.
2018-03-29 16:15:57 +11:00
Damien George d9e69681f5 stm32: Add custom, optimised Reset_Handler code.
The Reset_Handler needs to copy the data section and zero the BSS, and
these operations should be as optimised as possible to reduce start up
time.  The versions provided in this patch are about 2x faster (on a Cortex
M4) than the previous implementations.
2018-03-29 15:29:23 +11:00
Damien George 7e28212352 stm32/boards/STM32L476DISC: Update to not take the address of pin objs. 2018-03-28 16:29:55 +11:00
Damien George 2dca693c24 stm32: Change pin_X and pyb_pin_X identifiers to be pointers to objects.
Rather than pin objects themselves.  The actual object is now pin_X_obj and
defines are provided so that pin_X is &pin_X_obj.  This makes it so that
code that uses pin objects doesn't need to know if they are literals or
objects (that need pointers taken) or something else.  They are just
entities that can be passed to the map_hal_pin_xxx functions.  This mirrors
how the core handles constant objects (eg mp_const_none which is
&mp_const_none_obj) and allows for the possibility of different
implementations of the pin layer.

For example, prior to this patch there was the following:

    extern const pin_obj_t pin_A0;
    #define pyb_pin_X1 pin_A0
    ...
    mp_hal_pin_high(&pin_A0);

and now there is:

    extern const pin_obj_t pin_A0_obj;
    #define pin_A0 (&pin_A0_obj)
    #define pyb_pin_X1 pin_A0
    ...
    mp_hal_pin_high(pin_A0);

This patch should have minimal effect on board configuration files.  The
only change that may be needed is if a board has .c files that configure
pins.
2018-03-28 16:29:50 +11:00
iabdalkader cf1d6df05a stm32/boards/NUCLEO_H743ZI: Enable SD card support. 2018-03-28 13:25:00 +11:00
iabdalkader b4f814c9b7 stm32/sdcard: Add H7 SD card support. 2018-03-28 13:25:00 +11:00
iabdalkader 9b9896b44d stm32/dma: Remove H7 SDMMC DMA descriptors.
The H7 SD peripheral has direct connection to MDMA instead.
2018-03-28 13:23:40 +11:00
Damien George 1efe6a0316 stm32/boards/NUCLEO_H743ZI: Update to build with new linker management. 2018-03-28 13:20:48 +11:00
Damien George b121c9515d stm32/boards/stm32h743.ld: Remove include of common.ld.
The relevant common.ld file should now be included explicitly by a
particular board.
2018-03-28 13:20:07 +11:00
Damien George 4d409b8e32 stm32/boards/stm32f767.ld: Add definition of FLASH_APP.
This allows F767 MCUs to support a bootloader in the first sector.
2018-03-27 21:35:03 +11:00