main.c.bak 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. ******************************************************************************
  3. * File Name : main.c
  4. * Description : Main program body
  5. ******************************************************************************
  6. ** This notice applies to any and all portions of this file
  7. * that are not between comment pairs USER CODE BEGIN and
  8. * USER CODE END. Other portions of this file, whether
  9. * inserted by the user or by software development tools
  10. * are owned by their respective copyright owners.
  11. *
  12. * COPYRIGHT(c) 2019 STMicroelectronics
  13. *
  14. * Redistribution and use in source and binary forms, with or without modification,
  15. * are permitted provided that the following conditions are met:
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************
  37. */
  38. /* Includes ------------------------------------------------------------------*/
  39. #include "main.h"
  40. #include "stm32f1xx_hal.h"
  41. #include "delay.h"
  42. #include "sys.h"
  43. #include "usart.h"
  44. #include "led.h"
  45. #include "usmart.h"
  46. #include "24cxx.h"
  47. //#include "rtc.h"
  48. //#include "sim7600.h"
  49. #include "iwdg.h"
  50. #include "gpio.h"
  51. const u8 TEXT_Buffer[]={"4G_SIM7600C STM32F103 IIC TEST"};
  52. #define SIZE sizeof(TEXT_Buffer)
  53. int main(void)
  54. {
  55. u8 datatemp[SIZE];
  56. // u8 time;
  57. HAL_Init();
  58. Stm32_Clock_Init(RCC_PLL_MUL9); //设置时钟,72M
  59. delay_init(72); //初始化延时函数
  60. uart2_init(115200);
  61. uart3_init(115200); //初始化串口
  62. usmart_dev.init(36); //初始化USMART
  63. LED_Init(); //初始化LED
  64. AT24CXX_Init(); //初始化IIC
  65. // time=RTC_Init(); //初始化RTC
  66. // sim7600_Init(); //4G模块初始化
  67. while(AT24CXX_Check())//检测不到24c02
  68. {
  69. // SIM7600_led=0;
  70. delay_ms(50);
  71. SIM7600_led=1;
  72. delay_ms(50);
  73. }
  74. // AT24CXX_Write(0,(u8*)TEXT_Buffer,SIZE);
  75. // delay_us(50);
  76. AT24CXX_Read(0,datatemp,SIZE);
  77. Usart_Send_Str_Data("\r ***初始化完成*** \r"); //初始化完成
  78. Usart_Send_Str_Data("\r\n\r\n"); //初始化完成
  79. Usart_Send_Str_Data("\r ***EEPROM初始化完成*** \r"); //初始化完成
  80. while (1)
  81. {
  82. SIM7600_led=0;
  83. Usart_TX_Set(1); //设置为发送模式
  84. delay_us(50);
  85. printf("\r\n\r\n");
  86. printf("\r ***串口3发送测试*** \r");
  87. Usart_TX_Set(0); //设置为接收模式
  88. // tx_led=0;
  89. delay_ms(300);
  90. SIM7600_led=1;
  91. delay_ms(300);
  92. }
  93. }
  94. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/