Revision 9797f02a

View differences:

include/P9221R/v1/alld_P9221R_v1.h
99 99
#ifdef __cplusplus
100 100
extern "C" {
101 101
#endif
102
  apalExitStatus_t p9221r_lld_read_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, uint16_t* const data, const uint8_t num, const apalTime_t timeout);
102
  apalExitStatus_t p9221r_lld_read_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, uint8_t* const data, const uint8_t num, const apalTime_t timeout);
103 103
  apalExitStatus_t p9221r_lld_write_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, const uint16_t* const data, const uint8_t num, const apalTime_t timeout);
104
  apalExitStatus_t p9221r_lld_read_x_alignment(const P9221RDriver* const p9221r, int32_t const x_alignment, const apalTime_t timeout);
105
  apalExitStatus_t p9221r_lld_read_y_alignment(const P9221RDriver* const p9221r, int32_t const y_alignment, const apalTime_t timeout);
106
  apalExitStatus_t p9221r_lld_read_voltage(const P9221RDriver* const p9221r, int32_t const voltage, const apalTime_t timeout);
107
  apalExitStatus_t p9221r_lld_read_current(const P9221RDriver* const p9221r, int32_t const current, const apalTime_t timeout);
108

  
104 109
#ifdef __cplusplus
105 110
}
106 111
#endif
source/P9221R/v1/alld_P9221R_v1.c
64 64
 * @param[in]   timeout     timeout
65 65
 * @return                  An indicator whether the call was successfull
66 66
 */
67
apalExitStatus_t p9221r_lld_read_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, uint16_t* const data, const uint8_t num, const apalTime_t timeout)
67
apalExitStatus_t p9221r_lld_read_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, uint8_t* const data, const uint8_t num, const apalTime_t timeout)
68 68
{
69 69
  apalDbgAssert(p9221r != NULL);
70 70
  apalDbgAssert(p9221r->i2cd != NULL);
71 71
  apalDbgAssert(data != NULL);
72 72

  
73
  uint16_t address = ((uint16_t)addr << 8) | ((uint16_t)addr & 0x00FF);
74
  uint8_t buffer[num*2];
75
  for (uint8_t i = 0; i < num*2; ++i) {
73
  uint8_t buffer[num];
74
  for (uint8_t i = 0; i < num; ++i) {
76 75
      buffer[i] = 1;
77 76
  }
78
  apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), &address, 2, buffer, 2*num, timeout);
77
  apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), (uint8_t*)&addr, 1, buffer, num, timeout);
79 78
  for (uint8_t dataIdx = 0; dataIdx < num; dataIdx++) {
80
    data[dataIdx] = (buffer[2*dataIdx] << 8) | buffer[2*dataIdx+1];
79
    //data[dataIdx] = (buffer[2*dataIdx] << 8) | buffer[2*dataIdx+1];
80
      data[dataIdx] = buffer[dataIdx];
81
   // TODO test!
81 82
  }
82 83
  return status;
83 84
}
......
92 93
 * @param[in]   timeout     timeout
93 94
 * @return                  An indicator whether the call was successfull
94 95
 */
95

  
96 96
apalExitStatus_t p9221r_lld_write_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, const uint16_t* const data, const uint8_t num, const apalTime_t timeout)
97 97
{
98 98
  apalDbgAssert(p9221r != NULL);
......
108 108
  return apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), buffer, 1+2*num, NULL, 0, timeout);
109 109
}
110 110

  
111
/**
112
 * @brief Read the x_alignment.
113
 * @param[in]   i2cd        i2c driver
114
 * @param[in]   PRd         p9221r driver
115
 * @param[out]  x_alignment alignment register content
116
 * @param[in]   timeout     timeout
117
 * @return                  An indicator whether the call was successfull
118
 */
119
apalExitStatus_t p9221r_lld_read_x_alignment(const P9221RDriver* const p9221r, int32_t const x_alignment, const apalTime_t timeout)
120
{
121
    apalExitStatus_t status = NULL;
122

  
123
    return status;
124
}
125

  
126
/**
127
 * @brief Read the y_alignment.
128
 * @param[in]   i2cd        i2c driver
129
 * @param[in]   PRd         p9221r driver
130
 * @param[out]  y_alignment alignment register content
131
 * @param[in]   timeout     timeout
132
 * @return                  An indicator whether the call was successfull
133
 */
134
apalExitStatus_t p9221r_lld_read_y_alignment(const P9221RDriver* const p9221r, int32_t const y_alignment, const apalTime_t timeout)
135
{
136
    apalExitStatus_t status = NULL;
137

  
138
    return status;
139
}
140

  
141
/**
142
 * @brief Read the voltage.
143
 * @param[in]   i2cd        i2c driver
144
 * @param[in]   PRd         p9221r driver
145
 * @param[out]  voltage     voltage register content
146
 * @param[in]   timeout     timeout
147
 * @return                  An indicator whether the call was successfull
148
 */
149
apalExitStatus_t p9221r_lld_read_voltage(const P9221RDriver* const p9221r, int32_t const voltage, const apalTime_t timeout)
150
{
151
    apalExitStatus_t status = NULL;
152

  
153
    return status;
154
}
155

  
156
/**
157
 * @brief Read the current.
158
 * @param[in]   i2cd        i2c driver
159
 * @param[in]   PRd         p9221r driver
160
 * @param[out]  current     register content
161
 * @param[in]   timeout     timeout
162
 * @return                  An indicator whether the call was successfull
163
 */
164
apalExitStatus_t p9221r_lld_read_current(const P9221RDriver* const p9221r, int32_t const current, const apalTime_t timeout)
165
{
166
    apalExitStatus_t status = NULL;
167

  
168
    return status;
169
}
170

  
171

  
111 172
#endif /* defined(AMIROLLD_CFG_P9221R) && (AMIROLLD_CFG_P9221R == 1) */
112 173

  
113 174

  

Also available in: Unified diff