|
|
@ -22,10 +22,11 @@
|
|
|
|
#pragma once
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* HAL/HAL_SPI.h
|
|
|
|
* HAL/shared/HAL_SPI.h
|
|
|
|
* Core Marlin definitions for SPI, implemented in the HALs
|
|
|
|
* Core Marlin definitions for SPI, implemented in the HALs
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Marduino.h"
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -53,18 +54,40 @@
|
|
|
|
#define SPI_SPEED_5 5 // Set SCK rate to 1/32 of max rate
|
|
|
|
#define SPI_SPEED_5 5 // Set SCK rate to 1/32 of max rate
|
|
|
|
#define SPI_SPEED_6 6 // Set SCK rate to 1/64 of max rate
|
|
|
|
#define SPI_SPEED_6 6 // Set SCK rate to 1/64 of max rate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Standard SPI functions
|
|
|
|
// Standard SPI functions
|
|
|
|
/** Initialize SPI bus */
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize SPI bus
|
|
|
|
void spiBegin(void);
|
|
|
|
void spiBegin(void);
|
|
|
|
/** Configure SPI for specified SPI speed */
|
|
|
|
|
|
|
|
|
|
|
|
// Configure SPI for specified SPI speed
|
|
|
|
void spiInit(uint8_t spiRate);
|
|
|
|
void spiInit(uint8_t spiRate);
|
|
|
|
/** Write single byte to SPI */
|
|
|
|
|
|
|
|
|
|
|
|
// Write single byte to SPI
|
|
|
|
void spiSend(uint8_t b);
|
|
|
|
void spiSend(uint8_t b);
|
|
|
|
/** Read single byte from SPI */
|
|
|
|
|
|
|
|
|
|
|
|
// Read single byte from SPI
|
|
|
|
uint8_t spiRec(void);
|
|
|
|
uint8_t spiRec(void);
|
|
|
|
/** Read from SPI into buffer */
|
|
|
|
|
|
|
|
|
|
|
|
// Read from SPI into buffer
|
|
|
|
void spiRead(uint8_t* buf, uint16_t nbyte);
|
|
|
|
void spiRead(uint8_t* buf, uint16_t nbyte);
|
|
|
|
/** Write token and then write from 512 byte buffer to SPI (for SD card) */
|
|
|
|
|
|
|
|
|
|
|
|
// Write token and then write from 512 byte buffer to SPI (for SD card)
|
|
|
|
void spiSendBlock(uint8_t token, const uint8_t* buf);
|
|
|
|
void spiSendBlock(uint8_t token, const uint8_t* buf);
|
|
|
|
/** Begin SPI transaction, set clock, bit order, data mode */
|
|
|
|
|
|
|
|
|
|
|
|
// Begin SPI transaction, set clock, bit order, data mode
|
|
|
|
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode);
|
|
|
|
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Extended SPI functions taking a channel number (Hardware SPI only)
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Write single byte to specified SPI channel
|
|
|
|
|
|
|
|
void spiSend(uint32_t chan, byte b);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Write buffer to specified SPI channel
|
|
|
|
|
|
|
|
void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Read single byte from specified SPI channel
|
|
|
|
|
|
|
|
uint8_t spiRec(uint32_t chan);
|
|
|
|