-
Notifications
You must be signed in to change notification settings - Fork 49
/
main.c
37 lines (29 loc) · 939 Bytes
/
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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stm32isp.h>
int main(int argc, char *argv[])
{
if(argc != 3){
printf("parameter error!\nexample: stm32isp /dev/ttyUSB0 stm32_test.bin\n");
return 0;
}
stm32isp_init(argv[1], 57600, 8, 1, 'N', 30);
printf("syncing...");
if(stm32isp_sync()) printf("sync ok\n");
else printf("sync fail\n\n");
stm32isp_get_command();
stm32isp_get_ID_command();
printf("erasing flash...\n");
if(stm32isp_erase_all()) printf("erase flash done\n");
else printf("erase flash fail\n\n");
printf("starting download...\n");
if(stm32isp_write_bin(argv[2])) printf("download success\n");
else printf("download fail\n\n");
printf("starting verify...\n");
if(stm32isp_verify(argv[2])) printf("verify success\n");
else printf("verify fail\n");
stm32isp_close();
return 0;
}