resets the pointer

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
yangyong
Level 5
Level 5
Distributor - Jingchuan(GC)
5 comments on blog First comment on blog 50 questions asked

When I2C slave read and write buffers operation ,the index is incremented。 I can't find a function to reset the array index in the CAT2 Peripheral Driver Library of MTB.

0 Likes
1 Solution
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

你打开modus的工程,在i2c slave 做好一次读的时候,代码里面会调用:

/* Configure write buffer for the next write */
Cy_SCB_I2C_SlaveConfigWriteBuf(CYBSP_I2C_HW, i2cWriteBuffer,
SL_WR_BUFFER_SIZE, &CYBSP_I2C_context);

这个函数的函数体就是:

void Cy_SCB_I2C_SlaveConfigWriteBuf(CySCB_Type const *base, uint8_t *buffer, uint32_t size,
cy_stc_scb_i2c_context_t *context)
{
CY_ASSERT_L1(CY_SCB_IS_I2C_BUFFER_VALID(buffer, size));

/* Suppress a compiler warning about unused variables */
CY_UNUSED_PARAMETER(base);

context->slaveRxBuffer = buffer;
context->slaveRxBufferSize = size;
context->slaveRxBufferIdx = 0UL;
}

slavRxBufferIdx=0就是你说的指针复位。如果你以前用psoc creator,也就是

/* Clear the slave write buffer and status */
I2CS_I2CSlaveClearWriteBuf();

其实你进到函数里面去看代码:

void I2CS_I2CSlaveClearWriteBuf(void)
{
I2CS_slWrBufIndex = 0u;
}

希望我的解释能对你有帮助。

View solution in original post

0 Likes
1 Reply
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

你打开modus的工程,在i2c slave 做好一次读的时候,代码里面会调用:

/* Configure write buffer for the next write */
Cy_SCB_I2C_SlaveConfigWriteBuf(CYBSP_I2C_HW, i2cWriteBuffer,
SL_WR_BUFFER_SIZE, &CYBSP_I2C_context);

这个函数的函数体就是:

void Cy_SCB_I2C_SlaveConfigWriteBuf(CySCB_Type const *base, uint8_t *buffer, uint32_t size,
cy_stc_scb_i2c_context_t *context)
{
CY_ASSERT_L1(CY_SCB_IS_I2C_BUFFER_VALID(buffer, size));

/* Suppress a compiler warning about unused variables */
CY_UNUSED_PARAMETER(base);

context->slaveRxBuffer = buffer;
context->slaveRxBufferSize = size;
context->slaveRxBufferIdx = 0UL;
}

slavRxBufferIdx=0就是你说的指针复位。如果你以前用psoc creator,也就是

/* Clear the slave write buffer and status */
I2CS_I2CSlaveClearWriteBuf();

其实你进到函数里面去看代码:

void I2CS_I2CSlaveClearWriteBuf(void)
{
I2CS_slWrBufIndex = 0u;
}

希望我的解释能对你有帮助。

0 Likes