Statistics
| Branch: | Tag: | Revision:

amiro-os / test / periphery-lld / P9221R_v1 / aos_test_P9221R.c @ c60ee2dd

History | View | Annotate | Download (4.576 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 5b1af1ae Julia Niermann
#include <aos_test_P9221R.h>
21 a2cdc4ae Julia Niermann
22 5b1af1ae Julia Niermann
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
23 da1c10ac Julia Niermann
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 5b1af1ae Julia Niermann
aos_testresult_t aosTestP9221rFunc(BaseSequentialStream* stream, const aos_test_t* test)
52 a2cdc4ae Julia Niermann
{
53 5b1af1ae Julia Niermann
    aosDbgCheck(test->data != NULL && ((aos_test_p9221rdata_t*)(test->data))->PRd != NULL);
54 da1c10ac Julia Niermann
55
    // local variables
56 5b1af1ae Julia Niermann
    aos_testresult_t result = {0, 0};
57 da1c10ac Julia Niermann
    uint32_t status;
58 7da9c509 Julia Niermann
    uint8_t data[79] = {0xA5};
59 c60ee2dd Julia Niermann
    int8_t alignment[2] = {0xA5};
60 77a3b16a Julia Niermann
    float voltage[1];
61
    float current[1];
62 da1c10ac Julia Niermann
63 7da9c509 Julia Niermann
    chprintf(stream, "read all registers...\n");
64 5b1af1ae Julia Niermann
    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 7da9c509 Julia Niermann
    if (status == APAL_STATUS_SUCCESS) {
66 5b1af1ae Julia Niermann
      aosTestPassed(stream, &result);
67 7da9c509 Julia Niermann
      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 5b1af1ae Julia Niermann
      aosTestFailed(stream, &result);
72 7da9c509 Julia Niermann
    }
73 da1c10ac Julia Niermann
74 c60ee2dd Julia Niermann
    chprintf(stream, "read alignment for five seconds, move receiver ... \n");
75 4684a9d9 Julia Niermann
    status = APAL_STATUS_SUCCESS;
76
    for (uint32_t i = 0; i <= 5; i++) {
77 c60ee2dd Julia Niermann
        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 5b1af1ae Julia Niermann
        //aosTestPassed(stream, &result);
81 4684a9d9 Julia Niermann
        aosThdSSleep(1);
82
    }
83
    if(status == APAL_STATUS_SUCCESS) {
84 5b1af1ae Julia Niermann
      aosTestPassed(stream, &result);
85 adcbcf83 Julia Niermann
    } else {
86 5b1af1ae Julia Niermann
      aosTestFailed(stream, &result);
87 adcbcf83 Julia Niermann
    }
88
89 77a3b16a Julia Niermann
     chprintf(stream, "read the voltage... \n");
90 5b1af1ae Julia Niermann
     status =   p9221r_lld_read_voltage(((aos_test_p9221rdata_t*)test->data)->PRd, voltage, ((aos_test_p9221rdata_t*)test->data)->timeout);
91 77a3b16a Julia Niermann
     if (status == APAL_STATUS_SUCCESS) {
92 5b1af1ae Julia Niermann
       aosTestPassed(stream, &result);
93 77a3b16a Julia Niermann
       chprintf(stream, "voltage: %.2f \n", *voltage);
94
     } else {
95 5b1af1ae Julia Niermann
       aosTestFailed(stream, &result);
96 77a3b16a Julia Niermann
     }
97
98
     chprintf(stream, "read the current... \n");
99 5b1af1ae Julia Niermann
     status =  p9221r_lld_read_current(((aos_test_p9221rdata_t*)test->data)->PRd, current, ((aos_test_p9221rdata_t*)test->data)->timeout);
100 77a3b16a Julia Niermann
     if (status == APAL_STATUS_SUCCESS) {
101 5b1af1ae Julia Niermann
       aosTestPassed(stream, &result);
102 77a3b16a Julia Niermann
       chprintf(stream, "current: %.2f \n", *current);
103
     } else {
104 5b1af1ae Julia Niermann
       aosTestFailed(stream, &result);
105 77a3b16a Julia Niermann
     }
106 b49ed442 Julia Niermann
107 8cbe3240 Julia Niermann
    return result;
108 a2cdc4ae Julia Niermann
}
109 5b1af1ae Julia Niermann
110
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */