欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2750|回復: 0
收起左側

STM8L0單片機+L76C GPS+DMA+串口源程序

[復制鏈接]
ID:420860 發表于 2020-11-18 16:04 | 顯示全部樓層 |閱讀模式
本程序用于太陽能同步霧燈,可通過DMA+USART1接收移遠GPS模塊(L76C)實現同步閃爍。

單片機源程序如下:
  1. #include "stm8l15x.h"
  2. #include "led.h"
  3. #include "lamp.h"
  4. #include "adc.h"
  5. #include "usart1.h"
  6. #include "timer.h"
  7. #include "switch.h"
  8. #include "gps.h"
  9. #include "dma.h"

  10. void main()
  11. {
  12.   disableInterrupts();   //關閉系統總中斷
  13.   CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1); //內部時鐘為1分頻 = 16Mhz
  14.   
  15.   LEDInit();
  16.   LAMPInit();
  17.   SWITCHInit();
  18.   ADCInit();
  19.   USART1Init(9600);
  20.   DMAInit();
  21.   GPSInit();
  22.   TIM4_Init();   //調用定時器4初始化函數
  23.   enableInterrupts();   //使能系統總中斷

  24.   while(1)
  25.   {  
  26.     AdcHandler(); //AD采樣
  27.     GPSHandler(); //GPS數據解析
  28.   }   
  29. }
復制代碼

#include "GPS.h"

void GPSInit(void)
{
  L76C_CFG_GGA(0);//關閉GGA
  L76C_CFG_GLL(0);//關閉GLL
  L76C_CFG_GSA(0);//關閉GSA
  L76C_CFG_GSV(0);//關閉GSV
  L76C_CFG_RMC(0);//關閉RMC
  L76C_CFG_VTG(0);//關閉VTG
  L76C_CFG_ZDA(5);//ZDA數據5秒發送一次
  L76C_CFG_GST(0);//關閉GST
  L76C_CFG_SAVE();//保存配置信息
}

void L76C_CFG_GGA(unsigned char temp)
{
  unsigned char tempBuf[15]={'$','C','F','G','M','S','G',',','0',',','0',',','0',0x0A,0x0D};
  if(temp!=0)
  {
    tempBuf[12]=temp;
  }
  
  Uart1_SendString(tempBuf,15);
}

void L76C_CFG_GLL(unsigned char temp)
{
  unsigned char tempBuf[15]={'$','C','F','G','M','S','G',',','1',',','0',',','0',0x0A,0x0D};
  if(temp!=0)
  {
    tempBuf[12]=temp;
  }
  
  Uart1_SendString(tempBuf,15);
}

void L76C_CFG_GSA(unsigned char temp)
{
  unsigned char tempBuf[15]={'$','C','F','G','M','S','G',',','2',',','0',',','0',0x0A,0x0D};
  if(temp!=0)
  {
    tempBuf[12]=temp;
  }
  
  Uart1_SendString(tempBuf,15);
}

void L76C_CFG_GSV(unsigned char temp)
{
  unsigned char tempBuf[15]={'$','C','F','G','M','S','G',',','3',',','0',',','0',0x0A,0x0D};
  if(temp!=0)
  {
    tempBuf[12]=temp;
  }
  
  Uart1_SendString(tempBuf,15);
}

void L76C_CFG_RMC(unsigned char temp)
{
  unsigned char tempBuf[15]={'$','C','F','G','M','S','G',',','4',',','0',',','0',0x0A,0x0D};
  if(temp!=0)
  {
    tempBuf[12]=temp;
  }
  
  Uart1_SendString(tempBuf,15);
}

void L76C_CFG_VTG(unsigned char temp)
{
  unsigned char tempBuf[15]={'$','C','F','G','M','S','G',',','5',',','0',',','0',0x0A,0x0D};
  if(temp!=0)
  {
    tempBuf[12]=temp;
  }
  
  Uart1_SendString(tempBuf,15);
}

void L76C_CFG_ZDA(unsigned char temp)
{
  unsigned char tempBuf[15]={'$','C','F','G','M','S','G',',','6',',','0',',','0',0x0A,0x0D};
  if(temp!=0)
  {
    tempBuf[12]=temp;
  }
  
  Uart1_SendString(tempBuf,15);
}

void L76C_CFG_GST(unsigned char temp)
{
  unsigned char tempBuf[15]={'$','C','F','G','M','S','G',',','7',',','0',',','0',0x0A,0x0D};
  if(temp!=0)
  {
    tempBuf[12]=temp;
  }
  
  Uart1_SendString(tempBuf,15);
}

void L76C_CFG_SAVE(void)
{
  unsigned char tempBuf[14]={'$','C','F','G','S','A','V','E',',','h','0','F',0x0A,0x0D};
  
  Uart1_SendString(tempBuf,14);
}


所有資料51hei提供下載:
GPS.7z (810.72 KB, 下載次數: 32)
L76-C.7z (2.31 MB, 下載次數: 28)


評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

回復

使用道具 舉報

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

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表