| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- #ifndef SLAVE_PORTS_STATUS_H
- #define SLAVE_PORTS_STATUS_H
- #include <Arduino.h>
-
- #ifndef voidfuncptr_t
- #define voidfuncptr_t voidfuncptr_t
- typedef void (*voidfuncptr_t)(void); // void function pointer typedef
- #endif
-
-
-
- #ifndef vfp_vpu32b_t
- #define vfp_vpu32b_t vfp_vpu32b_t
- typedef void (*vfp_vpu32b_t)(void*, uint32_t, bool);
- #endif
- typedef struct
- {
- uint8_t CNF1;
- } I2C_driver_T;
- static I2C_driver_T constexpr _NOT_USED_ = {0x00};
- static I2C_driver_T constexpr Adafruit_PWMServoDriver = {0x01};
- /*
- typedef struct {
- char I2C_driver_TA[32];
- } I2C_driver_TS ;
- */
- //typedef struct I2C_driver_TS I2C_driver_TT;
- //I2C_driver_TS I2C_driver_AA = { "_NOT_USED_" };
-
- //I2C_driver_AA[0] = "_NOT_USED_" ;
- //I2C_driver_AA[0x01] = "Adafruit_PWMServoDriver" ;
- struct Slave_Ports_Status_S {
- int Port_ID ; //global id for device //const char * const _Protocol;
- int _Slave_ID; //Device which orginated port //remote id - use FF for broadcast
- int PortTypes; //0xFF = 1111 1111 s
- /*
- {
- bit 1 - PWM port
- bit 2 - on I2C managed port
- bit 3 - expanded port with LocalPort address
- bit 4 - not allocated
- bit 2 - not allocated
- bit 5 - not allocated
- bit 6 - not allocated
- bit 7 - not allocated
- bit 8 - not allocated
- }
- */
- // byte has_Address;
- int Address ;
- // byte has_Local_Port;
- int LocalPort;
- int Exp_state; /*0xFF = 1111 1111
- 0x00 = 0000 0000 = OFF = 0V
- 0x01 = 0000 0001 = ON = PWM max
- {
- bit 1 - OFF = 0V
- bit 2 - ON = PWM max
- bit 3 - not allocated
- bit 4 - not allocated
- bit 2 - not allocated
- bit 5 - not allocated
- bit 6 - not allocated
- bit 7 - not allocated
- bit 8 - not allocated
- }*/
- int Exp_state_ttl; // 0x00 = odswiezyc
- int Broadcast_state; //0x00 - not broadcast; 0x01
- int I2C_port ; //0x01 - default port, 0x00 - not I2C connected
- int I2C_driver; //0x00 - not driver, 0x01 Adafruit_PWMServoDriver.h
- // int IS_Local; // Define if port is local or remote added
-
- } ;
- typedef struct Slave_Ports_Status_S Slave_Ports_Status_T;
- /*
- enum class Mode : uint8_t
- {
- Normal = 0x00,
- Sleep = 0x20,
- Loopback = 0x40,
- ListenOnly = 0x60,
- Config = 0x80
- };
- */
- //char I2C_driver_FT[32] ;
- static char I2C_driver_FT[24];
- class Slave_Ports_Status
- {
- private:
-
-
-
-
- //public:
- // static Slave_Ports_Status *first;
- //static Slave_Ports_Status *_data;
- public:
- Slave_Ports_Status_T *Slave_Ports_Status_A;
- int _count;
-
- // void push(Slave_Ports_Status_S const &item);
- //void push();
- //Slave_Ports_Status();
- // bool setMode();
- //voidfuncptr_t func; // address of coroutine function
- Slave_Ports_Status();
-
- /* inline int add(
- Slave_Ports_Status_LIST_T Slave_Ports_Status_LIST_A ,
- Slave_Ports_Status_T Slave_Ports_Status_A
- ) {
- };
- */
- void add_port(
- int Port_ID,
- int _Slave_ID,
- int PortTypes,
- int Address,
- int LocalPort,
- int Exp_state,
- int Exp_state_ttl,
- int Broadcast_state,
- int I2C_port,
- //int I2C_driver
- I2C_driver_T I2C_driver
- );
- bool add_empty();
- void print_ports();
- void list_ports();
- Slave_Ports_Status_S get_port(int Port_ID);
- // int get_count();
-
- bool I2C_driver_F(I2C_driver_T I2C_driver_A);
- char* I2C_driver_FS(int I2C_driver) ;
-
- // byte _Slave_Ports_Protocol_CAN_broadcast_F();
-
- ~Slave_Ports_Status();
- };
- /*
- class Slave_Ports_Status {
- private:
- int _front, _back, _count;
- T *_data;
- int _maxitems;
- public:
- Queue(int maxitems = 256) {
- _front = 0;
- _back = 0;
- _count = 0;
- _maxitems = maxitems;
- _data = new T[maxitems + 1];
- }
- ~Queue() {
- delete[] _data;
- }
- inline int count();
- inline int front();
- inline int back();
- // void push(const T &item);
- // T peek();
- // T pop();
- // void clear();
- // T pop_item(const T &item);
- }
- */
- #endif
|