久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標(biāo)題:
STM32 MODBUS協(xié)議源程序
[打印本頁(yè)]
作者:
nihaobu
時(shí)間:
2019-8-2 15:26
標(biāo)題:
STM32 MODBUS協(xié)議源程序
STM32 MODBUS協(xié)議
單片機(jī)源程序如下:
/**
******************************************************************************
* @文件
* @作者
* @版本
* @日期
* @概要
******************************************************************************
* @注意事項(xiàng)
*
*
*
******************************************************************************
*/
/* 頭文件 --------------------------------------------------------------*/
#include <stdio.h>
#include "stm32f10x.h"
#include "mb.h"
/* 私有數(shù)據(jù)類型 --------------------------------------------------------------*/
/* 私有定義 --------------------------------------------------------------*/
/* 私有宏定義 --------------------------------------------------------------*/
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/* 私有變量 --------------------------------------------------------------*/
/* 私有函數(shù)聲明 --------------------------------------------------------------*/
void LED_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC,&GPIO_InitStructure);
}
/**
* @brief Configure the nested vectored interrupt controller.
* @param None
* @retval : None
*/
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the TIM2 gloabal Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the TIM2 gloabal Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/**
* @功能
* @參數(shù)
* @返回值
*/
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_Configuration();
LED_Config();
/*模式 從機(jī)地址 端口 波特率 校驗(yàn)位*/
eMBInit( MB_RTU, 0x01, 0, 9600, MB_PAR_NONE );
/* Enable the Modbus Protocol Stack. */
eMBEnable( );
for( ;; )
{
( void )eMBPoll( );
/* Here we simply count the number of poll cycles. */
//usRegInputBuf[0]++;
}
}
/**
* @brief Retargets the C library printf function to the USART.
* @param None
* @retval None
*/
PUTCHAR_PROTOTYPE
{
/* Place your implementation of fputc here */
/* Loop until the end of transmission */
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)
{}
/* e.g. write a character to the USART */
USART_SendData(USART1, (uint8_t) ch);
return ch;
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**
* @}
*/
/*******************************文件結(jié)尾**************************************/
復(fù)制代碼
所有資料51hei提供下載:
STM32_MODBUS.7z
(196.05 KB, 下載次數(shù): 129)
2019-8-2 18:06 上傳
點(diǎn)擊文件名下載附件
STM32_MODBUS協(xié)議
下載積分: 黑幣 -5
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
日韩久久成人
|
免费天天干
|
最近免费日本视频在线
|
日韩久久久久
|
亚洲精品在线视频
|
激情 一区
|
久久精品99
|
国产精品久久久久久婷婷天堂
|
中文二区
|
欧美一级欧美一级在线播放
|
av官网在线
|
欧洲精品在线观看
|
久久在线看
|
久艹av
|
久久专区
|
亚洲精品一区二区三区蜜桃久
|
国产精品久久久久久久久免费高清
|
美国黄色毛片
|
一级黄色片网址
|
美女黄频
|
日本精品一区二区
|
免费av观看
|
一区二区三区欧美大片
|
欧美成人在线免费
|
中文字幕日韩欧美一区二区三区
|
免费一级欧美在线观看视频
|
国产精品免费在线
|
欧美视频免费在线观看
|
国产精品久久久一区二区三区
|
6080亚洲精品一区二区
|
久久爱黑人激情av摘花
|
国产美女久久久
|
wwwxx在线观看
|
亚洲精品久久视频
|
亚洲综合中文字幕在线观看
|
国产成人精品久久
|
亚洲欧美综合
|
精品99在线
|
一区二区日韩
|
视频一二区
|
中文字幕在线一区
|