|
智能井盖
FreeRTOS
GPS+BMA253传感器
串口通讯
单片机源程序如下:
- /* USER CODE END Header */
- /* Includes ------------------------------------------------------------------*/
- #include "main.h"
- #include "cmsis_os.h"
- #include "OEM_I2C.h"
- #include "OEM_Uart.h"
- #include "ATHandler.h"
- #include "sensor_api.h"
- #include "HAL_OS_API.h"
- #include "HAL_TCP_API.h"
- #include "HAL_UDP_API.h"
- #include "iot_protocol.h"
- #include "sensor_bma253.h"
- #include "gps_nmea_parse.h"
- #include "iot_data_packed.h"
- /* Private includes ----------------------------------------------------------*/
- /* USER CODE BEGIN Includes */
- /* USER CODE END Includes */
- /* Private typedef -----------------------------------------------------------*/
- /* USER CODE BEGIN PTD */
- /* USER CODE END PTD */
- /* Private define ------------------------------------------------------------*/
- /* USER CODE BEGIN PD */
- /* USER CODE END PD */
- /* Private macro -------------------------------------------------------------*/
- /* USER CODE BEGIN PM */
- /* USER CODE END PM */
- /* Private variables ---------------------------------------------------------*/
- RTC_HandleTypeDef hRtc;
- IWDG_HandleTypeDef hiwdg;
- static MAYBE_UNUSED osThreadId hSensorTask;
- static MAYBE_UNUSED osThreadId hProcessTask;
- static MAYBE_UNUSED char WorkingBuf[256*2];
- static MAYBE_UNUSED stAT_URC_t URCTabBuf[2];
- static osMessageQId MsgBox;
- /* USER CODE BEGIN PV */
- /* USER CODE END PV */
- /* Private function prototypes -----------------------------------------------*/
- void SystemClock_Config(void);
- void StartSensorMonitorTask(void const * argument);
- void StartDataProcessTask(void const * argument);
- /* USER CODE BEGIN PFP */
- /* USER CODE END PFP */
- /* Private user code ---------------------------------------------------------*/
- /* USER CODE BEGIN 0 */
- /**
- * @brief Retargets the C library printf function to the USART.
- * @param None
- * @retval None
- */
- int fputc(int ch, FILE *f)
- {
- /* Place your implementation of fputc here */
- /* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */
- HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xffff);
- return ch;
- }
- /* USER CODE END 0 */
- /**
- * @brief Toggles the selected LED.
- * @param Led: Specifies the Led to be toggled.
- * This parameter must be: LED2
- * @retval None
- */
- static MAYBE_UNUSED void STM_EVAL_LED_Toggle(void)
- {
- HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
- }
- static MAYBE_UNUSED void casic_gps_rsp_callback(char *rspinfo, int rsplen,void *arg)
- {
- if (NULL == rspinfo || rsplen == 0)
- {
- LOGE("invalid input at %s \r\n", __func__);
- return;
- }
- LOGI("+++++++++++++++++ rsp = %s \r\n", rspinfo);
- gps_data_t gpsdata;
- if (0 == gps_gp_proc(rspinfo, &gpsdata))
- {
- printf("lat is %f lon is %f elv is %f\r\n", gpsdata.lat, gpsdata.lon, gpsdata.elv);
- }
- return;
- }
- static MAYBE_UNUSED BOOL ConfigClockFromPLL(void)
- {
- #if 0
- RCC_ClkInitTypeDef RCC_ClkInitStruct;
- // Select PLL as system clock source and configure the HCLK and PCLK1 clocks dividers
- RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1);
- RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 48 MHz
- RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 48 MHz
- RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; // 48 MHz
- if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
- {
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
STM32F0RBTx-20192026.7z
(2.94 MB, 下载次数: 19)
|
|