amiro-os / unittests / periphery-lld / src / ut_alld_bq24103a.c @ 83ca1b95
History | View | Annotate | Download (2.807 KB)
1 | e545e620 | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | 84f0ce9e | Thomas Schöpping | Copyright (C) 2016..2019 Thomas Schöpping et al.
|
4 | e545e620 | Thomas Schöpping | |
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | it under the terms of the GNU General Public License as published by
|
||
7 | the Free Software Foundation, either version 3 of the License, or
|
||
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | GNU General Public License for more details.
|
||
14 | |||
15 | You should have received a copy of the GNU General Public License
|
||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
17 | */
|
||
18 | |||
19 | #include <ut_alld_bq24103a.h> |
||
20 | |||
21 | #if ((AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_BQ24103A)) || defined(__DOXYGEN__) |
||
22 | |||
23 | #include <aos_debug.h> |
||
24 | #include <chprintf.h> |
||
25 | #include <aos_thread.h> |
||
26 | #include <alld_bq24103a.h> |
||
27 | |||
28 | aos_utresult_t utAlldBq24103aFunc(BaseSequentialStream* stream, aos_unittest_t* ut) |
||
29 | { |
||
30 | aosDbgCheck(ut->data != NULL);
|
||
31 | |||
32 | // local variables
|
||
33 | aos_utresult_t result = {0, 0}; |
||
34 | uint32_t status; |
||
35 | bq24103a_lld_enable_t en[3];
|
||
36 | bq24103a_lld_charge_state_t charge; |
||
37 | |||
38 | chprintf(stream, "read enable pin...\n");
|
||
39 | status = bq24103a_lld_get_enabled((BQ24103ADriver*)ut->data, &en[0]);
|
||
40 | chprintf(stream, "\t\tcurrently %s\n", (en[0] == BQ24103A_LLD_ENABLED) ? "enabled" : "disabled"); |
||
41 | if(status == APAL_STATUS_SUCCESS){
|
||
42 | aosUtPassed(stream, &result); |
||
43 | } else {
|
||
44 | aosUtFailedMsg(stream, &result, "0x%08X\n", status);
|
||
45 | } |
||
46 | |||
47 | chprintf(stream, "write enable pin...\n");
|
||
48 | status = bq24103a_lld_set_enabled((BQ24103ADriver*)ut->data, (en[0] == BQ24103A_LLD_ENABLED) ? BQ24103A_LLD_DISABLED : BQ24103A_LLD_ENABLED);
|
||
49 | aosThdMSleep(1);
|
||
50 | status |= bq24103a_lld_get_enabled((BQ24103ADriver*)ut->data, &en[1]);
|
||
51 | status |= bq24103a_lld_set_enabled((BQ24103ADriver*)ut->data, en[0]);
|
||
52 | aosThdMSleep(1);
|
||
53 | status |= bq24103a_lld_get_enabled((BQ24103ADriver*)ut->data, &en[2]);
|
||
54 | if(status == APAL_STATUS_SUCCESS && en[0] != en[1] && en[0] == en[2] && en[1] != en[2]){ |
||
55 | aosUtPassed(stream, &result); |
||
56 | } else {
|
||
57 | aosUtFailedMsg(stream, &result, "0x%08X, %u-%u\n", status, en[1], en[2]); |
||
58 | } |
||
59 | |||
60 | chprintf(stream, "read status pin...\n");
|
||
61 | aosThdMSleep(500);
|
||
62 | status = bq24103a_lld_get_charge_status((BQ24103ADriver*)ut->data, &charge); |
||
63 | chprintf(stream, "\t\tcharge status: %scharging\n", (charge == BQ24103A_LLD_CHARGING) ? "" : "not "); |
||
64 | if (status == APAL_STATUS_SUCCESS) {
|
||
65 | aosUtPassed(stream, &result); |
||
66 | } else {
|
||
67 | aosUtFailedMsg(stream, &result, "0x%08X\n", status);
|
||
68 | } |
||
69 | |||
70 | aosUtInfoMsg(stream,"driver object memory footprint: %u bytes\n", sizeof(BQ24103ADriver)); |
||
71 | |||
72 | return result;
|
||
73 | } |
||
74 | |||
75 | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_BQ24103A) */ |