This repository has been archived on 2022-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
Marlin-Artillery-M600/Marlin/src/HAL/HAL_LPC1768/SoftwareSPI.h

51 lines
1.7 KiB
C
Raw Normal View History

/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _SOFTWARE_SPI_H_
#define _SOFTWARE_SPI_H_
#include "pinmapping.h"
// --------------------------------------------------------------------------
// software SPI
// --------------------------------------------------------------------------
/**
* This software SPI runs at multiple rates. The SD software provides an index
* (spiRate) of 0-6. The mapping is:
* 0 - about 5 MHz peak (6 MHz on LPC1769)
* 1-2 - about 2 MHz peak
* 3 - about 1 MHz peak
* 4 - about 500 kHz peak
* 5 - about 250 kHz peak
* 6 - about 125 kHz peak
*/
void swSpiBegin(pin_t sck_pin, pin_t miso_pin, pin_t mosi_pin);
// Returns the spi_speed value to be passed to swSpiTransfer
uint8_t swSpiInit(uint8_t spiRate, pin_t sck_pin, pin_t mosi_pin);
uint8_t swSpiTransfer(uint8_t b, uint8_t spi_speed, pin_t sck_pin, pin_t miso_pin, pin_t mosi_pin);
#endif // _SOFTWARE_SPI_H_