예제 #1
0
파일: main.c 프로젝트: thaigiang/VMS
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{	
	RCC_Configuration();
	GPIO_Configuration();
	USART_Configuration();	
	SysTick_Config(SystemCoreClock/10);
	// Enable the LSI OSC 
 	RCC_LSICmd(ENABLE);
	// Wait till LSI is ready 
	while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) {};
	
 	IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
	// IWDG counter clock: LSI/256 
	IWDG_SetPrescaler(IWDG_Prescaler_256);
	IWDG_SetReload(0x0FFF);
	// Reload IWDG counter 
	IWDG_ReloadCounter();
	// Enable IWDG (the LSI oscillator will be enabled by hardware) 
	IWDG_Enable(); 
	
	// Write memmory
	FLASH_UnlockBank1();
	FLASH_ErasePage(FLAG_ADDR);
	FLASH_ProgramWord(FLAG_ADDR,(u32)FLAG_UPDATED);
	FLASH_LockBank1();
	
	updateFW_control();
}
예제 #2
0
//================================================================================================
// System Pheriperal Initialize
//================================================================================================
void SysConfiguration_Test(void)
{
	RCC_ClocksTypeDef clocks;

	RCC_Configuration();
	GPIO_Configuration();
	USART_Configuration();

	NVIC_Configuration();

	TIM2_Configuration();

//	ExtI_Configuration();
//	TIM3_Configuration();

	RCC_GetClocksFreq(&clocks);

	dp("ADC    Clk: %d\r\n", clocks.ADCCLK_Frequency);
	dp("HCLK   Clk: %d\r\n", clocks.HCLK_Frequency);
	dp("PCLK1  Clk: %d\r\n", clocks.PCLK1_Frequency);
	dp("PCLK2  Clk: %d\r\n", clocks.PCLK2_Frequency);
	dp("SYSCLK Clk: %d\r\n", clocks.SYSCLK_Frequency);

	if(SysTick_Config(SystemCoreClock/1000) != 0){	// Sys Tick을 1ms로 설정
		dp("Sys Tick Configuration Fail\r\n");
	}

}
void Hardware_Configuration()
{
  
  //Config RCC(clock PLL flash periph_clock)
  RCC_Configuration();
  
  //Config GPIO
  GPIO_Configuration();
  
  //Config EXTI
  //EXTI_Configuration();
  
  //Config TIM
  //TIM_Configuration();
  
  //Config USART
  USART_Configuration();
  
  //Config NVIC
  NVIC_Configuration();
  
  //Config DMA
  DMA_Configuration();
  
  //Config I2C
  I2C_Configuration();
}
예제 #4
0
파일: main.c 프로젝트: eeinz/trochili
/**
  * @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_gd32f1x0.s) before to branch to application main.
    */
    SysTick_Config((SystemCoreClock / 1000));
    
    GD_EVAL_LEDInit (LED2);
    
    /* USART configuration */
    USART_Configuration();
    
    /* Configure SystemClock*/ 
    delay_s(20);
    
    /* Wake up from USART DeepSleep mode by Start bit Method */
    WakeUp_StartBitMethod();
    
    /* Configure SystemClock*/
    RestoreConfiguration();
    
    /* Configure and enable the systick timer to generate an interrupt each 1 ms */
    SysTick_Config((SystemCoreClock / 1000));
    
    while (1)
    {
    }
}
예제 #5
0
int main1(void)
{
	uint32 i=0;
	RCC_Configuration();
	Mema_Init(MemBuf);
	SPI_FLASH_Init();
	Load_EnvConfig();
	Frist_CheckEnv();
	if(enValue.UpdateApp==True)
	{
		//在这里放置搬运程序
		enValue.UpdateApp=False;
		Save_EnvConfig();
	}
	if(enValue.UpdateOver==True)
	{
		//在这里放置回滚程序
		enValue.UpdateOver=False;
		Save_EnvConfig();
	}
	
	USART_Configuration(0);
	for(i=0;i<10000;i++)
	{
		FLASH_ProgramStart(SPI_FLASH_SectorErase,i*1024,1024);
		Flash_Coppy(Flash_ReadData,0,W25Q16_Write,i*1024,1024);
		Flash_Printf(W25Q16_Read,i*1024);
	}
	//Flash_Printf(Flash_ReadData,0);
	//Application_Run();
	while(1);
}
예제 #6
0
/*******************************************************************************
* Function Name  : usart_rxtx
* Description    : Print "Welcome to CooCox!"  on Hyperterminal via USART1.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void usart_rxtx(void)
{
    u16 k=0;
    const unsigned char menu[] = " Welcome to CooCox!\r\n";

    /* Enable USART1 and GPIOA clock */
    //RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);

    /* NVIC Configuration */
    NVIC_Configuration();


    /* Configure the GPIOs */
  //  GPIO_Configuration();
    
    /* Configure the USART1 */
    USART_Configuration();

    /* Enable the USART1 Receive interrupt: this interrupt is generated when the 
         USART1 receive data register is not empty */
    USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);

    /* print welcome information */
    UARTSend(menu, sizeof(menu));

    while(1)
	{
		if(name[k] != '\0')
		{
			UARTSend((const unsigned char*)&name[k++],1);
		}
		if(k > NUM)
		k = 0;	
	}
}
예제 #7
0
/*-----------------------------------------------------------*/
void prvSetupHardware( void )
{
	/* Set the Vector Table base address at 0x08000000 */
	NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );
	NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );

	/* Configure LED IOs as output push-pull */
    /* Initialize LEDs on STM32F4_Discovery board */
	//prvLED_Config(GPIO);
	/* Configure User button pin (PA0) as external interrupt -> modes switching */
	STM_EVAL_PBInit(BUTTON_USER,BUTTON_MODE_EXTI);

	/* Configuration of Timer4 to control LEDs based on MEMS data */
	//prvTIM4_Config();

	/* Configure LIS302 in order to produce data used for TIM4 reconfiguration and LED control */
	prvMEMS_Config();

  	RCC_Configuration();
  	GPIO_Configuration();
  	TIM_Configuration();
  	USART_Configuration();
  	prvGRYO_Config();
	
}
예제 #8
0
/*********************************************************************************************************//**
  * @brief  Period_Reload program,the example main funtion.
  * @retval None
  ***********************************************************************************************************/
