~aleteoryx/muditaos

785111d9e1356015fe095388989108a3060fd9cd — Lukasz Skrzypczak 4 years ago 113aea8
[BH-653] Fixed style

Fixed style
M module-bsp/board/linux/bell_temp_sensor/bell_temp_sensor.cpp => module-bsp/board/linux/bell_temp_sensor/bell_temp_sensor.cpp +3 -5
@@ 6,8 6,8 @@

namespace bsp::bell_temp_sensor
{
    bool isFahrenheit = false;
    constexpr auto celsius_temperature_mock = 21.0;
    bool isFahrenheit                          = false;
    constexpr auto celsius_temperature_mock    = 21.0;
    constexpr auto fahrenheit_temperature_mock = (celsius_temperature_mock * 1.8) + 32;

    std::int32_t init(bool Fahrenheit)


@@ 18,9 18,7 @@ namespace bsp::bell_temp_sensor
    }

    void deinit()
    {
        
    }
    {}

    bool standby()
    {

M module-bsp/board/rt1051/bellpx/pin_mux.c => module-bsp/board/rt1051/bellpx/pin_mux.c +8 -6
@@ 1194,7 1194,7 @@ void PINMUX_WDOG_B_Init(void)

void PINMUX_InitI2C4(void)
{
    //D0B0 (11 0 1 0 000 10 110 00 0) ->
    // D0B0 (11 0 1 0 000 10 110 00 0) ->
    /*
        0 (SRE)     : 0
        1-2 (X)     : 00


@@ 1206,21 1206,23 @@ void PINMUX_InitI2C4(void)
        13 (PUE)    : 0
        14-15 (PUS) : 11
        16 (HYS)    : 0
    */ 
    */

    IOMUXC_SetPinMux(PINMUX_I2C4_SCL, 1U); /* Software Input On Field: Input Path is determined by functionality */

    IOMUXC_SetPinConfig(PINMUX_I2C4_SCL,

                        PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_DRIVER_STRENGTH_LVL_6 | PAD_CONFIG_SPEED_MEDIUM_2_100MHz |
                            PAD_CONFIG_PULL_KEEPER_ENABLED | PAD_CONFIG_SELECT_KEEPER | PAD_CONFIG_PULL_UP_22kOhm);
                        PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_DRIVER_STRENGTH_LVL_6 |
                            PAD_CONFIG_SPEED_MEDIUM_2_100MHz | PAD_CONFIG_PULL_KEEPER_ENABLED |
                            PAD_CONFIG_SELECT_KEEPER | PAD_CONFIG_PULL_UP_22kOhm);

    IOMUXC_SetPinMux(PINMUX_I2C4_SDA, 1U); /* Software Input On Field: Input Path is determined by functionality */

    IOMUXC_SetPinConfig(PINMUX_I2C4_SDA,

                        PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_DRIVER_STRENGTH_LVL_6 | PAD_CONFIG_SPEED_MEDIUM_2_100MHz |
                            PAD_CONFIG_PULL_KEEPER_ENABLED | PAD_CONFIG_SELECT_KEEPER | PAD_CONFIG_PULL_UP_22kOhm);
                        PAD_CONFIG_SLEW_RATE_SLOW | PAD_CONFIG_DRIVER_STRENGTH_LVL_6 |
                            PAD_CONFIG_SPEED_MEDIUM_2_100MHz | PAD_CONFIG_PULL_KEEPER_ENABLED |
                            PAD_CONFIG_SELECT_KEEPER | PAD_CONFIG_PULL_UP_22kOhm);
}

