/*----------------------------------------------------------------------------
 * 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");
  }

}
/*----------------------------------------------------------------------------
 * 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
    }
  }

}
Exemple #3
0
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();
  }
}
Exemple #4
0
bool Putz01Init (void) {
	puts ("\r\n\nPutz01Init() Enter\r");
	Buttons_Initialize();
	LED_Initialize();
	CheckSignalsForLife();
	puts ("Putz01Init() Leave\r");
	return true;
}
void ModeControl_Initialize(void) {
	LED_Initialize(); // TEMP
	PORTC_PCR5 = PORT_PCR_IRQC(10) | PORT_PCR_MUX(1) ;
	GPIOC_PDDR |= (0 << 5);
	NVIC_EnableIRQ(PORTC_IRQn);// TEMP

	ModeControl_changeMode(0);
	previousMode = NUM_OF_MODES-1;
}
Exemple #6
0
/* 
* main: initialize and start the system */ 
int main (void) 
{ 
osKernelInitialize (); // Initialize CMSIS-RTOS 
// initialize peripherals here 
LED_Initialize (); // Initialize LEDs 
// create 'thread' functions that start executing, 
// example: tid_name = osThreadCreate (osThread(name), NULL); 
Init_BlinkyThread (); // Start Blinky thread 
osKernelStart (); // Start thread execution 
while (1); 
}
Exemple #7
0
/*----------------------------------------------------------------------------
 *      Main: Initialize and start RTX Kernel
 *---------------------------------------------------------------------------*/
int main (void) {

  LED_Initialize();                         /* Initialize the LEDs           */
  tid_phaseA = osThreadCreate(osThread(phaseA), NULL);
  tid_phaseB = osThreadCreate(osThread(phaseB), NULL);
  tid_phaseC = osThreadCreate(osThread(phaseC), NULL);
  tid_phaseD = osThreadCreate(osThread(phaseD), NULL);
  tid_clock  = osThreadCreate(osThread(clock),  NULL);

  osSignalSet(tid_phaseA, 0x0001);          /* set signal to phaseA thread   */

  osDelay(osWaitForever);
  while(1);
}
/*----------------------------------------------------------------------------
 *        Main: Initialize and start RTX Kernel
 *---------------------------------------------------------------------------*/
