Revision 7da9c509

View differences:

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];
59
    int32_t x_alignment;
60
    int32_t y_alignment;
58
    uint8_t data[79] = {0xA5};
59
    uint8_t alignment[20] = {0xA5};
60
    int8_t x_alignment;
61
    int8_t y_alignment;
61 62
    int32_t voltage;
62 63
    int32_t current;
63 64

  
65
    chprintf(stream, "read all registers...\n");
66
    status = p9221r_lld_read_register(((ut_p9221rdata_t*)ut->data)->PRd, P9221R_LLD_REGISTER_PARTNUMBER, data, 79, ((ut_p9221rdata_t*)ut->data)->timeout);
67
    if (status == APAL_STATUS_SUCCESS) {
68
      aosUtPassed(stream, &result);
69
      for(int i=0; i<79; i++){
70
          chprintf(stream, "register: 0x%02x, data: 0x%02X \n", 0x00+i, data[i]);
71
      }
72
    } else {
73
      aosUtFailed(stream, &result);
74
    }
64 75

  
65 76
    chprintf(stream, "read registers...\n");
66
    status = p9221r_lld_read_register(((ut_p9221rdata_t*)ut->data)->PRd, P9221R_LLD_REGISTER_PARTNUMBER, data, 80, ((ut_p9221rdata_t*)ut->data)->timeout);
77
    status = p9221r_lld_read_register(((ut_p9221rdata_t*)ut->data)->PRd, P9221R_LLD_REGISTER_BATTERY_STATUS_SENT, alignment, 20, ((ut_p9221rdata_t*)ut->data)->timeout);
67 78
    if (status == APAL_STATUS_SUCCESS) {
68 79
      aosUtPassed(stream, &result);
69
      for(int i=0; i<80; i++){
70
          chprintf(stream, "register: 0x%02x, data: 0x%02X \n", 0x00+i, data[i]);
80
      for(int i=0; i<20; i++){
81
          chprintf(stream, "register: 0x%02x, data: 0x%02X \n", P9221R_LLD_REGISTER_BATTERY_STATUS_SENT+i, alignment[i]);
71 82
      }
72 83
    } else {
73 84
      aosUtFailed(stream, &result);
74 85
    }
75 86

  
76
    chprintf(stream, "read x_alignment... \n");
77
    status =  p9221r_lld_read_x_alignment(((ut_p9221rdata_t*)ut->data)->PRd, x_alignment, ((ut_p9221rdata_t*)ut->data)->timeout);
87
    chprintf(stream, "read all registers...\n");
88
    status = p9221r_lld_read_register(((ut_p9221rdata_t*)ut->data)->PRd, P9221R_LLD_REGISTER_PARTNUMBER, data, 79, ((ut_p9221rdata_t*)ut->data)->timeout);
78 89
    if (status == APAL_STATUS_SUCCESS) {
79 90
      aosUtPassed(stream, &result);
80
      chprintf(stream, "x_alignment %d \n", x_alignment);
91
      for(int i=0; i<79; i++){
92
          chprintf(stream, "register: 0x%02x, data: 0x%02X \n", 0x00+i, data[i]);
93
      }
81 94
    } else {
82 95
      aosUtFailed(stream, &result);
83 96
    }
84 97

  
85
     chprintf(stream, "read y_alignment... \n");
86
     status =  p9221r_lld_read_y_alignment(((ut_p9221rdata_t*)ut->data)->PRd, y_alignment, ((ut_p9221rdata_t*)ut->data)->timeout);
87
     if (status == APAL_STATUS_SUCCESS) {
88
       aosUtPassed(stream, &result);
89
       chprintf(stream, "y_alignment: %d \n", y_alignment);
90
     } else {
91
       aosUtFailed(stream, &result);
92
     }
93

  
94
     chprintf(stream, "read the voltage... \n");
95
     status =   p9221r_lld_read_voltage(const P9221RDriver* const p9221r, int32_t const voltage, const apalTime_t timeout);
96
     if (status == APAL_STATUS_SUCCESS) {
97
       aosUtPassed(stream, &result);
98
       chprintf(stream, "voltage: %d \n", voltage);
99
     } else {
100
       aosUtFailed(stream, &result);
101
     }
102

  
103
     chprintf(stream, "read the current... \n");
104
     status =  p9221r_lld_read_current(const P9221RDriver* const p9221r, int32_t const current, const apalTime_t timeout);
105
     if (status == APAL_STATUS_SUCCESS) {
106
       aosUtPassed(stream, &result);
107
       chprintf(stream, "current: %d \n", current);
108
     } else {
109
       aosUtFailed(stream, &result);
110
     }
98
//    chprintf(stream, "read x_alignment... \n");
99
//    status =  p9221r_lld_read_x_alignment(((ut_p9221rdata_t*)ut->data)->PRd, x_alignment, ((ut_p9221rdata_t*)ut->data)->timeout);
100
//    if (status == APAL_STATUS_SUCCESS) {
101
//      aosUtPassed(stream, &result);
102
//      chprintf(stream, "x_alignment %d \n", x_alignment);
103
//    } else {
104
//      aosUtFailed(stream, &result);
105
//    }
106

  
107
//     chprintf(stream, "read y_alignment... \n");
108
//     status =  p9221r_lld_read_y_alignment(((ut_p9221rdata_t*)ut->data)->PRd, y_alignment, ((ut_p9221rdata_t*)ut->data)->timeout);
109
//     if (status == APAL_STATUS_SUCCESS) {
110
//       aosUtPassed(stream, &result);
111
//       chprintf(stream, "y_alignment: %d \n", y_alignment);
112
//     } else {
113
//       aosUtFailed(stream, &result);
114
//     }
115

  
116
//     chprintf(stream, "read the voltage... \n");
117
//     status =   p9221r_lld_read_voltage(const P9221RDriver* const p9221r, int32_t const voltage, const apalTime_t timeout);
118
//     if (status == APAL_STATUS_SUCCESS) {
119
//       aosUtPassed(stream, &result);
120
//       chprintf(stream, "voltage: %d \n", voltage);
121
//     } else {
122
//       aosUtFailed(stream, &result);
123
//     }
124

  
125
//     chprintf(stream, "read the current... \n");
126
//     status =  p9221r_lld_read_current(const P9221RDriver* const p9221r, int32_t const current, const apalTime_t timeout);
127
//     if (status == APAL_STATUS_SUCCESS) {
128
//       aosUtPassed(stream, &result);
129
//       chprintf(stream, "current: %d \n", current);
130
//     } else {
131
//       aosUtFailed(stream, &result);
132
//     }
111 133

  
112 134
    return result;
113 135
}

Also available in: Unified diff