-
Notifications
You must be signed in to change notification settings - Fork 3
/
smart_connection.c
66 lines (49 loc) · 1.56 KB
/
smart_connection.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
#ifdef MTK_SMARTCONNECT_HDK
#include "FreeRTOS.h"
#include "hal_gpio.h"
#include "task.h"
#include "os.h"
static int startSmart = 0;
void smart_connection_init () {
hal_pinmux_set_function(HAL_GPIO_0, 8);
hal_gpio_data_t data_pull_up;
hal_gpio_data_t data_pull_down;
hal_gpio_status_t ret;
hal_pinmux_status_t ret_pinmux_status;
ret = hal_gpio_init(HAL_GPIO_0);
/* set pin to work in GPIO mode.*/
ret_pinmux_status = hal_pinmux_set_function(HAL_GPIO_0, 8);
/* set direction of GPIO is input.*/
ret = hal_gpio_set_direction(HAL_GPIO_0, HAL_GPIO_DIRECTION_INPUT);
/* configure the pull state to pull-up.*/
ret = hal_gpio_pull_up(HAL_GPIO_0);
/* get input data of the pin for further validation.*/
ret = hal_gpio_get_input(HAL_GPIO_0, &data_pull_up);
if (1 == data_pull_up && 0 == startSmart) {
startSmart = 1;
char param[0] = "connect\0";
_smart_config_test(1, param);
}
/* configure the pull state to pull-down.*/
ret = hal_gpio_pull_down(HAL_GPIO_0);
/* get input data of the pin for further validation.*/
ret = hal_gpio_get_input(HAL_GPIO_0, &data_pull_down);
// printf("down: %d\n", data_pull_down);
// printf("up: %d\n", data_pull_up);
ret = hal_gpio_deinit(HAL_GPIO_0);
}
void smart_connection_task(void *parameter) {
for (;;) {
smart_connection_init();
vTaskDelay(200);
}
}
void smart_config_if_enabled()
{
xTaskCreate(smart_connection_task, "smartConnectionConnect", 2048, NULL, 2, NULL);
}
#else
void smart_config_if_enabled()
{
}
#endif