int main(void) { Systick_Init(); while (1) { gps.update(); if(gps.fix()) { latitude = gps.latitude(); longitude = gps.longitude(); time = gps.time(); date = gps.date(); } } }
int main(void) { uint8_t tmp; InitFifo(); USART_Config(); LED_Init(); // I2C_Configuration(); Systick_Init(); mySPI_Init(); //spi(); //Delay(1000); printf("init SPI test \n\r"); SPI_send(0x23, 0xc9); // resetting the accelerometer internal circuit SPI_send(0x20, 0x67); // 100Hz data update rate, block data update disable, x/y/z enabled SPI_send(0x24, 0x20); // Anti aliasing filter bandwidth 800Hz, 16G (very sensitive), no self-test, 4-wire interface SPI_send(0x10, 0x00); // Output(X) = Measurement(X) - OFFSET(X) * 32; SPI_send(0x11, 0x00); // Output(Y) = Measurement(Y) - OFFSET(Y) * 32; SPI_send(0x12, 0x00); // Output(Z) = Measurement(Z) - OFFSET(Z) * 32; while (1) { //tmp = SPI_read(0x28); //printf("x : %x \n\r",tmp); tmp = SPI_read(0x29); printf("x : %x \n\r",tmp); Delay(1000); } }
/****************************************************************************** ** Main Function main() ******************************************************************************/ int main (void) { /* SystemClockUpdate() updates the SystemFrequency variable */ SystemClockUpdate(); //SystemFrequency = 72000000 by default Systick_Init(); //10 ms de bir tick atacak sekilde Systick i baslat Gpio_Config(); //Beacon MCU da kullanilacak pinleri konfigure et ADF7021_CHIP_POWER_DOWN; //CE pini asagi cek Delay_ms(10); ADF7021_LOAD_REGISTER_DISABLE; //LE pinini yukari cek, load register disable olsun Delay_ms(10); ADF7021_CHIP_POWER_UP; //CE pinini yukari cek, ADF7012 enable olsun Delay_ms(10); SSP1Init(); // SSP1 portunda SPI konusalim*/ DACInit(); // 1.2kHz ve 2kHz sinus olusturmak icin DAC peripheral i baslatalim Delay_ms(10); Init_Adf7012(); //Adf7012 registerlarini istedigimiz konfigurasyonda yazalim Init_Timer(10); //10us intervalinde timer0 baslat Enable_Timer(); //Timer0 enable et while ( 1 ); //main de yapilacak is kalmadi bundan sonra isr lerle devam edecegiz return 0; }
int main(void) { char buffer[255] = ""; Systick_Init(); #ifdef WRITE // Memory address buffer[0] = 0x00; // Data to store strcpy(buffer+1, "Hello World!"); // Store data i2c.write_b(EEPROM_ADDRESS, buffer, 13); #else // Memory address buffer[0] = 0x00; i2c.write_b(EEPROM_ADDRESS, buffer, 1); // Read eeprom i2c.read(EEPROM_ADDRESS, buffer, 12); #endif Delay(1000); }
/********************************************************************* ** @fn : ** ** @brief : ** ** @param : ** ** @return : *********************************************************************/ static void Module_Init(void) { EVL_Board_Init(); UART_Init(); Task_Init(); BuffPool_Init(); GPRS_Init(); GPS_Init(); NetFrame_Init(); Systick_Init(); }
int main(void) { Systick_Init(); while (1) { temperature = mcp9803.get(); Delay(100); } }
void bsp_init(void) { SystemInit(); //系统时钟初始化 Timer3_init(); Systick_Init(); LED_GPIO_Config();//LED引脚初始化 Moto_Init(); //电机初始化 I2c_Init(); //IIC初始化 Delay_ms(50); }
int main(void) { Systick_Init(); tick.attach(&blink, 1); //tick.attach_us(&blink, 15); while(1) { led6 = !led6; Delay(1); } }
int main(void) { char buffer[] = "HelloWorld!"; Systick_Init(); while (1) { spi.cs(0); spi.write(buffer, 12); spi.cs(1); Delay(1); } }
int main(void) { Systick_Init(); pushButton.rise(&Push); while (1) { led6 = !led6; Delay(100); // if(pushButton) led2 = 1; // else led2 = 0; } }
int main(void) { Systick_Init(); tick.attach(&blink1, 1000); pwm.enable_irq(); pwm.attach(&blink2); pwm = 0.5; while(1) { } }
int main(void) { Systick_Init(); time.hours = 10; time.minutes = 30; time.seconds = 0; clock.set(time); // Alarm set to 10 sec clock.alarm(10, &toggle); while (1) { clock.get(&time); } }
int main() { Systick_Init(); while(1) { timer.start(); begin = timer.read_us(); Delay(1000); led = !led; end = timer.read_us(); elapsed = end - begin; } }
int main(void) { char i = 0; Systick_Init(); button.rise(&toggle); while (1) { Delay(250); led1 = !led1; if(i >= 20) { i = 0; led1 = 0; power.stop(); } else i++; } }
int main(void) { Systick_Init(); // Callback executed every 1 ms (1000 us) tick.attach_us(&GlobalBaseTime, 1000); // Add seven segment into a group sevenSegGroup.add(&sevenSeg0); sevenSegGroup.add(&sevenSeg1); sevenSegGroup.add(&sevenSeg2); sevenSegGroup.add(&sevenSeg3); sevenSegGroup.add(&sevenSeg4); sevenSegGroup.add(&sevenSeg5); //sevenSegGroup.effect((char*)test1, 8, 3, 50); sevenSegGroup.effect((char*)test2, 8, 4, 50); //sevenSegGroup.effect((char*)test3, 6, 1, 50); while (1) { sevenSegGroup.update(); } }
int main(void) { uint8_t buf[HID_OUT_BUFFER_SIZE-1], RepeatCounter = 0; IRMP_DATA myIRData; int8_t ret; /* first wakeup slot empty? */ uint8_t learn_wakeup = eeprom_restore(buf, (MACRO_DEPTH + 1) * SIZEOF_IR/2 * MACRO_SLOTS); USB_HID_Init(); LED_Switch_init(); IRMP_Init(); irsnd_init(); FLASH_Unlock(); EE_Init(); Systick_Init(); while (1) { if (!AlarmValue) Wakeup(); wakeup_reset(); /* test if USB is connected to PC and command is received */ if (USB_HID_GetStatus() == USB_HID_CONNECTED && USB_HID_ReceiveData(buf) == RX_READY && buf[0] == STAT_CMD) { switch ((enum access) buf[1]) { case ACC_GET: ret = get_handler(buf); break; case ACC_SET: ret = set_handler(buf); break; case ACC_RESET: ret = reset_handler(buf); break; default: ret = -1; } if (ret == -1) { buf[0] = STAT_FAILURE; ret = 3; } else { buf[0] = STAT_SUCCESS; } /* send configuration data */ USB_HID_SendData(REPORT_ID_CONFIG, buf, ret); toggle_LED(); } /* poll IR-data */ if (irmp_get_data(&myIRData)) { if (learn_wakeup) { /* store received wakeup IRData in first wakeup slot */ eeprom_store((MACRO_DEPTH + 1) * SIZEOF_IR/2 * MACRO_SLOTS, (uint8_t *) &myIRData); learn_wakeup = 0; } if (!(myIRData.flags)) { RepeatCounter = 0; } else { RepeatCounter++; } if (RepeatCounter == 0 || RepeatCounter >= MIN_REPEATS) { toggle_LED(); /* if macros are sent already, while the trigger IR data are still repeated, * the receiving device may crash */ check_macros(&myIRData); check_wakeups(&myIRData); } /* send IR-data */ memcpy(buf, &myIRData, sizeof(myIRData)); USB_HID_SendData(REPORT_ID_IR, buf, sizeof(myIRData)); } } }
int main(void) { uint8_t buf[HID_OUT_BUFFER_SIZE-1]; IRMP_DATA myIRData; int8_t ret; LED_Switch_init(); Systick_Init(); USB_Reset(); USB_HID_Init(); USB_DISC_release(); IRMP_Init(); irsnd_init(); FLASH_Unlock(); EE_Init(); irmp_set_callback_ptr (led_callback); while (1) { if (!AlarmValue) Wakeup(); if (!send_ir_on_delay) send_magic(); wakeup_reset(); /* test if USB is connected to PC, sendtransfer is complete and configuration command is received */ if (USB_HID_GetStatus() == CONFIGURED && PrevXferComplete && USB_HID_ReceiveData(buf) == RX_READY && buf[0] == STAT_CMD) { switch ((enum access) buf[1]) { case ACC_GET: ret = get_handler(buf); break; case ACC_SET: ret = set_handler(buf); break; case ACC_RESET: ret = reset_handler(buf); break; default: ret = -1; } if (ret == -1) { buf[0] = STAT_FAILURE; ret = 3; } else { buf[0] = STAT_SUCCESS; } /* send configuration data */ USB_HID_SendData(REPORT_ID_CONFIG, buf, ret); blink_LED(); if(Reboot) reboot(); } /* poll IR-data */ if (irmp_get_data(&myIRData)) { myIRData.flags = myIRData.flags & IRMP_FLAG_REPETITION; if (!(myIRData.flags)) { store_wakeup(&myIRData); check_macros(&myIRData); check_wakeups(&myIRData); check_resets(&myIRData); check_reboot(&myIRData); } /* send IR-data */ USB_HID_SendData(REPORT_ID_IR, (uint8_t *) &myIRData, sizeof(myIRData)); } } }