⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 基于STM32的RF905无线通讯收发程序
💻 C
字号:
/***************************************************************

                    DQ-STM32开发板试验程序      
                          GPIO1实验		   
                       四个LED轮流显示
					  端口分配详见原理图


						 重庆DQ电子
****************************************************************/

#include "stm32f10x_lib.h"									 //调用的库文件
#include "18b20.h"
#include "ABSACC.h"
#include "stdio.h"
#include "nrf905.h"
void RCC_Configuration(void);
void Delay_ms(u16 Nms);
void Delay_us(u32 Nus);
void fasong(void);
void GPIO_Configuration(void);
#define countof(a) (sizeof(a) / sizeof(*(a)))
int main(void)												  //主函数
{	
	RCC_Configuration();
	GPIO_Configuration();
	nRF905Init();
    Config905();
	while(1)
	{
		fasong();
	}
}

/*******************************************************************************
* Function Name  : RCC_Configuration
* Description    : Configures the different system clocks.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void RCC_Configuration(void)
{
  ErrorStatus HSEStartUpStatus;
  /* RCC system reset(for debug purpose) */
  RCC_DeInit();										//时钟控制寄存器全部恢复默认值

  /* Enable HSE */
  RCC_HSEConfig(RCC_HSE_ON);						//外部高速时钟源开启(8M晶振)

  /* Wait till HSE is ready */
  HSEStartUpStatus = RCC_WaitForHSEStartUp();		//等待外部时钟就绪

  if(HSEStartUpStatus == SUCCESS)					//如果时钟启动成功
  {
    /* HCLK = SYSCLK */
    RCC_HCLKConfig(RCC_SYSCLK_Div1);				//定义AHB设备时钟为系统时钟1分频

    /* PCLK2 = HCLK */
    RCC_PCLK2Config(RCC_HCLK_Div1);					//定义AHB2设备时钟为HCLK时钟1分频

    /* PCLK1 = HCLK/2 */
    RCC_PCLK1Config(RCC_HCLK_Div2);					//定义AHB1设备时钟为HCLK时钟2分频

    /* Flash 2 wait state */
    FLASH_SetLatency(FLASH_Latency_2);				//设定内部FLASH的的延时周期为2周期
    /* Enable Prefetch Buffer */
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);	 //使能FLASH预存取缓冲区

    /* PLLCLK = 8MHz * 9 = 72 MHz */
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);	 //配置PLL时钟为外部高速时钟的9倍频,8MHz * 9 = 72 MHz

    /* Enable PLL */
    RCC_PLLCmd(ENABLE);										 //使能PLL时钟

    /* Wait till PLL is ready */
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)		 //等待PLL时钟设置完成准备就绪
    {
    }

    /* Select PLL as system clock source */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);				 //使用PLL时钟作为系统时钟源

    /* Wait till PLL is used as system clock source */
    while(RCC_GetSYSCLKSource() != 0x08)					 //返回系统所用时钟源确认为外部高速晶振,8M晶振。
    {
    }
  }
  /*Enble GPIOA、GPIOB、GPIOC*/
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE, ENABLE);	//使能由APB2时钟控制的外设中的PA,PB端口
}


#ifdef  DEBUG
/*******************************************************************************
* Function Name  : assert_failed
* Description    : Reports the name of the source file and the source line number
*                  where the assert error has occurred.
* Input          : - file: pointer to the source file name
*                  - line: assert error line source number
* Output         : None
* Return         : None
*******************************************************************************/
void assert_failed(u8* file, u32 line)
{
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}
#endif
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -