This should be a little more efficient (since we anyway scan the input
packet for the interrupt char), and it should also fix any non-atomic read
issues with the buffer state being changed during an interrupt.
Throughput tests show that RX rate is unchanged by this patch.
The previous timeout value of 150ms could lead to data being lost (ie never
received by the host) in some rare cases, eg when the host is under load.
A value of 500ms is quite conservative and allows the host plenty of time
to read our data.
This follows the pattern of how all other headers are now included, and
makes it explicit where the header file comes from. This patch also
removes -I options from Makefile's that specify the mp-readline/timeutils/
netutils directories, which are no longer needed.
Such constants are MCU specific so shouldn't be specified in the board
config file (else it leads to too much duplication of code).
This patch also adds I2C timing values for the F767/F769 for 100k, 400k
and 1MHz I2C bus frequencies.
By default the SDIO (F4) or SDMMC1 (L4, F7) is used as the SD card
peripheral, but if a board config defines MICROPY_HW_SDMMC2_CK and other
pins then the SD card driver will use SDMMC2.
With the existing timeout of 100ms the transfer would end prematurely if
the baudrate was low and the number of bytes to send was high. This patch
fixes the problem by making the timeout proportional to the number of bytes
that are being transferred.
The C nearbyint function has exactly the semantics that Python's round()
requires, whereas C's round() requires extra steps to handle rounding of
numbers half way between integers. So using nearbyint reduces code size
and potentially eliminates any source of errors in the handling of half-way
numbers.
Also, bare-metal implementations of nearbyint can be more efficient than
round, so further code size is saved (and efficiency improved).
nearbyint is provided in the C99 standard so it should be available on all
supported platforms.
The -ansi flag is used for C dialect selection and it is equivalent to -std=c90.
Because it goes right before -std=gnu99 it is ignored as for conflicting flags
GCC always uses the last one.
We can actually handle interrupts during a thread switch (because we always
have a valid stack), but only if those interrupts don't access any of the
thread state (because the state may not correspond to the stack pointer).
So to be on the safe side we disable interrupts during the very short
period of the thread state+stack switch.
ExtInt, Timer and CAN IRQ callbacks are made to work with the scheduler.
They are still hard IRQs by default, but one can now call
micropython.schedule within the hard IRQ to schedule a soft callback.
The renames are:
HAL_Delay -> mp_hal_delay_ms
sys_tick_udelay -> mp_hal_delay_us
sys_tick_get_microseconds -> mp_hal_ticks_us
And mp_hal_ticks_ms is added to provide the full set of timing functions.
Also, a separate HAL_Delay function is added which differs slightly from
mp_hal_delay_ms and is intended for use only by the ST HAL functions.
Allows to iterate over the following without allocating on the heap:
- tuple
- list
- string, bytes
- bytearray, array
- dict (not dict.keys, dict.values, dict.items)
- set, frozenset
Allows to call the following without heap memory:
- all, any, min, max, sum
TODO: still need to allocate stack memory in bytecode for iter_buf.
This patch changes the threading implementation from simple round-robin
with busy waits on mutexs, to proper scheduling whereby threads that are
waiting on a mutex are only scheduled when the mutex becomes available.
The aapcs-linux ABI is not required, instead the default aapcs ABI is
enough. And using the default ABI means that the provided libgcc will now
link with the firmware without warnings about variable vs fixed enums.
Although the binary size increases by about 1k, RAM usage is slightly
decreased. And libgcc may prove useful in the future for things like
long-long division.
This new function controls what happens on a hard-fault:
- debugging disabled: board will do a reset
- debugging enabled: board will print registers and stack and flash LEDs
The default is disabled, ie to do a reset. This is different to previous
behaviour which flashed the LEDs and waited indefinitely.
This patch brings the _thread module to stmhal/pyboard. There is a very
simple round-robin thread scheduler, which is disabled if there is only
one thread (for efficiency when threading is not used).
The scheduler currently switches threads at a rate of 250Hz using the
systick timer and the pend-SV interrupt.
The GIL is disabled so one must be careful to use lock objects to prevent
concurrent access of objects.
The threading is disabled by default, one can enabled it with the config
option MICROPY_PY_THREAD to test it out.