Exemplo n.º 1
0
void led(rt_uint32_t led, rt_uint32_t value)
{
    int i;
    /* init led configuration if it's not inited. */
    if (!led_inited)
    {
        rt_hw_led_init();
        led_inited = 1;
    }

    for(i = 0 ; i < 4 ; i ++)
    {
        if ( led == i )
        {
            /* set led status */
            switch (value)
            {
            case 0:
                rt_hw_led_off(i);
                break;
            case 1:
                rt_hw_led_on(i);
                break;
            default:
                break;
            }
        }
    }
}
void led(rt_uint32_t led, rt_uint32_t value)
{
    /* init led configuration if it's not inited. */
    if (!led_inited)
    {
        rt_hw_led_init();
        led_inited = 1;
    }

    if ( led == 0 )
    {
        /* set led status */
        switch (value)
        {
        case 0:
            rt_hw_led_off(0);
            break;
        case 1:
            rt_hw_led_on(0);
            break;
        default:
            break;
        }
    }

    if ( led == 1 )
    {
        /* set led status */
        switch (value)
        {
        case 0:
            rt_hw_led_off(1);
            break;
        case 1:
            rt_hw_led_on(1);
            break;
        default:
            break;
        }
    }

    if ( led == 2 )
    {
        /* set led status */
        switch (value)
        {
        case 0:
            rt_hw_led_off(2);
            break;
        case 1:
            rt_hw_led_on(2);
            break;
        default:
            break;
        }
    }
}
Exemplo n.º 3
0
static void rt_init_thread_entry(void* parameter)
{
	rt_thread_t system_thread;
	rt_uint8_t buf[256];
	/* Initialization RT-Thread Components */
#ifdef RT_USING_COMPONENTS_INIT
	rt_components_init();
#endif

	/* Set finsh device */
#ifdef  RT_USING_FINSH
	finsh_set_device(RT_CONSOLE_DEVICE_NAME);
#endif  /* RT_USING_FINSH */
	rt_hw_led1_off();
	//cmx865a_init();


	unsigned int count=1000;
	rt_memset(buf,'\0',256);
	rt_hw_led_init();
//	rt_kprintf("led on, count : %d\r\n",count);
	//rt_sprintf(buf,"%s","- RT -    Thread Operating System");
		
	//	ST7585_Write_String(0,5,"- RT -    ");
	//ST7585_Write_String(0,4,"Thread Operating System");
	//	Draw_bat(3);
	//b(0,1);
r(0);
	while (1)
	{
		
		/* led1 on */
#ifdef RT_USING_FINSH
		rt_kprintf("led on , count : %d\r\n",count);
#endif
	
		
	//	rt_sprintf(buf,"led on , count : %d",count);
	//	ST7585_Write_String(0,5,buf);

		//test_cmx865a();
		count++;
		rt_hw_led1_off();
		rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* sleep 0.5 second and switch to other thread */

		/* led1 off */
#ifdef RT_USING_FINSH
		rt_kprintf("led off\r\n");
#endif
	//	rt_sprintf(buf,"led off, count : %d",count);
	//	ST7585_Write_String(0,5,buf);

		rt_hw_led1_on();
		rt_thread_delay( RT_TICK_PER_SECOND/2 );
	}
}
Exemplo n.º 4
0
static void led_thread_entry(void* parameter)
{
		rt_uint8_t ledStatus;
	
    rt_hw_led_init();		
		ledData_mq = rt_mq_create("LEDMQ",1,2,RT_IPC_FLAG_FIFO);
		
    while (1)
    {
				if(rt_mq_recv(ledData_mq,&ledStatus,1,RT_WAITING_FOREVER) == RT_EOK)
				{
					if(ledStatus &0x10)
					{
						rt_hw_led_on(4);											
					}
					else
					{
						rt_hw_led_off(4);			
					}
					
					if(ledStatus &0x08)
					{
						rt_hw_led_on(3);											
					}
					else
					{
						rt_hw_led_off(3);			
					}
					
					if(ledStatus &0x04)
					{
						rt_hw_led_on(2);											
					}
					else
					{
						rt_hw_led_off(2);			
					}
					if(ledStatus &0x2)
					{
						rt_hw_led_on(1);											
					}
					else
					{
						rt_hw_led_off(1);			
					}
					if(ledStatus &0x01)
					{
						rt_hw_led_on(0);											
					}
					else
					{
						rt_hw_led_off(0);			
					}					
				}        			
    }
}
Exemplo n.º 5
0
static void rt_thread_entry_led1(void* parameter)
{
    int n = 0;
//	int stage=0;
    rt_uint32_t offset=0;
//	int i=2000;
//	int delta = 50;
    rt_hw_led_init();
	dac_dma();
	
	/*SIM->SCGC2 |= SIM_SCGC2_DAC0_MASK;
		DAC0->C0 |= DAC_C0_DACEN_MASK
				   |DAC_C0_DACRFS_MASK
				   |DAC_C0_DACTRGSEL_MASK;
		
		DAC0->DAT[0].DATL = stage &  0xFF;
		DAC0->DAT[0].DATH = stage >> 8;
		DAC0->C0 |= DAC_C0_DACSWTRG_MASK;
*/
    while (1)
    {
        //rt_kprintf("LED\t%d\tis shining\r\n",n);
		/*if(i==2000)
			  delta = 50;
			else if(i==4000)
			  delta = -50;
			
			i += delta;
*/
        rt_hw_led_on(n);
        rt_thread_delay(RT_TICK_PER_SECOND/2);
		/*rt_kprintf("i is %d\r\n",i);
		DAC0->DAT[0].DATL = i &  0xFF;
		DAC0->DAT[0].DATH = i >> 8;
		DAC0->C0 |= DAC_C0_DACSWTRG_MASK;*/
	if(!Mem_Check(offset))
		//rt_kprintf("offset %x test ok\r\n",offset);
	//else
		rt_kprintf("offset %x test failed\r\n",offset);
	offset++;
	if(offset==0x10000)
		offset=0;
        rt_hw_led_off(n);
        rt_thread_delay(RT_TICK_PER_SECOND/2);

        n++;
		//stage=stage+100000;
        if (n == (LED_MAX+1))
            n = 0;
    }
}
Exemplo n.º 6
0
static void rt_thread_entry_led1(void* parameter)
{
    int n = 0;
    rt_hw_led_init();

    while (1)
    {
        //rt_kprintf("LED\t%d\tis shining\r\n",n);

        rt_hw_led_on(n);
        rt_thread_delay(RT_TICK_PER_SECOND/2);
        rt_hw_led_off(n);
        rt_thread_delay(RT_TICK_PER_SECOND/2);

        n++;

        if (n == LED_MAX)
            n = 0;
    }
}
static void led_thread_entry(void* parameter)
{
    unsigned int count=0;

    rt_hw_led_init();

    while (1)
    {
        /* led1 on */
#ifndef RT_USING_FINSH
        rt_kprintf("led on, count : %d\r\n",count);
#endif
        count++;
        rt_hw_led_on(0);
        rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* sleep 0.5 second and switch to other thread */

        /* led1 off */
#ifndef RT_USING_FINSH
        rt_kprintf("led off\r\n");
#endif
        rt_hw_led_off(0);
        rt_thread_delay( RT_TICK_PER_SECOND/2 );
    }
}
Exemplo n.º 8
0
/**
 * This function will initial STM32 Radio board.
 */
