amiro-os / unittests / periphery-lld / src / ut_alld_P9221R_v1.c @ 77a3b16a
History | View | Annotate | Download (5.13 KB)
1 | da1c10ac | Julia Niermann | /*
|
---|---|---|---|
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 | a2cdc4ae | Julia Niermann | #include <amiroos.h> |
20 | #include <ut_alld_P9221R_v1.h> |
||
21 | |||
22 | da1c10ac | Julia Niermann | #if ((AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_P9221R) && (AMIROLLD_CFG_P9221R == 1)) || 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 | 7a333f53 | Julia Niermann | |
51 | a2cdc4ae | Julia Niermann | aos_utresult_t utAlldP9221rFunc(BaseSequentialStream* stream, aos_unittest_t* ut) |
52 | { |
||
53 | da1c10ac | Julia Niermann | aosDbgCheck(ut->data != NULL && ((ut_p9221rdata_t*)(ut->data))->PRd != NULL); |
54 | |||
55 | // local variables
|
||
56 | aos_utresult_t result = {0, 0}; |
||
57 | uint32_t status; |
||
58 | 7da9c509 | Julia Niermann | uint8_t data[79] = {0xA5}; |
59 | 77a3b16a | Julia Niermann | int8_t x_alignment[2] = {0xA5}; |
60 | int8_t y_alignment[2] = {0xA5}; |
||
61 | float voltage[1]; |
||
62 | float current[1]; |
||
63 | da1c10ac | Julia Niermann | |
64 | 7da9c509 | Julia Niermann | chprintf(stream, "read all registers...\n");
|
65 | status = p9221r_lld_read_register(((ut_p9221rdata_t*)ut->data)->PRd, P9221R_LLD_REGISTER_PARTNUMBER, data, 79, ((ut_p9221rdata_t*)ut->data)->timeout);
|
||
66 | if (status == APAL_STATUS_SUCCESS) {
|
||
67 | aosUtPassed(stream, &result); |
||
68 | for(int i=0; i<79; i++){ |
||
69 | chprintf(stream, "register: 0x%02x, data: 0x%02X \n", 0x00+i, data[i]); |
||
70 | } |
||
71 | } else {
|
||
72 | aosUtFailed(stream, &result); |
||
73 | } |
||
74 | da1c10ac | Julia Niermann | |
75 | 4684a9d9 | Julia Niermann | chprintf(stream, "read x_alignment for five seconds, move receiver ... \n");
|
76 | status = APAL_STATUS_SUCCESS; |
||
77 | for (uint32_t i = 0; i <= 5; i++) { |
||
78 | status |= p9221r_lld_read_x_alignment(((ut_p9221rdata_t*)ut->data)->PRd, x_alignment, ((ut_p9221rdata_t*)ut->data)->timeout); |
||
79 | 77a3b16a | Julia Niermann | chprintf(stream, "x_alignment %d \n", x_alignment[0]); |
80 | 4684a9d9 | Julia Niermann | //aosUtPassed(stream, &result);
|
81 | aosThdSSleep(1);
|
||
82 | } |
||
83 | if(status == APAL_STATUS_SUCCESS) {
|
||
84 | da1c10ac | Julia Niermann | aosUtPassed(stream, &result); |
85 | } else {
|
||
86 | aosUtFailed(stream, &result); |
||
87 | } |
||
88 | |||
89 | 4684a9d9 | Julia Niermann | chprintf(stream, "read y_alignment for five seconds, move receiver ... \n");
|
90 | status = APAL_STATUS_SUCCESS; |
||
91 | for (uint32_t i = 0; i <= 5; i++) { |
||
92 | status |= p9221r_lld_read_y_alignment(((ut_p9221rdata_t*)ut->data)->PRd, y_alignment, ((ut_p9221rdata_t*)ut->data)->timeout); |
||
93 | 77a3b16a | Julia Niermann | chprintf(stream, "y_alignment: %d \n", y_alignment[0]); |
94 | 4684a9d9 | Julia Niermann | //aosUtPassed(stream, &result);
|
95 | aosThdSSleep(1);
|
||
96 | } |
||
97 | if(status == APAL_STATUS_SUCCESS) {
|
||
98 | adcbcf83 | Julia Niermann | aosUtPassed(stream, &result); |
99 | } else {
|
||
100 | aosUtFailed(stream, &result); |
||
101 | } |
||
102 | |||
103 | 77a3b16a | Julia Niermann | chprintf(stream, "read the voltage... \n");
|
104 | status = p9221r_lld_read_voltage(((ut_p9221rdata_t*)ut->data)->PRd, voltage, ((ut_p9221rdata_t*)ut->data)->timeout); |
||
105 | if (status == APAL_STATUS_SUCCESS) {
|
||
106 | aosUtPassed(stream, &result); |
||
107 | chprintf(stream, "voltage: %.2f \n", *voltage);
|
||
108 | } else {
|
||
109 | aosUtFailed(stream, &result); |
||
110 | } |
||
111 | |||
112 | chprintf(stream, "read the current... \n");
|
||
113 | status = p9221r_lld_read_current(((ut_p9221rdata_t*)ut->data)->PRd, current, ((ut_p9221rdata_t*)ut->data)->timeout); |
||
114 | if (status == APAL_STATUS_SUCCESS) {
|
||
115 | aosUtPassed(stream, &result); |
||
116 | chprintf(stream, "current: %.2f \n", *current);
|
||
117 | } else {
|
||
118 | aosUtFailed(stream, &result); |
||
119 | } |
||
120 | b49ed442 | Julia Niermann | |
121 | 8cbe3240 | Julia Niermann | return result;
|
122 | a2cdc4ae | Julia Niermann | } |
123 | da1c10ac | Julia Niermann | #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_P9221R) && (AMIROLLD_CFG_P9221R == 1) */ |