Ejemplo n.º 1
0
int main(void) {

    unsigned char input;

    ANSEL=0;
    ANSELH=0;
    CM1CON0=0;
    CM2CON0=0;

    INTCON=0;   // DESABILITA AS INTERRUPCOES

    init_comms();    // prepara a USART com configuracoes definidas em usart.h

    while (1==1)
    {
        unsigned char count;
        for ( count=0x31; count <= 0x39; count=count+1)
        {
            putch(count);
            input = getch();
            putch(input);

        }
        while (1)
        {
            printf("Press a key and I will echo it back:\r\n");
            input = getch();
            printf("I detected [%c]\r\n",input);

        }
    }

    return 0;
}
Ejemplo n.º 2
0
void init()
{
	INTCON=0;	// purpose of disabling the interrupts.
	OSCCON = 0xE8;
	PORTA = 0;
	LATA = 0;
	ANSELA = 0;
	TRISA = TRISS_;  //Set RA<5:0> as Outputs

#ifdef __1822__

	APFCON = 0b00000000;
	TRISA2 =0;
	TRISA4 =0;
	TRISA3 = 1;
//	APFCON = 0b11000111;
//	APFCON = 0b10000100;
	

#else
	ANSELB = 0;
#endif

	init_comms();	// set up the USART - settings defined in usart.h
	Init_timer1();
	initInts();

}
Ejemplo n.º 3
0
static int setupEMBXAndOS() 
{
	EMBX_FACTORY hFact;
	EMBX_TRANSPORT hTrans;
	EMBX_PORT masterPort;
	int status = 0;

	/*
	 * Start OS21
	 */
	kernel_initialize(NULL);
	kernel_start();
	kernel_timeslice(OS21_TRUE);

	if(init_mailboxes() < 0) { 
		printf("Failed to initialize mailboxes\n");
		status = 1;
		goto exit;
	}

	if(init_comms(&hFact,&hTrans,&masterPort) < 0) {
		printf("Failed to initialize embx comms\n");
		status = 1;
	}
 exit:
	return status;
}
Ejemplo n.º 4
0
void init(void){

    OSCCON = 0b01100000;	//set frequency to 4MHz
    TRISA = 0x0F;               //
    TRISB = 0b000000100;         // set RB2 as input
    ANSEL = 0x00;               // ignore this

    init_comms(); //Prepare the usart
}
Ejemplo n.º 5
0
int main()
{
    DWORD exit_code = STILL_ACTIVE;
    atexit(application_exit);

    // Set security attributes for the Child Process (Output.exe)
    SECURITY_ATTRIBUTES security_attributes = {}; 
    security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES); 
    security_attributes.bInheritHandle = TRUE; 
    security_attributes.lpSecurityDescriptor = NULL;  
    CreatePipe(&output_pipe_read, &output_pipe_write, &security_attributes, 0);
    SetHandleInformation(output_pipe_write, HANDLE_FLAG_INHERIT, 0);

    // Assigns startup information for the Child Process (Output.exe)
    STARTUPINFO startup_info = {};
    startup_info.cb = sizeof(STARTUPINFO);
    startup_info.hStdInput = output_pipe_read;
    startup_info.dwFlags = STARTF_USESTDHANDLES;
    CreateProcess(NULL, "Output", NULL, NULL, TRUE,
        CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT, NULL, NULL,
        &startup_info, &process_information);

    // Prints welcome banner for LanComms user
    std::cout <<
        "/---------------------------------------------------------\\\n"
        "|                                                         |\n"
        "|                 --Welcome to LanComms--                 |\n"
        "|                      Version 1.3.2                      |\n"
        "|         Copyright (c) 2012 by Christopher Harpum        |\n"
        "|                                                         |\n"
        "|  -PRESS ESCAPE TO RETURN TO PREVIOUS MENU AT ANY TIME-  |\n"
        "|                                                         |\n"
        "\\---------------------------------------------------------/\n\n";

    // Super loop
    while (application_alive) {
        GetExitCodeProcess(process_information.hProcess, &exit_code);
        if (exit_code != STILL_ACTIVE) {
            break;
        } else if (needs_restart) {
            init_comms();
        } else {
            process_user_messages();
            receive_messages();
            transmit_messages();
        }
        Sleep(5);
    }

    // Application has requested to quit so print leaving message and close down
    std::cout <<
        "\n\n----------------------------------------\n\n"
        "Exiting Application...";

    return 0;
}
Ejemplo n.º 6
0
void init(void){

    OSCCON = 0b01100000;	//set frequency to 4MHz
    TRISA = 0x00;               // set all pins in PORTA as outputs
    TRISB = 0b000000100;         // set RB2 as input
    ANSEL = 0x00;               // ignore this

    PORTA = 0x00;
    PORTB = 0x00;

    init_comms(); //Prepare the usart
}
Ejemplo n.º 7
0
void init(void)
{
	CMCON = 0b00000111; //cut off analog comparator just add this one
	OSCCON = 0b01111010;
	INTCON=0;	// purpose of disabling the interrupts.
	ANSEL = 0b00000010;
	TRISA = 0b00000010;	//RA3 is input only. RA3 is direct. RA2(INT) is interrupt by clock
	PORTA = 0x00;

	init_comms();	// set up the USART - settings defined in usart.h
	adc_init();
	adc_itrpt_init();
}
Ejemplo n.º 8
0
Archivo: main.c Proyecto: wheelerz/ento
void main(void){
	unsigned char input;

	INTCON=0;	// purpose of disabling the interrupts.

	init_comms();	// set up the USART - settings defined in usart.h

	// Output a message to prompt the user for a keypress	
	printf("\rPress a key and I will echo it back:\n");
	while(1){
		input = getch();	// read a response from the user
		printf("\rI detected [%c]",input);	// echo it back
	}
}
Ejemplo n.º 9
0
Archivo: main.c Proyecto: SeaPea/HomeP
void handle_init(void) {
  g_device_id_list = NULL;
  show_mainwin();
  show_msg("HomeP\n\nLogging In...", true, 0);
  comms_register_errorhandler(comms_error);
  comms_register_devicelist(device_list_fetched);
  comms_register_devicedetails(device_details_fetched);
  comms_register_devicestatus(device_status_fetched);
  comms_register_devicestatusset(device_status_change_sent);
  ui_register_deviceswitch(device_switched);
  ui_register_statuschange(device_status_change);
  reset_inactivity_timer();
  // Initializing comms will trigger phone JS to fetch device list
  init_comms();
}
Ejemplo n.º 10
0
void S_Init()
{
	init_memory_manager();
	init_streaming();
	init_sound_engine();
	init_comms();
	init_reverb();
	init_waves();
	init_voices();

	// Load the banks.
	AK::SoundEngine::LoadBank(AK::BANKS::INIT, AK_DEFAULT_POOL_ID);
	AK::SoundEngine::LoadBank(AK::BANKS::GLOBAL, AK_DEFAULT_POOL_ID);

	snd_initialized = qtrue;
}
void main(void)
{
	unsigned char input;

	init_comms();

	printf("\nThis programs was writed using HITECH PICC LITE compiler");	
	printf("\rPress a key and I will echo it back:\n");
	
	while(1){

		input = getch();	// read a response from the user
		printf("\rI detected [%c]",input);	// echo it back

		
	}
}
Ejemplo n.º 12
0
void main() {

	unsigned char input;

	init_comms();
	puts("\nThis program was writed using SDCC compiler");
	puts("\rPress a key and I will echo it back:\n");
	while(1)
	{
		input = getch();	// read a response from the user
		puts("\rI detected [");
		putch(input);
		putch(']');

	}

}
Ejemplo n.º 13
0
static int _init_cluster(void)
{
	int r;

	if (!(_locks = dm_hash_create(128))) {
		DEBUGLOG("Failed to allocate single-node hash table.\n");
		return 1;
	}

	r = init_comms();
	if (r) {
		dm_hash_destroy(_locks);
		return r;
	}

	DEBUGLOG("Single-node cluster initialised.\n");
	return 0;
}
Ejemplo n.º 14
0
/*
   ** Place the camera in remote mode. In this mode, "PC CONNECTED"
   ** will be displayed on the camera's screen.
 */
