Just want to provide some feedback.
I understand that TI is leaning into programming and configuration through driverlib, but IMO, the code style is inconsistent and often hard to read.
Here are a few examples found in ethernet.h/c in F2838x driverlib_cm:
- White space
- There is a anywhere between 1-4 lines between code entities (such as block documentation, struct/enum definitions, etc)
- The code (mostly) uses spaces for indentation, so it is independent of tab-width definitions (good), but the indentation is inconsistent even in the same entity (such as a struct definition).
- Spacing before or after the asterik to declare pointer.
- Bracket placement
- typedef enum/struct definitions sometimes have a new line before the opening bracket and sometimes not, almost at random. Sometimes there are two line breaks
- Variable / function Naming
- Mostly its <device>_xxx, but the xxx part is the wild west. Sometimes words are camel cased, sometimes they are separated by underscore
Here is an unedited snippet that demonstrates a few examples. For anyone adversely affected by this, I apologize.
//*****************************************************************************
//
//! The structure for Rx Queue Configuration
//! Used by the driver in Rx Queue Configuration
//
//*****************************************************************************
typedef struct {
uint32_t reserved_0:4;
uint32_t PTPQ:1;
uint32_t reserved_1:7;
uint32_t UPQ:1;
uint32_t reserved_2:3;
uint32_t MCBCQ:1;
uint32_t reserved_3:3;
uint32_t MCBCQEN:1;
uint32_t reserved_4:1;
uint32_t TPQC:1;
uint32_t reserved_5:9;
} Ethernet_RxQControl;
typedef enum
{
ETHERNET_CHANNEL_0 ,
ETHERNET_CHANNEL_1
} Ethernet_ChannelNum;