void Init_Hard(void){ Init_CLK(); gpio_init(); externalInterrupt_CcCv_init(); InitDelTim(); delay_ms(100); Init_Beep(); Init_Timer4(); //FAN_PWM Init_Encoder(); InitAdc(); Init_DAC_CH1(); Init_DAC_CH2(); Init_DS18B20(); Init_PVD(); Init_EXTI1(); Init_SPI2(); uart_init(USART3, BR38400); lcd_init (); //Глючная инициализация lcd_init (); lcd_init (); lcd_init (); timMeasInit(); //DEBUG }
int main(void) { WDTCTL = WDTPW + WDTHOLD ; Init_CLK() ; Init_J60SPI() ; MAIN_POWER_ON ; __delay_cycles(5000000) ; P9DIR |= IrDA_OUT ; P9OUT &=~IrDA_OUT ; Init_EtherNet() ; ENC_SLEEP() ; // 省电 OS_IncDI() ; // 屏蔽中断 OS_InitKern() ; // 初始化系统内核 OS_InitHW() ; // 初始化硬件 Init_Func() ; Init_UART() ; Init_RSUART() ; Ini_LED(8) ; Init_ADC() ; Init_RTC() ; LCD_Init() ; LED_POWER_ON ; BackLight() ; OS_CREATERSEMA(&SemaLCD) ; OS_CREATERSEMA(&SemaSPI) ; LED_Disp_Float(3.1415925,7,FIT_ZERO) ; LED_Flicker_Digit(8,1) ; Color = Black ; Color_BK = 0xEF9F ; OS_CREATETASK(&Seg7LED_TASK_TCB, "Seg7LedTask", Seg7LedRefresh, 100, Seg7LED_TASK_STACK ) ; OS_CREATETASK(&LCD_TASK_TCB, "LCD_Task", LCD_Task, 100, LCD_TASK_STACK ) ; OS_CREATETASK(&MENU_OP_TASK_TCB, "MENU_OP_Task", MENU_OP_Task, 100, MENU_OP_TASK_STACK) ; OS_CREATETASK(&KEY_TP_TASK_TCB, "KEY_TP_Task", Key_TP_Task, 100, KEY_TP_TASK_STACK ) ; OS_Start() ; return 0 ; }
int main( void ) { WDTCTL = WDTPW + WDTHOLD ; // 关闭看门狗 Init_CLK() ; P11DS = TACK + TMCK + TSMCK ; // ACK、MCK、SMCK输出至P11.0/1/2 P11SEL = TACK + TMCK + TSMCK ; P11DIR = TACK + TMCK + TSMCK ; MAIN_POWER_ON ; // 指示时钟初始化成功 while(1) ; }
void Init_Device(void) { EA = 0; Init_RST(); Init_CLK(); Init_XBAR(); Config_GPIO(); Config_INT1(); CFG_UART0(); CFG_ADC0(); Config_Timer2(); EA = 1; }
void main() { unsigned char i; Init_CLK(); LCD_Init(); //TFT³õʼ»¯ LCD_Clear(BLACK); //ÇåÆÁ /* LCD_Clear(RED); delay_s(1); LCD_Clear(GREEN); delay_s(2); LCD_Clear(BLUE); delay_s(2); //showimage(); */ POINT_COLOR=GREEN; LCD_DrawRectangle(0,0, 479, 271); POINT_COLOR=BLUE; LCD_DrawRectangle(5,5, 474, 266); POINT_COLOR=RED; Draw_Circle(100,100,100); LCD_DrawPicture(0,0,160,160, gImage_fg); while(1) { POINT_COLOR=RED; for(i=100;i>0;i--) { Draw_Circle(100,100,i); Draw_Circle(100,200,i); Draw_Circle(200,200,i); Draw_Circle(300,100,i); Draw_Circle(300,200,i); delay_ms(50); } POINT_COLOR=BLACK; for(i=0;i<101;i++) { Draw_Circle(100,100,i); Draw_Circle(100,200,i); Draw_Circle(200,200,i); Draw_Circle(300,100,i); Draw_Circle(300,200,i); delay_ms(50); } } }
void main() { Init_CLK(); LCD_Init(); //TFT³õʼ»¯ LCD_Clear(WHITE); //ÇåÆÁ LCD_Clear(RED); delay_s(2); LCD_Clear(GREEN); delay_s(2); LCD_Clear(BLUE); delay_s(2); showimage(); while(1) { ; } }
void main() { P6DIR|=BIT1;//发光二极管 P6OUT|=BIT1; P1DIR|=BIT0;//给fpga的信号 P1OUT&=~BIT0; WDTCTL = WDTPW + WDTHOLD; //关闭看门狗 Init_CLK(); Ini_Lcd(); Init_IO(); Init_LDC1000(); Port_init(); delay_ms(100); //延时100ms while(1) { Key_Scan(); //键盘扫描,看是否有按键按下 if(key!=0xff) //如果有按键按下,则显示该按键键值1~4 { { switch(key) { case 1: LED8 = 0xFC; arange=key1;break; //给不同的键赋键值,键值1,亮2个LED灯 case 2: LED8 = 0xF3;arange=key2;break; //给不同的键赋键值,键值2,亮2个LED灯 case 3: LED8 = 0xCF;arange=key3;break; //给不同的键赋键值,键值3,亮2个LED灯 case 4: LED8 = 0x3F;arange=key4;break; //给不同的键赋键值,键值4,亮2个LED灯 } } } else { //LED=key; //没有按键的时候显示上次的键值 } proximtyData[0] = spi_readByte(LDC1000_CMD_PROXLSB); proximtyData[1] = spi_readByte(LDC1000_CMD_PROXMSB); frequencyData[0] = spi_readByte(LDC1000_CMD_FREQCTRLSB); frequencyData[1] = spi_readByte(LDC1000_CMD_FREQCTRLSB+1); frequencyData[2] = spi_readByte(LDC1000_CMD_FREQCTRLSB+2); proximtyDataMAX = ((unsigned char) proximtyData[1]<<8) + proximtyData [0]; frequencyDataMAX =((unsigned char)frequencyData[1]<<8) + frequencyData[0]; disNum(proximtyDataMAX%10+0x30,0x86); disNum(proximtyDataMAX/10%10+0x30,0x85); disNum(proximtyDataMAX/100%10+0x30,0x84); disNum(proximtyDataMAX/1000%10+0x30,0x83); disNum(proximtyDataMAX/10000%10+0x30,0x82); a = spi_readByte(LDC1000_CMD_REVID); if(proximtyDataMAX>arange) { P6OUT&=~BIT1;//灯亮 P1OUT|=BIT0;//给fpga高电平,表示发现硬币 } else { P6OUT|=BIT1; P1OUT&=~BIT0; } _NOP(); } }
int main(void) { unsigned int num_bytes ; WDTCTL = WDTPW + WDTHOLD ; Init_CLK() ; Init_PSPI() ; P9DIR |= IrDA_OUT; P9OUT &=~IrDA_OUT; MAIN_POWER_ON ; /* for(;;){ for(i=0;i<40;i++) { P9OUT |= IrDA_OUT; __delay_cycles(20000); P9OUT &=~IrDA_OUT; __delay_cycles(20000); } __delay_cycles(5000000); } */ /* for(;;){ for(j=0;j<40;j++){ for(i=0;i<50;i++) { P9OUT &=~IrDA_OUT; __delay_cycles(270); P9OUT |= IrDA_OUT; __delay_cycles(270); } __delay_cycles(20000); } __delay_cycles(5000000); } */ myNode.node.ip = IP4_ADDR(103,1,168,192) ; myNode.node.mask = IP4_ADDR(0,255,255,255) ; myNode.node.gate = IP4_ADDR(1,1,168,192) ; myNode.node.mac[0] = 0x00 ; myNode.node.mac[1] = 0x60 ; myNode.node.mac[2] = 0x97 ; myNode.node.mac[3] = 0x48 ; myNode.node.mac[4] = 0xF4 ; myNode.node.mac[5] = 0xAB ; encInit() ; nicSetMacAddress() ; encPhyWrite(0x14,0x0470) ; arptab_init() ; ENC_SLEEP() ;// TEST ENC_WAKEUP();// TEST while(1) { num_bytes = encPacketReceive(&rxdnetbuf); if(num_bytes > 0) { if(rxdnetbuf.etherframe.protocal==ARP_PACKET) // 收到一个AR请求包 { if(rxdnetbuf.arpframe.operation==0x0100) arp_answer() ; // ARP request,处理arp数据包 else if(rxdnetbuf.arpframe.operation==0x0200) arp_process() ; // ARP answer } else if( (rxdnetbuf.etherframe.protocal == IP_PACKET) // 收到一个IP包 && ((rxdnetbuf.ipframe.verandihl&0xf0) == 0x40) // IP V4 && (rxdnetbuf.ipframe.destip[0] == myNode.nodebytes.ipbytes[0]) && (rxdnetbuf.ipframe.destip[1] == myNode.nodebytes.ipbytes[1]) && (rxdnetbuf.ipframe.destip[2] == myNode.nodebytes.ipbytes[2]) && (rxdnetbuf.ipframe.destip[3] == myNode.nodebytes.ipbytes[3])) { arp_ip_mac() ; if(rxdnetbuf.ipframe.protocal == 1) // ICMP { if(rxdnetbuf.icmpframe.type == 8) // ECHO ping_answer() ; } else if(rxdnetbuf.ipframe.protocal == 17) // UDP { // net_udp_rcv() ; _NOP(); // Clear_UPD_Buf() ; } /* else if(rxdnetbuf.ipframe.protocal == 6) // TCP tcp_rcve(&rxdnetbuf) ; updatearptab() ; */ } } } }