static int 
SDSC_Initialise (void)
{

  fd = open (serial_port, O_RDWR);

  if (fd < 0)
    {
      error_dialog ("Couldn't open camera device");
      return 1;
    }

  if (init_comms (fd))
    {
      error_dialog ("Couldn't init comm port");
      return 1;
    }
  return 0;

}
Ejemplo n.º 15
0
int main (void)
{
	init();
	pwm_init(1000, 1);
	init_comms();
	char str[5] = {0};
	int duty = 0;
	int cnt,i;
	
	while(1)
	{
		pwm_set_duty(duty / 10);
		cnt = 0;
		do{
			str[cnt] = getche();
			cnt ++;
		}while(str[cnt -1] != 0x0d);
		
		duty = atoi(str);
		printf("set to %d\r\n", duty);
		printf("PR2: %x\r\n", PR2);
		printf("freq: %d\r\n", (unsigned int)(_XTAL_FREQ / ((PR2+1) * 4)));
		
		/* fuwafuwa
		if(i>=100)
		cnt = 0;
		else if(i<=0)
		cnt = 1;
		if(cnt > 0)
		pwm_set_duty(i++);
		else if(cnt <= 0)
		pwm_set_duty(i--);
		
		__delay_ms(20);
		*/
	}	
	return 0;
}
Ejemplo n.º 16
0
/**
*@brief The main function that intializes the system and communicates with the BT module
*@retval None
*@note The blueToothConfig function needs only be called once to setup the module.
*/
void main(void)
{
	init_comms(); 	//Setup UART
	init(); 		//Setup IO, Interupts, and Special UART

	RINGER_HARDWARE = 0; // make sure we are in low power mode
	
	DelayMs(500);
	
//	blueToothConfig(); //Configure BT Module
	CREN = 0;
	while(1)
	{		
	//	sendString("PIC ON\r\n");			
		while(!connected)
		{
			//Clear message & setup for recieve
			for(i = 0; i<MAX_MESSAGE_SIZE; i++)
			{
				message[i] = 0;
			}
			messageIndex = 0;
			messageComplete = 0;
		//	sendString("Waiting for Phone to Connect\r\n");			
			DelayMs(500);
			CREN = 1; //Enable UART interupt for message recieve
			RCIE = 1;
			while(!messageComplete); //wait to recieve message
			RCIE = 0;
			CREN  = 0; //Process message

			if( strnicmp(message, "RING 0",6) == 0 )
			{
				connected = 1; //We are connected so change flag
				ring(SHORT_RING); //Signals User
			}
		
			//Prep ISR for next read	
			for(i = 0; i<MAX_MESSAGE_SIZE; i++)
			{
				message[i] = 0;
			}
			messageIndex = 0;
			messageComplete = 0;
		}

		//	sendString("CONNECTED TO PHONE\r\n");
			DelayMs(500);
			DelayMs(500);
			DelayMs(500);
			DelayMs(500);

			
		while(connected)
		{

			while( HOOK == 0)
			{
				for(i = 0; i<MAX_MESSAGE_SIZE; i++)
				{
					message[i] = 0;
				}
				messageIndex = 0;
				messageComplete = 0;
				
				CREN = 1;
				RCIE = 1;			
				while(!messageComplete && HOOK == 0); //check if the ISR is finished
				RCIE = 0; //Process Message
				CREN = 0;
				
				//Check if there is an incoming call
				if(strnicmp(message, "HFP 0 RING", 10) == 0 )
				{
					DelayMs(500);
					incomingCall();
				}
				//check if we disconnected aswell
				/*
				else if(strnicmp(message, "NO CARRIER 0", 12) == 0)
				{
					connected = 0;
					break; //Leave the loop so we can restablish a connection
				}
				*/

			}
			call();
		}
			
	}

}	
Ejemplo n.º 17
0
/*******************************************************************************
*  ??????                                                                *
*******************************************************************************/
void main()
{

    char individual=255;
     setpin();
     init_comms();
     individual=E2promRead(0x00);
     OPTION_REG = 0b0000010 ; // ??????(Fosc/4)?TIMER0???????????????? 1:128
     TMR0   = T0COUT ;         // ????0????
     TMR0IF = 0 ;              // ????0?????(T0IF)?0???
     time   = 0 ;              // ??????????????0???
     TMR0IE = 1 ;              // ????0???(T0IE)?????
     WPUB = 0xC0;
     nWPUEN = 0;
     GIE    = 0 ;              // ???????????
//     while(individual==getch()){
//         putch(individual);
//         __delay_ms(100);
//     }
     uartget();
     while(1)
     {
         while(RD4==0);
         change();
         while(RD4==1);
         change();
     }

    PORTA=0xFF;
    PORTB=0xFF;
    PORTC=0xFF;
    PORTD=0xFF; 
    PORTE=0xFF;
        RA7=0;
        RA6=0;
        RC0=0;
        RC1=0;
        RC2=0;
        RC3=0;
        RD0=0;
        RD1=0;
        i=1;0;
        RD6=1;
     while(1){
         while(RD4==0);
         if(RD5==1)
             i=8;
         //__delay_ms(500);
         switch(i){
            case 1:RA7=1;break;
            case 2:RA6=1;break;
            case 3:RC0=1;break;
            case 4:RC1=1;break;
            case 5:RC2=1;break;
            case 6:RC3=1;break;
            case 7:RD0=1;break;
            case 8:RD1=1;i=0;break;
         }
         //__delay_ms(500);
         while(RD4==1);

        RA7=0;
        RA6=0;
        RC0=0;
        RC1=0;
        RC2=0;
        RC3=0;
        RD0=0;
        RD1=0;
        PORTC=0b11110000;
        PORTA=0b00111111;
        PORTD=0b11111100;

         i++;
    }
}
Ejemplo n.º 18
0
void main()
{
     char i,j,n,test[8][4],individual=255;
     char getdata[70]={0},getKeeping[16][2],getNum=0,onetime=0,resetFlug=0,gettingSuccess=0;
     setpin();
     while(1){
         RD6=1;
         getch();
         RD6=0;
         __delay_ms(100);
     }
     init_comms();
     individual=E2promRead(0x00);
     for(i=0;i<16;i++)
      putdata[i][1]=x2(i);
     OPTION_REG = 0b0000100 ; // ??????(Fosc/4)?TIMER0???????????????? 1:128
     TMR0   = T0COUT ;         // ????0????
     TMR0IF = 0 ;              // ????0?????(T0IF)?0???
     time   = 0 ;              // ??????????????0???
     TMR0IE = 1 ;              // ????0???(T0IE)?????
     WPUB = 0xC0;
     nWPUEN = 0;
     
     
     
     
     GIE    = 1 ;
     while(1) {
         // 0x 47 65 74 ="Get"
         if(getNum>69)
             getNum=0;
         else if(reservingNow){
             onetime=getch();
             getdata[getNum]=onetime;
             getNum++;
             reservingNow=0;
         }
         if(onetime==0x47)
             resetFlug=1;
         else if(resetFlug){
             if(resetFlug==1){
                 if(onetime==0x65)
                     resetFlug==2;
                 else
                     resetFlug=0;
             }
             else if(resetFlug==2){
                 if(onetime=0x74)
                     getNum=0;
                 else
                     resetFlug=0;
             }
         }
         if(getNum==64){
             if(onetime==0x0A)
                 gettingSuccess=1;
         }
         else if(gettingSuccess==1){
             if(onetime==0x0B)
                 gettingSuccess=2;
             else
                 gettingSuccess=0;
         }
         if(gettingSuccess==2){
             gettingSuccess=0;
             for(i=1;i<17;i++){
                 for(j=0;j<2;j++){
                     n=(i-1)*4+j;
                     getKeeping[i][j]=getdata[n];
                 }
             }
             for(i=1;i<17;i++){
                 //A
                 putdata[i][0]=getKeeping[i][0]&0b11111110;
                 //C
                 putdata[i][2]=getKeeping[i][1]&0b00001111;
                 //D
                 putdata[i][3]=(getKeeping[i][0]&0b00000001)|((getKeeping[i][1]&0b10000000)>>6);
                 if(i==16)
                     putdata[i][3]=putdata[i][3]|0b10110000;
                 else if(i%2==0)
                     putdata[i][3]=putdata[i][3]|0b10010000;
                 //E
                 putdata[i][4]=(getKeeping[i][1]&0b01110000)>>4;
             }
         }
     }