Statistics
| Branch: | Tag: | Revision:

amiro-os / unittests / periphery-lld / src / ut_alld_bq24103a.c @ 7da800ab

History | View | Annotate | Download (4.143 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 f3ac1c96 Thomas Schöpping
/******************************************************************************/
24
/* LOCAL DEFINITIONS                                                          */
25
/******************************************************************************/
26
27
/******************************************************************************/
28
/* EXPORTED VARIABLES                                                         */
29
/******************************************************************************/
30
31
/******************************************************************************/
32
/* LOCAL TYPES                                                                */
33
/******************************************************************************/
34
35
/******************************************************************************/
36
/* LOCAL VARIABLES                                                            */
37
/******************************************************************************/
38
39
/******************************************************************************/
40
/* LOCAL FUNCTIONS                                                            */
41
/******************************************************************************/
42
43
/******************************************************************************/
44
/* EXPORTED FUNCTIONS                                                         */
45
/******************************************************************************/
46
47 e545e620 Thomas Schöpping
48
aos_utresult_t utAlldBq24103aFunc(BaseSequentialStream* stream, aos_unittest_t* ut)
49
{
50
  aosDbgCheck(ut->data != NULL);
51
52
  // local variables
53
  aos_utresult_t result = {0, 0};
54
  uint32_t status;
55
  bq24103a_lld_enable_t en[3];
56
  bq24103a_lld_charge_state_t charge;
57
58
  chprintf(stream, "read enable pin...\n");
59
  status = bq24103a_lld_get_enabled((BQ24103ADriver*)ut->data, &en[0]);
60
  chprintf(stream, "\t\tcurrently %s\n", (en[0] == BQ24103A_LLD_ENABLED) ? "enabled" : "disabled");
61
  if(status == APAL_STATUS_SUCCESS){
62
    aosUtPassed(stream, &result);
63
  } else {
64
    aosUtFailedMsg(stream, &result, "0x%08X\n", status);
65
  }
66
67
  chprintf(stream, "write enable pin...\n");
68
  status = bq24103a_lld_set_enabled((BQ24103ADriver*)ut->data, (en[0] == BQ24103A_LLD_ENABLED) ? BQ24103A_LLD_DISABLED : BQ24103A_LLD_ENABLED);
69
  aosThdMSleep(1);
70
  status |= bq24103a_lld_get_enabled((BQ24103ADriver*)ut->data, &en[1]);
71
  status |= bq24103a_lld_set_enabled((BQ24103ADriver*)ut->data, en[0]);
72
  aosThdMSleep(1);
73
  status |= bq24103a_lld_get_enabled((BQ24103ADriver*)ut->data, &en[2]);
74
  if(status == APAL_STATUS_SUCCESS && en[0] != en[1] && en[0] == en[2] && en[1] != en[2]){
75
    aosUtPassed(stream, &result);
76
  } else {
77
    aosUtFailedMsg(stream, &result, "0x%08X, %u-%u\n", status, en[1], en[2]);
78
  }
79
80
  chprintf(stream, "read status pin...\n");
81
  aosThdMSleep(500);
82
  status = bq24103a_lld_get_charge_status((BQ24103ADriver*)ut->data, &charge);
83
  chprintf(stream, "\t\tcharge status: %scharging\n", (charge == BQ24103A_LLD_CHARGING) ? "" : "not ");
84
  if (status == APAL_STATUS_SUCCESS) {
85
    aosUtPassed(stream, &result);
86
  } else {
87
    aosUtFailedMsg(stream, &result, "0x%08X\n", status);
88
  }
89
90
  aosUtInfoMsg(stream,"driver object memory footprint: %u bytes\n", sizeof(BQ24103ADriver));
91
92
  return result;
93
}
94
95
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_BQ24103A) */