-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbsp_assert.cpp
79 lines (62 loc) · 2.39 KB
/
bsp_assert.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
68
69
70
71
72
73
74
75
76
77
78
79
/*
* bsp-motorctrl, a board support package library for a STM32 based motor
* control PCB. It is designed to abstract access to HW features in a generic
* and simple way. Please note thet it should not conain any buissness logic.
*
* Copyright (C) 2020 Julian Friedrich
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* You can file issues at https://github.com/fjulian79/bsp-motorctrl
*/
#include <stdio.h>
#include <stm32f1xx_ll_system.h>
#include <stm32f1xx_ll_tim.h>
#include "bsp/bsp_gpio.h"
#include "bsp/bsp_tty.h"
#include "bsp/bsp_motor.h"
#if BSP_ASSERT == BSP_ENABLED
void bspAbort(const char *pFunc, int line)
{
uint8_t idx = 0;
char buffer[80];
/* Disable all interrupts to prevent all further actions */
__disable_irq();
snprintf(buffer, 80, "\nAssertion in %s(%d)\n", pFunc, line);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* ATTENTION: Do here all what's needed to prevent any kind of hardware
* damage or unintended actions
**/
LL_TIM_OC_SetCompareCH1(TIM3, 0);
LL_TIM_OC_SetCompareCH2(TIM3, 0);
LL_TIM_OC_SetCompareCH3(TIM3, 0);
LL_TIM_OC_SetCompareCH4(TIM3, 0);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
while(1)
{
#if BSP_ASSERT_MESSAGE == BSP_ENABLED
bspTTYAssertMessage(buffer);
#endif /* BSP_ASSERT_MESSAGE == BSP_ENABLED */
idx=0;
while(idx < (BSP_ASSERT_MESSAGE_MS/(BSP_ASSERT_LED_MS/2)))
{
bspGpioToggle(BSP_GPIO_LED);
LL_mDelay(BSP_ASSERT_LED_MS/2);
idx++;
}
}
}
#endif /* BSP_ASSERT == BSP_ENABLED */