Wykres commitów

8272 Commity (1aaba5cabe48fa5168279a51f62124bbfedd5d59)

Autor SHA1 Wiadomość Data
Paul Sokolovsky 1aaba5cabe py/objtuple: Properly implement comparison with incompatible types.
Should raise TypeError, unless it's (in)equality comparison.
2017-09-06 00:23:41 +03:00
Damien George e354b0a0cb stmhal/timer: Remove unnecessary include of USB header files. 2017-09-05 14:30:53 +10:00
Paul Sokolovsky 376618cd8a tests/class_inplace_op: Test for inplace op fallback to normal one. 2017-09-04 16:44:38 +03:00
Paul Sokolovsky 60749e57f2 py/objtype: Implement fallback for instance inplace special methods.
If __iop__ is not defined, call __op__ instead. This is desired behavior
for immutable types, __iop__ needs to be defined only for mutable types.
2017-09-04 16:44:21 +03:00
Damien George 77a48e8cd4 py/obj: Remove declaration for mp_obj_new_none(), it's never defined. 2017-09-04 23:35:46 +10:00
Tobias Badertscher 98da3cf407 stmhal: Fix clock initialisation of L4 MCUs.
There are 2 changes:
- remove early initialisation of LSE and replaced it by LSEDRIVE config
  (there is no reason to call HAL_RCC_OscConfig twice).
- add initialisation of the variables PLLSAI1Source and PLLSAI1M as they
  are needed in Cube HAL 1.8.1.
2017-09-04 17:45:08 +10:00
Damien George 689dae1211 cc3200: Use standard implementation of keyboard interrupt. 2017-09-04 17:32:14 +10:00
Robert HH ab9d7619fc cc3200: Enable micropython.kbd_intr() method 2017-09-04 17:19:59 +10:00
Damien George d4b75f6b68 py/obj: Fix comparison of float/complex NaN with itself.
IEEE floating point is specified such that a comparison of NaN with itself
returns false, and Python respects these semantics.  This patch makes uPy
also have these semantics.  The fix has a minor impact on the speed of the
object-equality fast-path, but that seems to be unavoidable and it's much
more important to have correct behaviour (especially in this case where
the wrong answer for nan==nan is silently returned).
2017-09-04 14:16:27 +10:00
Paul Sokolovsky 9950865c39 py/objfloat: Fix binary ops with incompatible objects.
These are now returned as "operation not supported" instead of raising
TypeError. In particular, this fixes equality for float vs incompatible
types, which now properly results in False instead of exception. This
also paves the road to support reverse operation (e.g. __radd__) with
float objects.

This is achieved by introducing mp_obj_get_float_maybe(), similar to
existing mp_obj_get_int_maybe().
2017-09-02 23:05:24 +03:00
Damien George dd376a239d py/nlrthumb: Get working again on standard Thumb arch (ie not Thumb2).
"b" on Thumb might not be long enough for the jump to nlr_push_tail so it
must be done indirectly.
2017-09-01 15:25:29 +10:00
Damien George 860eeeea9b py/qstrdefs: Remove unused qstrs.
They are not used by any component and take up valuable flash space.
2017-09-01 15:22:25 +10:00
Damien George 1ee6c3771f .gitattributes: Remove obsolete entries for stmhal/hal, stmhal/cmsis. 2017-09-01 11:32:58 +10:00
Damien George bebff0dab0 pic16bit: Add definition of SEEK_SET to unistd.h. 2017-09-01 11:23:09 +10:00
Damien George 2daacc5cee py/modstruct: Check and prevent buffer-write overflow in struct packing.
Prior to this patch, the size of the buffer given to pack_into() was checked
for being too small by using the count of the arguments, not their actual
size.  For example, a format spec of '4I' would only check that there was 4
bytes available, not 16; and 'I' would check for 1 byte, not 4.

The pack() function is ok because its buffer is created to be exactly the
correct size.

