diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2020-12-09 23:15:14 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2020-12-09 23:15:14 -0700 |
commit | 5f1763ec87503527583cb1a7c6deb73604db0dfc (patch) | |
tree | 0892ddf94b614db2d879f7bc993961af5ac25bb2 /include | |
parent | a5923b21e48fcfe660c1e7d586fe0c6a5b79e421 (diff) | |
download | stm32l4-5f1763ec87503527583cb1a7c6deb73604db0dfc.tar.gz stm32l4-5f1763ec87503527583cb1a7c6deb73604db0dfc.tar.bz2 stm32l4-5f1763ec87503527583cb1a7c6deb73604db0dfc.zip |
Can read from the A/C remote control!test_ir
Diffstat (limited to 'include')
-rw-r--r-- | include/drv/ir/control.h | 14 | ||||
-rw-r--r-- | include/drv/ir/ir.h | 34 | ||||
-rw-r--r-- | include/drv/ir/lg_remote_codes.h | 17 | ||||
-rw-r--r-- | include/shared/avl_tree.h | 3 |
4 files changed, 66 insertions, 2 deletions
diff --git a/include/drv/ir/control.h b/include/drv/ir/control.h new file mode 100644 index 0000000..11e3604 --- /dev/null +++ b/include/drv/ir/control.h @@ -0,0 +1,14 @@ +#ifndef _DRV_IR_CONTROL_H_ +#define _DRV_IR_CONTROL_H_ + +#include "kern/common.h" + +#define add_ir_code_callback(code, fn, closure) \ + add_ir_code_callback_(code, (void (*)(uint32_t, void*))(fn), closure) + +void add_ir_code_callback_( + uint32_t code, void (*fn)(uint32_t code, void* closure), void* closure); + +void enable_ir_control(); + +#endif /* _DRV_IR_CONTROL_H_ */ diff --git a/include/drv/ir/ir.h b/include/drv/ir/ir.h new file mode 100644 index 0000000..0a747e8 --- /dev/null +++ b/include/drv/ir/ir.h @@ -0,0 +1,34 @@ +#ifndef _DRV_IR_IR_H_ +#define _DRV_IR_IR_H_ + +#include "kern/common.h" + +typedef struct { + uint16_t ts[64]; /* Timestamps. Microseconds. */ + uint8_t n; +} ir_code_t; + +typedef struct { + uint32_t c; +} decoded_ir; + +/* + * Attempt to decode the provided ir code. + * + * The generic ir is: + * + * The frame starts out as really-long, half(ish) as long, short. If + * this basic frame header does not exist decoding cannot continue. + * + * A short code followed by a short code = 0 + * A long code followed by a short code = 1 + * + * returns non-zero on successful decode. + */ +int ir_generic_decode(const ir_code_t* code, uint32_t* out); + +void add_ir_callback(void(*callback)(const ir_code_t*)); + +void ir_begin_listen(); + +#endif /* _DRV_IR_IR_H_ */ diff --git a/include/drv/ir/lg_remote_codes.h b/include/drv/ir/lg_remote_codes.h new file mode 100644 index 0000000..77cbb45 --- /dev/null +++ b/include/drv/ir/lg_remote_codes.h @@ -0,0 +1,17 @@ +#ifndef _DRV_IR_LG_REMOTE_CODES_H_ +#define _DRV_IR_LG_REMOTE_CODES_H_ + +#define RC_HIGH 0x08e76800 +#define RC_TEMP_UP 0x08e7a800 +#define RC_DRY 0x08e72800 +#define RC_LOW 0x08e77000 +#define RC_TEMP_DOWN 0x08e7b000 +#define RC_COOL 0x08e73000 +#define RC_CONTINUOUS 0x08e75000 +#define RC_FAN 0x08e71000 +#define RC_SLEEP 0x08e76000 +#define RC_UNITS 0x08e72000 +#define RC_TIMER 0x08e78000 +#define RC_POWER 0x08e70080 + +#endif /* _DRV_IR_LG_REMOTE_CODES_H_ */ diff --git a/include/shared/avl_tree.h b/include/shared/avl_tree.h index 98151f2..2b174d3 100644 --- a/include/shared/avl_tree.h +++ b/include/shared/avl_tree.h @@ -7,6 +7,7 @@ #include <assert.h> #include <stdio.h> +#include "kern/common.h" #include "kern/mem.h" #include "shared/stdmacro.h" @@ -29,8 +30,6 @@ #define null_dtor(a) -typedef unsigned int bool; - #define AVL_TREE_DECL(T) \ typedef struct CONCAT(AVL_TREE_NODE_, T) { \ T value; \ |