Ejemplo n.º 1
0
void Run_Main(){
  Init_Devicelib();
  Init_Device(Init_Button);
  InitUartStruct(CMDBUF,USB);
  AddGPIOHook(USBPIN,1,Reset,0);  //插拔USB就RESET
  //AddGPIOHook(USBPIN,3,PowerDownLongTime,0);  //插拔USB就RESET
  Init_RTOS();
  Init_RTC();
  Start_RTC(Show_DateTime);
  LoadTime();
  Beep1Sec();
  P2DIR&=~USBPIN;
  //P5DIR|=BIT5;  P5OUT|=BIT5;   //USB Reset pin pull hi
  if((P2IN&USBPIN)!=0){
    if(BattStruct.BattDetectState==0){Open_BattDetect();}
    //AddGPIOHook(USBPIN,2,PowerDown,0);  //插拔USB就RESET
    Run_RTOS(BackGroundUSBTask,0,ShowPIC1Page,10);
  }else{
    PowerOffAfter5Sec=0;
    //CurrentNode=Standby;
    //PowerDown();  //程式一初始會停在這
    CurrentNode=Main_DateTime;
    PowerOn();
    Run_RTOS(BackGroundTask,0,ShowPIC1Page,10);
  }
}
Ejemplo n.º 2
0
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                                           ;
}
Ejemplo n.º 3
0
void bsp_start( void )
{
  /* BSP Hardware Initialization*/
  Init_RTC();   /* Blackfin Real Time Clock initialization */
  Init_PLL();   /* PLL initialization */
  Init_EBIU();  /* EBIU initialization */
  Init_Flags(); /* GPIO initialization */

  int i=0;
  for (i=5;i<16;i++) {
    set_vector((rtems_isr_entry)null_isr, i, 1);
  }
}
Ejemplo n.º 4
0
void bsp_start( void )
{
  /* BSP Hardware Initialization*/
  Init_RTC();   /* Blackfin Real Time Clock initialization */  
  Init_PLL();   /* PLL initialization */
  Init_EBIU();  /* EBIU initialization */
  Init_Flags(); /* GPIO initialization */

  /*
   *  Allocate the memory for the RTEMS Work Space.  This can come from
   *  a variety of places: hard coded address, malloc'ed from outside
   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
   *  typically done by stock BSPs) by subtracting the required amount
   *  of work space from the last physical address on the CPU board.
   */
  int i=0;
  for (i=5;i<16;i++) {
    set_vector((rtems_isr_entry)null_isr, i, 1);
  }
  
}
Ejemplo n.º 5
0
Archivo: init.c Proyecto: rngadam/mboot
int main(void)
{
	BTNDIS_P();
	Init_EMIF();
	Init_LEDS();
	Init_TIMER();
	Init_FPGA();
	Init_UART();
	Init_TWI(100000);
	
	mbootBanner();
	
	Init_RTC();
	Init_Media();
	Init_SHA204();
	Init_EMAC();
	SYS_UNRESET();
	
	mboot();

	while(1);
	// return 0;
}
Ejemplo n.º 6
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{

  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f072xb.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */

  Configure_GPIO_LED();
  Configure_GPIO_USART1();
  Configure_USART1();
  Configure_RTC();
  Init_RTC(0);
  Configure_GPIO_Button();
  Configure_EXTI();
  
  /* Infinite loop */
  while (1)
  {
    Process();
  }
}
Ejemplo n.º 7
0
/**
 * @brief  Main function to show how to use BlueNRG Bluetooth Low Energy
 *         stack.
 *         To test this application you need:
 *         - an STM32 Nucleo board with its BlueNRG STM32 expansion board
 *         - a Smartphone with Bluetooth Low Energy (BLE) chip and Android
 *           OS >= v4.3.
 *         On the Android smartphone the STM32_BLE_Toolbox App must be installed
 *         and running.
 *         The STM32_BLE_Toolbox App can be found in this package at:
 *         $PATH_TO_THIS_PACKAGE$\Utilities\Android_Software\Profiles_Central
 *         This sample application configures the board as Server-Peripheral,
 *         while the smartphone plays the Client-Central role.
 *         To set/change the BLE Profile to test, change the value of the macro
 *         BLE_CURRENT_PROFILE_ROLES (in the "active profile" section) in file:
 *         $PATH_TO_THIS_PACKAGE$\Middlewares\ST\STM32_BlueNRG\Profile_Framework
 *         \includes\host_config.h
 *         For example, if the HEART_RATE profile is set, after the connection
 *         between the board and the smartphone has been established, the
 *         STM32_BLE_Toolbox App will show the Heart Rate values in bpm (beats
 *         per minute) coming from the STM32 Nucleo board.
 *         The communication is done using a vendor specific profile.
 *
 * @param  None
 * @retval None
 */
