Skip to content

Commit ab9964d

Browse files
author
albezanc
committed
lsm6dsrx: added const to stmdev_write_ptr #121
1 parent 0b7dfb3 commit ab9964d

15 files changed

Lines changed: 102 additions & 113 deletions

lsm6dsrx_STdC/driver

lsm6dsrx_STdC/examples/lsm6dsrx_activity.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
*/
5353

5454
//#define STEVAL_MKI109V3 /* little endian */
55-
#define NUCLEO_F411RE /* little endian */
55+
//#define NUCLEO_F411RE /* little endian */
5656
//#define SPC584B_DIS /* big endian */
5757

5858
/* ATTENTION: By default the driver is little endian. If you need switch
@@ -93,6 +93,7 @@
9393
#include "usbd_cdc_if.h"
9494
#include "gpio.h"
9595
#include "spi.h"
96+
#include "tim.h"
9697

9798
#elif defined(SPC584B_DIS)
9899
#include "components.h"
@@ -119,8 +120,7 @@ static uint8_t tx_buffer[1000];
119120
* and are strictly related to the hardware platform used.
120121
*
121122
*/
122-
static int32_t platform_write(void *handle, uint8_t reg,
123-
uint8_t *bufp,
123+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
124124
uint16_t len);
125125
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
126126
uint16_t len);
@@ -203,20 +203,19 @@ void lsm6dsrx_activity(void)
203203
* @param len number of consecutive register to write
204204
*
205205
*/
206-
static int32_t platform_write(void *handle, uint8_t reg,
207-
uint8_t *bufp,
206+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
208207
uint16_t len)
209208
{
210209
#if defined(NUCLEO_F411RE)
211210
HAL_I2C_Mem_Write(handle, LSM6DSRX_I2C_ADD_L, reg,
212-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
211+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
213212
#elif defined(STEVAL_MKI109V3)
214213
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
215214
HAL_SPI_Transmit(handle, &reg, 1, 1000);
216-
HAL_SPI_Transmit(handle, bufp, len, 1000);
215+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
217216
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
218217
#elif defined(SPC584B_DIS)
219-
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, bufp, len);
218+
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
220219
#endif
221220
return 0;
222221
}

lsm6dsrx_STdC/examples/lsm6dsrx_compressed_fifo.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
*/
5454

5555
//#define STEVAL_MKI109V3 /* little endian */
56-
#define NUCLEO_F411RE /* little endian */
56+
//#define NUCLEO_F411RE /* little endian */
5757
//#define SPC584B_DIS /* big endian */
5858

5959
/* ATTENTION: By default the driver is little endian. If you need switch
@@ -82,6 +82,7 @@
8282
#include <string.h>
8383
#include <stdio.h>
8484
#include <lsm6dsrx_reg.h>
85+
#include "fifo_utility.h"
8586

8687
#if defined(NUCLEO_F411RE)
8788
#include "stm32f4xx_hal.h"
@@ -94,6 +95,7 @@
9495
#include "usbd_cdc_if.h"
9596
#include "gpio.h"
9697
#include "spi.h"
98+
#include "tim.h"
9799

98100
#elif defined(SPC584B_DIS)
99101
#include "components.h"
@@ -128,8 +130,7 @@ static st_fifo_out_slot gyr_slot[SLOT_NUMBER];
128130
* and are strictly related to the hardware platform used.
129131
*
130132
*/
131-
static int32_t platform_write(void *handle, uint8_t reg,
132-
uint8_t *bufp,
133+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
133134
uint16_t len);
134135
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
135136
uint16_t len);
@@ -288,20 +289,19 @@ void lsm6dsrx_compressed_fifo_simple(void)
288289
* @param len number of consecutive register to write
289290
*
290291
*/
291-
static int32_t platform_write(void *handle, uint8_t reg,
292-
uint8_t *bufp,
292+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
293293
uint16_t len)
294294
{
295295
#if defined(NUCLEO_F411RE)
296296
HAL_I2C_Mem_Write(handle, LSM6DSRX_I2C_ADD_L, reg,
297-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
297+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
298298
#elif defined(STEVAL_MKI109V3)
299299
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
300300
HAL_SPI_Transmit(handle, &reg, 1, 1000);
301-
HAL_SPI_Transmit(handle, bufp, len, 1000);
301+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
302302
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
303303
#elif defined(SPC584B_DIS)
304-
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, bufp, len);
304+
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
305305
#endif
306306
return 0;
307307
}

lsm6dsrx_STdC/examples/lsm6dsrx_fifo_pedo.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
*/
5252

5353
//#define STEVAL_MKI109V3 /* little endian */
54-
#define NUCLEO_F411RE /* little endian */
54+
//#define NUCLEO_F411RE /* little endian */
5555
//#define SPC584B_DIS /* big endian */
5656

