Sub programs of serial_transport, PID and motor contrl.

Dependents:   tracking_ball_0516 tracking_ball_0516

Committer:
helenh
Date:
Sun May 30 01:39:35 2021 +0000
Revision:
7:fd405402ff8c
Parent:
5:9f066f9abe5d
e

Who changed what in which revision?

UserRevisionLine numberNew contents of line
helenh 1:09e2d1034894 1 #ifndef _Serial_Transport_H
helenh 1:09e2d1034894 2 #define _Serial_Transport_H
helenh 1:09e2d1034894 3
helenh 0:7f16c88e4047 4 #include "mbed.h"
helenh 4:82765e1fd9db 5 //#include "Serial.h"
helenh 5:9f066f9abe5d 6 //#include "Thread.h"
helenh 3:57962324a4a0 7
helenh 2:a668eb71516b 8 //#define RECV_BUFFER_SIZE 100
helenh 2:a668eb71516b 9 #define INFOR_BUFFER_SIZE 20
helenh 0:7f16c88e4047 10
helenh 2:a668eb71516b 11 /*
helenh 0:7f16c88e4047 12 typedef struct {
helenh 0:7f16c88e4047 13 unsigned char Recv_Buffer[RECV_BUFFER_SIZE]; //接收缓存,用于存储接受的数据
helenh 0:7f16c88e4047 14 unsigned char Write_Index; //写入位置(缓存区可写入数据的数组位置索性)
helenh 1:09e2d1034894 15 unsigned char Read_Index; //读取位置 (缓存区可以待读取数据的数组索引)
helenh 0:7f16c88e4047 16
helenh 0:7f16c88e4047 17 } Circle_Struct;
helenh 2:a668eb71516b 18 */
helenh 2:a668eb71516b 19
helenh 2:a668eb71516b 20
helenh 2:a668eb71516b 21 typedef struct{
helenh 2:a668eb71516b 22 unsigned char recv_buff[INFOR_BUFFER_SIZE];
helenh 2:a668eb71516b 23 unsigned char count;
helenh 2:a668eb71516b 24 unsigned int value;
helenh 2:a668eb71516b 25 unsigned char state;
helenh 2:a668eb71516b 26 } Infor_Struct;
helenh 0:7f16c88e4047 27
helenh 5:9f066f9abe5d 28 //
helenh 1:09e2d1034894 29 class Serial_class{
helenh 1:09e2d1034894 30
helenh 1:09e2d1034894 31 public:
helenh 5:9f066f9abe5d 32 Serial_class(PinName ptx, PinName prx,int baud);
helenh 2:a668eb71516b 33 ~Serial_class();
helenh 2:a668eb71516b 34
helenh 2:a668eb71516b 35 unsigned char HasRecv(void);
helenh 2:a668eb71516b 36 unsigned int ReadInfor();
helenh 5:9f066f9abe5d 37 //void Setcallback();
helenh 5:9f066f9abe5d 38 //void WriteInfor(char * pw,unsigned char length);
helenh 5:9f066f9abe5d 39
helenh 2:a668eb71516b 40
helenh 1:09e2d1034894 41 private:
helenh 2:a668eb71516b 42 //Circle_Struct * pcircle_Struct;
helenh 2:a668eb71516b 43 //Circle_Struct circle_Struct;
helenh 2:a668eb71516b 44 //unsigned char DealRecv( unsigned char * pinfor);
helenh 2:a668eb71516b 45 void Add_Char(char recv);
helenh 2:a668eb71516b 46 void Write_To(unsigned char infor);
helenh 2:a668eb71516b 47 //unsigned char Read_From(unsigned char *p);
helenh 2:a668eb71516b 48 //void Init_Circle_Struct(Circle_Struct * pcs);
helenh 2:a668eb71516b 49 void Do_Recv();
helenh 5:9f066f9abe5d 50 void Do_Recv_T();
helenh 5:9f066f9abe5d 51 void Do_Recv_E(UnbufferedSerial * pserial);
helenh 2:a668eb71516b 52 void Init_Infor_struct(void);
helenh 4:82765e1fd9db 53 void printtouart(char * pb,unsigned char length);
helenh 2:a668eb71516b 54 Infor_Struct infor_struct;
helenh 2:a668eb71516b 55 //Infor_Struct * pinfor_struct;
helenh 2:a668eb71516b 56 //信号量
helenh 2:a668eb71516b 57 //Mutex rw_mutex;
helenh 2:a668eb71516b 58 //char buff[RECV_BUFFER_SIZE];
helenh 5:9f066f9abe5d 59 UnbufferedSerial * s_port;
helenh 3:57962324a4a0 60 DigitalOut * pled;
helenh 3:57962324a4a0 61 Thread m_thread;
helenh 4:82765e1fd9db 62 UnbufferedSerial *pc;
helenh 4:82765e1fd9db 63 char printbuff[50];
helenh 4:82765e1fd9db 64 char recv_buff[50];
helenh 1:09e2d1034894 65
helenh 1:09e2d1034894 66 };
helenh 0:7f16c88e4047 67
helenh 5:9f066f9abe5d 68
helenh 4:82765e1fd9db 69
helenh 1:09e2d1034894 70 #endif /*end of Serial_Transport.h*/
helenh 0:7f16c88e4047 71