The fix in this patch calculates the total size of the format spec at the
start of pack_into() and verifies that the buffer is large enough.  This
adds some computational overhead, to iterate through the whole format spec.
The alternative is to check during the packing, but that requires extra
code to handle alignment, and the check is anyway not needed for pack().
So to maintain minimal code size the check is done using struct_calcsize.
2017-09-01 11:11:09 +10:00
Damien George 79d5acbd01 py/modstruct: Check and prevent buffer-read overflow in struct unpacking
Prior to this patch, the size of the buffer given to unpack/unpack_from was
checked for being too small by using the count of the arguments, not their
actual size.  For example, a format spec of '4I' would only check that
there was 4 bytes available, not 16; and 'I' would check for 1 byte, not 4.

This bug is fixed in this patch by calculating the total size of the format
spec at the start of the unpacking function.  This function anyway needs to
calculate the number of items at the start, so calculating the total size
can be done at the same time.
2017-09-01 10:53:29 +10:00
Damien George 793d826d9d py/modstruct: In struct.pack, stop converting if there are no args left.
This patch makes a repeat counter behave the same as repeating the
typecode, when there are not enough args.  For example:
struct.pack('2I', 1) now behave the same as struct.pack('II', 1).
2017-09-01 10:10:51 +10:00
Paul Sokolovsky b349479a49 tests/class_new: Add another testcase for __new__/__init__ interaction.
Similar to the existing testcase, but test that returning both value of
native type and instance of another user class from __new__ lead to
__init__ not being called, for better coverage.
2017-09-01 00:43:52 +03:00
Damien George ca21aed0a1 py: Make m_malloc_fail() have void return type, since it doesn't return. 2017-08-31 17:00:14 +10:00
Damien George 6c9fca2aa9 py/map: Remove unused new/free functions.
Maps are always allocated "statically" and (de)initialised via mp_map_init
and mp_map_deinit.
2017-08-31 16:46:13 +10:00
Damien George 0e420d48ee py/map: Replace always-false condition with assertion. 2017-08-31 16:45:02 +10:00
Damien George 09547f0f51 extmod/modubinascii: Only include uzlib/tinf.h when it's really needed. 2017-08-31 14:10:49 +10:00
Paul Sokolovsky 4556bd2acd py/objtype: mp_obj_class_lookup: Improve debug logging.
Now traces more explicitly thru the lookup process.
2017-08-31 00:44:51 +03:00
Paul Sokolovsky 35be9e805f tests/class_new: Add checks for __init__ being called and other improvements. 2017-08-30 21:33:42 +03:00
Paul Sokolovsky b565c36963 tests/object_new: Better messages, check user __new__() method.
Make messages more verbose and easier to follow and check that user class'
__new__() is not called by object.__new__(user_class).
2017-08-30 21:29:23 +03:00
Paul Sokolovsky df6605eaba py/objtype: mp_obj_instance_make_new: Fix typos in comment. 2017-08-30 20:55:34 +03:00
Damien George 0102ee092b py: Change obsolete "///" comment formatting to normal comments.
This comment style is no longer used because the docs are written by hand,
not generated.
2017-08-30 21:02:00 +10:00
Damien George 71c9cfb028 all: Convert remaining "mp_uint_t n_args" to "size_t n_args".
This is to have consistency across the whole repository.
2017-08-30 10:59:58 +10:00
Paul Sokolovsky 784909ce16 py/objtype: Handle NotImplemented return from binary special methods.
NotImplemented means "try other fallbacks (like calling __rop__
instead of __op__) and if nothing works, raise TypeError". As
MicroPython doesn't implement any fallbacks, signal to raise
TypeError right away.
2017-08-30 01:39:24 +03:00
Damien George 8388ec4e35 stmhal: Update to new STM Cube HAL library.
This upgrades the HAL to the versions:
- F4 V1.16.0
- F7 V1.7.0
- L4 V1.8.1

