Skip to content

Commit

Permalink
Fix issue #109, SPI needs to read register SPI_USER(SPI_NO) instead o…
Browse files Browse the repository at this point in the history
…f 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
  • Loading branch information
mtavenrath committed May 18, 2016
1 parent fc50665 commit 0c87357
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
5 changes: 2 additions & 3 deletions sming/sming/core/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -261,7 +261,6 @@ void SPIClass::prepare(SPISettings mySettings) {
#endif

_SPISettings = mySettings;
mySettings._user_regvalue = SPI_USER(SPI_NO);
_init = true;
};

Expand Down
2 changes: 0 additions & 2 deletions sming/sming/core/SPISettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ SPISettings::SPISettings() {
_speed = 4000000;
_byteOrder = MSBFIRST;
_dataMode = SPI_MODE0;
_user_regvalue = 0;
}

/*
Expand All @@ -38,7 +37,6 @@ SPISettings::SPISettings(int speed, uint8 byteOrder, uint8 dataMode) {
_speed = speed;
_byteOrder = byteOrder;
_dataMode = dataMode;
_user_regvalue = 0;
}


Expand Down
1 change: 0 additions & 1 deletion sming/sming/core/SPISettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0c87357

Please sign in to comment.