Hepta_Cam&GPS

Dependents:   HEPTA2_assembly_0720 HEPTA2_ALL HEPTA2_ALL_ver0803_02

Fork of HeptaSerial by Hepta 2

Committer:
hepta2ume
Date:
Fri Jul 21 10:35:56 2017 +0000
Revision:
3:12659e671bad
Parent:
2:686c7043f5f4
Child:
4:57c7f33a3621
HeptaSerial

Who changed what in which revision?

UserRevisionLine numberNew 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 2:686c7043f5f4 7 class HeptaSerial {
sunifu 0:5a6468b4164d 8 public:
sunifu 0:5a6468b4164d 9
sunifu 0:5a6468b4164d 10 enum JpegResolution {
sunifu 0:5a6468b4164d 11 JpegResolution80x64 = 0x01, // unofficial
sunifu 0:5a6468b4164d 12 JpegResolution160x128 = 0x03, // unofficial
sunifu 0:5a6468b4164d 13 JpegResolution320x240 = 0x05, // QVGA
sunifu 0:5a6468b4164d 14 JpegResolution640x480 = 0x07 // VGA
sunifu 0:5a6468b4164d 15 };
sunifu 0:5a6468b4164d 16
sunifu 0:5a6468b4164d 17 enum ErrorNumber {
sunifu 0:5a6468b4164d 18 NoError = 0x00,
sunifu 0:5a6468b4164d 19 UnexpectedReply = 0x04,
sunifu 0:5a6468b4164d 20 ParameterError = 0x0b,
sunifu 0:5a6468b4164d 21 SendRegisterTimeout = 0x0c,
sunifu 0:5a6468b4164d 22 CommandIdError = 0x0d,
sunifu 0:5a6468b4164d 23 CommandHeaderError = 0xf0,
sunifu 0:5a6468b4164d 24 SetTransferPackageSizeWrong = 0x11
sunifu 0:5a6468b4164d 25 };
sunifu 0:5a6468b4164d 26
sunifu 0:5a6468b4164d 27 enum Baud {
sunifu 0:5a6468b4164d 28 Baud460800 = 0x02,
sunifu 0:5a6468b4164d 29 Baud230400 = 0x03,
sunifu 0:5a6468b4164d 30 Baud115200 = 0x04,
sunifu 0:5a6468b4164d 31 Baud57600 = 0x05,
sunifu 0:5a6468b4164d 32 Baud28800 = 0x06,
sunifu 0:5a6468b4164d 33 Baud14400 = 0x07 // Default.
sunifu 0:5a6468b4164d 34 };
sunifu 0:5a6468b4164d 35
sunifu 0:5a6468b4164d 36 enum ResetType {
sunifu 0:5a6468b4164d 37 Nomal = 0x00,
sunifu 0:5a6468b4164d 38 High = 0xff
sunifu 0:5a6468b4164d 39 };
sunifu 0:5a6468b4164d 40
hepta2ume 2:686c7043f5f4 41 HeptaSerial(PinName tx, PinName rx, int baud = 14400);
sunifu 0:5a6468b4164d 42
hepta2ume 2:686c7043f5f4 43 ~HeptaSerial();
sunifu 0:5a6468b4164d 44
sunifu 0:5a6468b4164d 45 ErrorNumber sync();
sunifu 0:5a6468b4164d 46 ErrorNumber init(Baud baud, JpegResolution jr);
hepta2ume 1:d16a4c3a272a 47 ErrorNumber getJpegSnapshotPicture();
hepta2ume 1:d16a4c3a272a 48 ErrorNumber getJpegSnapshotPicture_data();
sunifu 0:5a6468b4164d 49 void setmbedBaud(Baud baud);
hepta2ume 1:d16a4c3a272a 50 void Sync(void);
hepta2ume 1:d16a4c3a272a 51 void initialize(Baud baud,JpegResolution jr);
hepta2ume 3:12659e671bad 52 void test_jpeg_snapshot_picture(int CAPTURE_FRAMES);
hepta2ume 3:12659e671bad 53 void test_jpeg_snapshot_data(int CAPTURE_FRAMES);
hepta2ume 1:d16a4c3a272a 54 void jpeg_callback(char *buf, size_t siz);
hepta2ume 3:12659e671bad 55
hepta2ume 3:12659e671bad 56
hepta2ume 3:12659e671bad 57
hepta2ume 3:12659e671bad 58
sunifu 0:5a6468b4164d 59 private:
sunifu 0:5a6468b4164d 60 SerialBuffered serial;
sunifu 0:5a6468b4164d 61 static const int COMMAND_LENGTH = 6;
sunifu 0:5a6468b4164d 62 static const int SYNCMAX = 60;
sunifu 0:5a6468b4164d 63 static const int packageSize = 256;
hepta2ume 3:12659e671bad 64 //static const int CAPTURE_FRAMES = 3;
hepta2ume 1:d16a4c3a272a 65
sunifu 0:5a6468b4164d 66 ErrorNumber sendInitial(Baud band, JpegResolution jr);
sunifu 0:5a6468b4164d 67 ErrorNumber sendGetPicture(void);
sunifu 0:5a6468b4164d 68 ErrorNumber sendSnapshot(void);
sunifu 0:5a6468b4164d 69 ErrorNumber sendSetPackageSize(uint16_t packageSize);
sunifu 0:5a6468b4164d 70 ErrorNumber sendReset(ResetType specialReset);
sunifu 0:5a6468b4164d 71 ErrorNumber recvData(uint32_t *length);
sunifu 0:5a6468b4164d 72 ErrorNumber sendSync();
sunifu 0:5a6468b4164d 73 ErrorNumber recvSync();
sunifu 0:5a6468b4164d 74 ErrorNumber sendAck(uint8_t commandId, uint16_t packageId);
sunifu 0:5a6468b4164d 75 ErrorNumber recvAckOrNck();
sunifu 0:5a6468b4164d 76
sunifu 0:5a6468b4164d 77 bool sendBytes(char *buf, size_t len, int timeout_us = 20000);
sunifu 0:5a6468b4164d 78 bool recvBytes(char *buf, size_t len, int timeout_us = 20000);
sunifu 0:5a6468b4164d 79 bool waitRecv();
sunifu 0:5a6468b4164d 80 bool waitIdle();
sunifu 0:5a6468b4164d 81 };
sunifu 0:5a6468b4164d 82
sunifu 0:5a6468b4164d 83 #endif