Skip to content

Commit f266cb8

Browse files
author
albezanc
committed
lis3mdl: added const to stmdev_write_ptr #121
1 parent f4aa6a4 commit f266cb8

4 files changed

Lines changed: 24 additions & 27 deletions

File tree

lis3mdl_STdC/driver

lis3mdl_STdC/examples/lis3mdl_interrupt.c

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

5656
//#define STEVAL_MKI109V3 /* little endian */
57-
#define NUCLEO_F411RE /* little endian */
57+
//#define NUCLEO_F411RE /* little endian */
5858
//#define SPC584B_DIS /* big endian */
5959

6060
/* ATTENTION: By default the driver is little endian. If you need switch
@@ -95,6 +95,7 @@
9595
#include "usbd_cdc_if.h"
9696
#include "gpio.h"
9797
#include "spi.h"
98+
#include "tim.h"
9899

99100
#elif defined(SPC584B_DIS)
100101
#include "components.h"
@@ -121,8 +122,7 @@ static uint16_t threshold = (uint16_t)(1711 * 0.192f);
121122
* and are strictly related to the hardware platform used.
122123
*
123124
*/
124-
static int32_t platform_write(void *handle, uint8_t reg,
125-
uint8_t *bufp,
125+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
126126
uint16_t len);
127127
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
128128
uint16_t len);
@@ -249,26 +249,25 @@ void lis3mdl_interrupt(void)
249249
* @param len number of consecutive register to write
250250
*
251251
*/
252-
static int32_t platform_write(void *handle, uint8_t reg,
253-
uint8_t *bufp,
252+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
254253
uint16_t len)
255254
{
256255
#if defined(NUCLEO_F411RE)
257256
/* Write multiple command */
258257
reg |= 0x80;
259258
HAL_I2C_Mem_Write(handle, LIS3MDL_I2C_ADD_L, reg,
260-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
259+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
261260
#elif defined(STEVAL_MKI109V3)
262261
/* Write multiple command */
263262
reg |= 0x40;
264263
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
265264
HAL_SPI_Transmit(handle, &reg, 1, 1000);
266-
HAL_SPI_Transmit(handle, bufp, len, 1000);
265+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
267266
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
268267
#elif defined(SPC584B_DIS)
269268
/* Write multiple command */
270269
reg |= 0x80;
271-
i2c_lld_write(handle, LIS3MDL_I2C_ADD_L & 0xFE, reg, bufp, len);
270+
i2c_lld_write(handle, LIS3MDL_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
272271
#endif
273272
return 0;
274273
}
@@ -349,7 +348,7 @@ static void platform_init(void)
349348
TIM3->CCR2 = PWM_3V3;
350349
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
351350
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
352-
HAL_Delay(1000);
351+
platform_delay(1000);
353352
#endif
354353
}
355354

lis3mdl_STdC/examples/lis3mdl_read_data_polling.c

Lines changed: 8 additions & 9 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
@@ -94,6 +94,7 @@
9494
#include "usbd_cdc_if.h"
9595
#include "gpio.h"
9696
#include "spi.h"
97+
#include "tim.h"
9798

9899
#elif defined(SPC584B_DIS)
99100
#include "components.h"
@@ -118,8 +119,7 @@ static uint8_t tx_buffer[1000];
118119
* and are strictly related to the hardware platform used.
119120
*
120121
*/
121-
static int32_t platform_write(void *handle, uint8_t reg,
122-
uint8_t *bufp,
122+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
123123
uint16_t len);
124124
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
125125
uint16_t len);
@@ -202,26 +202,25 @@ void lis3mdl_read_data_polling(void)
202202
* @param len number of consecutive register to write
203203
*
204204
*/
205-
static int32_t platform_write(void *handle, uint8_t reg,
206-
uint8_t *bufp,
205+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
207206
uint16_t len)
208207
{
209208
#if defined(NUCLEO_F411RE)
210209
/* Write multiple command */
211210
reg |= 0x80;
212211
HAL_I2C_Mem_Write(handle, LIS3MDL_I2C_ADD_L, reg,
213-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
212+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
214213
#elif defined(STEVAL_MKI109V3)
215214
/* Write multiple command */
216215
reg |= 0x40;
217216
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
218217
HAL_SPI_Transmit(handle, &reg, 1, 1000);
219-
HAL_SPI_Transmit(handle, bufp, len, 1000);
218+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
220219
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
221220
#elif defined(SPC584B_DIS)
222221
/* Write multiple command */
223222
reg |= 0x80;
224-
i2c_lld_write(handle, LIS3MDL_I2C_ADD_L & 0xFE, reg, bufp, len);
223+
i2c_lld_write(handle, LIS3MDL_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
225224
#endif
226225
return 0;
227226
}
@@ -302,7 +301,7 @@ static void platform_init(void)
302301
TIM3->CCR2 = PWM_3V3;
303302
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
304303
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
305-
HAL_Delay(1000);
304+
platform_delay(1000);
306305
#endif
307306
}
308307

lis3mdl_STdC/examples/lis3mdl_self_test.c

Lines changed: 7 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
@@ -94,6 +94,7 @@
9494
#include "usbd_cdc_if.h"
9595
#include "gpio.h"
9696
#include "spi.h"
97+
#include "tim.h"
9798

9899
#elif defined(SPC584B_DIS)
99100
#include "components.h"
@@ -126,8 +127,7 @@ static const float max_st_limit[] = {3.0f, 3.0f, 1.0f};
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);
@@ -286,26 +286,25 @@ void lis3mdl_self_test(void)
286286
* @param len number of consecutive register to write
287287
*
288288
*/
289-
static int32_t platform_write(void *handle, uint8_t reg,
290-
uint8_t *bufp,
289+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
291290
uint16_t len)
292291
{
293292
#if defined(NUCLEO_F411RE)
294293
/* Write multiple command */
295294
reg |= 0x80;
296295
HAL_I2C_Mem_Write(handle, LIS3MDL_I2C_ADD_L, reg,
297-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
296+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
298297
#elif defined(STEVAL_MKI109V3)
299298
/* Write multiple command */
300299
reg |= 0x40;
301300
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
302301
HAL_SPI_Transmit(handle, &reg, 1, 1000);
303-
HAL_SPI_Transmit(handle, bufp, len, 1000);
302+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
304303
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
305304
#elif defined(SPC584B_DIS)
306305
/* Write multiple command */
307306
reg |= 0x80;
308-
i2c_lld_write(handle, LIS3MDL_I2C_ADD_L & 0xFE, reg, bufp, len);
307+
i2c_lld_write(handle, LIS3MDL_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
309308
#endif
310309
return 0;
311310
}

0 commit comments

Comments
 (0)