Skip to content

Commit

Permalink
lis2de12: added const to stmdev_write_ptr #121
Browse files Browse the repository at this point in the history
  • Loading branch information
albezanc committed May 21, 2021
1 parent 8829d95 commit beaa944
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lis2de12_STdC/driver
12 changes: 5 additions & 7 deletions lis2de12_STdC/examples/lis2de12_filter_hp_rst_on_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ static uint8_t tx_buffer[1000];
* and are strictly related to the hardware platform used.
*
*/
static int32_t platform_write(void *handle, uint8_t reg,
uint8_t *bufp,
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
uint16_t len);
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
uint16_t len);
Expand Down Expand Up @@ -204,26 +203,25 @@ void lis2de12_filter_hp_rst_on_int(void)
* @param len number of consecutive register to write
*
*/
static int32_t platform_write(void *handle, uint8_t reg,
uint8_t *bufp,
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
uint16_t len)
{
#if defined(NUCLEO_F411RE)
/* Write multiple command */
reg |= 0x80;
HAL_I2C_Mem_Write(handle, LIS2DE12_I2C_ADD_L, reg,
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
#elif defined(STEVAL_MKI109V3)
/* Write multiple command */
reg |= 0x40;
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(handle, &reg, 1, 1000);
HAL_SPI_Transmit(handle, bufp, len, 1000);
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
#elif defined(SPC584B_DIS)
/* Write multiple command */
reg |= 0x80;
i2c_lld_write(handle, LIS2DE12_I2C_ADD_L & 0xFE, reg, bufp, len);
i2c_lld_write(handle, LIS2DE12_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
#endif
return 0;
}
Expand Down
12 changes: 5 additions & 7 deletions lis2de12_STdC/examples/lis2de12_read_data_polling.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ static uint8_t tx_buffer[1000];
* and are strictly related to the hardware platform used.
*
*/
static int32_t platform_write(void *handle, uint8_t reg,
uint8_t *bufp,
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
uint16_t len);
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
uint16_t len);
Expand Down Expand Up @@ -204,26 +203,25 @@ void lis2de12_read_data_polling(void)
* @param len number of consecutive register to write
*
*/
static int32_t platform_write(void *handle, uint8_t reg,
uint8_t *bufp,
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
uint16_t len)
{
#if defined(NUCLEO_F411RE)
/* Write multiple command */
reg |= 0x80;
HAL_I2C_Mem_Write(handle, LIS2DE12_I2C_ADD_L, reg,
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
#elif defined(STEVAL_MKI109V3)
/* Write multiple command */
reg |= 0x40;
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(handle, &reg, 1, 1000);
HAL_SPI_Transmit(handle, bufp, len, 1000);
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
#elif defined(SPC584B_DIS)
/* Write multiple command */
reg |= 0x80;
i2c_lld_write(handle, LIS2DE12_I2C_ADD_L & 0xFE, reg, bufp, len);
i2c_lld_write(handle, LIS2DE12_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
#endif
return 0;
}
Expand Down
12 changes: 5 additions & 7 deletions lis2de12_STdC/examples/lis2de12_read_fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ static uint8_t whoamI;
* and are strictly related to the hardware platform used.
*
*/
static int32_t platform_write(void *handle, uint8_t reg,
uint8_t *bufp,
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
uint16_t len);
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
uint16_t len);
Expand Down Expand Up @@ -202,26 +201,25 @@ void lis2de12_read_fifo(void)
* @param len number of consecutive register to write
*
*/
static int32_t platform_write(void *handle, uint8_t reg,
uint8_t *bufp,
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
uint16_t len)
{
#if defined(NUCLEO_F411RE)
/* Write multiple command */
reg |= 0x80;
HAL_I2C_Mem_Write(handle, LIS2DE12_I2C_ADD_L, reg,
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
#elif defined(STEVAL_MKI109V3)
/* Write multiple command */
reg |= 0x40;
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(handle, &reg, 1, 1000);
HAL_SPI_Transmit(handle, bufp, len, 1000);
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
#elif defined(SPC584B_DIS)
/* Write multiple command */
reg |= 0x80;
i2c_lld_write(handle, LIS2DE12_I2C_ADD_L & 0xFE, reg, bufp, len);
i2c_lld_write(handle, LIS2DE12_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
#endif
return 0;
}
Expand Down
12 changes: 5 additions & 7 deletions lis2de12_STdC/examples/lis2de12_self_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ static float min_st_limit_mg;
* and are strictly related to the hardware platform used.
*
*/
static int32_t platform_write(void *handle, uint8_t reg,
uint8_t *bufp,
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
uint16_t len);
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
uint16_t len);
Expand Down Expand Up @@ -272,26 +271,25 @@ void lis2de12_self_test(void)
* @param len number of consecutive register to write
*
*/
static int32_t platform_write(void *handle, uint8_t reg,
uint8_t *bufp,
static int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp,
uint16_t len)
{
#if defined(NUCLEO_F411RE)
/* Write multiple command */
reg |= 0x80;
HAL_I2C_Mem_Write(handle, LIS2DE12_I2C_ADD_L, reg,
I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
I2C_MEMADD_SIZE_8BIT, (uint8_t*) bufp, len, 1000);
#elif defined(STEVAL_MKI109V3)
/* Write multiple command */
reg |= 0x40;
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(handle, &reg, 1, 1000);
HAL_SPI_Transmit(handle, bufp, len, 1000);
HAL_SPI_Transmit(handle, (uint8_t*) bufp, len, 1000);
HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
#elif defined(SPC584B_DIS)
/* Write multiple command */
reg |= 0x80;
i2c_lld_write(handle, LIS2DE12_I2C_ADD_L & 0xFE, reg, bufp, len);
i2c_lld_write(handle, LIS2DE12_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
#endif
return 0;
}
Expand Down

0 comments on commit beaa944

Please sign in to comment.