Added GCC port files for AVR Mega0 and AVR Dx. (#101)
This commit is contained in:
350
portable/GCC/AVR_AVRDx/port.c
Normal file
350
portable/GCC/AVR_AVRDx/port.c
Normal file
File diff suppressed because it is too large
Load Diff
133
portable/GCC/AVR_AVRDx/porthardware.h
Normal file
133
portable/GCC/AVR_AVRDx/porthardware.h
Normal file
@ -0,0 +1,133 @@
|
||||
#ifndef PORTHARDWARE_H
|
||||
#define PORTHARDWARE_H
|
||||
|
||||
#include "FreeRTOSConfig.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define CLR_INT(FLAG_REG, FLAG_MASK) \
|
||||
asm volatile( "push r16\n\t" \
|
||||
"ldi r16, %1\n\t" \
|
||||
"sts %0, r16\n\t" \
|
||||
"pop r16\n\t" \
|
||||
: \
|
||||
: "i"(_SFR_MEM_ADDR(FLAG_REG)),"i"((uint8_t)(FLAG_MASK)) \
|
||||
);
|
||||
|
||||
#if ( configUSE_TIMER_INSTANCE == 0 )
|
||||
|
||||
#define TICK_INT_vect TCB0_INT_vect
|
||||
#define INT_FLAGS TCB0_INTFLAGS
|
||||
#define INT_MASK TCB_CAPT_bm
|
||||
|
||||
#define TICK_init() { \
|
||||
TCB0.CCMP = configCPU_CLOCK_HZ / configTICK_RATE_HZ; \
|
||||
TCB0.INTCTRL = TCB_CAPT_bm; \
|
||||
TCB0.CTRLA = TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
TCB0.INTCTRL &= ~TCB_CAPT_bm;\
|
||||
TCB0.CTRLA &= ~TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#elif ( configUSE_TIMER_INSTANCE == 1 )
|
||||
|
||||
#define TICK_INT_vect TCB1_INT_vect
|
||||
#define INT_FLAGS TCB1_INTFLAGS
|
||||
#define INT_MASK TCB_CAPT_bm
|
||||
|
||||
#define TICK_init() { \
|
||||
TCB1.CCMP = configCPU_CLOCK_HZ / configTICK_RATE_HZ; \
|
||||
TCB1.INTCTRL = TCB_CAPT_bm; \
|
||||
TCB1.CTRLA = TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
TCB1.INTCTRL &= ~TCB_CAPT_bm; \
|
||||
TCB1.CTRLA &= ~TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#elif ( configUSE_TIMER_INSTANCE == 2 )
|
||||
|
||||
#define TICK_INT_vect TCB2_INT_vect
|
||||
#define INT_FLAGS TCB2_INTFLAGS
|
||||
#define INT_MASK TCB_CAPT_bm
|
||||
|
||||
#define TICK_init() { \
|
||||
TCB2.CCMP = configCPU_CLOCK_HZ / configTICK_RATE_HZ; \
|
||||
TCB2.INTCTRL = TCB_CAPT_bm; \
|
||||
TCB2.CTRLA = TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
TCB2.INTCTRL &= ~TCB_CAPT_bm; \
|
||||
TCB2.CTRLA &= ~TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#elif ( configUSE_TIMER_INSTANCE == 3 )
|
||||
|
||||
#define TICK_INT_vect TCB3_INT_vect
|
||||
#define INT_FLAGS TCB3_INTFLAGS
|
||||
#define INT_MASK TCB_CAPT_bm
|
||||
|
||||
#define TICK_init() { \
|
||||
TCB3.CCMP = configCPU_CLOCK_HZ / configTICK_RATE_HZ; \
|
||||
TCB3.INTCTRL = TCB_CAPT_bm; \
|
||||
TCB3.CTRLA = TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
TCB3.INTCTRL &= ~TCB_CAPT_bm; \
|
||||
TCB3.CTRLA &= ~TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#elif ( configUSE_TIMER_INSTANCE == 4 )
|
||||
|
||||
#define TICK_INT_vect TCB4_INT_vect
|
||||
#define INT_FLAGS TCB4_INTFLAGS
|
||||
#define INT_MASK TCB_CAPT_bm
|
||||
|
||||
#define TICK_init() { \
|
||||
TCB4.CCMP = configCPU_CLOCK_HZ / configTICK_RATE_HZ; \
|
||||
TCB4.INTCTRL = TCB_CAPT_bm; \
|
||||
TCB4.CTRLA = TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
TCB4.INTCTRL &= ~TCB_CAPT_bm; \
|
||||
TCB4.CTRLA &= ~TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#elif ( configUSE_TIMER_INSTANCE == 5 )
|
||||
|
||||
/* Hertz to period for RTC setup */
|
||||
#define RTC_PERIOD_HZ(x) (32768 * ((1.0 / x)))
|
||||
|
||||
#define TICK_INT_vect RTC_CNT_vect
|
||||
#define INT_FLAGS RTC_INTFLAGS
|
||||
#define INT_MASK RTC_OVF_bm
|
||||
|
||||
#define TICK_init() { \
|
||||
while (RTC.STATUS > 0); \
|
||||
RTC.CTRLA = RTC_PRESCALER_DIV1_gc | 1 << RTC_RTCEN_bp; \
|
||||
RTC.PER = RTC_PERIOD_HZ(configTICK_RATE_HZ); \
|
||||
RTC.INTCTRL |= 1 << RTC_OVF_bp; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
RTC.CTRLA &= ~(1 << RTC_RTCEN_bp); \
|
||||
RTC.INTCTRL &= ~(1 << RTC_OVF_bp); \
|
||||
}
|
||||
|
||||
#else
|
||||
#undef TICK_INT_vect
|
||||
#undef INT_FLAGS
|
||||
#undef INT_MASK
|
||||
#undef TICK_init()
|
||||
#error Invalid timer setting.
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#endif /* PORTHARDWARE_H */
|
107
portable/GCC/AVR_AVRDx/portmacro.h
Normal file
107
portable/GCC/AVR_AVRDx/portmacro.h
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.1
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Port specific definitions.
|
||||
*
|
||||
* The settings in this file configure FreeRTOS correctly for the
|
||||
* given hardware and compiler.
|
||||
*
|
||||
* These settings should not be altered.
|
||||
*-----------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT int
|
||||
#define portSTACK_TYPE uint8_t
|
||||
#define portBASE_TYPE char
|
||||
|
||||
#define portPOINTER_SIZE_TYPE uint16_t
|
||||
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef signed char BaseType_t;
|
||||
typedef unsigned char UBaseType_t;
|
||||
|
||||
#if (configUSE_16_BIT_TICKS == 1)
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY (TickType_t)0xffff
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY (TickType_t)0xffffffffUL
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Critical section management. */
|
||||
#define portENTER_CRITICAL() \
|
||||
asm volatile("in __tmp_reg__, __SREG__"); \
|
||||
asm volatile("cli"); \
|
||||
asm volatile("push __tmp_reg__")
|
||||
|
||||
#define portEXIT_CRITICAL() \
|
||||
asm volatile("pop __tmp_reg__"); \
|
||||
asm volatile("out __SREG__, __tmp_reg__")
|
||||
|
||||
#define portDISABLE_INTERRUPTS() asm volatile("cli" ::);
|
||||
#define portENABLE_INTERRUPTS() asm volatile("sei" ::);
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Architecture specifics. */
|
||||
#define portSTACK_GROWTH (-1)
|
||||
#define portTICK_PERIOD_MS ((TickType_t)1000 / configTICK_RATE_HZ)
|
||||
#define portBYTE_ALIGNMENT 1
|
||||
#define portNOP() asm volatile("nop");
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Kernel utilities. */
|
||||
extern void vPortYield(void) __attribute__((naked));
|
||||
#define portYIELD() vPortYield()
|
||||
|
||||
extern void vPortYieldFromISR(void) __attribute__((naked));
|
||||
#define portYIELD_FROM_ISR() vPortYieldFromISR()
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||
#define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters)
|
||||
#define portTASK_FUNCTION(vFunction, pvParameters) void vFunction(void *pvParameters)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PORTMACRO_H */
|
338
portable/GCC/AVR_Mega0/port.c
Normal file
338
portable/GCC/AVR_Mega0/port.c
Normal file
File diff suppressed because it is too large
Load Diff
113
portable/GCC/AVR_Mega0/porthardware.h
Normal file
113
portable/GCC/AVR_Mega0/porthardware.h
Normal file
@ -0,0 +1,113 @@
|
||||
#ifndef PORTHARDWARE_H
|
||||
#define PORTHARDWARE_H
|
||||
|
||||
#include "FreeRTOSConfig.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#define CLR_INT(FLAG_REG, FLAG_MASK) \
|
||||
asm volatile( "push r16\n\t" \
|
||||
"ldi r16, %1\n\t" \
|
||||
"sts %0, r16\n\t" \
|
||||
"pop r16\n\t" \
|
||||
: \
|
||||
: "i"(_SFR_MEM_ADDR(FLAG_REG)),"i"((uint8_t)(FLAG_MASK)) \
|
||||
);
|
||||
|
||||
#if ( configUSE_TIMER_INSTANCE == 0 )
|
||||
|
||||
#define TICK_INT_vect TCB0_INT_vect
|
||||
#define INT_FLAGS TCB0_INTFLAGS
|
||||
#define INT_MASK TCB_CAPT_bm
|
||||
|
||||
#define TICK_init() { \
|
||||
TCB0.CCMP = configCPU_CLOCK_HZ / configTICK_RATE_HZ; \
|
||||
TCB0.INTCTRL = TCB_CAPT_bm; \
|
||||
TCB0.CTRLA = TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
TCB0.INTCTRL &= ~TCB_CAPT_bm;\
|
||||
TCB0.CTRLA &= ~TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#elif ( configUSE_TIMER_INSTANCE == 1 )
|
||||
|
||||
#define TICK_INT_vect TCB1_INT_vect
|
||||
#define INT_FLAGS TCB1_INTFLAGS
|
||||
#define INT_MASK TCB_CAPT_bm
|
||||
|
||||
#define TICK_init() { \
|
||||
TCB1.CCMP = configCPU_CLOCK_HZ / configTICK_RATE_HZ; \
|
||||
TCB1.INTCTRL = TCB_CAPT_bm; \
|
||||
TCB1.CTRLA = TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
TCB1.INTCTRL &= ~TCB_CAPT_bm; \
|
||||
TCB1.CTRLA &= ~TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#elif ( configUSE_TIMER_INSTANCE == 2 )
|
||||
|
||||
#define TICK_INT_vect TCB2_INT_vect
|
||||
#define INT_FLAGS TCB2_INTFLAGS
|
||||
#define INT_MASK TCB_CAPT_bm
|
||||
|
||||
#define TICK_init() { \
|
||||
TCB2.CCMP = configCPU_CLOCK_HZ / configTICK_RATE_HZ; \
|
||||
TCB2.INTCTRL = TCB_CAPT_bm; \
|
||||
TCB2.CTRLA = TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
TCB2.INTCTRL &= ~TCB_CAPT_bm; \
|
||||
TCB2.CTRLA &= ~TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#elif ( configUSE_TIMER_INSTANCE == 3 )
|
||||
|
||||
#define TICK_INT_vect TCB3_INT_vect
|
||||
#define INT_FLAGS TCB3_INTFLAGS
|
||||
#define INT_MASK TCB_CAPT_bm
|
||||
|
||||
#define TICK_init() { \
|
||||
TCB3.CCMP = configCPU_CLOCK_HZ / configTICK_RATE_HZ; \
|
||||
TCB3.INTCTRL = TCB_CAPT_bm; \
|
||||
TCB3.CTRLA = TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
TCB3.INTCTRL &= ~TCB_CAPT_bm; \
|
||||
TCB3.CTRLA &= ~TCB_ENABLE_bm; \
|
||||
}
|
||||
|
||||
#elif ( configUSE_TIMER_INSTANCE == 4 )
|
||||
|
||||
#define TICK_INT_vect RTC_CNT_vect
|
||||
#define INT_FLAGS RTC_INTFLAGS
|
||||
#define INT_MASK RTC_OVF_bm
|
||||
|
||||
#define RTC_PERIOD_HZ(x) (32768 * ( (1.0 / x) ) )
|
||||
#define TICK_init() { \
|
||||
while (RTC.STATUS > 0); \
|
||||
RTC.CTRLA = RTC_PRESCALER_DIV1_gc | 1 << RTC_RTCEN_bp; \
|
||||
RTC.PER = RTC_PERIOD_HZ(configTICK_RATE_HZ); \
|
||||
RTC.INTCTRL |= 1 << RTC_OVF_bp; \
|
||||
}
|
||||
|
||||
#define TICK_stop() { \
|
||||
RTC.CTRLA &= ~(1 << RTC_RTCEN_bp); \
|
||||
RTC.INTCTRL &= ~(1 << RTC_OVF_bp); \
|
||||
}
|
||||
|
||||
#else
|
||||
#undef TICK_INT_vect
|
||||
#undef INT_FLAGS
|
||||
#undef INT_MASK
|
||||
#error Invalid timer setting
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#endif /* PORTHARDWARE_H */
|
109
portable/GCC/AVR_Mega0/portmacro.h
Normal file
109
portable/GCC/AVR_Mega0/portmacro.h
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.1
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef PORTMACRO_H
|
||||
#define PORTMACRO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Port specific definitions.
|
||||
*
|
||||
* The settings in this file configure FreeRTOS correctly for the
|
||||
* given hardware and compiler.
|
||||
*
|
||||
* These settings should not be altered.
|
||||
*-----------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT int
|
||||
#define portSTACK_TYPE uint8_t
|
||||
#define portBASE_TYPE char
|
||||
|
||||
#define portPOINTER_SIZE_TYPE uint16_t
|
||||
|
||||
typedef portSTACK_TYPE StackType_t;
|
||||
typedef signed char BaseType_t;
|
||||
typedef unsigned char UBaseType_t;
|
||||
|
||||
#if (configUSE_16_BIT_TICKS == 1)
|
||||
typedef uint16_t TickType_t;
|
||||
#define portMAX_DELAY (TickType_t)0xffff
|
||||
#else
|
||||
typedef uint32_t TickType_t;
|
||||
#define portMAX_DELAY (TickType_t)0xffffffffUL
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Critical section management. */
|
||||
#define portENTER_CRITICAL() \
|
||||
asm volatile("in __tmp_reg__, __SREG__"); \
|
||||
asm volatile("cli"); \
|
||||
asm volatile("push __tmp_reg__")
|
||||
|
||||
#define portEXIT_CRITICAL() \
|
||||
asm volatile("pop __tmp_reg__"); \
|
||||
asm volatile("out __SREG__, __tmp_reg__")
|
||||
|
||||
#define portDISABLE_INTERRUPTS() asm volatile("cli" ::);
|
||||
#define portENABLE_INTERRUPTS() asm volatile("sei" ::);
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Architecture specifics. */
|
||||
#define portSTACK_GROWTH (-1)
|
||||
#define portTICK_PERIOD_MS ((TickType_t)1000 / configTICK_RATE_HZ)
|
||||
#define portBYTE_ALIGNMENT 1
|
||||
#define portNOP() asm volatile("nop");
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Kernel utilities. */
|
||||
extern void vPortYield(void) __attribute__((naked));
|
||||
#define portYIELD() vPortYield()
|
||||
|
||||
extern void vPortYieldFromISR(void) __attribute__((naked));
|
||||
#define portYIELD_FROM_ISR() vPortYieldFromISR()
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||
#define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters)
|
||||
#define portTASK_FUNCTION(vFunction, pvParameters) void vFunction(void *pvParameters)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PORTMACRO_H */
|
||||
|
Reference in New Issue
Block a user