Skip to content

Commit

Permalink
Update functions.h
Browse files Browse the repository at this point in the history
added some useful macros
  • Loading branch information
KennethSimpson authored Nov 17, 2023
1 parent 84ba550 commit 2d358e5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Inc/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@
#include "main.h"
#include "targets.h"

#define MIN(a,b) \
__extension__ ({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
#define MAX(a,b) \
__extension__ ({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })


#define ABS(x) \
__extension__ ({ __typeof__ (x) _x = (x); \
_x > 0 ? _x : -_x; })
#define SIGN(x) \
__extension__ ({ __typeof__ (x) _x = (x); \
(_x > 0) - (_x < 0); })


int getAbsDif(int number1, int number2);
void delayMicros(uint32_t micros);
void delayMillis(uint32_t millis);
Expand Down

0 comments on commit 2d358e5

Please sign in to comment.