Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C Driver Implementation with RTOS STM32 HAL #32

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.1786407102" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.303076356" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32H733VGTX_FLASH.ld}" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.directories.1811723870" name="Library search path (-L)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.directories" valueType="libPaths"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.1306985313" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "src/third_party/rocketlib"]
path = src/third_party/rocketlib
url = https://github.com/waterloo-rocketry/rocketlib
[submodule "tests/mocks/fff"]
path = tests/mocks/fff
url = https://github.com/meekrosoft/fff.git
1 change: 1 addition & 0 deletions src/drivers/i2c/i2c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "i2c.h"
37 changes: 37 additions & 0 deletions src/drivers/i2c/i2c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef I2C_H
#define I2C_H

#include "common.h" // Common definitions
#include <stdint.h> // Standard integer types

// Supported I2C devices
typedef enum {
I2C_DEVICE_POLULU, // Polulu AltIMU-v6
I2C_DEVICE_MOVELLA, // Movella MTi-630 IMU
taisirhassan marked this conversation as resolved.
Show resolved Hide resolved
I2C_DEVICE_ST, // ST LSM6DSO32 IMU
I2C_DEVICE_COUNT // Number of devices
} i2c_device_t;

// Initialize an I2C device
// device: I2C device to initialize

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're commenting in this level of detail might as well use doxygen

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly had no idea on what level of detail I should've utilized but would doxygen be good atp if we're assuming the user isn't familiar with the design document? @celery6

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any code on its own should always contain documentation regardless of whether design doc exists or not.

Idc about doxygen or any other style tbh but sure lets make doxygen style our standard from now on

// timeout_ms: Operation timeout in milliseconds
// Returns: Status code indicating success or failure
w_status_t i2c_init(i2c_device_t device, uint32_t timeout_ms);
taisirhassan marked this conversation as resolved.
Show resolved Hide resolved

// Read data from a device register
// device: I2C device
// reg: Register address
// data: Buffer to store read data
// len: Number of bytes to read (max 255)
// Returns: Status code indicating success or failure
w_status_t i2c_read_reg(i2c_device_t device, uint8_t reg, uint8_t *data, uint8_t len);

// Write data to a device register
// device: I2C device
// reg: Register address
// data: Data to write
// len: Number of bytes to write
// Returns: Status code indicating success or failure
w_status_t i2c_write_reg(i2c_device_t device, uint8_t reg, const uint8_t *data, uint8_t len);
taisirhassan marked this conversation as resolved.
Show resolved Hide resolved

#endif // I2C_H
1 change: 1 addition & 0 deletions tests/mocks/fff
Submodule fff added at 5111c6
Loading