| BlueNRG-1 HAL drivers APIs

- Main Page
- Classes
- Files

- File List
- File Members

Macros | Enumerations | Functions
sleep.h File Reference

Header file for BlueNRG Sleep management. More...

`#include "BlueNRG1.h"`

Go to the source code of this file.

## Macros

#define | WAKEUP_IO9 0x01
| Wakeup source IO9 Mask. More...
#define | WAKEUP_IO10 0x02
| Wakeup source IO10 Mask. More...
#define | WAKEUP_IO11 0x04
| Wakeup source IO11 Mask. More...
#define | WAKEUP_IO12 0x08
| Wakeup source IO12 Mask. More...
#define | WAKEUP_IO13 0x10
| Wakeup source IO13 Mask. More...
#define | WAKEUP_SLEEP_TIMER1 0x20
| Wakeup source Blue block Sleep Timer 1. More...
#define | WAKEUP_SLEEP_TIMER2 0x40
| Wakeup source Blue block Sleep Timer 2. More...
#define | WAKEUP_BOR 0xF0
| The Reset reason is not caused from a wakeup source but from a BOR reset. More...
#define | WAKEUP_POR 0xF1
| The Reset reason is not caused from a wakeup source but from a POR reset. More...
#define | WAKEUP_SYS_RESET_REQ 0xF2
| The Reset reason is not caused from a wakeup source but from a System reset request. More...
#define | WAKEUP_RESET_WDG 0xF3
| The Reset reason is not caused from a wakeup source but from a watchdog timer reset. More...
#define | NO_WAKEUP_RESET 0xFF;
| The Reset reason is not caused from a known wakeup source. More...
#define | WAKEUP_IO_LOW 0x00
| The system wakes up when IO is low. More...
#define | WAKEUP_IO_HIGH 0x01
| The system wakes up when IO is high. More...
#define | BLUENRG_SLEEP_CONFIGURATION_ERROR 0xFE
| Sleep Configuration Error. More...
#define | SLEEP_TIMER 0
| Number of virtual sleep timer used. More...

## Enumerations

enum | SleepModes { SLEEPMODE_RUNNING = 0, SLEEPMODE_CPU_HALT = 1, SLEEPMODE_WAKETIMER = 2, SLEEPMODE_NOTIMER = 3 }
| Enumerations for the possible microcontroller sleep modes. More...

## Functions

uint8_t | BlueNRG_Sleep (SleepModes sleepMode, uint8_t gpioWakeBitMask, uint8_t gpioWakeLevelMask, uint32_t sleep_time)
| Puts the BlueNRG in power save. The device can be configured with different wake sources according the sleepMode paramter. The most power save is obtained configuring the device in SLEEPMODE_NOTIMER because all the sources is turned off. When the wakeup occours, the CPU returns executing the next instruction after the call BlueNRG_Sleep() resoting the context. More...
SleepModes | App_SleepMode_Check (SleepModes sleepMode)
| This function shall check if the BlueNRG Sleep mode selected is safe in according with the application point of view. This is a weak function, can be modified from the application. More...
void | BlueNRG_IdleSleep (void)
| This function executes a wait for interrupt instruction and suspends the core execution until one of a number of events occurs. More...
uint8_t | BlueNRG_WakeupSource (void)
| Return the wakeup source from deep sleep. Possible value are: More...

## Detailed Description

Header file for BlueNRG Sleep management.

Author
  AMS - VMA RF Application team

Version
  V1.0.0

Date
  21-Sept-2015

Attention

THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

##
© COPYRIGHT 2015 STMicroelectronics

Definition in file sleep.h.

## Macro Definition Documentation

#define BLUENRG_SLEEP_CONFIGURATION_ERROR 0xFE

Sleep Configuration Error.

Definition at line 90 of file sleep.h.

#define NO_WAKEUP_RESET 0xFF;

The Reset reason is not caused from a known wakeup source.

Definition at line 81 of file sleep.h.

#define SLEEP_TIMER 0

Number of virtual sleep timer used.

Definition at line 93 of file sleep.h.

#define WAKEUP_BOR 0xF0

The Reset reason is not caused from a wakeup source but from a BOR reset.

Definition at line 69 of file sleep.h.

#define WAKEUP_IO10 0x02

Wakeup source IO10 Mask.

Definition at line 51 of file sleep.h.

#define WAKEUP_IO11 0x04

Wakeup source IO11 Mask.

Definition at line 54 of file sleep.h.

#define WAKEUP_IO12 0x08

Wakeup source IO12 Mask.

Definition at line 57 of file sleep.h.

#define WAKEUP_IO13 0x10

Wakeup source IO13 Mask.

Definition at line 60 of file sleep.h.