int main (void) 
{
	osKernelInitialize ();                    
	LED_Initialize();
	Turnstile =	osSemaphoreCreate(osSemaphore(Turnstile), 0); // 0 tokens
	Turnstile2 = osSemaphoreCreate(osSemaphore(Turnstile2), 1); // 1 token
	Mutex =	osSemaphoreCreate(osSemaphore(Mutex), 1);	
	tsk2_0 = osThreadCreate(osThread(threadBaseCode),(void *) 1U);
	tsk2_1 = osThreadCreate(osThread(threadBaseCode),(void *) 2U); 
	tsk2_2 = osThreadCreate(osThread(threadBaseCode),(void *) 3U);
	tsk2_3 = osThreadCreate(osThread(threadBaseCode),(void *) 4U);
	tsk2_4 = osThreadCreate(osThread(threadBaseCode),(void *) 5U);

	osKernelStart ();                         
}
Exemple #9
0
/*----------------------------------------------------------------------------
 * 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);
  }
}
Exemple #11
0
/*--------------------------------------------*/
int main(void) {	
	 
	LED_Initialize();

    /* Create processes */ 
    if (process_create(pNRT, NRT_STACK) < 0) { return -1; }
    if (process_rt_create(pRT1, RT_STACK, &t_pRT1, &t_10sec, &t_1msec) < 0) { return -1; } 
   
    /* Launch concurrent execution */
	process_start();

  LED_Off();
  while(process_deadline_miss>0) {
		LEDGreen_On();
		shortDelay();
		LED_Off();
		shortDelay();
		process_deadline_miss--;
	}
	
	/* Hang out in infinite loop (so we can inspect variables if we want) */ 
	while (1);
	return 0;
}
Exemple #12
0
int main(void)
{
    SYSTEM_Initialize(SYSTEM_STATE_USB_START);
    LED_Initialize();
    APP_KeyboardConfigure();

#ifdef WITH_HOS
    HosCheckDFU(BOOT_FLAGS_VALUE & BOOT_WITH_APP);
    if (!isUSBMode() || !isBusPowered()) {
        HosMainLoop();
    }
    for (uint16_t i = 0; i < HOS_STARTUP_DELAY; ++i) {
        if (HosSleep(HOS_TYPE_DEFAULT)) {
            break;
        }
        __delay_ms(4);
    }
#endif

    USBDeviceInit();
    USBDeviceAttach();

    for (;;)
    {
#ifdef WITH_HOS
        if (!isBusPowered() || !isUSBMode()) {
            Reset();
            Nop();
            Nop();
            // NOT REACHED HERE
        }
#endif

        SYSTEM_Tasks();

#if defined(USB_POLLING)
        /* Check bus status and service USB interrupts.  Interrupt or polling
         * method.  If using polling, must call this function periodically.
         * This function will take care of processing and responding to SETUP
         * transactions (such as during the enumeration process when you first
         * plug in).  USB hosts require that USB devices should accept and
         * process SETUP packets in a timely fashion.  Therefore, when using
         * polling, this function should be called regularly (such as once every
         * 1.8ms or faster** [see inline code comments in usb_device.c for
         * explanation when "or faster" applies])  In most cases, the
         * USBDeviceTasks() function does not take very long to execute
         * (ex: <100 instruction cycles) before it returns. */
        USBDeviceTasks();
#endif

        APP_LEDUpdateUSBStatus();

        /* If the USB device isn't configured yet, we can't really do anything
         * else since we don't have a host to talk to.  So jump back to the
         * top of the while loop. */
        if (USBGetDeviceState() < CONFIGURED_STATE)
        {
            /* Jump back to the top of the while loop. */
            continue;
        }

        /* If we are currently suspended, then we need to see if we need to
         * issue a remote wakeup.  In either case, we shouldn't process any
         * keyboard commands since we aren't currently communicating to the host
         * thus just continue back to the start of the while loop. */
        if (USBIsDeviceSuspended())
        {
            //Check if we should assert a remote wakeup request to the USB host,
            //when the user presses the pushbutton.
            if (BUTTON_IsPressed())
            {
                USBCBSendResume();  //Does nothing unless we are in USB suspend with remote wakeup armed.
            }

            /* Jump back to the top of the while loop. */
            continue;
        }

        if (USBIsBusSuspended())
        {
            /* Jump back to the top of the while loop. */
            continue;
        }

        /* Run the keyboard tasks. */
        APP_KeyboardTasks();
    }//end while
}//end main
Exemple #13
0
int main (void) {
  int32_t max_num = LED_GetCount() - 1;
  int32_t num = 0;
  int32_t dir = 1;
  uint32_t keyMsk, adcVal;
  int32_t key  = -1;
  int32_t adc  = -1;

  SystemCoreClockUpdate();

  LED_Initialize();                         /* LED Initialization             */
  ADC_Initialize();                         /* A/D Converter Init             */
  Buttons_Initialize();                     /* Button initialization          */
  GLCD_Initialize();                        /* Initialize the GLCD            */

  SysTick_Config(SystemCoreClock/100);      /* Generate interrupt each 10 ms  */

  GLCD_SetBackgroundColor (GLCD_COLOR_WHITE);
  GLCD_ClearScreen ();

  GLCD_SetBackgroundColor (GLCD_COLOR_BLUE);
  GLCD_SetForegroundColor (GLCD_COLOR_WHITE);
  GLCD_SetFont            (&GLCD_Font_16x24);
  GLCD_DrawString (0*16, 0*24, " STM32303C-EVAL Demo");
  GLCD_DrawString (0*16, 1*24, "  Blinky Example    ");
  GLCD_DrawString (0*16, 2*24, "   www.keil.com     ");
  GLCD_SetBackgroundColor (GLCD_COLOR_WHITE);
  GLCD_SetForegroundColor (GLCD_COLOR_BLUE);

  GLCD_DrawString (0*16, 5*24, "LEDs:               ");
  GLCD_DrawString (0*16, 6*24, "AD value:           ");
  GLCD_DrawString (0*16, 7*24, "Buttons :           ");
  GLCD_SetForegroundColor (GLCD_COLOR_LIGHT_GREY);
  GLCD_DrawString (9*16, 5*24, "0123");

  while (1) {
    /* Force refresh */
    key = -1;
    adc = -1;

    if (LEDOn) {
      LEDOn = 0;
      LED_On (num);                         /* Turn specified LED on          */
      GLCD_SetForegroundColor (GLCD_COLOR_RED);
      GLCD_DrawChar ((9+num)*16, 5*24, numStr[num]);
    }

    if (LEDOff) {
      LEDOff = 0;
      LED_Off (num);                        /* Turn specified LED off         */
      GLCD_SetForegroundColor (GLCD_COLOR_LIGHT_GREY);
      GLCD_DrawChar ((9+num)*16, 5*24, numStr[num]);

      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         */
      }
    }

    keyMsk = Buttons_GetState();            /* Show buttons state             */
    if (key ^ keyMsk) {
      GLCD_SetForegroundColor (GLCD_COLOR_BLACK);
      if (keyMsk & KEY_USER  )    { GLCD_DrawString (9*16, 7*24, "Key");   }

      GLCD_SetForegroundColor (GLCD_COLOR_LIGHT_GREY);
      if (!(keyMsk & KEY_USER  )) { GLCD_DrawString (9*16, 7*24, "Key");   }
    }

    ADC_StartConversion();                  /* Show A/D conversion bargraph   */
    adcVal = ADC_GetValue();
    if (adc ^ adcVal) {
      adc = adcVal;
      GLCD_SetForegroundColor (GLCD_COLOR_GREEN);
      GLCD_DrawBargraph (9*16, 6*24, 160, 20, (adcVal * 100) / ((1 << ADC_GetResolution()) - 1));
    }
  }
}