From d7cc12cbad0e196e5352d81cd839d077c549768c Mon Sep 17 00:00:00 2001 From: Theodore Ateba Date: Thu, 22 Dec 2022 22:13:49 +0000 Subject: [PATCH] [AVR] Add ATxmega CRC register definition for lld driver. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15903 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/hal/ports/AVR/XMEGA/LLD/CRCv1/driver.mk | 11 ++ os/hal/ports/AVR/XMEGA/LLD/CRCv1/xmega_crc.h | 131 +++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 os/hal/ports/AVR/XMEGA/LLD/CRCv1/driver.mk create mode 100644 os/hal/ports/AVR/XMEGA/LLD/CRCv1/xmega_crc.h diff --git a/os/hal/ports/AVR/XMEGA/LLD/CRCv1/driver.mk b/os/hal/ports/AVR/XMEGA/LLD/CRCv1/driver.mk new file mode 100644 index 000000000..9d1ba079c --- /dev/null +++ b/os/hal/ports/AVR/XMEGA/LLD/CRCv1/driver.mk @@ -0,0 +1,11 @@ +ifeq ($(USE_SMART_BUILD),yes) +ifneq ($(findstring HAL_USE_CRC TRUE,$(HALCONF)),) +PLATFORMSRC += $(CHIBIOS)/os/hal/ports/AVR/XMEGA/LLD/CRCv1/hal_crc_lld.c +PLATFORMSRC += $(CHIBIOS)/os/hal/ports/AVR/XMEGA/LLD/CRCv1/hal_crc.c +endif +else +PLATFORMSRC += $(CHIBIOS)/os/hal/ports/AVR/XMEGA/LLD/CRCv1/hal_crc_lld.c +PLATFORMSRC += $(CHIBIOS)/os/hal/ports/AVR/XMEGA/LLD/CRCv1/hal_crc.c +endif + +PLATFORMINC += $(CHIBIOS)/os/hal/ports/AVR/XMEGA/LLD/CRCv1 diff --git a/os/hal/ports/AVR/XMEGA/LLD/CRCv1/xmega_crc.h b/os/hal/ports/AVR/XMEGA/LLD/CRCv1/xmega_crc.h new file mode 100644 index 000000000..29d480974 --- /dev/null +++ b/os/hal/ports/AVR/XMEGA/LLD/CRCv1/xmega_crc.h @@ -0,0 +1,131 @@ +/* + ChibiOS - Copyright (C) 2006..2022 Theodore Ateba + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file CRCv1/xmega_crc.h + * @brief XMEGA CRC units common header. + * @note This file requires definitions from the ATMEL XMEGA header file. + * + * @addtogroup XMEGA_CRCv1 + * @{ + */ + +#ifndef XMEGA_CRC_H +#define XMEGA_CRC_H + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/** + * @brief CRC module base address. + */ +#define CRC_BASE 0x00D0 + +/** + * @note Discarded definition from Atmel ATxmega headers. + * The CRC driver uses its own definition in order to have an + * unified handling for all devices. + */ +#undef CRC + +/** + * @name CRC Cyclic redondancy check definitions. + * @{ + */ +#define CRC ((xmega_crc_t *)CRC_BASE) +/** @} */ + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/** + * @brief XMEGA CRC registers block. + */ +typedef struct { + + volatile union { + uint8_t reg; + struct { + uint8_t SOURCE : 4; + uint8_t : 1; + uint8_t CRC32 : 1; + uint8_t RESET : 2; + } bit; + } CTRL; + volatile union { + uint8_t reg; + struct { + uint8_t BUSY : 1; + uint8_t ZERO : 1; + uint8_t : 6; + } bit; + } STATUS; + uint8_t reserved1; + volatile union { + uint8_t reg; + struct { + uint8_t DATAIN : 8; + } bit; + } DATAIN; + volatile union { + uint8_t reg; + struct { + uint8_t CHECKSUM : 8; + } bit; + } CHECKSUM0; + volatile union { + uint8_t reg; + struct { + uint8_t CHECKSUM : 8; + } bit; + } CHECKSUM1; + volatile union { + uint8_t reg; + struct { + uint8_t CHECKSUM : 8; + } bit; + } CHECKSUM2; + volatile union { + uint8_t reg; + struct { + uint8_t CHECKSUM : 8; + } bit; + } CHECKSUM3; +} xmega_crc_t; + +/** @} */ + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#endif /* XMEGA_CRC_H */ + +/** @} */