Skip to content

Commit 1949ff7

Browse files
author
albezanc
committed
lsm303agr: added const to stmdev_write_ptr #121
1 parent 4573922 commit 1949ff7

3 files changed

Lines changed: 13 additions & 17 deletions

File tree

lsm303agr_STdC/driver

lsm303agr_STdC/examples/lsm303agr_read_data_polling.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ static uint8_t tx_buffer[TX_BUF_DIM];
152152
* and are strictly related to the hardware platform used.
153153
*
154154
*/
155-
static int32_t platform_write(void *handle, uint8_t reg,
156-
uint8_t *bufp,
155+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
157156
uint16_t len);
158157
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
159158
uint16_t len);
@@ -286,8 +285,7 @@ void lsm303agr_read_data_polling(void)
286285
* @param len number of consecutive register to write
287286
*
288287
*/
289-
static int32_t platform_write(void *handle, uint8_t reg,
290-
uint8_t *bufp,
288+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
291289
uint16_t len)
292290
{
293291
sensbus_t *sensbus = (sensbus_t *)handle;
@@ -299,7 +297,7 @@ static int32_t platform_write(void *handle, uint8_t reg,
299297
}
300298

301299
HAL_I2C_Mem_Write(sensbus->hbus, sensbus->i2c_address, reg,
302-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
300+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
303301
#elif defined(STEVAL_MKI109V3)
304302

305303
if (sensbus->cs_pin == CS_up_Pin) {
@@ -309,7 +307,7 @@ static int32_t platform_write(void *handle, uint8_t reg,
309307

310308
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_RESET);
311309
HAL_SPI_Transmit(sensbus->hbus, &reg, 1, 1000);
312-
HAL_SPI_Transmit(sensbus->hbus, bufp, len, 1000);
310+
HAL_SPI_Transmit(sensbus->hbus, (uint8_t*) bufp, len, 1000);
313311
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_SET);
314312
#elif defined(SPC584B_DIS)
315313

@@ -318,8 +316,8 @@ static int32_t platform_write(void *handle, uint8_t reg,
318316
reg |= 0x80;
319317
}
320318

321-
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg, bufp,
322-
len);
319+
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg,
320+
(uint8_t*) bufp, len);
323321
#endif
324322
return 0;
325323
}

lsm303agr_STdC/examples/lsm303agr_self_test.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ static sensbus_t mag_bus = {&SENSOR_BUS,
150150
* and are strictly related to the hardware platform used.
151151
*
152152
*/
153-
static int32_t platform_write(void *handle, uint8_t reg,
154-
uint8_t *bufp,
153+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
155154
uint16_t len);
156155
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
157156
uint16_t len);
@@ -417,8 +416,7 @@ void lsm303agr_self_test(void)
417416
* @param len number of consecutive register to write
418417
*
419418
*/
420-
static int32_t platform_write(void *handle, uint8_t reg,
421-
uint8_t *bufp,
419+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
422420
uint16_t len)
423421
{
424422
sensbus_t *sensbus = (sensbus_t *)handle;
@@ -430,7 +428,7 @@ static int32_t platform_write(void *handle, uint8_t reg,
430428
}
431429

432430
HAL_I2C_Mem_Write(sensbus->hbus, sensbus->i2c_address, reg,
433-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
431+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
434432
#elif defined(STEVAL_MKI109V3)
435433

436434
if (sensbus->cs_pin == CS_up_Pin) {
@@ -440,7 +438,7 @@ static int32_t platform_write(void *handle, uint8_t reg,
440438

441439
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_RESET);
442440
HAL_SPI_Transmit(sensbus->hbus, &reg, 1, 1000);
443-
HAL_SPI_Transmit(sensbus->hbus, bufp, len, 1000);
441+
HAL_SPI_Transmit(sensbus->hbus, (uint8_t*) bufp, len, 1000);
444442
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_SET);
445443
#elif defined(SPC584B_DIS)
446444

@@ -449,8 +447,8 @@ static int32_t platform_write(void *handle, uint8_t reg,
449447
reg |= 0x80;
450448
}
451449

452-
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg, bufp,
453-
len);
450+
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg,
451+
(uint8_t*) bufp, len);
454452
#endif
455453
return 0;
456454
}

0 commit comments

Comments
 (0)