/* * checks if the reset button is pressed, return 1 if the button is pressed and 0 if not */ static int resetTouched(void) { int trigger = getGPIO(RESETBUTTON & 0x0f); if (RESETBUTTON & 0xf0) trigger = 1 - trigger; return trigger; }
void TICC1100::initDevice() { try { openDevice(); if(!_fileDescriptor || _fileDescriptor->descriptor == -1) return; initChip(); _out.printDebug("Debug: CC1100: Setting GPIO direction"); setGPIODirection(1, GPIODirection::IN); _out.printDebug("Debug: CC1100: Setting GPIO edge"); setGPIOEdge(1, GPIOEdge::BOTH); openGPIO(1, true); if(!_gpioDescriptors[1] || _gpioDescriptors[1]->descriptor == -1) throw(BaseLib::Exception("Couldn't listen to rf device, because the gpio pointer is not valid: " + _settings->device)); if(gpioDefined(2)) //Enable high gain mode { openGPIO(2, false); if(!getGPIO(2)) setGPIO(2, true); closeGPIO(2); } } catch(const std::exception& ex) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(BaseLib::Exception& ex) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(...) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__); } }
void COC::startListening() { try { _socket = GD::bl->serialDeviceManager.get(_settings->device); if(!_socket) _socket = GD::bl->serialDeviceManager.create(_settings->device, 38400, O_RDWR | O_NOCTTY | O_NDELAY, true, 45); if(!_socket) return; _socket->addEventHandler(this); _socket->openDevice(); if(gpioDefined(2)) { openGPIO(2, false); if(!getGPIO(2)) setGPIO(2, true); closeGPIO(2); } if(gpioDefined(1)) { openGPIO(1, false); if(!getGPIO(1)) { setGPIO(1, false); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); setGPIO(1, true); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); } closeGPIO(1); } writeToDevice(stackPrefix + "X21\n" + stackPrefix + "Zr\n"); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IPhysicalInterface::startListening(); } catch(const std::exception& ex) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(BaseLib::Exception& ex) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(...) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__); } }
void Comms_DTMF_Handler (void) { DtmfTone tone; tone.decoder = DTMF_INVALIDDECODER; tone.tone = 0; //ported to lpc2468, this ought to work //Interrupts have been disabled should check for decoders before and after pulling data portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; // char s[3]; Boolean bPriDecodeFailed = true; if (FIO2PIN&DTMF_INT_PINS_SIN)//Will only be necessary/have effect if we have other GPIO Interrupt sources {//One decoder has decoded something num = (num+1)%2; if (FIO2PIN&(DTMF_INT_1)) {//Check if the First decoder is ready tone.decoder = DTMF_DECODER1; tone.tone = (getGPIO(2,9))+(getGPIO(2,8)<<1)+(getGPIO(2,7)<<2)+(getGPIO(2,6)<<3); if (num == 1){ DTMF_BUFF[DTMF_BUFF_EP] = tone.tone; DTMF_BUFF_EP = (DTMF_BUFF_EP+1)%DTMF_SIZE; } //xQueueSendFromISR(DTMF_BUFF,&tone,&xHigherPriorityTaskWoken); bPriDecodeFailed = false; } if (FIO2PIN&(DTMF_INT_2) && bPriDecodeFailed) {//Check if the second decoder is ready tone.decoder = DTMF_DECODER2; tone.tone = (getGPIO(2,4))+(getGPIO(2,3)<<1)+(getGPIO(2,2)<<2)+(getGPIO(2,1)<<3); DTMF_BUFF[DTMF_BUFF_EP] = tone.tone; //xQueueSendFromISR(DTMF_BUFF,&tone,&xHigherPriorityTaskWoken); DTMF_BUFF_EP = (DTMF_BUFF_EP+1)%DTMF_SIZE; } if ((FIO2PIN&(DTMF_INT_1)) && bPriDecodeFailed) {// If the first decoder was not ready try it again tone.decoder = DTMF_DECODER1; tone.tone = (getGPIO(2,9))+(getGPIO(2,8)<<1)+(getGPIO(2,7)<<2)+(getGPIO(2,6)<<3); DTMF_BUFF[DTMF_BUFF_EP] = tone.tone; DTMF_BUFF_EP = (DTMF_BUFF_EP+1)%DTMF_SIZE; //xQueueSendFromISR(DTMF_BUFF,&tone,&xHigherPriorityTaskWoken); } if (DTMF_BUFF_EP%2==0){ // Push the tone to the Command task MessagePacket outgoingPacket; outgoingPacket.Src = TASK_COMMAND; // XXX: Pretend we are the Command task, since we're not really a task outgoingPacket.Dest = TASK_COMMAND; outgoingPacket.Token = enGetTaskToken(TASK_COMMAND); if(DTMF_BUFF_EP != 0){ outgoingPacket.Data = DTMF_BUFF[DTMF_BUFF_EP-2]*16+DTMF_BUFF[DTMF_BUFF_EP-1]; // We don't care about the decoder } else { outgoingPacket.Data = DTMF_BUFF[DTMF_SIZE-2]*16+DTMF_BUFF[DTMF_SIZE-1]; } UnivRetCode ret = dtmfRequest(&outgoingPacket); } } if( xHigherPriorityTaskWoken ) { portYIELD_FROM_ISR(); } }