mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-01 11:53:53 -04:00
Update to V4.5.0 files and directory structure.
This commit is contained in:
parent
1362bebfdc
commit
98a9959a44
758 changed files with 53177 additions and 3139 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
|||
#define portINITIAL_XPSR ( 0x01000000 )
|
||||
|
||||
/* For backward compatibility, ensure configKERNEL_INTERRUPT_PRIORITY is
|
||||
defined. The value zero should also ensure backward compatibility.
|
||||
defined. The value 255 should also ensure backward compatibility.
|
||||
FreeRTOS.org versions prior to V4.3.0 did not include this definition. */
|
||||
#ifndef configKERNEL_INTERRUPT_PRIORITY
|
||||
#define configKERNEL_INTERRUPT_PRIORITY 255
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
@ -42,8 +42,8 @@
|
|||
|
||||
#include <FreeRTOSConfig.h>
|
||||
|
||||
/* For backward compatibility, ensure configKERNEL_INTERRUPT_PRIORITY is
|
||||
defined. The value zero should also ensure backward compatibility.
|
||||
/* For backward compatibility, ensure configKERNEL_INTERRUPT_PRIORITY is
|
||||
defined. The value zero should also ensure backward compatibility.
|
||||
FreeRTOS.org versions prior to V4.3.0 did not include this definition. */
|
||||
#ifndef configKERNEL_INTERRUPT_PRIORITY
|
||||
#define configKERNEL_INTERRUPT_PRIORITY 0
|
||||
|
@ -79,60 +79,53 @@ vSetMSP
|
|||
/*-----------------------------------------------------------*/
|
||||
|
||||
xPortPendSVHandler:
|
||||
mrs r0, psp
|
||||
cbz r0, no_save
|
||||
/* Save the context into the TCB. */
|
||||
sub r0, r0, #0x20
|
||||
stm r0, {r4-r11}
|
||||
nop
|
||||
sub r0, r0, #0x04
|
||||
mrs r0, psp
|
||||
cbz r0, no_save
|
||||
/* Save the context into the TCB. */
|
||||
stmdb r0!, {r4-r11}
|
||||
sub r0, r0, #0x04
|
||||
ldr r1, =uxCriticalNesting
|
||||
ldr r1, [r1]
|
||||
str R1, [r0, #0x00]
|
||||
ldr r1, =pxCurrentTCB
|
||||
ldr r1, [r1]
|
||||
str r0, [r1]
|
||||
ldr r2, =pxCurrentTCB
|
||||
ldr r1, [r1]
|
||||
ldr r2, [r2]
|
||||
str r1, [r0]
|
||||
str r0, [r2]
|
||||
|
||||
no_save:
|
||||
ldr r0, =vPortSwitchContext
|
||||
push {r14}
|
||||
blx r0
|
||||
pop {r14}
|
||||
|
||||
/* Restore the context. */
|
||||
push {r14}
|
||||
bl vPortSwitchContext
|
||||
pop {r14}
|
||||
/* Restore the context. */
|
||||
ldr r1, =pxCurrentTCB
|
||||
ldr r1, [r1]
|
||||
ldr r0, [r1]
|
||||
ldm r0, {r1, r4-r11}
|
||||
nop
|
||||
ldr r1, [r1]
|
||||
ldr r0, [r1]
|
||||
ldmia r0!, {r1, r4-r11}
|
||||
ldr r2, =uxCriticalNesting
|
||||
str r1, [r2]
|
||||
add r0, r0, #0x24
|
||||
msr psp, r0
|
||||
orr r14, r14, #0xd
|
||||
/* Exit with interrupts in the state required by the task. */
|
||||
cbnz r1, sv_disable_interrupts
|
||||
bx r14
|
||||
|
||||
sv_disable_interrupts:
|
||||
str r1, [r2]
|
||||
msr psp, r0
|
||||
orr r14, r14, #0xd
|
||||
/* Exit with interrupts in the state required by the task. */
|
||||
cbnz r1, sv_disable_interrupts
|
||||
bx r14
|
||||
|
||||
sv_disable_interrupts:
|
||||
mov r1, #configKERNEL_INTERRUPT_PRIORITY
|
||||
msr basepri, R1
|
||||
bx r14
|
||||
|
||||
bx r14
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
xPortSysTickHandler:
|
||||
/* Call the scheduler tick function. */
|
||||
ldr r0, =vPortIncrementTick
|
||||
push {r14}
|
||||
blx r0
|
||||
bl vPortIncrementTick
|
||||
pop {r14}
|
||||
|
||||
/* If using preemption, also force a context switch. */
|
||||
#if configUSE_PREEMPTION == 1
|
||||
push {r14}
|
||||
ldr r0, =vPortYieldFromISR
|
||||
blx r0
|
||||
bl vPortYieldFromISR
|
||||
pop {r14}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
@ -90,7 +90,6 @@ extern void vPortYieldFromISR( void );
|
|||
|
||||
/* Critical section management. */
|
||||
|
||||
extern void vPortEnableInterrupts( void );
|
||||
extern void vPortEnterCritical( void );
|
||||
extern void vPortExitCritical( void );
|
||||
extern void vPortSetInterruptMask( void );
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
; FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
;
|
||||
; This file is part of the FreeRTOS.org distribution.
|
||||
;
|
||||
|
|
|
@ -70,107 +70,107 @@ _evba:
|
|||
ORG 0x000
|
||||
// Unrecoverable Exception.
|
||||
_handle_Unrecoverable_Exception:
|
||||
rjmp _handle_Unrecoverable_Exception
|
||||
rjmp $
|
||||
|
||||
ORG 0x004
|
||||
// TLB Multiple Hit: UNUSED IN AVR32UC.
|
||||
_handle_TLB_Multiple_Hit:
|
||||
rjmp _handle_TLB_Multiple_Hit
|
||||
rjmp $
|
||||
|
||||
ORG 0x008
|
||||
// Bus Error Data Fetch.
|
||||
_handle_Bus_Error_Data_Fetch:
|
||||
rjmp _handle_Bus_Error_Data_Fetch
|
||||
rjmp $
|
||||
|
||||
ORG 0x00C
|
||||
// Bus Error Instruction Fetch.
|
||||
_handle_Bus_Error_Instruction_Fetch:
|
||||
rjmp _handle_Bus_Error_Instruction_Fetch
|
||||
rjmp $
|
||||
|
||||
ORG 0x010
|
||||
// NMI.
|
||||
_handle_NMI:
|
||||
rjmp _handle_NMI
|
||||
rjmp $
|
||||
|
||||
ORG 0x014
|
||||
// Instruction Address.
|
||||
_handle_Instruction_Address:
|
||||
rjmp _handle_Instruction_Address
|
||||
rjmp $
|
||||
|
||||
ORG 0x018
|
||||
// ITLB Protection.
|
||||
_handle_ITLB_Protection:
|
||||
rjmp _handle_ITLB_Protection
|
||||
rjmp $
|
||||
|
||||
ORG 0x01C
|
||||
// Breakpoint.
|
||||
_handle_Breakpoint:
|
||||
rjmp _handle_Breakpoint
|
||||
rjmp $
|
||||
|
||||
ORG 0x020
|
||||
// Illegal Opcode.
|
||||
_handle_Illegal_Opcode:
|
||||
rjmp _handle_Illegal_Opcode
|
||||
rjmp $
|
||||
|
||||
ORG 0x024
|
||||
// Unimplemented Instruction.
|
||||
_handle_Unimplemented_Instruction:
|
||||
rjmp _handle_Unimplemented_Instruction
|
||||
rjmp $
|
||||
|
||||
ORG 0x028
|
||||
// Privilege Violation.
|
||||
_handle_Privilege_Violation:
|
||||
rjmp _handle_Privilege_Violation
|
||||
rjmp $
|
||||
|
||||
ORG 0x02C
|
||||
// Floating-Point: UNUSED IN AVR32UC.
|
||||
_handle_Floating_Point:
|
||||
rjmp _handle_Floating_Point
|
||||
rjmp $
|
||||
|
||||
ORG 0x030
|
||||
// Coprocessor Absent: UNUSED IN AVR32UC.
|
||||
_handle_Coprocessor_Absent:
|
||||
rjmp _handle_Coprocessor_Absent
|
||||
rjmp $
|
||||
|
||||
ORG 0x034
|
||||
// Data Address (Read).
|
||||
_handle_Data_Address_Read:
|
||||
rjmp _handle_Data_Address_Read
|
||||
rjmp $
|
||||
|
||||
ORG 0x038
|
||||
// Data Address (Write).
|
||||
_handle_Data_Address_Write:
|
||||
rjmp _handle_Data_Address_Write
|
||||
rjmp $
|
||||
|
||||
ORG 0x03C
|
||||
// DTLB Protection (Read).
|
||||
_handle_DTLB_Protection_Read:
|
||||
rjmp _handle_DTLB_Protection_Read
|
||||
rjmp $
|
||||
|
||||
ORG 0x040
|
||||
// DTLB Protection (Write).
|
||||
_handle_DTLB_Protection_Write:
|
||||
rjmp _handle_DTLB_Protection_Write
|
||||
rjmp $
|
||||
|
||||
ORG 0x044
|
||||
// DTLB Modified: UNUSED IN AVR32UC.
|
||||
_handle_DTLB_Modified:
|
||||
rjmp _handle_DTLB_Modified
|
||||
rjmp $
|
||||
|
||||
ORG 0x050
|
||||
// ITLB Miss: UNUSED IN AVR32UC.
|
||||
_handle_ITLB_Miss:
|
||||
rjmp _handle_ITLB_Miss
|
||||
rjmp $
|
||||
|
||||
ORG 0x060
|
||||
// DTLB Miss (Read): UNUSED IN AVR32UC.
|
||||
_handle_DTLB_Miss_Read:
|
||||
rjmp _handle_DTLB_Miss_Read
|
||||
rjmp $
|
||||
|
||||
ORG 0x070
|
||||
// DTLB Miss (Write): UNUSED IN AVR32UC.
|
||||
_handle_DTLB_Miss_Write:
|
||||
rjmp _handle_DTLB_Miss_Write
|
||||
rjmp $
|
||||
|
||||
ORG 0x100
|
||||
// Supervisor Call.
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
@ -76,6 +76,8 @@ volatile unsigned portLONG ulCriticalNesting = 9999UL;
|
|||
|
||||
#if( configTICK_USE_TC==0 )
|
||||
static void prvScheduleNextTick( void );
|
||||
#else
|
||||
static void prvClearTcInt( void );
|
||||
#endif
|
||||
|
||||
/* Setup the timer to generate the tick interrupts. */
|
||||
|
@ -169,7 +171,7 @@ static void vTick( void )
|
|||
|
||||
#if( configTICK_USE_TC==1 )
|
||||
/* Clear the interrupt flag. */
|
||||
AVR32_TC.channel[configTICK_TC_CHANNEL].sr;
|
||||
prvClearTcInt();
|
||||
#else
|
||||
/* Schedule the COUNT&COMPARE match interrupt in (configCPU_CLOCK_HZ/configTICK_RATE_HZ)
|
||||
clock cycles from now. */
|
||||
|
@ -201,6 +203,7 @@ void SCALLYield( void )
|
|||
different optimisation levels. The interrupt flags can therefore not always
|
||||
be saved to the stack. Instead the critical section nesting level is stored
|
||||
in a variable, which is then saved as part of the stack context. */
|
||||
#pragma optimize = no_inline
|
||||
void vPortEnterCritical( void )
|
||||
{
|
||||
/* Disable interrupts */
|
||||
|
@ -213,6 +216,7 @@ void vPortEnterCritical( void )
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#pragma optimize = no_inline
|
||||
void vPortExitCritical( void )
|
||||
{
|
||||
if(ulCriticalNesting > portNO_CRITICAL_NESTING)
|
||||
|
@ -301,6 +305,7 @@ clock cycles from now. */
|
|||
Set_system_register(AVR32_COMPARE, lCycles);
|
||||
}
|
||||
|
||||
#pragma optimize = no_inline
|
||||
static void prvScheduleNextTick(void)
|
||||
{
|
||||
unsigned long lCycles, lCount;
|
||||
|
@ -320,6 +325,12 @@ clock cycles from now. */
|
|||
}
|
||||
Set_system_register(AVR32_COMPARE, lCycles);
|
||||
}
|
||||
#else
|
||||
#pragma optimize = no_inline
|
||||
static void prvClearTcInt(void)
|
||||
{
|
||||
AVR32_TC.channel[configTICK_TC_CHANNEL].sr;
|
||||
}
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
; FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
;
|
||||
; This file is part of the FreeRTOS.org distribution.
|
||||
;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
; FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
;
|
||||
; This file is part of the FreeRTOS.org distribution.
|
||||
;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS.org distribution.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Implementation of functions defined in portable.h for the ST STR91x ARM7
|
||||
* Implementation of functions defined in portable.h for the ST STR91x ARM9
|
||||
* port.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
|
@ -43,22 +43,54 @@
|
|||
|
||||
/* Standard includes. */
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
#ifndef configUSE_WATCHDOG_TICK
|
||||
#error configUSE_WATCHDOG_TICK must be set to either 1 or 0 in FreeRTOSConfig.h to use either the Watchdog or timer 2 to generate the tick interrupt respectively.
|
||||
#endif
|
||||
|
||||
/* Constants required to setup the initial stack. */
|
||||
#ifndef _RUN_TASK_IN_ARM_MODE_
|
||||
#define portINITIAL_SPSR ( ( portSTACK_TYPE ) 0x3f ) /* System mode, THUMB mode, interrupts enabled. */
|
||||
#else
|
||||
#define portINITIAL_SPSR ( ( portSTACK_TYPE ) 0x1f ) /* System mode, ARM mode, interrupts enabled. */
|
||||
#endif
|
||||
|
||||
#define portINSTRUCTION_SIZE ( ( portSTACK_TYPE ) 4 )
|
||||
|
||||
/* Constants required to handle critical sections. */
|
||||
#define portNO_CRITICAL_NESTING ( ( unsigned portLONG ) 0 )
|
||||
|
||||
#ifndef abs
|
||||
#define abs(x) ((x)>0 ? (x) : -(x))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Toggle a led using the following algorithm:
|
||||
* if ( GPIO_ReadBit(GPIO9, GPIO_Pin_2) )
|
||||
* {
|
||||
* GPIO_WriteBit( GPIO9, GPIO_Pin_2, Bit_RESET );
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* GPIO_WriteBit( GPIO9, GPIO_Pin_2, Bit_RESET );
|
||||
* }
|
||||
*
|
||||
*/
|
||||
#define TOGGLE_LED(port,pin) \
|
||||
if ( ((((port)->DR[(pin)<<2])) & (pin)) != Bit_RESET ) \
|
||||
{ \
|
||||
(port)->DR[(pin) <<2] = 0x00; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(port)->DR[(pin) <<2] = (pin); \
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -73,12 +105,16 @@ unsigned portLONG ulCriticalNesting = ( unsigned portLONG ) 9999;
|
|||
/* Tick interrupt routines for cooperative and preemptive operation
|
||||
respectively. The preemptive version is not defined as __irq as it is called
|
||||
from an asm wrapper function. */
|
||||
__arm __irq void vPortNonPreemptiveTick( void );
|
||||
void WDG_IRQHandler( void );
|
||||
|
||||
/* VIC interrupt default handler. */
|
||||
static void prvDefaultHandler( void );
|
||||
|
||||
#if configUSE_WATCHDOG_TICK == 0
|
||||
/* Used to update the OCR timer register */
|
||||
static u16 s_nPulseLength;
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
|
@ -174,90 +210,189 @@ void vPortEndScheduler( void )
|
|||
|
||||
/* This function is called from an asm wrapper, so does not require the __irq
|
||||
keyword. */
|
||||
void WDG_IRQHandler( void )
|
||||
{
|
||||
/* Increment the tick counter. */
|
||||
vTaskIncrementTick();
|
||||
#if configUSE_WATCHDOG_TICK == 1
|
||||
|
||||
#if configUSE_PREEMPTION == 1
|
||||
/* The new tick value might unblock a task. Ensure the highest task that
|
||||
is ready to execute is the task that will execute when the tick ISR
|
||||
exits. */
|
||||
vTaskSwitchContext();
|
||||
#endif
|
||||
|
||||
/* Clear the interrupt in the watchdog. */
|
||||
WDG->SR &= ~0x0001;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#ifndef abs
|
||||
#define abs(x) ((x)>0 ? (x) : -(x))
|
||||
#endif
|
||||
|
||||
static void prvFindFactors(u32 n, u16 *a, u32 *b)
|
||||
{
|
||||
/* This function is copied from the ST STR7 library and is
|
||||
copyright STMicroelectronics. Reproduced with permission. */
|
||||
|
||||
u32 b0;
|
||||
u16 a0;
|
||||
long err, err_min=n;
|
||||
|
||||
*a = a0 = ((n-1)/65536ul) + 1;
|
||||
*b = b0 = n / *a;
|
||||
|
||||
for (; *a <= 256; (*a)++)
|
||||
static void prvFindFactors(u32 n, u16 *a, u32 *b)
|
||||
{
|
||||
*b = n / *a;
|
||||
err = (long)*a * (long)*b - (long)n;
|
||||
if (abs(err) > (*a / 2))
|
||||
/* This function is copied from the ST STR7 library and is
|
||||
copyright STMicroelectronics. Reproduced with permission. */
|
||||
|
||||
u32 b0;
|
||||
u16 a0;
|
||||
long err, err_min=n;
|
||||
|
||||
*a = a0 = ((n-1)/65536ul) + 1;
|
||||
*b = b0 = n / *a;
|
||||
|
||||
for (; *a <= 256; (*a)++)
|
||||
{
|
||||
(*b)++;
|
||||
*b = n / *a;
|
||||
err = (long)*a * (long)*b - (long)n;
|
||||
if (abs(err) > (*a / 2))
|
||||
{
|
||||
(*b)++;
|
||||
err = (long)*a * (long)*b - (long)n;
|
||||
}
|
||||
if (abs(err) < abs(err_min))
|
||||
{
|
||||
err_min = err;
|
||||
a0 = *a;
|
||||
b0 = *b;
|
||||
if (err == 0) break;
|
||||
}
|
||||
}
|
||||
if (abs(err) < abs(err_min))
|
||||
|
||||
*a = a0;
|
||||
*b = b0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupTimerInterrupt( void )
|
||||
{
|
||||
WDG_InitTypeDef xWdg;
|
||||
unsigned portSHORT a;
|
||||
unsigned portLONG n = configCPU_PERIPH_HZ / configTICK_RATE_HZ, b;
|
||||
|
||||
/* Configure the watchdog as a free running timer that generates a
|
||||
periodic interrupt. */
|
||||
|
||||
SCU_APBPeriphClockConfig( __WDG, ENABLE );
|
||||
WDG_DeInit();
|
||||
WDG_StructInit(&xWdg);
|
||||
prvFindFactors( n, &a, &b );
|
||||
xWdg.WDG_Prescaler = a - 1;
|
||||
xWdg.WDG_Preload = b - 1;
|
||||
WDG_Init( &xWdg );
|
||||
WDG_ITConfig(ENABLE);
|
||||
|
||||
/* Configure the VIC for the WDG interrupt. */
|
||||
VIC_Config( WDG_ITLine, VIC_IRQ, 10 );
|
||||
VIC_ITCmd( WDG_ITLine, ENABLE );
|
||||
|
||||
/* Install the default handlers for both VIC's. */
|
||||
VIC0->DVAR = ( unsigned portLONG ) prvDefaultHandler;
|
||||
VIC1->DVAR = ( unsigned portLONG ) prvDefaultHandler;
|
||||
|
||||
WDG_Cmd(ENABLE);
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void WDG_IRQHandler( void )
|
||||
{
|
||||
{
|
||||
err_min = err;
|
||||
a0 = *a;
|
||||
b0 = *b;
|
||||
if (err == 0) break;
|
||||
/* Increment the tick counter. */
|
||||
vTaskIncrementTick();
|
||||
|
||||
#if configUSE_PREEMPTION == 1
|
||||
{
|
||||
/* The new tick value might unblock a task. Ensure the highest task that
|
||||
is ready to execute is the task that will execute when the tick ISR
|
||||
exits. */
|
||||
vTaskSwitchContext();
|
||||
}
|
||||
#endif /* configUSE_PREEMPTION. */
|
||||
|
||||
/* Clear the interrupt in the watchdog. */
|
||||
WDG->SR &= ~0x0001;
|
||||
}
|
||||
}
|
||||
|
||||
*a = a0;
|
||||
*b = b0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
#else
|
||||
|
||||
static void prvSetupTimerInterrupt( void )
|
||||
{
|
||||
WDG_InitTypeDef xWdg;
|
||||
unsigned portSHORT a;
|
||||
unsigned portLONG n = configCPU_PERIPH_HZ / configTICK_RATE_HZ, b;
|
||||
static void prvFindFactors(u32 n, u8 *a, u16 *b)
|
||||
{
|
||||
/* This function is copied from the ST STR7 library and is
|
||||
copyright STMicroelectronics. Reproduced with permission. */
|
||||
|
||||
u16 b0;
|
||||
u8 a0;
|
||||
long err, err_min=n;
|
||||
|
||||
|
||||
*a = a0 = ((n-1)/256) + 1;
|
||||
*b = b0 = n / *a;
|
||||
|
||||
for (; *a <= 256; (*a)++)
|
||||
{
|
||||
*b = n / *a;
|
||||
err = (long)*a * (long)*b - (long)n;
|
||||
if (abs(err) > (*a / 2))
|
||||
{
|
||||
(*b)++;
|
||||
err = (long)*a * (long)*b - (long)n;
|
||||
}
|
||||
if (abs(err) < abs(err_min))
|
||||
{
|
||||
err_min = err;
|
||||
a0 = *a;
|
||||
b0 = *b;
|
||||
if (err == 0) break;
|
||||
}
|
||||
}
|
||||
|
||||
*a = a0;
|
||||
*b = b0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Configure the watchdog as a free running timer that generates a
|
||||
periodic interrupt. */
|
||||
static void prvSetupTimerInterrupt( void )
|
||||
{
|
||||
unsigned portCHAR a;
|
||||
unsigned portSHORT b;
|
||||
unsigned portLONG n = configCPU_PERIPH_HZ / configTICK_RATE_HZ;
|
||||
|
||||
TIM_InitTypeDef timer;
|
||||
|
||||
SCU_APBPeriphClockConfig( __TIM23, ENABLE );
|
||||
TIM_DeInit(TIM2);
|
||||
TIM_StructInit(&timer);
|
||||
prvFindFactors( n, &a, &b );
|
||||
|
||||
timer.TIM_Mode = TIM_OCM_CHANNEL_1;
|
||||
timer.TIM_OC1_Modes = TIM_TIMING;
|
||||
timer.TIM_Clock_Source = TIM_CLK_APB;
|
||||
timer.TIM_Clock_Edge = TIM_CLK_EDGE_RISING;
|
||||
timer.TIM_Prescaler = a-1;
|
||||
timer.TIM_Pulse_Level_1 = TIM_HIGH;
|
||||
timer.TIM_Pulse_Length_1 = s_nPulseLength = b-1;
|
||||
|
||||
TIM_Init (TIM2, &timer);
|
||||
TIM_ITConfig(TIM2, TIM_IT_OC1, ENABLE);
|
||||
/* Configure the VIC for the WDG interrupt. */
|
||||
VIC_Config( TIM2_ITLine, VIC_IRQ, 10 );
|
||||
VIC_ITCmd( TIM2_ITLine, ENABLE );
|
||||
|
||||
/* Install the default handlers for both VIC's. */
|
||||
VIC0->DVAR = ( unsigned portLONG ) prvDefaultHandler;
|
||||
VIC1->DVAR = ( unsigned portLONG ) prvDefaultHandler;
|
||||
|
||||
TIM_CounterCmd(TIM2, TIM_CLEAR);
|
||||
TIM_CounterCmd(TIM2, TIM_START);
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
SCU_APBPeriphClockConfig( __WDG, ENABLE );
|
||||
WDG_DeInit();
|
||||
WDG_StructInit(&xWdg);
|
||||
prvFindFactors( n, &a, &b );
|
||||
xWdg.WDG_Prescaler = a - 1;
|
||||
xWdg.WDG_Preload = b - 1;
|
||||
WDG_Init( &xWdg );
|
||||
WDG_ITConfig(ENABLE);
|
||||
|
||||
/* Configure the VIC for the WDG interrupt. */
|
||||
VIC_Config( WDG_ITLine, VIC_IRQ, 10 );
|
||||
VIC_ITCmd( WDG_ITLine, ENABLE );
|
||||
|
||||
/* Install the default handlers for both VIC's. */
|
||||
VIC0->DVAR = ( unsigned portLONG ) prvDefaultHandler;
|
||||
VIC1->DVAR = ( unsigned portLONG ) prvDefaultHandler;
|
||||
|
||||
WDG_Cmd(ENABLE);
|
||||
}
|
||||
void TIM2_IRQHandler( void )
|
||||
{
|
||||
/* Reset the timer counter to avioid overflow. */
|
||||
TIM2->OC1R += s_nPulseLength;
|
||||
|
||||
/* Increment the tick counter. */
|
||||
vTaskIncrementTick();
|
||||
|
||||
#if configUSE_PREEMPTION == 1
|
||||
{
|
||||
/* The new tick value might unblock a task. Ensure the highest task that
|
||||
is ready to execute is the task that will execute when the tick ISR
|
||||
exits. */
|
||||
vTaskSwitchContext();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Clear the interrupt in the watchdog. */
|
||||
TIM2->SR &= ~TIM_FLAG_OC1;
|
||||
}
|
||||
|
||||
#endif /* USE_WATCHDOG_TICK */
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
FreeRTOS.org V4.5.0 - Copyright (C) 2003-2007 Richard Barry.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue