-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.h
130 lines (104 loc) · 3.82 KB
/
main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* main.h
*
*/
//Heap allocation
#pragma NOINIT(ucHeap)
uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
//time counter
#pragma NOINIT(timeCounter)
unsigned long timeCounter;
int uartsetup = 0;
/* Use for recovery */
#pragma DATA_SECTION(recoverable, ".map") //indicate whether task stacks exist
/* Log whether the system is recoverable */
int recoverable;
/* Use for logging progress of applications */
#pragma DATA_SECTION(information, ".map")
unsigned long information[10];
/* -------------- Required functions for FreeRTOS operation --------------- */
/* Prototypes for the standard FreeRTOS callback/hook functions implemented */
void vApplicationMallocFailedHook( void );
void vApplicationIdleHook( void );
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
void vApplicationTickHook( void );
/* Called if a call to pvPortMalloc() fails because there is insufficient
free memory available in the FreeRTOS heap. pvPortMalloc() is called
internally by FreeRTOS API functions that create tasks, queues, software
timers, and semaphores. The size of the FreeRTOS heap is set by the
configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
void vApplicationMallocFailedHook( void )
{
/* Force an assert. */
configASSERT( ( volatile void * ) NULL );
}
/* Run time stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
function is called if a stack overflow is detected.
See http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
{
( void ) pcTaskName;
( void ) pxTask;
/* Force an assert. */
configASSERT( ( volatile void * ) NULL );
}
/* Can be used to implement background services */
void vApplicationIdleHook( void )
{
__bis_SR_register( LPM4_bits + GIE );
__no_operation();
}
/* Hook at each application tick */
void vApplicationTickHook( void )
{
return;
}
/* The MSP430X port uses this callback function to configure its tick interrupt.
This allows the application to choose the tick interrupt source.
configTICK_VECTOR must also be set in FreeRTOSConfig.h to the correct
interrupt vector for the chosen tick interrupt source. This implementation of
vApplicationSetupTimerInterrupt() generates the tick from timer A0, so in this
case configTICK_VECTOR is set to TIMER0_A0_VECTOR. */
void vApplicationSetupTimerInterrupt( void )
{
const unsigned short usACLK_Frequency_Hz = 32768;
/* Ensure the timer is stopped. */
TA0CTL = 0;
/* Run the timer from the ACLK. */
TA0CTL = TASSEL_1;
/* Clear everything to start with. */
TA0CTL |= TACLR;
/* Set the compare match value according to the tick rate we want. */
TA0CCR0 = usACLK_Frequency_Hz / configTICK_RATE_HZ;
TA0CCR1 = TA0CCR0;
TA0CCTL1 = OUTMOD_3;
/* Enable the interrupts. */
TA0CCTL0 = CCIE;
/* Start up clean. */
TA0CTL |= TACLR;
/* Up mode. */
TA0CTL |= MC_1;
}
void vConfigureTimerForRunTimeStats( void )
{
/* Configure a timer that is used as the time base for run time stats. See
http://www.freertos.org/rtos-run-time-stats.html */
/* Ensure the timer is stopped. */
TA1CTL = 0;
/* Start up clean. */
TA1CTL |= TACLR;
/* Run the timer from the ACLK/8, continuous mode, interrupt enable. */
TA1CTL = TASSEL_1 | ID__8 | MC__CONTINUOUS | TAIE;
}
/* Used for maintaining a 32-bit run time stats counter from a 16-bit timer. */
volatile uint32_t ulRunTimeCounterOverflows = 0;
#pragma vector=TIMER1_A1_VECTOR
__interrupt void v4RunTimeStatsTimerOverflow( void )
{
TA1CTL &= ~TAIFG;
/* 16-bit overflow, so add 17th bit. */
ulRunTimeCounterOverflows += 0x10000;
__bic_SR_register_on_exit( SCG1 + SCG0 + OSCOFF + CPUOFF );
}
/* -------------- End: Required functions for FreeRTOS operation --------------- */