Welcome to Orbital's OBC Firmware Onboarding Challenge! Please visit this Notion doc for the challenge instructions. Remember to follow our style guide which is written below.
Variable and function names should be descriptive enough to understand even without comments. Comments are needed to describe any complicated logic. You may use //
or /* */
for single line comments.
Function comments should exist in the .h file. For static functions, they should exist in the .c file. Function comments should follow the format shown below:
/**
* @brief Adds two numbers together
*
* @param num1 - The first number to add.
* @param num2 - The second number to add.
* @return Returns the sum of the two numbers.
*/
uint8_t addNumbers(uint8_t num1, uint8_t num2);
- File comments are not required
We use #pragma once
instead of include guards.
variableNames
in camelCasefunctionNames()
in camelCase#define MACRO_NAME
in CAPITAL_SNAKE_CASEfile_names
in snake_casetype_defs
in snake_case with _t suffix- Ex:
typedef struct { int a; int b; } struct_name_t
- Ex:
- Import statements should be grouped in the following order:
- Local imports (e.g.
#include "cc1120_driver.h
) - External library imports (e.g.
#include <os_semphr.h>
) - Standard library imports (e.g.
#include <stdint.h>
)
- Local imports (e.g.
Some of these rules don't apply in certain cases. Use your better judgement. To learn more about these rules, research NASA's Power of 10.
- Avoid complex flow constructs, such as goto and recursion.
- All loops must have fixed bounds. This prevents runaway code.
- Avoid heap memory allocation.
- Use an average of two runtime assertions per function.
- Restrict the scope of data to the smallest possible.
- Check the return value of all non-void functions, or cast to void to indicate the return value is useless.
- Limit pointer use to a single dereference, and do not use function pointers.
- Compile with all possible warnings active; all warnings should then be addressed before release of the software.
- Use the preprocessor sparingly
- Restrict functions to a single printed page