int main(void) { // unsigned long x, a, b, c, d; // char cool[5]; //int i = 0; SysTick_Init(); ADC_Init(1); PORTG_Init(1); PORTD_Init(); PORTA_Init(); PORTF_Init(); PORTB_Init(); PORTE_Init(1); PORTH_Init(); LCD_Init(); Touch_Init(); Camera_Init(); /* while(1) { x = ADC_In(); a = x/1000; x -= a * 1000; b = x/100; x -= b * 100; c = x/10; x -= c * 10; d = x; cool[0] = (char)(a + 48); cool[1] = (char)(b + 48); cool[2] = (char)(c + 48); cool[3] = (char)(d + 48); cool[4] = 0; TFT_Fill(purple); TFT_Text(&cool[0], 50, 50, 16, black, purple); } */ while(1) { GPIO_PORTG_DATA_R ^= 0x04; if(ADC_In() != 1023) { TFT_Fill(yellow); } else { TFT_Fill(purple); } } //TFT_H_Line(50,150,50,black); // return 1; }
void InitHallSensorProc() { //bind to message queue //hard coded until further notice Bind(HSMQNUM);//defined in MQNumENum.h //wait for synchronization start from keyboardProc char dummyBlock[1]; int syncSrc = KBMQNUM; Recv(&syncSrc, HSMQNUM, dummyBlock, 1); //create queue for keeping track of hall sensor interrupt triggers //it only needs to hold one flag int HSQueueID = QueueInit(HSQUEUEBLOCKNUMBER, sizeof(char)); char flag[1]; flag[0] = 0; //Reset hall sensors to initialize them Send(HSMQNUM, ATMELMQNUM, flag, sizeof(char)); //recv acknowledge that it worked int src = ATMELMQNUM; Recv(&src, HSMQNUM, flag, sizeof(char)); //Init interrupts on portF which will trigger when a hall sensor is triggered PORTF_Init(HSQueueID); //polling loop to see if there are any interrupts while(true) { if(Dequeue(HSQueueID, (void*)flag)) { //flag will either have a '1' which means atmel 1 needs to be polled (HS 1-8) //or a '3' which means atmel 3 needs to be polled (HS 9-32) //send which atmel to poll to Atmelproc Send(HSMQNUM, ATMELMQNUM, flag, sizeof(char)); } else { //it would be cool to add a forced context switch to next process so time isn't wasted here //or, rather, the smartest option be to have no queue and to immediately from within the isr send a message to the Atmel Comm process } } }