Skip to content

Custom sensor drivers using the STM32 HAL libraries, written in STM32CubeIDE

Notifications You must be signed in to change notification settings

ubcaerodesign/sensor-drivers-2024-2025

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sensor-drivers-2024-2025

BNO055 EXAMPLE

/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <math.h>
#include "BNO055.h"

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
I2C_HandleTypeDef hi2c1;

UART_HandleTypeDef huart1;

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_I2C1_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_I2C1_Init();
  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */

  BNO055_assignI2C(&hi2c1);
  BNO055_setup();

  BNO055_calibrationRoutine();

  BNO055_vector_t quaternion, euler, refQuaternion, refGravity;
  double heading;

  BNO055_getReferences(&refQuaternion, &refGravity);

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
	  BNO055_getVectorQuaternion(&quaternion);
	  BNO055_getVectorEuler_fromVectorQuaternion(&quaternion,&euler);
	  printf("roll = %f, pitch = %f, yaw = %f\r\n", euler.x,euler.y,euler.z);
	  HAL_Delay(500);

	  BNO055_getMagneticHeading(&refQuaternion, &refGravity, &quaternion, &heading);
	  printf("heading = %f\r\n", heading);
	  HAL_Delay(500);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

About

Custom sensor drivers using the STM32 HAL libraries, written in STM32CubeIDE

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages