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:
@@ -45,8 +45,9 @@ void I2CBB1::init() {
|
||||
}
|
||||
|
||||
bool I2CBB1::probe(uint8_t address) {
|
||||
if (!lock())
|
||||
if (!lock()) {
|
||||
return false;
|
||||
}
|
||||
start();
|
||||
bool ack = send(address);
|
||||
stop();
|
||||
@@ -55,8 +56,9 @@ bool I2CBB1::probe(uint8_t address) {
|
||||
}
|
||||
|
||||
bool I2CBB1::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) {
|
||||
@@ -91,8 +93,9 @@ bool I2CBB1::Mem_Read(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pData,
|
||||
}
|
||||
|
||||
bool I2CBB1::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) {
|
||||
@@ -123,8 +126,9 @@ bool I2CBB1::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, const uint8_t *
|
||||
}
|
||||
|
||||
void I2CBB1::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
|
||||
if (!lock())
|
||||
if (!lock()) {
|
||||
return;
|
||||
}
|
||||
start();
|
||||
bool ack = send(DevAddress);
|
||||
if (!ack) {
|
||||
@@ -147,8 +151,9 @@ void I2CBB1::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
|
||||
}
|
||||
|
||||
void I2CBB1::Receive(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
|
||||
if (!lock())
|
||||
if (!lock()) {
|
||||
return;
|
||||
}
|
||||
start();
|
||||
bool ack = send(DevAddress | 1);
|
||||
if (!ack) {
|
||||
@@ -166,10 +171,12 @@ void I2CBB1::Receive(uint16_t DevAddress, uint8_t *pData, uint16_t Size) {
|
||||
}
|
||||
|
||||
void I2CBB1::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);
|
||||
@@ -251,10 +258,11 @@ uint8_t I2CBB1::read(bool ack) {
|
||||
}
|
||||
|
||||
SOFT_SDA1_HIGH();
|
||||
if (ack)
|
||||
if (ack) {
|
||||
write_bit(0);
|
||||
else
|
||||
} else {
|
||||
write_bit(1);
|
||||
}
|
||||
return B;
|
||||
}
|
||||
|
||||
@@ -266,10 +274,11 @@ uint8_t I2CBB1::read_bit() {
|
||||
SOFT_SCL1_HIGH();
|
||||
SOFT_I2C_DELAY();
|
||||
|
||||
if (SOFT_SDA1_READ())
|
||||
if (SOFT_SDA1_READ()) {
|
||||
b = 1;
|
||||
else
|
||||
} else {
|
||||
b = 0;
|
||||
}
|
||||
|
||||
SOFT_SCL1_LOW();
|
||||
return b;
|
||||
@@ -278,7 +287,8 @@ uint8_t I2CBB1::read_bit() {
|
||||
void I2CBB1::unlock() { xSemaphoreGive(I2CSemaphore); }
|
||||
|
||||
bool I2CBB1::lock() {
|
||||
if (I2CSemaphore == NULL) {}
|
||||
if (I2CSemaphore == NULL) {
|
||||
}
|
||||
bool a = xSemaphoreTake(I2CSemaphore, (TickType_t)100) == pdTRUE;
|
||||
return a;
|
||||
}
|
||||
@@ -309,16 +319,18 @@ bool I2CBB1::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 I2CBB1::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