#include "CddSpiMcal.h" #include "Spi_Drv_Types.h" #include "Dio_Cfg.h" #include "Spi_Drv.h" #include "Dio.h" #include "Spi_Types.h" #include "Spi.h" #include "Spi_Cfg.h" #include "Spi_Types.h" boolean CddSpi_IfcIdle_Deriv(uint8 ucIfc) { return ((Spi_Drv_GetStatus(ucIfc) == SPI_DRV_IDLE) ? TRUE : FALSE); } boolean CddSpi_TransferComplete_Deriv(uint8 ucIfc, uint16 unTranSize) { // return ((Spi_Drv_GetStatus(ucIfc) == SPI_DRV_IDLE) ? TRUE : FALSE); return ((Spi_GetJobResult(ucIfc) == 0) ? TRUE : FALSE); } void SPI_Send1(uint8* data, uint8* retdata) { static uint8 TXbuffer_Stp[4]; static uint8 RXbuffer_Stp[4]; TXbuffer_Stp[3] = 0; for (int i = 0;i < 3;i++) { TXbuffer_Stp[2-i] = *(data + i); //change data position in buffer } Spi_SetAsyncMode(SPI_INTERRUPT_MODE); Spi_SetupEB(SpiConf_SpiChannel_SpiChl_Stp, TXbuffer_Stp, retdata, 3); // TODO: need modify spi Spi_AsyncTransmit(SpiConf_SpiChannel_SpiChl_Stp); } void CddSpi_Transfer_Deriv(uint8 ucIfc,const uint16* TxData ,uint16* RxData,uint8 length) { Spi_DataBufferType* SrcDataBufferPtr; Spi_DataBufferType* DesDataBufferPtr; SrcDataBufferPtr = (Spi_DataBufferType*)TxData; DesDataBufferPtr = (Spi_DataBufferType*)RxData; switch (ucIfc) { case SpiConf_SpiChannel_SpiChl_Buck: Spi_SetAsyncMode(SPI_INTERRUPT_MODE); Spi_SetupEB(SpiConf_SpiChannel_SpiChl_Buck,SrcDataBufferPtr, DesDataBufferPtr, length); Spi_AsyncTransmit(SpiConf_SpiChannel_SpiChl_Buck); break; case SpiConf_SpiChannel_SpiChl_Boost: Spi_SetAsyncMode(SPI_INTERRUPT_MODE); Spi_SetupEB(SpiConf_SpiChannel_SpiChl_Boost,SrcDataBufferPtr, DesDataBufferPtr, length); Spi_AsyncTransmit(SpiConf_SpiChannel_SpiChl_Boost); #if (CDDBUCk_CHIP_CPSQ5352 == CDDBUCK_CHIP_ERROR_HAND) if (BoostSendFlag == TRUE) { BoostSendFlag = FALSE; } #endif break; case SpiConf_SpiChannel_SpiChl_Stp: SPI_Send1(SrcDataBufferPtr, DesDataBufferPtr); break; case SpiConf_SpiChannel_SpiChl_Sbc: Spi_SetAsyncMode(SPI_INTERRUPT_MODE); Spi_SetupEB(SpiConf_SpiChannel_SpiChl_Sbc,SrcDataBufferPtr, DesDataBufferPtr, length); Spi_AsyncTransmit(SpiConf_SpiChannel_SpiChl_Sbc); break; default: break; } } void CddSpi_DeInitIfc_Deriv(uint8 ucIfc) { Spi_DeInit(); } void CddSpi_RxIntDisable_Deriv(uint8 ucIfc) { } boolean CddSpi_RxEventTriggered_Deriv(uint8 ucIfc) { //volatile tsCddSpi_CYT2_B9_SCB* const psSCB = CDDSPI_CYT2_B9_SCB_IFCBASE(ucIfc); //return ((psSCB->unINTR_RX.ulData & CDDSPI_CYT2_B9_SCB_INTR_RX_TRIGGER_MSK) == CDDSPI_CYT2_B9_SCB_INTR_RX_TRIGGER_VAL_SET ) ? TRUE : FALSE; return TRUE; } void CddSpi_RxTriggerEventClear_Deriv(uint8 ucIfc) { //volatile tsCddSpi_CYT2_B9_SCB* const psSCB = CDDSPI_CYT2_B9_SCB_IFCBASE(ucIfc); //Clear Rx Event //psSCB->unINTR_RX.ulData |= (uint32)CDDSPI_CYT2_B9_SCB_INTR_RX_TRIGGER_VAL_SET << CDDSPI_CYT2_B9_SCB_INTR_RX_TRIGGER_POS; }