reworking the structure

stable
Penguin 4 years ago
parent bbab8bdaee
commit f1a55f7002

@ -0,0 +1,4 @@
.
./arch/arm/common/inc
./arch/arm/SAM_D2X/hal/inc
./conf

@ -0,0 +1,6 @@
#ifndef _HAL_SAM_D2X_HPP_
#define _HAL_SAM_D2X_HPP_
#endif

@ -1,8 +0,0 @@
#ifndef _SAMD2X_HPP_
#define _SAMD2X_HPP_
#endif

@ -0,0 +1,60 @@
#ifndef _HDI_SAM_D2X_H_
#define _HDI_SAM_D2X_H_
#include "hal_arm.h"
#include <stdint.h>
#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

@ -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 <stdint.h>
#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

@ -1,7 +0,0 @@
#include <iostream>
int main()
{
USART_Async x;
}

@ -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

@ -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

@ -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

@ -4,4 +4,5 @@
#include "mcu.h"
#endif

@ -0,0 +1,6 @@
#ifndef _EPENGUIN_HAL_H_
#define _EPENGUIN_HAL_H_
#endif

@ -0,0 +1,9 @@
#ifndef __MCU_H__
#define __MCU_H__
#include "epenguin_conf.h"
#endif

35
mcu.h

@ -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
Loading…
Cancel
Save