forked from u-blox/ubxlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathu_main.c
153 lines (121 loc) · 4.07 KB
/
u_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
144
145
146
147
148
149
150
151
152
153
/*
* Copyright 2020 u-blox
*
* 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
* @brief The application entry point for the NRF52 platform. Starts
* the platform and calls Unity to run the selected examples/tests.
*/
#ifdef U_CFG_OVERRIDE
# include "u_cfg_override.h" // For a customer's configuration override
#endif
#include "stddef.h" // NULL, size_t etc.
#include "stdint.h" // int32_t etc.
#include "stdbool.h"
#include "u_cfg_sw.h"
#include "u_cfg_os_platform_specific.h"
#include "u_cfg_app_platform_specific.h"
#include "u_cfg_test_platform_specific.h"
#include "u_error_common.h"
#include "u_assert.h"
#include "u_port.h"
#include "u_port_os.h"
#include "u_port_debug.h"
#include "u_runner.h"
#include "nrf_delay.h"
/* ----------------------------------------------------------------
* COMPILE-TIME MACROS
* -------------------------------------------------------------- */
/** When running under automation the target is reset and then
* logging begins, which should be fine, except that the NRF logging
* system over RTT doesn't seem to like reaching a blocking state
* for any length of time, which it will do if there's a long string
* printed (e.g. a lot of tests in the test menu) _before_ an RTT
* logging thing is connected to the MCU. Hence this delay is added
* to keep it happy.
*/
#ifndef U_CFG_STARTUP_DELAY_SECONDS
# define U_CFG_STARTUP_DELAY_SECONDS 10
#endif
/* ----------------------------------------------------------------
* TYPES
* -------------------------------------------------------------- */
/* ----------------------------------------------------------------
* VARIABLES
* -------------------------------------------------------------- */
/* ----------------------------------------------------------------
* STATIC FUNCTIONS
* -------------------------------------------------------------- */
// The task within which th examples and tests run.
static void appTask(void *pParam)
{
(void) pParam;
#ifdef U_CFG_MUTEX_DEBUG
uMutexDebugInit();
uMutexDebugWatchdog(uMutexDebugPrint, NULL,
U_MUTEX_DEBUG_WATCHDOG_TIMEOUT_SECONDS);
#endif
uPortInit();
uPortLog("\n\nU_APP: application task started.\n");
UNITY_BEGIN();
uPortLog("U_APP: functions available:\n\n");
uRunnerPrintAll("U_APP: ");
#ifdef U_CFG_APP_FILTER
uPortLog("U_APP: running functions that begin with \"%s\".\n",
U_PORT_STRINGIFY_QUOTED(U_CFG_APP_FILTER));
uRunnerRunFiltered(U_PORT_STRINGIFY_QUOTED(U_CFG_APP_FILTER),
"U_APP: ");
#else
uPortLog("U_APP: running all functions.\n");
uRunnerRunAll("U_APP: ");
#endif
// The things that we have run may have
// called deinit so call init again here.
uPortInit();
UNITY_END();
uPortLog("\n\nU_APP: application task ended.\n");
uPortDeinit();
while (1) {}
}
/* ----------------------------------------------------------------
* PUBLIC FUNCTIONS
* -------------------------------------------------------------- */
// Unity setUp() function.
void setUp(void)
{
// Nothing to do
}
// Unity tearDown() function.
void tearDown(void)
{
// Add a small delay between test to make sure the
// host have some time to read out RTT buffer
nrf_delay_ms(10);
}
void testFail(void)
{
// Nothing to do
}
// Entry point
int main(void)
{
// Start the platform to run the tests
uPortPlatformStart(appTask, NULL,
U_CFG_OS_APP_TASK_STACK_SIZE_BYTES,
U_CFG_OS_APP_TASK_PRIORITY);
// Should never get here
U_ASSERT(false);
return 0;
}
// End of file