Slave_Ports_Status.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #ifndef SLAVE_PORTS_STATUS_H
  2. #define SLAVE_PORTS_STATUS_H
  3. #include <Arduino.h>
  4. #ifndef voidfuncptr_t
  5. #define voidfuncptr_t voidfuncptr_t
  6. typedef void (*voidfuncptr_t)(void); // void function pointer typedef
  7. #endif
  8. #ifndef vfp_vpu32b_t
  9. #define vfp_vpu32b_t vfp_vpu32b_t
  10. typedef void (*vfp_vpu32b_t)(void*, uint32_t, bool);
  11. #endif
  12. typedef struct
  13. {
  14. uint8_t CNF1;
  15. } I2C_driver_T;
  16. static I2C_driver_T constexpr _NOT_USED_ = {0x00};
  17. static I2C_driver_T constexpr Adafruit_PWMServoDriver = {0x01};
  18. /*
  19. typedef struct {
  20. char I2C_driver_TA[32];
  21. } I2C_driver_TS ;
  22. */
  23. //typedef struct I2C_driver_TS I2C_driver_TT;
  24. //I2C_driver_TS I2C_driver_AA = { "_NOT_USED_" };
  25. //I2C_driver_AA[0] = "_NOT_USED_" ;
  26. //I2C_driver_AA[0x01] = "Adafruit_PWMServoDriver" ;
  27. struct Slave_Ports_Status_S {
  28. int Port_ID ; //global id for device //const char * const _Protocol;
  29. int _Slave_ID; //Device which orginated port //remote id - use FF for broadcast
  30. int PortTypes; //0xFF = 1111 1111 s
  31. /*
  32. {
  33. bit 1 - PWM port
  34. bit 2 - on I2C managed port
  35. bit 3 - expanded port with LocalPort address
  36. bit 4 - not allocated
  37. bit 2 - not allocated
  38. bit 5 - not allocated
  39. bit 6 - not allocated
  40. bit 7 - not allocated
  41. bit 8 - not allocated
  42. }
  43. */
  44. // byte has_Address;
  45. int Address ;
  46. // byte has_Local_Port;
  47. int LocalPort;
  48. int Exp_state; /*0xFF = 1111 1111
  49. 0x00 = 0000 0000 = OFF = 0V
  50. 0x01 = 0000 0001 = ON = PWM max
  51. {
  52. bit 1 - OFF = 0V
  53. bit 2 - ON = PWM max
  54. bit 3 - not allocated
  55. bit 4 - not allocated
  56. bit 2 - not allocated
  57. bit 5 - not allocated
  58. bit 6 - not allocated
  59. bit 7 - not allocated
  60. bit 8 - not allocated
  61. }*/
  62. int Exp_state_ttl; // 0x00 = odswiezyc
  63. int Broadcast_state; //0x00 - not broadcast; 0x01
  64. int I2C_port ; //0x01 - default port, 0x00 - not I2C connected
  65. int I2C_driver; //0x00 - not driver, 0x01 Adafruit_PWMServoDriver.h
  66. // int IS_Local; // Define if port is local or remote added
  67. } ;
  68. typedef struct Slave_Ports_Status_S Slave_Ports_Status_T;
  69. /*
  70. enum class Mode : uint8_t
  71. {
  72. Normal = 0x00,
  73. Sleep = 0x20,
  74. Loopback = 0x40,
  75. ListenOnly = 0x60,
  76. Config = 0x80
  77. };
  78. */
  79. //char I2C_driver_FT[32] ;
  80. static char I2C_driver_FT[24];
  81. class Slave_Ports_Status
  82. {
  83. private:
  84. //public:
  85. // static Slave_Ports_Status *first;
  86. //static Slave_Ports_Status *_data;
  87. public:
  88. Slave_Ports_Status_T *Slave_Ports_Status_A;
  89. int _count;
  90. // void push(Slave_Ports_Status_S const &item);
  91. //void push();
  92. //Slave_Ports_Status();
  93. // bool setMode();
  94. //voidfuncptr_t func; // address of coroutine function
  95. Slave_Ports_Status();
  96. /* inline int add(
  97. Slave_Ports_Status_LIST_T Slave_Ports_Status_LIST_A ,
  98. Slave_Ports_Status_T Slave_Ports_Status_A
  99. ) {
  100. };
  101. */
  102. void add_port(
  103. int Port_ID,
  104. int _Slave_ID,
  105. int PortTypes,
  106. int Address,
  107. int LocalPort,
  108. int Exp_state,
  109. int Exp_state_ttl,
  110. int Broadcast_state,
  111. int I2C_port,
  112. //int I2C_driver
  113. I2C_driver_T I2C_driver
  114. );
  115. bool add_empty();
  116. void print_ports();
  117. void list_ports();
  118. Slave_Ports_Status_S get_port(int Port_ID);
  119. // int get_count();
  120. bool I2C_driver_F(I2C_driver_T I2C_driver_A);
  121. char* I2C_driver_FS(int I2C_driver) ;
  122. // byte _Slave_Ports_Protocol_CAN_broadcast_F();
  123. ~Slave_Ports_Status();
  124. };
  125. /*
  126. class Slave_Ports_Status {
  127. private:
  128. int _front, _back, _count;
  129. T *_data;
  130. int _maxitems;
  131. public:
  132. Queue(int maxitems = 256) {
  133. _front = 0;
  134. _back = 0;
  135. _count = 0;
  136. _maxitems = maxitems;
  137. _data = new T[maxitems + 1];
  138. }
  139. ~Queue() {
  140. delete[] _data;
  141. }
  142. inline int count();
  143. inline int front();
  144. inline int back();
  145. // void push(const T &item);
  146. // T peek();
  147. // T pop();
  148. // void clear();
  149. // T pop_item(const T &item);
  150. }
  151. */
  152. #endif