Skip to main content

Function and Variable naming standards

Writing styles

Non-FreeRTOS functions are named as snake_case ( void emodule_init(void) )

FreeRTOS functions are names as camelCase

FreeRTOS

Tasks

void vTaskUpdateMetrics(void *pvParameters);

Events

EventGroupHandle_t xGPIO_event_group;
int BTN_PUSH_BIT = BIT1; // bit is upper case
int BTN2_PUSH_BIT = BIT2; // bit is upper case
Queues

QueueHandle_t xGPIO_Q_handle; // Queue with item "GPIO"

Semaphore

SemaphoreHandle_t xSemaphoreSPIbus;


Variables

type type example
#defineĀ  upper case CONFIG_THIS_THAT
standard variables snake_case

int motor_state

bool my_bool_data

float voltage_1

structures

camelCase

struct Metric

struct SuperAnything

...



Declaration

int a;    // declaring a variable

// Get Wifi SSID (single line)
uint8_t* get_ssid(void){ 
    esp_wifi_sta_get_ap_info(&ap);
    ESP_LOGD(TAG, "Wifi ssid %s", ap.ssid);
    return ap.ssid;
}


/*
Get Wifi SSID (multiple line)
Returns the signal strenght of Wifi AP
*/ 
uint8_t* get_ssid(void){ 
    esp_wifi_sta_get_ap_info(&ap);
    ESP_LOGD(TAG, "Wifi ssid %s", ap.ssid);
    return ap.ssid;
}