void Period_Reload(void)
{

  NVIC_Configuration();               /* NVIC configuration                                                 */
  CKCU_Configuration();               /* System Related configuration                                       */
  USART_Configuration();              /* USART Related configuration                                        */
  SYSTICK_Configuration();            /* SYSTICK Related configuration                                      */
  LED_Configuration();

  /* WatchDog configuration */
  WDT_IntConfig(ENABLE);              /* Enable WDT Interrupt */
  WDT_SetPrescaler(WDT_PRESCALER_8);  /* Set Prescaler Value as 2 */
  WDT_SetReloadValue(0xEFF);          /* Set Reload Value as 0xEFF  */
  WDT_Restart();                      /* Reload Counter as WDTV Value */
  WDT_SetDeltaValue(0xA00);           /* Set Delta Value as 0xA00 */
  WDT_ProtectCmd(ENABLE);             /* Enable Protection  */

  //printf("\n\rWDT Period Reload Starts...\n\r");
  //printf("The Program Is Still Working If LED3 Keep Flashing\n\r");

  /* Enable the SYSTICK Counter */
  SYSTICK_CounterCmd(SYSTICK_COUNTER_ENABLE);

  while(1);
}
예제 #9
0
//=============================================================================
inline void usart_init(void)
{
	    GPIO_Configuration();

	    USART_Configuration();

}
예제 #10
0
파일: board.c 프로젝트: ccccjason/IMU
/*******************************************************************************
*Function:系统初始化
*parm:none
*description:
*******************************************************************************/
void board_init(void)
{
    delay_init();
    LED_Init();    //LED灯初始化
    USART_Configuration(115200);//串口通信初始化
    USART2_Init(9600);
}
예제 #11
0
파일: main.c 프로젝트: Amna2013/stm32-test
/**
  * @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_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
  */
  
  /* Initialize LEDs available on STM320518-EVAL board ************************/
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
   
  /* USART configuration */
  USART_Configuration();
  
  /* Wake up from USART STOP mode by Start bit Method */
  WakeUp_StartBitMethod();
  
  /* Configure SystemClock*/
  RestoreConfiguration();
  
  /* Configure and enable the systick timer to generate an interrupt each 1 ms */
  SysTick_Config((SystemCoreClock / 1000));
  
  while (1)
  {
  }
}
예제 #12
0
파일: main.c 프로젝트: eeinz/trochili
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
    /* Configure System clocks -----------------------------------------------*/
    RCC_Configuration();
    
    /* Configure GPIO ports --------------------------------------------------*/
    GPIO_Configuration();
    USART_Configuration();

    /* Output a message on Hyperterminal using printf function */
    printf("\n\rADC different test: \n\r");

    ADC_Configuration();
    while(ADC_GetBitState(ADC_FLAG_EOC) != SET);
    ADCConvertedValue = ADC_GetConversionValue();

    printf("\n\rThe original data  %d\n\r",ADCConvertedValue);
    ADC_DeInit(&ADC_InitStructure);

    ADC_OVERConfiguration();
    while(ADC_GetBitState(ADC_FLAG_EOC) != SET);
    ADCConvertedValue_OVER = ADC_GetConversionValue();

    printf("\n\rOversampling data  %d\n\r",ADCConvertedValue_OVER);

    while (1)
    {
    }
}
예제 #13
0
/**
  * @brief  串口打印输出
  * @param  None
  * @retval None
  */
