Change BNO055_I2C_ADDR in header file to match your i2c address.
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#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;
SPI_HandleTypeDef hspi2;
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);
static void MX_SPI2_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();
MX_SPI2_Init();
MX_FATFS_Init();
/* USER CODE BEGIN 2 */
BNO055_assignI2C(&hi2c1); //Change depending on your configs
BNO055_setup();
/* Uncomment and use if you would like to calibrate or re-calibrate BNO. Otherwise, don't need this.
* If want to save in eeprom: USE_EEPROM
* If want to save in sd card: USE_SD
*/
//BNO055_calibrationRoutine(USE_EEPROM);
/* Uncomment and use if you have ran BNO055_calibrationRoutine() once/before.
* Keep using this once there are calibration offsets stored.
* If want to load from eeprom: USE_EEPROM
* If want to load from sd card: USE_SD
*/
//BNO055_loadCalibrationData(USE_EEPROM);
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 */
}