diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/drv/ws2812B/ws2812b.h | 3 | ||||
-rw-r--r-- | include/kern/exti/exti_manager.h | 32 | ||||
-rw-r--r-- | include/shared/avl_tree.h.gch | bin | 0 -> 11451 bytes | |||
-rw-r--r-- | include/shared/math.h | 19 |
4 files changed, 51 insertions, 3 deletions
diff --git a/include/drv/ws2812B/ws2812b.h b/include/drv/ws2812B/ws2812b.h index 3189907..d7137a1 100644 --- a/include/drv/ws2812B/ws2812b.h +++ b/include/drv/ws2812B/ws2812b.h @@ -30,7 +30,4 @@ void ws2812b_write_rgb_arr_sync(ws2812b_t* drv, rgb_t* arr, size_t arr_len); void ws2812b_delete(ws2812b_t* drv); -/* Returns round(sin(2πn / 256) * 127.5 + 127.5). */ -uint8_t byte_sin(uint8_t n); - #endif /* WS2812B_H_ */ diff --git a/include/kern/exti/exti_manager.h b/include/kern/exti/exti_manager.h new file mode 100644 index 0000000..aa39b4f --- /dev/null +++ b/include/kern/exti/exti_manager.h @@ -0,0 +1,32 @@ +#ifndef _KERN_EXTI_EXTI_MANAGER_H_ +#define _KERN_EXTI_EXTI_MANAGER_H_ + +#include "kern/common.h" +#include "kern/gpio/gpio_manager.h" +#include "shared/linked_list.h" + +#define EXTI_ERROR_ALREADY_IN_USE 1 + +struct EXTI_HANDLE; + + +typedef struct { + void (*fn)(struct EXTI_HANDLE, void*); + void* closure; +} exti_callback_t; + +LINKED_LIST_DECL(exti_callback_t); +typedef struct EXTI_HANDLE { + uint8_t id; + linked_list_t(exti_callback_t)* callbacks; +} exti_handle_t; + +exti_handle_t* enable_exti_for_gpio(gpio_pin_t gpio_pin, int* ec); + +exti_handle_t* exti_add_callback(exti_handle_t*, exti_callback_t* callback); + +gpio_pin_t exti_gpio_pin(exti_handle_t* handle); + + + +#endif /* _KERN_EXTI_EXTI_MANAGER_H_ */ diff --git a/include/shared/avl_tree.h.gch b/include/shared/avl_tree.h.gch Binary files differnew file mode 100644 index 0000000..78fc043 --- /dev/null +++ b/include/shared/avl_tree.h.gch diff --git a/include/shared/math.h b/include/shared/math.h new file mode 100644 index 0000000..6aec0e7 --- /dev/null +++ b/include/shared/math.h @@ -0,0 +1,19 @@ +#ifndef _SHARED_MATH_H_ +#define _SHARED_MATH_H_ + +#include "kern/common.h" + +/* Returns round(sin(2πn / 256) * 127.5 + 127.5). */ +uint8_t byte_sin(uint8_t n); + +static inline uint8_t byte_scale(uint8_t n, uint8_t sc) { + return n * sc / 255; +} + +#define min(a, b) (a) < (b) ? (a) : (b) +#define max(a, b) (a) > (b) ? (a) : (b) + +/* returns (in / 256)^n * 256. */ +uint8_t amp(uint8_t in, uint8_t n); + +#endif /* _SHARED_MATH_H_ */ |