示例#1
0
文件: main.c 项目: kingbeful/AVRusb
//#ifdef DEBUG
//#include <stdio.h>
//#endif
int main(void)
{
//    #ifdef DEBUG
//    printf ("Start the Main Function\n");
//    #endif
    wdt_disable();
    // Insert code
    RF_init();
//    SPI_MasterTransmit(data);
    while(1)
    ;

    return 0;
}
示例#2
0
文件: main.c 项目: AubrCool/ble-1
int main()
{
	int i;

#ifdef FPGA 
	pll_init();
#else
	bt16_pll_init();
#endif
    delay(500000);

    uart_init((96000000/ 460800));  // pa8
    puts(pubDate);
    puts("...fpga bt16 setup ok.......\n");

#ifdef FPGA 
	spi_int();  
#endif
    puts("-----1\n");
	system_init();

    puts("-----2\n");
	timer0_start();

    puts("-----3\n");
	RF_init();

    //----------debug
    HWI_Install(1, exception_isr, 3) ; //timer0_isr
    

	ENABLE_INT();

    puts("-----4\n");
	thread_init(os_create_thread, os_delete_thread);

    puts("-----5\n");
	sys_timer_init();

    puts("-----6\n");
    ble_main();
    btstack_main();

	/* device_manager_init(); */

	/*INTALL_HWI(BT_BLE_INT, le_hw_isr, 0);
	INTALL_HWI(18, le_test_uart_isr, 0);*/

	lbuf_init(malloc_buf, sizeof(malloc_buf)*4);

	/* btstack_v21_main(); */

    puts("------------4.0 start run loop-----------\n");
    while(1)
    {
		int c;
       //asm("idle");
	   /*delay(100000);*/
		for (i=0; i<PRIORITY_NUM; i++)
		{
			if (thread_fun[i]){
				thread_fun[i](i);
			}

		}
        c = getchar();
        switch(c)
        {
            case 'A':
                puts("user cmd : ADV\n");
                ble_set_adv();
                break;
            case 'S':
                puts("user cmd : SCAN\n");
                ble_set_scan();
                break;
            default:
                break;
        }

		/*run_loop_execute();*/
	   /*printf("k");*/
    }

    return 0;
}
示例#3
0
int 
main(void){
	
	SCS |= 0x01;
	
	FIODIR0 = 0;	/* Just to make sure that all pins on Port0 are input. */
	
	/* The following pins are output: */
	FIODIR0 |= ((1<<21) | BACKLIGHT_PWM_PIN | SOUND_ENABLE_PIN | (1<<6));
	
	/* TODO what is this pin for ? */
	FIODIR0 |= (1<<12);
	FIOSET0 = (1<<12);

	setSpeed(SPEED_30);
		
	rand_seed(13); 				// initialize the random number generator
	
	/* Initialize the kernel. Kernel is not running yet */
	kernel_init();

	/* Initialize the display */
	lcd_init(0);
	
	/* Initialize the serial port */
	serial_init(38400);
	task_add(&serial_out);					// Task 0
	
	/* Enable IRQs. Now IRQ service routines start to run */
	enableIRQ();
	
	/* Enable radio communication */
	RF_init();								// Task 1 == produce_send_token)

	/* Initialize backlight task */
	inactivity_cnt = 0;		// consider power on to be a user activity
	task_add(&backl_proc);					// Task 2
	startPWMIRQ();

	/* Initialize keyboard handling */
	key_init();								// Task 3 == key_scan()

	/* Build an initial model of the internal and external state of the world */
	model_init();							// Task 4 == update_playtime()
	
	/* Show something to the user depending on model */
	mainscreen_init();						// Task 5 == win_scroll_all()
	
	dbg("RESET");
	
	/* Start the controller task 
		- keeps model up to date
		- starts actions according to model
		- shows relevant information on the screen
	*/
	task_add(&controller);					// Task 6
											// Task 7 == assemble_line()
	
	/* Start the kernel scheduler */
	while(1){
		schedule();
	};

	return 0;
}
示例#4
0
文件: main.c 项目: elmo2k3/McBetty
int main(void)
{
	sysInfo = 0;
	
	SCS |= 0x01;
	FIODIR0 |= ((1<<21) | (1<<4) | (1<<11) | (1<<6) | (1<<23) | (1<<19) | (1<<17));
	FIODIR0 |= (1<<12);
	FIOSET0 |= (1<<12);
	xx = 0x00;

	setSpeed(SPEED_30);

	lcd_init(0);
	serial_init();

	startTimerIRQ();
	startADC();

	initKeys();

	initSound();
	startSoundIRQ();

	initIR();
	startIrIRQ();

    RF_init();
    startcc1100IRQ();
	enableWOR();
	
	initRTC();
	startRtcIRQ();
	
	enableIRQ();

	testmenu_init();
	init_menu();
	
	initBacklight();

	oldkeys[0] = keys[0];
	oldkeys[1] = keys[0];

	key_state = KEY_IDLE;

	set_font(BOLDFONT);
	
	BFS_Mount();
	load_RC_setting();
	load_RF_setting();
	load_setting();
	
	{
		struct RAWset_ RAWset;
        unsigned char x;
        unsigned long RAWcmdbase;
        
        RAWcmdbase = FLASH1_BASE +(secaddr[0]<<1);
        x=memcmp((void*)RAWcmdbase,"RC01",4);
		
        if(!x) {
               
				memcpy(&RAWset,(void *)RAWcmdbase,sizeof(struct RAWset_));
				RAWset.name[7] = 0;
				BFS_SaveFile(BFS_ID_RAWslot0, sizeof(struct RAWset_), (unsigned char*) &RAWset);
				eraseSector(1,0);
        }
	}
	
	if (EncIsValid(irDevTab.device[irDevTab.active].encoder, irDevTab.device[irDevTab.active].set)) {
		setEncoder(irDevTab.device[irDevTab.active].encoder, irDevTab.device[irDevTab.active].set);
	}	
	
	drawMainscreen();
	ask_for_time(0);
	
						
/*
	playSound((unsigned char*)sound1_data, sound1_len);
	waitSound();
	playSound((unsigned char*)sound2_data, sound2_len);
*/

	while (1)
	{
		if(keys[0] != oldkeys[0] || keys[1] != oldkeys[1])
		{
			oldkeys[0] = keys[0];
			oldkeys[1] = keys[1];
			sysInfo |= 0x40;
		}

		switch(key_state)
		{
			case KEY_IDLE:
				if(sysInfo & 0x40)
				{
					sysInfo &= 0xBF;
					if(KEY_Betty)
					{
						setBacklight(BL_AUTO);
						menu_exec(&mainMenu);
						if (EncIsValid(irDevTab.device[irDevTab.active].encoder, irDevTab.device[irDevTab.active].set)) {
							setEncoder(irDevTab.device[irDevTab.active].encoder, irDevTab.device[irDevTab.active].set);
						}
						drawMainscreen();
					}
					else if(KEY_2)
					{
						//setSpeed(SPEED_30);
					}
					else if(KEY_3)
					{
						//setSpeed(SPEED_60);
					}
					else  if(KEY_A || KEY_B || KEY_C || KEY_D)
					{
						unsigned char x;
						//playSound((unsigned char*)sound3_data, sound3_len);
						x=0;
						if (KEY_B) x=1;
						if (KEY_C) x=2;
						if (KEY_D) x=3;
						
						if (EncIsValid(irDevTab.device[x].encoder, irDevTab.device[x].set)) {
							setBacklight(BL_AUTO);
							irDevTab.active = x;
							setEncoder(irDevTab.device[x].encoder, irDevTab.device[x].set);
							drawMainscreen();
						}	
					}
/*					else if(KEY_B)
					{
					
					}
					else if(KEY_C)
					{	
//						playSound((unsigned char*)sound1_data, sound1_len);
					}
					else if(KEY_D)
					{	
//						playSound((unsigned char*)sound2_data, sound2_len);
					}*/
					if((keys[0] != 0) || (keys[1] != 0))
						key_state = KEY_PRESS;
				}
				break;
			case KEY_PRESS:
				irSend(getCode());
				key_state = KEY_HOLD;
//				autorepeat = 0;
				break;
			case KEY_HOLD:
//				if(autorepeat >= AUTO_TIMEOUT)
					irRepeat();

				if(keys[0] == 0 && keys[1] == 0)
					key_state = KEY_RELEASE;

				break;
			case KEY_RELEASE:
				irStop();
				key_state = KEY_IDLE;
				break;
		}

		if(serial_tstc() > 0)
		{
			i = serial_getc();
			if(i=='.')
			{
				serial_puts("HELO");
			}
			else if(i=='0')
			{
				setBacklight(0x00);	// pwm value
			}
			else if(i=='1')
			{
				setBacklight(0x1F);	// pwm value
			}
			else if(i=='2')
			{
				setBacklight(0x3F);	// pwm value
			}
			else
				serial_putc(i);
		}
		
		if ((bl_val == 0) && (key_state == KEY_IDLE) && !((FIOPIN0 & (1<<30)) == 0) && (((RFstatus & (WORrxon | RXenabled)) == 0))) {
			EXTINT = 0x08;
			PCON = 0x02;
			PLLFEED = 0xAA;
			PLLFEED = 0x55;
		}
		
		if (timeInfo & timechanged) {
			printTime(86,152,(struct time_ *)&time);
			printDate(0,152,(struct date_ *)&date,0);
			
			timeInfo &= ~timechanged;
		}
		
	}
	return 0;
}