int main(void)
{	
	//Setting the clock frequency
	
	SysCtlClockSet(SYSCTL_SYSDIV_3 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);  // Refer to tm4c123gh6pm data sheet page 223
																																													 // and TivaWare™ Peripheral Driver Library refrence page: 489 for more options
																																													 // In this case the clock freq is 66.67 MHz
	
	
	//Get the clock
	Clock = SysCtlClockGet();           //In case you want to confirm the clock frequency
	
	
	//Setup peripherals
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);																							// enable timer0
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);																							// enable PORTF
	
	//set outputs
  GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_3)); 			// set pins of portf as output
	
	//Enable global interrupt
	IntMasterEnable();
	
	//Timer0 configuration
	Timer0Conf();
	
	while(1){
		SysCtlSleep(); 				
	}
	
	
}
Exemplo n.º 2
0
//1 oznacza brak confilktow, 0 oznacza konflikt
uint8_t checkCollision(uint8_t input) {
    Element *current;
    if(eatable->next == (Element*)0xEE) {
        //sprawdzamy eatable
        current = head;
        while(current != NULL && (eatable->x != current->x || eatable->y != current->y))
            current = current->next;
        if(current == NULL)
            return 1;
        else
            return 0;
    }
    else {
        //sprawdzamy wunsza, do implementacji
        //jesli wunsz zjadl eatable to eatable jest nowa glowa
        //jesli wunsz nie zjadl eatable i nie wszedl w nic to zmienia wspolrzedne wunsza
        switch(input) {
            case 1:
                head->y = (head->y+ELSIZE)%320;
                break;
            case 2:
                head->x = (head->x+ELSIZE)%240;
                break;
            case 4:
                head->y = (head->y-ELSIZE+320)%320;
                break;
            case 8:
                head->x = (head->x-ELSIZE+240)%240;
        }
        if(head->x == eatable->x && head->y == eatable->y) {
            switch(input) {
                case 1:
                    head->y = (head->y-ELSIZE+320)%320;
                    break;
                case 2:
                    head->x = (head->x-ELSIZE+240)%240;
                    break;
                case 4:
                    head->y = (head->y+ELSIZE)%320;
                    break;
                case 8:
                    head->x = (head->x+ELSIZE)%240;
            }
            eatable->next = head;
						head->prev = eatable;
            head = eatable;
            eatable = NULL;
						//DMA0ChannelConf();
						Timer0Conf();
            return 2;
        }
        else {
            current = head->next;
            while(current != NULL && (current->x != head->x || current->y != head->y))
                current = current->next;
            if(current == NULL)
                return 1;
            else
                return 0;
        }
    }
}