예제 #1
0
void  BSP_Init (void)
{
		// Interrupt initialization
    BSP_IntInit();
		
		// Initailize system services, clocks, etc.
    BSP_SysInit();             

		// RGB LED initialization
    BSP_LED_Init();
	
		// Push Button initialization
		BSP_SWITCH_Init();
	
		// PIR sensor initialization
		BSP_PIR_Init();
	
		// UART initialization
		BSP_UART_Init();
	
		// Semaphore Create
		sharedDataSem = OSSemCreate(1);
		
		// semaphore Create
		sharedDataSemUart = OSSemCreate(1);
		
		// Mailbox Create
		MailBox1 = OSMboxCreate(&global_pir_val);
	
}
예제 #2
0
void  BSP_Init (void)
{
    BSP_IntDisAll();                                            /* Disable all interrupts.                              */

  	/* M4F FPU settings --------------------------------------------------------*/
#ifdef __TARGET_FPU_VFP
    SCB->CPACR |= ((3UL << 10*2) |                 	/* set CP10 Full Access */
                   (3UL << 11*2)  );               	/* set CP11 Full Access */
    //FPU->FPCCR &= ~(3 << 30);						/* Disable automatic FP register content (bit 31) */
    //												/* Disable Lazy context switch (bit 30) */
#endif

  	/* Enable external crystal and PLL -----------------------------------------*/
	BSP_Enable_Clock(CLK_XTL_12M);								/* Enable external external 4 ~ 22M input               */

    // Enable UART0 clock
    CLK->APBCLK0 |= CLK_APBCLK0_UART0CKEN_Msk;
    
    // Select external 12 MHz as UART clock source 
    CLK->CLKSEL1 &= ~CLK_CLKSEL1_UARTSEL_Msk;
    
    /* Set GPG multi-function pins for UART0 RXD and TXD */
    SYS->GPG_MFPL = SYS_GPG_MFPL_PG1MFP_UART0_RXD | SYS_GPG_MFPL_PG2MFP_UART0_TXD ;

    UART0->LINE |= 0x07;	
    UART0->BAUD = 0x30000066;	/* 12MHz reference clock input, for 115200 */

    BSP_IntInit();

    BSP_Tick_Init();                                            /* Start Tick Initialization                            */
}
예제 #3
0
파일: bsp.c 프로젝트: nhaberla/stm32f4
void  BSP_Init (void)
{
  BSP_IntInit();

  STM_EVAL_LEDInit(LED4);
  STM_EVAL_LEDInit(LED5);
  STM_EVAL_LEDInit(LED6);
  STM_EVAL_LEDInit(LED3);

  BSP_PB_Init();
}
예제 #4
0
void  BSP_Init (void)
{
    BSP_IntInit();                                              /* Initialize Interrupts.                               */

    BSP_REG_SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK                  /* Enable all the port Clocks                           */
                      |   SIM_SCGC5_PORTB_MASK
                      |   SIM_SCGC5_PORTC_MASK
                      |   SIM_SCGC5_PORTD_MASK
                      |   SIM_SCGC5_PORTE_MASK);

                                                                /* Init System tick times.                              */
                                                                /* Clear pending interrupt.                             */

    CPU_REG_NVIC_ST_RELOAD  = (2000000UL);                      /* Set period.                                          */
    CPU_REG_NVIC_ST_CTRL   |=  SysTick_CSR_CLKSOURCE_MASK;      /* Clock source - System Clock.                         */
    CPU_REG_NVIC_ST_CTRL   |=  SysTick_CSR_TICKINT_MASK;        /* Enable interrupt.                                    */
    CPU_REG_NVIC_ST_CTRL   |=  SysTick_CSR_ENABLE_MASK;         /* Start Sys Timer.                                     */


    BSP_CPU_ClkFreq_MHz = BSP_CPU_ClkFreq() / (CPU_INT32U)1000000;

    BSP_CPU_ClkFreq_MHz = BSP_CPU_ClkFreq_MHz;                  /* Surpress compiler warning BSP_CPU_ClkFreq_MHz.       */

    BSP_PLL_Init();

    BSP_LED_Init();                                             /* Initialize the I/Os for the LEDs.                    */

    BSP_SW_Init();                                              /* Initialize the I/Os for the switches.                */

    BSP_TSI_Init();                                             /* Initialize the TSI module.                           */

    BSP_IRC_Init();                                             /* Initialize the High-Speed Internal Reference Clock.  */

