mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-27 16:17:31 -04:00
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:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -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__*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue