コード例 #1
0
void main(void) 
{

    OSCTUNEbits.PLLEN = 1;
    LCDInit();
    LCDClear();
    InitPins();
    ConfigPeriph();
    ConfigInterrupts();

    while (1) {
	    received = ReadSerial();
	    LCDClear();
            switch(received) {
                case 'a':
                         received2 = ReadSerial();  
                         sprintf(output,"Received char:%c",received2); 
			/*
			 *  FIXME : PIC18 doesn't transmit back to RPi
			 *  python script hangs on serial.read(1)
			 *  Same behavior with cat -A /dev/ttyACM0 
			 *
			 * 
			 * _delay(2); // 2 cycle delay
			 *while(!PIR1bits.TX1IF);
			 *sprintf(output,"TRANSMIT");
			 *LCDWriteLine(output,0);
			 *TXREG1=received2;
                         *
			 */
			 break ;
                case 'b':
                         potentiometer = ReadPot();
                         sprintf(output,"Pot value: %d", potentiometer);
                         LATD =~ LATD;
                         break;
                  
                case 'c':
			   received2=ReadSerial();
			   sprintf(output,"Set LED to 0x%X",received2);
                           LATD = received2;
                           break;
                default:
                    sprintf(output, ">>UNKNOWN %c",received);
                    break;
             
            }
        LCDWriteLine(output,0);
	
	
    }
}
コード例 #2
0
ファイル: Commande.c プロジェクト: scauglog/LopetteRobot
  int Reset(void){
  InitPins();

  wx[0] = 0x10;
  wx[1] = 0x00;
  wx[2] = 0x05;
  wx[3] = replyId;
  wx[4] = 0x00;
  
  replyId++;
  if(replyId == 0)
    replyId = 16;
  return true;
}
コード例 #3
0
/****************************************************************************
 Function
     InitStatusPAC

 Parameters
     uint8_t : the priorty of this service

 Returns
     boolean, False if error in initialization, True otherwise

 Description
     Saves away the priority,  and starts
     the top level state machine
 Notes

 Author
     J. Edward Carryer, 02/06/12, 22:06
****************************************************************************/
bool InitStatusPAC ( uint8_t Priority )
{
  ES_Event ThisEvent;

  MyPriority = Priority;  // save our priority

  ThisEvent.EventType = ES_ENTRY;
  // Start the Master State machine
  InitPins();
  StartStatusPAC( ThisEvent );
	
	

  return true;
}
コード例 #4
0
ファイル: Gpio.cpp プロジェクト: ldrolez/domoticz
bool CGpio::StartHardware()
{
	m_stoprequested=false;
//	_log.Log(LOG_NORM,"GPIO: Starting hardware (debounce: %d ms, period: %d ms, poll interval: %d sec)", m_debounce, m_period, m_pollinterval);

	if (InitPins())
	{
		/* Disabled for now, devices should be added manually (this was the old behaviour, which we'll follow for now). Keep code for possible future usage.
		 if (!CreateDomoticzDevices())
		 {
		 	_log.Log(LOG_NORM, "GPIO: Error creating pins in DB, aborting...");
		 	m_stoprequested=true;
		 }*/
		 if (!m_stoprequested)
		 {
			//  Read all exported GPIO ports and set the device status accordingly.
			//  No need for delayed startup and force update when no masters are able to connect.
			std::vector<std::vector<std::string> > result;
			result = m_sql.safe_query("SELECT ID FROM Users WHERE (RemoteSharing==1) AND (Active==1)");
			if (result.size() > 0)
			{
				for (int i = 0; i < DELAYED_STARTUP_SEC; ++i)
				{
					sleep_milliseconds(1000);
					if (m_stoprequested)
						break;
				}
				_log.Log(LOG_NORM, "GPIO: Optional connected Master Domoticz now updates its status");
				UpdateDeviceStates(true);
			}
			else
				UpdateDeviceStates(false);

			if (m_pollinterval > 0)
				m_thread_poller = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CGpio::Poller, this)));
		}
	}
	else
	{
		_log.Log(LOG_NORM, "GPIO: No exported pins found, aborting...");
		m_stoprequested=true;
	}
	m_bIsStarted=true;
	sOnConnected(this);
	StartHeartbeatThread();
	return (m_thread != NULL);
}
コード例 #5
0
ファイル: Gpio.cpp プロジェクト: n326/domoticz
/*
 * Direct GPIO implementation, inspired by other hardware implementations such as PiFace and EnOcean
 */
