Skip to content

Commit 1519c43

Browse files
author
albezanc
committed
lsm6dsm: added const to stmdev_write_ptr #121
1 parent 03df670 commit 1519c43

21 files changed

Lines changed: 110 additions & 159 deletions

lsm6dsm_STdC/driver

lsm6dsm_STdC/examples/lsm6dsm_activity.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ static uint8_t tx_buffer[1000];
114114
* and are strictly related to the hardware platform used.
115115
*
116116
*/
117-
static int32_t platform_write(void *handle, uint8_t reg,
118-
uint8_t *bufp,
117+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
119118
uint16_t len);
120119
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
121120
uint16_t len);
@@ -205,20 +204,19 @@ void lsm6dsm_activity(void)
205204
* @param len number of consecutive register to write
206205
*
207206
*/
208-
static int32_t platform_write(void *handle, uint8_t reg,
209-
uint8_t *bufp,
207+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
210208
uint16_t len)
211209
{
212210
#if defined(NUCLEO_F411RE)
213211
HAL_I2C_Mem_Write(handle, LSM6DSM_I2C_ADD_H, reg,
214-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
212+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
215213
#elif defined(STEVAL_MKI109V3)
216214
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
217215
HAL_SPI_Transmit(handle, &reg, 1, 1000);
218-
HAL_SPI_Transmit(handle, bufp, len, 1000);
216+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
219217
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
220218
#elif defined(SPC584B_DIS)
221-
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, bufp, len);
219+
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, (uint8_t*) bufp, len);
222220
#endif
223221
return 0;
224222
}

lsm6dsm_STdC/examples/lsm6dsm_fifo_stream_to_fifo.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ static uint8_t tx_buffer[1000];
123123
* and are strictly related to the hardware platform used.
124124
*
125125
*/
126-
static int32_t platform_write(void *handle, uint8_t reg,
127-
uint8_t *bufp,
126+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
128127
uint16_t len);
129128
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
130129
uint16_t len);
@@ -228,20 +227,19 @@ void lsm6dsm_fifo_stream(void)
228227
* @param len number of consecutive register to write
229228
*
230229
*/
231-
static int32_t platform_write(void *handle, uint8_t reg,
232-
uint8_t *bufp,
230+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
233231
uint16_t len)
234232
{
235233
#if defined(NUCLEO_F411RE)
236234
HAL_I2C_Mem_Write(handle, LSM6DSM_I2C_ADD_H, reg,
237-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
235+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
238236
#elif defined(STEVAL_MKI109V3)
239237
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
240238
HAL_SPI_Transmit(handle, &reg, 1, 1000);
241-
HAL_SPI_Transmit(handle, bufp, len, 1000);
239+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
242240
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
243241
#elif defined(SPC584B_DIS)
244-
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, bufp, len);
242+
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, (uint8_t*) bufp, len);
245243
#endif
246244
return 0;
247245
}

lsm6dsm_STdC/examples/lsm6dsm_free_fall.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ static uint8_t tx_buffer[1000];
114114
* and are strictly related to the hardware platform used.
115115
*
116116
*/
117-
static int32_t platform_write(void *handle, uint8_t reg,
118-
uint8_t *bufp,
117+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
119118
uint16_t len);
120119
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
121120
uint16_t len);
@@ -195,20 +194,19 @@ void lsm6dsm_free_fall(void)
195194
* @param len number of consecutive register to write
196195
*
197196
*/
198-
static int32_t platform_write(void *handle, uint8_t reg,
199-
uint8_t *bufp,
197+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
200198
uint16_t len)
201199
{
202200
#if defined(NUCLEO_F411RE)
203201
HAL_I2C_Mem_Write(handle, LSM6DSM_I2C_ADD_H, reg,
204-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
202+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
205203
#elif defined(STEVAL_MKI109V3)
206204
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
207205
HAL_SPI_Transmit(handle, &reg, 1, 1000);
208-
HAL_SPI_Transmit(handle, bufp, len, 1000);
206+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
209207
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
210208
#elif defined(SPC584B_DIS)
211-
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, bufp, len);
209+
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, (uint8_t*) bufp, len);
212210
#endif
213211
return 0;
214212
}