void rt_hw_board_init(void)
{
    /* Configure the system clocks */
    SystemInit();

#ifndef STM32_SIMULATOR
    all_device_reset();
#endif

    /* NVIC Configuration */
    NVIC_Configuration();

    /* Configure the SysTick */
    SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND );

    /* Console Initialization */
    rt_hw_usart_init();
    rt_console_set_device("uart1");

	/* Led Initialization */
	rt_hw_led_init();

    rt_kprintf("\r\n\r\nSystemInit......\r\n");
}
Exemplo n.º 9
0
void rt_init_thread_entry(void *parameter)
{
    rt_device_t lcd;  
    
    rt_hw_led_init();
	rt_hw_key_init();
	rt_hw_adc_init();
	rt_hw_lcd_init();      
	rt_hw_cpu_init();

#ifdef RT_USING_RTGUI
	extern void rtgui_system_server_init(void);

	/* find lcd device */
	lcd = rt_device_find("lcd");    
    
	/* set lcd device as rtgui graphic driver */		
	rtgui_graphic_set_device(lcd);

	/* init rtgui system server */
	rtgui_system_server_init();
   
	/* startup rtgui */
	rtgui_startup();
#else
	{
	char buf[20] = {'\0'};
    struct lcd_msg msg;
    rt_device_t device;   
    device = rt_device_find("lcd");
	rt_device_control(device, RT_DEVICE_CTRL_LCD_CLEAR_SCR, RT_NULL);
	x = 1;
	y = 1;
	rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, "ADC"); 
	x = 1;
	y = 20;
	rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, "CPU");
	x = 1;
	y = 40;
	rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, "KEY");
    
    while(1)
    {
        if (rt_mq_recv(&mq, &msg, sizeof(msg), RT_WAITING_FOREVER) == RT_EOK)
        {
        	switch(msg.type)
    		{
    			case ADC_MSG:
					x = 40;
					y = 1;
					rt_memset(buf, 0, sizeof(buf));
					rt_sprintf(buf, "%04d", msg.adc_value);
					rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, buf); 
					break;
				case CPU_MSG:
					x = 40;
					y = 20;
					rt_memset(buf, 0, sizeof(buf));
					rt_sprintf(buf, "%03d %03d", msg.major, msg.minor);
					rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, buf); 
					break;
				case KEY_MSG:
					x = 40;
					y = 40;
					rt_memset(buf, 0, sizeof(buf));
                    switch(msg.key)
                	{
                		case KEY_DOWN:
							rt_sprintf(buf, "DOWN KEY ");
							break;
						case KEY_UP:
							rt_sprintf(buf, "UP KEY   ");
							break;	
                		case KEY_RIGHT:
							rt_sprintf(buf, "RIGHT KEY");
							break;
						case KEY_LEFT:
							rt_sprintf(buf, "LEFT KEY ");
							break;	
                		case KEY_ENTER:
							rt_sprintf(buf, "ENTER KEY");
							break;
						default:
							rt_sprintf(buf, "NO KEY   ");
							break;								
                	}
					rt_device_control(device, RT_DEVICE_CTRL_LCD_PUT_STRING, buf); 
                    break;                    
    		}
        }
    }
	}
#endif
}