aboutsummaryrefslogtreecommitdiffstats
path: root/fw/types.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-10-27 20:25:28 -0400
committerSam Anthony <sam@samanthony.xyz>2025-10-27 20:25:28 -0400
commit3907711d2abca4277e1dbe01b98e0c7f3cc1304e (patch)
tree51bf124b217ac5f5f29314832a9937046ad04198 /fw/types.c
parent8b7701ed93ac19ac386c4de460e1c3424a260262 (diff)
downloadcan-gauge-interface-3907711d2abca4277e1dbe01b98e0c7f3cc1304e.zip
use builtin int types
Diffstat (limited to 'fw/types.c')
-rw-r--r--fw/types.c53
1 files changed, 0 insertions, 53 deletions
diff --git a/fw/types.c b/fw/types.c
deleted file mode 100644
index 1064379..0000000
--- a/fw/types.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <xc.h>
-
-#include <stdint.h>
-
-#include "types.h"
-
-U16
-addU16(U16 a, U16 b) {
- a.hi += b.hi;
- a.lo += b.lo;
- if (STATUSbits.C) {
- a.hi++;
- }
- return a;
-}
-
-U16
-addU16U8(U16 a, U8 b) {
- a.lo += b;
- if (STATUSbits.C) {
- a.hi++;
- }
- return a;
-}
-
-U16
-lshiftU16(U16 a, U8 b) {
- a.hi = (U8)(a.hi << b) | (a.lo >> (8u-b));
- a.lo <<= b;
- return a;
-}
-
-U16
-rshiftU16(U16 a, U8 b) {
- a.lo = (U8)((a.hi >> (8u-b)) << (8u-b)) | (U8)(a.lo >> b);
- a.hi >>= b;
- return a;
-}
-
-I8
-cmpU16(U16 a, U16 b) {
- if (a.hi > b.hi) {
- return 1;
- } else if (a.hi < b.hi) {
- return -1;
- } else if (a.lo > b.lo) {
- return 1;
- } else if (a.lo < b.lo) {
- return -1;
- } else {
- return 0;
- }
-}