Example #1
0
void delay1ms_show (unsigned int a, unsigned int val) { // 1ms延时程序(12MHz 10倍于51单片机速度时)
    unsigned int i;
    while( --a != 0) {
        for(i = 0; i < 600; i++);
        show_byte((cmd_func << 8) | (val & 0xff));
    }
}
void led_test_pattern()
{
	a = 0x00;
	while (1) 
	{
		a += 0x11;
		msg1.data[0] = a;
		show_byte( a, 0 );
		delay(one_second/2);
	}
}
Example #3
0
void main()
{
    unsigned short val = 0;
    unsigned int show_data = 0;
    //unsigned short last_data = 0;
    uart2_init();
    init_led();
    init_motor();
    init_steering();
    init_speed();
    show_byte(0);

    //led_vcc_on();
    while(1) {
        //		show_byte(0x12,1);

        if((uart_data >= '0') && (uart_data <= 'z')) {
            //last_data = val;
            val = uart_data;
        }
        //show_data = (cmd_func << 8) | (val & 0xff);
        show_data = ((left_dis << 8)&0xff00) | (right_dis & 0xff);
        //show_data = (left_diff << 8) | (right_diff & 0xff);

        show_byte(show_data);

        if(sg_flag == 1) {
            sg_flag = 0;
            delay1ms_show(1000 * 3,show_data);
            if(sg_flag == 0) { //maybe call up() twice in 3s
                stop_sg();
            }


        }
        //uart2_send('a');
        //uart2_send('b');
        //uart2_send('c');
    }
}
//***** main *****************************************************
int main(void)
{
	union uKeyRoster scan;
	
    chip_init();    // Chip initialization
	can_init();		/* Enables Mob0 for Reception! */
	can_init_test_msg();
	byte result = CANSTMOB;
	
	send_test_msgs();
	/* TEST A)  Initial Board Alive test, call this below.  Watch LEDs go. 
	led_test_pattern();	*/
	/* B) Enable Receive Interrupts and call Show_byte() in the ISR.
		ALL CODE IS IN ISR()	*/
	while (1) {};
	
    while (1)
    {  	  
		wait_for_press();
		
		// Result is stored in prev_keys & keys and hopefully keys2
		scan = pack_array( keys );
		can_prep_button_roster_msg( &msg1, scan );
        can_send_msg( 0, &msg1 );
		show_byte( scan.array[0], 1 );

//		result = CANEN2;		// shows MOb n in use   mob1 is staying "in use" after 1 can_tx()
//		result = CANSTMOB;		// shows TXOK or ERRs   BERR staying on instead of TXOK 
//		result = CANGSTA;		// shows TXOK or ERRs   TXBSY blinking (retires?)
//		result = 0x83;
//		result = scan.array[0];	
//		show_byte( a, 1 );
		// [0] upper nibble is front row
		// [0] lower        is top row
		// [1] upper nibble is 2nd row
		// [1] lower        is 3rd row
		// [2] upper nibble is 4th row
      /*  for (int j=0; j<4; j++)
        {
        	show_result_toggle(result);
        	delay (one_second/2);
        }  */
    }
    return(0);
} 
Example #5
0
int main (void)
{
    int count;
    uint8_t data = 'M';

    system_init ();
    tinygl_init (LOOP_RATE);
    tinygl_font_set (&font3x5_1);
    tinygl_text_speed_set (MESSAGE_RATE);
    tinygl_text_mode_set (TINYGL_TEXT_MODE_STEP);
    tinygl_text_dir_set (TINYGL_TEXT_DIR_ROTATE);

    navswitch_init ();
    ir_uart_init ();

    pacer_init (LOOP_RATE);

    show_byte ('M');

    count = 0;

    /* Paced loop.  */
    while (1)
    {
        /* Wait for next tick.  */
        pacer_wait ();

        tinygl_update ();

        if (ir_uart_read_ready_p ())
        {
            uint8_t data;

            data = ir_uart_getc ();

            /* Note, if messages come in too fast, say due to IR
               inteference from fluorescent lights, then the display
               will not keep up and will appear to freeze.  */
            show_byte (data);
        }

        count++;
        if (count > LOOP_RATE / SWITCH_POLL_RATE)
        {
            count = 0;

            navswitch_update ();

            if (navswitch_push_event_p (NAVSWITCH_WEST))
            {
                ir_uart_putc (--data);
                /* Gobble echoed character.  */
                ir_uart_getc ();
            }

            if (navswitch_push_event_p (NAVSWITCH_EAST))
            {
                ir_uart_putc (++data);
                /* Gobble echoed character.  */
                ir_uart_getc ();
            }
        }
    }

    return 0;
}