Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 3:e4cec33fe9eb, committed 2020-01-24
- Comitter:
- lsh2205
- Date:
- Fri Jan 24 00:26:29 2020 +0000
- Parent:
- 2:2193b220248b
- Commit message:
- 1
Changed in this revision
| LS7366.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LS7366.cpp Wed Oct 07 17:31:26 2015 +0000
+++ b/LS7366.cpp Fri Jan 24 00:26:29 2020 +0000
@@ -27,7 +27,7 @@
//Constructor
LS7366::LS7366(SPI& spi, PinName cs) : _spi(spi), _cs(cs) {
- this->_cs = 1; // Initialize chip select as off (high)
+ this->_cs = 0; // Initialize chip select as off (high)
this->_init();
}
@@ -50,13 +50,13 @@
this->_spi.format(8, 0);
this->_spi.frequency(2000000);
- this->_cs = 0;
+ this->_cs = 1;
wait_us(1);
this->LS7366_cmd(LOAD,OTR);//cmd = 0xe8, LOAD to OTR
- this->_cs = 1;
+ this->_cs = 0;
wait_us(1);
- this->_cs = 0;
+ this->_cs = 1;
wait_us(1);
this->LS7366_cmd(RD,CNTR); //cmd = 0x60, READ from CNTR
@@ -65,7 +65,7 @@
counter.byte_enc[1] = this->_spi.write(0x00);
counter.byte_enc[0] = this->_spi.write(0x00);
- this->_cs = 1;
+ this->_cs = 0;
this->count = counter.long_enc;
return counter.long_enc; //return count
@@ -76,13 +76,13 @@
this->_spi.format(8, 0);
this->_spi.frequency(2000000);
- this->_cs = 0;
+ this->_cs = 1;
wait_us(1);
this->LS7366_cmd(WR,MDR0);// Write to the MDR0 register
this->_spi.write(0x03); // X4 quadrature count mode
- this->_cs = 1;
+ this->_cs = 0;
}
void LS7366::LS7366_reset_counter(){
@@ -90,21 +90,21 @@
this->_spi.format(8, 0);
this->_spi.frequency(2000000);
- this->_cs = 0;
+ this->_cs = 1;
wait_us(1);
this->LS7366_cmd(CLR,CNTR);//Clear the counter register
- this->_cs = 1;
+ this->_cs = 0;
wait_us(1);
- this->_cs = 0;
+ this->_cs = 1;
wait_us(1);
this->LS7366_cmd(LOAD,CNTR);//
- this->_cs = 1;
+ this->_cs = 0;
}
void LS7366::LS7366_write_DTR(long enc_value)
@@ -120,7 +120,7 @@
counter.long_enc = enc_value;
- this->_cs = 0;
+ this->_cs = 1;
wait_us(1);
this->LS7366_cmd(WR,DTR);//
@@ -129,16 +129,16 @@
this->_spi.write(counter.byte_enc[1]);
this->_spi.write(counter.byte_enc[0]);
- this->_cs = 1;
+ this->_cs = 0;
wait_us(1);
- this->_cs = 0;
+ this->_cs = 1;
wait_us(1);
this->LS7366_cmd(LOAD,CNTR);//
- this->_cs = 1;
+ this->_cs = 0;
}
void LS7366::_init(){