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.
rs232.h
00001 #include "mbed.h" 00002 00003 00004 00005 //--------------------------------------- 00006 // Definitions 00007 //--------------------------------------- 00008 #define RS232_BUFFER_LENGTH 256 00009 #define RS232_RX_TIMEOUT_US 50000 00010 #define RS232_BAUDRATE 9600 00011 #define RS232_BITS 8 00012 #define RS232_STOPBIT 1 00013 00014 00015 //--------------------------------------- 00016 // Enums 00017 //--------------------------------------- 00018 typedef enum 00019 { 00020 RS232_MODE_LISTEN, 00021 RS232_MODE_RX_READY, 00022 //----------------- 00023 CNT_eRS232_mode 00024 }eRS232_mode; 00025 00026 00027 00028 //--------------------------------------- 00029 // Structures 00030 //--------------------------------------- 00031 typedef struct 00032 { 00033 eRS232_mode mode; // mode of RS232 hardware 00034 char *ptrReadPositon; // actual read position in buffer 00035 int bytesToRead; // Number of received bytes 00036 }sRS232_handler; 00037 00038 00039 00040 //--------------------------------------- 00041 // Global Variables 00042 //--------------------------------------- 00043 00044 00045 00046 //--------------------------------------- 00047 // Global Functions 00048 //--------------------------------------- 00049 void RS232_init( void ); // Init hardware and internal buffer 00050 00051 00052 int RS232_receiveData( char *& ptrData, int *ptrNumBytes ); // "char *&" = reference to pointer !! 00053 // return pointer to buffer and number of received bytes 00054 // Return 1: New data available, get pointer to buffer and number of bytes to read 00055 // Return 0: No new data available 00056 int RS232_sendData( char *ptrData, int NumBytes ); // send data NumBytes bytes from source pointer: ptrData 00057 // Return 1: Sending was successfull 00058 // Return 0: Could not send data, eithter to many bytes, zero bytes or UART is still listining 00059 00060 void RS232_setRTS( int level); 00061 int RS232_getCTS( void );
Generated on Sat Jul 16 2022 03:23:51 by
