void initDMA() { uint32_t i; for(i=0; i!=16; i++) { triangle[i] = (((i+1)<<6) - 1)<<6; } for(i=0; i!=16; i++) { triangle[16+i] = (((16-i)<<6) - 64)<<6; } // enable AOUT (P0.26) pin LPC_PINCON->PINSEL1 |= (2<<20); // Select MAT0.0 instead of UART0 Tx (p.609) LPC_SC->DMAREQSEL = 0x01; // Enable the GPDMA controller LPC_GPDMA->DMACConfig = 1; // Enable synchro logic request 8, MAT0.0 LPC_GPDMA->DMACSync = 1 << 8; LPC_GPDMACH0->DMACCSrcAddr = (uint32_t) &triangle[0]; LPC_GPDMACH0->DMACCDestAddr = (uint32_t) &(LPC_DAC->DACR); LPC_GPDMACH0->DMACCLLI = 0; // linked lists for ch0 LPC_GPDMACH0->DMACCControl = 32 // transfer size (0 - 11) = 32 | (0 << 12) // source burst size (12 - 14) = 1 | (0 << 15) // destination burst size (15 - 17) = 1 | (2 << 18) // source width (18 - 20) = 32 bit | (2 << 21) // destination width (21 - 23) = 32 bit | (0 << 24) // source AHB select (24) = AHB 0 | (0 << 25) // destination AHB select (25) = AHB 0 | (1 << 26) // source increment (26) = increment | (0 << 27) // destination increment (27) = no increment | (0 << 28) // mode select (28) = access in user mode | (0 << 29) // (29) = access not bufferable | (0 << 30) // (30) = access not cacheable | (0 << 31); // terminal count interrupt disabled LPC_GPDMACH0->DMACCConfig = 1 // channel enabled (0) | (0 << 1) // source peripheral (1 - 5) = none | (8 << 6) // destination request peripheral (6 - 10) = MAT0.0 | (1 << 11) // flow control (11 - 13) = mem to per | (0 << 14) // (14) = mask out error interrupt | (0 << 15) // (15) = mask out terminal count interrupt | (0 << 16) // (16) = no locked transfers | (0 << 18); // (27) = no HALT idThreadBeep = osThreadCreate (osThread (Thread_Beep), NULL); // create the thread T0_Init(); }
/******************Ö÷³ÌÐò********************************/ void main(void) { Pin_Init(); T0_Init(); Uart1_Init(); Uart2_Init(); Uart1_AppInit(); Uart2_AppInit(); MdTcbInit1(); MdTcbInit2(); Global_EI(); while (1) { TimeDeal(&Ahu1); MdPoll01(); MdPoll02(); if (Ahu1.Times.Solo._1msFlag) { UartTimeOut(&UartAppData1); UartTimeOut(&UartAppData2); KeyScanDeal(KeyGet()); KeyAllStateDeal(&Ahu1); NumberDisplayScan(&Ahu1); } DisplayNumber(flag); if (Ahu1.Times.Solo._5msFlag) { LedOutputScan(&Ahu1); RhDisplayScan(&Ahu1); TmepDisplayScan(&Ahu1); } if (Ahu1.Times.Solo._10msFlag) { } if (Ahu1.Times.Solo._1000msFlag) { flag++; } // Ahu1.Humidity.Solo.SEG_B = 1; // Ahu1.Temperature.Solo.SEG_C = 1; Ahu1.Times.All[0] = 0; } }
/******************主程序********************************/ void main(void) { Pin_Init(); T0_Init(); Uart_Init(); Uart2_Init(); Uart_AppInit(); Uart2_AppInit(); MdTcbInit(); MdTcbInit2(); AdcInit(); PWMInit(); FCInitOne(); while (1) { TimeDeal(&FC1); MdPoll(); MdMasterPoll(); FCKeyScan(&FC1); ResetDeal(&FC1); FCURun(&FC1); FCRelayOutput(&FC1); if (FC1.Buff.Flag.solo._2msFlag) { // FC2IOScan(&FC1); swih ^= 1; PORTB_PORTB4 = swih; TestSpeed(); UartTimeOut(&UartAppData1); UartTimeOut(&UartAppData2); } if (FC1.Buff.Flag.solo._4msFlag) { InputDeal(); } if (FC1.Buff.Flag.solo._10msFlag) { FCWorkTime(&FC1); } if (FC1.Buff.Flag.solo._20msFlag) { AdcGetAll(&FC1); FCAnalogOutSet(&FC1); EePromDeal(&FC1.Run, sizeof(FC_RUNING_Def) - CRC_LEN, &EeSave1); } if (FC1.Buff.Flag.solo._10000msFlag) { uint16 tmpCrc = FC1.Run.RunCrc; uint16 tmpCrcNew = GetCRC16((uint08 *)&FC1.Run, sizeof(FC_RUNING_Def) - CRC_LEN); if (tmpCrc != tmpCrcNew) { EeWriteTrg(&EeSave1); } } if (FC1.Buff.Flag.solo._nmsFlag) { speedPerMin = speedCnt * 60 / 4 / (nTimeSpeed / 100); speedCnt = 0; } FC1.Buff.Flag.All = 0; } }