#ifdef TRACE_EN                                                 /* See project / compiler preprocessor options.         */
    DBGMCU_CR |=  DBGMCU_CR_TRACE_IOEN_MASK;                    /* Enable tracing (see Note #2).                        */
    DBGMCU_CR &= ~DBGMCU_CR_TRACE_MODE_MASK;                    /* Clr trace mode sel bits.                             */
    DBGMCU_CR |=  DBGMCU_CR_TRACE_MODE_SYNC_04;                 /* Cfg trace mode to synch 4-bit.                       */
#endif
}
예제 #5
0
파일: bsp.c 프로젝트: CaryHWSZ/Linux
void  BSP_Init (void)
{
    BSP_IntInit();

    RCC_DeInit();
    RCC_HSEConfig(RCC_HSE_ON);
    RCC_WaitForHSEStartUp();


    RCC_HCLKConfig(RCC_SYSCLK_Div1);
    RCC_PCLK2Config(RCC_HCLK_Div1);
    RCC_PCLK1Config(RCC_HCLK_Div2);
    RCC_ADCCLKConfig(RCC_PCLK2_Div6);
    FLASH_SetLatency(FLASH_Latency_2);
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
    RCC_PLLCmd(ENABLE);

    while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {
        ;
    }

    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

    while (RCC_GetSYSCLKSource() != 0x08) {
        ;
    }

    BSP_ADC_Init();                                             /* Initialize the I/Os for the ADC      controls.       */
    BSP_LED_Init();                                             /* Initialize the I/Os for the LED      controls.       */
    BSP_PB_Init();                                              /* Initialize the I/Os for the PB       control.        */
    BSP_Joystick_Init();                                        /* Initialize the I/Os for the Joystick control.        */

    STM3210E_LCD_Init();
    LCD_Clear(0xFFFF);
}
예제 #6
0
void  BSP_Init (void)
{
    BSP_IntInit();

    RCC_DeInit();
    RCC_HSEConfig(RCC_HSE_ON);                                  /* HSE = 25MHz ext. crystal.                            */
    RCC_WaitForHSEStartUp();


    RCC_PREDIV2Config(RCC_PREDIV2_Div5);                        /* Fprediv2 = HSE      /  5 =  5MHz.                    */
    RCC_PLL2Config(RCC_PLL2Mul_8);                              /* PLL2     = Fprediv2 *  8 = 40MHz.                    */
    RCC_PLL2Cmd(ENABLE);
    RCC_PLL3Config(RCC_PLL3Mul_10);                             /* PLL3     = Fprediv2 * 10 = 50MHz.                    */
    RCC_PLL3Cmd(ENABLE);


    RCC_HCLKConfig(RCC_SYSCLK_Div1);                            /* HCLK    = AHBCLK  = PLL1 / AHBPRES(1) = 72MHz.       */
    RCC_PCLK2Config(RCC_HCLK_Div1);                             /* APB2CLK = AHBCLK  / APB2DIV(1)  = 72MHz.             */
    RCC_PCLK1Config(RCC_HCLK_Div2);                             /* APB1CLK = AHBCLK  / APB1DIV(2)  = 36MHz (max).       */
    RCC_ADCCLKConfig(RCC_PCLK2_Div6);                           /* ADCCLK  = AHBCLK  / APB2DIV / 6 = 12MHz.             */
    RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLL1VCO_Div3);        /* OTGCLK  = PLL1VCO / USBPRES(3)  = 144MHz / 3 = 48MHz */

    FLASH_SetLatency(FLASH_Latency_2);                          /* 2 Flash wait states when HCLK > 48MHz.               */
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

    while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET) {      /* Wait for PLL2 to lock.                               */
        ;
    }

    while (RCC_GetFlagStatus(RCC_FLAG_PLL3RDY) == RESET) {      /* Wait for PLL3 to lock.                               */
        ;
    }

                                                                /* Fprediv1 = PLL2 / 5 =  8MHz.                         */
    RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5);
    RCC_PLL1Config(RCC_PLL1Source_PREDIV1, RCC_PLL1Mul_9);      /* PLL1 = Fprediv1 * 9 = 72Mhz.                         */
    RCC_PLL1Cmd(ENABLE);
    while (RCC_GetFlagStatus(RCC_FLAG_PLL1RDY) == RESET) {      /* Wait for PLL1 to lock.                               */
        ;
    }


    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLL1CLK);                 /* HCLK = SYSCLK = PLL1 = 72MHz.                        */
    while (RCC_GetSYSCLKSource() != 0x08) {
        ;
    }

    BSP_CPU_ClkFreq_MHz = BSP_CPU_ClkFreq() / (CPU_INT32U)1000000;

    BSP_CPU_ClkFreq_MHz = BSP_CPU_ClkFreq_MHz;                  /* Surpress compiler warning BSP_CPU_ClkFreq_MHz    ... */
                                                                /* ... set and not used.                                */

    BSP_LED_Init();                                             /* Initialize the I/Os for the LED      controls.       */

    BSP_StatusInit();                                           /* Initialize the status input(s)                       */

