1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/lpc2387/include/cpu.h
Benjamin Valentin 32bbba2fc5 cpu/lpc2387: add support for backup RAM
lpc23xx has 2k of battery RAM that is retained in Deep Power Down mode.

To not overwrite that data it must only be initialized on Power On Reset.
However, RSIR looks the same when waking up from Deep Power Down as it does
on the power-on case.

So use 4 bytes of the backup RAM to keep a signature that is only valid if
memory was retained (no power-on Reset).

A small change to the linker script is required so two sections can be
placed into flash.
2019-11-28 11:33:03 +01:00

76 lines
1.5 KiB
C

/*
* Copyright (C) 2013, Freie Universitaet Berlin (FUB). All rights reserved.
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
#ifndef CPU_H
#define CPU_H
/**
* @defgroup cpu_lpc2387 NXP LPC2387
* @ingroup cpu
* @brief NXP LPC2387 specific code
* @{
*/
#include <stdio.h>
#include <stdbool.h>
#include "lpc2387.h"
#include "arm_cpu.h"
#ifdef __cplusplus
extern "C" {
#endif
extern uintptr_t __stack_start; /**< end of user stack memory space */
/**
* @brief Scale lpc2387 cpu speed
*/
void lpc2387_pclk_scale(uint32_t source, uint32_t target, uint32_t *pclksel, uint32_t *prescale);
/**
* @brief Initialize lpc2387 cpu clocks
*/
void cpu_init_clks(void);
/**
* @brief install lpc2387 irq
*/
bool install_irq(int IntNumber, void (*HandlerAddr)(void), int Priority);
#ifdef MODULE_PERIPH
void gpio_init_ports(void);
#endif
/**
* @brief Prints the current content of the link register (lr)
*/
static inline void cpu_print_last_instruction(void)
{
register uint32_t *lr_ptr;
__asm__ __volatile__("mov %0, lr" : "=r"(lr_ptr));
printf("%p\n", (void*) lr_ptr);
}
/**
* @brief Returns true if the CPU woke from Deep Sleep
*/
bool cpu_woke_from_backup(void);
/**
* @brief The CPU has RAM that is retained in the deepest sleep mode.
*/
#define CPU_HAS_BACKUP_RAM (1)
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* CPU_H */