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);
|
spiSelect(spi);
|
||||||
/* Atomic transfer operations. */
|
/* Atomic transfer operations. */
|
||||||
rx = spiPolledExchange(spi, tx);
|
rx = spiPolledExchange(spi, tx);
|
||||||
//spiExchange(spi, 2, &tx, &rxb); 8 bit version just in case?
|
|
||||||
/* Slave Select de-assertion. */
|
/* Slave Select de-assertion. */
|
||||||
spiUnselect(spi);
|
spiUnselect(spi);
|
||||||
/* Ownership release. */
|
/* Ownership release. */
|
||||||
|
@ -393,7 +392,7 @@ static int tle8888_spi_rw_array(struct tle8888_priv *chip, const uint16_t *tx, u
|
||||||
spiSelect(spi);
|
spiSelect(spi);
|
||||||
/* data transfer */
|
/* data transfer */
|
||||||
rxdata = spiPolledExchange(spi, tx[i]);
|
rxdata = spiPolledExchange(spi, tx[i]);
|
||||||
//spiExchange(spi, 2, &tx, &rxb); 8 bit version just in case?
|
|
||||||
if (rx)
|
if (rx)
|
||||||
rx[i] = rxdata;
|
rx[i] = rxdata;
|
||||||
/* Slave Select de-assertion. */
|
/* Slave Select de-assertion. */
|
||||||
|
|
|
@ -84,26 +84,18 @@ static void mcRestart();
|
||||||
|
|
||||||
// Receive 16bits
|
// Receive 16bits
|
||||||
unsigned short recv_16bit_spi() {
|
unsigned short recv_16bit_spi() {
|
||||||
unsigned short ret;
|
return spiPolledExchange(driver, 0xFFFF);
|
||||||
//spiSelect(driver);
|
|
||||||
spiReceive(driver, 1, &ret);
|
|
||||||
//spiUnselect(driver);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This could be used to detect if check byte is wrong.. or use a FLAG after init
|
// 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 txrx_16bit_spi(const unsigned short param) {
|
||||||
unsigned short ret;
|
return spiPolledExchange(driver, param);
|
||||||
//spiSelect(driver);
|
|
||||||
spiExchange(driver, 1, ¶m, &ret);
|
|
||||||
//spiUnselect(driver);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send 16bits
|
// Send 16bits
|
||||||
static void spi_writew(unsigned short param) {
|
static void spi_writew(unsigned short param) {
|
||||||
//spiSelect(driver);
|
//spiSelect(driver);
|
||||||
spiSend(driver, 1, ¶m);
|
spiPolledExchange(driver, param);
|
||||||
//spiUnselect(driver);
|
//spiUnselect(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,6 @@ EXTERN_ENGINE;
|
||||||
|
|
||||||
static Logging *logger;
|
static Logging *logger;
|
||||||
|
|
||||||
static uint8_t tx_buff[2] NO_CACHE;
|
|
||||||
static uint8_t rx_buff[1] NO_CACHE;
|
|
||||||
|
|
||||||
static CJ125 globalInstance;
|
static CJ125 globalInstance;
|
||||||
|
|
||||||
#if ! EFI_UNIT_TEST
|
#if ! EFI_UNIT_TEST
|
||||||
|
@ -97,30 +94,28 @@ static constexpr float lambdaLsu49[] = {
|
||||||
static uint8_t cjReadRegister(uint8_t regAddr) {
|
static uint8_t cjReadRegister(uint8_t regAddr) {
|
||||||
#if ! EFI_UNIT_TEST
|
#if ! EFI_UNIT_TEST
|
||||||
spiSelect(driver);
|
spiSelect(driver);
|
||||||
tx_buff[0] = regAddr;
|
spiPolledExchange(driver, regAddr);
|
||||||
spiSend(driver, 1, tx_buff);
|
uint8_t result = spiPolledExchange(driver, 0xFF);
|
||||||
spiReceive(driver, 1, rx_buff);
|
|
||||||
spiUnselect(driver);
|
spiUnselect(driver);
|
||||||
|
|
||||||
#ifdef CJ125_DEBUG_SPI
|
#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 */
|
#endif /* CJ125_DEBUG_SPI */
|
||||||
return rx_buff[0];
|
return result;
|
||||||
#else /* EFI_UNIT_TEST */
|
#else /* EFI_UNIT_TEST */
|
||||||
return 0;
|
return 0;
|
||||||
#endif /* EFI_UNIT_TEST */
|
#endif /* EFI_UNIT_TEST */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cjWriteRegister(uint8_t regAddr, uint8_t regValue) {
|
static void cjWriteRegister(uint8_t regAddr, uint8_t regValue) {
|
||||||
tx_buff[0] = regAddr;
|
|
||||||
tx_buff[1] = regValue;
|
|
||||||
#ifdef CJ125_DEBUG_SPI
|
#ifdef CJ125_DEBUG_SPI
|
||||||
scheduleMsg(logger, "cjWriteRegister: addr=%d value=%d", regAddr, regValue);
|
scheduleMsg(logger, "cjWriteRegister: addr=%d value=%d", regAddr, regValue);
|
||||||
#endif /* CJ125_DEBUG_SPI */
|
#endif /* CJ125_DEBUG_SPI */
|
||||||
// todo: extract 'sendSync' method?
|
// todo: extract 'sendSync' method?
|
||||||
#if HAL_USE_SPI
|
#if HAL_USE_SPI
|
||||||
spiSelect(driver);
|
spiSelect(driver);
|
||||||
spiSend(driver, 2, tx_buff);
|
spiPolledExchange(driver, regAddr);
|
||||||
|
spiPolledExchange(driver, regValue);
|
||||||
spiUnselect(driver);
|
spiUnselect(driver);
|
||||||
#endif /* HAL_USE_SPI */
|
#endif /* HAL_USE_SPI */
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ typedef uint16_t adcsample_t;
|
||||||
#define spiStop(x) {}
|
#define spiStop(x) {}
|
||||||
#define spiSelect(x) {}
|
#define spiSelect(x) {}
|
||||||
#define spiSelectI(x) {}
|
#define spiSelectI(x) {}
|
||||||
|
#define spiPolledExchange(x, y) {}
|
||||||
#define spiSend(x, y, z) {}
|
#define spiSend(x, y, z) {}
|
||||||
#define spiReceive(x, y, z) {}
|
#define spiReceive(x, y, z) {}
|
||||||
#define spiExchange(x,y,w,z) {}
|
#define spiExchange(x,y,w,z) {}
|
||||||
|
|
Loading…
Reference in New Issue