Programme pilote du pont
Fork of Le_Pont_V10015 by
Embed:
(wiki syntax)
Show/hide line numbers
Modbus.h
00001 /*******************************************************************/ 00002 /* */ 00003 /* Modbus */ 00004 /* */ 00005 /* Gestion de la liaison Modbus esclave */ 00006 /* */ 00007 /* */ 00008 /*******************************************************************/ 00009 #ifndef _MODBUS_ 00010 #define _MODBUS_ 00011 00012 #include "mbed.h" 00013 #include <Serial.h> 00014 00015 #include "Constantes.h" 00016 #include "Variable.h" 00017 00018 #include "time.h" 00019 00020 00021 00022 /***** Etats **********/ 00023 #define ARRET 0 00024 #define ATTENTE 1 00025 #define RECEPTION 2 00026 #define RECU 3 00027 #define TRAITE 4 00028 #define EMISSION 5 00029 #define FIN 6 00030 #define ERREUR 7 00031 #define TIMEOUT 8 00032 00033 /* ----------------------- Defines ------------------------------------------*/ 00034 #define MB_ADDRESSE_BROADCAST ( 0 ) /*! Modbus adresse de broadcast */ 00035 #define MB_ADDRESSE_MIN ( 1 ) /*! Smallest possible slave address. */ 00036 #define MB_ADDRESSE_MAX ( 247 ) /*! Biggest possible slave address. */ 00037 #define MB_FUNC_NONE ( 0 ) 00038 #define MB_FUNC_READ_COILS ( 1 ) 00039 #define MB_FUNC_READ_DISCRETE_INPUTS ( 2 ) 00040 #define MB_FUNC_WRITE_SINGLE_COIL ( 5 ) 00041 #define MB_FUNC_WRITE_MULTIPLE_COILS ( 15 ) 00042 #define MB_FUNC_READ_HOLDING_REGISTER ( 3 ) 00043 #define MB_FUNC_READ_INPUT_REGISTER ( 4 ) 00044 #define MB_FUNC_WRITE_REGISTER ( 6 ) 00045 #define MB_FUNC_WRITE_MULTIPLE_REGISTERS ( 16 ) 00046 #define MB_FUNC_READWRITE_MULTIPLE_REGISTERS ( 23 ) 00047 #define MB_FUNC_DIAG_READ_EXCEPTION ( 7 ) 00048 #define MB_FUNC_DIAG_DIAGNOSTIC ( 8 ) 00049 #define MB_FUNC_DIAG_GET_COM_EVENT_CNT ( 11 ) 00050 #define MB_FUNC_DIAG_GET_COM_EVENT_LOG ( 12 ) 00051 #define MB_FUNC_OTHER_REPORT_SLAVEID ( 17 ) 00052 #define MB_FUNC_ERROR ( 128 ) 00053 /* ----------------------- Type definitions ---------------------------------*/ 00054 typedef enum 00055 { 00056 MB_EX_NONE = 0x00, 00057 MB_EX_ILLEGAL_FUNCTION = 0x01, 00058 MB_EX_ILLEGAL_DATA_ADDRESS = 0x02, 00059 MB_EX_ILLEGAL_DATA_VALUE = 0x03, 00060 MB_EX_SLAVE_DEVICE_FAILURE = 0x04, 00061 MB_EX_ACKNOWLEDGE = 0x05, 00062 MB_EX_SLAVE_BUSY = 0x06, 00063 MB_EX_MEMORY_PARITY_ERROR = 0x08, 00064 MB_EX_GATEWAY_PATH_FAILED = 0x0A, 00065 MB_EX_GATEWAY_TGT_FAILED = 0x0B 00066 } Code_Erreur_t ; 00067 00068 #define TAILLE_MESSAGE_MAXI 20 00069 00070 typedef struct 00071 { 00072 U8 Etat_U8 ; 00073 U8 Code_Erreur ; 00074 U8 Trame_Recue_aU8 [TAILLE_MESSAGE_MAXI] ; 00075 U8 Nb_Caracteres_Recus_U8 ; 00076 U8 Trame_Reponse_aU8 [TAILLE_MESSAGE_MAXI] ; 00077 U8 Nb_Caracteres_A_Emettre_U8 ; 00078 } Ordre_Modbus_t ; 00079 00080 #define TAILLE_PILE_ORDRES 5 00081 00082 00083 extern volatile Ordre_Modbus_t Ordres[TAILLE_PILE_ORDRES] ; 00084 00085 00086 00087 extern void vModbus_Init(int Baudrate) ; 00088 extern void vModbus_Start() ; 00089 extern void vModbus_Stop() ; 00090 extern void vModbus_Reset() ; 00091 extern void vModbus() ; 00092 00093 00094 00095 00096 #endif
Generated on Tue Jul 12 2022 13:32:39 by
1.7.2
