test
Dependents: HEPTA_assembly template HEPTA_GS
HeptaSerial.h@7:a41100627f55, 2017-08-05 (annotated)
- Committer:
- umeume
- Date:
- Sat Aug 05 14:20:51 2017 +0000
- Revision:
- 7:a41100627f55
- Parent:
- 6:c11f48bbb567
test;
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 | |
umeume | 7:a41100627f55 | 42 | HeptaSerial(PinName tx, PinName rx, PinName CAM, PinName GPS); |
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); |
umeume | 7:a41100627f55 | 51 | void camera_setting(void); |
hepta2ume | 1:d16a4c3a272a | 52 | void Sync(void); |
hepta2ume | 1:d16a4c3a272a | 53 | void initialize(Baud baud,JpegResolution jr); |
hepta2ume | 3:12659e671bad | 54 | void test_jpeg_snapshot_picture(int CAPTURE_FRAMES); |
hepta2ume | 3:12659e671bad | 55 | void test_jpeg_snapshot_data(int CAPTURE_FRAMES); |
hepta2ume | 1:d16a4c3a272a | 56 | void jpeg_callback(char *buf, size_t siz); |
hepta2ume | 6:c11f48bbb567 | 57 | void gps_setting(void); |
hepta2ume | 4:57c7f33a3621 | 58 | char getc(); |
hepta2ume | 4:57c7f33a3621 | 59 | int readable(); |
hepta2ume | 4:57c7f33a3621 | 60 | void flushSerialBuffer(void); |
hepta2ume | 4:57c7f33a3621 | 61 | 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 | 6:c11f48bbb567 | 62 | void lat_log_sensing_u16(char *lat, char *log, char * height, int *dsize1, int *dsize2); |
hepta2ume | 4:57c7f33a3621 | 63 | |
sunifu | 0:5a6468b4164d | 64 | private: |
sunifu | 0:5a6468b4164d | 65 | SerialBuffered serial; |
umeume | 7:a41100627f55 | 66 | DigitalOut CAM_SW; |
umeume | 7:a41100627f55 | 67 | DigitalOut GPS_SW; |
sunifu | 0:5a6468b4164d | 68 | static const int COMMAND_LENGTH = 6; |
sunifu | 0:5a6468b4164d | 69 | static const int SYNCMAX = 60; |
sunifu | 0:5a6468b4164d | 70 | static const int packageSize = 256; |
hepta2ume | 3:12659e671bad | 71 | //static const int CAPTURE_FRAMES = 3; |
hepta2ume | 4:57c7f33a3621 | 72 | |
hepta2ume | 4:57c7f33a3621 | 73 | char msg[256],msgd[256]; |
hepta2ume | 4:57c7f33a3621 | 74 | int i,ite,rlock,stn; |
hepta2ume | 4:57c7f33a3621 | 75 | char c; |
hepta2ume | 4:57c7f33a3621 | 76 | char gps_data[7][1000]; |
hepta2ume | 4:57c7f33a3621 | 77 | char ns,ew,statas; |
hepta2ume | 4:57c7f33a3621 | 78 | float time,hokui,tokei,vel; |
hepta2ume | 4:57c7f33a3621 | 79 | float g_hokui,g_tokei; |
hepta2ume | 4:57c7f33a3621 | 80 | float d_hokui,m_hokui,d_tokei,m_tokei; |
hepta2ume | 4:57c7f33a3621 | 81 | int h_time,m_time,s_time; |
hepta2ume | 6:c11f48bbb567 | 82 | float height_1; |
hepta2ume | 6:c11f48bbb567 | 83 | int m_height,cm_height; |
hepta2ume | 4:57c7f33a3621 | 84 | |
sunifu | 0:5a6468b4164d | 85 | ErrorNumber sendInitial(Baud band, JpegResolution jr); |
sunifu | 0:5a6468b4164d | 86 | ErrorNumber sendGetPicture(void); |
hepta2ume | 4:57c7f33a3621 | 87 | ErrorNumber sendSnapshot(void); |
sunifu | 0:5a6468b4164d | 88 | ErrorNumber sendSetPackageSize(uint16_t packageSize); |
hepta2ume | 4:57c7f33a3621 | 89 | ErrorNumber sendReset(ResetType specialReset); |
sunifu | 0:5a6468b4164d | 90 | ErrorNumber recvData(uint32_t *length); |
sunifu | 0:5a6468b4164d | 91 | ErrorNumber sendSync(); |
sunifu | 0:5a6468b4164d | 92 | ErrorNumber recvSync(); |
sunifu | 0:5a6468b4164d | 93 | ErrorNumber sendAck(uint8_t commandId, uint16_t packageId); |
sunifu | 0:5a6468b4164d | 94 | ErrorNumber recvAckOrNck(); |
sunifu | 0:5a6468b4164d | 95 | |
sunifu | 0:5a6468b4164d | 96 | bool sendBytes(char *buf, size_t len, int timeout_us = 20000); |
sunifu | 0:5a6468b4164d | 97 | bool recvBytes(char *buf, size_t len, int timeout_us = 20000); |
sunifu | 0:5a6468b4164d | 98 | bool waitRecv(); |
sunifu | 0:5a6468b4164d | 99 | bool waitIdle(); |
sunifu | 0:5a6468b4164d | 100 | }; |
sunifu | 0:5a6468b4164d | 101 | #endif |