int main(void)
{
	uint8_t data[64];
	uint32_t i=0,ret=0;
	Set_System();//系统时钟初始化
	USART_Configuration();//串口1初始化
	printf("\x0c\0");printf("\x0c\0");//超级终端清屏
	printf("\033[1;40;32m");//设置超级终端背景为黑色,字符为绿色
	printf("\r\n*******************************************************************************");
	printf("\r\n************************ Copyright 2009-2012, ViewTool ************************");
	printf("\r\n*************************** http://www.viewtool.com ***************************");
	printf("\r\n***************************** All Rights Reserved *****************************");
	printf("\r\n*******************************************************************************");
	printf("\r\n");

	USB_Interrupts_Config();
	Set_USBClock();
	USB_Init();

	while(1)
	{
		if(USB_Received_Flag){
			USB_Received_Flag=0;
			ret = USB_GetData(data,sizeof(data));
			printf("usb get data %d byte data\n\r",ret);
			for(i=0;i<ret;i++){
				printf("0x%02X ",data[i]);
			}
			printf("\n\r");
			USB_SendData(data,sizeof(data));
		}
	}
}
예제 #14
0
/*******************************************************************************
* Function Name  : main
* Description    : Main program.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
int main(void)
{
#ifdef DEBUG
  debug();
#endif

  /* Configure the system clocks */
  RCC_Configuration();

  /* Configure GPIOs */
  GPIO_Configuration();

  /* Configures the EXTI Lines */
  EXTI_Configuration();
  
  /* Configures the DMA Channel */
  DMA_Configuration();
  
  /* Configures the USART1 */
  USART_Configuration();
    
