Revision 2e028ba0

View differences:

source/P9221R/v1/alld_P9221R_v1.c
112 112
 */
113 113
apalExitStatus_t p9221r_lld_read_x_alignment(const P9221RDriver* const p9221r, int8_t* const x_alignment, const apalTime_t timeout)
114 114
{
115
    uint8_t address = P9221R_LLD_REGISTER_ALIGNMENT_X;
116
    apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), &address, 2, x_alignment, 1, timeout); // TODO check if implicit cast is ok (uint)
115
    uint8_t addr[2] = {(P9221R_LLD_REGISTER_ALIGNMENT_X & 0xFF00) >> 8, P9221R_LLD_REGISTER_ALIGNMENT_X & 0x00FF};
116
    apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), addr, 2, x_alignment, 1, timeout); // TODO check if implicit cast is ok (uint)
117 117

  
118 118
    return status;
119 119
}
......
128 128
 */
129 129
apalExitStatus_t p9221r_lld_read_y_alignment(const P9221RDriver* const p9221r, int8_t* const y_alignment, const apalTime_t timeout)
130 130
{
131
    uint8_t address = P9221R_LLD_REGISTER_ALIGNMENT_Y;
132
    apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), &address, 2, y_alignment, 1, timeout); // TODO check if implicit cast is ok (uint)
131
    uint8_t addr[2] = {(P9221R_LLD_REGISTER_ALIGNMENT_Y & 0xFF00) >> 8, P9221R_LLD_REGISTER_ALIGNMENT_Y & 0x00FF};
132
    apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), addr, 2, y_alignment, 1, timeout); // TODO check if implicit cast is ok (uint)
133 133

  
134 134
    return status;
135 135
}
......
144 144
 */
145 145
apalExitStatus_t p9221r_lld_read_voltage(const P9221RDriver* const p9221r, float* const voltage, const apalTime_t timeout)
146 146
{
147
    uint8_t addr = P9221R_LLD_REGISTER_OUTPUT_VOLTAGE_LSB;
147
    uint8_t addr[2] = {(P9221R_LLD_REGISTER_OUTPUT_VOLTAGE_LSB & 0xFF00) >> 8, P9221R_LLD_REGISTER_OUTPUT_VOLTAGE_LSB & 0x00FF};
148 148
    uint8_t buffer[2];
149 149
    uint16_t value;
150 150

  
151
    apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), (uint8_t*)&addr, 1, buffer, 2, timeout);
151
    apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), addr, 2, buffer, 2, timeout);
152 152
    value = ((buffer[1] << 8) & 0x0F) | buffer[0]; // 4MSB are in buffer[1] so we shift and mask, 8LSB are in buffer[0]
153 153
    *voltage = (((float) value) * 6 * 2.1)/4095.0;
154 154

  
......
165 165
 */
166 166
apalExitStatus_t p9221r_lld_read_current(const P9221RDriver* const p9221r, float* const current, const apalTime_t timeout)
167 167
{
168
    uint8_t addr = P9221R_LLD_REGISTER_IOUT_CURRENT_LSB;
168
    uint8_t addr[2] = {(P9221R_LLD_REGISTER_IOUT_CURRENT_LSB & 0xFF00) >> 8, P9221R_LLD_REGISTER_IOUT_CURRENT_LSB & 0x00FF};
169 169
    uint8_t buffer[2];
170 170
    uint16_t value;
171 171

  
172
    apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), (uint8_t*)&addr, 1, buffer, 2, timeout);
172
    apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), addr, 2, buffer, 2, timeout);
173 173
    value = (buffer[1] << 8) | buffer[0]; // 8MSB are in buffer[1] so we shift, 8LSB are in buffer[0]
174 174
    *current = (((float) value) * 2 * 2.1)/4095.0;
175 175

  

Also available in: Unified diff