Skip to content

Commit

Permalink
Fix issue #709. Keep SPI_WR_BYTE_ORDER and SPI_RD_BYTE_ORDER when upd…
Browse files Browse the repository at this point in the history
…ating the SPI_USER reg
  • Loading branch information
Phaeodaria committed Apr 20, 2016
1 parent 444ffd6 commit cc303fd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Sming/SmingCore/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,11 @@ void SPIClass::endTransaction() {
*/
uint32 SPIClass::transfer32(uint32 data, uint8 bits)
{
uint32_t regvalue = 0;
uint32_t regvalue = READ_PERI_REG(SPI_USER(SPI_NO)) & (SPI_WR_BYTE_ORDER | SPI_RD_BYTE_ORDER);

while(READ_PERI_REG(SPI_CMD(SPI_NO))&SPI_USR);

regvalue |= SPI_USR_MOSI | SPI_DOUTDIN | SPI_CK_I_EDGE;
regvalue &= ~(BIT2 | SPI_USR_ADDR | SPI_USR_DUMMY | SPI_USR_MISO | SPI_USR_COMMAND); //clear bit 2 see example IoT_Demo
WRITE_PERI_REG(SPI_USER(SPI_NO), regvalue);


Expand Down Expand Up @@ -183,12 +182,11 @@ void SPIClass::transfer(uint8 *buffer, size_t numberBytes) {
// compute the number of bits to clock
num_bits = bufLenght * 8;

uint32_t regvalue = 0;
uint32_t regvalue = READ_PERI_REG(SPI_USER(SPI_NO)) & (SPI_WR_BYTE_ORDER | SPI_RD_BYTE_ORDER);

while(READ_PERI_REG(SPI_CMD(SPI_NO))&SPI_USR);

regvalue |= SPI_USR_MOSI | SPI_DOUTDIN | SPI_CK_I_EDGE;
regvalue &= ~(BIT2 | SPI_USR_ADDR | SPI_USR_DUMMY | SPI_USR_MISO | SPI_USR_COMMAND); //clear bit 2 see example IoT_Demo
WRITE_PERI_REG(SPI_USER(SPI_NO), regvalue);


Expand Down

0 comments on commit cc303fd

Please sign in to comment.