-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
62 lines (47 loc) · 1.24 KB
/
Copy pathmain.c
File metadata and controls
62 lines (47 loc) · 1.24 KB
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
#include <string.h>
#include "stm32f10x.h"
#include "dt_gpio.h"
#include "dt_sys_tick.h"
#include "dt_uart.h"
#define LED1_DELAY 1000 //ms
#define TEST_UART DT_UART1
int main(void)
{
const char* message = "Hello!!!\r\n";
// init all GPIO
//dt_gpio_init();
// init selected GPIO
if (dt_gpio_init_pin(gpio_LED1,OUT_10MHz,OUT_PP,LOW) != DT_STATUS_OK){
return -1;
}
if (SysTick_Config(TimerTick) != 0){
return -1;
}
dt_uart_init(TEST_UART);
dt_uart_write(TEST_UART, (uint8_t*)message, strlen(message));
// set zero delay for the first check delay
uint16_t led1_delay = (uint16_t)time_ms;
while(1){
#if MIN_TIME_BITSIZE < SYS_TICK_BITSIZE
if (dt_check_time(&led1_delay,sizeof(led1_delay))){
#elif MIN_TIME_BITSIZE == SYS_TICK_BITSIZE
if (dt_check_time(led1_delay)){
#endif
uint8_t buff[10] = {0};
uint16_t rx_count = dt_uart_get_rx_count(TEST_UART);
if (rx_count != 0){
if (dt_uart_read(TEST_UART, buff, rx_count) != rx_count){
return -1;
}
while (dt_uart_busy(TEST_UART)) {}
if (dt_uart_write(TEST_UART, buff, rx_count) != DT_STATUS_OK){
return -1;
}
}
led1_delay += LED1_DELAY;
if (dt_gpio_toggle(gpio_LED1) != DT_STATUS_OK){
return -1;
}
}
}
}