45 lines
2.0 KiB
C
45 lines
2.0 KiB
C
/*
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
|
*
|
|
* The MIT License (MIT)
|
|
*
|
|
* Copyright (c) 2013, 2014 Damien P. George
|
|
* Copyright (c) 2021, 2022 Renesas Electronics Corporation
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef MICROPY_INCLUDED_RA_SPI_H
|
|
#define MICROPY_INCLUDED_RA_SPI_H
|
|
|
|
// A transfer of "len" bytes should take len*8*1000/baudrate milliseconds.
|
|
// To simplify the calculation we assume the baudrate is never less than 8kHz
|
|
// and use that value for the baudrate in the formula, plus a small constant.
|
|
#define SPI_TRANSFER_TIMEOUT(len) ((len) + 100)
|
|
|
|
void spi_init0(void);
|
|
void spi_init(uint32_t ch);
|
|
void spi_deinit(uint32_t ch);
|
|
int spi_find_index(mp_obj_t id);
|
|
void spi_set_params(uint32_t ch, int32_t baudrate,
|
|
int32_t polarity, int32_t phase, int32_t bits, int32_t firstbit);
|
|
void spi_transfer(uint32_t ch, uint32_t bits, size_t len, const uint8_t *src, uint8_t *dest, uint32_t timeout);
|
|
|
|
#endif // MICROPY_INCLUDED_RA_SPI_H
|