Skip to content

Commit 826cff1

Browse files
author
albezanc
committed
lsm9ds1: added const to stmdev_write_ptr #121
1 parent 3b8ae48 commit 826cff1

3 files changed

Lines changed: 31 additions & 45 deletions

File tree

lsm9ds1_STdC/driver

lsm9ds1_STdC/examples/lsm9ds1_read_data_polling.c

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,13 @@ static uint8_t tx_buffer[1000];
153153
*
154154
*/
155155
static int32_t platform_write_imu(void *handle, uint8_t reg,
156-
uint8_t *bufp,
157-
uint16_t len);
156+
const uint8_t *bufp, uint16_t len);
158157
static int32_t platform_read_imu(void *handle, uint8_t reg,
159-
uint8_t *bufp,
160-
uint16_t len);
158+
uint8_t *bufp, uint16_t len);
161159
static int32_t platform_write_mag(void *handle, uint8_t reg,
162-
uint8_t *bufp,
163-
uint16_t len);
160+
const uint8_t *bufp, uint16_t len);
164161
static int32_t platform_read_mag(void *handle, uint8_t reg,
165-
uint8_t *bufp,
166-
uint16_t len);
162+
uint8_t *bufp, uint16_t len);
167163
static void tx_com( uint8_t *tx_buffer, uint16_t len );
168164
static void platform_delay(uint32_t ms);
169165
static void platform_init(void);
@@ -285,21 +281,20 @@ void lsm9ds1_read_data_polling(void)
285281
*
286282
*/
287283
static int32_t platform_write_imu(void *handle, uint8_t reg,
288-
uint8_t *bufp,
289-
uint16_t len)
284+
const uint8_t *bufp, uint16_t len)
290285
{
291286
sensbus_t *sensbus = (sensbus_t *)handle;
292287
#if defined(NUCLEO_F411RE)
293288
HAL_I2C_Mem_Write(sensbus->hbus, sensbus->i2c_address, reg,
294-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
289+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
295290
#elif defined(STEVAL_MKI109V3)
296291
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_RESET);
297292
HAL_SPI_Transmit(sensbus->hbus, &reg, 1, 1000);
298-
HAL_SPI_Transmit(sensbus->hbus, bufp, len, 1000);
293+
HAL_SPI_Transmit(sensbus->hbus, (uint8_t*) bufp, len, 1000);
299294
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_SET);
300295
#elif defined(SPC584B_DIS)
301-
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg, bufp,
302-
len);
296+
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg,
297+
(uint8_t*) bufp, len);
303298
#endif
304299
return 0;
305300
}
@@ -315,27 +310,26 @@ static int32_t platform_write_imu(void *handle, uint8_t reg,
315310
*
316311
*/
317312
static int32_t platform_write_mag(void *handle, uint8_t reg,
318-
uint8_t *bufp,
319-
uint16_t len)
313+
const uint8_t *bufp, uint16_t len)
320314
{
321315
sensbus_t *sensbus = (sensbus_t *)handle;
322316
#if defined(NUCLEO_F411RE)
323317
/* Write multiple command */
324318
reg |= 0x80;
325319
HAL_I2C_Mem_Write(sensbus->hbus, sensbus->i2c_address, reg,
326-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
320+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
327321
#elif defined(STEVAL_MKI109V3)
328322
/* Write multiple command */
329323
reg |= 0x40;
330324
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_RESET);
331325
HAL_SPI_Transmit(sensbus->hbus, &reg, 1, 1000);
332-
HAL_SPI_Transmit(sensbus->hbus, bufp, len, 1000);
326+
HAL_SPI_Transmit(sensbus->hbus, (uint8_t*) bufp, len, 1000);
333327
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_SET);
334328
#elif defined(SPC584B_DIS)
335329
/* Write multiple command */
336330
reg |= 0x80;
337-
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg, bufp,
338-
len);
331+
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg,
332+
(uint8_t*) bufp, len);
339333
#endif
340334
return 0;
341335
}
@@ -351,8 +345,7 @@ static int32_t platform_write_mag(void *handle, uint8_t reg,
351345
*
352346
*/
353347
static int32_t platform_read_imu(void *handle, uint8_t reg,
354-
uint8_t *bufp,
355-
uint16_t len)
348+
uint8_t *bufp, uint16_t len)
356349
{
357350
sensbus_t *sensbus = (sensbus_t *)handle;
358351
#if defined(NUCLEO_F411RE)
@@ -383,8 +376,7 @@ static int32_t platform_read_imu(void *handle, uint8_t reg,
383376
*
384377
*/
385378
static int32_t platform_read_mag(void *handle, uint8_t reg,
386-
uint8_t *bufp,
387-
uint16_t len)
379+
uint8_t *bufp, uint16_t len)
388380
{
389381
sensbus_t *sensbus = (sensbus_t *)handle;
390382
#if defined(NUCLEO_F411RE)

lsm9ds1_STdC/examples/lsm9ds1_self_test.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,13 @@ static sensbus_t imu_bus = {&SENSOR_BUS,
165165
*
166166
*/
167167
static int32_t platform_write_imu(void *handle, uint8_t reg,
168-
uint8_t *bufp,
169-
uint16_t len);
168+
const uint8_t *bufp, uint16_t len);
170169
static int32_t platform_read_imu(void *handle, uint8_t reg,
171-
uint8_t *bufp,
172-
uint16_t len);
170+
uint8_t *bufp, uint16_t len);
173171
static int32_t platform_write_mag(void *handle, uint8_t reg,
174-
uint8_t *bufp,
175-
uint16_t len);
172+
const uint8_t *bufp, uint16_t len);
176173
static int32_t platform_read_mag(void *handle, uint8_t reg,
177-
uint8_t *bufp,
178-
uint16_t len);
174+
uint8_t *bufp, uint16_t len);
179175
static void tx_com( uint8_t *tx_buffer, uint16_t len );
180176
static void platform_delay(uint32_t ms);
181177
static void platform_init(void);
@@ -532,21 +528,20 @@ void lis9ds1_self_test(void)
532528
*
533529
*/
534530
static int32_t platform_write_imu(void *handle, uint8_t reg,
535-
uint8_t *bufp,
536-
uint16_t len)
531+
const uint8_t *bufp, uint16_t len)
537532
{
538533
sensbus_t *sensbus = (sensbus_t *)handle;
539534
#if defined(NUCLEO_F411RE)
540535
HAL_I2C_Mem_Write(sensbus->hbus, sensbus->i2c_address, reg,
541-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
536+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
542537
#elif defined(STEVAL_MKI109V3)
543538
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_RESET);
544539
HAL_SPI_Transmit(sensbus->hbus, &reg, 1, 1000);
545-
HAL_SPI_Transmit(sensbus->hbus, bufp, len, 1000);
540+
HAL_SPI_Transmit(sensbus->hbus, (uint8_t*) bufp, len, 1000);
546541
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_SET);
547542
#elif defined(SPC584B_DIS)
548-
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg, bufp,
549-
len);
543+
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg,
544+
(uint8_t*) bufp, len);
550545
#endif
551546
return 0;
552547
}
@@ -562,27 +557,26 @@ static int32_t platform_write_imu(void *handle, uint8_t reg,
562557
*
563558
*/
564559
static int32_t platform_write_mag(void *handle, uint8_t reg,
565-
uint8_t *bufp,
566-
uint16_t len)
560+
const uint8_t *bufp, uint16_t len)
567561
{
568562
sensbus_t *sensbus = (sensbus_t *)handle;
569563
#if defined(NUCLEO_F411RE)
570564
/* Write multiple command */
571565
reg |= 0x80;
572566
HAL_I2C_Mem_Write(sensbus->hbus, sensbus->i2c_address, reg,
573-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
567+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
574568
#elif defined(STEVAL_MKI109V3)
575569
/* Write multiple command */
576570
reg |= 0x40;
577571
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_RESET);
578572
HAL_SPI_Transmit(sensbus->hbus, &reg, 1, 1000);
579-
HAL_SPI_Transmit(sensbus->hbus, bufp, len, 1000);
573+
HAL_SPI_Transmit(sensbus->hbus, (uint8_t*) bufp, len, 1000);
580574
HAL_GPIO_WritePin(sensbus->cs_port, sensbus->cs_pin, GPIO_PIN_SET);
581575
#elif defined(SPC584B_DIS)
582576
/* Write multiple command */
583577
reg |= 0x80;
584-
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg, bufp,
585-
len);
578+
i2c_lld_write(sensbus->hbus, sensbus->i2c_address & 0xFE, reg,
579+
(uint8_t*) bufp, len);
586580
#endif
587581
return 0;
588582
}

0 commit comments

Comments
 (0)