4 #include "../hubolib.h"
12 m_PulseLength = pulseLength;
16 printf (
"GPIO not properly initialized - following calls will fail!");
73 SendPysicalBit(Floating);
81 SendPysicalBit (Zero);
82 SendPysicalBit (Floating);
86 SendPysicalBit (Floating);
87 SendPysicalBit (Zero);
93 SendPysicalBit (Sync);
97 bool CSC5262::Switch (
unsigned char SystemCode,
unsigned char Receiver,
bool bTurnOn)
102 for (
int rover = 0x10; rover > 0; rover >>= 1)
103 SendLogicalBit (SystemCode & rover);
106 for (
int rover = 0x10; rover > 0; rover >>= 1)
107 SendLogicalBit (Receiver & rover);
110 SendCommand (bTurnOn);
119 bool bSuccess = ( ((long) (stop-start)) <= (128L + 1L)*m_PulseLength );
121 printf (
"Duration = %llu micro seconds - %s\n", stop-start, bSuccess?
"ok":
"failed");
126 bool CSC5262::SwitchSocket (
unsigned char SystemCode,
unsigned char Receiver,
bool bTurnOn,
int repeatedSuccess,
int totalTransmittion)
128 if (repeatedSuccess > totalTransmittion)
130 printf (
"User error - The number of total transmissions must not be less than the number of successfully repeated transmissions.\n");
133 if (repeatedSuccess < 3)
135 printf (
"User error - The number of successfully repeated transmissions must at least be 3 in order to switch the socket.\n");
139 int transmissionCount = 0;
140 int successCount = 0;
143 if (Switch (SystemCode, Receiver, bTurnOn))
148 if (successCount == repeatedSuccess)
153 if (transmissionCount == totalTransmittion)
void Delay_MicroSeconds(unsigned long delay_micros)
delays the execution of the calling thread for the given number of micro seconds. ...
bool IsGPIOInitialized()
Returns the status of the initialisation of the GPIO part of the library.
void SetPin(unsigned char pin)
Sets a pin configured as output to 1.
void SendLogicalBit(unsigned short bit)
void FunctionSelectPin(unsigned char pin, FunctionSelectType mode)
Use FunctionSelect() to configure the mode of a BCM2835 pin.
CSC5262(int pulseLength, int pin)
void SendCommand(bool bTurnOn)
void SendPysicalBit(TriSTateBit bit)
void ClearPin(unsigned char pin)
Resets a pin configured as output to 0.
unsigned long long GetTime_MicroSeconds()
Returns the number of micro seconds.
bool SwitchSocket(unsigned char SystemCode, unsigned char Receiver, bool bTurnOn, int repeatedSuccess, int totalTransmittion)
bool Switch(unsigned char SystemCode, unsigned char Receiver, bool bTurnOn)