embedded.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef EMBEDDED_H
  2. #define EMBEDDED_H
  3. #include <inttypes.h>
  4. /* must provide
  5. - mutex_create_p
  6. - pthread_create_name
  7. - stack size
  8. - s16_t, s32_t, s64_t and u64_t
  9. - PLAYER_ID
  10. can overload (use #define)
  11. - exit
  12. - gettime_ms
  13. - BASE_CAP
  14. - EXT_BSS
  15. recommended to add platform specific include(s) here
  16. */
  17. #ifndef PTHREAD_STACK_MIN
  18. #define PTHREAD_STACK_MIN 256
  19. #endif
  20. #define STREAM_THREAD_STACK_SIZE 6 * 1024
  21. #define DECODE_THREAD_STACK_SIZE 16 * 1024
  22. #define OUTPUT_THREAD_STACK_SIZE 6 * 1024
  23. #define IR_THREAD_STACK_SIZE 6 * 1024
  24. // or can be as simple as #define PLAYER_ID 100
  25. #define PLAYER_ID custom_player_id;
  26. extern u8_t custom_player_id;
  27. #define BASE_CAP "Model=squeezeesp32,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=" VERSION
  28. #define EXT_BSS __attribute__((section(".ext_ram.bss")))
  29. typedef int16_t s16_t;
  30. typedef int32_t s32_t;
  31. typedef int64_t s64_t;
  32. typedef unsigned long long u64_t;
  33. // all exit() calls are made from main thread (or a function called in main thread)
  34. #define exit(code) { int ret = code; pthread_exit(&ret); }
  35. #define gettime_ms _gettime_ms_
  36. #define mutex_create_p(m) mutex_create(m)
  37. uint32_t _gettime_ms_(void);
  38. int pthread_create_name(pthread_t *thread, _CONST pthread_attr_t *attr,
  39. void *(*start_routine)( void * ), void *arg, char *name);
  40. // must provide of #define as empty macros
  41. void embedded_init(void);
  42. void register_external(void);
  43. void deregister_external(void);
  44. void decode_restore(int external);
  45. // optional, please chain if used
  46. bool (*slimp_handler)(u8_t *data, int len);
  47. void (*slimp_loop)(void);
  48. void (*server_notify)(in_addr_t ip, u16_t hport, u16_t cport);
  49. #endif // EMBEDDED_H