blob: 72c4a29b9c73b3aff3ef3ddde18d7d7ed8c96ed8 (
plain)
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
|
/**
*****************************************************************************************
* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
*****************************************************************************************
* @file lpc.c
* @brief
* @author yuan
* @date 2018-05-04
* @version v0.1
**************************************************************************************
* @attention
* <h2><center>© COPYRIGHT 2017 Realtek Semiconductor Corporation</center></h2>
**************************************************************************************
*/
/*============================================================================*
* Header Files
*============================================================================*/
#include "io_lpc.h"
#include "app_task.h"
#include "board.h"
/**
* @brief initialization of pinmux settings and pad settings.
* @param No parameter.
* @return void
*/
void board_lpc_init(void)
{
Pad_Config(LPC_CAPTURE_PIN, PAD_SW_MODE, PAD_IS_PWRON, PAD_PULL_NONE, PAD_OUT_DISABLE,
PAD_OUT_HIGH);
Pinmux_Config(LPC_CAPTURE_PIN, IDLE_MODE);
}
/**
* @brief Initialize RTC peripheral.
* @param No parameter.
* @return void
*/
void driver_lpc_init(void)
{
LPC_DeInit();
LPC_InitTypeDef LPC_InitStruct;
LPC_StructInit(&LPC_InitStruct);
LPC_InitStruct.LPC_Channel = LPC_CAPTURE_CHANNEL;
LPC_InitStruct.LPC_Edge = LPC_VOLTAGE_DETECT_EDGE;
LPC_InitStruct.LPC_Threshold = LPC_VOLTAGE_DETECT_THRESHOLD;
LPC_Init(&LPC_InitStruct);
LPC_Cmd(ENABLE);
LPC_INTConfig(LPC_INT_LPCOMP_VOL, ENABLE);
}
void nvic_lpc_init(void)
{
/* Config LPC interrupt */
NVIC_InitTypeDef NVIC_InitStruct;
NVIC_InitStruct.NVIC_IRQChannel = LPCOMP_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPriority = 3;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStruct);
LPC_INTCmd(ENABLE);
}
/**
* @brief LPC battery detection interrupt handle function.
* @param None.
* @return None.
*/
void LPCOMP_Handler(void)
{
LPC_INTConfig(LPC_INT_LPCOMP_VOL, DISABLE);
APP_PRINT_INFO0("LPCOMP_Handler\r\n");
T_IO_MSG int_lpc_msg;
int_lpc_msg.type = IO_MSG_TYPE_BAT_LPC;
if (false == app_send_msg_to_apptask(&int_lpc_msg))
{
APP_PRINT_ERROR0("[io_lpc] LPCOMP_Handler: Send int_lpc_msg failed!");
return;
}
//Add application code here
}
|