14 .
name =
"MT6825 SPI3" ,
15 .id=CLSID_ENCODER_MTSPI,
47 uint8_t
cspin = conf_int & 0xF;
52 uint16_t conf_int = this->
cspin & 0xF;
103 uint8_t
txbuf[2] = {(uint8_t)(addr | MAGNTEK_READ),0};
104 uint8_t
rxbuf[2] = {0,0};
135 uint8_t txbufNew[4] = {0x03 | MAGNTEK_READ,0,0,0};
144 uint32_t angle17_10 =
rxbuf[1];
145 uint32_t angle9_4 =
rxbuf[2];
146 uint32_t angle3_0 =
rxbuf[3];
149 uint8_t pc1 = angle17_10 ^ angle17_10 >> 1;
150 pc1 = pc1 ^ pc1 >> 2;
151 pc1 = pc1 ^ pc1 >> 4;
153 uint8_t pc1_2 = angle9_4 ^ angle9_4 >> 1;
154 pc1_2 = pc1_2 ^ pc1_2 >> 2;
155 pc1_2 = pc1_2 ^ pc1_2 >> 4;
158 angle3_0 = angle3_0 >> 2;
159 uint8_t pc2 = (angle3_0) ^ (angle3_0) >> 1;
160 pc2 = pc2 ^ pc2 >> 2;
161 pc2 = pc2 ^ pc2 >> 4;
163 nomag = (angle9_4 & 0x02) >> 1;
165 angle9_4 = (angle9_4 & 0xFC) >> 2;
166 angle3_0 = angle3_0 >> 2;
169 bool parity_ok = !(pc2 & 1) && ((pc1 & 1) == (pc1_2 & 1));
171 curAngleInt = (angle17_10 << 10) | (angle9_4 << 4) | (angle3_0);
205 replies.emplace_back(this->
cspin+1);
215 replies.emplace_back(
getPos());
223 replies.emplace_back(
errors);
void registerCommand(const char *cmd, const ID cmdid, const char *help=nullptr, uint32_t flags=0)
int32_t getPos() override
uint32_t getCpr() override
cpp_freertos::BinarySemaphore requestNewDataSem
void saveFlash() override
cpp_freertos::BinarySemaphore waitForUpdateSem
int32_t getPosAbs() override
void writeSpi(uint8_t addr, uint8_t data)
const ClassIdentifier getInfo()
Command handlers always have class infos. Works well with ChoosableClass.
void restoreFlash() override
void spiTxRxCompleted(SPIPort *port)
uint8_t readSpi(uint8_t addr)
bool updateAngleStatusCb()
void setCsPin(uint8_t cspin)
static ClassIdentifier info
CommandStatus command(const ParsedCommand &cmd, std::vector< CommandReply > &replies)
void transmitReceive(const uint8_t *txbuf, uint8_t *rxbuf, uint16_t size, SPIDevice *device, uint16_t timeout)
std::vector< OutputPin > & getCsPins()
bool reserveCsPin(OutputPin pin)
void transmitReceive_DMA(const uint8_t *txbuf, uint8_t *rxbuf, uint16_t size, SPIDevice *device)
void transmit(const uint8_t *buf, uint16_t size, SPIDevice *device, uint16_t timeout)
OutputPin * getCsPin(uint16_t idx)
void configurePort(SPI_InitTypeDef *config)
bool freeCsPin(OutputPin pin)
bool Take(TickType_t Timeout=portMAX_DELAY)
uint32_t WaitForNotification(TickType_t Timeout=portMAX_DELAY)
TVal Flash_ReadDefault(uint16_t adr, TVal def)
bool Flash_Write(uint16_t adr, uint16_t dat)
static void * memcpy(void *dst, const void *src, size_t n)
SPI_InitTypeDef peripheral
bool cspol
CSPOL=true === active low.