/*---------------------------------------------------------------------------- * main: blink LED and check button state *----------------------------------------------------------------------------*/ int main (void) { int32_t max_num = LED_GetCount() - 1; int32_t num = 0; int32_t dir = 1; SystemCoreClockConfigure(); // configure HSI as System Clock SystemCoreClockUpdate(); LED_Initialize(); Buttons_Initialize(); SysTick_Config(SystemCoreClock / 1000); // SysTick 1 msec interrupts for (;;) { LED_On(num); // Turn specified LED on Delay(500); // Wait 500ms while (Buttons_GetState() & (1 << 0)); // Wait while holding USER button LED_Off(num); // Turn specified LED off Delay(500); // Wait 500ms while (Buttons_GetState() & (1 << 0)); // Wait while holding USER button num += dir; // Change LED number if (dir == 1 && num == max_num) { dir = -1; // Change direction to down } else if (num == 0) { dir = 1; // Change direction to up } } }
/*---------------------------------------------------------------------------- * main: blink LED and check button state *----------------------------------------------------------------------------*/ int main (void) { int32_t max_num = LED_GetCount(); int32_t num = 0; SystemCoreClockConfigure(); // configure HSI as System Clock SystemCoreClockUpdate(); LED_Initialize(); Buttons_Initialize(); SER_Initialize(); SysTick_Config(SystemCoreClock / 1000); // SysTick 1 msec interrupts for (;;) { LED_On(num); // Turn specified LED on // Delay(100); // Wait 500ms // while (Buttons_GetState() & (1 << 0)); // Wait while holding USER button LED_Off(num); // Turn specified LED off // Delay(100); // Wait 500ms // while (Buttons_GetState() & (1 << 0)); // Wait while holding USER button // num++; // Change LED number // if (num >= max_num) { // num = 0; // Restart with first LED // } // printf ("Hello World\n\r"); } }
int main() { SystemCoreClockConfigure(); // configure HSI as System Clock SystemCoreClockUpdate(); LED_Initialize(); Buttons_Initialize(); ecl_timer_init(timers, N_TIMERS); // The LEDs will start flashing fast after 2 seconds. // After another 5 seconds they will start flashing slower. short_toggle = ecl_timer_register(LedToggle, 50, ECL_TIMER_REPEATING); long_toggle = ecl_timer_register(LedToggle, 100, ECL_TIMER_REPEATING); start_timers = ecl_timer_register(StartTimers, 2000, ECL_TIMER_SINGLE_SHOT); swap_timers = ecl_timer_register(SwapTimers, 1500, ECL_TIMER_SINGLE_SHOT); SysTick_Config(SystemCoreClock / 1000); ecl_timer_enable(ECL_TIMER_ENABLED); ecl_timer_start(start_timers, ECL_TIMER_START_DELAYED); while (1) { __NOP(); } }
/*---------------------------------------------------------------------------- * main: initialize and start the system *----------------------------------------------------------------------------*/ int main (void) { uint32_t button_msk = (1U << Buttons_GetCount()) - 1; osKernelInitialize (); // initialize CMSIS-RTOS // initialize peripherals SystemCoreClockConfigure(); // configure System Clock SystemCoreClockUpdate(); LED_Initialize(); // LED Initialization Buttons_Initialize(); // Buttons Initialization // create threads tid_blinkLED = osThreadCreate (osThread(blinkLED), NULL); osKernelStart (); // start thread execution DAC_init(); DAC_enable(); for(Counter=0;Counter<182;Counter++) { DAC_value2[Counter]=DAC_value1[Counter]/2; } Counter=0; for (;;) { if (Counter<=0)Direction=0; else if (Counter>179)Direction=1; if (Direction==0)Counter++; else Counter--; DAC_write(DAC_value2[Counter]); // DAC_write(4000); // osDelay(100); // while (Buttons_GetState() & (button_msk)); // Wait while holding USER button // DAC_write(0); // osSignalSet(tid_blinkLED, 0x0001); } }
/*---------------------------------------------------------------------------- * main: initialize and start the system *----------------------------------------------------------------------------*/ int main (void) { uint32_t button_msk = (1U << Buttons_GetCount()) - 1; osKernelInitialize (); // initialize CMSIS-RTOS // initialize peripherals SystemCoreClockConfigure(); // configure System Clock SystemCoreClockUpdate(); LED_Initialize(); // LED Initialization Buttons_Initialize(); // Buttons Initialization // create threads tid_blinkLED = osThreadCreate (osThread(blinkLED), NULL); osKernelStart (); // start thread execution for (;;) { // main must not be terminated! osDelay(500); while (Buttons_GetState() & (button_msk)); // Wait while holding USER button osSignalSet(tid_blinkLED, 0x0001); } }