久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 7322|回復(fù): 5
打印 上一主題 下一主題
收起左側(cè)

BL5372-USB功能RTC時鐘程序源碼電路板原理圖和PCB工程文件

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:300076 發(fā)表于 2018-3-31 20:07 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
BL5372-USB功能RTC時鐘電路板AD格式的電路原理圖和PCB工程:

Demo演示用的固件(程序),出貨前已經(jīng)燒錄好,給PCBA通電即可工作!

如果您需要再次燒錄,請按此HEX文件進行燒錄即可。

燒錄工具一般用 ST-LINK/V2, 或者J-LINK都可以!

R8、R9兩者只能焊接一個
焊接R8則選擇IIC接口
焊接R9則選擇SPI接口

stm32程序源碼:
  1. /*

  2. 作者:紫電青霜


  3. */


  4. /*Includes ------------------------------------------------------------------*/
  5. #include "main.h"
  6. #include "stm32f0xx_hal.h"
  7. #include "usb_device.h"
  8. #include "BL5372_IIC.h"
  9. #include "usbd_cdc_if.h"


  10. uint8_t  RRTCiic_buf[16];
  11. uint8_t  RRTCiic_Buf_Out[26]={0x32,0x30,0x31,0x37,0xC4,0xEA,0x30,0x32,0xD4,0xC2,
  12.                              0x32,0x35,0xC8,0xD5,0x32,0x32,0x3A,0x35,0x36,0x3A,0x00,0x00,0x0D,0x0A,0x0D,0x0A};


  13.                                                                                                        
  14. extern unsigned char Set_Year ;       
  15. extern unsigned char Set_Month ;       
  16. extern unsigned char Set_Day ;       
  17. extern unsigned char Set_Hour ;       
  18. extern unsigned char Set_Minute ;       
  19. extern unsigned char Set_Second ;                                                                                                                         
  20.                                                                                                                  
  21. uint8_t   Rec_buff[18]={0};



  22. /* Private variables ---------------------------------------------------------*/
  23. SPI_HandleTypeDef hspi1;



  24. /* Private function prototypes -----------------------------------------------*/
  25. void SystemClock_Config(void);
  26. void Error_Handler(void);
  27. static void MX_GPIO_Init(void);
  28. static void MX_SPI1_Init(void);
  29. void My_GPIO_Init(void);


  30. unsigned char  DataStr[]=__DATE__;
  31. unsigned char  TimeStr[]=__TIME__;
  32. extern uint8_t UserRxBufferFS[];

  33. int main(void)
  34. {
  35.   unsigned char i=0;
  36.         unsigned char Miao_mark = 0;

  37.                


  38.   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  39.   HAL_Init();

  40.   /* Configure the system clock */
  41.   SystemClock_Config();

  42.   /* Initialize all configured peripherals */
  43.   MX_GPIO_Init();
  44.   MX_SPI1_Init();
  45.   MX_USB_DEVICE_Init();
  46.         IIC_Init();
  47.        
  48.         My_GPIO_Init();
  49.         if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_7) == 0)//讀取PB7管腳的電平,為低電平,則初始化BL5372時間
  50.         {
  51.                 BL5372_init();
  52.         }

  53.   while (1)
  54.   {
  55.                
  56.                
  57.                         HAL_Delay(50);


  58.                         if(UserRxBufferFS[0] == 'S'  && UserRxBufferFS[1] == 'T'  && UserRxBufferFS[10] == 'F' && UserRxBufferFS[11] == 'N' )
  59.                         {
  60.                                 CDC_Transmit_FS("設(shè)置年月日\r\n",12);
  61.                                 Set_Year = ((UserRxBufferFS[4]-0x30)<<4)+(UserRxBufferFS[5]-0x30);
  62.                                 Set_Month = ((UserRxBufferFS[6]-0x30)<<4)+(UserRxBufferFS[7]-0x30);
  63.                                 Set_Day = ((UserRxBufferFS[8]-0x30)<<4)+(UserRxBufferFS[9]-0x30);
  64.                                 BL5372_init();
  65.                         }
  66.                         else if(UserRxBufferFS[0] == 'S'  && UserRxBufferFS[1] == 'T'  && UserRxBufferFS[8] == 'F' && UserRxBufferFS[9] == 'I' )
  67.                         {
  68.                                 CDC_Transmit_FS("設(shè)置時分秒\r\n",12);
  69.                                 Set_Hour = ((UserRxBufferFS[2]-0x30)<<4)+(UserRxBufferFS[3]-0x30);
  70.                                 Set_Minute = ((UserRxBufferFS[4]-0x30)<<4)+(UserRxBufferFS[5]-0x30);
  71.                                 Set_Second = ((UserRxBufferFS[6]-0x30)<<4)+(UserRxBufferFS[7]-0x30);
  72.                                 BL5372_init();
  73.                         }
  74.                        

  75.                                 for(i=0;i<18;i++)
  76.                                 {
  77.                                         UserRxBufferFS[i] = 0;
  78.                                 }

  79. //                                        HAL_Delay(5);
  80.                                         BL5372_Read(0x00,RRTCiic_buf,7);
  81.                                         if(RRTCiic_buf[0] != Miao_mark)
  82.                                         {

  83.                                                                 //秒
  84.                                                                 RRTCiic_Buf_Out[20] = ((RRTCiic_buf[0]>>4)&0x0f) +0x30;
  85.                                                                 RRTCiic_Buf_Out[21] = (RRTCiic_buf[0]&0x0f) +0x30;
  86.                                                                
  87.                                                                 //分
  88.                                                                 RRTCiic_Buf_Out[17] = ((RRTCiic_buf[1]>>4)&0x0f) +0x30;
  89.                                                                 RRTCiic_Buf_Out[18] = (RRTCiic_buf[1]&0x0f) +0x30;
  90.                                                        
  91.                                                                 //時
  92.                                                                 RRTCiic_Buf_Out[14] = ((RRTCiic_buf[2]>>4)&0x0f) +0x30;
  93.                                                                 RRTCiic_Buf_Out[15] = (RRTCiic_buf[2]&0x0f) +0x30;       

  94.                                                                 //日
  95.                                                                 RRTCiic_Buf_Out[10] = ((RRTCiic_buf[4]>>4)&0x0f) +0x30;
  96.                                                                 RRTCiic_Buf_Out[11] = (RRTCiic_buf[4]&0x0f) +0x30;
  97.                                                                
  98.                                                                 //月
  99.                                                                 RRTCiic_Buf_Out[6] = ((RRTCiic_buf[5]>>4)&0x0f) +0x30;
  100.                                                                 RRTCiic_Buf_Out[7] = (RRTCiic_buf[5]&0x0f) +0x30;
  101.                                                        
  102.                                                                 //年
  103.                                                                 RRTCiic_Buf_Out[2] = ((RRTCiic_buf[6]>>4)&0x0f) +0x30;
  104.                                                                 RRTCiic_Buf_Out[3] = (RRTCiic_buf[6]&0x0f) +0x30;       



  105.                                                         CDC_Transmit_FS((uint8_t *)RRTCiic_Buf_Out,26);
  106.                                        
  107.                                         }
  108.                                         Miao_mark = RRTCiic_buf[0] ;
  109.                                         for(i=0;i<16;i++)
  110.                                         {
  111.                                                 RRTCiic_buf[i] = 0;
  112.                                         }
  113.   }
  114.   /* USER CODE END 3 */

  115. }

  116. /** System Clock Configuration
  117. */
  118. void SystemClock_Config(void)
  119. {

  120.   RCC_OscInitTypeDef RCC_OscInitStruct;
  121.   RCC_ClkInitTypeDef RCC_ClkInitStruct;
  122.   RCC_PeriphCLKInitTypeDef PeriphClkInit;

  123.     /**Initializes the CPU, AHB and APB busses clocks
  124.     */
  125.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
  126.   RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
  127.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  128.   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  129.   {
  130.     Error_Handler();
  131.   }

  132.     /**Initializes the CPU, AHB and APB busses clocks
  133.     */
  134.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  135.                               |RCC_CLOCKTYPE_PCLK1;
  136.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48;
  137.   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  138.   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

  139.   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
  140.   {
  141.     Error_Handler();
  142.   }

  143.   PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
  144.   PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;

  145.   if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  146.   {
  147.     Error_Handler();
  148.   }

  149.     /**Configure the Systick interrupt time
  150.     */
  151.   HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

  152.     /**Configure the Systick
  153.     */
  154.   HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

  155.   /* SysTick_IRQn interrupt configuration */
  156.   HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
  157. }

  158. /* SPI1 init function */
  159. static void MX_SPI1_Init(void)
  160. {

  161.   hspi1.Instance = SPI1;
  162.   hspi1.Init.Mode = SPI_MODE_MASTER;
  163.   hspi1.Init.Direction = SPI_DIRECTION_2LINES;
  164.   hspi1.Init.DataSize = SPI_DATASIZE_4BIT;
  165.   hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
  166.   hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
  167.   hspi1.Init.NSS = SPI_NSS_SOFT;
  168.   hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
  169.   hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  170.   hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  171.   hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  172.   hspi1.Init.CRCPolynomial = 7;
  173.   hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
  174.   hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
  175.   if (HAL_SPI_Init(&hspi1) != HAL_OK)
  176.   {
  177.     Error_Handler();
  178.   }

  179. }

  180. /** Pinout Configuration
  181. */
  182. static void MX_GPIO_Init(void)
  183. {

  184.   /* GPIO Ports Clock Enable */
  185.   __HAL_RCC_GPIOA_CLK_ENABLE();

  186. }





  187. void My_GPIO_Init(void)
  188. {                                             
  189.                 GPIO_InitTypeDef GPIO_InitStruct;
  190.          __HAL_RCC_GPIOB_CLK_ENABLE();
  191.           
  192.           /*Configure GPIO pin : PB7 */
  193.   GPIO_InitStruct.Pin = GPIO_PIN_7 ;
  194.   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;//輸入
  195.   GPIO_InitStruct.Pull = GPIO_PULLUP;//上拉輸入
  196.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  197.   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  198.        
  199.        

  200. }

  201. /* USER CODE BEGIN 4 */

  202. /* USER CODE END 4 */

  203. /**
  204.   * @brief  This function is executed in case of error occurrence.
  205.   * @param  None
  206.   * @retval None
  207.   */
  208. void Error_Handler(void)
  209. {
  210.   /* USER CODE BEGIN Error_Handler */
  211.   /* User can add his own implementation to report the HAL error return state */
  212.   while(1)
  213.   {
  214.   }
  215.   /* USER CODE END Error_Handler */
  216. }

  217. #ifdef USE_FULL_ASSERT

  218. /**
  219.    * @brief Reports the name of the source file and the source line number
  220.    * where the assert_param error has occurred.
  221.    * @param file: pointer to the source file name
  222.    * @param line: assert_param error line source number
  223.    * @retval None
  224.    */
  225. void assert_failed(uint8_t* file, uint32_t line)
  226. {
  227.   /* USER CODE BEGIN 6 */
  228.   /* User can add his own implementation to report the file name and line number,
  229.     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  230.   /* USER CODE END 6 */

  231. }


  232. #endif

  233. /**
  234.   * @}
  235.   */

  236. /**
  237.   * @}
  238. */

  239. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