int main(void)
{
#if (JTAG_SUPPORTED == 1) 
  /*
  * Keep debugger enabled while in any low power mode
  */
#ifdef STM32L053xx
  __DBGMCU_CLK_ENABLE();
  HAL_DBG_LowPowerConfig(DBGMCU_SLEEP | DBGMCU_STOP | DBGMCU_STANDBY, ENABLE);
#endif /* STM32L053xx */
  
#ifdef STM32L476xx
  HAL_DBGMCU_EnableDBGSleepMode();
  HAL_DBGMCU_EnableDBGStopMode();
  HAL_DBGMCU_EnableDBGStandbyMode();
#endif /* STM32L476xx */

#ifdef STM32F401xE 
  HAL_EnableDBGSleepMode();
  HAL_EnableDBGStopMode();
  HAL_EnableDBGStandbyMode();
#endif /* STM32F401xE */

#endif /* (JTAG_SUPPORTED == 1) */
 
  /* STM32Cube HAL library initialization:
   *  - Configure the Flash prefetch, Flash preread and Buffer caches
   *  - Systick timer is configured by default as source of time base, but user 
   *    can eventually implement his proper time base source (a general purpose 
   *    timer for example or other time source), keeping in mind that Time base 
   *    duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
   *    handled in milliseconds basis.
   *  - Low Level Initialization
   */
  HAL_Init();
  
  /* Configure the system clock */
  SystemClock_Config();
  
  /* Configure the system Power */
  SystemPower_Config();
    
  /* Initialize the Profile Application Context's Data Structures */
  Osal_MemSet(&profileApplContext,0,sizeof(tProfileApplContext));
  
  /* Configure the RTC */
  Init_RTC();
  TIMER_Init(&hrtc);
  TIMER_Create(eTimerModuleID_BlueNRG_Profile_App, &(profileApplContext.profileTimer_Id), eTimerMode_Repeated, 0);
  
  LPM_Mode_Request(eLPM_MAIN_LOOP_PROCESSES, eLPM_Mode_LP_Stop);  
  
  /* Initialize the BlueNRG SPI driver */
  BNRG_SPI_Init();
  
  /* Set current BlueNRG profile (HRM, HTM, GS, ...) */
  BNRG_Set_Current_profile();
  
  /* Initialize the BlueNRG Profile */
  /* set tx power and security parameters (common to all profiles) */
  BNRG_Profiles_Init();  
  /* low level profile initialization (profile specific) */
  profileApplContext.initProfileFunc();
  
  /* Start the main processes */
  while(1)
  {
    Background();
    
  } /* end while(1) */  
}
Ejemplo n.º 8
0
/**
  * @brief  This function processes RTC with USART.
  * @param  None
  * @retval None
  */
