From 9e4c08d89c9838465a09bc33770c451cffd3a9b5 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Wed, 6 Apr 2016 17:13:31 +0200 Subject: [PATCH] cpu/atmega2560: added CMSIS style defs for timers --- cpu/atmega2560/include/atmega2560_regs.h | 74 ++++++++++++++++++++++++ cpu/atmega2560/include/cpu_conf.h | 2 + 2 files changed, 76 insertions(+) create mode 100644 cpu/atmega2560/include/atmega2560_regs.h diff --git a/cpu/atmega2560/include/atmega2560_regs.h b/cpu/atmega2560/include/atmega2560_regs.h new file mode 100644 index 0000000000..2db8a7a16d --- /dev/null +++ b/cpu/atmega2560/include/atmega2560_regs.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2016 Freie Universität Berlin + * + * 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. + */ + +/** + * @ingroup cpu_atmega2560 + * @{ + * + * @file + * @brief CMSIS style register definitions for the atmega2560 + * + * @author Hauke Petersen + */ + +#ifndef ATMEGA2560_REGS_H +#define ATMEGA2560_REGS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Register types + * @{ + */ +#define REG8 volatile uint8_t +#define REG16 volatile uint16_t +/** @} */ + +/** + * @brief Timer register map + */ +typedef struct { + REG8 CRA; /**< control A */ + REG8 CRB; /**< control B */ + REG8 CRC; /**< control C */ + REG8 reserved; /**< reserved */ + REG16 CNT; /**< counter */ + REG16 ICR; /**< input capture */ + REG16 OCR[3]; /**< output compare */ +} mega_timer_t; + +/** + * @brief Base register address definitions + * @{ + */ +#define MEGA_TIMER1_BASE (uint16_t *)(&TCCR1A) +#define MEGA_TIMER3_BASE (uint16_t *)(&TCCR3A) +#define MEGA_TIMER4_BASE (uint16_t *)(&TCCR4A) +#define MEGA_TIMER5_BASE (uint16_t *)(&TCCR5A) +/** @} */ + +/** + * @brief Peripheral instances + * @{ + */ +#define MEGA_TIMER1 ((mega_timer_t *)MEGA_TIMER1_BASE) +#define MEGA_TIMER3 ((mega_timer_t *)MEGA_TIMER3_BASE) +#define MEGA_TIMER4 ((mega_timer_t *)MEGA_TIMER4_BASE) +#define MEGA_TIMER5 ((mega_timer_t *)MEGA_TIMER5_BASE) +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ATMEGA2560_REGS_H */ +/** @} */ diff --git a/cpu/atmega2560/include/cpu_conf.h b/cpu/atmega2560/include/cpu_conf.h index 0cdbd30058..4ebd7ee854 100644 --- a/cpu/atmega2560/include/cpu_conf.h +++ b/cpu/atmega2560/include/cpu_conf.h @@ -7,6 +7,7 @@ */ /** + * @ingroup cpu_atmega2560 * @{ * * @file @@ -19,6 +20,7 @@ #ifndef __CPU_CONF_H #define __CPU_CONF_H +#include "atmega2560_regs.h" #ifdef __cplusplus extern "C" {