Mini projet LOO
Dependencies: mbed APDS_9960 mbed-rtos
Home du projet
Diff: src/cSPI.cpp
- Revision:
- 30:c647da947bd9
- Parent:
- 29:95469b25e187
- Child:
- 31:7313366789f2
--- a/src/cSPI.cpp Wed Apr 20 15:09:43 2016 +0000 +++ b/src/cSPI.cpp Thu Apr 21 12:33:58 2016 +0000 @@ -15,9 +15,7 @@ cSPI::cSPI() { - _freq = 0; - _mode = 0; - _bits = 0; + } cSPI::cSPI(unsigned int f, unsigned int m, unsigned int b) @@ -78,32 +76,29 @@ void cSPI::initSPI(unsigned int frequence, unsigned int bits, unsigned int mode) { + Serial pc(USBTX, USBRX); + _freq = frequence; _cs = 0; - wait(0.5); - _spi.frequency(frequence); - _spi.format(bits, mode); - wait(0.5); + wait_us(500); + _spi.frequency(_freq); + //_spi.format(bits, mode); + wait_us(500); _cs = 1; + pc.printf("Liaison SPI Initialisee\n"); + } int cSPI::envoyerMatrice(cMatrice & mat) // Renvoi la reponse SPI { - int i = 0; + _cs = 0; - wait(0.5); - - for(; i < mat.getLig()/2; i++) { + wait_us(500); + for(int i = 0; i < mat.getLig(); i++) { for(int j = 0; j < mat.getCol(); j ++) { _spi.write(mat.getValTab(i, j)); } } - wait(0.01); - for(; i < mat.getLig(); i++) { - for(int j = 0; j < mat.getCol(); j ++) { - _spi.write(mat.getValTab(i, j)); - } - } - wait(0.5); + wait_us(500); _cs = 1; //avant 0 return 1; // temporaire } @@ -111,9 +106,9 @@ void cSPI::configurerNbMatrices(const int nb) { _cs = 0; - wait(0.5); - _spi.write(0x25); + wait_us(500); + _spi.write('%'); _spi.write(nb); - wait(0.5); + wait_us(500); _cs = 1; } \ No newline at end of file