Very Simple Library for the STM32F3-Discovery.
Dependents: accelerometer_test neopixel_square accelerometer_test_minimal Colour_Video_Demo
Diff: inc/stm32f3_discovery_lsm303dlhc.h
- Revision:
- 3:ddbddb863053
- Parent:
- 0:c65854d98061
--- a/inc/stm32f3_discovery_lsm303dlhc.h Thu May 10 03:56:43 2018 +0000 +++ b/inc/stm32f3_discovery_lsm303dlhc.h Wed Apr 03 20:55:48 2019 +0000 @@ -58,101 +58,6 @@ * @brief LSM303DLHC Status */ -/* LSM303DLHC ACC struct */ -typedef struct -{ - uint8_t Power_Mode; /* Power-down/Normal Mode */ - uint8_t AccOutput_DataRate; /* OUT data rate */ - uint8_t Axes_Enable; /* Axes enable */ - uint8_t High_Resolution; /* High Resolution enabling/disabling */ - uint8_t BlockData_Update; /* Block Data Update */ - uint8_t Endianness; /* Endian Data selection */ - uint8_t AccFull_Scale; /* Full Scale selection */ -}LSM303DLHCAcc_InitTypeDef; - -/* LSM303DLHC Acc High Pass Filter struct */ -typedef struct -{ - uint8_t HighPassFilter_Mode_Selection; /* Internal filter mode */ - uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */ - uint8_t HighPassFilter_AOI1; /* HPF_enabling/disabling for AOI function on interrupt 1 */ - uint8_t HighPassFilter_AOI2; /* HPF_enabling/disabling for AOI function on interrupt 2 */ -}LSM303DLHCAcc_FilterConfigTypeDef; - -/* LSM303DLHC Mag struct */ -typedef struct -{ - uint8_t Temperature_Sensor; /* Temperature sensor enable/disable */ - uint8_t MagOutput_DataRate; /* OUT data rate */ - uint8_t Working_Mode; /* operating mode */ - uint8_t MagFull_Scale; /* Full Scale selection */ -}LSM303DLHCMag_InitTypeDef; -/** - * @} - */ - -/** @defgroup STM32F3_DISCOVERY_LSM303DLHC_Exported_Constants - * @{ - */ -#define LSM303DLHC_OK ((uint32_t) 0) -#define LSM303DLHC_FAIL ((uint32_t) 0) - -/* Uncomment the following line to use the default LSM303DLHC_TIMEOUT_UserCallback() - function implemented in stm32f3_discovery_lgd20.c file. - LSM303DLHC_TIMEOUT_UserCallback() function is called whenever a timeout condition - occure during communication (waiting transmit data register empty flag(TXE) - or waiting receive data register is not empty flag (RXNE)). */ - #define USE_DEFAULT_TIMEOUT_CALLBACK - -/* Maximum Timeout values for flags waiting loops. These timeouts are not based - on accurate values, they just guarantee that the application will not remain - stuck if the I2C communication is corrupted. - You may modify these timeout values depending on CPU frequency and application - conditions (interrupts routines ...). */ -#define LSM303DLHC_FLAG_TIMEOUT ((uint32_t)0x1000) -#define LSM303DLHC_LONG_TIMEOUT ((uint32_t)(10 * LSM303DLHC_FLAG_TIMEOUT)) -/** - * @brief LSM303DLHC I2C Interface pins - */ -#define LSM303DLHC_I2C I2C1 -#define LSM303DLHC_I2C_CLK RCC_APB1Periph_I2C1 - -#define LSM303DLHC_I2C_SCK_PIN GPIO_Pin_6 /* PB.06 */ -#define LSM303DLHC_I2C_SCK_GPIO_PORT GPIOB /* GPIOB */ -#define LSM303DLHC_I2C_SCK_GPIO_CLK RCC_AHBPeriph_GPIOB -#define LSM303DLHC_I2C_SCK_SOURCE GPIO_PinSource6 -#define LSM303DLHC_I2C_SCK_AF GPIO_AF_4 - -#define LSM303DLHC_I2C_SDA_PIN GPIO_Pin_7 /* PB.7 */ -#define LSM303DLHC_I2C_SDA_GPIO_PORT GPIOB /* GPIOB */ -#define LSM303DLHC_I2C_SDA_GPIO_CLK RCC_AHBPeriph_GPIOB -#define LSM303DLHC_I2C_SDA_SOURCE GPIO_PinSource7 -#define LSM303DLHC_I2C_SDA_AF GPIO_AF_4 - -#define LSM303DLHC_DRDY_PIN GPIO_Pin_2 /* PE.02 */ -#define LSM303DLHC_DRDY_GPIO_PORT GPIOE /* GPIOE */ -#define LSM303DLHC_DRDY_GPIO_CLK RCC_AHBPeriph_GPIOE -#define LSM303DLHC_DRDY_EXTI_LINE EXTI_Line2 -#define LSM303DLHC_DRDY_EXTI_PORT_SOURCE EXTI_PortSourceGPIOE -#define LSM303DLHC_DRDY_EXTI_PIN_SOURCE EXTI_PinSource2 -#define LSM303DLHC_DRDY_EXTI_IRQn EXTI2_TS_IRQn - -#define LSM303DLHC_I2C_INT1_PIN GPIO_Pin_4 /* PE.04 */ -#define LSM303DLHC_I2C_INT1_GPIO_PORT GPIOE /* GPIOE */ -#define LSM303DLHC_I2C_INT1_GPIO_CLK RCC_AHBPeriph_GPIOE -#define LSM303DLHC_I2C_INT1_EXTI_LINE EXTI_Line4 -#define LSM303DLHC_I2C_INT1_EXTI_PORT_SOURCE EXTI_PortSourceGPIOE -#define LSM303DLHC_I2C_INT1_EXTI_PIN_SOURCE EXTI_PinSource4 -#define LSM303DLHC_I2C_INT1_EXTI_IRQn EXTI4_IRQn - -#define LSM303DLHC_I2C_INT2_PIN GPIO_Pin_5 /* PE.05 */ -#define LSM303DLHC_I2C_INT2_GPIO_PORT GPIOE /* GPIOE */ -#define LSM303DLHC_I2C_INT2_GPIO_CLK RCC_AHBPeriph_GPIOE -#define LSM303DLHC_I2C_INT2_EXTI_LINE EXTI_Line5 -#define LSM303DLHC_I2C_INT2_EXTI_PORT_SOURCE EXTI_PortSourceGPIOE -#define LSM303DLHC_I2C_INT2_EXTI_PIN_SOURCE EXTI_PinSource5ss -#define LSM303DLHC_I2C_INT2_EXTI_IRQn EXTI9_5_IRQn - /******************************************************************************/ /*************************** START REGISTER MAPPING **************************/ /******************************************************************************/ @@ -515,38 +420,6 @@ /** @defgroup STM32F3_DISCOVERY_LSM303DLHC_Exported_Functions * @{ */ -/* Acc functions */ -void LSM303DLHC_AccInit(LSM303DLHCAcc_InitTypeDef *LSM303DLHC_InitStruct); -void LSM303DLHC_AccRebootCmd(void); -void LSM303DLHC_AccFilterConfig(LSM303DLHCAcc_FilterConfigTypeDef *LSM303DLHC_FilterStruct) ; -void LSM303DLHC_AccFilterCmd(uint8_t HighPassFilterState); -void LSM303DLHC_AccFilterClickCmd(uint8_t HighPassFilterClickState); -void LSM303DLHC_AccIT1Config(uint8_t LSM303DLHC_IT, FunctionalState NewState); -void LSM303DLHC_AccIT2Config(uint8_t LSM303DLHC_IT, FunctionalState NewState); -void LSM303DLHC_AccINT1InterruptConfig(uint8_t ITCombination, uint8_t ITAxes, FunctionalState NewState ); -void LSM303DLHC_AccINT2InterruptConfig(uint8_t ITCombination, uint8_t ITAxes, FunctionalState NewState ); -void LSM303DLHC_AccClickITConfig(uint8_t ITClick, FunctionalState NewState); -uint8_t LSM303DLHC_AccGetDataStatus(void); - -/* Mag functions */ -void LSM303DLHC_MagInit(LSM303DLHCMag_InitTypeDef *LSM303DLHC_InitStruct); -uint8_t LSM303DLHC_MagGetDataStatus(void); - -/* read write funtions */ -uint16_t LSM303DLHC_Write(uint8_t DeviceAddr, uint8_t RegAddr, uint8_t* pBuffer); -uint16_t LSM303DLHC_Read(uint8_t DeviceAddr, uint8_t RegAddr,uint8_t* pBuffer, uint16_t NumByteToRead); - -/* USER Callbacks: This is function for which prototype only is declared in - MEMS accelerometre driver and that should be implemented into user applicaiton. */ -/* LSM303DLHC_TIMEOUT_UserCallback() function is called whenever a timeout condition - occure during communication (waiting transmit data register empty flag(TXE) - or waiting receive data register is not empty flag (RXNE)). - You can use the default timeout callback implementation by uncommenting the - define USE_DEFAULT_TIMEOUT_CALLBACK in stm32f3_discovery_LSM303DLHC.h file. - Typically the user implementation of this callback should reset MEMS peripheral - and re-initialize communication or in worst case reset all the application. */ -uint32_t LSM303DLHC_TIMEOUT_UserCallback(void); - #ifdef __cplusplus } #endif