From 3b5dec4b13033100e411421283b0554fd9f10d51 Mon Sep 17 00:00:00 2001 From: teemuatlut Date: Sat, 16 Jun 2018 00:07:53 +0300 Subject: [PATCH 1/2] Add new LPC include folder --- Marlin/src/HAL/HAL_LPC1768/{ => include}/HardwareSerial.cpp | 0 Marlin/src/HAL/HAL_LPC1768/{ => include}/HardwareSerial.h | 0 Marlin/src/HAL/HAL_LPC1768/{ => include}/SoftwareSerial.cpp | 2 +- Marlin/src/HAL/HAL_LPC1768/{ => include}/SoftwareSerial.h | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename Marlin/src/HAL/HAL_LPC1768/{ => include}/HardwareSerial.cpp (100%) rename Marlin/src/HAL/HAL_LPC1768/{ => include}/HardwareSerial.h (100%) rename Marlin/src/HAL/HAL_LPC1768/{ => include}/SoftwareSerial.cpp (99%) rename Marlin/src/HAL/HAL_LPC1768/{ => include}/SoftwareSerial.h (100%) diff --git a/Marlin/src/HAL/HAL_LPC1768/HardwareSerial.cpp b/Marlin/src/HAL/HAL_LPC1768/include/HardwareSerial.cpp similarity index 100% rename from Marlin/src/HAL/HAL_LPC1768/HardwareSerial.cpp rename to Marlin/src/HAL/HAL_LPC1768/include/HardwareSerial.cpp diff --git a/Marlin/src/HAL/HAL_LPC1768/HardwareSerial.h b/Marlin/src/HAL/HAL_LPC1768/include/HardwareSerial.h similarity index 100% rename from Marlin/src/HAL/HAL_LPC1768/HardwareSerial.h rename to Marlin/src/HAL/HAL_LPC1768/include/HardwareSerial.h diff --git a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp b/Marlin/src/HAL/HAL_LPC1768/include/SoftwareSerial.cpp similarity index 99% rename from Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp rename to Marlin/src/HAL/HAL_LPC1768/include/SoftwareSerial.cpp index 605102616..0baba4b2b 100644 --- a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/include/SoftwareSerial.cpp @@ -42,7 +42,7 @@ #include #include #include -#include "fastio.h" +#include "../fastio.h" #include "SoftwareSerial.h" void GpioEnableInt(uint32_t port, uint32_t pin, uint32_t mode); diff --git a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h b/Marlin/src/HAL/HAL_LPC1768/include/SoftwareSerial.h similarity index 100% rename from Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h rename to Marlin/src/HAL/HAL_LPC1768/include/SoftwareSerial.h From f38c81cdde22c82437a45cdcd18803ac534fdf28 Mon Sep 17 00:00:00 2001 From: teemuatlut Date: Fri, 6 Apr 2018 23:24:18 +0300 Subject: [PATCH 2/2] LPC176x: Expand HW SPI class --- Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp | 17 ++++++++++++++++- .../HAL/HAL_LPC1768/include/HardwareSerial.h | 4 ++-- Marlin/src/HAL/HAL_LPC1768/include/SPI.h | 7 +++++-- .../HAL/HAL_LPC1768/include/SoftwareSerial.cpp | 4 ++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp b/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp index 74543ee7d..c8fe029d3 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp @@ -150,7 +150,7 @@ } void spiInit(uint8_t spiRate) { - + SSP_Cmd(LPC_SSP0, DISABLE); // Disable SSP0 before changing rate // table to convert Marlin spiRates (0-5 plus default) into bit rates uint32_t Marlin_speed[7]; // CPSR is always 2 Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED @@ -242,6 +242,21 @@ void SPIClass::begin() { spiBegin(); } +void SPIClass::beginTransaction(SPISettings cfg) { + uint8_t spiRate; + switch(cfg.spiRate()) { + case 8000000: spiRate=0 ;break; + case 4000000: spiRate=1 ;break; + case 2000000: spiRate=2 ;break; + case 1000000: spiRate=3 ;break; + case 500000: spiRate=4 ;break; + case 250000: spiRate=5 ;break; + case 125000: spiRate=6 ;break; + default: spiRate=2; break; + } + spiInit(spiRate); +} + uint8_t SPIClass::transfer(uint8_t B) { return spiTransfer(B); } diff --git a/Marlin/src/HAL/HAL_LPC1768/include/HardwareSerial.h b/Marlin/src/HAL/HAL_LPC1768/include/HardwareSerial.h index 1f0be8958..f3bd2f6b4 100644 --- a/Marlin/src/HAL/HAL_LPC1768/include/HardwareSerial.h +++ b/Marlin/src/HAL/HAL_LPC1768/include/HardwareSerial.h @@ -23,9 +23,9 @@ #ifndef HARDWARE_SERIAL_H_ #define HARDWARE_SERIAL_H_ -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if ENABLED(EMERGENCY_PARSER) - #include "../../feature/emergency_parser.h" + #include "../../../feature/emergency_parser.h" #endif #include diff --git a/Marlin/src/HAL/HAL_LPC1768/include/SPI.h b/Marlin/src/HAL/HAL_LPC1768/include/SPI.h index 7de136633..bcd2d7b54 100644 --- a/Marlin/src/HAL/HAL_LPC1768/include/SPI.h +++ b/Marlin/src/HAL/HAL_LPC1768/include/SPI.h @@ -31,13 +31,16 @@ class SPISettings { public: - SPISettings(int a, int b, int c) {}; + SPISettings(uint32_t speed, int, int) : spi_speed(speed) {}; + uint32_t spiRate() { return spi_speed; } + private: + uint32_t spi_speed; }; class SPIClass { public: void begin(); - void beginTransaction(SPISettings foo) {}; + void beginTransaction(SPISettings); void endTransaction() {}; uint8_t transfer(uint8_t data); uint16_t transfer16(uint16_t data); diff --git a/Marlin/src/HAL/HAL_LPC1768/include/SoftwareSerial.cpp b/Marlin/src/HAL/HAL_LPC1768/include/SoftwareSerial.cpp index 0baba4b2b..607ea9dcb 100644 --- a/Marlin/src/HAL/HAL_LPC1768/include/SoftwareSerial.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/include/SoftwareSerial.cpp @@ -36,8 +36,8 @@ // Includes // //#include -#include "../../inc/MarlinConfig.h" -#include "../Delay.h" +#include "../../../inc/MarlinConfig.h" +#include "../../Delay.h" #include #include #include