-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathmain.cpp
67 lines (56 loc) · 1.91 KB
/
main.cpp
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
/*
* Copyright (c) 2016-2017, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------
#include <modm/board.hpp>
#include <modm/architecture/interface/assert.hpp>
using modm::accessor::asFlash;
static modm::Abandonment
test_assertion_handler(const modm::AssertionInfo &info)
{
MODM_LOG_INFO << IFSS("#1: '") << asFlash(info.name) << IFSS("'!") << modm::endl;
// The strings are located in FLASH!!!
if (strncmp_P("io.", info.name, 3) == 0) {
MODM_LOG_INFO << IFSS("Ignoring assertion!") << modm::endl;
return modm::Abandonment::Ignore;
}
return modm::Abandonment::DontCare;
}
MODM_ASSERTION_HANDLER(test_assertion_handler);
static modm::Abandonment
test_assertion_handler2(const modm::AssertionInfo &info)
{
MODM_LOG_INFO << IFSS("#2: '") << asFlash(info.name) << IFSS("'!") << modm::endl;
return modm::Abandonment::DontCare;
}
MODM_ASSERTION_HANDLER(test_assertion_handler2);
static modm::Abandonment
test_assertion_handler3(const modm::AssertionInfo &info)
{
MODM_LOG_INFO << IFSS("#3: '") << asFlash(info.name) << IFSS("'!") << modm::endl;
return modm::Abandonment::DontCare;
}
MODM_ASSERTION_HANDLER(test_assertion_handler3);
// ----------------------------------------------------------------------------
int main()
{
Board::initialize();
Leds::setOutput();
MODM_LOG_INFO << IFSS("Starting test...\n");
// only fails for debug builds, but is ignored anyways
modm_assert_continue_fail(false, "io.tx",
"The IO transmit buffer is full!");
modm_assert_continue_fail_debug(false, "uart.init", "UART init failed!");
modm_assert(false, "can.init", "CAN init timed out!");
while (true)
{
LedD13::toggle();
modm::delay(500ms);
}
}