mirror of
https://github.com/armink/FreeModbus_Slave-Master-RTT-STM32.git
synced 2024-09-01 08:09:25 +08:00
1、【修改】FreeModbus中的Port框架,并支持主机模式
2、【增加】FreeModbus中的Port关于主机的移植文件 3、【增加】FreeModbus分析图中关于FreeModbus初始化的流程图 Signed-off-by: armink <armink.ztl@gmail.com>
This commit is contained in:
parent
40aa4e1a58
commit
d4ee095afa
Binary file not shown.
@ -16,7 +16,7 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id: port.h,v 1.1 2007/04/24 23:15:18 wolti Exp $
|
||||
* File: $Id: port.h add Master Functions,v 1.1 2013/08/13 15:07:05 Armink Exp $
|
||||
*/
|
||||
|
||||
#ifndef _PORT_H
|
||||
@ -34,8 +34,10 @@
|
||||
#define PR_END_EXTERN_C }
|
||||
|
||||
//TODO <20><>ʱ<EFBFBD><CAB1>дB13<31><33><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ȷ<EFBFBD><C8B7>
|
||||
#define RS485_SEND_MODE GPIO_SetBits(GPIOB,GPIO_Pin_13)
|
||||
#define RS485_RECEIVE_MODE GPIO_ResetBits(GPIOB,GPIO_Pin_13)
|
||||
#define SLAVER_RS485_SEND_MODE GPIO_SetBits(GPIOB,GPIO_Pin_13)
|
||||
#define SLAVER_RS485_RECEIVE_MODE GPIO_ResetBits(GPIOB,GPIO_Pin_13)
|
||||
#define MASTER_RS485_SEND_MODE GPIO_SetBits(GPIOB,GPIO_Pin_13)
|
||||
#define MASTER_RS485_RECEIVE_MODE GPIO_ResetBits(GPIOB,GPIO_Pin_13)
|
||||
|
||||
//void USART1_IRQHandler(void);
|
||||
//void TIM3_IRQHandler(void);
|
||||
@ -45,9 +47,6 @@
|
||||
|
||||
void EnterCriticalSection(void);
|
||||
void ExitCriticalSection(void);
|
||||
void prvvUARTTxReadyISR(void);
|
||||
void prvvUARTRxISR(void);
|
||||
void TIMERExpiredISR(void);
|
||||
|
||||
typedef uint8_t BOOL;
|
||||
|
||||
|
58
FreeModbus/port/port_m_event.c
Normal file
58
FreeModbus/port/port_m_event.c
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* FreeModbus Libary: STM32 Port
|
||||
* Copyright (C) 2013 Armink <armink.ztl@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id: port_m_event.c add Master Functions,v 1.1 2013/08/13 15:07:05 Armink Exp $
|
||||
*/
|
||||
|
||||
/* ----------------------- Modbus includes ----------------------------------*/
|
||||
#include "mb.h"
|
||||
#include "mbport.h"
|
||||
|
||||
/* ----------------------- Variables ----------------------------------------*/
|
||||
static eMBEventType eMasterQueuedEvent;
|
||||
static BOOL xMasterEventInQueue;
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
BOOL
|
||||
xMBPortMasterEventInit( void )
|
||||
{
|
||||
xMasterEventInQueue = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
xMBPortMasterEventPost( eMBEventType eEvent )
|
||||
{
|
||||
xMasterEventInQueue = TRUE;
|
||||
eMasterQueuedEvent = eEvent;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
xMBPortMasterEventGet( eMBEventType * eEvent )
|
||||
{
|
||||
BOOL xEventHappened = FALSE;
|
||||
|
||||
if( xMasterEventInQueue )
|
||||
{
|
||||
*eEvent = eMasterQueuedEvent;
|
||||
xMasterEventInQueue = FALSE;
|
||||
xEventHappened = TRUE;
|
||||
}
|
||||
return xEventHappened;
|
||||
}
|
190
FreeModbus/port/port_m_serial.c
Normal file
190
FreeModbus/port/port_m_serial.c
Normal file
@ -0,0 +1,190 @@
|
||||
/*
|
||||
* FreeModbus Libary: STM32 Port
|
||||
* Copyright (C) 2013 Armink <armink.ztl@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id: port_m_serial.c add Master Functions,v 1.1 2013/08/13 15:07:05 Armink Exp $
|
||||
*/
|
||||
|
||||
#include "port.h"
|
||||
|
||||
/* ----------------------- Modbus includes ----------------------------------*/
|
||||
#include "mb.h"
|
||||
#include "mbport.h"
|
||||
/* ----------------------- static functions ---------------------------------*/
|
||||
static void prvvUARTTxReadyISR(void);
|
||||
static void prvvUARTRxISR(void);
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
|
||||
void vMBPortMasterSerialEnable(BOOL xRxEnable, BOOL xTxEnable)
|
||||
{
|
||||
if (xRxEnable)
|
||||
{
|
||||
MASTER_RS485_RECEIVE_MODE;
|
||||
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
MASTER_RS485_SEND_MODE;
|
||||
USART_ITConfig(USART2, USART_IT_RXNE, DISABLE);
|
||||
}
|
||||
if (xTxEnable)
|
||||
{
|
||||
USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void vMBPortMasterClose(void)
|
||||
{
|
||||
USART_ITConfig(USART2, USART_IT_TXE | USART_IT_RXNE, DISABLE);
|
||||
USART_Cmd(USART2, DISABLE);
|
||||
}
|
||||
//Ĭ<><C4AC>һ<EFBFBD><D2BB><EFBFBD>ӻ<EFBFBD> <20><><EFBFBD><EFBFBD>2 <20><><EFBFBD><EFBFBD><EFBFBD>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD> <20><>ż<EFBFBD><C5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
BOOL xMBPortMasterSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits,
|
||||
eMBParity eParity)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
USART_InitTypeDef USART_InitStructure;
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
//======================ʱ<>ӳ<EFBFBD>ʼ<EFBFBD><CABC>=======================================
|
||||
RCC_APB2PeriphClockCmd(
|
||||
RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB1Periph_USART2,
|
||||
ENABLE);
|
||||
//======================IO<49><4F>ʼ<EFBFBD><CABC>=======================================
|
||||
//USART2_TX
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
//USART2_RX
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
//<2F><><EFBFBD><EFBFBD>485<38><35><EFBFBD>ͺͽ<CDBA><CDBD><EFBFBD>ģʽ
|
||||
// TODO <20><>ʱ<EFBFBD><CAB1>дB13 <20><>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
//======================<3D><><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC>=======================================
|
||||
USART_InitStructure.USART_BaudRate = ulBaudRate;
|
||||
//<2F><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ģʽ
|
||||
switch (eParity)
|
||||
{
|
||||
case MB_PAR_NONE: //<2F><>У<EFBFBD><D0A3>
|
||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
break;
|
||||
case MB_PAR_ODD: //<2F><>У<EFBFBD><D0A3>
|
||||
USART_InitStructure.USART_Parity = USART_Parity_Odd;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_9b;
|
||||
break;
|
||||
case MB_PAR_EVEN: //żУ<C5BC><D0A3>
|
||||
USART_InitStructure.USART_Parity = USART_Parity_Even;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_9b;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
USART_InitStructure.USART_HardwareFlowControl =
|
||||
USART_HardwareFlowControl_None;
|
||||
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
|
||||
if (ucPORT > 1)
|
||||
return FALSE;
|
||||
|
||||
ENTER_CRITICAL_SECTION(); //<2F><>ȫ<EFBFBD><C8AB><EFBFBD>ж<EFBFBD>
|
||||
|
||||
USART_Init(USART2, &USART_InitStructure);
|
||||
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
|
||||
USART_Cmd(USART2, ENABLE);
|
||||
|
||||
//=====================<3D>жϳ<D0B6>ʼ<EFBFBD><CABC>======================================
|
||||
//<2F><><EFBFBD><EFBFBD>NVIC<49><43><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>ΪGroup2<70><32>0-3<><33>ռʽ<D5BC><CABD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>0-3<><33><EFBFBD><EFBFBD>Ӧʽ<D3A6><CABD><EFBFBD>ȼ<EFBFBD>
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
||||
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
|
||||
EXIT_CRITICAL_SECTION(); //<2F><>ȫ<EFBFBD><C8AB><EFBFBD>ж<EFBFBD>
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL xMBPortMasterSerialPutByte(CHAR ucByte)
|
||||
{
|
||||
USART_SendData(USART2, ucByte);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL xMBPortMasterSerialGetByte(CHAR * pucByte)
|
||||
{
|
||||
*pucByte = USART_ReceiveData(USART2);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an interrupt handler for the transmit buffer empty interrupt
|
||||
* (or an equivalent) for your target processor. This function should then
|
||||
* call pxMBFrameCBTransmitterEmpty( ) which tells the protocol stack that
|
||||
* a new character can be sent. The protocol stack will then call
|
||||
* xMBPortSerialPutByte( ) to send the character.
|
||||
*/
|
||||
void prvvUARTTxReadyISR(void)
|
||||
{
|
||||
pxMBFrameCBTransmitterEmpty();
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an interrupt handler for the receive interrupt for your target
|
||||
* processor. This function should then call pxMBFrameCBByteReceived( ). The
|
||||
* protocol stack will then call xMBPortSerialGetByte( ) to retrieve the
|
||||
* character.
|
||||
*/
|
||||
void prvvUARTRxISR(void)
|
||||
{
|
||||
pxMBFrameCBByteReceived();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Function Name : USART2_IRQHandler
|
||||
* Description : This function handles USART2 global interrupt request.
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void USART2_IRQHandler(void)
|
||||
{
|
||||
rt_interrupt_enter();
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
if (USART_GetITStatus(USART2, USART_IT_RXNE) == SET)
|
||||
{
|
||||
USART_ClearITPendingBit(USART2, USART_IT_RXNE);
|
||||
prvvUARTRxISR();
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
if (USART_GetITStatus(USART2, USART_IT_TXE) == SET)
|
||||
{
|
||||
USART_ClearITPendingBit(USART2, USART_IT_TXE);
|
||||
prvvUARTTxReadyISR();
|
||||
}
|
||||
rt_interrupt_leave();
|
||||
}
|
108
FreeModbus/port/port_m_timer.c
Normal file
108
FreeModbus/port/port_m_timer.c
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* FreeModbus Libary: STM32 Port
|
||||
* Copyright (C) 2013 Armink <armink.ztl@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id: port_m_timer.c add Master Functions,v 1.1 2013/08/13 15:07:05 Armink Exp $
|
||||
*/
|
||||
|
||||
/* ----------------------- Platform includes --------------------------------*/
|
||||
#include "port.h"
|
||||
|
||||
/* ----------------------- Modbus includes ----------------------------------*/
|
||||
#include "mb.h"
|
||||
#include "mbport.h"
|
||||
|
||||
/* ----------------------- static functions ---------------------------------*/
|
||||
static void prvvTIMERExpiredISR(void);
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
BOOL xMBPortMasterTimersInit(USHORT usTim1Timerout50us)
|
||||
{
|
||||
|
||||
uint16_t PrescalerValue = 0;
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
//====================================ʱ<>ӳ<EFBFBD>ʼ<EFBFBD><CABC>===========================
|
||||
//ʹ<>ܶ<EFBFBD>ʱ<EFBFBD><CAB1>2ʱ<32><CAB1>
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
|
||||
//====================================<3D><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>===========================
|
||||
//<2F><>ʱ<EFBFBD><CAB1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>
|
||||
//HCLKΪ72MHz<48><7A>APB1<42><31><EFBFBD><EFBFBD>2<EFBFBD><32>ƵΪ36MHz
|
||||
//TIM2<4D><32>ʱ<EFBFBD>ӱ<EFBFBD>Ƶ<EFBFBD><C6B5>Ϊ72MHz<48><7A>Ӳ<EFBFBD><D3B2><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>Ƶ,<2C>ﵽ<EFBFBD><EFB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//TIM2<4D>ķ<EFBFBD>Ƶϵ<C6B5><CFB5>Ϊ3599<39><39>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>Ϊ72 / (1 + Prescaler) = 20KHz,<2C><>Ϊ50us
|
||||
//TIM<49><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪusTim1Timerout50u
|
||||
|
||||
PrescalerValue = (uint16_t) (SystemCoreClock / 20000) - 1;
|
||||
//<2F><>ʱ<EFBFBD><CAB1>1<EFBFBD><31>ʼ<EFBFBD><CABC>
|
||||
TIM_TimeBaseStructure.TIM_Period = (uint16_t) usTim1Timerout50us;
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
|
||||
//Ԥװ<D4A4><D7B0>ʹ<EFBFBD><CAB9>
|
||||
TIM_ARRPreloadConfig(TIM2, ENABLE);
|
||||
//====================================<3D>жϳ<D0B6>ʼ<EFBFBD><CABC>===========================
|
||||
//<2F><><EFBFBD><EFBFBD>NVIC<49><43><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>ΪGroup2<70><32>0-3<><33>ռʽ<D5BC><CABD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>0-3<><33><EFBFBD><EFBFBD>Ӧʽ<D3A6><CABD><EFBFBD>ȼ<EFBFBD>
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־λ
|
||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
|
||||
//<2F><>ʱ<EFBFBD><CAB1>3<EFBFBD><33><EFBFBD><EFBFBD><EFBFBD>жϹر<CFB9>
|
||||
TIM_ITConfig(TIM2, TIM_IT_Update, DISABLE);
|
||||
//<2F><>ʱ<EFBFBD><CAB1>3<EFBFBD><33><EFBFBD><EFBFBD>
|
||||
TIM_Cmd(TIM2, DISABLE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void vMBPortMasterTimersEnable()
|
||||
{
|
||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
|
||||
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
|
||||
TIM_SetCounter(TIM2, 0);
|
||||
TIM_Cmd(TIM2, ENABLE);
|
||||
}
|
||||
|
||||
void vMBPortMasterTimersDisable()
|
||||
{
|
||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
|
||||
TIM_ITConfig(TIM2, TIM_IT_Update, DISABLE);
|
||||
TIM_SetCounter(TIM2, 0);
|
||||
TIM_Cmd(TIM2, DISABLE);
|
||||
}
|
||||
|
||||
void prvvTIMERExpiredISR(void)
|
||||
{
|
||||
//TODO <20><EFBFBD><DEB8><EFBFBD><EFBFBD>ʺ<EFBFBD><CABA><EFBFBD><EFBFBD><EFBFBD>
|
||||
(void) pxMBPortCBTimerExpired();
|
||||
}
|
||||
|
||||
void TIM2_IRQHandler(void)
|
||||
{
|
||||
rt_interrupt_enter();
|
||||
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
|
||||
{
|
||||
|
||||
TIM_ClearFlag(TIM2, TIM_FLAG_Update); //<2F><><EFBFBD>жϱ<D0B6><CFB1><EFBFBD>
|
||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>TIM2<4D><32><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־λ
|
||||
prvvTIMERExpiredISR();
|
||||
}
|
||||
rt_interrupt_leave();
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeModbus Libary: LPC214X Port
|
||||
* Copyright (C) 2007 Tiago Prado Lone <tiago@maxwellbohr.com.br>
|
||||
* FreeModbus Libary: STM32 Port
|
||||
* Copyright (C) 2013 Armink <armink.ztl@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -16,7 +16,7 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id: portevent.c,v 1.1 2007/04/24 23:15:18 wolti Exp $
|
||||
* File: $Id: port_s_event.c,v 1.1 2013/08/13 15:07:05 Armink Exp $
|
||||
*/
|
||||
|
||||
/* ----------------------- Modbus includes ----------------------------------*/
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeModbus Libary: LPC214X Port
|
||||
* Copyright (C) 2007 Tiago Prado Lone <tiago@maxwellbohr.com.br>
|
||||
* FreeModbus Libary: STM32 Port
|
||||
* Copyright (C) 2013 Armink <armink.ztl@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -16,7 +16,7 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id: portserial.c,v 1.1 2007/04/24 23:15:18 wolti Exp $
|
||||
* File: $Id: port_s_serial.c,v 1.1 2013/08/13 15:07:05 Armink Exp $
|
||||
*/
|
||||
|
||||
#include "port.h"
|
||||
@ -33,12 +33,12 @@ void vMBPortSerialEnable(BOOL xRxEnable, BOOL xTxEnable)
|
||||
{
|
||||
if (xRxEnable)
|
||||
{
|
||||
RS485_RECEIVE_MODE;
|
||||
SLAVER_RS485_RECEIVE_MODE;
|
||||
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
RS485_SEND_MODE;
|
||||
SLAVER_RS485_SEND_MODE;
|
||||
USART_ITConfig(USART1, USART_IT_RXNE, DISABLE);
|
||||
}
|
||||
if (xTxEnable)
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeModbus Libary: LPC214X Port
|
||||
* Copyright (C) 2007 Tiago Prado Lone <tiago@maxwellbohr.com.br>
|
||||
* FreeModbus Libary: STM32 Port
|
||||
* Copyright (C) 2013 Armink <armink.ztl@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -16,7 +16,7 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* File: $Id: porttimer.c,v 1.1 2007/04/24 23:15:18 wolti Exp $
|
||||
* File: $Id: port_s_timer.c,v 1.1 2013/08/13 15:07:05 Armink Exp $
|
||||
*/
|
||||
|
||||
/* ----------------------- Platform includes --------------------------------*/
|
||||
@ -26,6 +26,9 @@
|
||||
#include "mb.h"
|
||||
#include "mbport.h"
|
||||
|
||||
/* ----------------------- static functions ---------------------------------*/
|
||||
static void prvvTIMERExpiredISR(void);
|
||||
|
||||
/* ----------------------- Start implementation -----------------------------*/
|
||||
BOOL xMBPortTimersInit(USHORT usTim1Timerout50us)
|
||||
{
|
||||
@ -56,8 +59,8 @@ BOOL xMBPortTimersInit(USHORT usTim1Timerout50us)
|
||||
//<2F><><EFBFBD><EFBFBD>NVIC<49><43><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>ΪGroup2<70><32>0-3<><33>ռʽ<D5BC><CABD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>0-3<><33><EFBFBD><EFBFBD>Ӧʽ<D3A6><CABD><EFBFBD>ȼ<EFBFBD>
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־λ
|
Loading…
x
Reference in New Issue
Block a user