Slave_Ports_Status_S.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef Slave_Ports_Status_S_h
  2. #define Slave_Ports_Status_S_h
  3. #define I2C_driver_NOT_USED_ 0x00
  4. #define I2C_driver_Adafruit_PWMServoDriver 0x01
  5. #define PortTypes_PWM 0x01
  6. #define PortTypes_I2C 0x02
  7. #define PortTypes_EXP 0x03
  8. #define PortTypes_P2M_EXP_I2C 0x07
  9. #define Exp_state_OFF 0x01
  10. #define Exp_state_ON 0x02
  11. #define Exp_state_ttl_TO_REFRESH 0x01
  12. #define Broadcast_state_TO_REFRESH 0x01
  13. #define I2C_port_DEFAULT 0x01
  14. struct Slave_Ports_Status_S {
  15. int Port_ID ; //global id for device //const char * const _Protocol;
  16. int _Slave_ID; //Device which orginated port //remote id - use FF for broadcast
  17. int PortTypes; //0xFF = 1111 1111 s
  18. /*
  19. {
  20. bit 1 - PWM port
  21. bit 2 - on I2C managed port
  22. bit 3 - expanded port with LocalPort address
  23. bit 4 - not allocated
  24. bit 2 - not allocated
  25. bit 5 - not allocated
  26. bit 6 - not allocated
  27. bit 7 - not allocated
  28. bit 8 - not allocated
  29. }
  30. */
  31. // byte has_Address;
  32. int Address ;
  33. // byte has_Local_Port;
  34. int LocalPort;
  35. int Exp_state; /*0xFF = 1111 1111
  36. 0x00 = 0000 0001 = OFF = 0V
  37. 0x01 = 0000 0002 = ON = PWM max
  38. {
  39. bit 1 - OFF = 0V
  40. bit 2 - ON = PWM max
  41. bit 3 - not allocated
  42. bit 4 - not allocated
  43. bit 2 - not allocated
  44. bit 5 - not allocated
  45. bit 6 - not allocated
  46. bit 7 - not allocated
  47. bit 8 - not allocated
  48. }*/
  49. int Exp_state_ttl; // 0x01 = odswiezyc
  50. int Broadcast_state; //0x00 - not broadcast; 0x01
  51. int I2C_port ; //0x01 - default port, 0x00 - not I2C connected
  52. int I2C_driver; //0x00 - not driver, 0x01 Adafruit_PWMServoDriver.h
  53. // int IS_Local; // Define if port is local or remote added
  54. } ;
  55. typedef struct Slave_Ports_Status_S Slave_Ports_Status_T;
  56. typedef int Slave_Ports_Status_add_port_count_T;
  57. Slave_Ports_Status_add_port_count_T Slave_Ports_Status_add_port_count_A ;
  58. void Slave_Ports_Status_add_port(
  59. Slave_Ports_Status_T* Slave_Ports_Status_A , Slave_Ports_Status_add_port_count_T* Slave_Ports_Status_add_port_count_A,
  60. int Port_ID,
  61. int _Slave_ID,
  62. int PortTypes,
  63. int Address,
  64. int LocalPort,
  65. int Exp_state,
  66. int Exp_state_ttl,
  67. int Broadcast_state,
  68. int I2C_port,
  69. //int I2C_driver
  70. int I2C_driver
  71. )
  72. {
  73. int i = Slave_Ports_Status_add_port_count_A ;
  74. if(Slave_Ports_Status_add_port_count_A == 0) {
  75. Slave_Ports_Status_add_port_count_A ++;
  76. Slave_Ports_Status_A[i].Port_ID=0x00;
  77. Slave_Ports_Status_A[i]._Slave_ID=0x00;
  78. Slave_Ports_Status_A[i].PortTypes=0x00;
  79. Slave_Ports_Status_A[i].Address=0x00;
  80. Slave_Ports_Status_A[i].LocalPort=0x00;
  81. Slave_Ports_Status_A[i].Exp_state=0x00;
  82. Slave_Ports_Status_A[i].Exp_state_ttl=0x00;
  83. Slave_Ports_Status_A[i].Broadcast_state=0x00;
  84. Slave_Ports_Status_A[i].I2C_port=0x00;
  85. Slave_Ports_Status_A[i].I2C_driver=0x00;
  86. Slave_Ports_Status_add_port_count_A ++;
  87. }
  88. Slave_Ports_Status_A[i + 1].Port_ID = Port_ID ;
  89. Slave_Ports_Status_A[i + 1]._Slave_ID = _Slave_ID ;
  90. Slave_Ports_Status_A[i + 1].PortTypes = PortTypes ;
  91. Slave_Ports_Status_A[i + 1].Address = Address ;
  92. Slave_Ports_Status_A[i + 1].LocalPort = LocalPort ;
  93. Slave_Ports_Status_A[i + 1].Exp_state = Exp_state ;
  94. Slave_Ports_Status_A[i + 1].Exp_state_ttl = Exp_state_ttl ;
  95. Slave_Ports_Status_A[i + 1].Broadcast_state = Broadcast_state ;
  96. Slave_Ports_Status_A[i + 1].I2C_port = I2C_port ;
  97. Slave_Ports_Status_A[i + 1].I2C_driver = I2C_driver ;
  98. // Slave_Ports_Status_A[Slave_Ports_Status_add_port_count_A + 1].I2C_driver = I2C_driver_F(I2C_driver) ;
  99. Slave_Ports_Status_add_port_count_A ++;
  100. }
  101. #endif