From e41764fceeabb1cdb6a7a299e00f2166a6f6ac32 Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Thu, 18 Jun 2020 13:26:56 +0100 Subject: moved stm32 into directory added noddy pcb --- stm32/app/i2c.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 stm32/app/i2c.c (limited to 'stm32/app/i2c.c') diff --git a/stm32/app/i2c.c b/stm32/app/i2c.c new file mode 100644 index 0000000..8c5630e --- /dev/null +++ b/stm32/app/i2c.c @@ -0,0 +1,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); +} -- cgit v1.2.3