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 uint8_t tx_buffer[TX_BUF_DIM];
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 );
@@ -134,6 +134,8 @@ void lps25hb_read_data_polling(void)
134134 dev_ctx .write_reg = platform_write ;
135135 dev_ctx .read_reg = platform_read ;
136136 dev_ctx .handle = & SENSOR_BUS ;
137+ /* Initialize platform specific hardware */
138+ platform_init ();
137139 /* Check device ID */
138140 whoamI = 0 ;
139141 lps25hb_device_id_get (& dev_ctx , & whoamI );
@@ -189,20 +191,19 @@ void lps25hb_read_data_polling(void)
189191 * @param len number of consecutive register to write
190192 *
191193 */
192- static int32_t platform_write (void * handle , uint8_t reg ,
193- uint8_t * bufp ,
194+ static int32_t platform_write (void * handle , uint8_t reg , const uint8_t * bufp ,
194195 uint16_t len )
195196{
196197#if defined(NUCLEO_F411RE )
197198 HAL_I2C_Mem_Write (handle , LPS25HB_I2C_ADD_L , reg ,
198- I2C_MEMADD_SIZE_8BIT , bufp , len , 1000 );
199+ I2C_MEMADD_SIZE_8BIT , ( uint8_t * ) bufp , len , 1000 );
199200#elif defined(STEVAL_MKI109V3 )
200201 HAL_GPIO_WritePin (CS_up_GPIO_Port , CS_up_Pin , GPIO_PIN_RESET );
201202 HAL_SPI_Transmit (handle , & reg , 1 , 1000 );
202- HAL_SPI_Transmit (handle , bufp , len , 1000 );
203+ HAL_SPI_Transmit (handle , ( uint8_t * ) bufp , len , 1000 );
203204 HAL_GPIO_WritePin (CS_up_GPIO_Port , CS_up_Pin , GPIO_PIN_SET );
204205#elif defined(SPC584B_DIS )
205- i2c_lld_write (handle , LPS25HB_I2C_ADD_L & 0xFE , reg , bufp , len );
206+ i2c_lld_write (handle , LPS25HB_I2C_ADD_L & 0xFE , reg , ( uint8_t * ) bufp , len );
206207#endif
207208 return 0 ;
208209}
@@ -278,7 +279,7 @@ static void platform_init(void)
278279 TIM3 -> CCR2 = PWM_3V3 ;
279280 HAL_TIM_PWM_Start (& htim3 , TIM_CHANNEL_1 );
280281 HAL_TIM_PWM_Start (& htim3 , TIM_CHANNEL_2 );
281- HAL_Delay (1000 );
282+ platform_delay (1000 );
282283#endif
283284}
284285
0 commit comments