Commit Graph

10 Commits

Author SHA1 Message Date
Damien George 6e91ab5806 stm32/spi: Further updates to use newer versions of HAL names. 2018-02-13 15:53:08 +11:00
Damien George 3eb0694b97 stm32: Update HAL macro and constant names to use newer versions.
Newer versions of the HAL use names which are cleaner and more
self-consistent amongst the HAL itself.  This patch switches to use those
names in most places so it is easier to update the HAL in the future.
2018-02-13 15:37:35 +11:00
Damien George 20f5de9b39 stm32/spi: Accept machine.SPI object in spi_from_mp_obj() function.
Also, change ValueError to TypeError if the argument to this function is
not of an SPI type.
2018-02-05 14:32:56 +11:00
Damien George 4ad3ede21a stm32/spi: Provide better separation between SPI driver and uPy objs.
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-05 14:30:32 +11:00
Damien George 5ddd1488bd stm32/spi: Allow SPI peripheral state to persist across a soft reset.
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-02 19:01:11 +11:00
Damien George 762db9ad2f stm32/spi: Add support for a board naming SPI peripherals 4, 5 and 6. 2018-02-02 17:44:05 +11:00
Damien George c0496fd44d stm32/spi: Make SPI DMA wait routine more power efficient by using WFI.
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-02-01 11:45:29 +11:00
Peter D. Gray dfe8980acf stm32/spi: If MICROPY_HW_SPIn_MISO undefined, do not claim pin on init.
This permits output-only SPI use.
2017-12-28 18:00:20 +11:00
Damien George a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00
Damien George 01dd7804b8 ports: Make new ports/ sub-directory and move all ports there.
This is to keep the top-level directory clean, to make it clear what is
core and what is a port, and to allow the repository to grow with new ports
in a sustainable way.
2017-09-06 13:40:51 +10:00