Пример #1
0
int main(void) {
    // Setup
    // activate grader and set system clock to 80 MHz
    TExaS_Init(SW_PIN_PE210, LED_PIN_PB543210, ScopeOff);
    PortsInit();           // Port B, Port F, and Port E initialization
    SystickInit();         // SysTick timer initialization
    this_state = GO_SOUTH; // GO_SOUTH is initial state
    EnableInterrupts();    // enable interrupts for grader

    // Loop
    while (1) {
        // make outputs
        GPIO_PORTB_DATA_R = FSM[this_state].port_b_out; // to cars (port B)
        GPIO_PORTF_DATA_R = FSM[this_state].port_f_out; // to pedestrians (port F)
        SystickWait1mss(FSM[this_state].wait);

        // get inputs
        // if no switch is pressed
        if (GPIO_PORTE_DATA_R == 0x00) {
            switch_input = 0; // then it is case 0 of the next[] array...
        }  // ... all LEDs stay the way they are since the last pressing
           // if south switch is pressed
        else if (GPIO_PORTE_DATA_R == 0x02) {
            switch_input = 1; // then it is case 1 of the next[] array...
        }  // ... all LEDs correspond to Go South mode
           // if west switch is pressed
        else if (GPIO_PORTE_DATA_R == 0x01) {
            switch_input = 2; // then it is case 2 of the next[] array...
        }  // ... all LEDs correspond to Go West mode
           // if pedestrian switch is pressed
        else if (GPIO_PORTE_DATA_R == 0x04) {
            switch_input = 3; // then it is case 3 of the next[] array...
        }  // ... all LEDs correspond to Go Pedestrian mode
           // if all switches are pressed
        else if (GPIO_PORTE_DATA_R == 0x07) {
            switch_input = 4; // then it is case 4 of the next[] array...
        }  // ... all LEDs correspond periodically: South, West, Pedestrian
           // change state based on input and current state
        this_state = FSM[this_state].next[switch_input];
    }
}
Пример #2
0
void UserMain(void * pd) {
    InitializeStack();
    OSChangePrio(MAIN_PRIO);
    EnableAutoUpdate();
    EnableTaskMonitor();

    #ifndef _DEBUG
    	EnableSmartTraps();
    #endif

    #ifdef _DEBUG
    	InitializeNetworkGDB_and_Wait();
    #endif

//    int fd = OpenSerial(9, 115200, 1, 8, eParityNone); // NetBurner 2.0: jack X5 - UART9, jack X4 - UART8

    PortsInit();

	iprintf("Initialization the LCD...\r\n");
	Display dis;
	dis.Init();

//	Tab *ta = new Tab("A", 170, 0, 22, 17, 8, 5 );
//	Tab *tb = new Tab("B", 170, 16, 22, 17, 8, 5 );
//	Tab *tc = new Tab("C", 170, 32, 22, 17, 7, 4 );
//	Tab *td = new Tab("All", 170, 48, 22, 16, 5, 4 );

		Tab *ta = new Tab("A", 170, 0, 22, 22, 8, 6 );
		Tab *tb = new Tab("B", 170, 21, 22, 22, 8, 6 );
		Tab *tc = new Tab("C", 170, 42, 22, 22, 7, 6 );


	Menu m;
	m.ta = ta;
	m.tb = tb;
	m.tc = tc;
//	m.td = td;
	m.disp = &dis;


	// Initialization Queues
	OSQInit( &BuzzerQueue, Buzzer_queue_data, BUZZER_QUEUE_SIZE );
	OSQInit( &DisplayQueue, Display_queue_data, DISPLAY_QUEUE_SIZE );

	// Initialization Tasks
	if( OSTaskCreate(PollKeyboardTask,
//					(void *) &fd,
					(void *) &m,
					(void *) &PollKeyboardTaskStack[USER_TASK_STK_SIZE],
					(void *) PollKeyboardTaskStack,
					MAIN_PRIO - 2 ) != OS_NO_ERR)
	{
		iprintf( "*** Error creating PollKeyboardTask\r\n" );
	}

	if( OSTaskCreate(DisplayingLCDTask,
					(void *) &m,
					(void *) &DisplayingLCDTaskStack[USER_TASK_STK_SIZE],
					(void *) DisplayingLCDTaskStack,
					MAIN_PRIO - 1 ) != OS_NO_ERR)
	{
		iprintf( "*** Error creating DisplayingLCDTask\r\n" );
	}

	if( OSTaskCreate(BuzzerTask,
					 NULL,
					(void *) &BuzzerTaskStack[USER_TASK_STK_SIZE],
					(void *) BuzzerTaskStack,
					MAIN_PRIO - 3 ) != OS_NO_ERR)
	{
		iprintf( "*** Error creating BuzzerTask\r\n" );
	}

    iprintf("Application started\n");
    while (1) {
        OSTimeDly(20);
    }
}