lsm6dsm_STdC/examples/lsm6dsm_orientation.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ static uint8_t tx_buffer[1000];
135135
* and are strictly related to the hardware platform used.
136136
*
137137
*/
138-
static int32_t platform_write(void *handle, uint8_t reg,
139-
uint8_t *bufp,
138+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
140139
uint16_t len);
141140
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
142141
uint16_t len);
@@ -243,20 +242,19 @@ void lsm6dsm_orientation(void)
243242
* @param len number of consecutive register to write
244243
*
245244
*/
246-
static int32_t platform_write(void *handle, uint8_t reg,
247-
uint8_t *bufp,
245+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
248246
uint16_t len)
249247
{
250248
#if defined(NUCLEO_F411RE)
251249
HAL_I2C_Mem_Write(handle, LSM6DSM_I2C_ADD_H, reg,
252-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
250+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
253251
#elif defined(STEVAL_MKI109V3)
254252
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
255253
HAL_SPI_Transmit(handle, &reg, 1, 1000);
256-
HAL_SPI_Transmit(handle, bufp, len, 1000);
254+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
257255
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
258256
#elif defined(SPC584B_DIS)
259-
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, bufp, len);
257+
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, (uint8_t*) bufp, len);
260258
#endif
261259
return 0;
262260
}

lsm6dsm_STdC/examples/lsm6dsm_read_data_polling.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ static uint8_t tx_buffer[1000];
120120
* and are strictly related to the hardware platform used.
121121
*
122122
*/
123-
static int32_t platform_write(void *handle, uint8_t reg,
124-
uint8_t *bufp,
123+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
125124
uint16_t len);
126125
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
127126
uint16_t len);
@@ -241,20 +240,19 @@ void lsm6dsm_read_data_polling(void)
241240
* @param len number of consecutive register to write
242241
*
243242
*/
244-
static int32_t platform_write(void *handle, uint8_t reg,
245-
uint8_t *bufp,
243+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
246244
uint16_t len)
247245
{
248246
#if defined(NUCLEO_F411RE)
249247
HAL_I2C_Mem_Write(handle, LSM6DSM_I2C_ADD_H, reg,
250-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
248+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
251249
#elif defined(STEVAL_MKI109V3)
252250
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
253251
HAL_SPI_Transmit(handle, &reg, 1, 1000);
254-
HAL_SPI_Transmit(handle, bufp, len, 1000);
252+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
255253
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
256254
#elif defined(SPC584B_DIS)
257-
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, bufp, len);
255+
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, (uint8_t*) bufp, len);
258256
#endif
259257
return 0;
260258
}

lsm6dsm_STdC/examples/lsm6dsm_read_fifo.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ static uint8_t tx_buffer[1000];
124124
* and are strictly related to the hardware platform used.
125125
*
126126
*/
127-
static int32_t platform_write(void *handle, uint8_t reg,
128-
uint8_t *bufp,
127+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
129128
uint16_t len);
130129
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
131130
uint16_t len);
@@ -254,20 +253,19 @@ void lsm6dsm_read_fifo_simple(void)
254253
* @param len number of consecutive register to write
255254
*
256255
*/
257-
static int32_t platform_write(void *handle, uint8_t reg,
258-
uint8_t *bufp,
256+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
259257
uint16_t len)
260258
{
261259
#if defined(NUCLEO_F411RE)
262260
HAL_I2C_Mem_Write(handle, LSM6DSM_I2C_ADD_H, reg,
263-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
261+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
264262
#elif defined(STEVAL_MKI109V3)
265263
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
266264
HAL_SPI_Transmit(handle, &reg, 1, 1000);
267-
HAL_SPI_Transmit(handle, bufp, len, 1000);
265+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
268266
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
269267
#elif defined(SPC584B_DIS)
270-
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, bufp, len);
268+
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, (uint8_t*) bufp, len);
271269
#endif
272270
return 0;
273271
}

