It is important that the code to handle the low-power transitions is protected in a critical section and that interrupts are not allowed to change the thread of operation. In the code snippet, this critical section is bound by the CyEnterCriticalSection() function at the beginning and the CyExitCriticalSection() function at the end. If you do not put the code in this critical section, it may result in race conditions between the system and the BLESS in entering the BLESS low-power modes, causing the device to enter an unknown state from which it cannot recover.
So you need to put the low power codes in the critical section.
It does appear from experience that that is required as it breaks if I don't do that.
However we have a UART with ISR configured. That does not fire when in deep sleep inside the critical section:
// when we receive data, generate an interrupt
And the ISR fires all the time except when put into deepsleep inside the critical section. Move it outside the critical section and it fires fine.
How do we go into deep sleep inside the critical section but still fire the UART ISR?