Sub programs of serial_transport, PID and motor contrl.
Dependents: tracking_ball_0516 tracking_ball_0516
Diff: Serial_Transport.h
- Revision:
- 1:09e2d1034894
- Parent:
- 0:7f16c88e4047
- Child:
- 2:a668eb71516b
--- a/Serial_Transport.h Sun May 16 12:22:23 2021 +0000 +++ b/Serial_Transport.h Mon May 17 05:22:35 2021 +0000 @@ -1,32 +1,41 @@ -#ifndef Serial_Transport_H_ -#define Serial_Transport_H_ +#ifndef _Serial_Transport_H +#define _Serial_Transport_H + #include "mbed.h" - #define RECV_BUFFER_SIZE 100 -Serial openmv_port(D5, D4); -Serial pc(SERIAL_TX, SERIAL_RX); +//Serial openmv_port(D5, D4); +//Serial pc(SERIAL_TX, SERIAL_RX); -void Serial_Porting_Init(); -void openmv_init(void); typedef struct { unsigned char Recv_Buffer[RECV_BUFFER_SIZE]; //接收缓存,用于存储接受的数据 unsigned char Write_Index; //写入位置(缓存区可写入数据的数组位置索性) - unsigned char Read_Index; //读取位置 (缓存区可以待读取数据的数组索引) + unsigned char Read_Index; //读取位置 (缓存区可以待读取数据的数组索引) } Circle_Struct; -Circle_Struct circle_Struct; -unsigned char state=0; -unsigned char count; +class Serial_class{ + +public: + Serial_class(PinName tx, PinName rx,PinName tx1, PinName rx1); + void Serial_Porting_Init(PinName tx, PinName rx); + void openmv_init(PinName tx, PinName rx); + void Init_Circle_Struct(Circle_Struct * pcs); + unsigned char IsEmputy(void); + void Write_To(unsigned char infor); + unsigned char Read_From(unsigned char *p); + void Do_Recv(); + unsigned char DealRecv( unsigned char * pinfor); + void InterruptAttach(void (* fp)(void)); + private: + Circle_Struct * pcircle_Struct; + unsigned char state; + unsigned char count; + Serial * openmv_port; + Serial * pc; + +}; -void Init_Circle_Struct(Circle_Struct * pcs); -unsigned char IsEmputy(void); -void Write_To(unsigned char infor); -unsigned char Read_From(unsigned char *p); -void Do_Recv(void); -unsigned char DealRecv( unsigned char * pinfor); +#endif /*end of Serial_Transport.h*/ -#endif -