diff --git a/docs/peripheral.md b/docs/peripheral.md index f0ae48a..e028d6f 100644 --- a/docs/peripheral.md +++ b/docs/peripheral.md @@ -262,16 +262,6 @@ The `::picolibrary::Microchip::megaAVR0::Peripheral::WDT` class is defined in th header/source file pair. ## Peripheral Instances -The `::picolibrary::Microchip::megaAVR0::Peripheral::Instance` template class is used to -define Microchip megaAVR 0-series peripheral instances. -The `::picolibrary::Microchip::megaAVR0::Peripheral::Instance` template class is defined -in the -[`include/picolibrary/microchip/megaavr0/peripheral/instance.h`](https://github.com/apcountryman/picolibrary-microchip-megaavr0/blob/main/include/picolibrary/microchip/megaavr0/peripheral/instance.h)/[`source/picolibrary/microchip/megaavr0/peripheral/instance.cc`](https://github.com/apcountryman/picolibrary-microchip-megaavr0/blob/main/source/picolibrary/microchip/megaavr0/peripheral/instance.cc) -header/source file pair. -- To access a peripheral instance, use the - `::picolibrary::Microchip::megaAVR0::Peripheral::Instance::instance()` static member - function. - Microchip megaAVR 0-series peripheral instances are defined in the [`include/picolibrary/microchip/megaavr0/peripheral.h`](https://github.com/apcountryman/picolibrary-microchip-megaavr0/blob/main/include/picolibrary/microchip/megaavr0/peripheral.h)/[`source/picolibrary/microchip/megaavr0/peripheral.cc`](https://github.com/apcountryman/picolibrary-microchip-megaavr0/blob/main/source/picolibrary/microchip/megaavr0/peripheral.cc) header/source file pair. diff --git a/include/picolibrary/microchip/megaavr0/peripheral.h b/include/picolibrary/microchip/megaavr0/peripheral.h index d73fb24..2781387 100644 --- a/include/picolibrary/microchip/megaavr0/peripheral.h +++ b/include/picolibrary/microchip/megaavr0/peripheral.h @@ -32,7 +32,6 @@ #include "picolibrary/microchip/megaavr0/peripheral/crcscan.h" #include "picolibrary/microchip/megaavr0/peripheral/evsys.h" #include "picolibrary/microchip/megaavr0/peripheral/fuse.h" -#include "picolibrary/microchip/megaavr0/peripheral/instance.h" #include "picolibrary/microchip/megaavr0/peripheral/nvmctrl.h" #include "picolibrary/microchip/megaavr0/peripheral/port.h" #include "picolibrary/microchip/megaavr0/peripheral/portmux.h" @@ -50,6 +49,7 @@ #include "picolibrary/microchip/megaavr0/peripheral/vport.h" #include "picolibrary/microchip/megaavr0/peripheral/vref.h" #include "picolibrary/microchip/megaavr0/peripheral/wdt.h" +#include "picolibrary/peripheral.h" /** * \brief Microchip megaAVR 0-series peripheral facilities. @@ -59,230 +59,230 @@ namespace picolibrary::Microchip::megaAVR0::Peripheral { /** * \brief VPORTA. */ -using VPORTA = Instance; +using VPORTA = ::picolibrary::Peripheral::Instance; #if defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) \ || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief VPORTB. */ -using VPORTB = Instance; +using VPORTB = ::picolibrary::Peripheral::Instance; #endif // defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief VPORTC. */ -using VPORTC = Instance; +using VPORTC = ::picolibrary::Peripheral::Instance; /** * \brief VPORTD. */ -using VPORTD = Instance; +using VPORTD = ::picolibrary::Peripheral::Instance; #if defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) \ || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief VPORTE. */ -using VPORTE = Instance; +using VPORTE = ::picolibrary::Peripheral::Instance; #endif // defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief VPORTF. */ -using VPORTF = Instance; +using VPORTF = ::picolibrary::Peripheral::Instance; /** * \brief RSTCTRL0. */ -using RSTCTRL0 = Instance; +using RSTCTRL0 = ::picolibrary::Peripheral::Instance; /** * \brief SLPCTRL0. */ -using SLPCTRL0 = Instance; +using SLPCTRL0 = ::picolibrary::Peripheral::Instance; /** * \brief CLKCTRL0. */ -using CLKCTRL0 = Instance; +using CLKCTRL0 = ::picolibrary::Peripheral::Instance; /** * \brief BOD0. */ -using BOD0 = Instance; +using BOD0 = ::picolibrary::Peripheral::Instance; /** * \brief VREF0. */ -using VREF0 = Instance; +using VREF0 = ::picolibrary::Peripheral::Instance; /** * \brief WDT0. */ -using WDT0 = Instance; +using WDT0 = ::picolibrary::Peripheral::Instance; /** * \brief CPUINT0. */ -using CPUINT0 = Instance; +using CPUINT0 = ::picolibrary::Peripheral::Instance; /** * \brief CRCSCAN0. */ -using CRCSCAN0 = Instance; +using CRCSCAN0 = ::picolibrary::Peripheral::Instance; /** * \brief RTC0. */ -using RTC0 = Instance; +using RTC0 = ::picolibrary::Peripheral::Instance; /** * \brief EVSYS0. */ -using EVSYS0 = Instance; +using EVSYS0 = ::picolibrary::Peripheral::Instance; /** * \brief CCL0. */ -using CCL0 = Instance; +using CCL0 = ::picolibrary::Peripheral::Instance; /** * \brief PORTA. */ -using PORTA = Instance; +using PORTA = ::picolibrary::Peripheral::Instance; #if defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) \ || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief PORTB. */ -using PORTB = Instance; +using PORTB = ::picolibrary::Peripheral::Instance; #endif // defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief PORTC. */ -using PORTC = Instance; +using PORTC = ::picolibrary::Peripheral::Instance; /** * \brief PORTD. */ -using PORTD = Instance; +using PORTD = ::picolibrary::Peripheral::Instance; #if defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) \ || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief PORTE. */ -using PORTE = Instance; +using PORTE = ::picolibrary::Peripheral::Instance; #endif // defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief PORTF. */ -using PORTF = Instance; +using PORTF = ::picolibrary::Peripheral::Instance; /** * \brief PORTMUX0. */ -using PORTMUX0 = Instance; +using PORTMUX0 = ::picolibrary::Peripheral::Instance; /** * \brief ADC0. */ -using ADC0 = Instance; +using ADC0 = ::picolibrary::Peripheral::Instance; /** * \brief AC0. */ -using AC0 = Instance; +using AC0 = ::picolibrary::Peripheral::Instance; /** * \brief USART0. */ -using USART0 = Instance; +using USART0 = ::picolibrary::Peripheral::Instance; /** * \brief USART1. */ -using USART1 = Instance; +using USART1 = ::picolibrary::Peripheral::Instance; /** * \brief USART2. */ -using USART2 = Instance; +using USART2 = ::picolibrary::Peripheral::Instance; #if defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) \ || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief USART3. */ -using USART3 = Instance; +using USART3 = ::picolibrary::Peripheral::Instance; #endif // defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief TWI0. */ -using TWI0 = Instance; +using TWI0 = ::picolibrary::Peripheral::Instance; /** * \brief SPI0. */ -using SPI0 = Instance; +using SPI0 = ::picolibrary::Peripheral::Instance; /** * \brief TCA0. */ -using TCA0 = Instance; +using TCA0 = ::picolibrary::Peripheral::Instance; /** * \brief TCB0. */ -using TCB0 = Instance; +using TCB0 = ::picolibrary::Peripheral::Instance; /** * \brief TCB1. */ -using TCB1 = Instance; +using TCB1 = ::picolibrary::Peripheral::Instance; /** * \brief TCB2. */ -using TCB2 = Instance; +using TCB2 = ::picolibrary::Peripheral::Instance; #if defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) \ || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief TCB3. */ -using TCB3 = Instance; +using TCB3 = ::picolibrary::Peripheral::Instance; #endif // defined( __AVR_ATmega809__ ) || defined( __AVR_ATmega1609__ ) || defined( __AVR_ATmega3209__ ) || defined( __AVR_ATmega4809__ ) /** * \brief SYSCFG0. */ -using SYSCFG0 = Instance; +using SYSCFG0 = ::picolibrary::Peripheral::Instance; /** * \brief NVMCTRL0. */ -using NVMCTRL0 = Instance; +using NVMCTRL0 = ::picolibrary::Peripheral::Instance; /** * \brief SIGROW0. */ -using SIGROW0 = Instance; +using SIGROW0 = ::picolibrary::Peripheral::Instance; /** * \brief FUSE0. */ -using FUSE0 = Instance; +using FUSE0 = ::picolibrary::Peripheral::Instance; /** * \brief USERROW0. */ -using USERROW0 = Instance; +using USERROW0 = ::picolibrary::Peripheral::Instance; } // namespace picolibrary::Microchip::megaAVR0::Peripheral diff --git a/include/picolibrary/microchip/megaavr0/peripheral/instance.h b/include/picolibrary/microchip/megaavr0/peripheral/instance.h deleted file mode 100644 index 2da3b1a..0000000 --- a/include/picolibrary/microchip/megaavr0/peripheral/instance.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * picolibrary-microchip-megaavr0 - * - * Copyright 2021-2023, Andrew Countryman and the - * picolibrary-microchip-megaavr0 contributors - * - * 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 - * \brief picolibrary::Microchip::megaAVR0::Peripheral::Instance interface. - */ - -#ifndef PICOLIBRARY_MICROCHIP_MEGAAVR0_PERIPHERAL_INSTANCE_H -#define PICOLIBRARY_MICROCHIP_MEGAAVR0_PERIPHERAL_INSTANCE_H - -#include - -namespace picolibrary::Microchip::megaAVR0::Peripheral { - -/** - * \brief Microchip megaAVR 0-series peripheral instance. - * - * \tparam T The peripheral type. - * \tparam INSTANCE_ADDRESS The address of the peripheral instance. - */ -template -class Instance { - public: - /** - * \brief The peripheral type. - */ - using Type = T; - - /** - * \brief The address of the peripheral instance. - */ - static constexpr auto ADDRESS = INSTANCE_ADDRESS; - - /** - * \brief Access the peripheral instance. - * - * \return The peripheral instance. - */ - static auto instance() noexcept -> Type & - { - return *reinterpret_cast( ADDRESS ); - } - - Instance() = delete; - - Instance( Instance && ) = delete; - - Instance( Instance const & ) = delete; - - ~Instance() = delete; - - auto operator=( Instance && ) = delete; - - auto operator=( Instance const & ) = delete; -}; - -} // namespace picolibrary::Microchip::megaAVR0::Peripheral - -#endif // PICOLIBRARY_MICROCHIP_MEGAAVR0_PERIPHERAL_INSTANCE_H diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index d2de882..c7e6651 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -44,7 +44,6 @@ set( "picolibrary/microchip/megaavr0/peripheral/crcscan.cc" "picolibrary/microchip/megaavr0/peripheral/evsys.cc" "picolibrary/microchip/megaavr0/peripheral/fuse.cc" - "picolibrary/microchip/megaavr0/peripheral/instance.cc" "picolibrary/microchip/megaavr0/peripheral/nvmctrl.cc" "picolibrary/microchip/megaavr0/peripheral/port.cc" "picolibrary/microchip/megaavr0/peripheral/portmux.cc" diff --git a/source/picolibrary/microchip/megaavr0/peripheral/instance.cc b/source/picolibrary/microchip/megaavr0/peripheral/instance.cc deleted file mode 100644 index e6ceea6..0000000 --- a/source/picolibrary/microchip/megaavr0/peripheral/instance.cc +++ /dev/null @@ -1,23 +0,0 @@ -/** - * picolibrary-microchip-megaavr0 - * - * Copyright 2021-2023, Andrew Countryman and the - * picolibrary-microchip-megaavr0 contributors - * - * 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 - * \brief picolibrary::Microchip::megaAVR0::Peripheral::Instance implementation. - */ - -#include "picolibrary/microchip/megaavr0/peripheral/instance.h"