#ifdef TRACE_EN                                                 /* See project / compiler preprocessor options.         */
    DBGMCU_CR |=  DBGMCU_CR_TRACE_IOEN_MASK;                    /* Enable tracing (see Note #2).                        */
    DBGMCU_CR &= ~DBGMCU_CR_TRACE_MODE_MASK;                    /* Clr trace mode sel bits.                             */
    DBGMCU_CR |=  DBGMCU_CR_TRACE_MODE_SYNC_04;                 /* Cfg trace mode to synch 4-bit.                       */
#endif
}
예제 #7
0
파일: bsp.c 프로젝트: drv91680/TestGit
void  BSP_Init (void)
{
    //初始化系统时钟72MHZ
    //SystemInit(); //已在启动代码中调用
	
	
	//使能各个模块时钟
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1
                         |RCC_AHBPeriph_FSMC, 
                         ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO 
                          |RCC_APB2Periph_GPIOA 
                          |RCC_APB2Periph_GPIOB 
                          |RCC_APB2Periph_GPIOC 
                          |RCC_APB2Periph_GPIOD
                          |RCC_APB2Periph_GPIOE 
                          //|RCC_APB2Periph_GPIOF 
                          //|RCC_APB2Periph_GPIOG
                          |RCC_APB2Periph_ADC1   
                          |RCC_APB2Periph_USART1 
                          |RCC_APB2Periph_SPI1  
                          |RCC_APB2Periph_TIM1,
                          //|RCC_APB2Periph_TIM8
                          |RCC_APB2Periph_ADC2  
                          |RCC_APB2Periph_ADC3  
                          ENABLE);
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2
                          |RCC_APB1Periph_TIM3
                          //|RCC_APB1Periph_TIM4
                          //|RCC_APB1Periph_TIM5
                          //|RCC_APB1Periph_TIM6
                          //|RCC_APB1Periph_TIM7
                          |RCC_APB1Periph_USART2
                          |RCC_APB1Periph_USART3
                          |RCC_APB1Periph_UART4
                          |RCC_APB1Periph_UART5
                          |RCC_APB1Periph_SPI2
                          |RCC_APB1Periph_USB,
                          //|RCC_APB1Periph_SPI3
                          //|RCC_APB1Periph_I2C1
                          //|RCC_APB1Periph_I2C2                          
                          //|RCC_APB1Periph_CAN1                          
                          //|RCC_APB1Periph_WWDG
                          //|RCC_APB1Periph_BKP
                          //|RCC_APB1Periph_PWR
                          //|RCC_APB1Periph_DAC
                          ENABLE);  

	//中断向量表初始化
#ifdef  VECT_TAB_RAM
  	/* Set the Vector Table base location at 0x20000000 */
  	NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else  /* VECT_TAB_FLASH  */
  	/* Set the Vector Table base location at 0x08000000 */
  	NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif

	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

	//中断服务程序初始化
	BSP_IntInit();
	
  	//初始化外?
	/* Initialize the I/Os for the ADC      controls. */
    //BSP_ADC_Init(); 
    /* Initialize the I/Os for the LED      controls.  */
    BSP_LED_Init();
	KEY_GPIO_Cfg();                                     
    /* Initialize the I/Os for the Joystick control.        */
	//BSP_Joystick_Init(); 

    //STM3210E_LCD_Init();
    //LCD_Clear(0xFFFF);
	LCD_GPIO_Init();
	LCD_CfgInit();
	
	CommGPIOCfg(COMM1);
	CommGPIOCfg(COMM2);
	CommNVICCfg(COMM1);
	CommNVICCfg(COMM2);
	CommCfg(COMM1);
	CommCfg(COMM2);
	
}