void NetworkAdapter::init(unsigned char PinEthLink_UB, unsigned char pMacAddr_UB[6], IPAddress IpAddr_X, IPAddress SubnetMaskAddr_X, IPAddress GatewayAddr_X, IPAddress DnsIpAddr_X) { GL_NetworkAdapterParam_X.PintEthLink_UB = PinEthLink_UB; pinMode(GL_NetworkAdapterParam_X.PintEthLink_UB, INPUT); for (int i = 0; i < 6; i++) GL_NetworkAdapterParam_X.pMacAddr_UB[i] = pMacAddr_UB[i]; GL_NetworkAdapterParam_X.IpAddr_X = IpAddr_X; GL_NetworkAdapterParam_X.SubnetMaskAddr_X = SubnetMaskAddr_X; GL_NetworkAdapterParam_X.GatewayAddr_X = GatewayAddr_X; GL_NetworkAdapterParam_X.DnsIpAddr_X = DnsIpAddr_X; GL_NetworkAdapterParam_X.IsDhcp_B = false; GL_NetworkAdapterParam_X.AdvancedConfig_B = true; GL_NetworkAdapterParam_X.IsInitialized_B = true; DBG_PRINTLN(DEBUG_SEVERITY_INFO, "Network Adapter Initialized"); DBG_PRINTLN(DEBUG_SEVERITY_INFO, "MAC Address = " + HexArrayToString(GL_NetworkAdapterParam_X.pMacAddr_UB, sizeof(GL_NetworkAdapterParam_X.pMacAddr_UB), ":")); DBG_PRINT(DEBUG_SEVERITY_INFO, "IP Address = "); DBG_PRINTDATA(IpAddr_X); DBG_ENDSTR(); DBG_PRINT(DEBUG_SEVERITY_INFO, "Subnet Mask = "); DBG_PRINTDATA(SubnetMaskAddr_X); DBG_ENDSTR(); DBG_PRINT(DEBUG_SEVERITY_INFO, "Gateway Address = "); DBG_PRINTDATA(GatewayAddr_X); DBG_ENDSTR(); DBG_PRINT(DEBUG_SEVERITY_INFO, "DNS Address = "); DBG_PRINTDATA(DnsIpAddr_X); DBG_ENDSTR(); }
bool IRrecv::decodeTcl112ac (decode_results *results) { unsigned long data = 0; // Somewhere to build our code int offset = 1; // Skip the Gap reading DBG_PRINTLN("Checking right amount of data: "); DBG_PRINTLN(irparams.rawlen); // Check we have the right amount of data if (irparams.rawlen != 1 + 2 + (2 * BITS) + 1) return false ; // Check initial Mark+Space match if (!MATCH_MARK (results->rawbuf[offset++], HDR_MARK )) return false ; if (!MATCH_SPACE(results->rawbuf[offset++], HDR_SPACE)) return false ; // Read the bits in for (int i = 0; i < BITS; i++) { // Each bit looks like: MARK + SPACE_1 -> 1 // or : MARK + SPACE_0 -> 0 if (!MATCH_MARK(results->rawbuf[offset++], BIT_MARK)) return false ; // IR data is big-endian, so we shuffle it in from the right: if (MATCH_SPACE(results->rawbuf[offset], ONE_SPACE)) data = (data << 1) | 1 ; else if (MATCH_SPACE(results->rawbuf[offset], ZERO_SPACE)) data = (data << 1) | 0 ; else return false ; offset++; } // Success results->bits = BITS; results->value = data; results->decode_type = TCL112AC; return true; }
void ProcessCheckCmd(void) { boolean FoundStx_B = false; unsigned char Temp_UB = 0x00; while (WCmdMedium_DataAvailable()) { // Look for the Start Of Transmit byte if (WCmdMedium_ReadByte() == WCMD_STX) { FoundStx_B = true; DBG_PRINTLN(DEBUG_SEVERITY_INFO, "Found STX"); break; } } if (FoundStx_B && (WCmdMedium_DataAvailable() > 0)) { // Get Command ID and Parameters bit Temp_UB = WCmdMedium_ReadByte(); GL_WCmdParam_X.CmdId_UB = Temp_UB & WCMD_CMD_ID_MASK; GL_WCmdParam_X.HasParam_B = ((Temp_UB & WCMD_PARAM_BIT_MASK) == WCMD_PARAM_BIT_MASK) ? true : false; DBG_PRINT(DEBUG_SEVERITY_INFO, "Command ID = 0x"); DBG_PRINTDATABASE(GL_WCmdParam_X.CmdId_UB, HEX); DBG_ENDSTR(); DBG_PRINT(DEBUG_SEVERITY_INFO, "Has Param ? = "); DBG_PRINTDATABASE(GL_WCmdParam_X.HasParam_B, BIN); DBG_ENDSTR(); // Get Parameters if any if (GL_WCmdParam_X.HasParam_B) { GL_WCmdParam_X.ParamNb_UL = WCmdMedium_ReadByte(); DBG_PRINT(DEBUG_SEVERITY_INFO, "Param Number = "); DBG_PRINTDATA(GL_WCmdParam_X.ParamNb_UL); DBG_ENDSTR(); //DBG_PRINTLN(DEBUG_SEVERITY_INFO, "Param List = "); for (int i = 0; i < GL_WCmdParam_X.ParamNb_UL; i++) { //DBG_PRINTDATA(i); //DBG_PRINTDATA(" - "); GL_WCmdParam_X.pParamBuffer_UB[i] = WCmdMedium_ReadByte(); //DBG_PRINTDATABASE(GL_WCmdParam_X.pParamBuffer_UB[i], HEX); //DBG_ENDSTR(); } } // Check for End Of Transmit byte if (WCmdMedium_ReadByte() == WCMD_ETX) { DBG_PRINTLN(DEBUG_SEVERITY_INFO, "Found ETX"); TransitionToProcessCmd(); } else { DBG_PRINTLN(DEBUG_SEVERITY_WARNING, "Do NOT Found ETX"); GL_WCmdParam_X.FctSts_E = WCMD_FCT_STS_BAD_PACKET; TransitionToSendResp(); } } }
void EButton::setEvents( const event_t eKeyPressed, const event_t eKeyDoublePressed, const event_t eKeyHold ) { eventKeyPressed = eKeyPressed; eventKeyDoublePressed = eKeyDoublePressed; eventKeyHold = eKeyHold; DBG_PRINTLN( eventKeyPressed ); DBG_PRINTLN( eventKeyDoublePressed ); DBG_PRINTLN( eventKeyHold ); };
void EOutputDevice::off() //выключение устройства с сохранением соответствующих полей { isOn = false; if ( this->reverseOn ) { digitalWrite( this->port, HIGH ); DBG_PRINTLN( F("EOD:off() REVERSE, OFF") ); } else { digitalWrite( this->port, LOW ); DBG_PRINTLN( F("EOD:off() NO REVERSE, OFF") ); }; };
void NetworkAdapter::init(unsigned char PinEthLink_UB, unsigned char pMacAddr_UB[6]) { GL_NetworkAdapterParam_X.PintEthLink_UB = PinEthLink_UB; pinMode(GL_NetworkAdapterParam_X.PintEthLink_UB, INPUT); for (int i = 0; i < 6; i++) GL_NetworkAdapterParam_X.pMacAddr_UB[i] = pMacAddr_UB[i]; GL_NetworkAdapterParam_X.IsDhcp_B = true; GL_NetworkAdapterParam_X.AdvancedConfig_B = false; GL_NetworkAdapterParam_X.IsInitialized_B = true; DBG_PRINTLN(DEBUG_SEVERITY_INFO, "Network Adapter Initialized"); DBG_PRINTLN(DEBUG_SEVERITY_INFO, "MAC Address = " + HexArrayToString(GL_NetworkAdapterParam_X.pMacAddr_UB, sizeof(GL_NetworkAdapterParam_X.pMacAddr_UB), ":")); DBG_PRINTLN(DEBUG_SEVERITY_INFO, "DHCP Configuration"); }
STATIC void A6(void) #endif /* KSTACK_MEMORY_MAPPING */ { KnxMsg_Buffer * pBuffer; /* ** Send a N_Data_Individual.req with T_DISCONNECT_REQ_PDU, priority = SYSTEM, ** destination = connection_address, sequence = 0 to the network layer (remote device). */ DBG_PRINTLN("A6()"); KnxMsg_AllocateBuffer(&pBuffer); if (pBuffer != (KnxMsg_Buffer *)NULL) { T_Disconnect_Req(pBuffer, KnxTlc_GetSourceAddress(), /* KnxADR_GetPhysAddr(), */ KnxTlc_GetConnectionAddress()); } else { /* Errorhandling. */ } /* Send a T_Disconnect.ind to the user. */ /* Handled by callback. */ //#if 0 if (KnxMsg_ScratchBufferPtr == (KnxMsg_Buffer *)NULL) { KnxMsg_AllocateBuffer(&KnxMsg_ScratchBufferPtr); } else { (void)KnxMsg_ClearBuffer(KnxMsg_ScratchBufferPtr); } T_Disconnect_Ind(KnxMsg_ScratchBufferPtr, KnxTlc_GetSourceAddress(), /* KnxADR_GetPhysAddr(), */ KnxTlc_GetConnectionAddress()); //#endif KnxTlc_StopAcknowledgementTimeoutTimer(); KnxTlc_StopConnectionTimeoutTimer(); }
void ProcessProcessCmd(void) { int i = 0; GL_WCmdParam_X.FctSts_E = WCMD_FCT_STS_ERROR; // Look for the command ID in the table of fonction handler for (i = 0; i < GL_WCmdFctNb_UL; i++) { if (GL_pWCmdFctDescr_X[i].CmdID_UB == GL_WCmdParam_X.CmdId_UB) { DBG_PRINTLN(DEBUG_SEVERITY_INFO, "Found Command ID. Call Function..."); GL_WCmdParam_X.FctSts_E = GL_pWCmdFctDescr_X[i].FctHandler(GL_WCmdParam_X.pParamBuffer_UB, GL_WCmdParam_X.ParamNb_UL, GL_WCmdParam_X.pAnsBuffer_UB, &(GL_WCmdParam_X.AnsNb_UL)); DBG_PRINT(DEBUG_SEVERITY_INFO, "Status = "); DBG_PRINTDATA(GL_WCmdParam_X.FctSts_E); DBG_PRINTDATA(" - Number of Bytes in Answer = "); DBG_PRINTDATA(GL_WCmdParam_X.AnsNb_UL); DBG_ENDSTR(); break; } } // Check if the ID has been found and call the appropriate function if (i == GL_WCmdFctNb_UL) { GL_WCmdParam_X.FctSts_E = WCMD_FCT_STS_UNKNOWN; DBG_PRINT(DEBUG_SEVERITY_WARNING, "Command ID Unknown [0x"); DBG_PRINTDATABASE(GL_WCmdParam_X.CmdId_UB, HEX); DBG_PRINTDATA("]"); DBG_ENDSTR(); } // Go to Send Response state TransitionToSendResp(); }
boolean GP2Y1010Sensor::run() { uint16_t value; digitalWrite(auxiliaryPin,LOW); // power on the LED delayMicroseconds(GP2Y1010_SAMPLE_TIME); value = (uint16_t)analogRead(attachPin); // read the dust value digitalWrite(auxiliaryPin,HIGH); // power on the LED /** **/ dustDensity = 0.83*(float)value - 100; if ( dustDensity < 0 ) { dustDensity = 0; } else if ( dustDensity > 520 ) { dustDensity = 520; } DBG_PRINT("Dust raw value="); DBG_PRINTLN(value); return true; }
int IRrecv::getRClevel (decode_results *results, int *offset, int *used, int t1) { int width; int val; int correction; int avail; if (*offset >= results->rawlen) return SPACE ; // After end of recorded buffer, assume SPACE. width = results->rawbuf[*offset]; val = ((*offset) % 2) ? MARK : SPACE; correction = (val == MARK) ? MARK_EXCESS : - MARK_EXCESS; if (MATCH(width, ( t1) + correction)) avail = 1 ; else if (MATCH(width, (2*t1) + correction)) avail = 2 ; else if (MATCH(width, (3*t1) + correction)) avail = 3 ; else return -1 ; (*used)++; if (*used >= avail) { *used = 0; (*offset)++; } DBG_PRINTLN( (val == MARK) ? "MARK" : "SPACE" ); return val; }
/* ******************************************************************************** */ void IndicatorInterface_Init(void) { // Fill-Up LD5218 Parameters and Function GL_pIndicatorInterface_X[INDICATOR_LD5218].FctHandler = LD5218_ProcessFrame; for (int i = 0; i < INDICATOR_INTERFACE_FRAME_NUM; i++) { GL_pIndicatorInterface_X[INDICATOR_LD5218].pFrame[i].Size_UB = GL_pLD5218Frames_X[i].Size_UB; GL_pIndicatorInterface_X[INDICATOR_LD5218].pFrame[i].RespSize_UB = GL_pLD5218Frames_X[i].RespSize_UB; for (int j = 0; j < GL_pIndicatorInterface_X[INDICATOR_LD5218].pFrame[i].Size_UB; j++) GL_pIndicatorInterface_X[INDICATOR_LD5218].pFrame[i].pWords_UB[j] = GL_pLD5218Frames_X[i].pWords_UB[j]; } // Fill-Up GI400 Parameters and Function GL_pIndicatorInterface_X[INDICATOR_GI400].FctHandler = GI400_ProcessFrame; for (int i = 0; i < INDICATOR_INTERFACE_FRAME_NUM; i++) { GL_pIndicatorInterface_X[INDICATOR_GI400].pFrame[i].Size_UB = GL_pGI400Frames_X[i].Size_UB; GL_pIndicatorInterface_X[INDICATOR_GI400].pFrame[i].RespSize_UB = GL_pGI400Frames_X[i].RespSize_UB; for (int j = 0; j < GL_pIndicatorInterface_X[INDICATOR_GI400].pFrame[i].Size_UB; j++) GL_pIndicatorInterface_X[INDICATOR_GI400].pFrame[i].pWords_UB[j] = GL_pGI400Frames_X[i].pWords_UB[j]; } // Do the same for other indicators.. // ... // Print out the allowed interfaces DBG_PRINTLN(DEBUG_SEVERITY_INFO, "Indicator Interfaces Initialized : "); for (int i = 0; i < INDICATOR_INTERFACE_DEVICES_NUM; i++) { DBG_PRINT(DEBUG_SEVERITY_INFO, " - "); DBG_PRINTDATA(pIndicatorInterfaceDeviceLut_Str[i]); DBG_ENDSTR(); } }
//+============================================================================= // The match functions were (apparently) originally MACROs to improve code speed // (although this would have bloated the code) hence the names being CAPS // A later release implemented debug output and so they needed to be converted // to functions. // I tried to implement a dual-compile mode (DEBUG/non-DEBUG) but for some // reason, no matter what I did I could not get them to function as macros again. // I have found a *lot* of bugs in the Arduino compiler over the last few weeks, // and I am currently assuming that one of these bugs is my problem. // I may revisit this code at a later date and look at the assembler produced // in a hope of finding out what is going on, but for now they will remain as // functions even in non-DEBUG mode // int MATCH (int measured, int desired) { DBG_PRINT(F("Testing: ")); DBG_PRINT(TICKS_LOW(desired), DEC); DBG_PRINT(F(" <= ")); DBG_PRINT(measured, DEC); DBG_PRINT(F(" <= ")); DBG_PRINT(TICKS_HIGH(desired), DEC); bool passed = ((measured >= TICKS_LOW(desired)) && (measured <= TICKS_HIGH(desired))); if (passed) DBG_PRINTLN(F("?; passed")); else DBG_PRINTLN(F("?; FAILED")); return passed; }
STATIC void A0(void) #endif /* KSTACK_MEMORY_MAPPING */ { /* do nothing. */ DBG_PRINTLN("A0()"); if (KnxMsg_ScratchBufferPtr != (KnxMsg_Buffer *)NULL) { KnxMsg_ReleaseBuffer(KnxMsg_ScratchBufferPtr); } }
STATIC void A11(void) /* (Client only???) */ #endif /* KSTACK_MEMORY_MAPPING */ { /* Store event back and handle after next event. Don't change order of T_Data_Connected.req events. */ DBG_PRINTLN("A11()"); // (void)KnxMsg_Post(KnxMsg_ScratchBufferPtr); /* push-bask event. */ }
STATIC void A8b(void) /* only local-user (Client only). */ #endif /* KSTACK_MEMORY_MAPPING */ { DBG_PRINTLN("A8b()"); KnxMsg_ReleaseBuffer(KnxMsg_ScratchBufferPtr); KnxTlc_StopAcknowledgementTimeoutTimer(); KnxTlc_SetSequenceNumberSend(KnxTlc_GetSequenceNumberSend() + (uint8_t)1); KnxTlc_RestartConnectionTimeoutTimer(); }
STATIC void A13(void) /* Nur local-user (Client only). */ #endif /* KSTACK_MEMORY_MAPPING */ { /* Send a T_Connect.con to the user. */ DBG_PRINTLN("A13()"); //KnxMsg_ScratchBufferPtr->service = KNX_SERVICE_T_CONNECT_CON; //(void)KnxMsg_Post(KnxMsg_ScratchBufferPtr); }
STATIC void A15(void) /* only local-user (Client only). */ #endif /* KSTACK_MEMORY_MAPPING */ { /* Send a T_Disconnect.con to the management user */ DBG_PRINTLN("A15()"); KnxTlc_StopAcknowledgementTimeoutTimer(); KnxTlc_StopConnectionTimeoutTimer(); }
/* ******************************************************************************** */ void NetworkAdapter::init(unsigned char PinEthLink_UB) { GL_NetworkAdapterParam_X.PintEthLink_UB = PinEthLink_UB; pinMode(GL_NetworkAdapterParam_X.PintEthLink_UB, INPUT); GL_NetworkAdapterParam_X.pMacAddr_UB[0] = NETWORK_ADAPTER_DEFAULT_MAC_ADDR0; GL_NetworkAdapterParam_X.pMacAddr_UB[1] = NETWORK_ADAPTER_DEFAULT_MAC_ADDR1; GL_NetworkAdapterParam_X.pMacAddr_UB[2] = NETWORK_ADAPTER_DEFAULT_MAC_ADDR2; GL_NetworkAdapterParam_X.pMacAddr_UB[3] = NETWORK_ADAPTER_DEFAULT_MAC_ADDR3; GL_NetworkAdapterParam_X.pMacAddr_UB[4] = NETWORK_ADAPTER_DEFAULT_MAC_ADDR4; GL_NetworkAdapterParam_X.pMacAddr_UB[5] = NETWORK_ADAPTER_DEFAULT_MAC_ADDR5; GL_NetworkAdapterParam_X.IsDhcp_B = true; GL_NetworkAdapterParam_X.AdvancedConfig_B = false; GL_NetworkAdapterParam_X.IsInitialized_B = true; DBG_PRINTLN(DEBUG_SEVERITY_INFO, "Network Adapter Initialized"); DBG_PRINTLN(DEBUG_SEVERITY_INFO, "Default MAC Address = " + HexArrayToString(GL_NetworkAdapterParam_X.pMacAddr_UB, sizeof(GL_NetworkAdapterParam_X.pMacAddr_UB), ":")); DBG_PRINTLN(DEBUG_SEVERITY_INFO, "DHCP Configuration"); }
STATIC void A14b(void) /* wie A14, nur ohne T_DISCONNECT_CON to user. */ #endif /* KSTACK_MEMORY_MAPPING */ { /* Send a N_Data_Individual.req with T_DISCONNECT_REQ_PDU, priority = SYSTEM, */ /* destination = connection_address, sequence = 0 to the network layer (remote device). */ DBG_PRINTLN(" A14b()"); KnxTlc_StopAcknowledgementTimeoutTimer(); KnxTlc_StopConnectionTimeoutTimer(); }
//+============================================================================= // The match functions were (apparently) originally MACROs to improve code speed // (although this would have bloated the code) hence the names being CAPS // A later release implemented debug output and so they needed to be converted // to functions. // I tried to implement a dual-compile mode (DEBUG/non-DEBUG) but for some // reason, no matter what I did I could not get them to function as macros again. // I have found a *lot* of bugs in the Arduino compiler over the last few weeks, // and I am currently assuming that one of these bugs is my problem. // I may revisit this code at a later date and look at the assembler produced // in a hope of finding out what is going on, but for now they will remain as // functions even in non-DEBUG mode // int MATCH (int measured, int desired) { DBG_PRINT("Testing: "); DBG_PRINT(TICKS_LOW(desired), DEC); DBG_PRINT(" <= "); DBG_PRINT(measured, DEC); DBG_PRINT(" <= "); DBG_PRINTLN(TICKS_HIGH(desired), DEC); return ((measured >= TICKS_LOW(desired)) && (measured <= TICKS_HIGH(desired))); }
void EChain::stop() { #ifdef DEBUG_ECHAIN DBG_PRINT( "EChain::stop():ON ID=" ); int port = getID(); DBG_PRINTLN(port); #endif chainMode = ecmStop; };
void EChain::on() { for(int iLed = 0; iLed < numLeds; iLed++) { memset(ledBuffer, 255, numLeds * sizeof(struct CRGB)); } #ifdef DEBUG_ECHAIN DBG_PRINT( "EChain::on():ON ID=" ); int port = getID(); DBG_PRINTLN(port); #endif // EOutputDevice::on(); isOn = true; };
//+======================================================== // Due to sensor lag, when received, Spaces tend to be 100us too short // int MATCH_SPACE (int measured_ticks, int desired_us) { DBG_PRINT(F("Testing space (actual vs desired): ")); DBG_PRINT(measured_ticks * USECPERTICK, DEC); DBG_PRINT(F("us vs ")); DBG_PRINT(desired_us, DEC); DBG_PRINT("us"); DBG_PRINT(": "); DBG_PRINT(TICKS_LOW(desired_us - MARK_EXCESS) * USECPERTICK, DEC); DBG_PRINT(F(" <= ")); DBG_PRINT(measured_ticks * USECPERTICK, DEC); DBG_PRINT(F(" <= ")); DBG_PRINT(TICKS_HIGH(desired_us - MARK_EXCESS) * USECPERTICK, DEC); bool passed = ((measured_ticks >= TICKS_LOW (desired_us - MARK_EXCESS)) && (measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS))); if (passed) DBG_PRINTLN(F("?; passed")); else DBG_PRINTLN(F("?; FAILED")); return passed; }
oid_t EButton::init( const port_t port, const bool reverseOn, const bool pullUp ) { oid_t result = EInputDevice::init( port, imUpOnly ); eventKeyPressed = evKeyPressed; eventKeyDoublePressed = evKeyDoublePressed; eventKeyHold = evKeyHold; DBG_PRINTLN( F("EButton::init_full()") ); debounceTimer.init( DEBOUNCEDELAY, TIMER_NO_AUTORESTART, TIMER_NO_AUTOSTART ); doublePressTimer.init( DOUBLEPRESSDELAY, TIMER_NO_AUTORESTART, TIMER_AUTOSTART ); holdTimer.init( KEYHOLDDELAY, TIMER_NO_AUTORESTART, TIMER_NO_AUTOSTART ); this->reverseOn = reverseOn; pinMode( this->port, INPUT ); // set this port to INPUT mode if ( pullUp ) { digitalWrite( this->port, HIGH ); DBG_PRINT( F("EButton::init PullUp port:") ); DBG_PRINTLN( this->port ); }; getData(); this->currentData = this->currentState; return result; };
STATIC void A5(void) #endif /* KSTACK_MEMORY_MAPPING */ { /* Send a T_Disconnect.ind to the user. */ /* Handled by callback. */ //(void)KnxMsg_ClearBuffer(KnxMsg_ScratchBufferPtr); //T_Disconnect_Ind(KnxMsg_ScratchBufferPtr, KnxTlc_GetConnectionAddress(), KnxTlc_GetSourceAddress(), /*KnxADR_GetPhysAddr() */); DBG_PRINTLN("A5()"); KnxTlc_StopAcknowledgementTimeoutTimer(); KnxTlc_StopConnectionTimeoutTimer(); }
STATIC void A3(void) #endif /* KSTACK_MEMORY_MAPPING */ { /* ** Send an N_Data_Individual.req with T_ACK_PDU, priority = SYSTEM, destination = ** connection_address, sequence = sequence of received message to the network ** layer (remote device). */ DBG_PRINTLN("A3()"); (void)KnxMsg_ClearBuffer(KnxMsg_ScratchBufferPtr); T_Ack_Req(KnxMsg_ScratchBufferPtr, KnxTlc_GetSourceAddress(), /* KnxADR_GetPhysAddr(), */ KnxTlc_GetConnectionAddress(), KnxTlc_GetSequenceNumberReceived()); KnxTlc_RestartConnectionTimeoutTimer(); }
oid_t EInputDevice::init(const port_t port, const InputMode im, const bool reverseOn, bool pullUp) { oid_t result=EDevice::init( port ); DBG_PRINTLN( F("EInputdevice::init_full()") ); debounceTimer.init( DEBOUNCEDELAY, false ); this->inputMode = im; //зададим режим создания событий устройства this->reverseOn = reverseOn; //зададим режим реверса pinMode( this->port, INPUT ); // после этого запрограммируем порт в режим чтения, подтяжку порта не делаем #ifdef DEBUG_EINPUTDEVICE int tmp = this->port; #endif if (pullUp) { digitalWrite( this->port, HIGH ); DBG_PRINT( F("EInputDevice::init PullUp port:") ); DBG_PRINTLN( tmp ); } else { digitalWrite( this->port, LOW ); DBG_PRINT( F("EInputDevice::init PullDown port:") ); DBG_PRINTLN( tmp ); } getDataFromInput(); // считаем данные с учетом флага реверса this->currentData = this->currentState; return result; };
/* ******************************************************************************** */ void MemoryCard::init(unsigned char PinChipSelect_UB, unsigned char PinCardDetect_UB, unsigned char PinWriteProtect_UB) { GL_pCard_H = &SD; GL_PinChipSelect_UB = PinChipSelect_UB; GL_PinCardDetect_UB = PinCardDetect_UB; GL_PinWriteProtect_UB = PinWriteProtect_UB; pinMode(GL_PinChipSelect_UB, OUTPUT); pinMode(GL_PinCardDetect_UB, INPUT); pinMode(GL_PinWriteProtect_UB, INPUT); // Check if Card is present before initialize handle if (isCardInserted()) { if (GL_pCard_H->begin(GL_PinChipSelect_UB)) { GL_MemoryCardParam_X.IsInitialized_B = true; DBG_PRINTLN(DEBUG_SEVERITY_INFO, "Memory Card Module Initialized"); } else { GL_MemoryCardParam_X.IsInitialized_B = false; DBG_PRINTLN(DEBUG_SEVERITY_ERROR, "Memory Card Module NOT Initialized - Error in low-level function !"); } } else { GL_MemoryCardParam_X.IsInitialized_B = false; DBG_PRINTLN(DEBUG_SEVERITY_ERROR, "Memory Card Module NOT Initialized - Card not detected !"); } }
//+======================================================== // Due to sensor lag, when received, Spaces tend to be 100us too short // int MATCH_SPACE (int measured_ticks, int desired_us) { DBG_PRINT("Testing space "); DBG_PRINT(measured_ticks * USECPERTICK, DEC); DBG_PRINT(" vs "); DBG_PRINT(desired_us, DEC); DBG_PRINT(": "); DBG_PRINT(TICKS_LOW(desired_us - MARK_EXCESS), DEC); DBG_PRINT(" <= "); DBG_PRINT(measured_ticks, DEC); DBG_PRINT(" <= "); DBG_PRINTLN(TICKS_HIGH(desired_us - MARK_EXCESS), DEC); return ((measured_ticks >= TICKS_LOW (desired_us - MARK_EXCESS)) && (measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS))); }
STATIC void A1(void) #endif /* KSTACK_MEMORY_MAPPING */ { DBG_PRINTLN("A1()"); //KnxTlc_SetConnectionAddress(KnxTlc_GetSourceAddress()); KnxTlc_SetConnectionAddress(KnxMsg_GetSourceAddress(KnxMsg_ScratchBufferPtr)); /* Send a T_CONNECT_ind to the user. */ KnxMsg_ScratchBufferPtr->service = KNX_SERVICE_T_CONNECT_IND; (void)KnxMsg_Post(KnxMsg_ScratchBufferPtr); KnxTlc_SetSequenceNumberSend((uint8_t)0); KnxTlc_SetSequenceNumberReceived((uint8_t)0); KnxTlc_StartConnectionTimeoutTimer(); }