Slave_Ports_Status.h 5.3 KB

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