Formatted code (#1007)

* Updated style

* Updated files

* fixed new line

* Updated spacing

* File fix WIP

* Updated to clang 13

* updated comment style

* Removed old comment code
This commit is contained in:
jLynx 2023-05-19 08:16:05 +12:00 committed by GitHub
parent 7aca7ce74d
commit 033c4e9a5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
599 changed files with 70746 additions and 66896 deletions

View file

@ -28,59 +28,60 @@
#include "hal.h"
struct I2CClockConfig {
float clock_source_f;
float bus_f;
float high_period_ns;
float clock_source_f;
float bus_f;
float high_period_ns;
static constexpr float period_ns(const float f) {
return 1e9 / f;
}
static constexpr float period_ns(const float f) {
return 1e9 / f;
}
constexpr uint32_t i2c_period_count() const {
return period_ns(bus_f) / period_ns(clock_source_f) + 0.5f;
}
constexpr uint32_t i2c_period_count() const {
return period_ns(bus_f) / period_ns(clock_source_f) + 0.5f;
}
constexpr uint32_t i2c_high_count() const {
return high_period_ns / period_ns(clock_source_f) + 0.5f;
}
constexpr uint32_t i2c_high_count() const {
return high_period_ns / period_ns(clock_source_f) + 0.5f;
}
constexpr uint32_t i2c_low_count() const {
return i2c_period_count() - i2c_high_count();
}
constexpr uint32_t i2c_low_count() const {
return i2c_period_count() - i2c_high_count();
}
};
class I2C {
public:
using address_t = uint8_t;
public:
using address_t = uint8_t;
constexpr I2C(I2CDriver* const driver) :
_driver(driver) {
}
constexpr I2C(I2CDriver* const driver)
: _driver(driver) {
}
void start(const I2CConfig& config);
void stop();
void start(const I2CConfig& config);
void stop();
bool receive(
const address_t slave_address,
uint8_t* const data, const size_t count,
const systime_t timeout = TIME_INFINITE
);
bool receive(
const address_t slave_address,
uint8_t* const data,
const size_t count,
const systime_t timeout = TIME_INFINITE);
bool transmit(
const address_t slave_address,
const uint8_t* const data, const size_t count,
const systime_t timeout = TIME_INFINITE
);
bool transmit(
const address_t slave_address,
const uint8_t* const data,
const size_t count,
const systime_t timeout = TIME_INFINITE);
private:
I2CDriver* const _driver;
private:
I2CDriver* const _driver;
bool transfer(
const address_t slave_address,
const uint8_t* const data_tx, const size_t count_tx,
uint8_t* const data_rx, const size_t count_rx,
const systime_t timeout
);
bool transfer(
const address_t slave_address,
const uint8_t* const data_tx,
const size_t count_tx,
uint8_t* const data_rx,
const size_t count_rx,
const systime_t timeout);
};
#endif/*__I2C_PP_H__*/
#endif /*__I2C_PP_H__*/