#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_1);
  
  /* Enable the DMA1 Channel 5 Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel5_IRQChannel;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  /* Enable the EXTI9_5  Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQChannel;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_Init(&NVIC_InitStructure);
    
  while (1)
  {
    if(LowPowerMode == 1)
    {

      GPIO_ResetBits(GPIO_LED, GPIO_Pin_7 | GPIO_Pin_8);

      /* Request to enter WFI mode */
      __WFI();
      LowPowerMode = 0;
    }

    Delay(0xFFFFF);
    GPIO_WriteBit(GPIO_LED, GPIO_Pin_6, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIO_LED, GPIO_Pin_6)));
  }
}
예제 #15
0
// Open the Zigbee device
u8 zgb_hal_open(u8 devIndex, u32 baudrate)
{
	// Configure the baudrate of the Zigbee USART port
	USART_Configuration(USART_ZIG, 57600); // Note: We actually fix the baudrate instead of looking at what was passed!

	// Return success
	return 1;
}
예제 #16
0
/*******************************************************************************
* Function Name  : usart_rxtx
* Description    : Print "Welcome to CooCox!"  on Hyperterminal via USART1.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void usart_init(void)
{
		NVIC_USART1_Configuration();
		NVIC_USART2_Configuration();
	    USART_Configuration();
	    USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
	    USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
}
예제 #17
0
/*******************************************************************************
* Function Name  : Init_Device
* Description    : Init all the system moudles
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Init_Device(void)
{
	RCC_Configuration();
	
	GPIO_Configuration();
	USART_Configuration();

    NVIC_Configuration();
}
void InitBluetooth()       {
    int i;
    GPIO_InitTypeDef GPIO_InitStructure;
    RCC_AHBxPeriphClockCmd(RCC_GPIO_BL,ENABLE);
    GPIO_InitStructure.GPIO_Pin = GPIO_PIN_BL;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_Init(GPIO_BL_PORT, &GPIO_InitStructure);
    GPIO_InitStructure.GPIO_Pin = GPIO_PIN_RS;
    GPIO_Init(GPIO_BL_PORT, &GPIO_InitStructure);

    KEY_Disable
    RS_Enable
    for (i=0; i<100000; i++);
    KEY_Enable
    RS_Disable
    for (i=0; i<100000; i++);
    RS_Enable

    USART_Configuration(38400);
    USART_NVIC_Config();


    for (i=0; i<100000; i++);
    sprintf_u0( control_str);
    for (i=0; i<100000; i++);
    KEY_Disable
    for (i=0; i<100000; i++);
    RS_Disable
    for (i=0; i<100000; i++);
    RS_Enable
    USART_Configuration(38400);
    USART_NVIC_Config();






}
예제 #19
0
int main()
{
	DBG_Configuration();
	SystemClock_Configuration();
	DelayManager::DelayMs(150);
	RCC_Configuration();
	GPIO_Configuration();
	EXTI_Configuration();
	NVIC_Configuration();
	I2C_Configuration(&i2c);
	USART_Configuration(&uart);
	DMA_I2C_TX_Configuration(&i2cDmaTx);
	//__HAL_LINKDMA(&i2c, hdmatx, i2cDmaTx);

	MX_USB_DEVICE_Init();

	systemMode = LOADING;
	graphMode = SECONDS;

	display.initDisplay(&i2c);
	display.setFont(font5x7);
	display.clearScreen();
	display.printf(12, 50, logoStr);
	display.drawLine(0, 44, 127, 44);
	display.printf(12, 15, ".... LOADING ....");
	display.drawFramebuffer();

	sensorOk = co2sensor.initSensor(&uart);
	systemMode = ACTIVE;
	if (!sensorOk)
	{
		display.clearScreen();
		display.printf(12, 50, logoStr);
		display.drawLine(0, 44, 127, 44);
		display.printf(12, 15, errorStr);
		display.drawFramebuffer();
		errorHandler(NULL);
	}

	osThreadDef(processSensorThread, processSensorTask, osPriorityNormal, 0, 128);
	processSensorTaskHandle = osThreadCreate(osThread(processSensorThread), NULL);

	osThreadDef(processKeysThread, processKeysTask, osPriorityLow, 0, configMINIMAL_STACK_SIZE);
	processKeysTaskHandle = osThreadCreate(osThread(processKeysThread), NULL);

	osThreadDef(drawDataThread, drawDataTask, osPriorityHigh, 0, 256);
	drawDataTaskHandle = osThreadCreate(osThread(drawDataThread), NULL);

	osKernelStart();
	
	while (true)
	{
	}
}
예제 #20
0
파일: main.c 프로젝트: jesstr/smarthome
void init(void)
{
  //init_RCC();
  /* RCC_Configuration */
  RCC_Configuration();
  init_GPIO();
  init_SPI();
  NVIC_Configuration();
  USART_Configuration();
  init_printf(0,putc);
}
예제 #21
0
파일: main.c 프로젝트: guillep19/frob
int main(void)
{
    /* System Clocks Configuration */
	RCC_Configuration();

	/* NVIC configuration */
	NVIC_Configuration();

	/* GPIO configuration */
	GPIO_Configuration();

	SysTick_Configuration();

	Timer_Configuration();

	dxl_initialize( 0, 1 );
	USART_Configuration(USART_PC, Baudrate_PC);

	while(1)
	{
		bMoving = dxl_read_byte( id, P_MOVING );
		CommStatus = dxl_get_result();
		if( CommStatus == COMM_RXSUCCESS )
		{
			if( bMoving == 0 )
			{
				// Change goal position
				if( INDEX == 0 )
					INDEX = 1;
				else
					INDEX = 0;

				// Write goal position
				dxl_write_word( id, P_GOAL_POSITION_L, GoalPos[INDEX] );
			}

			PrintErrorCode();

			// Read present position
			wPresentPos = dxl_read_word( id, P_PRESENT_POSITION_L );
			TxDWord16(GoalPos[INDEX]);
			TxDString("   ");
			TxDWord16(wPresentPos);
			TxDByte_PC('\r');
			TxDByte_PC('\n');
		}
		else
			PrintCommStatus(CommStatus);

	}
	return 0;
}
예제 #22
0
파일: main.c 프로젝트: Seok-Jung/STM32F207
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{

    USART_Configuration();
    printf("\r\n****************************************************************\r\n");
    printf("CAN-Bus Test \r\n");
    printf("CAN-Bus Speed 100kHz \r\n");

    CAN_Config();
    NVIC_Config();
    Open207_LEDInit();
    /* Infinite loop */
    while (1)
    {
        if( CanFlag == ENABLE )
        {
            CanFlag = DISABLE;
            printf("CAN Receive Data \r\n");
            printf("CAN ID %x \r\n",CAN_ID);
            printf("CAN_DATA0 %x \r\n",CAN_DATA0);
            printf("CAN_DATA1 %x \r\n",CAN_DATA1);
            printf("CAN_DATA2 %x \r\n",CAN_DATA2);
            printf("CAN_DATA3 %x \r\n",CAN_DATA3);
            printf("CAN_DATA4 %x \r\n",CAN_DATA4);
            printf("CAN_DATA5 %x \r\n",CAN_DATA5);
            printf("CAN_DATA6 %x \r\n",CAN_DATA6);
            printf("CAN_DATA7 %x \r\n",CAN_DATA7);
        }

        CanWriteData(0xA5A5);

        if( Display )
        {
            /*====LED-ON=======*/
            GPIO_SetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED1);
            GPIO_SetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED2);
            GPIO_SetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED3);
            GPIO_SetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED4);
        }
        else
        {
            /*====LED-OFF=======*/
            GPIO_ResetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED1);
            GPIO_ResetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED2);
            GPIO_ResetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED3);
            GPIO_ResetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED4);
        }
        Display = ~Display;
        Delay();  /* delay 200ms */
    }
}
예제 #23
0
int main(void)
{
    SystemInit();
    GPIO_Configuration();
    USART_Configuration();

    QueTestId = xQueueCreate(10 * sizeof(char), sizeof(char));
    xTaskCreate(Task_Led, "Task_Led", 128, 0, 2, 0);
    xTaskCreate(Task_Led1, "Task_Led1", 128, 0, 3, 0);

    vTaskStartScheduler();
	
	return 0;  
}
예제 #24
0
void Platform_Init(void)
{
    RCC_Configuration();
    GPIO_Configuration();
    NVIC_Configuration();
	Timer_Configuration();
	USART_Configuration();			  
	EXTI_Configuration();
    delay_init(72);

	RS485_1_RX;				 //RS485 receive mode
	RS485_2_RX;				 //RS485 receive mode
   
//	IWDG_Configuration(781); //初始化独立看门狗5s

}
예제 #25
0
파일: main.c 프로젝트: jiesse/time-meter
/**
  * @brief  Main program.
  * @param  None
  * @retval : None
  */
