Nordic Thingy:52
Introduction
API Reference
Modules
Data Structures
File List
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
Pages
m_batt_meas.h
1
/*
2
Copyright (c) 2010 - 2017, Nordic Semiconductor ASA
3
All rights reserved.
4
5
Redistribution and use in source and binary forms, with or without modification,
6
are permitted provided that the following conditions are met:
7
8
1. Redistributions of source code must retain the above copyright notice, this
9
list of conditions and the following disclaimer.
10
11
2. Redistributions in binary form, except as embedded into a Nordic
12
Semiconductor ASA integrated circuit in a product or a software update for
13
such product, must reproduce the above copyright notice, this list of
14
conditions and the following disclaimer in the documentation and/or other
15
materials provided with the distribution.
16
17
3. Neither the name of Nordic Semiconductor ASA nor the names of its
18
contributors may be used to endorse or promote products derived from this
19
software without specific prior written permission.
20
21
4. This software, with or without modification, must only be used with a
22
Nordic Semiconductor ASA integrated circuit.
23
24
5. Any software provided in binary form under this license must not be reverse
25
engineered, decompiled, modified and/or disassembled.
26
27
THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
28
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29
OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
30
DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
31
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
33
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
*/
38
48
#ifndef __M_BATT_MEAS_H__
49
#define __M_BATT_MEAS_H__
50
51
#include "m_ble.h"
52
#include <stdint.h>
53
#include <stdbool.h>
54
55
#define MEAS_INTERVAL_LOW_LIMIT_MS 50
56
/* The SAADC is configured for oversampling for improved noise immunity.
57
corresponding settings can be found in sdk_config.h */
58
61
enum
62
{
63
M_BATT_STATUS_CODE_SUCCESS
,
64
M_BATT_STATUS_CODE_INVALID_PARAM
,
65
};
66
69
typedef
enum
70
{
71
M_BATT_MEAS_EVENT_DATA
,
72
M_BATT_MEAS_EVENT_LOW
,
73
M_BATT_MEAS_EVENT_FULL
,
74
M_BATT_MEAS_EVENT_USB_CONN_CHARGING
,
75
M_BATT_MEAS_EVENT_USB_CONN_CHARGING_FINISHED
,
76
M_BATT_MEAS_EVENT_USB_DISCONN
,
77
M_BATT_MEAS_EVENT_ERROR
,
78
}
m_batt_meas_event_type_t
;
79
82
typedef
struct
83
{
84
m_batt_meas_event_type_t
type
;
85
uint16_t
voltage_mv
;
86
uint8_t
level_percent
;
87
bool
valid_voltage
;
88
}
m_batt_meas_event_t
;
89
92
typedef
void (*
m_batt_meas_event_handler_t
)(
m_batt_meas_event_t
const
* p_event);
93
98
typedef
struct
99
{
100
uint32_t r_1_ohm;
101
uint32_t r_2_ohm;
102
}
voltage_divider_t
;
103
106
typedef
struct
107
{
108
uint16_t
app_timer_prescaler
;
109
uint8_t
adc_pin_no
;
110
uint8_t
usb_detect_pin_no
;
111
uint8_t
batt_chg_stat_pin_no
;
112
bool
batt_mon_en_pin_used
;
113
uint8_t
batt_mon_en_pin_no
;
114
uint16_t
batt_voltage_limit_low
;
115
uint16_t
batt_voltage_limit_full
;
116
voltage_divider_t
voltage_divider
;
117
}
batt_meas_param_t
;
118
121
typedef
struct
122
{
123
m_batt_meas_event_handler_t
evt_handler
;
124
batt_meas_param_t
batt_meas_param
;
125
}
batt_meas_init_t
;
126
137
uint32_t
m_batt_meas_init
(
m_ble_service_handle_t
* p_handle,
batt_meas_init_t
const
*
const
p_batt_meas_init);
138
149
uint32_t
m_batt_meas_enable
(uint32_t meas_interval_ms);
150
156
uint32_t
m_batt_meas_disable
(
void
);
157
158
#endif
159
Documentation feedback
|
Developer Zone
|
Subscribe
| Updated