Hepta_Cam&GPS
Dependents: HEPTA2_assembly_0720 HEPTA2_ALL HEPTA2_ALL_ver0803_02
Fork of HeptaSerial by
HeptaSerial.h@4:57c7f33a3621, 2017-07-24 (annotated)
- Committer:
- hepta2ume
- Date:
- Mon Jul 24 05:51:24 2017 +0000
- Revision:
- 4:57c7f33a3621
- Parent:
- 3:12659e671bad
- Child:
- 6:c11f48bbb567
Hepta_assembly
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sunifu | 0:5a6468b4164d | 1 | #include "mbed.h" |
sunifu | 0:5a6468b4164d | 2 | #include "SerialBuffered.h" |
sunifu | 0:5a6468b4164d | 3 | |
hepta2ume | 2:686c7043f5f4 | 4 | #ifndef HEPTA_SERIAL_H |
hepta2ume | 2:686c7043f5f4 | 5 | #define HEPTA_SERIAL_H |
sunifu | 0:5a6468b4164d | 6 | |
hepta2ume | 4:57c7f33a3621 | 7 | class HeptaSerial |
hepta2ume | 4:57c7f33a3621 | 8 | { |
sunifu | 0:5a6468b4164d | 9 | public: |
sunifu | 0:5a6468b4164d | 10 | |
sunifu | 0:5a6468b4164d | 11 | enum JpegResolution { |
hepta2ume | 4:57c7f33a3621 | 12 | JpegResolution80x64 = 0x01, // unofficial |
hepta2ume | 4:57c7f33a3621 | 13 | JpegResolution160x128 = 0x03, // unofficial |
hepta2ume | 4:57c7f33a3621 | 14 | JpegResolution320x240 = 0x05, // QVGA |
hepta2ume | 4:57c7f33a3621 | 15 | JpegResolution640x480 = 0x07 // VGA |
sunifu | 0:5a6468b4164d | 16 | }; |
sunifu | 0:5a6468b4164d | 17 | |
sunifu | 0:5a6468b4164d | 18 | enum ErrorNumber { |
sunifu | 0:5a6468b4164d | 19 | NoError = 0x00, |
sunifu | 0:5a6468b4164d | 20 | UnexpectedReply = 0x04, |
sunifu | 0:5a6468b4164d | 21 | ParameterError = 0x0b, |
sunifu | 0:5a6468b4164d | 22 | SendRegisterTimeout = 0x0c, |
sunifu | 0:5a6468b4164d | 23 | CommandIdError = 0x0d, |
sunifu | 0:5a6468b4164d | 24 | CommandHeaderError = 0xf0, |
sunifu | 0:5a6468b4164d | 25 | SetTransferPackageSizeWrong = 0x11 |
sunifu | 0:5a6468b4164d | 26 | }; |
sunifu | 0:5a6468b4164d | 27 | |
sunifu | 0:5a6468b4164d | 28 | enum Baud { |
sunifu | 0:5a6468b4164d | 29 | Baud460800 = 0x02, |
sunifu | 0:5a6468b4164d | 30 | Baud230400 = 0x03, |
sunifu | 0:5a6468b4164d | 31 | Baud115200 = 0x04, |
sunifu | 0:5a6468b4164d | 32 | Baud57600 = 0x05, |
sunifu | 0:5a6468b4164d | 33 | Baud28800 = 0x06, |
hepta2ume | 4:57c7f33a3621 | 34 | Baud14400 = 0x07 // Default. |
sunifu | 0:5a6468b4164d | 35 | }; |
sunifu | 0:5a6468b4164d | 36 | |
sunifu | 0:5a6468b4164d | 37 | enum ResetType { |
sunifu | 0:5a6468b4164d | 38 | Nomal = 0x00, |
sunifu | 0:5a6468b4164d | 39 | High = 0xff |
sunifu | 0:5a6468b4164d | 40 | }; |
sunifu | 0:5a6468b4164d | 41 | |
hepta2ume | 4:57c7f33a3621 | 42 | HeptaSerial(PinName tx, PinName rx); |
sunifu | 0:5a6468b4164d | 43 | |
hepta2ume | 2:686c7043f5f4 | 44 | ~HeptaSerial(); |
sunifu | 0:5a6468b4164d | 45 | |
sunifu | 0:5a6468b4164d | 46 | ErrorNumber sync(); |
sunifu | 0:5a6468b4164d | 47 | ErrorNumber init(Baud baud, JpegResolution jr); |
hepta2ume | 1:d16a4c3a272a | 48 | ErrorNumber getJpegSnapshotPicture(); |
hepta2ume | 1:d16a4c3a272a | 49 | ErrorNumber getJpegSnapshotPicture_data(); |
sunifu | 0:5a6468b4164d | 50 | void setmbedBaud(Baud baud); |
hepta2ume | 1:d16a4c3a272a | 51 | void Sync(void); |
hepta2ume | 1:d16a4c3a272a | 52 | void initialize(Baud baud,JpegResolution jr); |
hepta2ume | 3:12659e671bad | 53 | void test_jpeg_snapshot_picture(int CAPTURE_FRAMES); |
hepta2ume | 3:12659e671bad | 54 | void test_jpeg_snapshot_data(int CAPTURE_FRAMES); |
hepta2ume | 1:d16a4c3a272a | 55 | void jpeg_callback(char *buf, size_t siz); |
hepta2ume | 4:57c7f33a3621 | 56 | char getc(); |
hepta2ume | 4:57c7f33a3621 | 57 | int readable(); |
hepta2ume | 4:57c7f33a3621 | 58 | void flushSerialBuffer(void); |
hepta2ume | 4:57c7f33a3621 | 59 | void gga_sensing(float *time, float *latitude, char *ns, float *longitude, char *ew, int *quality, int *stnum, float *hacu, float *altitude, char *aunit, int *gps_check); |
hepta2ume | 4:57c7f33a3621 | 60 | void lat_log_sensing_u16(char *lat, char *log, int *dsize); |
hepta2ume | 4:57c7f33a3621 | 61 | |
sunifu | 0:5a6468b4164d | 62 | private: |
sunifu | 0:5a6468b4164d | 63 | SerialBuffered serial; |
sunifu | 0:5a6468b4164d | 64 | static const int COMMAND_LENGTH = 6; |
sunifu | 0:5a6468b4164d | 65 | static const int SYNCMAX = 60; |
sunifu | 0:5a6468b4164d | 66 | static const int packageSize = 256; |
hepta2ume | 3:12659e671bad | 67 | //static const int CAPTURE_FRAMES = 3; |
hepta2ume | 4:57c7f33a3621 | 68 | |
hepta2ume | 4:57c7f33a3621 | 69 | char msg[256],msgd[256]; |
hepta2ume | 4:57c7f33a3621 | 70 | int i,ite,rlock,stn; |
hepta2ume | 4:57c7f33a3621 | 71 | char c; |
hepta2ume | 4:57c7f33a3621 | 72 | char gps_data[7][1000]; |
hepta2ume | 4:57c7f33a3621 | 73 | char ns,ew,statas; |
hepta2ume | 4:57c7f33a3621 | 74 | float time,hokui,tokei,vel; |
hepta2ume | 4:57c7f33a3621 | 75 | float g_hokui,g_tokei; |
hepta2ume | 4:57c7f33a3621 | 76 | float d_hokui,m_hokui,d_tokei,m_tokei; |
hepta2ume | 4:57c7f33a3621 | 77 | int h_time,m_time,s_time; |
hepta2ume | 4:57c7f33a3621 | 78 | |
sunifu | 0:5a6468b4164d | 79 | ErrorNumber sendInitial(Baud band, JpegResolution jr); |
sunifu | 0:5a6468b4164d | 80 | ErrorNumber sendGetPicture(void); |
hepta2ume | 4:57c7f33a3621 | 81 | ErrorNumber sendSnapshot(void); |
sunifu | 0:5a6468b4164d | 82 | ErrorNumber sendSetPackageSize(uint16_t packageSize); |
hepta2ume | 4:57c7f33a3621 | 83 | ErrorNumber sendReset(ResetType specialReset); |
sunifu | 0:5a6468b4164d | 84 | ErrorNumber recvData(uint32_t *length); |
sunifu | 0:5a6468b4164d | 85 | ErrorNumber sendSync(); |
sunifu | 0:5a6468b4164d | 86 | ErrorNumber recvSync(); |
sunifu | 0:5a6468b4164d | 87 | ErrorNumber sendAck(uint8_t commandId, uint16_t packageId); |
sunifu | 0:5a6468b4164d | 88 | ErrorNumber recvAckOrNck(); |
sunifu | 0:5a6468b4164d | 89 | |
sunifu | 0:5a6468b4164d | 90 | bool sendBytes(char *buf, size_t len, int timeout_us = 20000); |
sunifu | 0:5a6468b4164d | 91 | bool recvBytes(char *buf, size_t len, int timeout_us = 20000); |
sunifu | 0:5a6468b4164d | 92 | bool waitRecv(); |
sunifu | 0:5a6468b4164d | 93 | bool waitIdle(); |
sunifu | 0:5a6468b4164d | 94 | }; |
sunifu | 0:5a6468b4164d | 95 | #endif |