aboutsummaryrefslogtreecommitdiff
path: root/stmhal/spi.c
AgeCommit message (Collapse)Author
2017-09-06ports: Make new ports/ sub-directory and move all ports there.Damien George
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-08-30all: Convert remaining "mp_uint_t n_args" to "size_t n_args".Damien George
This is to have consistency across the whole repository.
2017-08-13all: Raise exceptions via mp_raise_XXXJavier Candeira
- Changed: ValueError, TypeError, NotImplementedError - OSError invocations unchanged, because the corresponding utility function takes ints, not strings like the long form invocation. - OverflowError, IndexError and RuntimeError etc. not changed for now until we decide whether to add new utility functions.
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-06-15stmhal: Make error messages more consistent across peripherals.Damien George
2017-05-06stmhal: Convert all module and method tables to use MP_ROM macros.Damien George
2017-03-29stmhal/spi: Increase SPI transfer timeout, proportional to num bytes.Damien George
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.
2017-03-28stmhal/spi: Clean and/or invalidate D-cache before SPI DMA transfers.Damien George
On MCUs with a cache (eg F7) this must be done or else the SPI data that is transferred is incorrect.
2017-01-04all: Consistently update signatures of .make_new and .call methods.Paul Sokolovsky
Otherwise, they serve reoccurring source of copy-paste mistakes and breaking nanbox build.
2016-12-08stmhal: Refactor to use extmod implementation of software SPI class.Damien George
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.
2016-11-11stmhal: Rename mp_hal_pin_set_af to _config_alt, to simplify alt config.Damien George
This way the caller doesn't need to initialise a big GPIO_InitTypeDef struct, and HAL_GPIO_Init is no longer called.
2016-10-18stmhal: Refactor pin usage to use mp_hal_pin API.Damien George
2016-10-04stmhal/spi: Enable use of fast software SPI.Damien George
2016-10-04extmod/machine_spi: Use delay_half, not baudrate, for internal timing.Damien George
The delay_half parameter must be specified by the port to set up the timing of the software SPI. This allows the port to adjust the timing value to better suit its timing characteristics, as well as provide a more accurate printing of the baudrate.
2016-10-04stmhal/spi: Use software SPI if no periph id given, even if pins given.Damien George
It's simpler to just default to always using software SPI if no specific peripheral id/name is given. To use hardware SPI users must specify a hardware peripheral id as the first parameter to the SPI constructor.
2016-10-03stmhal/spi: Make machine.SPI class conform to correct API.Damien George
Includes both software and hardware SPI implementations.
2016-10-03stmhal/spi: Simplify spi_transfer function to take only one buf len arg.Damien George
2016-10-03extmod/machine_spi: Simplify SPI xfer function to only take one buf len.Damien George
There is no need to take src_len and dest_len arguments. The case of reading-only with a single output byte (originally src_len=1, dest_len>1) is now handled by using the output buffer as the input buffer, and using memset to fill the output byte into this buffer. This simplifies the implementations of the spi_transfer protocol function.
2016-09-01stmhal/spi: Support new machine SPI methods in legacy SPI object.Damien George
2016-09-01stmhal/spi: Factor out SPI transfer code to a single function.Damien George
2016-07-30stmhal: Make SPI NSS pin definition optional.Dave Hylands
Some boards (like the GHI Electronics G30 Dev Board) don't use NSS at all and rather just use GPIO chip selects.
2016-05-05stmhal: L4: Adapt DMA to be able to support STM32L4 MCU series.Tobias Badertscher
The main thing is to change the DMA code in a way that the structure DMA_Stream_TypeDef (which is similar to DMA_Channel_TypeDef on stm32l4) is no longer used outside of dma.c, as this structure only exists for the F4 series. Therefore I introduced a new structure (dma_descr_t) which handles all DMA specific stuff for configuration. Further the periphery (spi, i2c, sdcard, dac) does not need to know the internals of the dma.
2016-03-07stmhal: Make spi use mp_hal_gpio_set_afDave Hylands
2016-01-11py: Change first arg of type.make_new from mp_obj_t to mp_obj_type_t*.Damien George
The first argument to the type.make_new method is naturally a uPy type, and all uses of this argument cast it directly to a pointer to a type structure. So it makes sense to just have it a pointer to a type from the very beginning (and a const pointer at that). This patch makes such a change, and removes all unnecessary casting to/from mp_obj_t.
2015-12-16stmhal: Extend SPI support to fully support all SPI devices on STM32F429.Tobias Badertscher
This includes SPI4, SPI5 and SPI6.
2015-12-12stmhal: For SPI config, use HW_SPIx_SCK instead of HW_ENABLE_SPIx.Damien George
Previously, SPI was configured by a board defining MICROPY_HW_ENABLE_SPIx to 0 or 1. Now, the board should define MICROPY_HW_SPIx_SCK, MISO, MOSI and NSS. This makes it the same as how I2C is configured.
2015-12-02stmhal: Put all DMA channel & stream definitions in dma.hDave Hylands
2015-10-31all: Add py/mphal.h and use it in all ports.Damien George
py/mphal.h contains declarations for generic mp_hal_XXX functions, such as stdio and delay/ticks, which ports should provide definitions for. A port will also provide mphalport.h with further HAL declarations.
2015-09-15stmhal: Use polling, not DMA, for 1 byte SPI transfers.Damien George
There is an issue sending 1 byte on the SPI bus using DMA, but it only occurs when the transmit is done for the first time after initialising the SPI and DMA peripherals. All other cases (sending 2 or more bytes, doing send_recv, doing recv first) work okay. We sidestep this issue by using polling (not DMA) for all 1 byte transfers. This is fine because a 1 byte transfer can't be interrupted and doesn't need the benefits of DMA (and using polling for this case is more efficient). Resolves #1456.
2015-08-05stmhal: Fix hardfault when configured as a SPI slaveDave Hylands
2015-08-05stmhal: Enable SPI support for F7 MCUs.Dave Hylands
2015-08-03stmhal: Factor GPIO clock enable logic into mp_hal_gpio_clock_enable.Damien George
Extracted GPIO clock enable logic into mp_hal_gpio_clock_enable and called from anyplace which might need to use GPIO functions on ports other than A-D. Thanks to Dave Hylands for the patch.
2015-07-30stmhal: Add STM32F7DISC and associated changes.Dave Hylands
2015-06-24stmhal/dma.c: Modify dma_init() to accept init struct as an argumentblmorris
This removes hard-coded DMA init params from dma_init(), instead defining these parameters in a DMA_InitTypeDef struct that gets passed as an argument to dma_init() This makes dma_init more generic so it can be used for I2S and SD Card, which require different initialization parameters.
2015-06-10stmhal: Factor out DMA initialisation code from spi.c.Damien George
This is so that the DMA can be shared by multiple peripherals.
2015-06-03stmhal: Fix slow SPI DMA transfers by removing wfi from DMA wait loop.Damien George
Addresses issue #1268.
2015-05-28stmhal: Fix off-by-one error when checking for valid I2C and SPI bus.Damien George
2015-05-27stmhal: Allow to name SPI busses, and give them names for pyboard.Damien George
2015-04-16py: Overhaul and simplify printf/pfenv mechanism.Damien George
Previous to this patch the printing mechanism was a bit of a tangled mess. This patch attempts to consolidate printing into one interface. All (non-debug) printing now uses the mp_print* family of functions, mainly mp_printf. All these functions take an mp_print_t structure as their first argument, and this structure defines the printing backend through the "print_strn" function of said structure. Printing from the uPy core can reach the platform-defined print code via two paths: either through mp_sys_stdout_obj (defined pert port) in conjunction with mp_stream_write; or through the mp_plat_print structure which uses the MP_PLAT_PRINT_STRN macro to define how string are printed on the platform. The former is only used when MICROPY_PY_IO is defined. With this new scheme printing is generally more efficient (less layers to go through, less arguments to pass), and, given an mp_print_t* structure, one can call mp_print_str for efficiency instead of mp_printf("%s", ...). Code size is also reduced by around 200 bytes on Thumb2 archs.
2015-01-21py: Remove mp_obj_str_builder and use vstr instead.Damien George
With this patch str/bytes construction is streamlined. Always use a vstr to build a str/bytes object. If the size is known beforehand then use vstr_init_len to allocate only required memory. Otherwise use vstr_init and the vstr will grow as needed. Then use mp_obj_new_str_from_vstr to create a str/bytes object using the vstr memory. Saves code ROM: 68 bytes on stmhal, 108 bytes on bare-arm, and 336 bytes on unix x64.
2015-01-21stmhal: Add support for FEZ Cerb40 II board from ghielectronics.com.Dave Hylands
2015-01-01stmhal: Prefix includes with py/; remove need for -I../py.Damien George
2014-12-08stmhal: Allow SPI.init to specify prescaler directly; improve SPI docs.Damien George
2014-12-06stmhal: Make SPI bus use DMA for transfers.Damien George
Uses DMA if interrupts are enabled, polling if they are disabled.
2014-10-26stmhal: Change SPI phase spec to 0,1 to match standard conventions.Damien George
Was 1 or 2, now 0 or 1 (respectively). 0 means sample MISO on first edge, 1 means sample on second edge. Addresses issue #936.
2014-10-23stmhal: Use OSError with POSIX error code for HAL errors.Damien George
Addresses issue #921.
2014-09-30stmhal: For spi_init, add argument to select if NSS pin is enabled.Damien George
Most of the time you don't use the NSS pin of the SPI bus, and so it shouldn't be enabled by default (this gave some bugs in the past).
2014-09-26stmhal: Initial implementation of cc3k module and driver.Damien George
Pulled in and modified work done by mux/iabdalkader on cc3k driver, from iabdalkader-cc3k-update branch. That branch was terribly messy and had too many conflicts to merge neatly.
2014-08-30Change some parts of the core API to use mp_uint_t instead of uint/int.Damien George
Addressing issue #50, still some way to go yet.
2014-07-03Rename machine_(u)int_t to mp_(u)int_t.Damien George
See discussion in issue #50.