|
如题,前阵子本人买了一块GSM模块,PTM100,实现了通过STM32控制GSM模块发送短信及彩信; 趁此机会将源码上传与大家共享,希望大家拍砖 PS:发帖字数有限,只能发了main函数部分,其他部分在附件中,大家可自行下载查看 int main(void) { u8 count_error=0,GSM_Init_Flag=0x00; u8 length; RCC_Configuration(); GPIO_Configuration(); NVIC_Configuration(); USART_Configuration(); gsm_count=0; GPIO_SetBits(GPIOA,GPIO_Pin_0); GPIO_SetBits(GPIOA,GPIO_Pin_4); GPIO_SetBits(GPIOA,GPIO_Pin_5); GPIO_SetBits(GPIOA,GPIO_Pin_6); GPIO_SetBits(GPIOA,GPIO_Pin_7); GPIO_SetBits(GPIOA,GPIO_Pin_8); GSM_Init_Flag=CheckGSM(); while(1) { if(GSM_Init_Flag==USART_ERROR) { if(count_error==0) { USART2_SendToPC("USART_ERROR\n",12); count_error++; } GPIO_ResetBits(GPIOA,GPIO_Pin_0); Delay_us(10000); GPIO_SetBits(GPIOA,GPIO_Pin_0); Delay_us(10000); } else if(GSM_Init_Flag==CIMI_ERROR) { if(count_error==0) { USART2_SendToPC("CIMI_ERROR\n",11); count_error++; } GPIO_ResetBits(GPIOA,GPIO_Pin_4); Delay_us(10000); GPIO_SetBits(GPIOA,GPIO_Pin_4); Delay_us(10000); } else if(GSM_Init_Flag==CREG_ERROR) { if(count_error==0) { USART2_SendToPC("CREG_ERROR\n",11); count_error++; } GPIO_ResetBits(GPIOA,GPIO_Pin_5); Delay_us(10000); GPIO_SetBits(GPIOA,GPIO_Pin_5); Delay_us(10000); } else if(GSM_Init_Flag==CSQ_ERROR) { if(count_error==0) { USART2_SendToPC("CSQ_ERROR\n",10); count_error++; } GPIO_ResetBits(GPIOA,GPIO_Pin_6); Delay_us(10000); GPIO_SetBits(GPIOA,GPIO_Pin_6); Delay_us(10000); } else { count_error=0; GPIO_ResetBits(GPIOA,GPIO_Pin_7); Delay_us(10000); GPIO_SetBits(GPIOA,GPIO_Pin_7); Delay_us(10000); } if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1)==0) { Delay_us(15000); if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1)==0) while(!GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1)); Message_Send(Phone_Num,Title,strlen(Title),MMS,3286); } } } |
main.zip
下载9.47 KB, 下载次数: 101
STM32
超强工具——STM32CubeMX 你会用吗?
集结出发! STM32全国研讨会系列之一:ST智能门铃中国首秀
关于STM32启动文件的几个小问题
【银杏科技ARM+FPGA双核心应用】STM32H7系列35——USB_VCP_FS
【银杏科技ARM+FPGA双核心应用】STM32H7系列28——USB_HID
粉丝分享 | 图说CRC原理应用及STM32硬件CRC外设
STM32L151进入低功耗,并由RTC唤醒的故事
[转]stm32控制NFC模块(PN532)源码(P2P,模拟卡,读写卡等
STM32G070RB+LVGL移植
微信公众号
手机版
玩玩还是可以的,总归是为了学习,花点钱也值了
玩玩还是可以的,总归是为了学习,花点钱也值了