int main(void) { //init_USART(); init_SPI(); init_ster(); lcd_init(); LCD_DISPLAY(LCDDISPLAY); lcd_puts("KAROL"); if(GetRegister(STATUS) == 0x0E) { LED_ON; _delay_ms(1000); LED_OFF; _delay_ms(1000); } LCD_CLEAR; NRF24L01_init(); while(1) { reset(); receive_payload(); if(((GetRegister(STATUS) & (1<<RX_DR)) != 0)) { LED_ON; _delay_ms(10); //LCD_CLEAR; receive_buffer=WriteReadToNrf(R,R_RX_PAYLOAD,receive_buffer,5); X_acc=receive_buffer[0]; Y_acc=receive_buffer[1]; Z_acc=receive_buffer[2]; ster(X_acc,Y_acc); LCD_LOCATE(0,0); sprintf(Text_buff,"%3d",X_acc); lcd_puts(Text_buff); LCD_LOCATE(0,1); sprintf(Text_buff,"%3d",Y_acc); lcd_puts(Text_buff); LED_OFF; } } }
int main(void) { uint8_t year=0, month=0, day=0, hour=0, minute=0, second=0; char str[16]; uint8_t count = 0, men = 0; UCSRB = (1<<RXEN)|(1<<TXEN)|(1<<RXC); //odblokowanie przerwania z odbiorem na urat lcd_init(); USART_Init(MYUBRR); initI2C(); LCD_DISPLAY(LCDDISPLAY); LCD_CLEAR; LCD_LOCATE(0,0); lcd_puts("Hello!"); ds1307_setdate(91, 1, 14, 12, 00, 00); sei(); while(1) { ds1307_getdate(&year, &month, &day, &hour, &minute, &second); if (a == "N") { LCD_CLEAR; men ++; _delay_ms(20); } switch(men){ case 0: LCD_LOCATE(5,1); lcd_puts(itoa(hour, str, 10)); lcd_puts(":"); lcd_puts(itoa(minute, str, 10)); lcd_puts(":"); lcd_puts(itoa(second, str, 10)); lcd_puts(a); break; case 1: LCD_LOCATE(5,1); lcd_puts("20"); lcd_puts(itoa(year, str, 10)); lcd_puts("-"); lcd_puts(itoa(month, str, 10)); lcd_puts("-"); lcd_puts(itoa(day, str, 10)); break; case 2: men = 0; break; } if (count == 20) { Send_Znak(a); count=0; } count++; _delay_ms(50); } }
/*-----------------------------------------------------------------------*/ void init_all_and_POST(void) { int i = 0; disable_watchdog(); init_modes_and_clock(); initEMIOS_0MotorAndSteer(); /* PIT:光编读值&速度控制 */ // init_pit_10ms(); /* PIT:步进电机控制&角度控制标志位 */ init_pit_1ms(); //init_Stepmotor(); /* 初始化步进电机 */ init_led(); //init_DIP(); /* 拨码开关 */ init_serial_port_1(); /* BlueTooth */ init_ADC(); /* 陀螺仪读值 - 其中一路ADC与MPU9250片选冲突,不要同时打开*/ init_optical_encoder(); /* 光编 */ //init_I2C(); //init_choose_mode(); /* 拨码开关模式选择 */ /* 初始化SPI总线 */ init_DSPI_1(); /* 开启外部总中断 */ enable_irq(); /* 初始化显示屏 */ initLCD(); LCD_DISPLAY(); LCD_Fill(0xFF); /* 亮屏 */ delay_ms(50); LCD_Fill(0x00); /* 黑屏 */ delay_ms(50); /*初始化螺旋桨电机,给1000占空比*/ set_PropellerA_motor_pwm(1000); set_PropellerB_motor_pwm(1000); /* 初始化TF卡 */ //test_init_TF(); /* 读取设备号 */ //read_device_no(); /* 初始化陀螺仪 */ // init_MPU9250(); //delay_ms(1000); /* 换屏 */ //LCD_Fill(0x00); /* 读取舵机参数 */ //read_display_helm(); /* 读取拨码开关模式号 */ //read_DIP_mode(); //delay_ms(1000); /* 换屏 */ //LCD_Fill(0x00); /* 速度闭环开启及测试 速度=0 */ //init_speed_control(); // g_f_enable_supersonic=1; //delay_ms(2000); /* 换屏 */ //LCD_Fill(0x00); }