CGpio::CGpio(const int ID)
{
	m_stoprequested=false;
	m_HwdID=ID;

	//Prepare a generic packet info for LIGHTING1 packet, so we do not have to do it for every packet
	IOPinStatusPacket.LIGHTING1.packetlength = sizeof(IOPinStatusPacket.LIGHTING1) -1;
	IOPinStatusPacket.LIGHTING1.housecode = 0;
	IOPinStatusPacket.LIGHTING1.packettype = pTypeLighting1;
	IOPinStatusPacket.LIGHTING1.subtype = sTypeIMPULS;
	IOPinStatusPacket.LIGHTING1.rssi = 12;
	IOPinStatusPacket.LIGHTING1.seqnbr = 0;

	if (!m_bIsInitGPIOPins)
	{
		InitPins();
		m_bIsInitGPIOPins=true;
	}
}
コード例 #6
0
ファイル: main.c プロジェクト: theepot/esc64
int main (void)
{
	//set clock divider at 1x
	CLKPR = 0x80;
	CLKPR = 0x00;

	led_init();
	trace_init();
	usart_init();
	InitPins();
	stdout = &uart_output;
	stderr = &uart_output;
	
	puts("begin");

	test();

	puts("end");

	for(;;);
	return 0;
}
コード例 #7
0
void EffectManager :: InitHardware()
{
    InitPanels();
    InitSpectrum();
    InitPins();
}
コード例 #8
0
void hardwareInit(){
	StartCritical();
	println_I("Getting MAC from flash");
	FlashGetMac(MyMAC.v);
	char macStr[13];
	int j=0,i=0;
	for (i=0;i<6;i++){
		macStr[j++]=GetHighNib(MyMAC.v[i]);
		macStr[j++]=GetLowNib(MyMAC.v[i]);
	}
	macStr[12]=0;
	println_I("MAC address is =");
	print_I(macStr);
#if defined(ROBOSUB_DEMO)
	//char * dev = "AHD Wave";
#else
	char * dev = "DyIO v.3";
#endif
	Pic32_Bowler_HAL_Init();
	usb_CDC_Serial_Init(dev,macStr,0x04D8,0x3742);

	mInitSwitch();

	for (i=0;i<6;i++){
		MyMAC.v[i]= MY_MAC_ADDRESS[i];
	}
	//Must initialize IO before hardware
	InitPins();
	println_I("Adding IO Namespace");
	addNamespaceToList((NAMESPACE_LIST * )get_bcsIoNamespace());
	println_I("Adding IO.Setmode Namespace");
	addNamespaceToList((NAMESPACE_LIST * )get_bcsIoSetmodeNamespace());
	println_I("Adding DyIO Namespace");
	addNamespaceToList((NAMESPACE_LIST * )get_neuronRoboticsDyIONamespace());
	println_I("Adding PID Namespace");
	addNamespaceToList((NAMESPACE_LIST * )getBcsPidNamespace());
	println_I("Adding DyIO PID Namespace");
	addNamespaceToList((NAMESPACE_LIST * )get_bcsPidDypidNamespace());
	println_I("Adding Safe Namespace");
	addNamespaceToList((NAMESPACE_LIST * )get_bcsSafeNamespace());


	Init_FLAG_BUSY_ASYNC();
	//InitCTS_RTS_HO();

	//AVR Reset pin
	InitAVR_RST();
	HoldAVRReset();

	//ConfigUARTOpenCollector();
	ConfigUARTRXTristate();


	InitLEDS();
	SetColor(0,0,1);
	//Starts Timer 3
	InitCounterPins();
	InitADC();


	BYTE rev [] = {MAJOR_REV,MINOR_REV,FIRMWARE_VERSION};
	FlashSetFwRev(rev);

	//Starts co-proc uart
	initCoProcCom();

	EndCritical();
	INTEnableSystemMultiVectoredInt();

//	initBluetooth();
//	if(!hasBluetooth()){
//		Pic32UARTSetBaud( 115200 );
//	}

}