void Process(void)
{
  volatile uint32_t TimeToCompute = 0;
  static uint32_t NewTime=0;
  
  switch(RTC_InitializationMode)
  {
  case 0:
    /* check alarm and synchronisation flag */
    if((Alarm)&&((RTC->ISR & RTC_ISR_RSF) == RTC_ISR_RSF))
    {
      Alarm=0;
      
      TimeToCompute = RTC->TR; /* get time */
      DateToCompute = RTC->DR; /* need to read date also */
      
      stringtosend[1] = (uint8_t)(((TimeToCompute & RTC_TR_HT)>>20) + 48);/* hour tens */
      stringtosend[2] = (uint8_t)(((TimeToCompute & RTC_TR_HU)>>16) + 48);/* hour units */
      stringtosend[6] = (uint8_t)(((TimeToCompute & RTC_TR_MNT)>>12) + 48);/* minute tens */
      stringtosend[7] = (uint8_t)(((TimeToCompute & RTC_TR_MNU)>>8) + 48);/* minute units */
      stringtosend[11] = (uint8_t)(((TimeToCompute & RTC_TR_ST)>>4) + 48);/* second tens */
      stringtosend[12] = (uint8_t)((TimeToCompute & RTC_TR_SU) + 48);/* second units */
      
      /* start USART transmission */
      USART1->TDR = stringtosend[send++]; /* Will inititiate TC if TXE */
    }
  break;
  case 1:      
    {
      if(!send)
      {
        strcpy((char *)stringtosend,"\nSend hour tens\n");
        USART1->TDR = stringtosend[send++]; /* Will inititiate TC if TXE */
        RTC_InitializationMode=2;
      }
    }
    break;
  case 2: /* Hour tens */
    {
       if(CharReceived)
      {
        CharReceived=0;
        CharToReceive -= 48;
        NewTime = CharToReceive << 20;
        RTC_InitializationMode=3;
      }
    }
    break;
  case 3:      
    {
      if(!send)
      {
        strcpy((char *)stringtosend,"\nSend hour units\n");
        USART1->TDR = stringtosend[send++]; /* Will inititiate TC if TXE */
        RTC_InitializationMode=4;
      }
    }
    break;
  case 4: /* Hour units */
    {
       if(CharReceived)
      {
        CharReceived=0;
        CharToReceive -= 48;
        NewTime |= CharToReceive << 16;
        RTC_InitializationMode=5;
      }
    }
    break;
  case 5:      
    {
      if(!send)
      {
        strcpy((char *)stringtosend,"\nSend minute tens\n");
        USART1->TDR = stringtosend[send++]; /* Will inititiate TC if TXE */
        RTC_InitializationMode=6;
      }
    }
    break;
  case 6: /* Minute tens */
    {
      if(CharReceived)
      {
        CharReceived=0;
        CharToReceive -= 48;
        NewTime |= CharToReceive << 12;
        RTC_InitializationMode=7;
      }
    }
    break;
  case 7:      
    {
      if(!send)
      {
        strcpy((char *)stringtosend,"\nSend minute units\n");
        USART1->TDR = stringtosend[send++]; /* Will inititiate TC if TXE */
        RTC_InitializationMode=8;
      }
    }
    break;
  case 8: /* Minute units */
    {
      if(CharReceived)
      {
        CharReceived=0;
        CharToReceive -= 48;
        NewTime |= CharToReceive << 8;
        RTC_InitializationMode=9;
      }
    }
    break;
  case 9:      
    {
      if(!send)
      {
        strcpy((char *)stringtosend,"\nSend second tens\n");
        USART1->TDR = stringtosend[send++]; /* Will inititiate TC if TXE */
        RTC_InitializationMode=10;
      }
    }
    break;
  case 10: /* Second tens */
    {
       if(CharReceived)
      {
        CharReceived=0;
        CharToReceive -= 48;
        NewTime |= CharToReceive << 4;
        RTC_InitializationMode=11;
      }
    }
    break;
  case 11:      
    {
      if(!send)
      {
        strcpy((char *)stringtosend,"\nSend second units\n");
        USART1->TDR = stringtosend[send++]; /* Will inititiate TC if TXE */
        RTC_InitializationMode=12;
      }
    }
    break;
  case 12: /* Second Units */
    {
       if(CharReceived)
      {
        CharReceived=0;
        CharToReceive -= 48;
        NewTime |= CharToReceive;
        RTC_InitializationMode=13;
      }
    }
    break;
  case 13:
    {
      if (NewTime > (2<<20 | 3<<16 | 5<<12 | 9<<8 | 5<<4 | 9<<0))
      {
        NewTime = 0;
      }
      Init_RTC(NewTime);
      strcpy((char *)stringtosend,"\n-- : -- : --      ");
      RTC_InitializationMode=0;
      GPIOC->BSRR = GPIO_BSRR_BR_8 ; /* Off Orange LED */
    }
    break;
  }