Skip to content

Commit

Permalink
fix bad merge
Browse files Browse the repository at this point in the history
  • Loading branch information
vegano1 committed Jan 3, 2025
1 parent 91a2e8b commit 9ef6d69
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 352 deletions.
2 changes: 0 additions & 2 deletions stm32-modules/flex-stacker/firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ set(${TARGET_MODULE_NAME}_FW_LINTABLE_SRCS
${TOF_SENSOR_DIR}/freertos_tof_driver_task.cpp
${TOF_SENSOR_DIR}/freertos_tof_sensor_task.cpp
${TOF_SENSOR_DIR}/tof_driver_policy.cpp
${TOF_SENSOR_DIR}/i2c_comms.cpp
)

# Add source files that should NOT be checked by clang-tidy here
Expand All @@ -51,7 +50,6 @@ set(${TARGET_MODULE_NAME}_FW_NONLINTABLE_SRCS
${MOTOR_CONTROL_DIR}/motor_hardware.c
${MOTOR_CONTROL_DIR}/motor_spi_hardware.c
${TOF_SENSOR_DIR}/tof_sensor_hardware.c
${TOF_SENSOR_DIR}/i2c_hardware.c
)

add_executable(${TARGET_MODULE_NAME}
Expand Down
31 changes: 0 additions & 31 deletions stm32-modules/flex-stacker/firmware/tof_sensor/i2c_comms.cpp

This file was deleted.

194 changes: 0 additions & 194 deletions stm32-modules/flex-stacker/firmware/tof_sensor/i2c_hardware.c

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "firmware/tof_driver_policy.hpp"
#include "firmware/tof_sensor_hardware.h"
#include "firmware/hardware_iface.hpp"
#include "systemwide.h"

using namespace tof::hardware;
Expand All @@ -11,11 +12,13 @@ auto TOFDriverPolicy::enable_tof_sensor(TOFSensorID sensor_id, bool enable) -> v
}

auto TOFDriverPolicy::i2c_write(uint16_t dev_addr, uint16_t reg, uint8_t* data,
uint16_t size) -> RxTxReturn {
return i2c_comms->i2c_write(dev_addr, reg, data, size);
uint16_t size) -> i2c::hardware::RxTxReturn {
return i2c::hardware::RxTxReturn();
//return i2c_comms->i2c_write(dev_addr, reg, data, size);
}

auto TOFDriverPolicy::i2c_read(uint16_t dev_addr, uint16_t reg, uint16_t size)
-> RxTxReturn {
return i2c_comms->i2c_read(dev_addr, reg, size);
-> i2c::hardware::RxTxReturn {
return i2c::hardware::RxTxReturn();
//return i2c_comms->i2c_read(dev_addr, reg, size);
}
104 changes: 0 additions & 104 deletions stm32-modules/flex-stacker/firmware/tof_sensor/tof_sensor_hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,9 @@
#include "stm32g4xx_hal_gpio.h"

#include "firmware/tof_sensor_hardware.h"
#include "firmware/i2c_hardware.h"
#include "systemwide.h"
#include "main.h"

static I2C_HandleTypeDef hi2c2;
static I2C_HandleTypeDef hi2c3;

HAL_I2C_HANDLE MX_I2C2_Init()
{
hi2c2.State = HAL_I2C_STATE_RESET;
hi2c2.Instance = I2C2;
hi2c2.Init.Timing = 0x10C0ECFF;
hi2c2.Init.OwnAddress1 = 0;
hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c2.Init.OwnAddress2 = 0;
hi2c2.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c2) != HAL_OK)
{
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c2, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c2, 0) != HAL_OK)
{
Error_Handler();
}

/** I2C Fast mode Plus enable */
__HAL_SYSCFG_FASTMODEPLUS_ENABLE(I2C_FASTMODEPLUS_I2C2);

return &hi2c2;
}

HAL_I2C_HANDLE MX_I2C3_Init() {
hi2c3.Instance = I2C3;
hi2c3.Init.Timing = 0x10C0ECFF;
hi2c3.Init.OwnAddress1 = 0;
hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c3.Init.OwnAddress2 = 0;
hi2c3.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c3) != HAL_OK) {
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) !=
HAL_OK) {
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK) {
Error_Handler();
}

/** I2C Fast mode Plus enable */
__HAL_SYSCFG_FASTMODEPLUS_ENABLE(I2C_FASTMODEPLUS_I2C3);

return &hi2c3;
}

/**
* @brief enable the eeprom write protect pin.
Expand Down Expand Up @@ -129,38 +60,3 @@ void enable_tof_sensor_write(TOFSensorID sensor_id, bool enable) {
HAL_GPIO_WritePin(TOF_EN_Z_PORT, TOF_EN_Z_PIN, enable ? GPIO_PIN_SET : GPIO_PIN_RESET);
}
}

void i2c_hardware_init(I2CHandlerStruct* i2c_handles) {
HAL_I2C_HANDLE i2c2 = MX_I2C2_Init();
HAL_I2C_HANDLE i2c3 = MX_I2C3_Init();
i2c_handles->i2c2 = i2c2;
i2c_handles->i2c3 = i2c3;
eeprom_write_protect_init();
tof_write_protect_init();

// write protect the eeprom
enable_eeprom_write(false);
// Disable tof sensors
enable_tof_sensor_write(TOF_X, false);
enable_tof_sensor_write(TOF_Z, false);
}

void I2C2_EV_IRQHandler(void)
{
HAL_I2C_EV_IRQHandler(&hi2c2);
}

void I2C2_ER_IRQHandler(void)
{
HAL_I2C_ER_IRQHandler(&hi2c2);
}

void I2C3_EV_IRQHandler(void)
{
HAL_I2C_EV_IRQHandler(&hi2c3);
}

void I2C3_ER_IRQHandler(void)
{
HAL_I2C_ER_IRQHandler(&hi2c3);
}
Loading

0 comments on commit 9ef6d69

Please sign in to comment.