#define WAKEUP_IO9 0x01

Wakeup source IO9 Mask.

Definition at line 48 of file sleep.h.

#define WAKEUP_IO_HIGH 0x01

The system wakes up when IO is high.

Definition at line 87 of file sleep.h.

#define WAKEUP_IO_LOW 0x00

The system wakes up when IO is low.

Definition at line 84 of file sleep.h.

#define WAKEUP_POR 0xF1

The Reset reason is not caused from a wakeup source but from a POR reset.

Definition at line 72 of file sleep.h.

#define WAKEUP_RESET_WDG 0xF3

The Reset reason is not caused from a wakeup source but from a watchdog timer reset.

Definition at line 78 of file sleep.h.

#define WAKEUP_SLEEP_TIMER1 0x20

Wakeup source Blue block Sleep Timer 1.

Definition at line 63 of file sleep.h.

#define WAKEUP_SLEEP_TIMER2 0x40

Wakeup source Blue block Sleep Timer 2.

Definition at line 66 of file sleep.h.

#define WAKEUP_SYS_RESET_REQ 0xF2

The Reset reason is not caused from a wakeup source but from a System reset request.

Definition at line 75 of file sleep.h.

## Enumeration Type Documentation

enum SleepModes

Enumerations for the possible microcontroller sleep modes.

- SLEEPMODE_RUNNING Everything is active and running. In practice this mode is not used, but it is defined for completeness of information.
- SLEEPMODE_CPU_HALT Only the CPU is halted. The rest of the chip continues running normally. The chip will wake from any interrupt.
- SLEEPMODE_WAKETIMER The device is in deep sleep and the timer clock sources remain running. Wakeup is possible from both GPIO and the sleep timer.
- SLEEPMODE_NOTIMER The sleep timer clock sources are turned off. Wakeup is possible from only GPIO.

Enumerator
SLEEPMODE_RUNNING |
SLEEPMODE_CPU_HALT |
SLEEPMODE_WAKETIMER |
SLEEPMODE_NOTIMER |

Definition at line 40 of file sleep.h.

## Function Documentation

SleepModes App_SleepMode_Check | ( | SleepModes | sleepMode | ) |

This function shall check if the BlueNRG Sleep mode selected is safe in according with the application point of view. This is a weak function, can be modified from the application.

Parameters

  sleepMode | Sleep mode (see SleepModes enum)

Return values

  Return | the sleep mode possible and safe from the application point of view

void BlueNRG_IdleSleep | ( | void |  | ) |

This function executes a wait for interrupt instruction and suspends the core execution until one of a number of events occurs.

uint8_t BlueNRG_Sleep | ( | SleepModes | sleepMode,
|  | uint8_t | gpioWakeBitMask,
|  | uint8_t | gpioWakeLevelMask,
|  | uint32_t | sleep_time
| ) |  |

Puts the BlueNRG in power save. The device can be configured with different wake sources according the sleepMode paramter. The most power save is obtained configuring the device in SLEEPMODE_NOTIMER because all the sources is turned off. When the wakeup occours, the CPU returns executing the next instruction after the call BlueNRG_Sleep() resoting the context.

Parameters

  sleepMode | Sleep mode (see SleepModes enum)
  gpioWakeBitMask | A bit mask of the GPIO that are allowed to wake the chip from deep sleep. A high bit in the mask will enable waking the chip if the corresponding GPIO changes state. bit0 is IO9, bit1 is IO10, bit2 is IO11, bit3 is IO12, bit4 is IO13, bits[5:7] are ignored. If this param is 0 the wakeup GPIO are ignored
  gpioWakeLevelMask | A mask used to setup the active wakeup level:
  - 0: the system wakes up when IO is low
  - 1: the system wakes up when IO is high The bit mask follow the bit mask of the gpioWakeBitMask parameter.
  sleep_time | Deep sleep timeout. This timeout is expressed in ms. The device is put in deep sleep with this timeout. If this timeout is equal to zero, the power save procedure follows the timeout imposed from the BlueNRG-1 stack. The wakeup sources can be also the GPIOs.

Return values

  Status | of the call

uint8_t BlueNRG_WakeupSource | ( | void |  | ) |

Return the wakeup source from deep sleep. Possible value are:

- WAKEUP_IO9
- WAKEUP_IO10
- WAKEUP_IO11
- WAKEUP_IO12
- WAKEUP_IO13
- WAKEUP_SLEEP_TIMER1
- WAKEUP_SLEEP_TIMER2
- WAKEUP_BOR
- WAKEUP_POR
- WAKEUP_SYS_RESET_REQ
- WAKEUP_RESET_WDG
- NO_WAKEUP_RESET