Skip to content

Commit

Permalink
Fix bug reported in github issue #8 chip -> chip_n
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpolidoro committed May 28, 2024
1 parent a009794 commit 69b244e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* Library Information
- Name :: AD57X4R
- Version :: 5.0.0
- Version :: 5.0.1
- License :: BSD
- URL :: https://github.com/janelia-arduino/AD57X4R
- Author :: Peter Polidoro
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=AD57X4R
version=5.0.0
version=5.0.1
author=Peter Polidoro <[email protected]>
maintainer=Peter Polidoro <[email protected]>
sentence=Provides an SPI based interface to the AD5724R, AD5734R, and the AD5754R Quad 12-/14-/16-Bit Unipolar/Bipolar Voltage Output DACs.
Expand Down
8 changes: 4 additions & 4 deletions src/AD57X4R/AD57X4R.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ void AD57X4R::writeMosiDatagramToChip(int chip,
spiBeginTransaction();
for (int chip_n=(chip_count_ - 1); chip_n>=0; --chip_n)
{
Datagram mosi_datagram_n = mosi_datagram_array[chip];
Datagram mosi_datagram_n = mosi_datagram_array[chip_n];
for (int byte_n=(DATAGRAM_SIZE - 1); byte_n>=0; --byte_n)
{
uint8_t byte_write = (mosi_datagram_n.bytes >> (8*byte_n)) & 0xff;
Expand All @@ -533,12 +533,12 @@ AD57X4R::Datagram AD57X4R::readMisoDatagramFromChip(int chip)
spiBeginTransaction();
for (int chip_n=(chip_count_ - 1); chip_n>=0; --chip_n)
{
miso_datagram_array[chip].bytes = 0;
miso_datagram_array[chip_n].bytes = 0;
for (int byte_n=(DATAGRAM_SIZE - 1); byte_n>=0; --byte_n)
{
uint8_t byte_write = (mosi_datagram_array[chip].bytes >> (8*byte_n)) & 0xff;
uint8_t byte_write = (mosi_datagram_array[chip_n].bytes >> (8*byte_n)) & 0xff;
uint8_t byte_read = SPI.transfer(byte_write);
miso_datagram_array[chip].bytes |= ((uint32_t)byte_read) << (8*byte_n);
miso_datagram_array[chip_n].bytes |= ((uint32_t)byte_read) << (8*byte_n);
}
}
spiEndTransaction();
Expand Down

0 comments on commit 69b244e

Please sign in to comment.