Revision 77a3b16a
unittests/periphery-lld/src/ut_alld_P9221R_v1.c | ||
---|---|---|
56 | 56 |
aos_utresult_t result = {0, 0}; |
57 | 57 |
uint32_t status; |
58 | 58 |
uint8_t data[79] = {0xA5}; |
59 |
uint8_t alignment[20] = {0xA5}; |
|
60 |
int8_t x_alignment; |
|
61 |
int8_t y_alignment; |
|
62 |
int32_t voltage; |
|
63 |
int32_t current; |
|
59 |
int8_t x_alignment[2] = {0xA5}; |
|
60 |
int8_t y_alignment[2] = {0xA5}; |
|
61 |
float voltage[1]; |
|
62 |
float current[1]; |
|
64 | 63 |
|
65 | 64 |
chprintf(stream, "read all registers...\n"); |
66 | 65 |
status = p9221r_lld_read_register(((ut_p9221rdata_t*)ut->data)->PRd, P9221R_LLD_REGISTER_PARTNUMBER, data, 79, ((ut_p9221rdata_t*)ut->data)->timeout); |
... | ... | |
77 | 76 |
status = APAL_STATUS_SUCCESS; |
78 | 77 |
for (uint32_t i = 0; i <= 5; i++) { |
79 | 78 |
status |= p9221r_lld_read_x_alignment(((ut_p9221rdata_t*)ut->data)->PRd, x_alignment, ((ut_p9221rdata_t*)ut->data)->timeout); |
80 |
chprintf(stream, "x_alignment %d \n", x_alignment); |
|
79 |
chprintf(stream, "x_alignment %d \n", x_alignment[0]);
|
|
81 | 80 |
//aosUtPassed(stream, &result); |
82 | 81 |
aosThdSSleep(1); |
83 | 82 |
} |
... | ... | |
91 | 90 |
status = APAL_STATUS_SUCCESS; |
92 | 91 |
for (uint32_t i = 0; i <= 5; i++) { |
93 | 92 |
status |= p9221r_lld_read_y_alignment(((ut_p9221rdata_t*)ut->data)->PRd, y_alignment, ((ut_p9221rdata_t*)ut->data)->timeout); |
94 |
chprintf(stream, "y_alignment: %d \n", y_alignment); |
|
93 |
chprintf(stream, "y_alignment: %d \n", y_alignment[0]);
|
|
95 | 94 |
//aosUtPassed(stream, &result); |
96 | 95 |
aosThdSSleep(1); |
97 | 96 |
} |
... | ... | |
101 | 100 |
aosUtFailed(stream, &result); |
102 | 101 |
} |
103 | 102 |
|
104 |
// chprintf(stream, "read y_alignment... \n"); |
|
105 |
// status = p9221r_lld_read_y_alignment(((ut_p9221rdata_t*)ut->data)->PRd, y_alignment, ((ut_p9221rdata_t*)ut->data)->timeout); |
|
106 |
// if (status == APAL_STATUS_SUCCESS) { |
|
107 |
// aosUtPassed(stream, &result); |
|
108 |
// chprintf(stream, "y_alignment: %d \n", y_alignment); |
|
109 |
// } else { |
|
110 |
// aosUtFailed(stream, &result); |
|
111 |
// } |
|
112 |
|
|
113 |
// chprintf(stream, "read the voltage... \n"); |
|
114 |
// status = p9221r_lld_read_voltage(const P9221RDriver* const p9221r, int32_t const voltage, const apalTime_t timeout); |
|
115 |
// if (status == APAL_STATUS_SUCCESS) { |
|
116 |
// aosUtPassed(stream, &result); |
|
117 |
// chprintf(stream, "voltage: %d \n", voltage); |
|
118 |
// } else { |
|
119 |
// aosUtFailed(stream, &result); |
|
120 |
// } |
|
121 |
|
|
122 |
// chprintf(stream, "read the current... \n"); |
|
123 |
// status = p9221r_lld_read_current(const P9221RDriver* const p9221r, int32_t const current, const apalTime_t timeout); |
|
124 |
// if (status == APAL_STATUS_SUCCESS) { |
|
125 |
// aosUtPassed(stream, &result); |
|
126 |
// chprintf(stream, "current: %d \n", current); |
|
127 |
// } else { |
|
128 |
// aosUtFailed(stream, &result); |
|
129 |
// } |
|
103 |
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 |
} |
|
130 | 120 |
|
131 | 121 |
return result; |
132 | 122 |
} |
Also available in: Unified diff