aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/AVR/MEGA/ATMEGAxx
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/ports/AVR/MEGA/ATMEGAxx')
-rw-r--r--os/hal/ports/AVR/MEGA/ATMEGAxx/avr_pins.h159
-rw-r--r--os/hal/ports/AVR/MEGA/ATMEGAxx/avr_timers.h55
-rw-r--r--os/hal/ports/AVR/MEGA/ATMEGAxx/hal_lld.c55
-rw-r--r--os/hal/ports/AVR/MEGA/ATMEGAxx/hal_lld.h72
-rw-r--r--os/hal/ports/AVR/MEGA/ATMEGAxx/platform.mk15
5 files changed, 356 insertions, 0 deletions
diff --git a/os/hal/ports/AVR/MEGA/ATMEGAxx/avr_pins.h b/os/hal/ports/AVR/MEGA/ATMEGAxx/avr_pins.h
new file mode 100644
index 000000000..b98ce2574
--- /dev/null
+++ b/os/hal/ports/AVR/MEGA/ATMEGAxx/avr_pins.h
@@ -0,0 +1,159 @@
+/*
+ ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+
+ 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.
+*/
+
+#ifndef AVR_PINS_H
+#define AVR_PINS_H
+
+#include <avr/io.h>
+
+#if AVR_SPI_USE_SPI1
+
+#if defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega162__)
+ #define PIN_SPI1 PINB
+ #define PORT_SPI1 PORTB
+ #define DDR_SPI1 DDRB
+ #define SPI1_SS 4
+ #define SPI1_SCK 7
+ #define SPI1_MOSI 5
+ #define SPI1_MISO 6
+#elif defined(__AVR_ATmega328P__)
+ #define PIN_SPI1 PINB
+ #define PORT_SPI1 PORTB
+ #define DDR_SPI1 DDRB
+ #define SPI1_SS 2
+ #define SPI1_SCK 5
+ #define SPI1_MOSI 3
+ #define SPI1_MISO 4
+#elif defined(__AVR_ATmega2560__) || \
+ defined(__AVR_ATmega1280__) || \
+ defined(__AVR_ATmega128__)
+ #define PIN_SPI1 PINB
+ #define PORT_SPI1 PORTB
+ #define DDR_SPI1 DDRB
+ #define SPI1_SS 0
+ #define SPI1_SCK 1
+ #define SPI1_MOSI 2
+ #define SPI1_MISO 3
+#elif defined(__AVR_AT90CAN128__) || \
+ defined(__AVR_AT90CAN64__) || \
+ defined(__AVR_AT90CAN32__)
+ #define PIN_SPI1 PINB
+ #define PORT_SPI1 PORTB
+ #define DDR_SPI1 DDRB
+ #define SPI1_SS 0
+ #define SPI1_SCK 1
+ #define SPI1_MOSI 2
+ #define SPI1_MISO 3
+#else
+ #warning "Device not supported by SPI driver"
+#endif
+
+#endif /* AVR_SPI_USE_SPI1 */
+
+#if AVR_ADC_USE_ADC1
+
+#if defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__)
+ #define PINADC PINA
+ #define PORTADC PORTA
+ #define DDRADC DDRA
+#elif defined(__AVR_ATmega328P__)
+ #define PINADC PINC
+ #define PORTADC PORTC
+ #define DDRADC DDRC
+#elif defined(__AVR_ATmega2560__) || \
+ defined(__AVR_ATmega1280__) || \
+ defined(__AVR_ATmega128__)
+ #define PINADC PINF
+ #define PORTADC PORTF
+ #define DDRADC DDRF
+#elif defined(__AVR_AT90CAN128__) || \
+ defined(__AVR_AT90CAN64__) || \
+ defined(__AVR_AT90CAN32__)
+ #define PINADC PINF
+ #define PORTADC PORTF
+ #define DDRADC DDRF
+#else
+ #warning "Device not supported by ADC driver"
+#endif
+
+#endif /* AVR_ADC_USE_ADC1 */
+
+#if AVR_EXT_USE_PCINT0
+#if defined(__AVR_ATmega162__)
+ #define PCINT0_PIN PINA
+#elif defined(__AVR_ATmega328P__) || \
+ defined(__AVR_ATmega1280__) || \
+ defined(__AVR_ATmega2560__)
+ #define PCINT0_PIN PINB
+#else
+ #warning "Device not supported by EXT driver"
+#endif
+#endif /* AVR_EXT_USE_PCINT0 */
+
+#if AVR_EXT_USE_PCINT1
+#if defined(__AVR_ATmega162__) || \
+ defined(__AVR_ATmega328P__)
+ #define PCINT1_PIN PINC
+#elif defined(__AVR_ATmega1280__) || \
+ defined(__AVR_ATmega2560__)
+ #define PCINT1_PIN PINE
+#else
+ #warning "Device not supported by EXT driver"
+#endif
+#endif /* AVR_EXT_USE_PCINT1 */
+
+#if AVR_EXT_USE_PCINT2
+#if defined(__AVR_ATmega1280__) || \
+ defined(__AVR_ATmega2560__)
+ #define PCINT2_PIN PINK
+#else
+ #warning "Device not supported by EXT driver"
+#endif
+#endif /* AVR_EXT_USE_PCINT2 */
+
+#if AVR_EXT_USE_PCINT3
+#warning "Device not supported by EXT driver"
+#endif /* AVR_EXT_USE_PCINT3 */
+
+#if AVR_EXT_USE_PCINT4
+#warning "Device not supported by EXT driver"
+#endif /* AVR_EXT_USE_PCINT4 */
+
+#if AVR_EXT_USE_PCINT5
+#warning "Device not supported by EXT driver"
+#endif /* AVR_EXT_USE_PCINT5 */
+
+#if AVR_EXT_USE_PCINT6
+#warning "Device not supported by EXT driver"
+#endif /* AVR_EXT_USE_PCINT6 */
+
+#if AVR_EXT_USE_PCINT7
+#warning "Device not supported by EXT driver"
+#endif /* AVR_EXT_USE_PCINT7 */
+
+#if AVR_EXT_USE_PCINT8
+#warning "Device not supported by EXT driver"
+#endif /* AVR_EXT_USE_PCINT8 */
+
+#if AVR_EXT_USE_PCINT9
+#warning "Device not supported by EXT driver"
+#endif /* AVR_EXT_USE_PCINT9 */
+
+#if AVR_EXT_USE_PCINT10
+#warning "Device not supported by EXT driver"
+#endif /* AVR_EXT_USE_PCINT10 */
+
+#endif /* AVR_PINS_H */
diff --git a/os/hal/ports/AVR/MEGA/ATMEGAxx/avr_timers.h b/os/hal/ports/AVR/MEGA/ATMEGAxx/avr_timers.h
new file mode 100644
index 000000000..42c275e20
--- /dev/null
+++ b/os/hal/ports/AVR/MEGA/ATMEGAxx/avr_timers.h
@@ -0,0 +1,55 @@
+/*
+ ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+
+ 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.
+*/
+
+#ifndef AVR_TIMERS_H
+#define AVR_TIMERS_H
+
+#include "mcuconf.h"
+
+#if ((OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING) && \
+ (AVR_GPT_USE_TIM1 || AVR_PWM_USE_TIM1 || AVR_ICU_USE_TIM1))
+ #error "Timer 1 cannot be used by drivers when running in tickless mode."
+#endif
+
+#if ((AVR_GPT_USE_TIM1 && AVR_PWM_USE_TIM1) || \
+ (AVR_GPT_USE_TIM1 && AVR_ICU_USE_TIM1) || \
+ (AVR_PWM_USE_TIM1 && AVR_ICU_USE_TIM1))
+ #error "Timer 1 cannot simultaneously be used by multiple drivers."
+#endif
+
+#if ((AVR_GPT_USE_TIM2 && AVR_PWM_USE_TIM2))
+ #error "Timer 2 cannot simultaneously be used by multiple drivers."
+#endif
+
+#if ((AVR_GPT_USE_TIM3 && AVR_PWM_USE_TIM3) || \
+ (AVR_GPT_USE_TIM3 && AVR_ICU_USE_TIM3) || \
+ (AVR_PWM_USE_TIM3 && AVR_ICU_USE_TIM3))
+ #error "Timer 3 cannot simultaneously be used by multiple drivers."
+#endif
+
+#if ((AVR_GPT_USE_TIM4 && AVR_PWM_USE_TIM4) || \
+ (AVR_GPT_USE_TIM4 && AVR_ICU_USE_TIM4) || \
+ (AVR_PWM_USE_TIM4 && AVR_ICU_USE_TIM4))
+ #error "Timer 4 cannot simultaneously be used by multiple drivers."
+#endif
+
+#if ((AVR_GPT_USE_TIM5 && AVR_PWM_USE_TIM5) || \
+ (AVR_GPT_USE_TIM5 && AVR_ICU_USE_TIM5) || \
+ (AVR_PWM_USE_TIM5 && AVR_ICU_USE_TIM5))
+ #error "Timer 5 cannot simultaneously be used by multiple drivers."
+#endif
+
+#endif /* AVR_TIMERS_H */
diff --git a/os/hal/ports/AVR/MEGA/ATMEGAxx/hal_lld.c b/os/hal/ports/AVR/MEGA/ATMEGAxx/hal_lld.c
new file mode 100644
index 000000000..fef8b7084
--- /dev/null
+++ b/os/hal/ports/AVR/MEGA/ATMEGAxx/hal_lld.c
@@ -0,0 +1,55 @@
+/*
+ ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+
+ 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 hal_lld.c
+ * @brief AVR HAL subsystem low level driver code.
+ *
+ * @addtogroup HAL
+ * @{
+ */
+
+#include "hal.h"
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Low level HAL driver initialization.
+ *
+ * @notapi
+ */
+void hal_lld_init(void) {
+}
+
+/** @} */
diff --git a/os/hal/ports/AVR/MEGA/ATMEGAxx/hal_lld.h b/os/hal/ports/AVR/MEGA/ATMEGAxx/hal_lld.h
new file mode 100644
index 000000000..eca18ffc3
--- /dev/null
+++ b/os/hal/ports/AVR/MEGA/ATMEGAxx/hal_lld.h
@@ -0,0 +1,72 @@
+/*
+ ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+
+ 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 hal_lld.h
+ * @brief AVR HAL subsystem low level driver header.
+ *
+ * @addtogroup HAL
+ * @{
+ */
+
+#ifndef HAL_LLD_H
+#define HAL_LLD_H
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/**
+ * @brief Defines the support for realtime counters in the HAL.
+ */
+#define HAL_IMPLEMENTS_COUNTERS FALSE
+
+/**
+ * @brief Platform name.
+ */
+#define PLATFORM_NAME "AVR"
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void hal_lld_init(void);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_LLD_H */
+
+/** @} */
diff --git a/os/hal/ports/AVR/MEGA/ATMEGAxx/platform.mk b/os/hal/ports/AVR/MEGA/ATMEGAxx/platform.mk
new file mode 100644
index 000000000..0e47351ce
--- /dev/null
+++ b/os/hal/ports/AVR/MEGA/ATMEGAxx/platform.mk
@@ -0,0 +1,15 @@
+# List of all the AVR platform files.
+PLATFORMSRC = ${CHIBIOS}/os/hal/ports/AVR/MEGA/hal_lld.c \
+
+# Required include directories
+PLATFORMINC = ${CHIBIOS}/os/hal/ports/AVR/MEGA
+
+# Drivers compatible with the platform.
+include $(CHIBIOS)/os/hal/ports/AVR/MEGA/ADCv1/driver.mk
+include $(CHIBIOS)/os/hal/ports/AVR/MEGA/EXTv1/driver.mk
+include $(CHIBIOS)/os/hal/ports/AVR/MEGA/GPIOv1/driver.mk
+include $(CHIBIOS)/os/hal/ports/AVR/MEGA/I2Cv1/driver.mk
+include $(CHIBIOS)/os/hal/ports/AVR/MEGA/SPIv1/driver.mk
+include $(CHIBIOS)/os/hal/ports/AVR/MEGA/TIMv1/driver.mk
+include $(CHIBIOS)/os/hal/ports/AVR/MEGA/USARTv1/driver.mk
+include $(CHIBIOS)/os/hal/ports/AVR/MEGA/USBv1/driver.mk