diff --git a/.clang_output b/.clang_output new file mode 100644 index 00000000..37dfa481 --- /dev/null +++ b/.clang_output @@ -0,0 +1,4 @@ +. +./arch/arm/common/inc +./arch/arm/SAM_D2X/hal/inc +./conf diff --git a/arch/arm/SAM_D2X/hal/hal_sam_d2x.hpp b/arch/arm/SAM_D2X/hal/hal_sam_d2x.hpp new file mode 100644 index 00000000..3da6bd35 --- /dev/null +++ b/arch/arm/SAM_D2X/hal/hal_sam_d2x.hpp @@ -0,0 +1,6 @@ +#ifndef _HAL_SAM_D2X_HPP_ +#define _HAL_SAM_D2X_HPP_ + + + +#endif diff --git a/arch/arm/SAM_D2X/hal/inc/hal_cache.h b/arch/arm/SAM_D2X/hal/inc/hal_cache.hpp similarity index 100% rename from arch/arm/SAM_D2X/hal/inc/hal_cache.h rename to arch/arm/SAM_D2X/hal/inc/hal_cache.hpp diff --git a/arch/arm/SAM_D2X/hal/inc/hal_clock.h b/arch/arm/SAM_D2X/hal/inc/hal_clock.hpp similarity index 100% rename from arch/arm/SAM_D2X/hal/inc/hal_clock.h rename to arch/arm/SAM_D2X/hal/inc/hal_clock.hpp diff --git a/arch/arm/SAM_D2X/hal/inc/hal_gpio.h b/arch/arm/SAM_D2X/hal/inc/hal_gpio.hpp similarity index 100% rename from arch/arm/SAM_D2X/hal/inc/hal_gpio.h rename to arch/arm/SAM_D2X/hal/inc/hal_gpio.hpp diff --git a/arch/arm/SAM_D2X/hal/inc/hal_init.h b/arch/arm/SAM_D2X/hal/inc/hal_init.hpp similarity index 98% rename from arch/arm/SAM_D2X/hal/inc/hal_init.h rename to arch/arm/SAM_D2X/hal/inc/hal_init.hpp index 95b72ed4..90b3717d 100644 --- a/arch/arm/SAM_D2X/hal/inc/hal_init.h +++ b/arch/arm/SAM_D2X/hal/inc/hal_init.hpp @@ -1,4 +1,3 @@ - #ifdef __cplusplus extern "C" { #endif diff --git a/arch/arm/SAM_D2X/hal/inc/hal_io.hpp b/arch/arm/SAM_D2X/hal/inc/hal_io.hpp new file mode 100644 index 00000000..e69de29b diff --git a/arch/arm/SAM_D2X/hal/inc/hal_sleep.hpp b/arch/arm/SAM_D2X/hal/inc/hal_sleep.hpp new file mode 100644 index 00000000..e69de29b diff --git a/arch/arm/SAM_D2X/hal/inc/samd2x.hpp b/arch/arm/SAM_D2X/hal/inc/samd2x.hpp deleted file mode 100644 index a59b9f9d..00000000 --- a/arch/arm/SAM_D2X/hal/inc/samd2x.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _SAMD2X_HPP_ -#define _SAMD2X_HPP_ - - - - - -#endif diff --git a/arch/arm/SAM_D2X/hdi/hdi_sam_d2x.h b/arch/arm/SAM_D2X/hdi/hdi_sam_d2x.h new file mode 100644 index 00000000..c22d6501 --- /dev/null +++ b/arch/arm/SAM_D2X/hdi/hdi_sam_d2x.h @@ -0,0 +1,60 @@ +#ifndef _HDI_SAM_D2X_H_ +#define _HDI_SAM_D2X_H_ +#include "hal_arm.h" +#include +#ifdef __cplusplus +extern "C" { +#endif + +#if !(defined(__ASSEMBLY__)) +#ifndef __cplusplus + typedef volatile const uint32_t RoReg; // Read only 32-bit register (volatile const unsigned int) + typedef volatile const uint16_t RoReg16; // Read only 16-bit register (volatile const unsigned int) + typedef volatile const uint8_t RoReg8; // Read only 8-bit register (volatile const unsigned int) +#else + typedef volatile uint32_t RoReg; // Read only 32-bit register (volatile const unsigned int) + typedef volatile uint16_t RoReg16; // Read only 16-bit register (volatile const unsigned int) + typedef volatile uint8_t RoReg8; // Read only 8-bit register (volatile const unsigned int) +#endif + typedef volatile uint32_t WoReg; // Write only 32-bit register (volatile unsigned int) + typedef volatile uint16_t WoReg16; // Write only 16-bit register (volatile unsigned int) + typedef volatile uint16_t WoReg8; // Write only 8-bit register (volatile unsigned int) + typedef volatile uint32_t RwReg; // Write only 32-bit register (volatile unsigned int) + typedef volatile uint16_t RwReg16; // Write only 16-bit register (volatile unsigned int) + typedef volatile uint8_t RwReg8; // Write only 8-bit register (volatile unsigned int) +#define CAST(type, value) ((type*)(value)) +#define REG_ACCESS(type, address) (*(type*)(address)) +#else +#define CAST(type, value) (value) +#define REG_ACCESS(type, address) (address) +#endif + +typedef enum IRQn +{ + // Cortex-M0+ Processor Exception Numbers + NonMaskableInt_IRQn = -14, + HardFault_IRQn = -13, + SVCall_IRQn = -5, + PendSV_IRQn = -2, + SysTick_IRQn = -1, + // samd21j18a specific interrupt numbers + PM_IRQn = 0, + SYSCTRL_IRQn = 1, + WDT_IRQn = 2, + RTC_IRQn = 3, + EIC_IRQn = 4, + NVMCTRL_IRQn = 5, + DMAC_IRQn = 6, + USB_IRQn = 7, + EVSYS_IRQ = 8, + SERCOM0_IRQn = 9, + SERCOM1_IRQn = 10, + SERCOM2_IRQn = 11, + SERCOM3_IRQn = 12, + SERCOM4_IRQn = 13, + SERCOM5_IRQn = 14 +}IRQn_Type; +#ifdef __cplusplus +} +#endif +#endif diff --git a/arch/arm/common/inc/hal_arm.h b/arch/arm/common/inc/hal_arm.h new file mode 100644 index 00000000..e11b65be --- /dev/null +++ b/arch/arm/common/inc/hal_arm.h @@ -0,0 +1,35 @@ +#ifndef _HAL_ARM_H_ +#define _HAL_ARM_H_ + +#include "epenguin_conf.h" + +#if !(EP_UARCH == __UARCH_ARM__) + #error This shouldn't be included unless arm is the uarch of choice! +#endif + + +#if !(defined(__ASSEMBLY__)) +#include +#ifndef __cplusplus + typedef volatile const uint32_t RoReg; // Read only 32-bit register (volatile const unsigned int) + typedef volatile const uint16_t RoReg16; // Read only 16-bit register (volatile const unsigned int) + typedef volatile const uint8_t RoReg8; // Read only 8-bit register (volatile const unsigned int) +#else + typedef volatile uint32_t RoReg; // Read only 32-bit register (volatile const unsigned int) + typedef volatile uint16_t RoReg16; // Read only 16-bit register (volatile const unsigned int) + typedef volatile uint8_t RoReg8; // Read only 8-bit register (volatile const unsigned int) +#endif + typedef volatile uint32_t WoReg; // Write only 32-bit register (volatile unsigned int) + typedef volatile uint16_t WoReg16; // Write only 16-bit register (volatile unsigned int) + typedef volatile uint16_t WoReg8; // Write only 8-bit register (volatile unsigned int) + typedef volatile uint32_t RwReg; // Write only 32-bit register (volatile unsigned int) + typedef volatile uint16_t RwReg16; // Write only 16-bit register (volatile unsigned int) + typedef volatile uint8_t RwReg8; // Write only 8-bit register (volatile unsigned int) +#define CAST(type, value) ((type*)(value)) +#define REG_ACCESS(type, address) (*(type*)(address)) +#else +#define CAST(type, value) (value) +#define REG_ACCESS(type, address) (address) +#endif + +#endif diff --git a/arch/arm/common/inc/main.cpp b/arch/arm/common/inc/main.cpp deleted file mode 100644 index c9a61fd9..00000000 --- a/arch/arm/common/inc/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main() -{ - USART_Async x; - -} diff --git a/arch/arm/common/inc/mcu.hpp b/arch/arm/common/inc/mcu.hpp deleted file mode 100644 index a6d68a28..00000000 --- a/arch/arm/common/inc/mcu.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _MCU_H_ -#define _MCU_H_ - -#define MCU_ARCH_ARM (0) -#define MCU_ARCH_ARM64 (1) -#define MCU_ARCH_AVR (2) - -#define MCU_MANUF_MICROCHIP (0) - -#define MCU_TYPE atsamd2x - -#define MCU_ARCH MCU_ARCH_ARM -#define MCU_MANUF MCU_MANUF_MICROCHIP - - -#if MCU_ARCH == MCU_ARCH_ARM - typedef mcu -#elif - -#endif diff --git a/arch/arm/common/inc/notes.txt b/arch/arm/common/inc/notes.txt deleted file mode 100644 index efb4050c..00000000 --- a/arch/arm/common/inc/notes.txt +++ /dev/null @@ -1,31 +0,0 @@ -I2C - Software Addressed Protocol - Clocked Protocol -Pins: SDA = Serial Data - SCL = Serial Clock - -Speeds up to 400Khz, 1 Mhz - -SPI - Serial Protocol Interface - Hardware Addressed Protocol - Clocked Protocol - -Pins: MOSI (Master Out Slave In) - MISO (Master In Slave Out) - SCL Serial Clock - SS or nCS (Slave Select or not Chip Select) - -Up to 20Mhz - -USART Two Wire, Non Clocked Protocol - -Pins: -TX: Transmit -RX: Receive - -Baudrate = bits per second (sorta) - -frequency = 100 / 1 time in seconds - -9600 -115200 -38400 diff --git a/arch/arm/common/inc/usart.h b/arch/arm/common/inc/usart.h deleted file mode 100644 index ce8e0898..00000000 --- a/arch/arm/common/inc/usart.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _USART_H_ -#define _USART_H_ - - -class Usart -{ - public: - Usart(); - ~Usart(); - - void Write(const char* arr); - void Read(char* arr, int max_len); - private: - hal_usart _usart; - -}; - -#endif \ No newline at end of file diff --git a/epenguin.h b/inc/epenguin.h similarity index 98% rename from epenguin.h rename to inc/epenguin.h index 64c0f3bd..7c0fd4ea 100644 --- a/epenguin.h +++ b/inc/epenguin.h @@ -4,4 +4,5 @@ #include "mcu.h" + #endif diff --git a/inc/epenguin_hal.h b/inc/epenguin_hal.h new file mode 100644 index 00000000..39830af5 --- /dev/null +++ b/inc/epenguin_hal.h @@ -0,0 +1,6 @@ +#ifndef _EPENGUIN_HAL_H_ +#define _EPENGUIN_HAL_H_ + + +#endif + diff --git a/inc/mcu.h b/inc/mcu.h new file mode 100644 index 00000000..980beba1 --- /dev/null +++ b/inc/mcu.h @@ -0,0 +1,9 @@ +#ifndef __MCU_H__ +#define __MCU_H__ + +#include "epenguin_conf.h" + + +#endif + + diff --git a/mcu.h b/mcu.h deleted file mode 100644 index 4ad39626..00000000 --- a/mcu.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __MCU_H__ -#define __MCU_H__ - -#include "epenguin_conf.h" - -#ifndef EP_UARCH - #error You must specify an architecture! -#elifndef EP_MCU_FAMILY - #error You must specify a mcu family! -#elifndef EP_MCU - #error You must specify a mcu! -#else - #if EP_UARCH == __UARCH_ARM__ - #if EP_MCU_FAMILY == __SAM_D2X__ - #if EP_MCU == __ATSAMD21J18A__ - #else - #endif - #elif EP_MCU - #endif - #elif EP_UARCH == __UARCH_ARM64__ - - #elif EP_UARCH == __UARCH_AVR__ - - #elif EP_UARCH == __UARCH_AVR32__ - - #elif EP_UARCH == __UARCH_RISCV__ - - #elif EP_UARCH == __UARCH_X86__ - - #else - #error Selected uarch not found! Try again =( - #endif -#endif - -#endif