Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: HEPTA_assembly template HEPTA_GS
Diff: HeptaSerial.h
- Revision:
- 2:686c7043f5f4
- Parent:
- 1:d16a4c3a272a
- Child:
- 3:12659e671bad
diff -r d16a4c3a272a -r 686c7043f5f4 HeptaSerial.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/HeptaSerial.h Wed Jul 19 09:20:37 2017 +0000
@@ -0,0 +1,140 @@
+/**
+ * C1098-SS device driver class (Version 1.0)
+ * Reference documents: C1098-SS User Manual v1.0 2012.5.6
+ *
+ * CameraC328Library
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ *
+ * CameraC1098-SS Library
+ * Copyright (C) 2012 Tadao Iida
+ */
+
+#include "mbed.h"
+#include "SerialBuffered.h"
+
+#ifndef HEPTA_SERIAL_H
+#define HEPTA_SERIAL_H
+
+/*
+ * Class: HeptaSerial
+ */
+
+class HeptaSerial {
+public:
+
+ /**
+ * @enum JPEG resolution.
+ */
+ enum JpegResolution {
+ JpegResolution80x64 = 0x01, // unofficial
+ JpegResolution160x128 = 0x03, // unofficial
+ JpegResolution320x240 = 0x05, // QVGA
+ JpegResolution640x480 = 0x07 // VGA
+ };
+
+ /**
+ * @enum Error number.
+ */
+ enum ErrorNumber {
+ NoError = 0x00,
+ UnexpectedReply = 0x04,
+ ParameterError = 0x0b,
+ SendRegisterTimeout = 0x0c,
+ CommandIdError = 0x0d,
+ CommandHeaderError = 0xf0,
+ SetTransferPackageSizeWrong = 0x11
+ };
+
+ /**
+ * @enum Baud rate.
+ */
+ enum Baud {
+ Baud460800 = 0x02,
+ Baud230400 = 0x03,
+ Baud115200 = 0x04,
+ Baud57600 = 0x05,
+ Baud28800 = 0x06,
+ Baud14400 = 0x07 // Default.
+ };
+
+ /**
+ * @enum Reset type.
+ */
+ enum ResetType {
+ Nomal = 0x00,
+ High = 0xff
+ };
+
+ /** Constructor.
+ *
+ * @param tx A pin for transmit.
+ * @param rx A pin for receive.
+ * @param baud Baud rate. (Default is 14400.)
+ */
+ HeptaSerial(PinName tx, PinName rx, int baud = 14400);
+
+ /** Destructor.
+ *
+ */
+ ~HeptaSerial();
+
+ /** sync
+ * Make a sync. for baud rate.
+ */
+ ErrorNumber sync();
+
+ /** Initialize.
+ *
+ *
+ * @param baud Camera Interface Speed.
+ * @param jr JPEG resolution.
+ */
+ ErrorNumber init(Baud baud, JpegResolution jr);
+
+ /** getJpegSnapshotPicture
+ * Get JPEG snapshot picture.
+ *
+ * @param func A pointer to a callback function.
+ * You can block this function until saving the image datas.
+ * @return Status of the error.
+ */
+ ErrorNumber getJpegSnapshotPicture();
+ ErrorNumber getJpegSnapshotPicture_data();
+
+ /** setmbedBaud
+ * mbed Interface Speed.
+ *
+ * @param baud mbed Interface Speed.
+ */
+ void setmbedBaud(Baud baud);
+ void Sync(void);
+ void initialize(Baud baud,JpegResolution jr);
+ void test_jpeg_snapshot_picture(void);
+ void test_jpeg_snapshot_data(void);
+ void jpeg_callback(char *buf, size_t siz);
+private:
+ SerialBuffered serial;
+ static const int COMMAND_LENGTH = 6;
+ static const int SYNCMAX = 60;
+ static const int packageSize = 256;
+ static const int CAPTURE_FRAMES = 3;
+
+ ErrorNumber sendInitial(Baud band, JpegResolution jr);
+ ErrorNumber sendGetPicture(void);
+ ErrorNumber sendSnapshot(void);
+ ErrorNumber sendSetPackageSize(uint16_t packageSize);
+ ErrorNumber sendReset(ResetType specialReset);
+ ErrorNumber recvData(uint32_t *length);
+ ErrorNumber sendSync();
+ ErrorNumber recvSync();
+ ErrorNumber sendAck(uint8_t commandId, uint16_t packageId);
+ ErrorNumber recvAckOrNck();
+
+ bool sendBytes(char *buf, size_t len, int timeout_us = 20000);
+ bool recvBytes(char *buf, size_t len, int timeout_us = 20000);
+ bool waitRecv();
+ bool waitIdle();
+};
+
+#endif