The main changes were in the SD card driver.  The vendor changed the SD
read/write functions to accept block number intead of byte address, so
there is no longer any need for a custom patch for this in stm32lib.
The CardType values also changed, so pyb.SDCard().info() will return
different values for the 3rd element of the tuple, but this function was
never documented.
2017-08-29 17:03:28 +10:00
Damien George fe6f0354f6 docs/library/micropython: Fix typo in RST formatting. 2017-08-29 16:53:30 +10:00
Damien George e30ba2f1c7 docs/library: Add description of "index" parameter to uos.dupterm(). 2017-08-29 16:50:28 +10:00
Damien George 6568001c00 stmhal/Makefile: Automatically fetch stm32lib submodule if needed. 2017-08-29 13:50:24 +10:00
Damien George 293e81f31e stmhal: Remove cmsis and hal files, they are now a submodule. 2017-08-29 13:40:22 +10:00
Damien George 05eba60d84 stmhal/Makefile: Use lib/stm32lib instead of local cmsis and hal files. 2017-08-29 13:40:09 +10:00
Damien George 904eb2d9f3 lib: Add new submodule, stm32lib containing STM32 CMSIS and HAL source.
Linked to https://github.com/micropython/stm32lib
2017-08-29 13:39:09 +10:00
Damien George 58321dd985 all: Convert mp_uint_t to mp_unary_op_t/mp_binary_op_t where appropriate
The unary-op/binary-op enums are already defined, and there are no
arithmetic tricks used with these types, so it makes sense to use the
correct enum type for arguments that take these values.  It also reduces
code size quite a bit for nan-boxing builds.
2017-08-29 13:16:30 +10:00
Damien George be8e5744e6 py/nlrx86,x64: Replace #define of defined() with portable macro usage.
Using gcc -Wpedantic will warn that #define of defined() is non-portable
and this patch fixes this.
2017-08-29 12:52:18 +10:00
Damien George 613510bce8 drivers/memory/spiflash: Change from hard-coded soft SPI to generic SPI.
The SPI flash driver now supports using an arbitrary SPI object to
communicate with the flash chip, and in particular can use a hardware SPI
peripheral.
2017-08-29 11:37:18 +10:00
Paul Sokolovsky d5336ba136 docs/machine.Signal: Improve style/grammar and add usage example. 2017-08-29 00:08:40 +03:00
Paul Sokolovsky 37379a2974 py/objstr: startswith, endswith: Check arg to be a string.
Otherwise, it will silently get incorrect result on other values types,
including CPython tuple form like "foo.png".endswith(("png", "jpg"))
(which MicroPython doesn't support for unbloatedness).
2017-08-29 00:06:21 +03:00
Paul Sokolovsky c5c095690f docs/library/network: Fix ref to "socket" module (should be "usocket"). 2017-08-28 14:00:16 +03:00
Paul Sokolovsky 358a7ba014 docs: More xrefs to "MicroPython port" in glossary. 2017-08-28 13:51:05 +03:00
Damien George 7e6881cf7d stmhal/boards/pllvalues.py: Make script work with both Python 2 and 3. 2017-08-24 22:43:36 +10:00
Damien George 3e1412a1fb stmhal/Makefile: Use GEN_PINS_HDR var instead of writing it explicitly. 2017-08-24 13:09:35 +10:00
Damien George a8052d343c stmhal/modmachine: For F7 MCU, save power by reducing internal volt reg. 2017-08-24 12:20:26 +10:00
Damien George 41b4686dd7 stmhal: Compute PLL freq table during build instead of at run time.
Allows for simpler, smaller and faster code at run time when selecting the
boards frequency, and allows more customisation opportunities for the PLL
values depending on the target MCU.
2017-08-24 11:38:39 +10:00
Damien George b84268d49c docs/pyboard/tutorial: Add "timeout=0" to UART in pass-through example.
Without this the pass-through will pause for 1 second at each character.
2017-08-23 17:01:43 +10:00
Damien George fc483706d3 stmhal/modmachine: Improve support for sleep/deepsleep on F7 MCUs.
Changes for F7 are:
- machine.reset_cause() now reports DEEPSLEEP_RESET correctly;
- machine.sleep() is further optimised to reduce power consumption;
- machine.deepsleep() is now implemented and working.
2017-08-23 17:00:02 +10:00
Damien George 49316b864b stmhal/modmachine: Make machine.bootloader() work when MPU is enabled. 2017-08-23 16:58:48 +10:00