--- /dev/null
+unsigned char somestring[25];\r
+\r
+//*********************************************************************\r
+//******************** SYSTERM HEARTBEAT @ 10 ms *********************\r
+//*********************************************************************\r
+void InitSPI (void)\r
+{\r
+ //set functionalite to pins:\r
+ //port0.11 -> NPCS0\r
+ //port0.12 -> MISO\r
+ //port0.13 -> MOSI\r
+ //port0.14 -> SPCK\r
+ PIOA_PDR = BIT11 | BIT12 | BIT13 | BIT14;\r
+ PIOA_ASR = BIT11 | BIT12 | BIT13 | BIT14;\r
+ PIOA_BSR = 0;\r
+\r
+\r
+ PMC_PCER |= 1 << 5; // Enable SPI timer clock.\r
+\r
+ /**** Fixed mode ****/\r
+ SPI_CR = 0x81; //SPI Enable, Sowtware reset\r
+ SPI_CR = 0x01; //SPI Enable\r
+\r
+\r
+\r
+ SPI_MR = 0x000E0011; //Master mode\r
+ SPI_CSR0 = 0x01010B11; //9 bit\r
+\r
+}\r
+\r
+//*********************************************************************\r
+//*************************** Task 1 ********************************\r
+//*********************************************************************\r
+void Task_1(void *p)\r
+{\r
+ char beat=0; // just flash the onboard LED for Heatbeat\r
+\r
+ while(1)\r
+ {\r
+ if(beat)\r
+ {\r
+ PIOA_SODR = BIT18;\r
+ beat=0;\r
+ }\r
+ else\r
+ {\r
+ PIOA_CODR = BIT18;\r
+ beat=1;\r
+ }\r
+\r
+ ctl_timeout_wait(ctl_get_current_time()+ 150);\r
+\r
+ }\r
+}\r
+//*********************************************************************\r
+//*************************** Task 2 ********************************\r
+//*********************************************************************\r
+void Task_2(void *p)\r
+{\r
+ unsigned long z;\r
+ unsigned int x,y;\r
+ unsigned char a,b,c,d,e;\r
+\r
+ char seconds,minutes,hours;\r
+\r
+ unsigned int nowold,tenths;\r
+\r
+\r
+ InitLCD();\r
+\r
+\r
+/******* Put smiley face up in 4096 color mode *******/\r
+ LCD_Fill(0,0,132,132,Black);\r
+\r
+ LCD_Set_Resolution(HIGH_RES); // set 4096 color mode\r
+\r
+// ShowImage_4096(0,0,smiley);\r
+ LCD_Set_Resolution(LOW_RES); // set 256 color mode\r
+\r
+ ctl_timeout_wait(ctl_get_current_time()+ 4000); // wait 4 seconds to view it\r
+\r
+/******* Do some static on screen *******/\r
+\r
+ LCD_Fill(0,0,132,132,Black);\r
+\r
+ for(z=0;z<100000;z++)\r
+ {\r
+ while( (a = rand()) > 132);\r
+ while( (b = rand()) > 132);\r
+ c = rand();\r
+ LCD_PixelPut(a,b,c);\r
+ }\r
+\r
+/******* Do some lines on screen *******/\r
+ LCD_Fill(0,0,132,132,Black);\r
+\r
+ for(z=1;z<300;z++)\r
+ {\r
+ while( (a = rand()) > 132);\r
+ while( (b = rand()) > 132);\r
+ while( (c = rand()) > 132);\r
+ while( (d = rand()) > 132);\r
+ e = rand(); // pick color\r
+\r
+ LCD_Line(a,b,c,d,e);\r
+ ctl_timeout_wait(ctl_get_current_time()+ 10);\r
+ }\r
+\r
+/******* Do some Boxes on screen *******/\r
+ LCD_Fill(0,0,132,132,Black);\r
+\r
+ for(z=0;z<300;z++)\r
+ {\r
+\r
+ while( (a = rand()) > 132);\r
+ while( (b = rand()) > 132);\r
+ while( (c = rand()) > 132);\r
+ while( (d = rand()) > 132);\r
+\r
+ e = rand(); // pick color\r
+ LCD_Box(a,b,c,d,e);\r
+\r
+ ctl_timeout_wait(ctl_get_current_time()+ 10);\r
+ }\r
+/******* Do some Circles on screen *******/\r
+ LCD_Fill(0,0,132,132,Black);\r
+\r
+ for(z=0;z<100;z++)\r
+ {\r
+\r
+ while( (a = rand()) > 132);\r
+ while( (b = rand()) > 132);\r
+ while( (c = rand()) > 127); // diameter\r
+\r
+ d = rand(); // pick color\r
+ LCD_Circle(a,b,c,d);\r
+\r
+ ctl_timeout_wait(ctl_get_current_time()+ 10);\r
+ }\r
+\r
+/******* Do some Thick Circles on screen *******/\r
+ LCD_Fill(0,0,132,132,Black);\r
+\r
+ for(z=0;z<25;z++)\r
+ {\r
+ while( (a = rand()) > 132);\r
+ while( (b = rand()) > 132);\r
+ while( (c = rand()) > 40); // diameter\r
+ while( (d = rand()) > 10); // wall thicknes\r
+ e = rand(); // pick color\r
+ LCD_Thick_Circle(a,b,c,d,e);\r
+\r
+ ctl_timeout_wait(ctl_get_current_time()+ 1);\r
+ }\r
+\r
+/******* Do something funky to wipe screen *******/\r
+ b=0;\r
+\r
+ for(a=0;a<131;a++)\r
+ {\r
+ LCD_Line(a,b,65,65,0x62);\r
+ }\r
+ for(b=0;b<131;b++)\r
+ {\r
+ LCD_Line(a,b,65,65,0x62);\r
+ }\r
+ for(;a>1;a--)\r
+ {\r
+ LCD_Line(a,b,65,65,0x62);\r
+ }\r
+ for(;b>1;b--)\r
+ {\r
+ LCD_Line(a,b,65,65,0x62);\r
+ }\r
+\r
+ ctl_timeout_wait(ctl_get_current_time()+ 1000);\r
+\r
+/******* Show Image scrolling *******/\r
+ LCD_Fill(0,0,132,132,Black);\r
+\r
+ ShowImage(0,50,sparkfun);\r
+\r
+ sprintf(somestring,"Thanks SparkFun");\r
+ LCD_String(somestring,&FONT8x8F[0][0],5,10,LightGreen,Black);\r
+\r
+ ctl_timeout_wait(ctl_get_current_time()+ 2000); // hold sparkfun image for a bit\r
+\r
+ for(y=50;y<140;y++)\r
+ {\r
+ LCD_Line(0,y-1,132,y-1,Black); // wipe the white line as it moves down\r
+ ShowImage(0,y,sparkfun); // move image to Y location\r
+ ctl_timeout_wait(ctl_get_current_time()+ 25); // wait a bit\r
+ }\r
+\r
+/******* Run radar in loop with example fonts displayed *******/\r
+ LCD_Fill(0,0,132,132,Black);\r
+\r
+ LCD_Thick_Circle(66,66,30,2,DarkBlue);\r
+\r
+ y=0;\r
+\r
+ while (1)\r
+ {\r
+ LCD_Circle_Line(66,66,28,0,y,LightGreen);\r
+\r
+ ctl_timeout_wait(ctl_get_current_time()+ 1);\r
+\r
+ tenths = ctl_current_time / 1000;\r
+\r
+ if(tenths != nowold)\r
+ {\r
+ nowold = tenths;\r
+\r
+ if(++seconds == 60)\r
+ {\r
+ seconds = 0;\r
+\r
+ if(++minutes == 60)\r
+ {\r
+ minutes=0;\r
+ hours++;\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ printf("a=%6lu - b=%6lu - c=%6lu - d=%6lu : Time=%lu\r\n",a,b,c,d,ctl_current_time);\r
+\r
+ sprintf(somestring,"%05lu",y);\r
+ LCD_String(somestring,&FONT6x8[0][0],52,25,White,Black);\r
+\r
+ sprintf(somestring,"Time:%02u:%02u:%02u",hours,minutes,seconds);\r
+ LCD_String(somestring,&FONT8x8F[0][0],14,10,DarkRed,Black);\r
+\r
+ sprintf(somestring,"Time:%02u:%02u:%02u",hours,minutes,seconds);\r
+ LCD_String(somestring,&FONT8x16[0][0],14,115,LightGreen,Black);\r
+\r
+ LCD_Circle_Line(66,66,28,0,y,Black);\r
+\r
+ if(++y==360)\r
+ {\r
+ y=0;\r
+ }\r
+\r
+ ctl_timeout_wait(ctl_get_current_time()+ 10);\r
+\r
+ }\r
+}\r
+\r
+/*************************************************************************\r
+ ********************* Main Module *************************\r
+ ********************* *************************\r
+ ********************* Initialize Program *************************\r
+ ********************* Sequences *************************\r
+ ********************* *************************\r
+ *************************************************************************/\r
+int main(void)\r
+{\r
+ BoardInit();\r
+\r
+ InitSPI();\r
+\r
+ while (1)\r
+ {\r
+ Idle();\r
+ }\r
+\r
+ return 0;\r
+}\r