Open the BLE datasheet and search for CyBle_EnterLPM.
Sorry about my mistake ( I`m not make this word big enough) EXAMPLE of code.
I should put on my glasses ;-)
In all examples you provided I can`t find CyBle_EnterLPM() function with the input parameter as ACTIVE.
Why you provided it ? I have 100 examples without it ...
Low power startup program has this function I checked for it. Did you look at the Ble API spec's it should be in it.
This function requests the underlying BLE modules such as BLE Controller, BLE Host Stack and BLE Stack manger to enter into one of the supported low power modes. Application should use this function to put Bluetooth Low Energy Sub-System (BLESS) to Low Power Mode (LPM).
BLE Stack enters and exits low power modes based on its current state and hence the application should consider the BLE Stack LPM state before putting the CPU or the overall device into LPM. This function attempts to set the requested low power mode and if that is not possible, it tries to set the next higher low-power-mode. This behavior is due to the requirement that the application will always try to use the lowest power mode when there is nothing that it needs to process. Note that the CPU will not be able to access the BLESS registers when BLESS is in deep sleep mode.
BLE Stack has the following power modes:
Sleep (Low Power Mode)
DeepSleep with ECO Off (Low Power Mode)
Hibernate (Low Power Mode)
Note that certain conditions may prevent BLE sub system from entering a particular low power mode.
Bluetooth Low Energy Sub System (BLESS) has three sub-modes in Active mode:
Transmit Mode, and
These modes draw full current from the device and the CPU has full access to its registers.
The clock to the link layer engine and digital modem is gated and the (External Crystal Oscillator) ECO continues to run to maintain the link layer timing. The application cannot enter sleep mode if a Transmit or Receive is in progress.
Deep Sleep with ECO Off Mode
The ECO is stopped and Watch Crystal Oscillator (WCO) is used to maintain link layer timing. All the regulators in the Radio Frequency (RF) transceiver are turned off to reduce leakage current and BLESS logic is kept powered ON from the System Resources Sub System (SRSS) deep-sleep regulator for retention of current BLESS state information. This mode can be entered from either Idle (Active) or Sleep mode. It should be entered when the next scheduled activity instant in time domain is greater than the Deep Sleep total wakeup time (typically 2ms).
NOTE: If application is using ECO as source of HFCLK for higher clock accuracy and calls this API to move BLESS to Deep Sleep mode then HFCLK accuracy and frequency would be impacted as this API switches HFCLK source from ECO to IMO. On BLESS wakeup, the HFCLK source would be switched back to ECO.
Recommendation is that application turns on IMO and sets it as HFCLK source before calling this API. Upon wakeup due to sources other than BLESS, application can turn on ECO and switch HFCLK source to ECO. Pseudo code of recommendation is given below.
Pseudo Code: //Turn on IMO and switch HFCLK to IMO CyBle_EnterLPM(CYBLE_BLESS_DEEPSLEEP); CySysPmDeepSleep(); //If exit is not due to BLE and application need to use ECO //then turn on ECO and switch HFCLK source to ECO.
The application layer should invoke this function with the Hibernate Mode option to put the BLE Stack in to hibernate mode. If this mode is set, the micro-controller can be put in to Hibernate Mode by the application layer. This mode ensures that BLE Sub-system is completely idle and no procedures such ADV, SCAN and CONNECTION are active.
The following table indicates the allowed sleep modes for the complete system (BLE Sub-system and the micro-controller). Modes marked In 'X' are the allowed combinations. The application layer should make sure that the invalid modes are not entered in to:
BLE Stack LPM / PSoC4A-BLE LPM Active Sleep DeepSleep Hibernate
Sleep X X
DeepSleep (ECO OFF) X X X
The application layer is responsible for putting the BLE Sub-system and the micro-controller in to the desired sleep modes. Upon entering the requested sleep mode combination, the BLE Sub-system and the micro-controller are woken up by an interrupt every advertisement interval(in case of a GAP Peripheral) or connection interval (in case of GAP Central). On wakeup, if the application needs to transmit some data, appropriate function(s) including the Stack functions need to be invoked. This needs to be followed by a call to the function CyBle_ProcessEvents, which handles all pending transmit and receive operations. The application can now put the complete system back in to one of the sleep modes. The application should ensure that the above invalid states are never encountered.
Application shall also ensure that BLE Sub-system's low power entry and low power exit interrupts are processed in realtime and not blocked. It is recommended that BLE Sub-system interrupt should be of higher priority. If BLE Sub-system interrupts are blocked for longer time ( > 200us ), BLE Sub-system can violate Bluetooth specification timing for wakeup where ECO is required to perform BLE radio operation. It can also result in race condition where BLE Stack waits for interrupt as ECO is not started correctly and BLE Sub system enters in unknown state, BLE Stack gets stuck in busy loop.
This is a blocking function. In process of entering in BLESS Deep Sleep Mode, BLE Stack puts CPU in Sleep Mode to save power while polling for entry indication to BLESS DSM. No event is generated on calling this function. Based on the return code from this function, the application layer should decide on the sleep mode for the complete system. For example, if the return code is CYBLE_BLESS_DEEPSLEEP, the application can choose to call system wide DeepSleep mode function.
pwrMode The power mode that the component is intended to enter. The allowed values are,
CYBLE_LP_MODE_T: The actual power mode that BLE stack is now set to.
I don`t understand why you do it. I can read manuals and I placed link to excellent doc with code snippets. But in all manuals and documents and examples not exist ANY code snippet for using this call.
Please don`t send spam.
I opened a support case with Cypress on your issue and will get back with you when they respond.
Thanks ! This is really help.
Chaplin: Here is Cypress's answer to your issue.
Few things that I can tell you:
1) CyBle_EnterLPM(CYBLE_BLESS_ACTIVE) is used under 2 scenarios:
a) Writing to FLASH: The BLESS interrupts are disabled and BLESS is put into LPM before starting write to FLASH. After write is complete, BLESS is woken up by CyBle_EnterLPM(CYBLE_BLESS_ACTIVE).
b) Reading Link Layer registers: You will be able to access Link Layer registers only when BLESS is active. So if the BLESS is in LPM, we use the CyBle_EnterLPM(CYBLE_BLESS_ACTIVE) API to wake it up and then read the LL registers.
2) It is better to you use CyBle_ExitLPM() over CyBle_EnterLPM(CYBLE_BLESS_ACTIVE).
3) I don't think there are examples for these.
I had him check on item 3 here is his answer.
We do not have any examples to demonstrate what I had told you.
I hope this helps you.
Hm, not so good news. How can I create something if even Cypress don`t checked it.
Can you ask to check CyBle_ExitLPM() ( if it`s better) functionality ?
They have experts and professional programmers to do this.
And will be very help if they can create some example like LED ON/OFF . Go to SLEEP and after some delay Wake-Up.