Skip to content
Snippets Groups Projects
Select Git revision
  • 71be1ddeb128e6068d2f1df605ec9c8c10f67091
  • master default protected
  • schneider/ir
  • rahix/user-space-ctx
  • schneider/iaq-python
  • schneider/ble-mini-demo
  • schneider/ble-ecg-stream-visu
  • schneider/mp-exception-print
  • schneider/sleep-display
  • schneider/deepsleep4
  • schneider/deepsleep2
  • schneider/deepsleep
  • schneider/ble-central
  • rahix/bluetooth-app-favorite
  • schneider/v1.17-changelog
  • schneider/ancs
  • schneider/png
  • schneider/freertos-list-debug
  • schneider/212-reset-hardware-when-entering-repl
  • schneider/bonding-fail-if-full
  • schneider/ble-fixes-2020-3
  • v1.18
  • v1.17
  • v1.16
  • v1.15
  • v1.14
  • v1.13
  • v1.12
  • v1.11
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
41 results

group__RTC__TRIM.html

Blame
  • spi.c 25.53 KiB
    /*
     * This file is part of the Micro Python project, http://micropython.org/
     *
     * The MIT License (MIT)
     *
     * Copyright (c) 2013, 2014 Damien P. George
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy
     * of this software and associated documentation files (the "Software"), to deal
     * in the Software without restriction, including without limitation the rights
     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     * copies of the Software, and to permit persons to whom the Software is
     * furnished to do so, subject to the following conditions:
     *
     * The above copyright notice and this permission notice shall be included in
     * all copies or substantial portions of the Software.
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     * THE SOFTWARE.
     */
    
    #include <stdio.h>
    #include <string.h>
    
    #include "py/nlr.h"
    #include "py/runtime.h"
    #include "irq.h"
    #include "pin.h"
    #include "genhdr/pins.h"
    #include "bufhelper.h"
    #include "dma.h"
    #include "spi.h"
    #include MICROPY_HAL_H
    
    /// \moduleref pyb
    /// \class SPI - a master-driven serial protocol
    ///
    /// SPI is a serial protocol that is driven by a master.  At the physical level
    /// there are 3 lines: SCK, MOSI, MISO.
    ///
    /// See usage model of I2C; SPI is very similar.  Main difference is
    /// parameters to init the SPI bus:
    ///
    ///     from pyb import SPI
    ///     spi = SPI(1, SPI.MASTER, baudrate=600000, polarity=1, phase=0, crc=0x7)
    ///
    /// Only required parameter is mode, SPI.MASTER or SPI.SLAVE.  Polarity can be
    /// 0 or 1, and is the level the idle clock line sits at.  Phase can be 0 or 1
    /// to sample data on the first or second clock edge respectively.  Crc can be
    /// None for no CRC, or a polynomial specifier.
    ///
    /// Additional method for SPI:
    ///
    ///     data = spi.send_recv(b'1234')        # send 4 bytes and receive 4 bytes
    ///     buf = bytearray(4)
    ///     spi.send_recv(b'1234', buf)          # send 4 bytes and receive 4 into buf
    ///     spi.send_recv(buf, buf)              # send/recv 4 bytes from/to buf
    
    // Possible DMA configurations for SPI busses:
    // SPI1_TX: DMA2_Stream3.CHANNEL_3 or DMA2_Stream5.CHANNEL_3
    // SPI1_RX: DMA2_Stream0.CHANNEL_3 or DMA2_Stream2.CHANNEL_3
    // SPI2_TX: DMA1_Stream4.CHANNEL_0
    // SPI2_RX: DMA1_Stream3.CHANNEL_0
    // SPI3_TX: DMA1_Stream5.CHANNEL_0 or DMA1_Stream7.CHANNEL_0
    // SPI3_RX: DMA1_Stream0.CHANNEL_0 or DMA1_Stream2.CHANNEL_0