Lines Matching refs:context
39 static void SlaveHandleAddress (CySCB_Type *base, cy_stc_scb_i2c_context_t *context);
40 static void SlaveHandleDataReceive (CySCB_Type *base, cy_stc_scb_i2c_context_t *context);
41 static void SlaveHandleDataTransmit(CySCB_Type *base, cy_stc_scb_i2c_context_t *context);
42 static void SlaveHandleStop (CySCB_Type *base, cy_stc_scb_i2c_context_t *context);
44 static void MasterHandleEvents (CySCB_Type *base, cy_stc_scb_i2c_context_t *context);
45 static void MasterHandleDataTransmit(CySCB_Type *base, cy_stc_scb_i2c_context_t *context);
46 static void MasterHandleDataReceive (CySCB_Type *base, cy_stc_scb_i2c_context_t *context);
47 static void MasterHandleStop (CySCB_Type *base, cy_stc_scb_i2c_context_t *context);
48 static void MasterHandleComplete (CySCB_Type *base, cy_stc_scb_i2c_context_t *context);
51 cy_stc_scb_i2c_context_t *context);
80 …2C_Init(CySCB_Type *base, cy_stc_scb_i2c_config_t const *config, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_Init() argument
83 if ((NULL == base) || (NULL == config) || (NULL == context)) in Cy_SCB_I2C_Init()
139 context->useRxFifo = config->useRxFifo; in Cy_SCB_I2C_Init()
140 context->useTxFifo = config->useTxFifo; in Cy_SCB_I2C_Init()
142 context->state = CY_SCB_I2C_IDLE; in Cy_SCB_I2C_Init()
145 context->masterStatus = 0UL; in Cy_SCB_I2C_Init()
146 context->masterBufferIdx = 0UL; in Cy_SCB_I2C_Init()
149 context->slaveStatus = 0UL; in Cy_SCB_I2C_Init()
151 context->slaveRxBufferIdx = 0UL; in Cy_SCB_I2C_Init()
152 context->slaveRxBufferSize = 0UL; in Cy_SCB_I2C_Init()
154 context->slaveTxBufferIdx = 0UL; in Cy_SCB_I2C_Init()
155 context->slaveTxBufferSize = 0UL; in Cy_SCB_I2C_Init()
158 context->cbEvents = NULL; in Cy_SCB_I2C_Init()
159 context->cbAddr = NULL; in Cy_SCB_I2C_Init()
226 void Cy_SCB_I2C_Disable(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_Disable() argument
231 context->state = CY_SCB_I2C_IDLE; in Cy_SCB_I2C_Disable()
232 context->masterStatus = 0UL; in Cy_SCB_I2C_Disable()
233 context->slaveStatus = 0UL; in Cy_SCB_I2C_Disable()
286 cy_stc_scb_i2c_context_t *locContext = (cy_stc_scb_i2c_context_t *) callbackParams->context; in Cy_SCB_I2C_DeepSleepCallback()
458 cy_stc_scb_i2c_context_t *locContext = (cy_stc_scb_i2c_context_t *) callbackParams->context; in Cy_SCB_I2C_HibernateCallback()
798 uint32_t Cy_SCB_I2C_SlaveGetStatus(CySCB_Type const *base, cy_stc_scb_i2c_context_t const *context) in Cy_SCB_I2C_SlaveGetStatus() argument
803 return (context->slaveStatus); in Cy_SCB_I2C_SlaveGetStatus()
848 cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_SlaveConfigReadBuf() argument
855 context->slaveTxBuffer = buffer; in Cy_SCB_I2C_SlaveConfigReadBuf()
856 context->slaveTxBufferSize = size; in Cy_SCB_I2C_SlaveConfigReadBuf()
857 context->slaveTxBufferIdx = 0UL; in Cy_SCB_I2C_SlaveConfigReadBuf()
858 context->slaveTxBufferCnt = 0UL; in Cy_SCB_I2C_SlaveConfigReadBuf()
889 void Cy_SCB_I2C_SlaveAbortRead(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_SlaveAbortRead() argument
899 context->slaveTxBufferSize = 0UL; in Cy_SCB_I2C_SlaveAbortRead()
901 if ((context->useTxFifo) && in Cy_SCB_I2C_SlaveAbortRead()
902 (0UL != (CY_SCB_I2C_SLAVE_RD_BUSY & context->slaveStatus))) in Cy_SCB_I2C_SlaveAbortRead()
939 …_SCB_I2C_SlaveGetReadTransferCount(CySCB_Type const *base, cy_stc_scb_i2c_context_t const *context) in Cy_SCB_I2C_SlaveGetReadTransferCount() argument
944 return (context->slaveTxBufferCnt); in Cy_SCB_I2C_SlaveGetReadTransferCount()
970 uint32_t Cy_SCB_I2C_SlaveClearReadStatus(CySCB_Type const *base, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_SlaveClearReadStatus() argument
977 retStatus = (context->slaveStatus & CY_SCB_I2C_SLAVE_RD_CLEAR); in Cy_SCB_I2C_SlaveClearReadStatus()
978 context->slaveStatus &= (uint32_t) ~CY_SCB_I2C_SLAVE_RD_CLEAR; in Cy_SCB_I2C_SlaveClearReadStatus()
1027 cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_SlaveConfigWriteBuf() argument
1034 context->slaveRxBuffer = buffer; in Cy_SCB_I2C_SlaveConfigWriteBuf()
1035 context->slaveRxBufferSize = size; in Cy_SCB_I2C_SlaveConfigWriteBuf()
1036 context->slaveRxBufferIdx = 0UL; in Cy_SCB_I2C_SlaveConfigWriteBuf()
1062 void Cy_SCB_I2C_SlaveAbortWrite(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_SlaveAbortWrite() argument
1072 context->slaveRxBufferSize = 0UL; in Cy_SCB_I2C_SlaveAbortWrite()
1074 if ((context->useRxFifo) && in Cy_SCB_I2C_SlaveAbortWrite()
1075 (0UL != (CY_SCB_I2C_SLAVE_WR_BUSY & context->slaveStatus))) in Cy_SCB_I2C_SlaveAbortWrite()
1115 …SCB_I2C_SlaveGetWriteTransferCount(CySCB_Type const *base, cy_stc_scb_i2c_context_t const *context) in Cy_SCB_I2C_SlaveGetWriteTransferCount() argument
1120 return (context->slaveRxBufferIdx); in Cy_SCB_I2C_SlaveGetWriteTransferCount()
1147 uint32_t Cy_SCB_I2C_SlaveClearWriteStatus(CySCB_Type const *base, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_SlaveClearWriteStatus() argument
1154 retStatus = (context->slaveStatus & CY_SCB_I2C_SLAVE_WR_CLEAR); in Cy_SCB_I2C_SlaveClearWriteStatus()
1155 context->slaveStatus &= (uint32_t) ~CY_SCB_I2C_SLAVE_WR_CLEAR; in Cy_SCB_I2C_SlaveClearWriteStatus()
1191 uint32_t Cy_SCB_I2C_MasterGetStatus(CySCB_Type const *base, cy_stc_scb_i2c_context_t const *context) in Cy_SCB_I2C_MasterGetStatus() argument
1196 return (context->masterStatus); in Cy_SCB_I2C_MasterGetStatus()
1253 cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_MasterRead() argument
1264 if (0UL != (CY_SCB_I2C_IDLE_MASK & context->state)) in Cy_SCB_I2C_MasterRead()
1273 context->masterStatus = CY_SCB_I2C_MASTER_BUSY; in Cy_SCB_I2C_MasterRead()
1275 context->masterBuffer = xferConfig->buffer; in Cy_SCB_I2C_MasterRead()
1276 context->masterBufferSize = xferConfig->bufferSize; in Cy_SCB_I2C_MasterRead()
1277 context->masterBufferIdx = 0UL; in Cy_SCB_I2C_MasterRead()
1278 context->masterNumBytes = 0UL; in Cy_SCB_I2C_MasterRead()
1279 context->masterPause = xferConfig->xferPending; in Cy_SCB_I2C_MasterRead()
1280 context->masterRdDir = true; in Cy_SCB_I2C_MasterRead()
1286 if (CY_SCB_I2C_IDLE == context->state) in Cy_SCB_I2C_MasterRead()
1309 if ((context->useRxFifo) && (!context->masterPause) && (context->masterBufferSize >= 2UL)) in Cy_SCB_I2C_MasterRead()
1317 Cy_SCB_SetRxFifoLevel(base, (context->masterBufferSize <= fifoSize) ? in Cy_SCB_I2C_MasterRead()
1318 … (context->masterBufferSize - 2UL) : ((fifoSize / 2UL) - 1UL)); in Cy_SCB_I2C_MasterRead()
1320 context->state = CY_SCB_I2C_MASTER_RX1; in Cy_SCB_I2C_MasterRead()
1327 context->state = CY_SCB_I2C_MASTER_RX0; in Cy_SCB_I2C_MasterRead()
1368 void Cy_SCB_I2C_MasterAbortRead(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_MasterAbortRead() argument
1374 if (0UL != (CY_SCB_I2C_MASTER_BUSY & context->masterStatus)) in Cy_SCB_I2C_MasterAbortRead()
1377 if ((CY_SCB_I2C_MASTER_RX0 == context->state) || (CY_SCB_I2C_MASTER_RX1 == context->state)) in Cy_SCB_I2C_MasterAbortRead()
1379 if (context->useRxFifo) in Cy_SCB_I2C_MasterAbortRead()
1385 context->state = CY_SCB_I2C_MASTER_STOP; in Cy_SCB_I2C_MasterAbortRead()
1393 context->masterBufferSize = 1UL; in Cy_SCB_I2C_MasterAbortRead()
1397 context->masterPause = false; in Cy_SCB_I2C_MasterAbortRead()
1406 if (CY_SCB_I2C_MASTER_WAIT == context->state) in Cy_SCB_I2C_MasterAbortRead()
1413 context->masterStatus = CY_SCB_I2C_MASTER_BUSY; in Cy_SCB_I2C_MasterAbortRead()
1414 context->masterNumBytes = 0UL; in Cy_SCB_I2C_MasterAbortRead()
1415 context->masterPause = false; in Cy_SCB_I2C_MasterAbortRead()
1422 context->state = CY_SCB_I2C_MASTER_WAIT_STOP; in Cy_SCB_I2C_MasterAbortRead()
1481 cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_MasterWrite() argument
1492 if (0UL != (CY_SCB_I2C_IDLE_MASK & context->state)) in Cy_SCB_I2C_MasterWrite()
1500 context->masterStatus = CY_SCB_I2C_MASTER_BUSY; in Cy_SCB_I2C_MasterWrite()
1502 context->masterBuffer = xferConfig->buffer; in Cy_SCB_I2C_MasterWrite()
1503 context->masterBufferSize = xferConfig->bufferSize; in Cy_SCB_I2C_MasterWrite()
1504 context->masterBufferIdx = 0UL; in Cy_SCB_I2C_MasterWrite()
1505 context->masterNumBytes = 0UL; in Cy_SCB_I2C_MasterWrite()
1506 context->masterPause = xferConfig->xferPending; in Cy_SCB_I2C_MasterWrite()
1507 context->masterRdDir = false; in Cy_SCB_I2C_MasterWrite()
1513 if (CY_SCB_I2C_IDLE == context->state) in Cy_SCB_I2C_MasterWrite()
1532 if (0U == context->masterBufferSize) in Cy_SCB_I2C_MasterWrite()
1555 context->state = CY_SCB_I2C_MASTER_TX; in Cy_SCB_I2C_MasterWrite()
1558 Cy_SCB_SetTxFifoLevel(base, (context->useTxFifo) ? CY_SCB_I2C_HALF_FIFO_SIZE : (1UL)); in Cy_SCB_I2C_MasterWrite()
1608 void Cy_SCB_I2C_MasterAbortWrite(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_MasterAbortWrite() argument
1614 if (0UL != (CY_SCB_I2C_MASTER_BUSY & context->masterStatus)) in Cy_SCB_I2C_MasterAbortWrite()
1619 if (context->useTxFifo) in Cy_SCB_I2C_MasterAbortWrite()
1625 … if ((CY_SCB_I2C_MASTER_TX == context->state) || (CY_SCB_I2C_MASTER_TX_DONE == context->state)) in Cy_SCB_I2C_MasterAbortWrite()
1628 context->state = CY_SCB_I2C_MASTER_STOP; in Cy_SCB_I2C_MasterAbortWrite()
1635 context->masterPause = false; in Cy_SCB_I2C_MasterAbortWrite()
1643 if (CY_SCB_I2C_MASTER_WAIT == context->state) in Cy_SCB_I2C_MasterAbortWrite()
1650 context->masterStatus = CY_SCB_I2C_MASTER_BUSY; in Cy_SCB_I2C_MasterAbortWrite()
1651 context->masterNumBytes = 0UL; in Cy_SCB_I2C_MasterAbortWrite()
1652 context->masterPause = false; in Cy_SCB_I2C_MasterAbortWrite()
1659 context->state = CY_SCB_I2C_MASTER_WAIT_STOP; in Cy_SCB_I2C_MasterAbortWrite()
1696 … Cy_SCB_I2C_MasterGetTransferCount(CySCB_Type const *base, cy_stc_scb_i2c_context_t const *context) in Cy_SCB_I2C_MasterGetTransferCount() argument
1701 return (context->masterNumBytes); in Cy_SCB_I2C_MasterGetTransferCount()
1754 cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_MasterSendStart() argument
1765 if (CY_SCB_I2C_IDLE == context->state) in Cy_SCB_I2C_MasterSendStart()
1771 context->state = CY_SCB_I2C_MASTER_ADDR; in Cy_SCB_I2C_MasterSendStart()
1772 context->masterRdDir = (CY_SCB_I2C_READ_XFER == bitRnW); in Cy_SCB_I2C_MasterSendStart()
1793 retStatus = HandleStatus(base, locStatus, context); in Cy_SCB_I2C_MasterSendStart()
1851 cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_MasterSendReStart() argument
1859 if (0UL != (CY_SCB_I2C_MASTER_ACTIVE & context->state)) in Cy_SCB_I2C_MasterSendReStart()
1865 context->state = CY_SCB_I2C_MASTER_ADDR; in Cy_SCB_I2C_MasterSendReStart()
1866 context->masterRdDir = (CY_SCB_I2C_READ_XFER == bitRnW); in Cy_SCB_I2C_MasterSendReStart()
1906 retStatus = HandleStatus(base, locStatus, context); in Cy_SCB_I2C_MasterSendReStart()
1950 cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_MasterSendStop() argument
1956 if (0UL != (CY_SCB_I2C_MASTER_ACTIVE & context->state)) in Cy_SCB_I2C_MasterSendStop()
1973 retStatus = HandleStatus(base, locStatus, context); in Cy_SCB_I2C_MasterSendStop()
2026 cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_MasterReadByte() argument
2034 if (CY_SCB_I2C_MASTER_RX0 == context->state) in Cy_SCB_I2C_MasterReadByte()
2059 retStatus = HandleStatus(base, locStatus, context); in Cy_SCB_I2C_MasterReadByte()
2116 cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_MasterWriteByte() argument
2122 if (CY_SCB_I2C_MASTER_TX == context->state) in Cy_SCB_I2C_MasterWriteByte()
2139 retStatus = HandleStatus(base, locStatus, context); in Cy_SCB_I2C_MasterWriteByte()
2168 void Cy_SCB_I2C_Interrupt(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_Interrupt() argument
2170 if (0UL != (CY_SCB_I2C_MASTER_ACTIVE & context->state)) in Cy_SCB_I2C_Interrupt()
2173 Cy_SCB_I2C_MasterInterrupt(base, context); in Cy_SCB_I2C_Interrupt()
2178 Cy_SCB_I2C_SlaveInterrupt(base, context); in Cy_SCB_I2C_Interrupt()
2201 void Cy_SCB_I2C_SlaveInterrupt(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_SlaveInterrupt() argument
2211 context->state = CY_SCB_I2C_SLAVE_ACTIVE; in Cy_SCB_I2C_SlaveInterrupt()
2223 context->slaveStatus |= (0UL != (CY_SCB_SLAVE_INTR_I2C_BUS_ERROR & slaveIntrStatus)) ? in Cy_SCB_I2C_SlaveInterrupt()
2239 if ((Cy_SCB_GetNumInRxFifo(base) > 0UL) && (context->slaveRxBufferSize > 0UL)) in Cy_SCB_I2C_SlaveInterrupt()
2250 SlaveHandleDataReceive(base, context); in Cy_SCB_I2C_SlaveInterrupt()
2258 SlaveHandleStop(base, context); in Cy_SCB_I2C_SlaveInterrupt()
2269 SlaveHandleAddress(base, context); in Cy_SCB_I2C_SlaveInterrupt()
2278 SlaveHandleDataTransmit(base, context); in Cy_SCB_I2C_SlaveInterrupt()
2423 static void SlaveHandleAddress(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in SlaveHandleAddress() argument
2429 if (NULL != context->cbAddr) in SlaveHandleAddress()
2451 cmd = context->cbAddr(events); in SlaveHandleAddress()
2481 if (NULL != context->cbEvents) in SlaveHandleAddress()
2483 … context->cbEvents(readDirection ? CY_SCB_I2C_SLAVE_READ_EVENT : CY_SCB_I2C_SLAVE_WRITE_EVENT); in SlaveHandleAddress()
2489 context->state = CY_SCB_I2C_SLAVE_TX; in SlaveHandleAddress()
2490 context->slaveStatus |= CY_SCB_I2C_SLAVE_RD_BUSY; in SlaveHandleAddress()
2493 context->slaveTxBufferIdx = context->slaveTxBufferCnt; in SlaveHandleAddress()
2494 context->slaveRdBufEmpty = false; in SlaveHandleAddress()
2501 context->state = CY_SCB_I2C_SLAVE_RX; in SlaveHandleAddress()
2502 context->slaveStatus |= CY_SCB_I2C_SLAVE_WR_BUSY; in SlaveHandleAddress()
2507 if (context->useRxFifo) in SlaveHandleAddress()
2509 if (context->slaveRxBufferSize > 0UL) in SlaveHandleAddress()
2516 if (context->slaveRxBufferSize > fifoSize) in SlaveHandleAddress()
2519 level = (context->slaveRxBufferSize - fifoSize); in SlaveHandleAddress()
2525 level = (context->slaveRxBufferSize - 1UL); in SlaveHandleAddress()
2559 static void SlaveHandleDataReceive(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in SlaveHandleDataReceive() argument
2562 if (context->slaveRxBufferSize > 0UL) in SlaveHandleDataReceive()
2564 if (context->useRxFifo) in SlaveHandleDataReceive()
2573 numToCopy = Cy_SCB_ReadArray(base, context->slaveRxBuffer, numToCopy); in SlaveHandleDataReceive()
2574 context->slaveRxBufferIdx += numToCopy; in SlaveHandleDataReceive()
2575 context->slaveRxBufferSize -= numToCopy; in SlaveHandleDataReceive()
2576 context->slaveRxBuffer = &context->slaveRxBuffer[numToCopy]; in SlaveHandleDataReceive()
2579 if (context->slaveRxBufferSize > fifoSize) in SlaveHandleDataReceive()
2581 level = context->slaveRxBufferSize - fifoSize; in SlaveHandleDataReceive()
2588 … level = (context->slaveRxBufferSize == 0UL) ? (0UL) : (context->slaveRxBufferSize - 1UL); in SlaveHandleDataReceive()
2601 context->slaveRxBuffer[context->slaveRxBufferIdx] = (uint8_t) Cy_SCB_ReadRxFifo(base); in SlaveHandleDataReceive()
2602 ++context->slaveRxBufferIdx; in SlaveHandleDataReceive()
2603 --context->slaveRxBufferSize; in SlaveHandleDataReceive()
2631 static void SlaveHandleDataTransmit(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in SlaveHandleDataTransmit() argument
2638 if ((!context->slaveRdBufEmpty) && (0UL == context->slaveTxBufferSize)) in SlaveHandleDataTransmit()
2641 if (NULL != context->cbEvents) in SlaveHandleDataTransmit()
2643 context->cbEvents(CY_SCB_I2C_SLAVE_RD_BUF_EMPTY_EVENT); in SlaveHandleDataTransmit()
2647 context->slaveRdBufEmpty = (0UL == context->slaveTxBufferSize); in SlaveHandleDataTransmit()
2654 if (context->slaveRdBufEmpty) in SlaveHandleDataTransmit()
2657 numToCopy = (context->useTxFifo) ? Cy_SCB_GetFifoSize(base) : 1UL; in SlaveHandleDataTransmit()
2660 context->slaveTxBufferIdx += numToCopy; in SlaveHandleDataTransmit()
2662 context->slaveStatus |= CY_SCB_I2C_SLAVE_RD_UNDRFL; in SlaveHandleDataTransmit()
2666 if (context->slaveTxBufferSize > 1UL) in SlaveHandleDataTransmit()
2669 numToCopy = (context->useTxFifo) ? (context->slaveTxBufferSize - 1UL) : (1UL); in SlaveHandleDataTransmit()
2672 numToCopy = Cy_SCB_WriteArray(base, context->slaveTxBuffer, numToCopy); in SlaveHandleDataTransmit()
2673 context->slaveTxBufferIdx += numToCopy; in SlaveHandleDataTransmit()
2674 context->slaveTxBufferSize -= numToCopy; in SlaveHandleDataTransmit()
2675 context->slaveTxBuffer = &context->slaveTxBuffer[numToCopy]; in SlaveHandleDataTransmit()
2679 … if ((CY_SCB_I2C_FIFO_SIZE != Cy_SCB_GetNumInTxFifo(base)) && (1UL == context->slaveTxBufferSize)) in SlaveHandleDataTransmit()
2690 Cy_SCB_WriteTxFifo (base, (uint32_t) context->slaveTxBuffer[0UL]); in SlaveHandleDataTransmit()
2696 ++context->slaveTxBufferIdx; in SlaveHandleDataTransmit()
2697 context->slaveTxBufferSize = 0UL; in SlaveHandleDataTransmit()
2698 context->slaveTxBuffer = &context->slaveTxBuffer[1UL]; in SlaveHandleDataTransmit()
2703 if (context->useTxFifo) in SlaveHandleDataTransmit()
2706 context->slaveStatus |= CY_SCB_I2C_SLAVE_RD_IN_FIFO; in SlaveHandleDataTransmit()
2709 if (NULL != context->cbEvents) in SlaveHandleDataTransmit()
2711 context->cbEvents(CY_SCB_I2C_SLAVE_RD_IN_FIFO_EVENT); in SlaveHandleDataTransmit()
2736 static void SlaveHandleStop(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in SlaveHandleStop() argument
2740 if (CY_SCB_I2C_SLAVE_RX == context->state) in SlaveHandleStop()
2745 context->slaveStatus |= CY_SCB_I2C_SLAVE_WR_OVRFL; in SlaveHandleStop()
2747 if (context->useRxFifo) in SlaveHandleStop()
2758 context->slaveStatus |= (uint32_t) CY_SCB_I2C_SLAVE_WR_CMPLT; in SlaveHandleStop()
2759 context->slaveStatus &= (uint32_t) ~CY_SCB_I2C_SLAVE_WR_BUSY; in SlaveHandleStop()
2774 context->slaveTxBufferCnt = (context->slaveTxBufferIdx - size); in SlaveHandleStop()
2777 if (0UL == (CY_SCB_I2C_SLAVE_RD_UNDRFL & context->slaveStatus)) in SlaveHandleStop()
2779 context->slaveTxBufferSize += size; in SlaveHandleStop()
2780 context->slaveTxBuffer -= size; in SlaveHandleStop()
2784 context->slaveStatus |= (uint32_t) CY_SCB_I2C_SLAVE_RD_CMPLT; in SlaveHandleStop()
2785 context->slaveStatus &= (uint32_t) ~CY_SCB_I2C_SLAVE_RD_BUSY; in SlaveHandleStop()
2801 context->state = CY_SCB_I2C_IDLE; in SlaveHandleStop()
2804 if (NULL != context->cbEvents) in SlaveHandleStop()
2806 context->cbEvents(locEvents); in SlaveHandleStop()
2830 void Cy_SCB_I2C_MasterInterrupt(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in Cy_SCB_I2C_MasterInterrupt() argument
2842 context->masterStatus |= CY_SCB_I2C_MASTER_ABORT_START; in Cy_SCB_I2C_MasterInterrupt()
2845 context->state = CY_SCB_I2C_MASTER_CMPLT; in Cy_SCB_I2C_MasterInterrupt()
2851 MasterHandleEvents(base, context); in Cy_SCB_I2C_MasterInterrupt()
2859 MasterHandleDataReceive(base, context); in Cy_SCB_I2C_MasterInterrupt()
2866 MasterHandleDataTransmit(base, context); in Cy_SCB_I2C_MasterInterrupt()
2872 if (CY_SCB_I2C_MASTER_CMPLT == context->state) in Cy_SCB_I2C_MasterInterrupt()
2874 MasterHandleComplete(base, context); in Cy_SCB_I2C_MasterInterrupt()
2878 if (CY_SCB_I2C_MASTER_STOP == context->state) in Cy_SCB_I2C_MasterInterrupt()
2880 MasterHandleStop(base, context); in Cy_SCB_I2C_MasterInterrupt()
2905 static void MasterHandleEvents(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in MasterHandleEvents() argument
2916 …context->masterStatus |= (0UL != (CY_SCB_MASTER_INTR_I2C_ACK & Cy_SCB_GetMasterInterruptStatus(bas… in MasterHandleEvents()
2920 if (CY_SCB_I2C_MASTER_WAIT_STOP != context->state) in MasterHandleEvents()
2922 … context->state = (context->masterPause) ? CY_SCB_I2C_MASTER_CMPLT : CY_SCB_I2C_MASTER_STOP; in MasterHandleEvents()
2929 context->masterStatus |= CY_SCB_I2C_MASTER_BUS_ERR; in MasterHandleEvents()
2935 context->masterStatus |= CY_SCB_I2C_MASTER_ARB_LOST; in MasterHandleEvents()
2941 context->state = CY_SCB_I2C_MASTER_CMPLT; in MasterHandleEvents()
2962 static void MasterHandleDataReceive(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in MasterHandleDataReceive() argument
2964 switch (context->state) in MasterHandleDataReceive()
2969 context->masterBuffer[0UL] = (uint8_t) Cy_SCB_ReadRxFifo(base); in MasterHandleDataReceive()
2971 ++context->masterBufferIdx; in MasterHandleDataReceive()
2972 --context->masterBufferSize; in MasterHandleDataReceive()
2974 if (context->masterBufferSize > 0UL) in MasterHandleDataReceive()
2977 context->masterBuffer = &context->masterBuffer[1UL]; in MasterHandleDataReceive()
2983 … context->state = (context->masterPause) ? CY_SCB_I2C_MASTER_CMPLT : CY_SCB_I2C_MASTER_STOP; in MasterHandleDataReceive()
2993 numToCopied = Cy_SCB_ReadArray(base, context->masterBuffer, context->masterBufferSize); in MasterHandleDataReceive()
2994 context->masterBufferIdx += numToCopied; in MasterHandleDataReceive()
2995 context->masterBufferSize -= numToCopied; in MasterHandleDataReceive()
2996 context->masterBuffer = &context->masterBuffer[numToCopied]; in MasterHandleDataReceive()
2998 if (context->masterBufferSize < 2UL) in MasterHandleDataReceive()
3003 if (1UL == context->masterBufferSize) in MasterHandleDataReceive()
3008 context->state = CY_SCB_I2C_MASTER_RX0; in MasterHandleDataReceive()
3015 context->state = CY_SCB_I2C_MASTER_STOP; in MasterHandleDataReceive()
3023 Cy_SCB_SetRxFifoLevel(base, (context->masterBufferSize <= halfFifoSize) ? in MasterHandleDataReceive()
3024 … (context->masterBufferSize - 2UL) : (halfFifoSize - 1UL)); in MasterHandleDataReceive()
3052 static void MasterHandleDataTransmit(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in MasterHandleDataTransmit() argument
3054 if (CY_SCB_I2C_MASTER_TX_DONE == context->state) in MasterHandleDataTransmit()
3056 context->state = CY_SCB_I2C_MASTER_CMPLT; in MasterHandleDataTransmit()
3058 else if (CY_SCB_I2C_MASTER_TX == context->state) in MasterHandleDataTransmit()
3060 if (context->masterBufferSize > 1UL) in MasterHandleDataTransmit()
3063 uint32_t NumToCopy = (context->useTxFifo) ? (context->masterBufferSize - 1UL) : (1UL); in MasterHandleDataTransmit()
3066 NumToCopy = Cy_SCB_WriteArray(base, context->masterBuffer, NumToCopy); in MasterHandleDataTransmit()
3067 context->masterBufferIdx += NumToCopy; in MasterHandleDataTransmit()
3068 context->masterBufferSize -= NumToCopy; in MasterHandleDataTransmit()
3069 context->masterBuffer = &context->masterBuffer[NumToCopy]; in MasterHandleDataTransmit()
3073 … if ((CY_SCB_I2C_FIFO_SIZE != Cy_SCB_GetNumInTxFifo(base)) && (1UL == context->masterBufferSize)) in MasterHandleDataTransmit()
3084 Cy_SCB_WriteTxFifo (base, (uint32_t) context->masterBuffer[0UL]); in MasterHandleDataTransmit()
3089 ++context->masterBufferIdx; in MasterHandleDataTransmit()
3090 context->masterBufferSize = 0UL; in MasterHandleDataTransmit()
3094 if (0UL == context->masterBufferSize) in MasterHandleDataTransmit()
3096 if (context->masterPause) in MasterHandleDataTransmit()
3101 context->state = CY_SCB_I2C_MASTER_TX_DONE; in MasterHandleDataTransmit()
3109 context->state = CY_SCB_I2C_MASTER_STOP; in MasterHandleDataTransmit()
3112 if (context->useTxFifo) in MasterHandleDataTransmit()
3115 context->masterStatus |= CY_SCB_I2C_MASTER_WR_IN_FIFO; in MasterHandleDataTransmit()
3117 if (NULL != context->cbEvents) in MasterHandleDataTransmit()
3119 context->cbEvents(CY_SCB_I2C_MASTER_WR_IN_FIFO_EVENT); in MasterHandleDataTransmit()
3147 static void MasterHandleStop(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in MasterHandleStop() argument
3167 context->state = CY_SCB_I2C_MASTER_WAIT_STOP; in MasterHandleStop()
3189 static void MasterHandleComplete(CySCB_Type *base, cy_stc_scb_i2c_context_t *context) in MasterHandleComplete() argument
3206 context->masterStatus &= (uint32_t) ~CY_SCB_I2C_MASTER_BUSY; in MasterHandleComplete()
3209 if (context->masterRdDir) in MasterHandleComplete()
3211 context->masterNumBytes = context->masterBufferIdx; in MasterHandleComplete()
3215 context->masterNumBytes = context->masterBufferIdx - in MasterHandleComplete()
3245 context->state = CY_SCB_I2C_IDLE; in MasterHandleComplete()
3249 if (context->useRxFifo) in MasterHandleComplete()
3256 context->state = (context->masterPause) ? CY_SCB_I2C_MASTER_WAIT : CY_SCB_I2C_IDLE; in MasterHandleComplete()
3260 if (NULL != context->cbEvents) in MasterHandleComplete()
3263 …uint32_t locEvents = context->masterRdDir ? CY_SCB_I2C_MASTER_RD_CMPLT_EVENT : CY_SCB_I2C_MASTER_W… in MasterHandleComplete()
3266 …locEvents |= (0UL != (CY_SCB_I2C_MASTER_ERR & context->masterStatus)) ? CY_SCB_I2C_MASTER_ERR_EVEN… in MasterHandleComplete()
3268 context->cbEvents(locEvents); in MasterHandleComplete()
3330 …scb_i2c_status_t HandleStatus(CySCB_Type *base, uint32_t status, cy_stc_scb_i2c_context_t *context) in HandleStatus() argument
3347 context->state = CY_SCB_I2C_IDLE; in HandleStatus()
3358 if (CY_SCB_I2C_MASTER_ADDR == context->state) in HandleStatus()
3368 context->state = CY_SCB_I2C_IDLE; in HandleStatus()
3378 retStatus = (CY_SCB_I2C_MASTER_ADDR == context->state) ? in HandleStatus()
3388 context->state = CY_SCB_I2C_IDLE; in HandleStatus()
3393 if (CY_SCB_I2C_MASTER_ADDR == context->state) in HandleStatus()
3396 context->state = (context->masterRdDir) ? in HandleStatus()
3407 context->state = CY_SCB_I2C_IDLE; in HandleStatus()