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.
Dependents: Carte_Moteur_test_asservissement_1M identification Carte_Moteur_test_asservissement_3M
7366_lib.cpp
- Committer:
- natienza
- Date:
- 2019-01-22
- Revision:
- 1:53a1b0bdffb7
- Child:
- 2:f678a256adc8
File content as of revision 1:53a1b0bdffb7:
#include "mbed.h"
#include "7366_lib.h"
SPI_7366::SPI_7366(PinName SPI_MOSI, PinName SPI_MISO, PinName SPI_SCLK, PinName SPI_SSEL):SPI(SPI_MOSI,SPI_MISO, SPI_SCLK, ssel=SPI_SSEL){
}
void SPI_7366::setup(void){
uint8_t rxBuffer[2];
int rxLength = 0;
int txLength = 2;
uint8_t IR = WR|MDR0;
uint8_t data = QUADRATURE_X1|FREE_RUN;
uint8_t txBuffer[2] = {IR,data};
self.lock();
self.write(txBuffer, txLength, rxBuffer, rxLength);
self.unlock();
IR = WR|MDR1;
data = 4BYTES_CONFIG|CPT_ENABLE;
txBuffer = {IR,data};
self.lock();
self.write(txBuffer, txLength, rxBuffer, rxLength);
self.unlock();
return;
}
void SPI_7366::read_value(uint8_t* rxBuffer, int rxLength ){
uint8_t IR = RD|CNTR;
uint8_t txBuffer[1] = {IR};
int txLength = 1;
self.lock();
self.write(txBuffer, txLength, rxBuffer, rxLength);
self.unlock();
return;
}