use spiPolledExchange for small transfers (#2358)
* configure for no cache * this doesn't need a setting * now we don't need invalidate * reorder and comment * mmc * sw knock * use spiPolledExchange for small transfers * mock spi Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
443df01eea
commit
d933d18e29
|
@ -344,7 +344,6 @@ static int tle8888_spi_rw(struct tle8888_priv *chip, uint16_t tx, uint16_t *rx_p
|
|||
spiSelect(spi);
|
||||
/* Atomic transfer operations. */
|
||||
rx = spiPolledExchange(spi, tx);
|
||||
//spiExchange(spi, 2, &tx, &rxb); 8 bit version just in case?
|
||||
/* Slave Select de-assertion. */
|
||||
spiUnselect(spi);
|
||||
/* Ownership release. */
|
||||
|
@ -393,7 +392,7 @@ static int tle8888_spi_rw_array(struct tle8888_priv *chip, const uint16_t *tx, u
|
|||
spiSelect(spi);
|
||||
/* data transfer */
|
||||
rxdata = spiPolledExchange(spi, tx[i]);
|
||||
//spiExchange(spi, 2, &tx, &rxb); 8 bit version just in case?
|
||||
|
||||
if (rx)
|
||||
rx[i] = rxdata;
|
||||
/* Slave Select de-assertion. */
|
||||
|
|
|
@ -84,26 +84,18 @@ static void mcRestart();
|
|||
|
||||
// Receive 16bits
|
||||
unsigned short recv_16bit_spi() {
|
||||
unsigned short ret;
|
||||
//spiSelect(driver);
|
||||
spiReceive(driver, 1, &ret);
|
||||
//spiUnselect(driver);
|
||||
return ret;
|
||||
return spiPolledExchange(driver, 0xFFFF);
|
||||
}
|
||||
|
||||
// This could be used to detect if check byte is wrong.. or use a FLAG after init
|
||||
unsigned short txrx_16bit_spi(const unsigned short param) {
|
||||
unsigned short ret;
|
||||
//spiSelect(driver);
|
||||
spiExchange(driver, 1, ¶m, &ret);
|
||||
//spiUnselect(driver);
|
||||
return ret;
|
||||
return spiPolledExchange(driver, param);
|
||||
}
|
||||
|
||||
// Send 16bits
|
||||
static void spi_writew(unsigned short param) {
|
||||
//spiSelect(driver);
|
||||
spiSend(driver, 1, ¶m);
|
||||
spiPolledExchange(driver, param);
|
||||
//spiUnselect(driver);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,6 @@ EXTERN_ENGINE;
|
|||
|
||||
static Logging *logger;
|
||||
|
||||
static uint8_t tx_buff[2] NO_CACHE;
|
||||
static uint8_t rx_buff[1] NO_CACHE;
|
||||
|
||||
static CJ125 globalInstance;
|
||||
|
||||
#if ! EFI_UNIT_TEST
|
||||
|
@ -97,30 +94,28 @@ static constexpr float lambdaLsu49[] = {
|
|||
static uint8_t cjReadRegister(uint8_t regAddr) {
|
||||
#if ! EFI_UNIT_TEST
|
||||
spiSelect(driver);
|
||||
tx_buff[0] = regAddr;
|
||||
spiSend(driver, 1, tx_buff);
|
||||
spiReceive(driver, 1, rx_buff);
|
||||
spiPolledExchange(driver, regAddr);
|
||||
uint8_t result = spiPolledExchange(driver, 0xFF);
|
||||
spiUnselect(driver);
|
||||
|
||||
#ifdef CJ125_DEBUG_SPI
|
||||
scheduleMsg(logger, "cjReadRegister: addr=%d answer=%d", regAddr, rx_buff[0]);
|
||||
scheduleMsg(logger, "cjReadRegister: addr=%d answer=%d", regAddr, result);
|
||||
#endif /* CJ125_DEBUG_SPI */
|
||||
return rx_buff[0];
|
||||
return result;
|
||||
#else /* EFI_UNIT_TEST */
|
||||
return 0;
|
||||
#endif /* EFI_UNIT_TEST */
|
||||
}
|
||||
|
||||
static void cjWriteRegister(uint8_t regAddr, uint8_t regValue) {
|
||||
tx_buff[0] = regAddr;
|
||||
tx_buff[1] = regValue;
|
||||
#ifdef CJ125_DEBUG_SPI
|
||||
scheduleMsg(logger, "cjWriteRegister: addr=%d value=%d", regAddr, regValue);
|
||||
#endif /* CJ125_DEBUG_SPI */
|
||||
// todo: extract 'sendSync' method?
|
||||
#if HAL_USE_SPI
|
||||
spiSelect(driver);
|
||||
spiSend(driver, 2, tx_buff);
|
||||
spiPolledExchange(driver, regAddr);
|
||||
spiPolledExchange(driver, regValue);
|
||||
spiUnselect(driver);
|
||||
#endif /* HAL_USE_SPI */
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef uint16_t adcsample_t;
|
|||
#define spiStop(x) {}
|
||||
#define spiSelect(x) {}
|
||||
#define spiSelectI(x) {}
|
||||
#define spiPolledExchange(x, y) {}
|
||||
#define spiSend(x, y, z) {}
|
||||
#define spiReceive(x, y, z) {}
|
||||
#define spiExchange(x,y,w,z) {}
|
||||
|
|
Loading…
Reference in New Issue