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.
Dependents: ClassFRDM ClassLPC
DataComm.h
00001 //data comm functions 00002 //serial communication protocol 00003 00004 #ifndef DATACOMM_H 00005 #define DATACOMM_H 00006 00007 #define PREAMBLE 0x7E 00008 #define POSTAMBLE 0x7F 00009 #define MAX 100 00010 00011 #include "mbed.h" 00012 #include "platform.h" 00013 #include "gpio_api.h" 00014 00015 class DataComm { 00016 00017 public: 00018 //initialize signal input/output pins 00019 void setClockOut(PinName pin); 00020 void setClockIn(PinName pin); 00021 void setSerialOut(PinName pin); 00022 void setSerialIn(PinName pin); 00023 //listen for incoming preamble 00024 void listen(); 00025 //set clock speed 00026 void setClock(int clock); 00027 //send preamble 00028 void initiate_connection(); 00029 void send_data(char data[], int size); 00030 char* receive_data(); 00031 //send postamble 00032 void close_connection(); 00033 00034 00035 00036 protected: 00037 //gpio input/output pins 00038 gpio_t clock_out; 00039 gpio_t clock_in; 00040 gpio_t serial_out; 00041 gpio_t serial_in; 00042 //clock speed and skew 00043 int clock_time; 00044 int skew_time; 00045 //timer for handling clock and skew 00046 Timer t; 00047 }; 00048 00049 #endif
Generated on Wed Jul 13 2022 11:41:11 by
1.7.2