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.
uart.h
00001 #include "mbed.h" 00002 00003 00004 //--------------------------------------- 00005 // Definitions 00006 //--------------------------------------- 00007 #define UART_BUFFER_LENGTH 512 00008 #define UART_RX_TIMEOUT_US 1000 00009 #define UART_BAUDRATE 115200 00010 #define UART_BITS 8 00011 #define UART_STOPBIT 1 00012 00013 //--------------------------------------- 00014 // Enums 00015 //--------------------------------------- 00016 typedef enum { 00017 UART_MODE_LISTEN, 00018 UART_MODE_RX_READY, 00019 //----------------- 00020 CNT_eUART_mode 00021 } eUART_mode; 00022 00023 00024 //--------------------------------------- 00025 // Structures 00026 //--------------------------------------- 00027 typedef struct { 00028 eUART_mode mode; // mode of UART hardware 00029 char *ptrBuffer; // start address of buffer 00030 char *ptrReadPositon; // actual read position in buffer 00031 char *ptrWritePosition; // actual write position in buffer 00032 char bytesToRead; // Number of received bytes 00033 char bytesToWrite; // Number of bytes to send 00034 } sUART_handler; 00035 00036 00037 00038 //--------------------------------------- 00039 // Global Variables 00040 //--------------------------------------- 00041 extern sUART_handler UART_handler; 00042 extern char uartBuffer[UART_BUFFER_LENGTH]; 00043 00044 00045 //--------------------------------------- 00046 // Global Functions 00047 //--------------------------------------- 00048 void UART_init( void ); 00049 void UART_reset( void ); // clear all UART registers, --> restart 00050 int UART_newFrame( void ); // check for new received frame 00051 int UART_checkReceivedCRC( void ); // check received CRC16 00052 int UART_sendData( void ); // send data saved in buffer
Generated on Sat Jul 16 2022 03:23:52 by
