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
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 );
124124static int32_t platform_read (void * handle , uint8_t reg , uint8_t * bufp ,
125125 uint16_t len );
@@ -132,7 +132,7 @@ void lps22hb_read_one_shot(void)
132132 /* Initialize mems driver interface */
133133 dev_ctx .write_reg = platform_write ;
134134 dev_ctx .read_reg = platform_read ;
135- dev_ctx .handle = & hi2c1 ;
135+ dev_ctx .handle = & SENSOR_BUS ;
136136 /* Initialize platform specific hardware */
137137 platform_init ();
138138 /* Check device ID */
@@ -195,20 +195,19 @@ void lps22hb_read_one_shot(void)
195195 * @param len number of consecutive register to write
196196 *
197197 */
198- static int32_t platform_write (void * handle , uint8_t reg ,
199- uint8_t * bufp ,
198+ static int32_t platform_write (void * handle , uint8_t reg , const uint8_t * bufp ,
200199 uint16_t len )
201200{
202201#if defined(NUCLEO_F411RE )
203202 HAL_I2C_Mem_Write (handle , LPS22HB_I2C_ADD_H , reg ,
204- I2C_MEMADD_SIZE_8BIT , bufp , len , 1000 );
203+ I2C_MEMADD_SIZE_8BIT , ( uint8_t * ) bufp , len , 1000 );
205204#elif defined(STEVAL_MKI109V3 )
206205 HAL_GPIO_WritePin (CS_up_GPIO_Port , CS_up_Pin , GPIO_PIN_RESET );
207206 HAL_SPI_Transmit (handle , & reg , 1 , 1000 );
208- HAL_SPI_Transmit (handle , bufp , len , 1000 );
207+ HAL_SPI_Transmit (handle , ( uint8_t * ) bufp , len , 1000 );
209208 HAL_GPIO_WritePin (CS_up_GPIO_Port , CS_up_Pin , GPIO_PIN_SET );
210209#elif defined(SPC584B_DIS )
211- i2c_lld_write (handle , LPS22HB_I2C_ADD_H & 0xFE , reg , bufp , len );
210+ i2c_lld_write (handle , LPS22HB_I2C_ADD_H & 0xFE , reg , ( uint8_t * ) bufp , len );
212211#endif
213212 return 0 ;
214213}
@@ -284,7 +283,7 @@ static void platform_init(void)
284283 TIM3 -> CCR2 = PWM_3V3 ;
285284 HAL_TIM_PWM_Start (& htim3 , TIM_CHANNEL_1 );
286285 HAL_TIM_PWM_Start (& htim3 , TIM_CHANNEL_2 );
287- HAL_Delay (1000 );
286+ platform_delay (1000 );
288287#endif
289288}
290289
0 commit comments