Revision adcbcf83
unittests/periphery-lld/src/ut_alld_P9221R_v1.c | ||
---|---|---|
55 | 55 |
// local variables |
56 | 56 |
aos_utresult_t result = {0, 0}; |
57 | 57 |
uint32_t status; |
58 |
uint8_t data[80] = {0xAA};
|
|
58 |
uint8_t data[80]; |
|
59 | 59 |
int32_t x_alignment; |
60 | 60 |
int32_t y_alignment; |
61 |
int32_t voltage; |
|
62 |
int32_t current; |
|
61 | 63 |
|
62 | 64 |
chprintf(stream, "read registers...\n"); |
63 | 65 |
status = p9221r_lld_read_register(((ut_p9221rdata_t*)ut->data)->PRd, P9221R_LLD_REGISTER_PARTNUMBER, data, 80, ((ut_p9221rdata_t*)ut->data)->timeout); |
64 | 66 |
if (status == APAL_STATUS_SUCCESS) { |
65 | 67 |
aosUtPassed(stream, &result); |
66 |
for(int i=0; i<8; i++){ |
|
67 |
chprintf(stream, "register: 0x%02x, data: 0x%04X \n", 0x00+i, data[i]);
|
|
68 |
for(int i=0; i<80; i++){
|
|
69 |
chprintf(stream, "register: 0x%02x, data: 0x%02X \n", 0x00+i, data[i]);
|
|
68 | 70 |
} |
69 | 71 |
} else { |
70 | 72 |
aosUtFailed(stream, &result); |
71 | 73 |
} |
72 | 74 |
|
73 |
// chprintf(stream, "read x_alignment... \n"); |
|
74 |
// status = p9221r_lld_read_x_alignment(((ut_p9221rdata_t*)ut->data)->PRd, x_alignment, ((ut_p9221rdata_t*)ut->data)->timeout); |
|
75 |
// if (status == APAL_STATUS_SUCCESS) { |
|
76 |
// aosUtPassed(stream, &result); |
|
77 |
// chprintf(stream, "x_alignment: 0x%02x, data: %u \n", P9221R_LLD_REGISTER_ALIGNMENT_X, x_alignment); |
|
78 |
// } else { |
|
79 |
// aosUtFailed(stream, &result); |
|
80 |
// } |
|
81 |
|
|
82 |
// chprintf(stream, "read y_alignment... \n"); |
|
83 |
// status = p9221r_lld_read_y_alignment(((ut_p9221rdata_t*)ut->data)->PRd, y_alignment, ((ut_p9221rdata_t*)ut->data)->timeout); |
|
84 |
// if (status == APAL_STATUS_SUCCESS) { |
|
85 |
// aosUtPassed(stream, &result); |
|
86 |
// chprintf(stream, "y_alignment: 0x%02x, data: %u \n", P9221R_LLD_REGISTER_ALIGNMENT_Y, y_alignment); |
|
87 |
// } else { |
|
88 |
// aosUtFailed(stream, &result); |
|
89 |
// } |
|
75 |
chprintf(stream, "read x_alignment... \n"); |
|
76 |
status = p9221r_lld_read_x_alignment(((ut_p9221rdata_t*)ut->data)->PRd, x_alignment, ((ut_p9221rdata_t*)ut->data)->timeout); |
|
77 |
if (status == APAL_STATUS_SUCCESS) { |
|
78 |
aosUtPassed(stream, &result); |
|
79 |
chprintf(stream, "x_alignment %d \n", x_alignment); |
|
80 |
} else { |
|
81 |
aosUtFailed(stream, &result); |
|
82 |
} |
|
83 |
|
|
84 |
chprintf(stream, "read y_alignment... \n"); |
|
85 |
status = p9221r_lld_read_y_alignment(((ut_p9221rdata_t*)ut->data)->PRd, y_alignment, ((ut_p9221rdata_t*)ut->data)->timeout); |
|
86 |
if (status == APAL_STATUS_SUCCESS) { |
|
87 |
aosUtPassed(stream, &result); |
|
88 |
chprintf(stream, "y_alignment: %d \n", y_alignment); |
|
89 |
} else { |
|
90 |
aosUtFailed(stream, &result); |
|
91 |
} |
|
92 |
|
|
93 |
chprintf(stream, "read the voltage... \n"); |
|
94 |
status = p9221r_lld_read_voltage(const P9221RDriver* const p9221r, int32_t const voltage, const apalTime_t timeout); |
|
95 |
if (status == APAL_STATUS_SUCCESS) { |
|
96 |
aosUtPassed(stream, &result); |
|
97 |
chprintf(stream, "voltage: %d \n", voltage); |
|
98 |
} else { |
|
99 |
aosUtFailed(stream, &result); |
|
100 |
} |
|
101 |
|
|
102 |
chprintf(stream, "read the current... \n"); |
|
103 |
status = p9221r_lld_read_current(const P9221RDriver* const p9221r, int32_t const current, const apalTime_t timeout); |
|
104 |
if (status == APAL_STATUS_SUCCESS) { |
|
105 |
aosUtPassed(stream, &result); |
|
106 |
chprintf(stream, "current: %d \n", current); |
|
107 |
} else { |
|
108 |
aosUtFailed(stream, &result); |
|
109 |
} |
|
90 | 110 |
|
91 | 111 |
return result; |
92 | 112 |
} |
Also available in: Unified diff