int main(void)
{
  /* Configure the system clocks */
  RCC_Configuration();

  /* Configure GPIOs */
  GPIO_Configuration();

  /* Configures the EXTI Lines */
  EXTI_Configuration();
  
  /* Configures the DMA Channel */
  DMA_Configuration();
  
  /* Configures the USART1 */
  USART_Configuration();

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
  
  /* Enable the DMA1 Channel 5 Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  /* Enable the EXTI9_5  Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_Init(&NVIC_InitStructure);
    
  while (1)
  {
    if(LowPowerMode == 1)
    {

      GPIO_ResetBits(GPIO_LED, GPIO_Pin_7 | GPIO_Pin_8);

      /* Request to enter WFI mode */
      __WFI();
      LowPowerMode = 0;
    }

    Delay(0xFFFFF);
    GPIO_WriteBit(GPIO_LED, GPIO_Pin_6, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIO_LED, GPIO_Pin_6)));
  }
}
예제 #26
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
	uint8_t initSuccess;
	uint8_t mpuData[14];
	initSuccess = 0;
	NVIC_Config();
	STM_EVAL_COMInit();
	USART_Configuration(9600);
	USART_ITConfig(USART1,USART_IT_RXNE, ENABLE);
	initSuccess = MPU9250_Init();
  while (initSuccess)
  {
		MPU9250_ReadValue(mpuData);
		USART_SendDataArray(USART1,mpuData);
		Delay(0xFFFF);
  }
}
예제 #27
0
파일: init_main.c 프로젝트: fulong/mystm32
void _main(void)
{
	LED_GPIO_Configuration();
	USART_Configuration(USART1);
#ifdef __DEBUG__
	printfs("this is in init fuction.\r\n");
	printfs("usart1's initation is compelete.\r\n");
	printfs("three lights can bright.\r\n");
#endif
	systick_init();
#ifdef __DEBUG__
	printfs("system ticket clock's initation is compelete.\r\n");
	printfs("\r\n");
	printfs("now into the tft's initation.\r\n");
#endif
	LCD_Init();
	set_orgin(120, 120);
}
예제 #28
0
파일: main.c 프로젝트: prid77/Reference
/*******************************************************************************
* Function Name  : main
* Description    : Main program
* Input          : None
* Output         : None
* Return         : None
* Attention		 : None
*******************************************************************************/
int main(void)
{
	USART_Configuration();
	MSD_SPI_Configuration();

	if( _card_insert() == 0 )
    {
	  printf("-- SD card detected OK \r\n");
    }
    else
    {
      printf("-- Please connect a SD card \r\n");
      while( _card_insert() != 0 );
      printf("-- SD card connection detected \r\n");
	  Delay(0xffffff);
    }

	f_mount(0,&fs);	

	res = f_open( &fsrc , "0:/Demo.TXT" , FA_CREATE_NEW | FA_WRITE);		

    if ( res == FR_OK )
    { 
      /* Write buffer to file */
      res = f_write(&fsrc, textFileBuffer, sizeof(textFileBuffer), &br);     
 
	  printf("Demo.TXT successfully created        \r\n");
    
      /*close file */
      f_close(&fsrc);      
    }
    else if ( res == FR_EXIST )
    {
	  printf("Demo.TXT created in the disk      \r\n");
    }

	scan_files(path);
	SD_TotalSize();

    /* Infinite loop */
    while (1){

    }
}
예제 #29
0
파일: main.c 프로젝트: Seok-Jung/STM32F207
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
	uint16_t Addr;
	uint8_t WriteBuffer[256],ReadBuffer[256];
	
	Open207_LEDInit();
	USART_Configuration();
	I2C_Configuration();
	
	printf("\r\n****************************************************************\r\n");
	
	for(Addr=0; Addr<256; Addr++)
	WriteBuffer[Addr]=Addr;	 /* 填充WriteBuffer */
	
	/* 开始向EEPROM写数据 */
	printf("\r\n EEPROM 24C02 Write Test \r\n");
	I2C_Write(Open207Z_I2Cx,ADDR_24LC02,0,WriteBuffer,sizeof(WriteBuffer) );
	printf("\r\n EEPROM 24C02 Write Test OK \r\n");
	
	/* EEPROM读数据 */
	printf("\r\n EEPROM 24C02 Read Test \r\n");
	I2C_Read(Open207Z_I2Cx,ADDR_24LC02,0,ReadBuffer,sizeof(WriteBuffer) );
	
	if(memcmp(WriteBuffer,ReadBuffer,sizeof(WriteBuffer)) == 0 ) /* 匹配数据 */
		printf("\r\n EEPROM 24C02 Read Test OK\r\n");
	else
		printf("\r\n EEPROM 24C02 Read Test False\r\n");
	
	/* Infinite loop */

	while (1)
	{
		GPIO_SetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED1);
		GPIO_SetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED2);
		GPIO_SetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED3);
		GPIO_SetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED4);
		Delay(0x5fffff);
		GPIO_ResetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED1);
		GPIO_ResetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED2);
		GPIO_ResetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED3);
		GPIO_ResetBits(Open207Z_LED_GPIO , Open207Z_GPIO_Pin_LED4);
		Delay(0x5fffff);	
	}
}
예제 #30
0
파일: hal.c 프로젝트: liuxizhen2009/zlggui
/*******************************
**函数名:ChipHalInit()
**功能:片内硬件初始化
*******************************/
void  ChipHalInit(void)
{
	//初始化时钟源
	RCC_Configuration();
	
	//初始化GPIO
	GPIO_Configuration();
	//初始化串口
	USART_Configuration();
	init_printf(printf_buf,uart1_putc);
	tfp_printf("tfp_printf Inital over\n");

	TIMER_Configuration();

	//初始化中断,在ucos启动后执行,其中包含两步,1,分配中断优先级,2,使能中断
	//NVIC_Configuration();

//	OLED_Configuration();
}