// this task is the initial task running, started by main(). It begins the system tick timer // and creates all the other task. Then it deletes itself. void StartupTask(void* pdata) { INT8U err; DEBUGMSG(1,("StartupTask: begin\n\r")); DEBUGMSG(1,("StartupTask: tick timer\n\r")); // Initialize BSP functions BSP_Init(); // re-init the UART so we can use the serial port initUART0(38400, UART_8N1, UART_FIFO_OFF, getFcclk()); // initialize the driver sub-system err = OSDRV_SubsysInit(DriverTable, DRIVER_COUNT); if (err != OS_DRV_NO_ERR) { RETAILMSG(1,("StartupTask: Failed to initialize driver subsystem: %d\n\r", err)); //park here while(TRUE); } SemPrint = OSSemCreate(1); // create the the test tasks // we have OS_STK_GROWTH set to 1, so the stack grows from high to low DEBUGMSG(1,("StartupTask: Creating the tasks...\n\r")); OSTaskCreate(PlayTask, (void*)0, (void*)&TaskPlayStk[APP_TASK_DEFAULT_STK_SIZE-1], APP_TASK_PLAY_PRIO); #ifdef OS_TASK_STAT_EN //create a CPU monitor task OSStatInit (); //?? OSTaskCreate(MonTask, (void*)0, (void*)&TaskMonStk[APP_TASK_DEFAULT_STK_SIZE-1], APP_TASK_MON_PRIO); #endif //OS_TASK_STAT_EN // delete ourselves, letting the work be done in the new tasks. DEBUGMSG(1,("StartupTask: deleting self\n\r")); OSTaskDel(OS_PRIO_SELF); }
int main(void) { char msg[] = { 'H','e','l','l','o',' ','t','h','i','s',' ','a','','t','e','s','t','\0' }; int c=0; // count initClocks(); // Set CCLK=60Mhz and PCLK=60Mhz initUART0(); for(;;) { while( msg[c]!='\0' ) { U0Write(msg[c]); c++; } U0Write(NEW_LINE); c=0; // reset count } return 0; }
/**************************************************************** Основная функция ****************************************************************/ void main(void) { P1DIR = 0x03; //Управления P1 LED RLED = 0; YLED = 0; //выключить Led initUART0(); stringlen = strlen((char *)Recdata); UartTX_Send_String(Recdata,30); while(1) { if(RXTXflag == 1) //принимающее устройство { YLED=!YLED; //Получите индикации состояния if( temp != 0) { if((temp!='#')&&(datanumber<50)) // Определяется как конец пакета , может принять максимум 50 символов { Recdata[datanumber++] = temp; } else { RXTXflag = 3; //Передающее устройства } if(datanumber == 50) RXTXflag = 3; temp = 0; } } if(RXTXflag == 3) //Отправить статуса { YLED = 0; //Off Зеленый светодиод RLED = 1; //Отправить индикации состояния U0CSR &= ~0x40; //Не взыскание долгов UartTX_Send_String(Recdata,datanumber); U0CSR |= 0x40; //позволило получить RXTXflag = 1; //Вернуться к принимающем государстве datanumber = 0; //Указатель возврат 0 RLED = 0; //Off Направление инструкций } } }
int usermain(void) { setGpioDirection(GPIO0_7,GPIO_OUT); //led // Initialize uart0 and set debugger interface initUART0(); setDebugInterface(sendByteToUART0); debugPrintf("lpc13xx is running !\r\n"); // Power down usb clock SETBIT(LPC_SYSCON->PDRUNCFG,10); SETBIT(LPC_SYSCON->PDRUNCFG,8); newThread(led,512,10,5); // newThread(PRS_I2CComm,512,10,4); return 0; }