Skip to content

Commit

Permalink
iis2dh: 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 58f6d75 commit 59bc4e4
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 57 deletions.
2 changes: 1 addition & 1 deletion iis2dh_STdC/driver
15 changes: 7 additions & 8 deletions iis2dh_STdC/examples/iis2dh_fifo_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*/

//#define STEVAL_MKI109V3 /* little endian */
#define NUCLEO_F411RE /* little endian */
//#define NUCLEO_F411RE /* little endian */
//#define SPC584B_DIS /* big endian */

/* ATTENTION: By default the driver is little endian. If you need switch
Expand Down Expand Up @@ -92,6 +92,7 @@
#include "usbd_cdc_if.h"
#include "gpio.h"
#include "spi.h"
#include "tim.h"

#elif defined(SPC584B_DIS)
#include "components.h"
Expand All @@ -115,8 +116,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 @@ -200,26 +200,25 @@ void iis2dh_fifo_read(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, IIS2DH_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, IIS2DH_I2C_ADD_L & 0xFE, reg, bufp, len);
i2c_lld_write(handle, IIS2DH_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
#endif
return 0;
}
Expand Down
15 changes: 7 additions & 8 deletions iis2dh_STdC/examples/iis2dh_free_fall.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/

//#define STEVAL_MKI109V3 /* little endian */
#define NUCLEO_F411RE /* little endian */
//#define NUCLEO_F411RE /* little endian */
//#define SPC584B_DIS /* big endian */

/* ATTENTION: By default the driver is little endian. If you need switch
Expand Down Expand Up @@ -93,6 +93,7 @@
#include "usbd_cdc_if.h"
#include "gpio.h"
#include "spi.h"
#include "tim.h"

#elif defined(SPC584B_DIS)
#include "components.h"
Expand All @@ -114,8 +115,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 @@ -198,26 +198,25 @@ void iis2dh_free_fall(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, IIS2DH_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, IIS2DH_I2C_ADD_L & 0xFE, reg, bufp, len);
i2c_lld_write(handle, IIS2DH_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
#endif
return 0;
}
Expand Down
15 changes: 7 additions & 8 deletions iis2dh_STdC/examples/iis2dh_orientation.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*/

//#define STEVAL_MKI109V3 /* little endian */
#define NUCLEO_F411RE /* little endian */
//#define NUCLEO_F411RE /* little endian */
//#define SPC584B_DIS /* big endian */

/* ATTENTION: By default the driver is little endian. If you need switch
Expand Down Expand Up @@ -92,6 +92,7 @@
#include "usbd_cdc_if.h"
#include "gpio.h"
#include "spi.h"
#include "tim.h"

#elif defined(SPC584B_DIS)
#include "components.h"
Expand All @@ -113,8 +114,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 @@ -239,26 +239,25 @@ void iis2dh_orientation(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, IIS2DH_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, IIS2DH_I2C_ADD_L & 0xFE, reg, bufp, len);
i2c_lld_write(handle, IIS2DH_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
#endif
return 0;
}
Expand Down
15 changes: 7 additions & 8 deletions iis2dh_STdC/examples/iis2dh_read_data_polling.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*/

//#define STEVAL_MKI109V3 /* little endian */
#define NUCLEO_F411RE /* little endian */
//#define NUCLEO_F411RE /* little endian */
//#define SPC584B_DIS /* big endian */

/* ATTENTION: By default the driver is little endian. If you need switch
Expand Down Expand Up @@ -92,6 +92,7 @@
#include "usbd_cdc_if.h"
#include "gpio.h"
#include "spi.h"
#include "tim.h"

#elif defined(SPC584B_DIS)
#include "components.h"
Expand All @@ -117,8 +118,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 @@ -207,26 +207,25 @@ void iis2dh_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, IIS2DH_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, IIS2DH_I2C_ADD_L & 0xFE, reg, bufp, len);
i2c_lld_write(handle, IIS2DH_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
#endif
return 0;
}
Expand Down
15 changes: 7 additions & 8 deletions iis2dh_STdC/examples/iis2dh_tap_double.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/

//#define STEVAL_MKI109V3 /* little endian */
#define NUCLEO_F411RE /* little endian */
//#define NUCLEO_F411RE /* little endian */
//#define SPC584B_DIS /* big endian */

/* ATTENTION: By default the driver is little endian. If you need switch
Expand Down Expand Up @@ -93,6 +93,7 @@
#include "usbd_cdc_if.h"
#include "gpio.h"
#include "spi.h"
#include "tim.h"

#elif defined(SPC584B_DIS)
#include "components.h"
Expand All @@ -114,8 +115,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 @@ -203,26 +203,25 @@ void iis2dh_tap_double(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, IIS2DH_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, IIS2DH_I2C_ADD_L & 0xFE, reg, bufp, len);
i2c_lld_write(handle, IIS2DH_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
#endif
return 0;
}
Expand Down
15 changes: 7 additions & 8 deletions iis2dh_STdC/examples/iis2dh_tap_single.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*/

//#define STEVAL_MKI109V3 /* little endian */
#define NUCLEO_F411RE /* little endian */
//#define NUCLEO_F411RE /* little endian */
//#define SPC584B_DIS /* big endian */

/* ATTENTION: By default the driver is little endian. If you need switch
Expand Down Expand Up @@ -92,6 +92,7 @@
#include "usbd_cdc_if.h"
#include "gpio.h"
#include "spi.h"
#include "tim.h"

#elif defined(SPC584B_DIS)
#include "components.h"
Expand All @@ -113,8 +114,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 @@ -199,26 +199,25 @@ void iis2dh_tap_single(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, IIS2DH_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, IIS2DH_I2C_ADD_L & 0xFE, reg, bufp, len);
i2c_lld_write(handle, IIS2DH_I2C_ADD_L & 0xFE, reg, (uint8_t*) bufp, len);
#endif
return 0;
}
Expand Down
Loading

0 comments on commit 59bc4e4

Please sign in to comment.