Go to the documentation of this file.
36 #include <avr/interrupt.h>
50 #define PERIPH_I2C_NEED_READ_REG
51 #define PERIPH_I2C_NEED_WRITE_REG
52 #define PERIPH_I2C_NEED_READ_REGS
53 #define PERIPH_I2C_NEED_WRITE_REGS
60 #define ATMEGA_STATE_FLAG_ISR (0x80U)
61 #define ATMEGA_STATE_FLAG_UART0_TX (0x01U)
62 #define ATMEGA_STATE_FLAG_UART1_TX (0x02U)
63 #define ATMEGA_STATE_FLAG_UART_TX(x) (0x01U << x)
88 extern uint8_t atmega_state;
107 "lds %[state], atmega_state \n\t"
108 : [state]
"=r" (state)
160 __asm__
volatile (
"in __tmp_reg__, __SP_H__ \n\t"
161 "mov %0, __tmp_reg__ \n\t"
164 __asm__
volatile (
"in __tmp_reg__, __SP_L__ \n\t"
165 "mov %0, __tmp_reg__ \n\t"
168 printf(
"Stack Pointer: 0x%04x\n", ptr);
177 CPU_ATMEGA_CLK_SCALE_DIV1 = 0,
178 CPU_ATMEGA_CLK_SCALE_DIV2 = 1,
179 CPU_ATMEGA_CLK_SCALE_DIV4 = 2,
180 CPU_ATMEGA_CLK_SCALE_DIV8 = 3,
181 CPU_ATMEGA_CLK_SCALE_DIV16 = 4,
182 CPU_ATMEGA_CLK_SCALE_DIV32 = 5,
183 CPU_ATMEGA_CLK_SCALE_DIV64 = 6,
184 CPU_ATMEGA_CLK_SCALE_DIV128 = 7,
185 CPU_ATMEGA_CLK_SCALE_DIV256 = 8,
186 CPU_ATMEGA_CLK_SCALE_DIV512 = 9,
196 CLKPR = (1 << CLKPCE);
void atmega_stdio_init(void)
Initializes avrlibc stdio.
static void atmega_set_prescaler(uint8_t clk_scale)
Initializes system clock prescaler.
#define ATMEGA_STATE_FLAG_ISR
In ISR.
static int atmega_is_uart_tx_pending(void)
Check if TX on any present UART device is still pending.
static void atmega_enter_isr(void)
Run this code on entering interrupt routines.
Scheduler API definition.
static uint8_t atmega_get_state(void)
Atomically read the state (atmega_state)
uint8_t atmega_state
Global variable containing the current state of the MCU.
void cpu_init(void)
Initialization of the CPU.
void atmega_exit_isr(void)
Run this code on exiting interrupt routines.
#define ATMEGA_STATE_FLAG_UART1_TX
TX pending for UART 1.
#define ATMEGA_STATE_FLAG_UART0_TX
TX pending for UART 0.
Implementation specific CPU configuration options.
static void cpu_print_last_instruction(void)
Print the last instruction's address.