They are the same as the existing raw constants (namely 0, 1, 2) but we
want to explicitly show that one can use the HAL's constants if necessary
(eg the mpconfigboard.h files do use the HAL's constants to define the
pull state of certain configurable pins).
Without this the timer will have random values for its State and Lock
entries. The object can then be in a locked state leading to some HAL
functions returning immediately with an error code (which is unchecked).
This patch fixes such a bug which did manifest itself as PWM not working
correctly for LEDs.
mp_kbd_exception is now considered the standard variable name to hold the
singleton KeyboardInterrupt exception.
This patch also moves the creation of this object from pyb_usb_init() to
main().
This is a pure refactoring (and simplification) of code so that stmhal
uses the software SPI class provided in extmod, for the machine.SPI
implementation.
So long as a port defines relevant mp_hal_pin_xxx functions (and delay) it
can make use of this software SPI class without the need for additional
code.
Previous to this patch trying to construct, but not init, a UART that
didn't exist on the target board would actually succeed. Only when
initialising the UART would it then raise an exception that the UART does
not exist.
This patch adds an explicit check that the constructed UART does in fact
exist for the given board.
This follows the pattern of other peripherals (I2C, SPI) to specify the
pins using pin objects instead of a pair of GPIO port and pin number. It
makes it easier to customise the UART pins for a particular board.
The constants MP_IOCTL_POLL_xxx, which were stmhal-specific, are moved
from stmhal/pybioctl.h (now deleted) to py/stream.h. And they are renamed
to MP_STREAM_POLL_xxx to be consistent with other such constants.
All uses of these constants have been updated.
Add 2 macros in mphalport.h that clean and invalidate data caches only on
STM32F7 MCUs. They are needed to ensure the cache coherency before/after
DMA transferts.
* MP_HAL_CLEANINVALIDATE_DCACHE cleans and invalidate the data cache. It
must be called before starting a DMA transfer from the peripheral to the
RAM memory.
* MP_HAL_CLEAN_DCACHE cleans the data cache. It must be called before
starting a DMA transfert from the RAM memory to the peripheral.
These macros are called in sdcard.c, before reading from and writing to
the SDCard, when DMA is used.
The temperature sensor on F4 and F7 MCUs is mostly, but not always, on
channel 16. To retain compatibility across all these MCUs this patch
maps the user-facing channel 16 to the internal temperature sensor.
The "mask" parameter is used to select which pins the ADCAll constructor
will initialise to analog mode. It defaults to all pins (0xffffffff),
which is backwards compatible with previous behaviour.
These were inadvertently removed with a recent upgrade to CMSIS, where
those registers were no longer defined in the CMSIS headers, and hence
no longer extracted.
This allows one to construct an I2C object using ids that are specific
to the stmhal port, eg machine.I2C('X'). Right now the implementation
of I2C uses software I2C but the idea is to just change the C-level I2C
protocol functions to hardware implementations later on.
stdio.h was included in all HAL files only to provide
definition of NULL symbol
"stdio.h" includes "types.h" which contains some conflicting definitions
with "drivers/cc3000/inc/socket.h"
HAL Driver before v1.4.2 had a bug which caused clearing all pending
flags in MSR, TSR, RF0R and RF1R instead of only the requested one.
This is why micropython got away without explicitly clearing flags
in IRQ handler.
Current version of HAL drivers optimize IRQ handler by using precalculated
DMA register address and stream bitshift instead of calculating it on every interrupt.
Since we skip call to `HAL_DMA_Init` on reused DMA, fields StreamBaseAddress and StreamIndex
of DMA handle are not initialized and thus leads to SegFault in `DMA_IRQHandler`.
HAL_DMA_Init is a big routine and we do not need to call it on each use of DMA
(ex.: series of I2C operations) and DMA_CalcBaseAndBitshift is really small and
releasing it increases code size by only 8 bytes.
If a port defines MICROPY_READER_POSIX or MICROPY_READER_FATFS then
lexer.c now provides an implementation of mp_lexer_new_from_file using
the mp_reader_new_file function.
Implementations of persistent-code reader are provided for POSIX systems
and systems using FatFS. Macros to use these are MICROPY_READER_POSIX and
MICROPY_READER_FATFS respectively. If an alternative implementation is
needed then a port can define the function mp_reader_new_file.
Its addition was due to an early exploration on how to add CPython-like
stream interface. It's clear that it's not needed and just takes up
bytes in all ports.
If an I2C send/recv fails then the peripheral is now checked to see if
it's in a "stuck" state waiting for the stop bit, and if so then it is
reset so that the next I2C transaction can proceed.
This patch also de-inits the I2C peripheral in the init() method, before
init'ing it again.
New keyword option in constructor and init() method is "dma=<bool>".
DMA is now disabled by default for I2C transfers because it currently does
not handle I2C bus errors very well (eg if slave device doesn't ACK or
NACK correctly during a transfer).
The DMA state is always HAL_DMA_STATE_RESET because of the memset clearing
all the data, so prior to this patch HAL_DMA_DeInit was never called. Now
it is always called to make sure the DMA is properly reset.
Now, to use frozen bytecode all a port needs to do is define
FROZEN_MPY_DIR to the directory containing the .py files to freeze, and
define MICROPY_MODULE_FROZEN_MPY and MICROPY_QSTR_EXTRA_POOL.
In order to have more fine-grained control over how builtin functions are
constructed, the MP_DECLARE_CONST_FUN_OBJ macros are made more specific,
with suffix of _0, _1, _2, _3, _VAR, _VAR_BETEEN or _KW. These names now
match the MP_DEFINE_CONST_FUN_OBJ macros.