MBSlave.cpp
Código
#include "MBSlave.h" UCHAR mFrame[BUFFER_SIZE]; UINT mHoldingRegsSize; UINT *mRegs; UCHAR mBroadcastFlag; UCHAR mSlaveID; UCHAR mFunction; UINT errorCount; UINT T1_5; //inter character time out UINT T3_5; //frame delay Serial *MBPort; // function definitions void exceptionResponse(UCHAR exception); UINT calculateCRC(UCHAR bufferSize); void sendPacket(UCHAR bufferSize); void mBInit( Serial *SerialPort, int baud, UCHAR _slaveID, UINT _holdingRegsSize, UINT *_regs) { //implementación } metodos de las funciones.
MBSlave.h
Código
#ifndef MBSlave_H #define MBSlave_H //definitions of types typedef unsigned char UCHAR; typedef unsigned int UINT; #include "mbed.h" #define BUFFER_SIZE 64 #define MBdebug 1 UINT mBPoll( void ); void mBInit(Serial *SerialPort, int baud, UCHAR _slaveID, UINT _holdingRegsSize, UINT *_regs) #endif