-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
143 lines (124 loc) · 3.61 KB
/
main.c
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*************************************************************************************************/
/*!
* \file main.c
*
* \brief Main file for dats application.
*
* Copyright (c) 2013-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* 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.
*/
/*************************************************************************************************/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "mxc_device.h"
#include "wut.h"
#include "lp.h"
#include "led.h"
#include "board.h"
/*! \brief Stack initialization for app. */
extern void StackInitDats(void);
extern void bleStartup(void);
/* =| vApplicationIdleHook |==============================
*
* Call the user defined function from within the idle task. This
* allows the application designer to add background functionality
* without the overhead of a separate task.
* NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES,
* CALL A FUNCTION THAT MIGHT BLOCK.
*
* =======================================================
*/
void vApplicationIdleHook(void)
{
/* Sleep while idle */
LED_Off(1);
MXC_LP_EnterSleepMode();
LED_On(1);
}
void vTask1(void *pvParameters)
{
TickType_t xLastWakeTime;
/* Get task start time */
xLastWakeTime = xTaskGetTickCount();
while (1)
{
printf("self defined task is running \n");
/* Wait 1 second until next run */
vTaskDelayUntil(&xLastWakeTime, configTICK_RATE_HZ);
}
}
/*************************************************************************************************/
/*!
* \fn main
*
* \brief Entry point for demo software.
*
* \param None.
*
* \return None.
*/
/*************************************************************************************************/
int main(void)
{
/* Delay to prevent bricks */
volatile int i;
for(i = 0; i < 0x3FFFFF; i++) {}
bleStartup();
//WsfOsEnterMainLoop();
xTaskCreate(vTask1, (const char *)"Task1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
/* Start scheduler */
vTaskStartScheduler();
/* This code is only reached if the scheduler failed to start */
printf("ERROR: FreeRTOS did not start due to above error!\n");
while (1) {
__NOP();
}
/* Quiet GCC warnings */
return -1;
}
typedef struct __attribute__((packed)) ContextStateFrame {
uint32_t r0;
uint32_t r1;
uint32_t r2;
uint32_t r3;
uint32_t r12;
uint32_t lr;
uint32_t return_address;
uint32_t xpsr;
} sContextStateFrame;
/*****************************************************************/
void HardFault_Handler(void)
{
__asm(
" TST LR, #4\n"
" ITE EQ \n"
" MRSEQ R0, MSP \n"
" MRSNE R0, PSP \n"
" B HardFault_Decoder \n");
}
/*****************************************************************/
/* Disable optimizations for this function so "frame" argument */
/* does not get optimized away */
__attribute__((optimize("O0")))
void HardFault_Decoder(sContextStateFrame *frame)
{
/* Hang here */
while(1) {}
}