Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
RS485.h
00001 #include "mbed.h" 00002 00003 00004 //--------------------------------------- 00005 // Definitions 00006 //--------------------------------------- 00007 #define RS485_BUFFER_LENGTH 512 00008 #define RS485_RX_TIMEOUT_US 300 00009 #define RS485_TX_TIMEOUT_US 300 00010 #define RS485_BAUDRATE 38400 // Same as Display 00011 #define RS485_BITS 8 00012 #define RS485_STOPBIT 1 00013 00014 //--------------------------------------- 00015 // Enums 00016 //--------------------------------------- 00017 typedef enum 00018 { 00019 RS485_MODE_LISTEN, 00020 RS485_MODE_RX_READY, 00021 //----------------- 00022 CNT_eRS485_mode 00023 }eRS485_mode; 00024 00025 00026 //--------------------------------------- 00027 // Structures 00028 //--------------------------------------- 00029 typedef struct 00030 { 00031 eRS485_mode mode; // mode of RS485 hardware 00032 char *ptrRXBuffer; // actual read position in buffer 00033 char bytesToRead; // Number of received bytes 00034 }sRS485_handler; 00035 00036 00037 00038 //--------------------------------------- 00039 // Global Variables 00040 //--------------------------------------- 00041 extern sRS485_handler RS485_handler; 00042 extern char RS485Buffer[RS485_BUFFER_LENGTH]; 00043 00044 00045 //--------------------------------------- 00046 // Global Functions 00047 //--------------------------------------- 00048 void RS485_init( void ); 00049 void RS485_reset( void ); // clear all RS485 registers, --> restart 00050 int RS485_receiveData( char *& ptrData, int *ptrNumBytes ); 00051 int RS485_sendData( char *ptrDataToSend, int NumBytes ); 00052 int RS485_sendDataWithCRC( char *ptrDataToSend, int NumBytes );
Generated on Sat Jul 16 2022 03:23:52 by
