ESR-2025/src/i2c.h

43 lines
1.0 KiB
C

/* File: i2c.h */
/**
* @file i2c.h
* @brief Interface for a minimal blocking I²C master driver (MSP430FR2355).
*
* Provides initialization, blocking write, and single-byte register read.
*
* @author
* Frederik Beimgraben
* Minh Dan Cam
* Luis Meyer
* @date 2025-07-02
*/
#ifndef I2C_H
#define I2C_H
#include <stdint.h>
#include <stdbool.h>
/**
* @brief Initialize the I2C module as master (SMCLK/20 → 50 kHz SCL).
*/
void i2c_init(void);
/**
* @brief Send a data packet to an I2C slave.
* @param slaveAddress 7-bit address of the target device.
* @param data Pointer to the data buffer to send.
* @param length Number of bytes to send.
*/
void i2c_write(uint8_t slaveAddress, char data[], uint8_t length);
/**
* @brief Read a single byte from a specific register of an I2C slave.
* @param slaveAddress 7-bit address of the target device.
* @param registerAddress Register address to read.
* @return The byte read from the device.
*/
char i2c_read_reg(uint8_t slaveAddress, uint8_t registerAddress);
#endif /* I2C_H */