~aleteoryx/muditaos

8c11d6a145b3feeea6343dfc995fa74b66e0d464 — Lukasz Skrzypczak 4 years ago 542065b
[BH-1084] Enable Power For Temp Sensor

Enabled power switching for temperature sensor
M module-bsp/board/rt1051/bellpx/board/BoardDefinitions.hpp => module-bsp/board/rt1051/bellpx/board/BoardDefinitions.hpp +3 -0
@@ 165,4 165,7 @@ enum class BoardDefinitions
    BELL_FUELGAUGE_I2C          = static_cast<int>(drivers::I2CInstances ::I2C4),
    BELL_FUELGAUGE_ALRT_GPIO    = static_cast<int>(drivers::GPIOInstances ::GPIO_1),
    BELL_FUELGAUGE_ALRT_PIN     = 3,

    BELL_TEMP_SENSOR_PWR_GPIO = static_cast<int>(drivers::GPIOInstances ::GPIO_1),
    BELL_TEMP_SENSOR_PWR_PIN  = 27,
};

M module-bsp/board/rt1051/bellpx/board/pin_mux.h => module-bsp/board/rt1051/bellpx/board/pin_mux.h +7 -0
@@ 188,6 188,13 @@ extern "C"

    void PINMUX_InitFuelGauge(void);

/**
 * Temperature sensor power supply enable
 */
#define PINUMX_TEMP_SENSOR_PWR_ENABLE IOMUXC_GPIO_AD_B1_11_GPIO1_IO27

    void PINMUX_InitTempSensorPwr(void);

#if defined(__cplusplus)
}
#endif

M module-bsp/board/rt1051/bellpx/bsp/bell_temp_sensor/bell_temp_sensor.cpp => module-bsp/board/rt1051/bellpx/bsp/bell_temp_sensor/bell_temp_sensor.cpp +16 -2
@@ 4,14 4,16 @@
#include "bsp/bell_temp_sensor/bell_temp_sensor.hpp"
#include "CT7117.hpp"
#include <board/BoardDefinitions.hpp>
#include "drivers/i2c/DriverI2C.hpp"
#include "drivers/gpio/DriverGPIO.hpp"
#include <drivers/i2c/DriverI2C.hpp>
#include <drivers/gpio/DriverGPIO.hpp>

#include "fsl_common.h"
#include <log/log.hpp>

namespace bsp::bell_temp_sensor
{
    using namespace drivers;

    bool isFahrenheit = false;

    namespace


@@ 42,6 44,9 @@ namespace bsp::bell_temp_sensor
            return i2c->Read(addr, reinterpret_cast<uint8_t *>(readout), 2);
        }

        auto gpio_pwren = DriverGPIO::Create(static_cast<GPIOInstances>(BoardDefinitions::BELL_TEMP_SENSOR_PWR_GPIO),
                                             DriverGPIOParams{});

    } // namespace

    std::int32_t init(bool Fahrenheit)


@@ 50,6 55,13 @@ namespace bsp::bell_temp_sensor

        LOG_DEBUG("Initializing Bell temperature sensor");

        gpio_pwren->ConfPin(
            DriverGPIOPinParams{.dir      = DriverGPIOPinParams::Direction::Output,
                                .irqMode  = DriverGPIOPinParams::InterruptMode::NoIntmode,
                                .defLogic = 1,
                                .pin      = static_cast<uint32_t>(BoardDefinitions::BELL_TEMP_SENSOR_PWR_PIN)});
        gpio_pwren->WritePin(static_cast<uint32_t>(BoardDefinitions::BELL_TEMP_SENSOR_PWR_PIN), 1); // enable power

        if (isInitiated) {
            return isPresent() ? kStatus_Success : kStatus_Fail;
        }


@@ 69,6 81,8 @@ namespace bsp::bell_temp_sensor
    void deinit()
    {
        standby();

        gpio_pwren->WritePin(static_cast<uint32_t>(BoardDefinitions::BELL_TEMP_SENSOR_PWR_PIN), 0); // disable power
    }

    bool standby()

M module-bsp/board/rt1051/bellpx/pin_mux.c => module-bsp/board/rt1051/bellpx/pin_mux.c +12 -0
@@ 308,6 308,7 @@ void PINMUX_InitBootPins(void)
    PINMUX_WDOG_B_Init();
    PINMUX_InitI2C4();
    PINMUX_InitFuelGauge();
    PINMUX_InitTempSensorPwr();
}

/*


@@ 1250,6 1251,17 @@ void PINMUX_InitFuelGauge(void)
                            PAD_CONFIG_PULL_KEEPER_ENABLED | PAD_CONFIG_SELECT_PULL | PAD_CONFIG_PULL_UP_100kOhm);
}

void PINMUX_InitTempSensorPwr(void)
{
    IOMUXC_SetPinMux(PINUMX_TEMP_SENSOR_PWR_ENABLE,
                     0U); /* Software Input On Field: Input Path is determined by functionality */

    IOMUXC_SetPinConfig(PINUMX_TEMP_SENSOR_PWR_ENABLE,

                        PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_DRIVER_DISABLED | PAD_CONFIG_SPEED_SLOW_50MHz |
                            PAD_CONFIG_PULL_KEEPER_ENABLED | PAD_CONFIG_SELECT_PULL | PAD_CONFIG_PULL_DOWN_100kOhm);
}

/***********************************************************************************************************************
 * EOF
 **********************************************************************************************************************/