This is the quick start guide for the BPM Module, with step-by-step instructions on how to configure and use the driver in a selection of use cases.
The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.
BPM use cases
Basic use case - Entering Sleep Modes
In this use case, the BPM module can put system into different power saving modes. Check the current of the system to see consumptions.
Setup
Prerequisites
Sleep mode itself does not require any IO input, but to wakeup an interrupt is needed.
- Common IOPORT (for GPIO)
- External Interrupt Controller (EIC)
Code
The following code needs to be added to the user application, to wakeup system and switch to next power mode.
static void push_button_eic_handler()
{
eic_line_clear_interrupt(EIC, GPIO_PUSH_BUTTON_EIC_LINE);
}
my_eic_init()
{
struct eic_line_config eic_opt={
EIC_MODE_EDGE_TRIGGERED,
EIC_EDGE_FALLING_EDGE,
EIC_LEVEL_LOW_LEVEL,
EIC_FILTER_DISABLED,
EIC_ASYNCH_MODE
};
eic_enable(EIC);
eic_line_set_config(EIC, GPIO_PUSH_BUTTON_EIC_LINE, &eic_opt);
eic_line_set_callback(EIC, GPIO_PUSH_BUTTON_EIC_LINE,
push_button_eic_handler, EIC_5_IRQn, 1);
eic_line_enable(EIC, GPIO_PUSH_BUTTON_EIC_LINE);
}
Workflow
- Ensure that ioport and eic driver is available.
- Ensure that push button is configured as external interrupt in conf_board.h:
- Add EIC initialize to application C-file:
Use case
Example code
Add to application C-file:
Workflow
- Enable wakeup by EIC:
- Setup IO retention:
- Setup fast wakeup:
- Enter sleep/wait/backup mode: