-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathmain.c
154 lines (144 loc) · 3.52 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
144
145
146
147
148
149
150
151
152
153
154
#include <string.h>
#include <stdio.h>
#include "mhscpu.h"
#include "cm_backtrace.h"
#include "drv_sys.h"
#include "drv_uart.h"
#include "drv_spi.h"
#include "drv_psram.h"
#include "drv_trng.h"
#include "drv_ds28s60.h"
#include "drv_gd25qxx.h"
#include "drv_sensor.h"
#include "drv_rtc.h"
#include "drv_usb.h"
#include "drv_battery.h"
#include "drv_lcd_bright.h"
#include "drv_i2c_io.h"
#include "drv_atecc608b.h"
#include "drv_power.h"
#include "drv_aw32001.h"
#include "drv_button.h"
#include "drv_tamper.h"
#include "drv_exti.h"
#include "drv_motor.h"
#include "hal_lcd.h"
#include "cmsis_os.h"
#include "user_msg.h"
#include "cmd_task.h"
#include "ui_display_task.h"
#include "qrdecode_task.h"
#include "touchpad_task.h"
#include "background_task.h"
#include "fetch_sensitive_data_task.h"
#include "data_parser_task.h"
#include "log_task.h"
#include "usb_task.h"
#include "user_fatfs.h"
#include "user_sqlite3.h"
#include "screen_manager.h"
#include "keystore.h"
#include "log.h"
#include "fingerprint_process.h"
#include "fingerprint_task.h"
#include "low_power.h"
#include "draw_on_lcd.h"
#include "device_setting.h"
#include "anti_tamper.h"
#include "power_on_self_check.h"
#include "account_manager.h"
#include "version.h"
#include "hardware_version.h"
#include "librust_c.h"
int main(void)
{
__enable_irq();
SetAllGpioLow();
SystemClockInit();
SensorInit();
Uart0Init(CmdIsrRcvByte);
FingerprintInit();
cm_backtrace_init("mh1903", GetHardwareVersionString(), GetSoftwareVersionString());
TrngInit();
TamperInit(TamperStartup);
PowerInit();
LcdBrightInit();
LcdCheck();
LcdInit();
DrawBootLogoOnLcd();
Gd25FlashInit();
NvicInit();
PsramInit();
LogInit();
DeviceSettingsInit();
UserMsgInit();
DS28S60_Init();
Atecc608bInit();
AccountsDataCheck();
MountUsbFatfs();
UsbInit();
RtcInit();
MotorInit();
BatteryInit();
Aw32001Init();
ButtonInit();
ExtInterruptInit();
MountSdFatfs();
UserSqlite3Init();
ScreenManagerInit();
AccountManagerInit();
PowerOnSelfCheck();
PrintSystemInfo();
osKernelInitialize();
CreateFingerprintTask();
#ifndef BUILD_PRODUCTION
CreateCmdTask();
#endif
CreateFetchSensitiveDataTask();
CreateDataParserTask();
CreateUiDisplayTask();
CreateQrDecodeTask();
CreateTouchPadTask();
CreateBackgroundTask();
CreateLogTask();
CreateUsbTask();
printf("start FreeRTOS scheduler\r\n");
osKernelStart();
while (1);
}
int _write(int fd, char *pBuffer, int size)
{
for (int i = 0; i < size; i++) {
while (!UART_IsTXEmpty(UART0));
#ifdef BUILD_PRODUCTION
UART_SendData(UART0, '-');
#else
UART_SendData(UART0, (uint8_t) pBuffer[i]);
#endif
}
return size;
}
int fputc(int ch, FILE *f)
{
(void)(f); //unused arg
while (!UART_IsTXEmpty(UART0));
UART_SendData(UART0, (uint8_t) ch);
return ch;
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
printf("err,file=%s,line=%d\r\n", (char *)file, line);
while (1);
}
#endif