aboutsummaryrefslogtreecommitdiffstats
path: root/fw/types.h
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-11-01 20:32:55 -0400
committerSam Anthony <sam@samanthony.xyz>2025-11-01 20:32:55 -0400
commitb71dd676b5ebe3feec1eb2194e20453a3d01705d (patch)
tree10e19b6fa21d27c97376cdaf2bcfa03c05b2a75a /fw/types.h
parent96a85a2bb8e52cb8b15745bca617e3cc788d02ad (diff)
downloadcan-gauge-interface-b71dd676b5ebe3feec1eb2194e20453a3d01705d.zip
lookup output value in table
Diffstat (limited to 'fw/types.h')
-rw-r--r--fw/types.h41
1 files changed, 26 insertions, 15 deletions
diff --git a/fw/types.h b/fw/types.h
index 55a17f6..f772878 100644
--- a/fw/types.h
+++ b/fw/types.h
@@ -15,25 +15,36 @@ typedef enum {
typedef uint8_t U8;
typedef uint16_t U16;
typedef uint32_t U32;
-
typedef int8_t I8;
typedef int16_t I16;
typedef int32_t I32;
+typedef enum {
+ NUM_U8,
+ NUM_U16,
+ NUM_U32,
+ NUM_I8,
+ NUM_I16,
+ NUM_I32,
+} NumType;
+
// Number
typedef struct {
- enum {
- NUM_U8,
- NUM_U16,
- NUM_U32,
- NUM_I8,
- NUM_I16,
- NUM_I32,
- } type;
- U8 u8;
- U16 u16;
- U32 u32;
- I8 i8;
- I16 i16;
- I32 i32;
+ NumType type;
+ union {
+ U8 u8;
+ U16 u16;
+ U32 u32;
+ I8 i8;
+ I16 i16;
+ I32 i32;
+ };
} Number;
+
+Status u32ToNum(U32 x, NumType t, Number *n);
+
+// Compare two numbers.
+// -1 if a < b
+// 0 if a == b
+// 1 if a > b
+Status cmpNum(Number a, Number b, int *ord);