From 0c873577dd0f2953cafc7516d3bd4dcb26559f7e Mon Sep 17 00:00:00 2001 From: Markus Tavenrath Date: Sat, 30 Apr 2016 18:18:08 +0200 Subject: [PATCH] Fix issue #109, SPI needs to read register SPI_USER(SPI_NO) instead of using the value SPI_USER(SPI_NO) as base value for SPI_USER in SPI::transfer and SPI::transfer32 modified: sming/core/SPI.cpp modified: sming/core/SPISettings.cpp modified: sming/core/SPISettings.h --- sming/sming/core/SPI.cpp | 5 ++--- sming/sming/core/SPISettings.cpp | 2 -- sming/sming/core/SPISettings.h | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/sming/sming/core/SPI.cpp b/sming/sming/core/SPI.cpp index b2c2575..0618c75 100644 --- a/sming/sming/core/SPI.cpp +++ b/sming/sming/core/SPI.cpp @@ -125,7 +125,7 @@ void SPIClass::endTransaction() { uint32 SPIClass::transfer32(uint32 data, uint8 bits) { // restore inital SPI_USER register - uint32_t regvalue = _SPISettings._user_regvalue; + uint32_t regvalue = READ_PERI_REG(SPI_USER(SPI_NO)); while(READ_PERI_REG(SPI_CMD(SPI_NO))&SPI_USR); @@ -193,7 +193,7 @@ void SPIClass::transfer(uint8 *buffer, size_t numberBytes) { num_bits = bufLenght * 8; // restore inital SPI_USER register - uint32_t regvalue = _SPISettings._user_regvalue; + uint32_t regvalue = READ_PERI_REG(SPI_USER(SPI_NO)); while(READ_PERI_REG(SPI_CMD(SPI_NO))&SPI_USR); @@ -261,7 +261,6 @@ void SPIClass::prepare(SPISettings mySettings) { #endif _SPISettings = mySettings; - mySettings._user_regvalue = SPI_USER(SPI_NO); _init = true; }; diff --git a/sming/sming/core/SPISettings.cpp b/sming/sming/core/SPISettings.cpp index be6de2b..4f0e9f7 100644 --- a/sming/sming/core/SPISettings.cpp +++ b/sming/sming/core/SPISettings.cpp @@ -21,7 +21,6 @@ SPISettings::SPISettings() { _speed = 4000000; _byteOrder = MSBFIRST; _dataMode = SPI_MODE0; - _user_regvalue = 0; } /* @@ -38,7 +37,6 @@ SPISettings::SPISettings(int speed, uint8 byteOrder, uint8 dataMode) { _speed = speed; _byteOrder = byteOrder; _dataMode = dataMode; - _user_regvalue = 0; } diff --git a/sming/sming/core/SPISettings.h b/sming/sming/core/SPISettings.h index 1c2780f..f138e5f 100644 --- a/sming/sming/core/SPISettings.h +++ b/sming/sming/core/SPISettings.h @@ -67,7 +67,6 @@ class SPISettings { int _speed; uint8 _byteOrder; uint8 _dataMode; - uint32_t _user_regvalue; // overload operator to check wheter the settings are equal bool operator==(const SPISettings &other) const;