!545 optimize cs keeping logic for spi transfer

Merge pull request !545 from NickYang/master
This commit is contained in:
openharmony_ci
2022-04-20 09:19:05 +00:00
committed by Gitee
4 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -285,7 +285,7 @@ static int32_t SpiDevRealTransfer(struct SpiDev *dev, struct SpiMsg *msg, struct
kmsg[i].wbuf = wbuf + pos;
kmsg[i].rbuf = rbuf + pos;
kmsg[i].len = msg[i].len;
kmsg[i].csChange = msg[i].csChange;
kmsg[i].keepCs = msg[i].keepCs;
kmsg[i].delayUs = msg[i].delayUs;
kmsg[i].speed = msg[i].speed;
pos += msg[i].len;
+1 -1
View File
@@ -809,7 +809,7 @@ static int32_t SpiDevTransfer(struct SpiCntlr *spiCntlr, struct SpiMsg *spiMsg,
}
/* pull pull up cs at the end */
if (msg->csChange) {
if (msg->keepCs == 0) {
hal_gpio_pin_set_dir(spiCtx[spiId].spiPinCS0, HAL_GPIO_DIR_OUT, 1);
}
if (ret < 0) {
+2 -2
View File
@@ -747,7 +747,7 @@ static int32_t SpiDevTransfer(struct SpiCntlr *spiCntlr, struct SpiMsg *spiMsg,
HalSpiSendRecv(spiDevice, msg->wbuf, msg->len, msg->rbuf, msg->len);
}
if (msg->csChange || singleCsChange) {
if (msg->keepCs == 0|| singleCsChange) {
LL_GPIO_SetOutputPin(LL_GET_GPIOX(spiDevice->resource.csGroup), LL_GET_HAL_PIN(spiDevice->resource.csPin));
}
if (msg->delayUs > 0) {
@@ -757,7 +757,7 @@ static int32_t SpiDevTransfer(struct SpiCntlr *spiCntlr, struct SpiMsg *spiMsg,
}
return HDF_SUCCESS;
CS_DOWN:
if (msg->csChange || singleCsChange) {
if (msg->keepCs == 0 || singleCsChange) {
LL_GPIO_SetOutputPin(LL_GET_GPIOX(spiDevice->resource.csGroup), LL_GET_HAL_PIN(spiDevice->resource.csPin));
}
return HDF_SUCCESS;
+1 -1
View File
@@ -500,7 +500,7 @@ static int32_t SpiDevTransfer(struct SpiCntlr *spiCntlr, struct SpiMsg *spiMsg,
}
/* pull pull up cs at the end */
if (msg->csChange && spiDevice->resource.spiCsSoft) {
if (msg->keepCs == 0 && spiDevice->resource.spiCsSoft) {
tls_gpio_write(WM_IO_PB_00 + spiDevice->resource.spiCsPin, 1);
}
}