aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-02-05stm32/main: Remove need for first_soft_reset variable.Damien George
2018-02-05stm32/main: Reorder some init calls to put them before soft-reset loop.Damien George
The calls to rtc_init_start(), sdcard_init() and storage_init() are all guarded by a check for first_soft_reset, so it's simpler to just put them all before the soft-reset loop, without the check. The call to machine_init() can also go before the soft-reset loop because it is only needed to check the reset cause which can happen once at the first boot. To allow this to work, the reset cause must be set to SOFT upon a soft-reset, which is the role of the new function machine_deinit().
2018-02-05stm32/rtc: Add compile-time option to set RTC source as LSE bypass.Damien George
To use the LSE bypass feature (where an external source provides the RTC clock) a board must set the config variable MICROPY_HW_RTC_USE_BYPASS.
2018-02-05stm32/rtc: Fix RTC init to use LSI if LSI is already selected on boot.Damien George
Upon boot the RTC early-init function should detect if LSE or LSI is already selected/running and, if so, use it. When the LSI has previously (in the previous reset cycle) been selected as the clock source the only way to reliably tell is if the RTCSEL bits of the RCC_BDCR are set to the correct LSI value. In particular the RCC_CSR bits for LSI control do not indicate if the LSI is ready even if it is selected. This patch removes the check on the RCC_CSR bits for the LSI being on and ready and only uses the check on the RCC_BDCR to see if the LSI should be used straightaway. This was tested on a PYBLITEv1.0 and with the patch the LSI persists correctly as the RTC source as long as the backup domain remains powered.
2018-02-05stm32/rtc: Fix rtc_info flags when LSE fails and falls back to LSI.Damien George
Previously, if LSE is selected but fails and the RTC falls back to LSI, then the rtc_info flags would incorrectly state that LSE is used. This patch fixes that by setting the bit in rtc_info only after the clock is ready.
2018-02-05stm32/spi: Accept machine.SPI object in spi_from_mp_obj() function.Damien George
Also, change ValueError to TypeError if the argument to this function is not of an SPI type.
2018-02-05drivers/cc3200: Update to work with new stm32 SPI API.Damien George
2018-02-05stm32: Update LCD and network drivers to work with new SPI API.Damien George
2018-02-05stm32/spi: Provide better separation between SPI driver and uPy objs.Damien George
There is an underlying hardware SPI driver (built on top of the STM HAL) and then on top of this sits the legacy pyb.SPI class as well as the machine.SPI class. This patch improves the separation between these layers, in particular decoupling machine.SPI from pyb.SPI.
2018-02-04py/compile: Combine compiler-opt of 2 and 3 tuple-to-tuple assignment.Damien George
This patch combines the compiler optimisation code for double and triple tuple-to-tuple assignment, taking it from two separate if-blocks to one combined if-block. This can be done because the code for both of these optimisations has a lot in common. Combining them together reduces code size for ports that have the triple-tuple optimisation enabled (and doesn't change code size for ports that have it disabled).
2018-02-02stm32/i2c: Allow I2C peripheral state to persist across a soft reset.Damien George
The I2C sub-system is independent from the uPy state (eg the heap) and so can safely persist across a soft reset.
2018-02-02stm32/spi: Allow SPI peripheral state to persist across a soft reset.Damien George
The SPI sub-system is independent from the uPy state (eg the heap) and so can safely persist across a soft reset. And this is actually necessary for drivers that rely on SPI and that also need to persist across soft reset (eg external SPI flash memory).
2018-02-02stm32/rng: Simplify RNG implementation by accessing raw peripheral regs.Damien George
It saves code size and RAM, and is more efficient to execute.
2018-02-02stm32/spi: Add support for a board naming SPI peripherals 4, 5 and 6.Damien George
2018-02-02stm32/i2c: Use macros instead of magic numbers for I2C speed grades.liamkinne
2018-02-01stm32/usbdev: Add support for high-speed USB device mode.Damien George
This patch adds support in the USBD configuration and CDC-MSC-HID class for high-speed USB mode. To enable it the board configuration must define USE_USB_HS, and either not define USE_USB_HS_IN_FS, or be an STM32F723 or STM32F733 MCU which have a built-in HS PHY. High-speed mode is then selected dynamically by passing "high_speed=True" to the pyb.usb_mode() function, otherwise it defaults to full-speed mode. This patch has been tested on an STM32F733.
2018-02-01stm32/usb: Allow board to select which USBD is used as the main one.Damien George
By defining MICROPY_HW_USB_MAIN_DEV a given board can select to use either USB_PHY_FS_ID or USB_PHY_HS_ID as the main USBD peripheral, on which the REPL will appear. If not defined this will be automatically configured.
2018-02-01docs/library/pyb.rst: Add note about availability of USB MSC-only mode.Damien George
2018-02-01stm32/usbdev: Add support for MSC-only USB device class.Damien George
Select this mode in boot.py via: pyb.usb_mode('MSC')
2018-02-01stm32/sdcard: Use maximum speed SDMMC clock on F7 MCUs.Damien George
This will get the SDMMC clock up to 48MHz.
2018-02-01stm32/sdcard: Only define IRQ handler if using SDMMC1 peripheral.Damien George
So that the IRQ can be used by other peripheral drivers if needed.
2018-02-01stm32/modmachine: In freq(), select flash latency value based on freq.Damien George
2018-02-01stm32: Improve support for STM32F722, F723, F732, F733 MCUs.Damien George
2018-02-01stm32/can: Support MCUs without a CAN2 peripheral.Damien George
2018-02-01stm32/usbdev: Combine all str descriptor accessor funcs into one func.Damien George
There's no need to have these as separate functions, they just take up unnecessary code space and combining them allows to factor common code, and also allows to support arbitrary string descriptor indices.
2018-02-01stm32/usbdev: Reduce dependency on py header files.Damien George
2018-02-01stm32/sdcard: Make SD wait routine more power efficient by using WFI.Damien George
Using WFI allows the CPU to sleep while it is waiting, reducing power consumption.
2018-02-01stm32/spi: Make SPI DMA wait routine more power efficient by using WFI.Damien George
The routine waits for the DMA to finish, which is signalled from a DMA IRQ handler. Using WFI makes the CPU sleep while waiting for the IRQ to arrive which decreases power consumption. To make it work correctly the check for the change in state must be atomic and so IRQs must be disabled during the check. The key feature of the Cortex MCU that makes this possible is that WFI will exit when an IRQ arrives even if IRQs are disabled.
2018-01-31drivers/sdcard: Update doc for ESP8266 to use correct SPI number.Hemanth kumar
machine.SPI(0) results in ValueError on ESP8266. SPI(1) is the user hardware SPI port (or use SPI(-1) for software SPI).
2018-01-31minimal/README: Update text to better describe what "make run" does.Damien George
2018-01-31esp32/machine_uart: Fix check of UART id so it only allows valid UARTs.Damien George
2018-01-31.gitmodules: Use https URL for lwIP submodule.Damien George
HTTPS is supported by Savannah and better to be secure than not.
2018-01-31lib/utils/pyexec.h: Include py/obj.h because its decls are needed.Damien George
2018-01-31stm32: Add support for DHT11/DHT22 sensors.Damien George
2018-01-31esp8266/modules: Move dht.py driver to drivers/dht directory.Damien George
2018-01-31extmod/vfs_fat_file: Implement SEEK_CUR for non-zero offset.Ayke van Laethem
CPython doesn't allow SEEK_CUR with non-zero offset for files in text mode, and uPy inherited this behaviour for both text and binary files. It makes sense to provide full support for SEEK_CUR of binary-mode files in uPy, and to do this in a minimal way means also allowing to use SEEK_CUR with non-zero offsets on text-mode files. That seems to be a fair compromise.
2018-01-31windows: Add Appveyor CI builds for windows mingw portstijn
Build and test 32bit and 64bit versions of the windows port using gcc from mingw-w64. Note a bunch of tests which rely on floating point math/printing have been disabled for now since they fail.
2018-01-31stm32/modmachine: Handle case of no MICROPY_PY_MACHINE_I2C.Peter D. Gray
2018-01-10drivers/sdcard: Avoid allocation on the heap.Ayke van Laethem
This commit fixes two things: 1. Do not allocate on the heap in readblocks() - unless the block size is bigger than 512 bytes. 2. Raise an error instead of returning 1 to indicate an error: the FAT block device layer does not check the return value. And other backends (e.g. esp32 blockdev) also raise an error instead of returning non-zero.
2018-01-10drivers/display/ssd1306: Fix super() call in SSD1306 driver.Jim Mussared
2017-12-29py/nlr: Fix missing trailing characters in comments in nlr.cstijn
2017-12-29py/nlr: Fix nlr functions for 64bit ports built with gcc on Windowsstijn
The number of registers used should be 10, not 12, to match the assembly code in nlrx64.c. With this change the 64bit mingw builds don't need to use the setjmp implementation, and this fixes miscellaneous crashes and assertion failures as reported in #1751 for instance. To avoid mistakes in the future where something gcc-related for Windows only gets fixed for one particular compiler/environment combination, make use of a MICROPY_NLR_OS_WINDOWS macro. To make sure everything nlr-related is now ok when built with gcc this has been verified with: - unix port built with gcc on Cygwin (i686-pc-cygwin-gcc and x86_64-pc-cygwin-gcc, version 6.4.0) - windows port built with mingw-w64's gcc from Cygwin (i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc, version 6.4.0) and MSYS2 (like the ones on Cygwin but version 7.2.0)
2017-12-29windows/mpconfigport: Enable some features, including the Python stackstijn
Add some features which are already enabled in the unix port and default to using the Python stack for scoped allocations: this can be more performant in cases the heap is heavily used because for example the memory needed for storing *args and **kwargs doesn't require scanning the heap to find a free block.
2017-12-29windows/mpconfigport: Provide off_t definition for MSVC portstijn
For MSVC off_t is defined in sys/types.h but according to the comment earlier in mpconfigport.h this cannot be included directly. So just make off_t the same as mp_off_t. This fixes the build for MSVC with MICROPY_STREAMS_POSIX_API enabled because stream.h uses off_t.
2017-12-29py/mpz: In mpz_as_str_inpl, convert always-false checks to assertions.Damien George
There are two checks that are always false so can be converted to (negated) assertions to save code space and execution time. They are: 1. The check of the str parameter, which is required to be non-NULL as per the original comment that it has enough space in it as calculated by mp_int_format_size. And for all uses of this function str is indeed non-NULL. 2. The check of the base parameter, which is already required to be between 2 and 16 (inclusive) via the assertion in mp_int_format_size.
2017-12-29py/mpz: Simplify handling of borrow and quo adjustment in mpn_div.Damien George
The motivation behind this patch is to remove unreachable code in mpn_div. This unreachable code was added some time ago in 9a21d2e070c9ee0ef2c003f3a668e635c6ae4401, when a loop in mpn_div was copied and adjusted to work when mpz_dig_t was exactly half of the size of mpz_dbl_dig_t (a common case). The loop was copied correctly but it wasn't noticed at the time that the final part of the calculation of num-quo*den could be optimised, and hence unreachable code was left for a case that never occurred. The observation for the optimisation is that the initial value of quo in mpn_div is either exact or too large (never too small), and therefore the subtraction of quo*den from num may subtract exactly enough or too much (but never too little). Using this observation the part of the algorithm that handles the borrow value can be simplified, and most importantly this eliminates the unreachable code. The new code has been tested with DIG_SIZE=3 and DIG_SIZE=4 by dividing all possible combinations of non-negative integers with between 0 and 3 (inclusive) mpz digits.
2017-12-29py/parse: Fix macro evaluation by avoiding empty __VA_ARGS__.Damien George
Empty __VA_ARGS__ are not allowed in the C preprocessor so adjust the rule arg offset calculation to not use them. Also, some compilers (eg MSVC) require an extra layer of macro expansion.
2017-12-29py/parse: Update debugging code to compile on 64-bit arch.Damien George
2017-12-29py/parse: Compress rule pointer table to table of offsets.Damien George
This is the sixth and final patch in a series of patches to the parser that aims to reduce code size by compressing the data corresponding to the rules of the grammar. Prior to this set of patches the rules were stored as rule_t structs with rule_id, act and arg members. And then there was a big table of pointers which allowed to lookup the address of a rule_t struct given the id of that rule. The changes that have been made are: - Breaking up of the rule_t struct into individual components, with each component in a separate array. - Removal of the rule_id part of the struct because it's not needed. - Put all the rule arg data in a big array. - Change the table of pointers to rules to a table of offsets within the array of rule arg data. The last point is what is done in this patch here and brings about the biggest decreases in code size, because an array of pointers is now an array of bytes. Code size changes for the six patches combined is: bare-arm: -644 minimal x86: -1856 unix x64: -5408 unix nanbox: -2080 stm32: -720 esp8266: -812 cc3200: -712 For the change in parser performance: it was measured on pyboard that these six patches combined gave an increase in script parse time of about 0.4%. This is due to the slightly more complicated way of looking up the data for a rule (since the 9th bit of the offset into the rule arg data table is calculated with an if statement). This is an acceptable increase in parse time considering that parsing is only done once per script (if compiled on the target).
2017-12-28py/parse: Remove rule_t struct because it's no longer needed.Damien George