Hi, Alina,
I use PTA2 pin as SDA, PTA3 pin SCL, and enable internal pull-up for the two pins configured as following image. I have not used external pull-ups fro each line.


I test it again and find that it will return STATUS_I2C_RECEIVED_NACK in every situation you mentioned after the LPI2C_DRV_MasterSendDataBlocking() function, and when that happens I call LPI2C_DRV_MasterDeinit() to find the SCL and SDA can be back to high.
Finally, there is the same between without a slave connected and with a slave.
Note: When NACK signal is received, it will jump into LPI2C_DRV_MasterIRQHandler() function, and in this function there is LPI2C_DRV_MasterEndTransfer() to end current transfer where I set parameter sendStop to be true to generate STOP condition it will be back to high, however the default setting value is false. I wonder why the parameter will have different effect on different baudrate and different optimization level because it is exactly OK for different optimization -O0 and -O1 with baudrate 400KHz.
if (LPI2C_Get_MasterNACKDetectEvent(baseAddr))
{
/* Received NACK */
#if(LPI2C_HAS_ULTRA_FAST_MODE)
/* Ignore NACK in Ultra Fast mode */
if (master->operatingMode != LPI2C_ULTRAFAST_MODE)
{
#endif
/* Signal transfer end for blocking transfers */
if (master->blocking == true)
{
(void)OSIF_SemaPost(&(master->idleSemaphore));
}
#if(LPI2C_HAS_HIGH_SPEED_MODE)
/* High-speed transfers end at STOP condition */
master->highSpeedInProgress = false;
#endif
master->status = STATUS_I2C_RECEIVED_NACK;
/* End transfer: no stop generation (the module will handle that by itself
if needed), reset FIFOs */
LPI2C_DRV_MasterEndTransfer(baseAddr, master, false, true);
if (master->masterCallback != NULL)
{
master->masterCallback(I2C_MASTER_EVENT_END_TRANSFER, master->callbackParam);
}
/* Clear NACK flag */
LPI2C_Clear_MasterNACKDetectEvent(baseAddr);
#if(LPI2C_HAS_ULTRA_FAST_MODE)
}
#endif
}
Thanks, BR
Han