amiro-os / test / periphery-lld / P9221R_v1 / aos_test_P9221R.c @ c60ee2dd
History | View | Annotate | Download (4.576 KB)
1 |
/*
|
---|---|
2 |
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
3 |
Copyright (C) 2016..2019 Thomas Schöpping et al.
|
4 |
|
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 <amiroos.h> |
20 |
#include <aos_test_P9221R.h> |
21 |
|
22 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
23 |
|
24 |
#include <math.h> |
25 |
|
26 |
/******************************************************************************/
|
27 |
/* LOCAL DEFINITIONS */
|
28 |
/******************************************************************************/
|
29 |
|
30 |
/******************************************************************************/
|
31 |
/* EXPORTED VARIABLES */
|
32 |
/******************************************************************************/
|
33 |
|
34 |
/******************************************************************************/
|
35 |
/* LOCAL TYPES */
|
36 |
/******************************************************************************/
|
37 |
|
38 |
/******************************************************************************/
|
39 |
/* LOCAL VARIABLES */
|
40 |
/******************************************************************************/
|
41 |
|
42 |
/******************************************************************************/
|
43 |
/* LOCAL FUNCTIONS */
|
44 |
/******************************************************************************/
|
45 |
|
46 |
/******************************************************************************/
|
47 |
/* EXPORTED FUNCTIONS */
|
48 |
/******************************************************************************/
|
49 |
|
50 |
|
51 |
aos_testresult_t aosTestP9221rFunc(BaseSequentialStream* stream, const aos_test_t* test)
|
52 |
{ |
53 |
aosDbgCheck(test->data != NULL && ((aos_test_p9221rdata_t*)(test->data))->PRd != NULL); |
54 |
|
55 |
// local variables
|
56 |
aos_testresult_t result = {0, 0}; |
57 |
uint32_t status; |
58 |
uint8_t data[79] = {0xA5}; |
59 |
int8_t alignment[2] = {0xA5}; |
60 |
float voltage[1]; |
61 |
float current[1]; |
62 |
|
63 |
chprintf(stream, "read all registers...\n");
|
64 |
status = p9221r_lld_read_register(((aos_test_p9221rdata_t*)test->data)->PRd, P9221R_LLD_REGISTER_PARTNUMBER, data, 79, ((aos_test_p9221rdata_t*)test->data)->timeout);
|
65 |
if (status == APAL_STATUS_SUCCESS) {
|
66 |
aosTestPassed(stream, &result); |
67 |
for(int i=0; i<79; i++){ |
68 |
chprintf(stream, "register: 0x%02x, data: 0x%02X \n", 0x00+i, data[i]); |
69 |
} |
70 |
} else {
|
71 |
aosTestFailed(stream, &result); |
72 |
} |
73 |
|
74 |
chprintf(stream, "read alignment for five seconds, move receiver ... \n");
|
75 |
status = APAL_STATUS_SUCCESS; |
76 |
for (uint32_t i = 0; i <= 5; i++) { |
77 |
status |= p9221r_lld_read_alignment(((aos_test_p9221rdata_t*)test->data)->PRd, alignment, ((aos_test_p9221rdata_t*)test->data)->timeout); |
78 |
chprintf(stream, "x_alignment %2d \n", alignment[0]); |
79 |
chprintf(stream, "y_alignment %2d \n", alignment[1]); |
80 |
//aosTestPassed(stream, &result);
|
81 |
aosThdSSleep(1);
|
82 |
} |
83 |
if(status == APAL_STATUS_SUCCESS) {
|
84 |
aosTestPassed(stream, &result); |
85 |
} else {
|
86 |
aosTestFailed(stream, &result); |
87 |
} |
88 |
|
89 |
chprintf(stream, "read the voltage... \n");
|
90 |
status = p9221r_lld_read_voltage(((aos_test_p9221rdata_t*)test->data)->PRd, voltage, ((aos_test_p9221rdata_t*)test->data)->timeout); |
91 |
if (status == APAL_STATUS_SUCCESS) {
|
92 |
aosTestPassed(stream, &result); |
93 |
chprintf(stream, "voltage: %.2f \n", *voltage);
|
94 |
} else {
|
95 |
aosTestFailed(stream, &result); |
96 |
} |
97 |
|
98 |
chprintf(stream, "read the current... \n");
|
99 |
status = p9221r_lld_read_current(((aos_test_p9221rdata_t*)test->data)->PRd, current, ((aos_test_p9221rdata_t*)test->data)->timeout); |
100 |
if (status == APAL_STATUS_SUCCESS) {
|
101 |
aosTestPassed(stream, &result); |
102 |
chprintf(stream, "current: %.2f \n", *current);
|
103 |
} else {
|
104 |
aosTestFailed(stream, &result); |
105 |
} |
106 |
|
107 |
return result;
|
108 |
} |
109 |
|
110 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |