NavHAL 0.1.0
NAVRobotec's architecture-agnostic HAL for embedded systems.
Loading...
Searching...
No Matches
main.c File Reference

Example: Read raw temperature from BMP180 over I2C and print via UART2. More...

#include "navhal.h"
Include dependency graph for main.c:

Macros

#define CORTEX_M4
#define BMP180_ADDR   0x77
#define BMP180_REG_CONTROL   0xF4
#define BMP180_REG_RESULT   0xF6
#define BMP180_CMD_TEMP   0x34
#define I2C_BUS   I2C1

Functions

int main (void)

Detailed Description

Example: Read raw temperature from BMP180 over I2C and print via UART2.

  • Initializes SysTick for delay functions.
  • Configures UART2 at 9600 baud for console output.
  • Configures I2C1 and GPIO pins for BMP180 communication (PB8=SCL, PB9=SDA).
  • Periodically starts a temperature measurement, reads the raw value, and prints it.
Note
Delay between measurement and reading follows BMP180 datasheet (~4.5 ms).

© 2025 NAVROBOTEC PVT. LTD. All rights reserved.

Macro Definition Documentation

◆ BMP180_ADDR

#define BMP180_ADDR   0x77

◆ BMP180_CMD_TEMP

#define BMP180_CMD_TEMP   0x34

◆ BMP180_REG_CONTROL

#define BMP180_REG_CONTROL   0xF4

◆ BMP180_REG_RESULT

#define BMP180_REG_RESULT   0xF6

◆ CORTEX_M4

#define CORTEX_M4

◆ I2C_BUS

#define I2C_BUS   I2C1

Function Documentation

◆ main()

int main ( void )

< Initialize SysTick for delays

< Initialize UART2 at 9600 baud

< Stop execution if I2C init fails

< Wait for conversion (~4.5 ms for temperature)

< Assumes uart2_write_int exists

< Wait 1 second before next measurement