From 8d036e94bf7a47805de89bc98c36333d29974aca Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 4 Sep 2019 23:23:31 -0500 Subject: [PATCH] Combine channel-based SPI headers --- Marlin/src/HAL/HAL_DUE/HAL.h | 11 -------- Marlin/src/HAL/HAL_LINUX/HAL.h | 8 ------ Marlin/src/HAL/HAL_LPC1768/HAL.h | 11 -------- Marlin/src/HAL/HAL_STM32/HAL.h | 11 -------- Marlin/src/HAL/HAL_STM32F1/HAL.h | 11 -------- Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h | 11 -------- Marlin/src/HAL/HAL_TEENSY31_32/HAL.h | 11 -------- Marlin/src/HAL/HAL_TEENSY35_36/HAL.h | 8 ------ Marlin/src/HAL/shared/HAL_SPI.h | 39 ++++++++++++++++++++++------ 9 files changed, 31 insertions(+), 90 deletions(-) diff --git a/Marlin/src/HAL/HAL_DUE/HAL.h b/Marlin/src/HAL/HAL_DUE/HAL.h index 514c7a2f72..feabd64fb0 100644 --- a/Marlin/src/HAL/HAL_DUE/HAL.h +++ b/Marlin/src/HAL/HAL_DUE/HAL.h @@ -94,17 +94,6 @@ void sei(void); // Enable interrupts void HAL_clear_reset_source(void); // clear reset reason uint8_t HAL_get_reset_source(void); // get reset reason -// -// SPI: Extended 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); - // // EEPROM // diff --git a/Marlin/src/HAL/HAL_LINUX/HAL.h b/Marlin/src/HAL/HAL_LINUX/HAL.h index 4f872371ef..9f83c9ccc3 100644 --- a/Marlin/src/HAL/HAL_LINUX/HAL.h +++ b/Marlin/src/HAL/HAL_LINUX/HAL.h @@ -86,14 +86,6 @@ inline void HAL_init(void) { } int freeMemory(void); #pragma GCC diagnostic pop -// SPI: Extended functions which take 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); - // ADC #define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin) #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL.h b/Marlin/src/HAL/HAL_LPC1768/HAL.h index 00b01adf6a..cadf35e1ca 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL.h @@ -116,17 +116,6 @@ extern "C" volatile uint32_t _millis; int freeMemory(void); #pragma GCC diagnostic pop -// -// SPI: Extended 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); - // // ADC API // diff --git a/Marlin/src/HAL/HAL_STM32/HAL.h b/Marlin/src/HAL/HAL_STM32/HAL.h index f48ec41783..59fe0d89db 100644 --- a/Marlin/src/HAL/HAL_STM32/HAL.h +++ b/Marlin/src/HAL/HAL_STM32/HAL.h @@ -169,17 +169,6 @@ static inline int freeMemory() { #pragma GCC diagnostic pop -// -// SPI: Extended functions which take 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); - // // EEPROM // diff --git a/Marlin/src/HAL/HAL_STM32F1/HAL.h b/Marlin/src/HAL/HAL_STM32F1/HAL.h index a8de9a16da..08c79bc6de 100644 --- a/Marlin/src/HAL/HAL_STM32F1/HAL.h +++ b/Marlin/src/HAL/HAL_STM32F1/HAL.h @@ -208,17 +208,6 @@ static int freeMemory() { #pragma GCC diagnostic pop -// -// SPI: Extended functions which take 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); - // // EEPROM // diff --git a/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h b/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h index 554f8e1b32..0fcffc69e9 100644 --- a/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h +++ b/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h @@ -186,17 +186,6 @@ static inline int freeMemory(void) { #pragma GCC diagnostic pop -// -// SPI: Extended functions which take 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); - // // EEPROM // diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h b/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h index 8c3c355e9c..99e161cf04 100644 --- a/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h @@ -104,17 +104,6 @@ extern "C" { } #pragma GCC diagnostic pop -// SPI: Extended functions which take 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); - // ADC void HAL_adc_init(); diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h b/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h index ff83bd6491..de86198b33 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h @@ -110,14 +110,6 @@ extern "C" { } #pragma GCC diagnostic pop -// SPI: Extended functions which take 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); - // ADC void HAL_adc_init(); diff --git a/Marlin/src/HAL/shared/HAL_SPI.h b/Marlin/src/HAL/shared/HAL_SPI.h index 16a58f673a..aa37048d34 100644 --- a/Marlin/src/HAL/shared/HAL_SPI.h +++ b/Marlin/src/HAL/shared/HAL_SPI.h @@ -22,10 +22,11 @@ #pragma once /** - * HAL/HAL_SPI.h + * HAL/shared/HAL_SPI.h * Core Marlin definitions for SPI, implemented in the HALs */ +#include "Marduino.h" #include /** @@ -53,18 +54,40 @@ #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 +// // Standard SPI functions -/** Initialize SPI bus */ +// + +// Initialize SPI bus void spiBegin(void); -/** Configure SPI for specified SPI speed */ + +// Configure SPI for specified SPI speed void spiInit(uint8_t spiRate); -/** Write single byte to SPI */ + +// Write single byte to SPI void spiSend(uint8_t b); -/** Read single byte from SPI */ + +// Read single byte from SPI uint8_t spiRec(void); -/** Read from SPI into buffer */ + +// Read from SPI into buffer 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); -/** 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); + +// +// 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);