Skip to content

Commit

Permalink
Fix line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
calebchalmers committed Nov 23, 2024
1 parent 4858a8d commit f372757
Show file tree
Hide file tree
Showing 8 changed files with 456 additions and 456 deletions.
32 changes: 16 additions & 16 deletions ut-robomaster/src/board.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#pragma once

#include "tap/board/board.hpp"

namespace Board
{
using I2cSda = DigitalInPinPF0;
using I2cScl = DigitalInPinPF1;
using I2cMaster = I2cMaster2;

inline void initialize_i2c()
{
I2cMaster::connect<I2cSda::Sda, I2cScl::Scl>(I2cMaster::PullUps::Internal);
I2cMaster::initialize<SystemClock>();
}
} // namespace Board
#pragma once

#include "tap/board/board.hpp"

namespace Board
{
using I2cSda = DigitalInPinPF0;
using I2cScl = DigitalInPinPF1;
using I2cMaster = I2cMaster2;

inline void initialize_i2c()
{
I2cMaster::connect<I2cSda::Sda, I2cScl::Scl>(I2cMaster::PullUps::Internal);
I2cMaster::initialize<SystemClock>();
}
} // namespace Board
40 changes: 20 additions & 20 deletions ut-robomaster/src/drivers.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#pragma once

#include "tap/drivers.hpp"

#include "communication/cv_board.hpp"
#include "communication/rtt.hpp"

namespace src
{
class Drivers : public tap::Drivers
{
public:
Drivers() : tap::Drivers(), cvBoard(this), rtt() {}
communication::CVBoard cvBoard;
communication::RttStream rtt;

bool isKillSwitched() { return !remote.isConnected(); }
}; // class Drivers

} // namespace src
#pragma once

#include "tap/drivers.hpp"

#include "communication/cv_board.hpp"
#include "communication/rtt.hpp"

namespace src
{
class Drivers : public tap::Drivers
{
public:
Drivers() : tap::Drivers(), cvBoard(this), rtt() {}
communication::CVBoard cvBoard;
communication::RttStream rtt;

bool isKillSwitched() { return !remote.isConnected(); }
}; // class Drivers

} // namespace src
128 changes: 64 additions & 64 deletions ut-robomaster/src/drivers/as5600.hpp
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
#pragma once

#include "modm/architecture/interface/i2c_device.hpp"
#include "modm/processing/protothread/protothread.hpp"

#include "board.hpp"
#include "encoder.hpp"

namespace driver
{
using Board::I2cMaster;
class As5600 : public Encoder, public modm::I2cDevice<I2cMaster, 1>, public modm::pt::Protothread
{
public:
As5600() : modm::I2cDevice<I2cMaster, 1>(ADDRESS) {};

void update() { run(); }

bool run()
{
PT_BEGIN();

while (true)
{
buffer[0] = uint8_t(Register::RAWANGLE);
PT_WAIT_UNTIL(this->startWriteRead(buffer, 1, buffer, 2));
PT_WAIT_WHILE(this->isTransactionRunning());

if (this->wasTransactionSuccessful())
{
angle = (buffer[0] << 8) | buffer[1];
online = true;
}
}

PT_END();
}

float getAngle() override { return angle / 4096.0f; }

bool isOnline() override { return online; }

protected:
enum class Register : uint8_t
{
ZPOS = 0x01,
MPOS = 0x03,
CONF = 0x07,

RAWANGLE = 0x0C,
ANGLE = 0x0E,

STATUS = 0x0B,
AGC = 0x1A,
MAG = 0x1B,
};

private:
static const uint8_t ADDRESS = 0x36;
uint16_t angle = 0;
uint8_t buffer[2];
bool online = false;
};

#pragma once

#include "modm/architecture/interface/i2c_device.hpp"
#include "modm/processing/protothread/protothread.hpp"

#include "board.hpp"
#include "encoder.hpp"

namespace driver
{
using Board::I2cMaster;
class As5600 : public Encoder, public modm::I2cDevice<I2cMaster, 1>, public modm::pt::Protothread
{
public:
As5600() : modm::I2cDevice<I2cMaster, 1>(ADDRESS) {};

void update() { run(); }

bool run()
{
PT_BEGIN();

while (true)
{
buffer[0] = uint8_t(Register::RAWANGLE);
PT_WAIT_UNTIL(this->startWriteRead(buffer, 1, buffer, 2));
PT_WAIT_WHILE(this->isTransactionRunning());

if (this->wasTransactionSuccessful())
{
angle = (buffer[0] << 8) | buffer[1];
online = true;
}
}

PT_END();
}

float getAngle() override { return angle / 4096.0f; }

bool isOnline() override { return online; }

protected:
enum class Register : uint8_t
{
ZPOS = 0x01,
MPOS = 0x03,
CONF = 0x07,

RAWANGLE = 0x0C,
ANGLE = 0x0E,

STATUS = 0x0B,
AGC = 0x1A,
MAG = 0x1B,
};

private:
static const uint8_t ADDRESS = 0x36;
uint16_t angle = 0;
uint8_t buffer[2];
bool online = false;
};

}; // namespace driver
30 changes: 15 additions & 15 deletions ut-robomaster/src/drivers/encoder.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#pragma once

namespace driver
{
class Encoder
{
public:
virtual ~Encoder() {}

/// @brief Get current measured angle of the encoder
/// @return Angle (revs)
virtual float getAngle() = 0;

virtual bool isOnline() = 0;
};
#pragma once

namespace driver
{
class Encoder
{
public:
virtual ~Encoder() {}

/// @brief Get current measured angle of the encoder
/// @return Angle (revs)
virtual float getAngle() = 0;

virtual bool isOnline() = 0;
};
} // namespace driver
Loading

0 comments on commit f372757

Please sign in to comment.