|
SensorTile的传感器应该就是用SPI实现的,代码你可以参考一下
- uint8_t Sensor_IO_SPI_CS_Init_All(void)
- {
- GPIO_InitTypeDef GPIO_InitStruct;
-
- GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
-
- SENSORTILE_LSM6DSM_SPI_CS_GPIO_CLK_ENABLE();
- GPIO_InitStruct.Pin = SENSORTILE_LSM6DSM_SPI_CS_Pin;
- HAL_GPIO_Init(SENSORTILE_LSM6DSM_SPI_CS_Port, &GPIO_InitStruct);
- HAL_GPIO_WritePin(SENSORTILE_LSM6DSM_SPI_CS_Port, SENSORTILE_LSM6DSM_SPI_CS_Pin, GPIO_PIN_SET);
-
- SENSORTILE_LSM303AGR_X_SPI_CS_GPIO_CLK_ENABLE();
- GPIO_InitStruct.Pin = SENSORTILE_LSM303AGR_X_SPI_CS_Pin;
- HAL_GPIO_Init(SENSORTILE_LSM303AGR_X_SPI_CS_Port, &GPIO_InitStruct);
- HAL_GPIO_WritePin(SENSORTILE_LSM303AGR_X_SPI_CS_Port, SENSORTILE_LSM303AGR_X_SPI_CS_Pin, GPIO_PIN_SET);
-
- SENSORTILE_LSM303AGR_M_SPI_CS_GPIO_CLK_ENABLE();
- GPIO_InitStruct.Pin = SENSORTILE_LSM303AGR_M_SPI_CS_Pin;
- HAL_GPIO_Init(SENSORTILE_LSM303AGR_M_SPI_CS_Port, &GPIO_InitStruct);
- HAL_GPIO_WritePin(SENSORTILE_LSM303AGR_M_SPI_CS_Port, SENSORTILE_LSM303AGR_M_SPI_CS_Pin, GPIO_PIN_SET);
-
- SENSORTILE_LPS22HB_SPI_CS_GPIO_CLK_ENABLE();
- GPIO_InitStruct.Pin = SENSORTILE_LPS22HB_SPI_CS_Pin;
- HAL_GPIO_Init(SENSORTILE_LPS22HB_SPI_CS_Port, &GPIO_InitStruct);
- HAL_GPIO_WritePin(SENSORTILE_LPS22HB_SPI_CS_Port, SENSORTILE_LPS22HB_SPI_CS_Pin, GPIO_PIN_SET);
- return COMPONENT_OK;
- }
复制代码
|
|