资源简介
用于stm32的modbus库,已经移植好,亲测可以用,方便大家参考学习
代码片段和文件信息
/**
******************************************************************************
* @文件
* @作者
* @版本
* @日期
* @概要
******************************************************************************
* @注意事项
*
*
*
******************************************************************************
*/
/* 头文件 --------------------------------------------------------------*/
#include
#include “stm32f10x.h“
#include “mb.h“
/* 私有数据类型 --------------------------------------------------------------*/
/* 私有定义 --------------------------------------------------------------*/
/* 私有宏定义 --------------------------------------------------------------*/
#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__ */
/* 私有变量 --------------------------------------------------------------*/
/* 私有函数声明 --------------------------------------------------------------*/
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);
}
/**
* @功能
* @参数
* @返回值
*/
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_Configuration();
LED_Config();
/*模式 从机地址 端口 波特率 校验位*/
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(USART
相关资源
- stm32F103通过IIC读取MPU9250用DMP融合得到
- 鸥鹏stm32教程配套
- STM32F103ZET6最小系统板原理图
- STM32 串口 Modbus RTU 协议 代码
- Modbus TCP/IP协议说明书
- 声源定位程序
- labview modbus
- STM32-无刷直流电机控制器程序
- Altium designer STM32元件库
- SPWM波产生STM32F103 DMA
- STM32F103测频率
- STM32F103+DAC8552
- STM32 4*4按键
- STM32全系列芯片封装库,最齐全封装库
- STM32F407最小系统板(SWD口)
- modbus 从站调试软件
- STM32F103C8T6 LCD12864 串行通信
- STM32驱动ht1621b显示LCD
- STM32 F4系列所有原理图及PCB封装库
- Modbus Poll
- cubeMX视频教程stm32hal库函数cubemx实战讲
- SPWM逆变器stm32例程及电路图仿真.zip
- MPU6050(STM32 DMP).rar
- STM32F407 485 MODBUS
- STM32 hal库操作ESP8266
- STM32 STM32F103C8T6 读取DS18B20温度数据例
- STM32 STM32F103C8T6 CAN从机+4DI2DO 硬件设计
- STM32外部计数器程序
- STMicroelectronics STM32及STM8全系列Altium
- 基于STM32cubeMX,STM32F103C8T6的PWM输出实
评论
共有 条评论