DuinOS: Small and Simple OS based on FreeRTOS

Another tip; you only require a mutex/semaphore if the resource is being shared with more than one tasks.

For example; if you are using i2c for one device a mutex isn't required per say.

static void vI2CTask(void *pvParameters) {

   /* The parameters are not used. */
   ( void ) pvParameters;

   portENTER_CRITICAL();
   {
        // init i2c
   }
   portEXIT_CRITICAL();

  /* Cycle for ever, delaying then checking all the other tasks are still
     operating without error. */
   for( ;; ) {
      // read i2c device
      // process data
      // sleep for 10 seconds
   }
}

The "critical" section halts background tasks and allows the code to execute atomically alleviating potential synch issues. Additional information is available in the FreeRTOS on-line documentation. If you have done C# threaded programming its similar to a "lock" call.