An ELEC3300 project.
- Indent 2 spaces
- End file with newline
// Use single line comments even if
// the comment spans multiple lines
/* Don't use block style comments */
Use 80 backslashes above and below to create a title comment:
////////////////////////////////////////////////////////////////////////////////
// Title comment example
////////////////////////////////////////////////////////////////////////////////
Use integer typedefs instead of primitive types:
// Include stdint header if needed
#include <stdint.h>
int8_t x; // not char x
int16_t x; // not short x
int32_t x; // not int x
uint8_t x4; // not unsigned char x
uint16_t x5; // not unsigned short x
uint32_t x6; // not unsigned int x
Use lower camel case:
static int32_t staticVariableExample = 0;
void staticFunctionExample(void) {}
Use uppercase with underscores:
extern int32_t EXPORTED_VARIABLE_EXAMPLE;
void EXPORTED_FUNCTION_EXAMPLE(void) {}
Use uppercase with underscores, with double underscore prefix:
#ifndef __INCLUDE_GUARD_EXAMPLE_H
#define __INCLUDE_GUARD_EXAMPLE_H
- Include project dependencies
- Include library dependencies
- Define static variables
- Define static functions
- Define exported variables
- Define exported functions
#include "example1.h"
#include "example2.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_tim.h"
////////////////////////////////////////////////////////////////////////////////
// Static
////////////////////////////////////////////////////////////////////////////////
static int32_t staticVariableExample = 0;
void staticFunctionExample(void) {}
////////////////////////////////////////////////////////////////////////////////
// Exported
////////////////////////////////////////////////////////////////////////////////
int32_t EXPORTED_VARIABLE_EXAMPLE = staticVariableExample;
void EXPORTED_FUNCTION_EXAMPLE(void) {}