5757
/* ATTENTION: By default the driver is little endian. If you need switch
@@ -92,6 +92,7 @@
9292
#include "usbd_cdc_if.h"
9393
#include "gpio.h"
9494
#include "spi.h"
95+
#include "tim.h"
9596

9697
#elif defined(SPC584B_DIS)
9798
#include "components.h"
@@ -126,8 +127,7 @@ static uint8_t tx_buffer[1000];
126127
* and are strictly related to the hardware platform used.
127128
*
128129
*/
129-
static int32_t platform_write(void *handle, uint8_t reg,
130-
uint8_t *bufp,
130+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
131131
uint16_t len);
132132
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
133133
uint16_t len);
@@ -148,6 +148,8 @@ void lsm6dsrx_fifo_pedo_simple(void)
148148
ag_ctx.handle = &SENSOR_BUS;
149149
/* Init test platform */
150150
platform_init();
151+
/* Wait sensor boot time */
152+
platform_delay(BOOT_TIME);
151153
/* Check device ID */
152154
lsm6dsrx_device_id_get(&ag_ctx, &whoamI);
153155

@@ -236,20 +238,19 @@ void lsm6dsrx_fifo_pedo_simple(void)
236238
* @param len number of consecutive register to write
237239
*
238240
*/
239-
static int32_t platform_write(void *handle, uint8_t reg,
240-
uint8_t *bufp,
241+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
241242
uint16_t len)
242243
{
243244
#if defined(NUCLEO_F411RE)
244245
HAL_I2C_Mem_Write(handle, LSM6DSRX_I2C_ADD_L, reg,
245-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
246+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
246247
#elif defined(STEVAL_MKI109V3)
247248
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
248249
HAL_SPI_Transmit(handle, &reg, 1, 1000);
249-
HAL_SPI_Transmit(handle, bufp, len, 1000);
250+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
250251
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
251252
#elif defined(SPC584B_DIS)
252-
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, bufp, len);
253+
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
253254
#endif
254255
return 0;
255256
}

lsm6dsrx_STdC/examples/lsm6dsrx_free_fall.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
*/
5353

5454
//#define STEVAL_MKI109V3 /* little endian */
55-
#define NUCLEO_F411RE /* little endian */
55+
//#define NUCLEO_F411RE /* little endian */
5656
//#define SPC584B_DIS /* big endian */
5757

5858
/* ATTENTION: By default the driver is little endian. If you need switch
@@ -93,6 +93,7 @@
9393
#include "usbd_cdc_if.h"
9494
#include "gpio.h"
9595
#include "spi.h"
96+
#include "tim.h"
9697

9798
#elif defined(SPC584B_DIS)
9899
#include "components.h"
@@ -115,8 +116,7 @@ static uint8_t tx_buffer[1000];
115116
* and are strictly related to the hardware platform used.
116117
*
117118
*/
118-
static int32_t platform_write(void *handle, uint8_t reg,
119-
uint8_t *bufp,
119+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
120120
uint16_t len);
121121
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
122122
uint16_t len);
@@ -198,20 +198,19 @@ void lsm6dsrx_free_fall(void)
198198
* @param len number of consecutive register to write
199199
*
200200
*/
201-
static int32_t platform_write(void *handle, uint8_t reg,
202-
uint8_t *bufp,
201+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
203202
uint16_t len)
204203
{
205204
#if defined(NUCLEO_F411RE)
206205
HAL_I2C_Mem_Write(handle, LSM6DSRX_I2C_ADD_L, reg,
207-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
206+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
208207
#elif defined(STEVAL_MKI109V3)
209208
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
210209
HAL_SPI_Transmit(handle, &reg, 1, 1000);
211-
HAL_SPI_Transmit(handle, bufp, len, 1000);
210+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
212211
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
213212
#elif defined(SPC584B_DIS)
214-
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, bufp, len);
213+
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
215214
#endif
216215
return 0;
217216
}

lsm6dsrx_STdC/examples/lsm6dsrx_multi_read_fifo_simple.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
*/
5252

5353
//#define STEVAL_MKI109V3 /* little endian */
54-
#define NUCLEO_F411RE /* little endian */
54+
//#define NUCLEO_F411RE /* little endian */
5555
//#define SPC584B_DIS /* big endian */
5656

