Bootloader

Форк
0
/
test_app.cpp 
87 строк · 1.5 Кб
1

2
#include <iopins.h>
3
#include <dispatcher.h>
4
#include <sys_tick.h>
5
#include <watchdog.h>
6
#include <usart.h>
7
#include <tiny_ostream.h>
8
#include <tiny_iomanip.h>
9

10
using namespace Mcucpp;
11
using namespace Mcucpp::IO;
12
using namespace Mcucpp::Clock;
13

14

15
#if defined(STM32F40_41xxx)
16

17
typedef Usart1 BootDevice;
18
typedef Usart1Clock BootDeviceClock;
19

20
typedef Pb6 TxPin;
21
typedef Pb7 RxPin;
22
typedef NullPin DePin;
23
typedef Pd13 Led;
24

25
#elif defined(STM32L471xx)
26

27

28
typedef Usart3 BootDevice;
29
typedef Usart3Clock BootDeviceClock;
30

31
typedef Pc4 TxPin;
32
typedef Pc5 RxPin;
33
typedef Pb1 DePin;
34
typedef Pb9 Led;
35

36
#endif
37

38
basic_ostream<BootDevice> cout;
39

40
void Blink()
41
{
42
    Led::Toggle();
43
    GetCurrentDispatcher().SetTimer(1000, Blink);
44
}
45

46
struct Bar
47
{
48
public:
49
    unsigned c;
50
    unsigned d;
51
};
52

53
struct Foo
54
{
55
public:
56
    int a;
57
    int b;
58
    Bar bar;
59
    uint16_t buffer[100];
60
};
61

62
volatile Foo fooInstance{1, 2, {3, 4}, {0}};
63

64
int main()
65
{
66
    Led::Port::Enable();
67
    Led::SetConfiguration(Led::Port::Out);
68
    Led::Set();
69
    BootDevice::Init(115200);
70
    BootDevice::SelectTxRxPins<TxPin, RxPin>();
71
    BootDevice::SelectDePin<DePin>();
72
    BootDevice::SetRxTimeout(20);
73

74
    cout << "Hello!!\r\n";
75
   
76
    Watchdog::Start(2000);
77
    SysTickTimer::Init(1);
78
    SysTickTimer::EnableInterrupt();
79
    GetCurrentDispatcher().SetTimerFunc(&GetTickCount);
80
    Blink();
81

82
    while (true)
83
    {
84
        GetCurrentDispatcher().Poll();
85
        Watchdog::Reset();
86
    }
87
    return 0;
88
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.