Thanks for putting this document together, it is very helpful!
I had one question, however, when using peripheral UART and disabling the sleep modes, does that mean that from then on throughout the program, all sleep modes will be disabled?
If that callback function is in the list of functions and returns a value of 0x00, is there any way to reverse that callback when you know the program is not using peripheral UART? I am trying to do this by recalling that same callback but this time returning 0xFFFFFFFF, but I can tell that the chip is not going into sleep or deep-sleep. Is there another method that will work?
Your help is much appreciated.
So are you trying to figure out how to keep the part in sleep mode except when the PUART is being used?
Yes, when I am not communicating through PUART, I would like the chip to go through the regular sleep mode cycles and deep sleep. Is it possible to only disable sleep during PUART communication?
I think I could get away with changing the callback function to a non 0 number which would only prevent the chip from going into sleep modes for a certain amount of time, depending on what the return number is. At least that's what I got from the document above.
Just wondering if there is a better more efficient way.
Yea, that was actually a question I asked also
Not sure how to only disable sleep for a portion of the time. Anything you can suggest or point me in the direction of?
The sleep callback will be invoked whenever the FW is ready to sleep. What you should do is if PUART TX or RX FIFO is not empty, return 0 (for don't sleep - the app will get polled again in a few hundred uS) and if both are empty, return 0xFFFFFFFF (for sleep for however long you want to - other modules in the FW will decide the actual time to sleep based on adv/connection/scan intervals/timers etc).
I see, do I use the same exact callback function and return different values depending on the situation? Or do I enter different callback functions with different names?
When I have tried something like this, I see the chip doesn't go into sleep. When you return 0 for the callback function, won't the device always get this value when trying to go into sleep modes and therefore never enter sleep?
Are these callback functions permanent? If i enter a callback function with return value 0, is this action irreversible?
I'm using the BCM20732 (chip only), by the way so I can only use the SDK 1.1
Really appreciate the help.
Please sees previous comments as these are correct:
Here is a code snippet:
if(!P_UART_RX_FIFO_NOT_EMPTY() && P_UART_TX_FIFO_IS_EMPTY())
return ~0; ////// TX FIFO is empty and RX FIFO is empty. Allow sleep.
return 0; // Either TX or RX is not empty. Don’t sleep.
"The sleep callback will be invoked whenever the FW is ready to sleep. What you should do is if PUART TX or RX FIFO is not empty, return 0 (for don't sleep - the app will get polled again in a few hundred uS) and if both are empty, return 0xFFFFFFFF (for sleep for however long you want to - other modules in the FW will decide the actual time to sleep based on adv/connection/scan intervals/timers etc)."
"Have you looked at Re: Peripheral UART missing bytes?"
this worked! Really appreciate the help.