summaryrefslogtreecommitdiffstats
path: root/app/i2c.c
blob: 8c5630e158000790b3846a6631a481a5baec70e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "project.h"

static int mutex = 0;

int
i2c_lock (void)
{
  if (__sync_add_and_fetch (&mutex, 1) != 1) {
    __sync_sub_and_fetch (&mutex, 1);
    return -1;
  }

  return 0;
}


void
i2c_unlock (void)
{
  __sync_sub_and_fetch (&mutex, 1);
}