uint8_t型とunsigned char型に対応した多バイトシリアル通信用ライブラリ

Dependents:   multiserial_test serial_check_controller receiverA receiver_transmitter ... more

Revision:
7:f15a96ec54e1
Parent:
6:49c82ca5aa37
Child:
8:cfc53cc4914a
--- a/MultiSerial.h	Thu Aug 21 21:29:25 2014 +0000
+++ b/MultiSerial.h	Thu Aug 28 04:57:01 2014 +0000
@@ -2,17 +2,18 @@
  *mbed Multibyte Serial Library
  *This comment is available in Japanese only
  */
-
-
+ 
 
-#ifndef MBED_MULTISERIAL
-#define MBED_MULTISERIAL
+#ifndef MULTISERIAL_H
+#define MULTISERIAL_H
 
-#include"mbed.h"
+#include "mbed.h"
 
 #define __SIZE(array) (sizeof(array) / sizeof(array[0]))
 
-#define MAX_DATA_NUM 30
+
+#define MAX_DATA_NUM 10
+#define KEY 0//number of first data
 
 /** 多バイト通信用クラス 
  *
@@ -37,74 +38,57 @@
  * @endcode
  */
 
-
-class MultiSerial {
+class MultiSerial{
 
     public:
-
+    
         /** 多バイト通信用オブジェクト作成 Serialにそのままつなげるよ
          *
          * @param tx Serial tx pin
          * @param rx Serial rx pin
-         */  
+         */ 
+
         MultiSerial(PinName tx,PinName rx);
-
+        
         /**データ読み込みするよ 
          *
-         * @param value 読み込み先の配列アドレス
-         * @param size 配列の要素数
-         * @param keycode 多バイト通信のキーコード
-         */
-        void start_read(uint8_t* value,int size,uint8_t keycode);
-
-        /**データカキコするよ
-         *
-         * @param value 送るデーターの配列アドレス
-         * @param size 配列の要素数
-         * @param keycode 多バイト通信のキーコード
+         * @param readData 読み込み先の配列アドレス
+         * @param readKey 多バイト通信のキーコード
          */
 
-        void start_write(uint8_t* value,int size,uint8_t keycode);
-        /*        
-          void writeAttach(void (*func)()){
-          __serial__.attach(func,Serial::TxIrq);
-          }
+        void read(uint8_t* readData,uint8_t readKey);
+        
+        /**データカキコするよ
+         *
+         * @param writeData 送るデーターの配列アドレス
+         * @param writeKey 多バイト通信のキーコード
+         */
 
-          void readAttach(void(*func)()){     
-          __serial__.attach(func,Serial::RxIrq);
-          }
-          */          
-        /**シリアル通信 受信割り込み ルーチン 
-         * @param none
-         */           
-        void RX(void);
-        /**シリアル通信 送信バッファ空き割り込みルーチン
-         * @param none
+        void write(uint8_t* writeData,uint8_t writeKey);
+
+        /**送信割り込み用関数
+         *
+         *@param none
          */
         void TX(void);
-
-        /** データ読み込み起動するよ
+        /**受信割り込み用関数
          *
-         * @param value 読み込み先の配列アドレス
-         * @param keycode 多バイト通信のキーコード
-         */            
-        void read(uint8_t* value,uint8_t keycode);
-        /**データカキコ起動するよ 
-         *
-         * @param value 送信データの配列アドレス
-         * @param keycode 多バイト通信のキーコード
-         */            
-
-        void write(uint8_t* value,uint8_t keycode);
+         *@param none
+         */
+        void RX(void);
+        
 
     protected:
 
         Serial __serial__;
-        uint8_t *__readData;
-        uint8_t *__writeData;
-        int __readSize;
-        int __writeSize;
-        uint8_t __readKey;
-        uint8_t __writeKey;
+
+        volatile    uint8_t* __readData;
+        volatile    uint8_t __readSize;
+        volatile    uint8_t __readKey;
+
+        volatile    uint8_t* __writeData;
+        volatile    uint8_t __writeSize;
+        volatile    uint8_t __writeKey;
+
 };
-#endif
+#endif
\ No newline at end of file