5757
/* ATTENTION: By default the driver is little endian. If you need switch
@@ -92,6 +92,7 @@
9292
#include "usbd_cdc_if.h"
9393
#include "gpio.h"
9494
#include "spi.h"
95+
#include "tim.h"
9596

9697
#elif defined(SPC584B_DIS)
9798
#include "components.h"
@@ -124,8 +125,7 @@ static uint8_t tx_buffer[1000];
124125
* and are strictly related to the hardware platform used.
125126
*
126127
*/
127-
static int32_t platform_write(void *handle, uint8_t reg,
128-
uint8_t *bufp,
128+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
129129
uint16_t len);
130130
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
131131
uint16_t len);
@@ -260,20 +260,19 @@ void lsm6dsrx_read_fifo_simple(void)
260260
* @param len number of consecutive register to write
261261
*
262262
*/
263-
static int32_t platform_write(void *handle, uint8_t reg,
264-
uint8_t *bufp,
263+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
265264
uint16_t len)
266265
{
267266
#if defined(NUCLEO_F411RE)
268267
HAL_I2C_Mem_Write(handle, LSM6DSRX_I2C_ADD_L, reg,
269-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
268+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
270269
#elif defined(STEVAL_MKI109V3)
271270
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
272271
HAL_SPI_Transmit(handle, &reg, 1, 1000);
273-
HAL_SPI_Transmit(handle, bufp, len, 1000);
272+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
274273
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
275274
#elif defined(SPC584B_DIS)
276-
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, bufp, len);
275+
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
277276
#endif
278277
return 0;
279278
}

lsm6dsrx_STdC/examples/lsm6dsrx_orientation_6d_4d.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
*/
5353

5454
//#define STEVAL_MKI109V3 /* little endian */
55-
#define NUCLEO_F411RE /* little endian */
55+
//#define NUCLEO_F411RE /* little endian */
5656
//#define SPC584B_DIS /* big endian */
5757

5858
/* ATTENTION: By default the driver is little endian. If you need switch
@@ -93,6 +93,7 @@
9393
#include "usbd_cdc_if.h"
9494
#include "gpio.h"
9595
#include "spi.h"
96+
#include "tim.h"
9697

9798
#elif defined(SPC584B_DIS)
9899
#include "components.h"
@@ -115,8 +116,7 @@ static uint8_t tx_buffer[1000];
115116
* and are strictly related to the hardware platform used.
116117
*
117118
*/
118-
static int32_t platform_write(void *handle, uint8_t reg,
119-
uint8_t *bufp,
119+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
120120
uint16_t len);
121121
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
122122
uint16_t len);
@@ -224,20 +224,19 @@ void lsm6dsrx_orientation(void)
224224
* @param len number of consecutive register to write
225225
*
226226
*/
227-
static int32_t platform_write(void *handle, uint8_t reg,
228-
uint8_t *bufp,
227+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
229228
uint16_t len)
230229
{
231230
#if defined(NUCLEO_F411RE)
232231
HAL_I2C_Mem_Write(handle, LSM6DSRX_I2C_ADD_L, reg,
233-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
232+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
234233
#elif defined(STEVAL_MKI109V3)
235234
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
236235
HAL_SPI_Transmit(handle, &reg, 1, 1000);
237-
HAL_SPI_Transmit(handle, bufp, len, 1000);
236+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
238237
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
239238
#elif defined(SPC584B_DIS)
240-
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, bufp, len);
239+
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
241240
#endif
242241
return 0;
243242
}

lsm6dsrx_STdC/examples/lsm6dsrx_read_data_interrupt.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
*/
5353

5454
//#define STEVAL_MKI109V3 /* little endian */
55-
#define NUCLEO_F411RE /* little endian */
55+
//#define NUCLEO_F411RE /* little endian */
5656
//#define SPC584B_DIS /* big endian */
5757

5858
/* ATTENTION: By default the driver is little endian. If you need switch
@@ -93,6 +93,7 @@
9393
#include "usbd_cdc_if.h"
9494
#include "gpio.h"
9595
#include "spi.h"
96+
#include "tim.h"
9697

9798
#elif defined(SPC584B_DIS)
9899
#include "components.h"
@@ -120,8 +121,7 @@ static uint8_t whoamI, rst;
120121
* and are strictly related to the hardware platform used.
121122
*
122123
*/
123-
static int32_t platform_write(void *handle, uint8_t reg,
124-
uint8_t *bufp,
124+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
125125
uint16_t len);
126126
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
127127
uint16_t len);
@@ -235,20 +235,19 @@ void lsm6dsrx_main_interrupt(void)
235235
* @param len number of consecutive register to write
236236
*
237237
*/
238-
static int32_t platform_write(void *handle, uint8_t reg,
239-
uint8_t *bufp,
238+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
240239
uint16_t len)
241240
{
242241
#if defined(NUCLEO_F411RE)
243242
HAL_I2C_Mem_Write(handle, LSM6DSRX_I2C_ADD_L, reg,
244-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
243+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
245244
#elif defined(STEVAL_MKI109V3)
246245
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
247246
HAL_SPI_Transmit(handle, &reg, 1, 1000);
248-
HAL_SPI_Transmit(handle, bufp, len, 1000);
247+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
249248
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
250249
#elif defined(SPC584B_DIS)
251-
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, bufp, len);
250+
i2c_lld_write(handle, LSM6DSRX_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
252251
#endif
253252
return 0;
254253
}

0 commit comments

Comments
 (0)