/***********************************************************************************************************************

M module-bsp/board/rt1051/bsp/bell_temp_sensor/CT7117.hpp => module-bsp/board/rt1051/bsp/bell_temp_sensor/CT7117.hpp +16 -16
@@ 8,32 8,32 @@
namespace bsp::bell_temp_sensor
{
    constexpr inline auto CT7117_DEVICE_ADDR = (0x90 >> 1);
    constexpr inline auto CT7117_DEVICE_ID = 0x59;
    constexpr inline auto CT7117_DEVICE_ID   = 0x59;

    enum class CT7117_Registers
    {
        Temp = 0x00,
        Config = 0x01,
        Low_Temp_Set = 0x02,
        Temp          = 0x00,
        Config        = 0x01,
        Low_Temp_Set  = 0x02,
        High_Temp_Set = 0x03,
        ID = 0x07
        ID            = 0x07
    };

    enum class CT7117_Config_Reg
    {
        OTS = (1<<15),
        F1 = (1 << 12),
        F0 = (1 << 11),
        OTS  = (1 << 15),
        F1   = (1 << 12),
        F0   = (1 << 11),
        ALTM = (1 << 9),
        SD = (1 << 8),
        EM = (1 << 7),
        SD   = (1 << 8),
        EM   = (1 << 7),
        RES1 = (1 << 6),
        RES0 = (1 << 5),
        TO = (1 << 4),
        PEC = (1 << 3),
        CR1 = (1 << 2),
        CR0 = (1 << 1),
        OS = (1 << 0)
    }; 
        TO   = (1 << 4),
        PEC  = (1 << 3),
        CR1  = (1 << 2),
        CR0  = (1 << 1),
        OS   = (1 << 0)
    };

} // namespace bsp::bell_temp_sensor

M module-bsp/board/rt1051/bsp/bell_temp_sensor/bell_temp_sensor.cpp => module-bsp/board/rt1051/bsp/bell_temp_sensor/bell_temp_sensor.cpp +15 -14
@@ 26,7 26,7 @@ namespace bsp::bell_temp_sensor
        bool writeSingleRegister(std::uint32_t address, std::uint16_t *to_send)
        {
            addr.subAddress          = address;
            const auto write_success = i2c->Write(addr, reinterpret_cast<uint8_t*>(to_send), 2);
            const auto write_success = i2c->Write(addr, reinterpret_cast<uint8_t *>(to_send), 2);

            return write_success == 1;
        }


@@ 34,13 34,13 @@ namespace bsp::bell_temp_sensor
        ssize_t readSingleRegister(std::uint32_t address, std::uint16_t *readout)
        {
            addr.subAddress = address;
            return i2c->Read(addr, reinterpret_cast<uint8_t*>(readout), 2);
            return i2c->Read(addr, reinterpret_cast<uint8_t *>(readout), 2);
        }

        ssize_t readMeasurementRegisters(std::uint16_t *readout)
        {
            addr.subAddress = static_cast<std::uint32_t>(CT7117_Registers::Temp);
            return i2c->Read(addr, reinterpret_cast<uint8_t*>(readout), 2);
            return i2c->Read(addr, reinterpret_cast<uint8_t *>(readout), 2);
        }

    } // namespace


@@ 51,9 51,8 @@ namespace bsp::bell_temp_sensor

        LOG_DEBUG("Initializing Bell temperature sensor");

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

        drivers::DriverI2CParams i2cParams;


@@ 92,16 91,18 @@ namespace bsp::bell_temp_sensor
    Temperature readout()
    {
        uint8_t reg[2] = {0, 0};
        float temp = 0.0;
        float temp     = 0.0;

        readSingleRegister(static_cast<uint32_t>(CT7117_Registers::Temp), reinterpret_cast<uint16_t*>(&reg[0]));
        uint16_t reg16 = (static_cast<uint16_t>(reg[0])<<8) | (static_cast<uint16_t>(reg[1]) & 0xFFE0);  //0.25 C resolution
        readSingleRegister(static_cast<uint32_t>(CT7117_Registers::Temp), reinterpret_cast<uint16_t *>(&reg[0]));
        uint16_t reg16 =
            (static_cast<uint16_t>(reg[0]) << 8) | (static_cast<uint16_t>(reg[1]) & 0xFFE0); // 0.25 C resolution

        uint16_t integer = (reg16 & 0x7FFF) >> 7;           //remove sign bit and shift to lower byte
        uint16_t fractional = ((reg16 >> 5) & 0x3) * 25;    //shift fractional part to correct decimal position and limit resolution to 0.25 C
        uint16_t integer = (reg16 & 0x7FFF) >> 7; // remove sign bit and shift to lower byte
        uint16_t fractional = ((reg16 >> 5) & 0x3) *
                              25; // shift fractional part to correct decimal position and limit resolution to 0.25 C

        temp = static_cast<float>(integer) + static_cast<float>(fractional) / 100.0;
        if (reg16 & 0x8000) //sign bit present
        if (reg16 & 0x8000) // sign bit present
            temp *= -1.0;
        if (isFahrenheit)
            temp = (temp * 1.8) + 32.00;


@@ 113,10 114,10 @@ namespace bsp::bell_temp_sensor
    {
        std::uint8_t readout;
        addr.subAddress = static_cast<uint8_t>(CT7117_Registers::ID);
        i2c->Read(addr, reinterpret_cast<uint8_t*>(&readout), 1);
        i2c->Read(addr, reinterpret_cast<uint8_t *>(&readout), 1);

        LOG_DEBUG("Bell temperature sensor %s", (readout == CT7117_DEVICE_ID) ? "present" : "error !");
        

        return readout == CT7117_DEVICE_ID;
    }