atmega_common/include/cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
3  * 2014 Freie Universit├Ąt Berlin, Hinnerk van Bruinehsen
4  * 2018 RWTH Aachen, Josua Arndt <jarndt@ias.rwth-aachen.de>
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
30 #ifndef CPU_H
31 #define CPU_H
32 
33 #include <stdio.h>
34 #include <stdint.h>
35 
36 #include <avr/interrupt.h>
37 #include "cpu_conf.h"
38 
43 #include "irq.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
52 extern volatile uint8_t __in_isr;
53 
57 static inline void __enter_isr(void)
58 {
59  __in_isr = 1;
60 }
61 
65 static inline void __exit_isr(void)
66 {
67  __in_isr = 0;
68 }
69 
73 void cpu_init(void);
74 
78 __attribute__((always_inline)) static inline void cpu_print_last_instruction(void)
79 {
80  uint8_t hi;
81  uint8_t lo;
82  uint16_t ptr;
83 
84  __asm__ volatile( "in __tmp_reg__, __SP_H__ \n\t"
85  "mov %0, __tmp_reg__ \n\t"
86  : "=g"(hi) );
87 
88  __asm__ volatile( "in __tmp_reg__, __SP_L__ \n\t"
89  "mov %0, __tmp_reg__ \n\t"
90  : "=g"(lo) );
91  ptr = hi<<8 | lo;
92  printf("Stack Pointer: 0x%04x\n", ptr);
93 }
94 
98 void atmega_stdio_init(void);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* CPU_H */
105 
volatile uint8_t __in_isr
For downwards compatibility with old RIOT code.
static void __exit_isr(void)
Flag exiting of an ISR.
void cpu_init(void)
Initialization of the CPU.
void atmega_stdio_init(void)
Initializes avrlibc stdio.
static void __enter_isr(void)
Flag entering of an ISR.
stdio.h wrapper for MSP430
static void cpu_print_last_instruction(void)
Print the last instruction&#39;s address.
IRQ driver interface.