Loading...
Searching...
No Matches
cpu.h File Reference

Common implementations and headers for AVR-8 family based micro-controllers. More...

Detailed Description

Common implementations and headers for AVR-8 family based micro-controllers.

Basic definitions for the AVR-8 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 stefa.nosp@m.n.pf.nosp@m.eiffe.nosp@m.r@fu.nosp@m.-berl.nosp@m.in.d.nosp@m.e
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de
Hinnerk van Bruinehsen h.v.b.nosp@m.ruin.nosp@m.ehsen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de
Kaspar Schleiser kaspa.nosp@m.r@sc.nosp@m.hleis.nosp@m.er.d.nosp@m.e
Josua Arndt jarnd.nosp@m.t@ia.nosp@m.s.rwt.nosp@m.h-aa.nosp@m.chen..nosp@m.de
Gerson Fernando Budke nando.nosp@m.jve@.nosp@m.gmail.nosp@m..com

Definition in file cpu.h.

#include <stdio.h>
#include <stdint.h>
#include <avr/interrupt.h>
#include "architecture.h"
#include "cpu_conf.h"
#include "cpu_clock.h"
#include "sched.h"
#include "thread.h"
#include "states_internal.h"
+ Include dependency graph for cpu.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CPU_CYCLES_PER_LOOP   (7)
 CPU cycles per busy wait loop.
 
#define AVR8_STATE_FLAG_UART_TX(uart)   (0x01U << uart)
 Compute UART TX channel.
 

Functions

static void avr8_enter_isr (void)
 Run this code on entering interrupt routines.
 
static void avr8_uart_tx_set_pending (unsigned uart)
 Set UART TX channel as pending.
 
static void avr8_uart_tx_clear_pending (unsigned uart)
 Clear UART TX channel pending state.
 
static int avr8_is_uart_tx_pending (void)
 Check if TX on any present UART device is still pending.
 
void avr8_exit_isr (void)
 Run this code on exiting interrupt routines.
 
void avr8_clk_init (void)
 Initialization of the CPU clock.
 
static uinttxtptr_t cpu_get_caller_pc (void)
 Get the last instruction's address.
 
void avr8_stdio_init (void)
 Initializes avrlibc stdio.
 
void avr8_reset_cause (void)
 Print reset cause.
 

BOD monitoring when CPU is on sleep

#define AVR8_PM_DISABLE_BOD_ON_SLEEP   0
 BOD is active on sleep.
 

Macro Definition Documentation

◆ AVR8_PM_DISABLE_BOD_ON_SLEEP

#define AVR8_PM_DISABLE_BOD_ON_SLEEP   0

BOD is active on sleep.

Definition at line 56 of file cpu.h.

◆ AVR8_STATE_FLAG_UART_TX

#define AVR8_STATE_FLAG_UART_TX (   uart)    (0x01U << uart)

Compute UART TX channel.

Parameters
uartThe UART number

Definition at line 92 of file cpu.h.

◆ CPU_CYCLES_PER_LOOP

#define CPU_CYCLES_PER_LOOP   (7)

CPU cycles per busy wait loop.

Definition at line 63 of file cpu.h.

◆ PERIPH_I2C_NEED_READ_REG

#define PERIPH_I2C_NEED_READ_REG

Definition at line 69 of file cpu.h.

◆ PERIPH_I2C_NEED_READ_REGS

#define PERIPH_I2C_NEED_READ_REGS

Definition at line 71 of file cpu.h.

◆ PERIPH_I2C_NEED_WRITE_REG

#define PERIPH_I2C_NEED_WRITE_REG

Definition at line 70 of file cpu.h.

◆ PERIPH_I2C_NEED_WRITE_REGS

#define PERIPH_I2C_NEED_WRITE_REGS

Definition at line 72 of file cpu.h.

Function Documentation

◆ avr8_enter_isr()

static void avr8_enter_isr ( void  )
inlinestatic

Run this code on entering interrupt routines.

Definition at line 78 of file cpu.h.

◆ avr8_is_uart_tx_pending()

static int avr8_is_uart_tx_pending ( void  )
inlinestatic

Check if TX on any present UART device is still pending.

Return values
!=0At least on UART device is still sending data out
0No UART is currently sending data

Definition at line 120 of file cpu.h.

◆ avr8_uart_tx_clear_pending()

static void avr8_uart_tx_clear_pending ( unsigned  uart)
inlinestatic

Clear UART TX channel pending state.

Parameters
uartThe UART number

Definition at line 109 of file cpu.h.

◆ avr8_uart_tx_set_pending()

static void avr8_uart_tx_set_pending ( unsigned  uart)
inlinestatic

Set UART TX channel as pending.

Parameters
uartThe UART number

Definition at line 99 of file cpu.h.

◆ cpu_get_caller_pc()

static uinttxtptr_t cpu_get_caller_pc ( void  )
inlinestatic

Get the last instruction's address.

This works only if called in a function as first statement, as it relies on the return address to be the topmost item on the stack.

Definition at line 141 of file cpu.h.