Skip to content

Commit fed43d7

Browse files
author
albezanc
committed
lps33k: added const to stmdev_write_ptr #121
1 parent fe522dc commit fed43d7

3 files changed

Lines changed: 15 additions & 17 deletions

File tree

lps33k_STdC/driver

lps33k_STdC/examples/lps33k_read_data_polling.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
@@ -118,8 +119,7 @@ static stmdev_ctx_t dev_ctx;
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);
@@ -191,20 +191,19 @@ void lps33k_read_data_polling(void)
191191
* @param len number of consecutive register to write
192192
*
193193
*/
194-
static int32_t platform_write(void *handle, uint8_t reg,
195-
uint8_t *bufp,
194+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
196195
uint16_t len)
197196
{
198197
#if defined(NUCLEO_F411RE)
199198
HAL_I2C_Mem_Write(handle, LPS33K_I2C_ADD, reg,
200-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
199+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
201200
#elif defined(STEVAL_MKI109V3)
202201
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
203202
HAL_SPI_Transmit(handle, &reg, 1, 1000);
204-
HAL_SPI_Transmit(handle, bufp, len, 1000);
203+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
205204
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
206205
#elif defined(SPC584B_DIS)
207-
i2c_lld_write(handle, LPS33K_I2C_ADD & 0xFE, reg, bufp, len);
206+
i2c_lld_write(handle, LPS33K_I2C_ADD & 0xFE, reg, (uint8_t*) bufp, len);
208207
#endif
209208
return 0;
210209
}
@@ -280,6 +279,6 @@ static void platform_init(void)
280279
TIM3->CCR2 = PWM_3V3;
281280
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
282281
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
283-
HAL_Delay(1000);
282+
platform_delay(1000);
284283
#endif
285284
}

lps33k_STdC/examples/lps33k_read_one_shot.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
@@ -119,8 +120,7 @@ static stmdev_ctx_t dev_ctx;
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);
@@ -197,20 +197,19 @@ void lps33k_read_one_shot(void)
197197
* @param len number of consecutive register to write
198198
*
199199
*/
200-
static int32_t platform_write(void *handle, uint8_t reg,
201-
uint8_t *bufp,
200+
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
202201
uint16_t len)
203202
{
204203
#if defined(NUCLEO_F411RE)
205204
HAL_I2C_Mem_Write(handle, LPS33K_I2C_ADD, reg,
206-
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
205+
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
207206
#elif defined(STEVAL_MKI109V3)
208207
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
209208
HAL_SPI_Transmit(handle, &reg, 1, 1000);
210-
HAL_SPI_Transmit(handle, bufp, len, 1000);
209+
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
211210
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
212211
#elif defined(SPC584B_DIS)
213-
i2c_lld_write(handle, LPS33K_I2C_ADD & 0xFE, reg, bufp, len);
212+
i2c_lld_write(handle, LPS33K_I2C_ADD & 0xFE, reg, (uint8_t*) bufp, len);
214213
#endif
215214
return 0;
216215
}
@@ -286,6 +285,6 @@ static void platform_init(void)
286285
TIM3->CCR2 = PWM_3V3;
287286
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
288287
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
289-
HAL_Delay(1000);
288+
platform_delay(1000);
290289
#endif
291290
}

0 commit comments

Comments
 (0)