Skip to content

Commit 2eb7389

Browse files
author
albezanc
committed
lsm303ah: added const to stmdev_write_ptr #121
1 parent 1949ff7 commit 2eb7389

3 files changed

Lines changed: 13 additions & 17 deletions

File tree

lsm303ah_STdC/driver

lsm303ah_STdC/examples/lsm303ah_read_data_polling.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ static uint8_t whoamI, rst;
148148
* and are strictly related to the hardware platform used.
149149
*
150150
*/
151-
static int32_t platform_write(void *handle, uint8_t reg,
152-
uint8_t *bufp,
151+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
153152
uint16_t len);
154153
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
155154
uint16_t len);
@@ -272,27 +271,26 @@ void lsm303ah_read_data_polling(void)
272271
* @param len number of consecutive register to write
273272
*
274273
*/
275-
static int32_t platform_write(void *handle, uint8_t reg,
276-
uint8_t *bufp,
274+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
277275
uint16_t len)
278276
{
279277
sensbus_t *sensbus = (sensbus_t *)handle;
280278
#if defined(NUCLEO_F411RE)
281279
/* Write multiple command */
282280
reg |= 0x80;
283281
HAL_I2C_Mem_Write(sensbus->hbus, sensbus->i2c_address, reg,
284-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
282+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
285283
#elif defined(STEVAL_MKI109V3)
286284
/* Write multiple command */
287285
reg |= 0x40;
288286
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_RESET);
289287
HAL_SPI_Transmit(sensbus->hbus, &reg, 1, 1000);
290-
HAL_SPI_Transmit(sensbus->hbus, bufp, len, 1000);
288+
HAL_SPI_Transmit(sensbus->hbus, (uint8_t*) bufp, len, 1000);
291289
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_SET);
292290
#elif defined(SPC584B_DIS)
293291
reg |= 0x80;
294-
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg, bufp,
295-
len);
292+
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg,
293+
(uint8_t*) bufp, len);
296294
#endif
297295
return 0;
298296
}

lsm303ah_STdC/examples/lsm303ah_self_test.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ static sensbus_t mag_bus = {&SENSOR_BUS,
161161
* and are strictly related to the hardware platform used.
162162
*
163163
*/
164-
static int32_t platform_write(void *handle, uint8_t reg,
165-
uint8_t *bufp,
164+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
166165
uint16_t len);
167166
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
168167
uint16_t len);
@@ -422,27 +421,26 @@ void lsm303ah_self_test(void)
422421
* @param len number of consecutive register to write
423422
*
424423
*/
425-
static int32_t platform_write(void *handle, uint8_t reg,
426-
uint8_t *bufp,
424+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
427425
uint16_t len)
428426
{
429427
sensbus_t *sensbus = (sensbus_t *)handle;
430428
#if defined(NUCLEO_F411RE)
431429
/* Write multiple command */
432430
reg |= 0x80;
433431
HAL_I2C_Mem_Write(sensbus->hbus, sensbus->i2c_address, reg,
434-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
432+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
435433
#elif defined(STEVAL_MKI109V3)
436434
/* Write multiple command */
437435
reg |= 0x40;
438436
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_RESET);
439437
HAL_SPI_Transmit(sensbus->hbus, &reg, 1, 1000);
440-
HAL_SPI_Transmit(sensbus->hbus, bufp, len, 1000);
438+
HAL_SPI_Transmit(sensbus->hbus, (uint8_t*) bufp, len, 1000);
441439
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_SET);
442440
#elif defined(SPC584B_DIS)
443441
reg |= 0x80;
444-
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg, bufp,
445-
len);
442+
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg,
443+
(uint8_t*) bufp, len);
446444
#endif
447445
return 0;
448446
}

0 commit comments

Comments
 (0)