復(fù)制代碼

下載:
BL5372-USB功能RTC時鐘電路板原理圖和PCB.zip (17.33 MB, 下載次數(shù): 60)
BL5372.pdf (144.14 KB, 下載次數(shù): 38)
RTC時鐘電路板程序源碼.zip (3.63 MB, 下載次數(shù): 90)



分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏3 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:326234 發(fā)表于 2018-5-9 20:05 | 只看該作者
這個資源很好啊,準備弄BL5372
回復(fù)

使用道具 舉報

板凳
ID:464148 發(fā)表于 2019-1-7 21:28 | 只看該作者
看下BL5372源碼
回復(fù)

使用道具 舉報

地板
ID:714984 發(fā)表于 2020-3-24 18:34 | 只看該作者
很不錯的帖子,正好用到BL5372,這個帖子里的源碼可以參考一下。
回復(fù)

使用道具 舉報

5#
ID:545576 發(fā)表于 2021-8-7 12:33 | 只看該作者
感謝分享,測試一下,替代缺貨的3231
回復(fù)

使用道具 舉報

6#
ID:834913 發(fā)表于 2022-4-18 15:21 | 只看該作者
在使用BL5372的時候有遇到時鐘不準的問題(大約四個小時走快一秒) 樓主有什么解決方法嗎
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 日韩精品在线一区 | jlzzjlzz国产精品久久 | 国产在线精品一区 | 人人干在线视频 | 成人精品毛片国产亚洲av十九禁 | a在线观看| 在线一级片| 日韩中文字幕视频在线观看 | 成人国产一区二区三区精品麻豆 | 免费a在线| 国产成人免费视频网站高清观看视频 | 久久成人久久 | 天堂在线www | 精品一区二区三区在线观看国产 | 亚洲一区二区在线播放 | 成人不卡一区二区 | 羞羞色视频 | 麻豆av网站 | 亚洲综合色视频在线观看 | 国产一级在线 | 九九视频在线观看 | 日韩在线观看一区 | 亚洲狠狠爱 | 欧美日韩高清一区 | 成人欧美一区二区三区黑人孕妇 | 在线色网| 中文字幕一区二区三区在线视频 | 精品久久久久久 | 黄色网址免费看 | 国产一区视频在线 | 国产精品久久久久久久久久久久 | 国产精品日韩欧美 | 亚洲福利 | 亚洲精品大片 | 日本在线视 | 欧洲av在线 | 中文精品视频 | 九九久久精品 | 精品一区二区三 | 午夜丰满少妇一级毛片 | 欧美久久久久久久久 |