4 #include "../hubolib.h"
12 m_PulseLength = pulseLength;
17 printf (
"GPIO not properly initialized - following calls will fail!");
74 SendPysicalBit(Floating);
82 SendPysicalBit (Zero);
83 SendPysicalBit (Floating);
87 SendPysicalBit (Floating);
88 SendPysicalBit (Zero);
94 SendPysicalBit (Sync);
98 bool CSC5262::Switch (
unsigned char SystemCode,
unsigned char Receiver,
bool bTurnOn)
103 for (
int rover = 0x10; rover > 0; rover >>= 1)
104 SendLogicalBit (SystemCode & rover);
107 for (
int rover = 0x10; rover > 0; rover >>= 1)
108 SendLogicalBit (Receiver & rover);
111 SendCommand (bTurnOn);
120 bool bSuccess = ( ((long) (stop-start)) <= (128L + 1L)*m_PulseLength );
123 printf (
"Duration = %llu micro seconds - %s\n", stop-start, bSuccess?
"ok":
"failed");
128 bool CSC5262::SwitchSocket (
unsigned char SystemCode,
unsigned char Receiver,
bool bTurnOn,
int repeatedSuccess,
int totalTransmittion)
130 if (repeatedSuccess > totalTransmittion)
133 printf (
"User error - The number of total transmissions must not be less than the number of successfully repeated transmissions.\n");
136 if (repeatedSuccess < 3)
139 printf (
"User error - The number of successfully repeated transmissions must at least be 3 in order to switch the socket.\n");
143 int transmissionCount = 0;
144 int successCount = 0;
147 if (Switch (SystemCode, Receiver, bTurnOn))
152 if (successCount == repeatedSuccess)
157 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.
void SendCommand(bool bTurnOn)
CSC5262(int pulseLength, int pin, bool bQuiet=false)
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)