Landtiger LPC1768 C BigLib 1
A self made, custom C library for the LandTiger board.
 
Loading...
Searching...
No Matches
power.c File Reference
#include "power.h"
#include <LPC17xx.h>

Go to the source code of this file.

Functions

void POWER_Init (u8 config)
 Configures sleep/power down mode for the device.
 
void POWER_SleepOnWFI (void)
 WFI/WFE puts device to sleep or deep sleep mode depending on the configuration specified in the POWER_Init function.
 
void POWER_PowerDownOnWFI (void)
 WFI/WFE puts device to power down power down mode.
 
void POWER_DeepPowerDownOnWFI (void)
 WFI/WFE puts device to deep power down mode provided that the SLEEPDEEP bit is set.
 
void POWER_TurnOnPeripheral (u8 bit)
 Turns on a peripheral.
 
void POWER_TurnOffPeripheral (u8 bit)
 Turns off a peripheral.
 
void POWER_WaitForInterrupts (void)
 

Function Documentation

◆ POWER_DeepPowerDownOnWFI()

void POWER_DeepPowerDownOnWFI ( void  )

WFI/WFE puts device to deep power down mode provided that the SLEEPDEEP bit is set.

Definition at line 20 of file power.c.

21{
22 LPC_SC->PCON |= 0x3; // 11
23}

◆ POWER_Init()

void POWER_Init ( u8  config)

Configures sleep/power down mode for the device.

Parameters
configSettings for the power module (Use DEEP mode, and SLEEPONEXIT)
sleep_on_exitWhether to enter sleep mode on exit from an ISR

Definition at line 4 of file power.c.

5{
6 SCB->SCR |= (config & POWR_CFG_SLEEP_ON_EXIT);
7 SCB->SCR |= (config & POWR_CFG_DEEP);
8}
@ POWR_CFG_SLEEP_ON_EXIT
Definition power_types.h:7
@ POWR_CFG_DEEP
Definition power_types.h:6

◆ POWER_PowerDownOnWFI()

void POWER_PowerDownOnWFI ( void  )

WFI/WFE puts device to power down power down mode.

Definition at line 15 of file power.c.

16{
17 SET_BIT(LPC_SC->PCON, 0); // 01
18}
#define SET_BIT(reg, bit)
Definition types.h:26

◆ POWER_SleepOnWFI()

void POWER_SleepOnWFI ( void  )

WFI/WFE puts device to sleep or deep sleep mode depending on the configuration specified in the POWER_Init function.

Definition at line 10 of file power.c.

11{
12 LPC_SC->PCON &= ~0x3; // Sets B[1,0] = 00
13}

◆ POWER_TurnOffPeripheral()

void POWER_TurnOffPeripheral ( u8  bit)

Turns off a peripheral.

Parameters
peripheralThe bit # of the peripheral to turn off, defined in the POWER_Peripheral enum. If not present, the bit can be found in the user manual @ Table 46.

Definition at line 30 of file power.c.

31{
32 CLR_BIT(LPC_SC->PCONP, bit);
33}
#define CLR_BIT(reg, bit)
Definition types.h:27

◆ POWER_TurnOnPeripheral()

void POWER_TurnOnPeripheral ( u8  bit)

Turns on a peripheral.

Parameters
peripheralThe bit # of the peripheral to turn on, defined in the POWER_Peripheral enum. If not present, the bit can be found in the user manual @ Table 46.

Definition at line 25 of file power.c.

26{
27 SET_BIT(LPC_SC->PCONP, bit);
28}

◆ POWER_WaitForInterrupts()

void POWER_WaitForInterrupts ( void  )

Definition at line 35 of file power.c.

36{
37 __asm volatile("wfi");
38}