lsm6dsm_STdC/examples/lsm6dsm_self_test.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@
126126
* and are strictly related to the hardware platform used.
127127
*
128128
*/
129-
static int32_t platform_write(void *handle, uint8_t reg,
130-
uint8_t *bufp,
129+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
131130
uint16_t len);
132131
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
133132
uint16_t len);
@@ -371,20 +370,19 @@ void lsm6dsm_self_test(void)
371370
* @param len number of consecutive register to write
372371
*
373372
*/
374-
static int32_t platform_write(void *handle, uint8_t reg,
375-
uint8_t *bufp,
373+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
376374
uint16_t len)
377375
{
378376
#if defined(NUCLEO_F411RE)
379377
HAL_I2C_Mem_Write(handle, LSM6DSM_I2C_ADD_H, reg,
380-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
378+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
381379
#elif defined(STEVAL_MKI109V3)
382380
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
383381
HAL_SPI_Transmit(handle, &reg, 1, 1000);
384-
HAL_SPI_Transmit(handle, bufp, len, 1000);
382+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
385383
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
386384
#elif defined(SPC584B_DIS)
387-
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, bufp, len);
385+
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, (uint8_t*) bufp, len);
388386
#endif
389387
return 0;
390388
}

lsm6dsm_STdC/examples/lsm6dsm_sens_hub_fifo_lis2mdl.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ static uint8_t tx_buffer[1000];
129129
* and are strictly related to the hardware platform used.
130130
*
131131
*/
132-
static int32_t platform_write(void *handle, uint8_t reg,
133-
uint8_t *bufp,
132+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
134133
uint16_t len);
135134
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
136135
uint16_t len);
@@ -191,8 +190,7 @@ static int32_t lsm6dsm_read_lis2mdl_cx(void *ctx, uint8_t reg,
191190
* to master I2C interface.
192191
*/
193192
static int32_t lsm6dsm_write_lis2mdl_cx(void *ctx, uint8_t reg,
194-
uint8_t *data,
195-
uint16_t len)
193+
const uint8_t *data, uint16_t len)
196194
{
197195
axis3bit16_t data_raw_acceleration;
198196
int32_t mm_error;
@@ -422,20 +420,19 @@ void lsm6dsm_sens_hub_fifo_lis2mdl(void)
422420
* @param len number of consecutive register to write
423421
*
424422
*/
425-
static int32_t platform_write(void *handle, uint8_t reg,
426-
uint8_t *bufp,
423+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
427424
uint16_t len)
428425
{
429426
#if defined(NUCLEO_F411RE)
430427
HAL_I2C_Mem_Write(handle, LSM6DSM_I2C_ADD_H, reg,
431-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
428+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
432429
#elif defined(STEVAL_MKI109V3)
433430
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
434431
HAL_SPI_Transmit(handle, &reg, 1, 1000);
435-
HAL_SPI_Transmit(handle, bufp, len, 1000);
432+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
436433
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
437434
#elif defined(SPC584B_DIS)
438-
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, bufp, len);
435+
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, (uint8_t*) bufp, len);
439436
#endif
440437
return 0;
441438
}

lsm6dsm_STdC/examples/lsm6dsm_sens_hub_fifo_lis2mdl_passthrough.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ stmdev_ctx_t dev_ctx;
129129
* and are strictly related to the hardware platform used.
130130
*
131131
*/
132-
static int32_t platform_write(void *handle, uint8_t reg,
133-
uint8_t *bufp,
132+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
134133
uint16_t len);
135134
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
136135
uint16_t len);
@@ -327,20 +326,19 @@ void example_sensor_hub_fifo_lis2mdl_passthrough_lsm6dsm(void)
327326
* @param len number of consecutive register to write
328327
*
329328
*/
330-
static int32_t platform_write(void *handle, uint8_t reg,
331-
uint8_t *bufp,
329+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
332330
uint16_t len)
333331
{
334332
#if defined(NUCLEO_F411RE)
335333
HAL_I2C_Mem_Write(handle, LSM6DSM_I2C_ADD_H, reg,
336-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
334+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
337335
#elif defined(STEVAL_MKI109V3)
338336
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
339337
HAL_SPI_Transmit(handle, &reg, 1, 1000);
340-
HAL_SPI_Transmit(handle, bufp, len, 1000);
338+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
341339
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
342340
#elif defined(SPC584B_DIS)
343-
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, bufp, len);
341+
i2c_lld_write(handle, LSM6DSM_I2C_ADD_H & 0xFE, reg, (uint8_t*) bufp, len);
344342
#endif
345343
return 0;
346344
}

0 commit comments

Comments
 (0)