1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/atmega_common/include/cpu.h

106 lines
2.4 KiB
C
Raw Normal View History

2014-07-15 12:08:52 +02:00
/*
2015-09-14 00:27:27 +02:00
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
* 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
* 2018 RWTH Aachen, Josua Arndt <jarndt@ias.rwth-aachen.de>
2014-07-15 12:08:52 +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-12-06 01:12:31 +01:00
* @ingroup cpu_atmega_common
2014-07-15 12:08:52 +02:00
* @brief Common implementations and headers for ATmega family based micro-controllers
* @{
*
* @file
* @brief Basic definitions for the ATmega common module
*
* When ever you want to do something hardware related, that is accessing MCUs registers directly,
* just include this file. It will then make sure that the MCU specific headers are included.
*
* @author Stefan Pfeiffer <stefan.pfeiffer@fu-berlin.de>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
2015-09-14 00:27:27 +02:00
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Josua Arndt <jarndt@ias.rwth-aachen.de>
*
2014-07-15 12:08:52 +02:00
*/
#ifndef CPU_H
#define CPU_H
2014-07-15 12:08:52 +02:00
#include <stdio.h>
2015-09-14 00:27:27 +02:00
#include <stdint.h>
2014-07-15 12:08:52 +02:00
2015-09-14 00:27:27 +02:00
#include <avr/interrupt.h>
#include "cpu_conf.h"
2014-07-15 12:08:52 +02:00
/**
* For downwards compatibility with old RIOT code.
* TODO: remove once core was adjusted
*/
#include "irq.h"
2014-10-13 10:53:20 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2015-09-14 00:27:27 +02:00
/**
* @brief global in-ISR state variable
*/
extern volatile uint8_t __in_isr;
/**
* @brief Flag entering of an ISR
*/
static inline void __enter_isr(void)
{
__in_isr = 1;
}
/**
* @brief Flag exiting of an ISR
*/
static inline void __exit_isr(void)
{
__in_isr = 0;
}
2014-07-15 12:08:52 +02:00
/**
* @brief Initialization of the CPU
*/
void cpu_init(void);
/**
* @brief Print the last instruction's address
*
* @todo: Not supported
*/
static inline void cpu_print_last_instruction(void)
{
uint8_t hi;
uint8_t lo;
uint16_t ptr;
__asm__ volatile( "in r0, __SP_H__; \n\t"
"mov %0, r0 \n\t"
: "=g"(hi)
:
: "r0");
__asm__ volatile( "in r0, __SP_L__; \n\t"
"mov %0, r0 \n\t"
: "=g"(lo)
:
: "r0");
ptr = hi<<8 | lo;
printf("Stack Pointer: 0x%04x\n", ptr);
}
2014-10-13 10:53:20 +02:00
#ifdef __cplusplus
}
#endif
2014-07-15 12:08:52 +02:00
#endif /* CPU_H */
2014-07-15 12:08:52 +02:00
/** @} */