2014-03-26 18:13:43 +01:00
|
|
|
/*
|
2015-05-18 18:47:17 +02:00
|
|
|
* Copyright (C) 2014-2015 Freie Universität Berlin
|
2014-03-26 18:13:43 +01:00
|
|
|
*
|
2014-08-23 15:43:13 +02:00
|
|
|
* 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.
|
2014-03-26 18:13:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2015-05-18 18:47:17 +02:00
|
|
|
* @defgroup cpu_cortexm_common ARM Cortex-M common
|
2015-01-14 12:40:07 +01:00
|
|
|
* @ingroup cpu
|
2015-05-18 18:47:17 +02:00
|
|
|
* @brief Common implementations and headers for Cortex-M family based
|
|
|
|
* micro-controllers
|
2014-03-26 18:13:43 +01:00
|
|
|
* @{
|
|
|
|
*
|
2014-10-21 16:52:30 +02:00
|
|
|
* @file
|
2015-05-18 18:47:17 +02:00
|
|
|
* @brief Basic definitions for the Cortex-M common module
|
2014-03-26 18:13:43 +01:00
|
|
|
*
|
2015-05-18 18:47:17 +02:00
|
|
|
* When ever you want to do something hardware related, that is accessing MCUs
|
|
|
|
* registers, just include this file. It will then make sure that the MCU
|
|
|
|
* specific headers are included.
|
2014-03-26 18:13:43 +01:00
|
|
|
*
|
|
|
|
* @author Stefan Pfeiffer <stefan.pfeiffer@fu-berlin.de>
|
|
|
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
2015-09-20 13:47:39 +02:00
|
|
|
* @author Joakim Nohlgård <joakim.nohlgard@eistec.se>
|
2015-07-31 22:13:48 +02:00
|
|
|
*
|
|
|
|
* @todo remove include irq.h once core was adjusted
|
2014-03-26 18:13:43 +01:00
|
|
|
*/
|
|
|
|
|
2015-05-27 21:57:55 +02:00
|
|
|
#ifndef CPU_H_
|
|
|
|
#define CPU_H_
|
2015-04-28 22:57:56 +02:00
|
|
|
|
2015-09-04 16:51:08 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2015-05-22 14:31:23 +02:00
|
|
|
#include "cpu_conf.h"
|
2014-03-26 18:13:43 +01:00
|
|
|
#include "irq.h"
|
2014-10-13 10:53:20 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-05-27 21:57:55 +02:00
|
|
|
/**
|
|
|
|
* @brief Configuration of default stack sizes
|
|
|
|
*
|
|
|
|
* As all members of the Cortex-M family behave identical in terms of stack
|
|
|
|
* usage, we define the default stack size values here centrally for all CPU
|
|
|
|
* implementations.
|
|
|
|
*
|
|
|
|
* If needed, you can overwrite these values the the `cpu_conf.h` file of the
|
|
|
|
* specific CPU implementation.
|
|
|
|
*
|
2015-07-31 22:13:48 +02:00
|
|
|
* @todo Adjust values for Cortex-M4F with FPU?
|
|
|
|
* @todo Configure second set if no newlib nano.specs are available?
|
2015-05-27 21:57:55 +02:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#ifndef THREAD_EXTRA_STACKSIZE_PRINTF
|
|
|
|
#define THREAD_EXTRA_STACKSIZE_PRINTF (512)
|
|
|
|
#endif
|
|
|
|
#ifndef THREAD_STACKSIZE_DEFAULT
|
|
|
|
#define THREAD_STACKSIZE_DEFAULT (1024)
|
|
|
|
#endif
|
|
|
|
#ifndef THREAD_STACKSIZE_IDLE
|
|
|
|
#define THREAD_STACKSIZE_IDLE (256)
|
|
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
|
2014-03-26 18:13:43 +01:00
|
|
|
/**
|
2015-05-27 21:57:55 +02:00
|
|
|
* @brief Some members of the Cortex-M family have architecture specific
|
|
|
|
* atomic operations in atomic_arch.c
|
2015-05-18 18:47:17 +02:00
|
|
|
*/
|
|
|
|
#if defined(CPU_ARCH_CORTEX_M3) || defined(CPU_ARCH_CORTEX_M4) || \
|
|
|
|
defined(CPU_ARCH_CORTEX_M4F)
|
|
|
|
#define ARCH_HAS_ATOMIC_COMPARE_AND_SWAP 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialization of the CPU
|
2014-03-26 18:13:43 +01:00
|
|
|
*/
|
|
|
|
void cpu_init(void);
|
|
|
|
|
2015-05-27 21:57:55 +02:00
|
|
|
/**
|
|
|
|
* @brief Initialize Cortex-M specific core parts of the CPU
|
|
|
|
*/
|
|
|
|
void cortexm_init(void);
|
|
|
|
|
2015-09-04 16:51:08 +02:00
|
|
|
/**
|
|
|
|
* @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));
|
2015-09-04 16:50:25 +02:00
|
|
|
printf("%p\n", lr_ptr);
|
2015-09-04 16:51:08 +02:00
|
|
|
}
|
|
|
|
|
2014-10-13 10:53:20 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2014-03-26 18:13:43 +01:00
|
|
|
|
2015-05-27 21:57:55 +02:00
|
|
|
#endif /* CPU_H_ */
|
2014-03-26 18:13:43 +01:00
|
|
|
/** @} */
|