diff options
Diffstat (limited to 'include/mcu')
-rw-r--r-- | include/mcu/Kconfig | 11 | ||||
-rw-r--r-- | include/mcu/atmega328p.Kconfig | 8 | ||||
-rw-r--r-- | include/mcu/atmega328p.h | 63 | ||||
-rw-r--r-- | include/mcu/atmega32u4.h | 19 | ||||
-rw-r--r-- | include/mcu/atmega8a.h | 18 | ||||
-rw-r--r-- | include/mcu/attiny4313.h | 46 | ||||
-rw-r--r-- | include/mcu/attiny85.Kconfig | 4 | ||||
-rw-r--r-- | include/mcu/attiny85.h | 28 | ||||
-rw-r--r-- | include/mcu/mcu.h | 18 | ||||
-rw-r--r-- | include/mcu/mcu_def.h | 21 |
10 files changed, 236 insertions, 0 deletions
diff --git a/include/mcu/Kconfig b/include/mcu/Kconfig new file mode 100644 index 0000000..a69903f --- /dev/null +++ b/include/mcu/Kconfig @@ -0,0 +1,11 @@ +config MMCU + string + default "atmega328p" if ATMEGA328P + +choice MCU + prompt "Microcontroller (MMCU)" + +source include/mcu/atmega328p.Kconfig +source include/mcu/attiny85.Kconfig + +endchoice diff --git a/include/mcu/atmega328p.Kconfig b/include/mcu/atmega328p.Kconfig new file mode 100644 index 0000000..5b4bf27 --- /dev/null +++ b/include/mcu/atmega328p.Kconfig @@ -0,0 +1,8 @@ +config ATMEGA328P + bool "atmega328p" + select MCUSUPPORT_IOPORTS + select MCUSUPPORT_PCINT0 + select MCUSUPPORT_PCINT1 + select MCUSUPPORT_PCINT2 + select MCUSUPPORT_SPI + select MCUSUPPORT_USART diff --git a/include/mcu/atmega328p.h b/include/mcu/atmega328p.h new file mode 100644 index 0000000..994e9e6 --- /dev/null +++ b/include/mcu/atmega328p.h @@ -0,0 +1,63 @@ +/* This is specific configuration for ATmega328P. + * Also applies on ATmega48A, ATmega48PA, ATmega88A, ATmega88PA, ATmega168A and + * ATmega168PA. + */ +#include <avr/io.h> + +// IO Ports +#define MCUSUPPORT_IOPORTS +#define IO_B 0 +#define IO_C 1 +#define IO_D 2 +#define IO_PIN(GROUP) (* (volatile uint8_t *)(PINB + 0x3*GROUP)) +#define IO_DDR(GROUP) (* (volatile uint8_t *)(DDRB + 0x3*GROUP)) +#define IO_PORT(GROUP) (* (volatile uint8_t *)(PORTB + 0x3*GROUP)) +#define IO_B0 IO_B, (1 << 0) +#define IO_B1 IO_B, (1 << 1) +#define IO_B2 IO_B, (1 << 2) +#define IO_B3 IO_B, (1 << 3) +#define IO_B4 IO_B, (1 << 4) +#define IO_B5 IO_B, (1 << 5) +#define IO_B6 IO_B, (1 << 6) +#define IO_B7 IO_B, (1 << 7) +#define IO_C0 IO_C, (1 << 0) +#define IO_C1 IO_C, (1 << 1) +#define IO_C2 IO_C, (1 << 2) +#define IO_C3 IO_C, (1 << 3) +#define IO_C4 IO_C, (1 << 4) +#define IO_C5 IO_C, (1 << 5) +#define IO_C6 IO_C, (1 << 6) +#define IO_D0 IO_D, (1 << 0) +#define IO_D1 IO_D, (1 << 1) +#define IO_D2 IO_D, (1 << 2) +#define IO_D3 IO_D, (1 << 3) +#define IO_D4 IO_D, (1 << 4) +#define IO_D5 IO_D, (1 << 5) +#define IO_D6 IO_D, (1 << 6) +#define IO_D7 IO_D, (1 << 7) +#define MCUSUPPORT_PCINT0 8 +#define MCUSUPPORT_PCINT1 8 +#define MCUSUPPORT_PCINT2 8 +// SPI +#define MCUSUPPORT_SPI +#define DDR_SPI DDRB +#define DD_SS DDB2 +#define DD_MOSI DDB3 +#define DD_MISO DDB4 +#define DD_SCLK DDB5 +#define PORT_SPI PORTB +#define PORT_SS PORTB2 +#define PORT_MOSI PORTB3 +#define PORT_MISO PORTB4 +#define PORT_SCLK PORTB5 +// USART +#define MCUSUPPORT_USART +// TWI +#define MCUSUPPORT_TWI +// TIMERS +#define MCUSUPPORT_TIMER_0 +#define MCUSUPPORT_TIMER_1 +#define MCUSUPPORT_TIMER_2 +#define COUNTER0_PWM 0 +#define COUNTER1_16PWM 1 +#define COUNTER2_PWM_ASYNC 2 diff --git a/include/mcu/atmega32u4.h b/include/mcu/atmega32u4.h new file mode 100644 index 0000000..16351e8 --- /dev/null +++ b/include/mcu/atmega32u4.h @@ -0,0 +1,19 @@ +/* This is specific configuration for ATmega32U4. + * This configuration also applies on ATmega16U4. + */ +#include <avr/io.h> + +// SPI +#define MCUSUPPORT_SPI +#define DDR_SPI DDRB +#define DD_SS DDB0 +#define DD_SCLK DDB1 +#define DD_MOSI DDB2 +#define DD_MISO DDB3 +#define PORT_SPI PORTB +#define PORT_SS PORTB0 +#define PORT_SCLK PORTB1 +#define PORT_MOSI PORTB2 +#define PORT_MISO PORTB3 +// USART +#define MCUSUPPORT_USART0 diff --git a/include/mcu/atmega8a.h b/include/mcu/atmega8a.h new file mode 100644 index 0000000..a2d3adf --- /dev/null +++ b/include/mcu/atmega8a.h @@ -0,0 +1,18 @@ +/* This is specific configuration for ATmega8A. + */ +#include <avr/io.h> + +// SPI +#define MCUSUPPORT_SPI +#define DDR_SPI DDRB +#define DD_SS DDB2 +#define DD_SCLK DDB5 +#define DD_MOSI DDB3 +#define DD_MISO DDB4 +#define PORT_SPI PORTB +#define PORT_SS PORTB2 +#define PORT_SCLK PORTB5 +#define PORT_MOSI PORTB3 +#define PORT_MISO PORTB4 +// USART +#define MCUSUPPORT_USART0 diff --git a/include/mcu/attiny4313.h b/include/mcu/attiny4313.h new file mode 100644 index 0000000..3a2d0b9 --- /dev/null +++ b/include/mcu/attiny4313.h @@ -0,0 +1,46 @@ +/* This is specific configuration for ATtiny4313. + * This configuration also applies on ATtiny2313A. + */ +#include <avr/io.h> + +// IO Ports +#define MCUSUPPORT_IOPORTS +#define IO_A 0 +#define IO_B 1 +#define IO_D 3 +#define IO_PIN(GROUP) (* (volatile uint8_t *)(PINB + 0x3*GROUP)) +#define IO_DDR(GROUP) (* (volatile uint8_t *)(DDRB + 0x3*GROUP)) +#define IO_PORT(GROUP) (* (volatile uint8_t *)(PORTB + 0x3*GROUP)) +#define IO_A0 IO_A, (1 << 0) +#define IO_A1 IO_A, (1 << 1) +#define IO_A2 IO_A, (1 << 2) +#define IO_B0 IO_B, (1 << 0) +#define IO_B1 IO_B, (1 << 1) +#define IO_B2 IO_B, (1 << 2) +#define IO_B3 IO_B, (1 << 3) +#define IO_B4 IO_B, (1 << 4) +#define IO_B5 IO_B, (1 << 5) +#define IO_B6 IO_B, (1 << 6) +#define IO_B7 IO_B, (1 << 7) +#define IO_D0 IO_D, (1 << 0) +#define IO_D1 IO_D, (1 << 1) +#define IO_D2 IO_D, (1 << 2) +#define IO_D3 IO_D, (1 << 3) +#define IO_D4 IO_D, (1 << 4) +#define IO_D5 IO_D, (1 << 5) +#define IO_D6 IO_D, (1 << 6) +#define MCUSUPPORT_PCINT0 8 // TODO this is B +#define MCUSUPPORT_PCINT1 7 // But this is D +#define MCUSUPPORT_PCINT2 3 // And this is A, this is not expected in ioport.c +// SPI USI +#define MCUSUPPORT_USI +#define DDR_USI DDRB +#define DD_DI DDB5 +#define DD_DO DDB6 +#define DD_USCK DDB7 +#define PORT_USI PORTB +#define PORT_DI PORTB5 +#define PORT_DO PORTB6 +#define PORT_USCK PORTB7 +// USART +#define MCUSUPPORT_USART0 diff --git a/include/mcu/attiny85.Kconfig b/include/mcu/attiny85.Kconfig new file mode 100644 index 0000000..d58c1d8 --- /dev/null +++ b/include/mcu/attiny85.Kconfig @@ -0,0 +1,4 @@ +config ATTINY85 + bool "attiny85" + select MCUSUPPORT_IOPORTS + select MCUSUPPORT_PCINT0 diff --git a/include/mcu/attiny85.h b/include/mcu/attiny85.h new file mode 100644 index 0000000..c342bbb --- /dev/null +++ b/include/mcu/attiny85.h @@ -0,0 +1,28 @@ +/* This is specific configuration for ATtiny85. + * This configuration also applies on ATtiny45 and ATtiny25. + */ +#include <avr/io.h> + +// IO Ports +#define MCUSUPPORT_IOPORTS +#define IO_B 0 +#define IO_PIN(GROUP) PINB +#define IO_DDR(GROUP) DDRB +#define IO_PORT(GROUP) PORTB +#define IO_B0 IO_B, (1 << 0) +#define IO_B1 IO_B, (1 << 1) +#define IO_B2 IO_B, (1 << 2) +#define IO_B3 IO_B, (1 << 3) +#define IO_B4 IO_B, (1 << 4) +#define IO_B5 IO_B, (1 << 5) +#define MCUSUPPORT_PCINT0 6 +// SPI USI +#define MCUSUPPORT_USI +#define DDR_USI DDRB +#define DD_DI DDB0 +#define DD_DO DDB1 +#define DD_USCK DDB2 +#define PORT_USI PORTB +#define PORT_DI PORTB0 +#define PORT_DO PORTB1 +#define PORT_USCK PORTB2 diff --git a/include/mcu/mcu.h b/include/mcu/mcu.h new file mode 100644 index 0000000..e1272b9 --- /dev/null +++ b/include/mcu/mcu.h @@ -0,0 +1,18 @@ +#define __MCU_ATmega328p__ \ + ((defined __AVR_ATmega328P__ || defined __AVR_ATmega328__ || \ + defined __AVR_ATmega1688PA__ || defined __AVR_ATmega168A__ || \ + defined __AVR_ATmega88PA__ || defined __AVR_ATmega88A__ || \ + defined __AVR_ATmega48PA__ || defined AVR_ATmega48A__)) + +#define __MCU_ATmega32U4__ \ + ((defined __AVR_ATmega32U4__ || defined __AVR_ATmega16U4)) + +#define __MCU_ATmega8A__ \ + (defined __AVR_ATmega8A__) + +#define __MCU_ATtiny4313__ \ + ((defined __AVR_ATtiny4313__ || defined __AVR_ATtiny2313A__)) + +#define __MCU_ATtiny85__ \ + ((defined __AVR_ATtiny85__ || defined __AVR_ATtiny45__ || \ + defined __AVR_ATtiny25__)) diff --git a/include/mcu/mcu_def.h b/include/mcu/mcu_def.h new file mode 100644 index 0000000..472b607 --- /dev/null +++ b/include/mcu/mcu_def.h @@ -0,0 +1,21 @@ +#include "mcu.h" + +#if __MCU_ATmega328p__ +#include "atmega328p.h" +#endif + +#if __MCU_ATmega32U4__ +#include "atmega32u4.h" +#endif + +#if __MCU_ATmega8A__ +#include "atmega8a.h" +#endif + +#if __MCU_ATtiny4313__ +#include "attiny4313.h" +#endif + +#if __MCU_ATtiny85__ +#include "attiny85.h" +#endif |