找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1136|回复: 0
打印 上一主题 下一主题
收起左侧

STM32F030 temperature source code源码下载

[复制链接]
跳转到指定楼层
楼主
STM32F030
Read the temperature sensor through ADC


  1. /* Includes ------------------------------------------------------------------*/
  2. #include "main.h"
  3. #include "stdio.h"

  4. /** @addtogroup STM32F0308-Discovery_Demo
  5.   * @{
  6.   */

  7. /* Private typedef -----------------------------------------------------------*/
  8. /* Private define ------------------------------------------------------------*/
  9. /* Private macro -------------------------------------------------------------*/
  10. /* Private variables ---------------------------------------------------------*/
  11. static __IO uint32_t TimingDelay;
  12. uint8_t BlinkSpeed = 0;

  13. /* Private function prototypes -----------------------------------------------*/
  14. /* Private functions ---------------------------------------------------------*/

  15. /**
  16.   * @brief  Main program.
  17.   * @param  None
  18.   * @retval None
  19.   */
  20. float Tmp275_temperature(void);
  21. void Tmp275_Init(void);
  22. extern void lcd_init(void);
  23. void PutStr(unsigned char row,unsigned char col,unsigned char *puts);
  24. void LcmClearTXT(void);

  25. int main(void)
  26. {
  27.         float temperature;
  28.         char msg[64];
  29.         RCC_ClocksTypeDef RCC_Clocks;

  30.         /* Configure LED3 and LED4 on STM32F0308-Discovery */
  31.         STM_EVAL_LEDInit(LED3);
  32.         STM_EVAL_LEDInit(LED4);

  33.         /* Initialize User_Button on STM32F0308-Discovery */
  34.         STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);

  35.         /* SysTick end of count event each 1ms */
  36.         RCC_GetClocksFreq(&RCC_Clocks);
  37.         SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);

  38.         /* Initiate Blink Speed variable */
  39.         BlinkSpeed = 1;
  40.        
  41.         lcd_init();
  42.         Tmp275_Init();
  43.         while(1)
  44.         {
  45.                 temperature = Tmp275_temperature();
  46.                 sprintf(msg, "温度: %6.1f℃", temperature);
  47.                 //LcmClearTXT();
  48.                 PutStr(0, 0, " HELLO EEWORLD! ");
  49.                 PutStr(1, 0, msg);
  50.                 Delay(2000);
  51.         }
  52. //        lcd_test();
  53. //  while(1)
  54. //  {  
  55. //    /* Check if the user button is pressed */
  56. //    if(STM_EVAL_PBGetState(BUTTON_USER)== SET)
  57. //    {
  58. //      /* BlinkSpeed: 1 -> 2 -> 0, then re-cycle */
  59. //      /* Turn on LD4 Blue LED during 1s each time User button is pressed */
  60. //      STM_EVAL_LEDOn(LED4);
  61. //      
  62. //      /* wait for 1s */
  63. //      Delay(1000);
  64. //      
  65. //      /* Turn off LD4 Blue LED after 1s each time User button is pressed */
  66. //      STM_EVAL_LEDOff(LED4);
  67. //      
  68. //      /* Increment the blink speed counter */
  69. //      BlinkSpeed++;
  70. //      
  71. //      /* Default value for blink speed counter */
  72. //      if(BlinkSpeed == 3)
  73. //      {  
  74. //        BlinkSpeed = 0;
  75. //      }
  76. //    }
  77. //   
  78. //    /* Test on blink speed */
  79. //    if(BlinkSpeed == 2)
  80. //    {
  81. //      /* LED3 toggles each 100 ms */
  82. //      STM_EVAL_LEDToggle(LED3);
  83. //      
  84. //      /* maintain LED3 status for 100ms */
  85. //      Delay(100);
  86. //    }
  87. //    else if(BlinkSpeed == 1)
  88. //    {
  89. //      /* LED3 toggles each 200 ms */
  90. //      STM_EVAL_LEDToggle(LED3);
  91. //      
  92. //      /* maintain LED3 status for 200ms */
  93. //      Delay(200);
  94. //    }
  95. //    else
  96. //    {  
  97. //      /* LED3 Off */
  98. //      STM_EVAL_LEDOff(LED3);
  99. //    }
  100. //  }
  101. }

  102. /**
  103.   * @brief  Inserts a delay time.
  104.   * @param  nTime: specifies the delay time length, in 1 ms.
  105.   * @retval None
  106.   */
  107. void Delay(__IO uint32_t nTime)
  108. {
  109.   TimingDelay = nTime;

  110.   while(TimingDelay != 0);
  111. }

  112. /**
  113.   * @brief  Decrements the TimingDelay variable.
  114.   * @param  None
  115.   * @retval None
  116.   */
  117. void TimingDelay_Decrement(void)
  118. {
  119.   if (TimingDelay != 0x00)
  120.   {
  121.     TimingDelay--;
  122.   }
  123. }

  124. #ifdef  USE_FULL_ASSERT

  125. /**
  126.   * @brief  Reports the name of the source file and the source line number
  127.   *   where the assert_param error has occurred.
  128.   * @param  file: pointer to the source file name
  129.   * @param  line: assert_param error line source number
  130.   * @retval None
  131.   */
  132. void assert_failed(uint8_t* file, uint32_t line)
  133. {
  134.   /* User can add his own implementation to report the file name and line number,
  135.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  136.   /* Infinite loop */
  137.   while (1)
  138.   {}
  139. }
  140. #endif

  141. /**
  142.   * @}
  143.   */


  144. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
复制代码



全部资料51hei下载地址:
STM32F0308-Discovery_FW_V1.0.1_temperature.rar (1.83 MB, 下载次数: 24)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表