Skip to content

Commit

Permalink
Drivers: move static asserts to headers in bq27220
Browse files Browse the repository at this point in the history
  • Loading branch information
skotopes committed Oct 6, 2024
1 parent 501ac15 commit d4aebc9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 0 additions & 8 deletions lib/drivers/bq27220.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
#include "bq27220_reg.h"
#include "bq27220_data_memory.h"

_Static_assert(sizeof(Bq27220ControlStatus) == 2, "Incorrect Bq27220ControlStatus structure size");
_Static_assert(sizeof(Bq27220BatteryStatus) == 2, "Incorrect Bq27220BatteryStatus structure size");
_Static_assert(
sizeof(Bq27220OperationStatus) == 2,
"Incorrect Bq27220OperationStatus structure size");

_Static_assert(sizeof(BQ27220DMGaugingConfig) == 2, "Incorrect structure size");

#include <furi.h>
#include <stdbool.h>

Expand Down
8 changes: 8 additions & 0 deletions lib/drivers/bq27220.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ typedef struct {
uint8_t RSVD1; /**< Reserved */
} Bq27220ControlStatus;

_Static_assert(sizeof(Bq27220ControlStatus) == 2, "Incorrect Bq27220ControlStatus structure size");

typedef struct {
// Low byte, Low bit first
bool DSG : 1; /**< The device is in DISCHARGE */
Expand All @@ -67,6 +69,8 @@ typedef struct {
bool FD : 1; /**< Full-discharge is detected */
} Bq27220BatteryStatus;

_Static_assert(sizeof(Bq27220BatteryStatus) == 2, "Incorrect Bq27220BatteryStatus structure size");

typedef enum {
Bq27220OperationStatusSecSealed = 0b11,
Bq27220OperationStatusSecUnsealed = 0b10,
Expand All @@ -88,6 +92,10 @@ typedef struct {
uint8_t RSVD0 : 5; /**< Reserved */
} Bq27220OperationStatus;

_Static_assert(
sizeof(Bq27220OperationStatus) == 2,
"Incorrect Bq27220OperationStatus structure size");

typedef struct {
// Low byte, Low bit first
bool FD : 1; /**< Full Discharge */
Expand Down
2 changes: 2 additions & 0 deletions lib/drivers/bq27220_data_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ typedef struct {
const bool SME0 : 1;
const uint8_t RSVD3 : 3;
} BQ27220DMGaugingConfig;

_Static_assert(sizeof(BQ27220DMGaugingConfig) == 2, "Incorrect structure size");

0 comments on commit d4aebc9

Please sign in to comment.