mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Cleanup make includes and formatting rules (#1860)
* Draft cleanup of the folder definition mess * Move old startup * Fixup! broken hacky includes * Update Makefile * Update Makefile * Update Makefile * Bulk format * Who knew, header guards are a wise idea * Squash some sizing warnings * Drop broken usb stack * Fix BLE headers to be sensible * Cleaning up proper c styling * We have newer clang, it does bracketing now * Run clang-format brackets * We can drop the old messy bracket-checker with newer clang format * WiP formatter * Align grids of scripts by right side Massively easier to read in nearly all cases * Excempt the table for compression from formatter
This commit is contained in:
@@ -44,8 +44,9 @@ void I2CBB2::init() {
|
||||
}
|
||||
|
||||
bool I2CBB2::probe(uint8_t address) {
|
||||
if (!lock())
|
||||
if (!lock()) {
|
||||
return false;
|
||||
}
|
||||
start();
|
||||
bool ack = send(address);
|
||||
stop();
|
||||
@@ -54,8 +55,9 @@ bool I2CBB2::probe(uint8_t address) {
|
||||
}
|
||||
|
||||
bool I2CBB2::Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData, uint16_t Size) {
|
||||
if (!lock())
|
||||
if (!lock()) {
|
||||
return false;
|
||||
}
|
||||
start();
|
||||
bool ack = send(DevAddress);
|
||||
if (!ack) {
|
||||
@@ -90,8 +92,9 @@ bool I2CBB2::Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData,
|
||||
}
|
||||
|
||||
bool I2CBB2::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, const uint8_t *pData, uint16_t Size) {
|
||||
if (!lock())
|
||||
if (!lock()) {
|
||||
return false;
|
||||
}
|
||||
start();
|
||||
bool ack = send(DevAddress);
|
||||
if (!ack) {
|
||||
@@ -122,8 +125,9 @@ bool I2CBB2::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, const uint8_t *
|
||||
}
|
||||
|
||||
void I2CBB2::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
|
||||
if (!lock())
|
||||
if (!lock()) {
|
||||
return;
|
||||
}
|
||||
start();
|
||||
bool ack = send(DevAddress);
|
||||
if (!ack) {
|
||||
@@ -146,8 +150,9 @@ void I2CBB2::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
|
||||
}
|
||||
|
||||
void I2CBB2::Receive(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
|
||||
if (!lock())
|
||||
if (!lock()) {
|
||||
return;
|
||||
}
|
||||
start();
|
||||
bool ack = send(DevAddress | 1);
|
||||
if (!ack) {
|
||||
@@ -165,10 +170,12 @@ void I2CBB2::Receive(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
|
||||
}
|
||||
|
||||
void I2CBB2::TransmitReceive(uint16_t DevAddress, uint8_t *pData_tx, uint16_t Size_tx, uint8_t *pData_rx, uint16_t Size_rx) {
|
||||
if (Size_tx == 0 && Size_rx == 0)
|
||||
if (Size_tx == 0 && Size_rx == 0) {
|
||||
return;
|
||||
if (lock() == false)
|
||||
}
|
||||
if (lock() == false) {
|
||||
return;
|
||||
}
|
||||
if (Size_tx) {
|
||||
start();
|
||||
bool ack = send(DevAddress);
|
||||
@@ -250,10 +257,11 @@ uint8_t I2CBB2::read(bool ack) {
|
||||
}
|
||||
|
||||
SOFT_SDA2_HIGH();
|
||||
if (ack)
|
||||
if (ack) {
|
||||
write_bit(0);
|
||||
else
|
||||
} else {
|
||||
write_bit(1);
|
||||
}
|
||||
return B;
|
||||
}
|
||||
|
||||
@@ -265,10 +273,11 @@ uint8_t I2CBB2::read_bit() {
|
||||
SOFT_SCL2_HIGH();
|
||||
SOFT_I2C_DELAY();
|
||||
|
||||
if (SOFT_SDA2_READ())
|
||||
if (SOFT_SDA2_READ()) {
|
||||
b = 1;
|
||||
else
|
||||
} else {
|
||||
b = 0;
|
||||
}
|
||||
|
||||
SOFT_SCL2_LOW();
|
||||
return b;
|
||||
@@ -277,7 +286,8 @@ uint8_t I2CBB2::read_bit() {
|
||||
void I2CBB2::unlock() { xSemaphoreGive(I2CSemaphore); }
|
||||
|
||||
bool I2CBB2::lock() {
|
||||
if (I2CSemaphore == NULL) {}
|
||||
if (I2CSemaphore == NULL) {
|
||||
}
|
||||
bool a = xSemaphoreTake(I2CSemaphore, (TickType_t)100) == pdTRUE;
|
||||
return a;
|
||||
}
|
||||
@@ -308,16 +318,18 @@ bool I2CBB2::writeRegistersBulk(const uint8_t address, const I2C_REG *registers,
|
||||
if (!I2C_RegisterWrite(address, registers[index].reg, registers[index].val)) {
|
||||
return false;
|
||||
}
|
||||
if (registers[index].pause_ms)
|
||||
if (registers[index].pause_ms) {
|
||||
delay_ms(registers[index].pause_ms);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool I2CBB2::wakePart(uint16_t DevAddress) {
|
||||
// wakepart is a special case where only the device address is sent
|
||||
if (!lock())
|
||||
if (!lock()) {
|
||||
return false;
|
||||
}
|
||||
start();
|
||||
bool ack = send(DevAddress);
|
||||
stop();
|
||||
|
||||
Reference in New Issue
Block a user