Ejemplo n.º 1
0
int main( void )
{
    WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
    BCSCTL1=0x00; //&= ~XT2OFF; // XT2= HF XTAL
    do{
      IFG1 &= ~OFIFG; // Clear OSCFault flag
      for (int i = 0xFF; i > 0; i--); // Time for flag to set
    }while ((IFG1 & OFIFG)); // OSCFault flag still set?
    BCSCTL2 |= SELM_2+SELS; // MCLK=SMCLK=XT2 (safe)

//Init System Service    
    InitialPort();
    InitFileSystem();
    Init_Pipe();
    InitTB();
//Init Device    
    InitialRTC();        
    Init_UART();
    InitADC();
    Creat_Command_Task();                   //After the bluetooth has beed connected
    SCH_Init();
   SCH_Start();

//    SCH_Add_Task(Task_UART_Send,0,5);       //creat a task for sending data via uart,after bluetooth connect
//   SCH_Add_Task(Acquire_ECG,0,4);      //32768/4*32 = 256hz
//    CommandSwitchList(1);

    while(1){
        SCH_Dispatch_Task();
    }
}
Ejemplo n.º 2
0
GOOD_OR_BAD W1_detect(struct port_in *pin)
{
	struct connection_in * in = pin->first ;

	/* Set up low-level routines */
	pin->type = ct_none ;
	W1_setroutines(in);
	Init_Pipe( in->master.w1.netlink_pipe ) ;

	if ( pipe( in->master.w1.netlink_pipe ) != 0 ) {
		ERROR_CONNECT("W1 pipe creation error");
		Init_Pipe( in->master.w1.netlink_pipe ) ;
		return gbBAD ;
	}

	in->Adapter = adapter_w1;
	in->adapter_name = "w1";
	pin->busmode = bus_w1;
	in->master.w1.seq = SEQ_INIT;
	return gbGOOD;
}
Ejemplo n.º 3
0
/* Device-specific functions */
GOOD_OR_BAD ENET_monitor_detect(struct port_in *pin)
{
	struct connection_in * in = pin->first ;
	struct address_pair ap ;
	pthread_t thread ;
	
	/* init_data has form "scan" or "scan:15" (15 seconds) */
	Parse_Address( pin->init_data, &ap ) ;
	in->master.enet_monitor.enet_scan_interval = DEFAULT_ENET_SCAN_INTERVAL ;
	switch ( ap.entries ) {
		case 0:
			in->master.enet_monitor.enet_scan_interval = DEFAULT_ENET_SCAN_INTERVAL ;
			break ;
		case 1:
			switch( ap.first.type ) {
				case address_numeric:
					in->master.enet_monitor.enet_scan_interval = ap.first.number ;
					break ;
				default:
					in->master.enet_monitor.enet_scan_interval = DEFAULT_ENET_SCAN_INTERVAL ;
					break ;
			}
			break ;
		case 2:
			switch( ap.second.type ) {
				case address_numeric:
					in->master.enet_monitor.enet_scan_interval = ap.second.number ;
					break ;
				default:
					in->master.enet_monitor.enet_scan_interval = DEFAULT_ENET_SCAN_INTERVAL ;
					break ;
			}
			break ;
	}
	Free_Address( &ap ) ;

	pin->type = ct_none ;

	// Device name will not be init_data copy
	SAFEFREE(DEVICENAME(in)) ;
	DEVICENAME(in) = owstrdup("ENET bus monitor") ;

	pin->file_descriptor = FILE_DESCRIPTOR_BAD;
	in->iroutines.detect = ENET_monitor_detect;
	in->Adapter = adapter_enet_monitor;
	in->iroutines.reset = NO_RESET_ROUTINE;
	in->iroutines.next_both = NO_NEXT_BOTH_ROUTINE;
	in->iroutines.PowerByte = NO_POWERBYTE_ROUTINE;
	in->iroutines.ProgramPulse = NO_PROGRAMPULSE_ROUTINE;
	in->iroutines.sendback_data = NO_SENDBACKDATA_ROUTINE;
	in->iroutines.sendback_bits = NO_SENDBACKBITS_ROUTINE;
	in->iroutines.select = NO_SELECT_ROUTINE;
	in->iroutines.select_and_sendback = NO_SELECTANDSENDBACK_ROUTINE ;
	in->iroutines.set_config = NO_SET_CONFIG_ROUTINE;
	in->iroutines.get_config = NO_GET_CONFIG_ROUTINE;
	in->iroutines.reconnect = NO_RECONNECT_ROUTINE;
	in->iroutines.close = ENET_monitor_close;
	in->iroutines.verify = NO_VERIFY_ROUTINE ;
	in->iroutines.flags = ADAP_FLAG_sham;
	in->adapter_name = "ENET scan";
	pin->busmode = bus_enet_monitor ; // repeat since can come via usb=scan
	
	Init_Pipe( in->master.enet_monitor.shutdown_pipe ) ;
	if ( pipe( in->master.enet_monitor.shutdown_pipe ) != 0 ) {
		ERROR_DEFAULT("Cannot allocate a shutdown pipe. The program shutdown may be messy");
		Init_Pipe( in->master.enet_monitor.shutdown_pipe ) ;
	}
	if ( BAD( ENET_monitor_in_use(pin) ) ) {
		LEVEL_CONNECT("Second call for ENET scanning ignored") ;
		return gbBAD ;
	}

	if ( pthread_create(&thread, DEFAULT_THREAD_ATTR, ENET_monitor_loop, (void *) in) != 0 ) {
		ERROR_CALL("Cannot create the ENET monitoring program thread");
		return gbBAD ;
	}

	return gbGOOD ;
}