Web Camera for mbed-os. This sample works on GR-LYCHEE besides GR-PEACH. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Dependencies:   HttpServer_snapshot_mbed-os

License

When you use this program, we judge you have agreed to the following contents.
本プログラムを使用する際は、以下の内容に合意した事になります。

https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Information

Japanese version is available in lower part of this page.
このページの後半に日本語版が用意されています.

Video Links on how to setup and run WebCamera Application:

Your video will be live at:

Overview

This is a sample program that works on GR-PEACH or GR-LYCHEE.
This is a web camera sample program. When accessing from the Web browser, the following will be displayed.

  • Camera input picture
  • Control screen of devices connected to the I2C bus
  • LED control screen

Requirements

For GR-PEACH (via Wi-Fi):

  • GR-PEACH
  • GR-PEACH Wireless CAMERA Shield : OV7725

For GR-PEACH (via Ether):

  • GR-PEACH
  • One of the following
    • GR-PEACH Wireless CAMERA Shield : OV7725
    • NTSC analog camera
    • MT9V111 and GR-PEACH AUDIO CAMERA Shield
    • OV5642 and GR-PEACH AUDIO CAMERA Shield

For GR-LYCHEE (via Wi-Fi):

  • GR-LYCHEE

How to use

Turn on the power to the GR-Board and start the terminal software.
The default value of the bow rate with mbed is 9600, and in this sample we use the baud rate 9600.

When you press the reset button of GR-Board, the scan result of Wifi will be output on Terminal. Please refer to the following link for usage of Terminal.

********* PROGRAM START ***********
Network Setting up...
Scan:
No.0 Network: SSID_1 secured:WPA/WPA2 BSSID: xx:xx:xx:xx:xx:xx RSSI: -52 Ch: 1
No.1 Network: SSID_2 secured: Unknown BSSID: xx:xx:xx:xx:xx:xx RSSI: -67 Ch: 2
2 networks available.

Please enter the number of the network you want to connect.
Enter key:[0]-[1], (If inputting the other key, it's scanned again.)

Enter the number of the network you want to connect from the keyboard. To select SSID_1, press "0" on the keyboard.

[SSID_1] is selected.
please enter the PSK.

Finally, enter the password to connect to the network.

If the connection is successful, the IP address is output on Terminal.

connecting...
MAC Address is xx:xx:xx:xx:xx:xx
IP Address is 192.168.0.2
NetMask is 255.255.255.240
Gateway Address is 192.168.0.1
Network Setup OK

When you open IP Address ("192.168.0.2" in the above example) by a Web browser, top screen is indicated. The configuration of the top screen is a menu screen on the left side, a description screen of the sample program on the right side. If you click on each menu on the left side of the screen, the screen along the menu is indicated on the right screen.

Page Top

/media/uploads/1050186/web_top2.jpg

Web Camera

/media/uploads/1050186/camera3.jpg
When you click the "Web camera" in the menu screen, the pictures of a camera is indicated. It can be changed at a slider bar in "Wait time" at the timing of a renewal of a camera picture. (Defaults are 500ms.)

Setting by I2C

/media/uploads/1050186/setting_i2c3.jpg
When you click the "Setting by I2C" of the menu screen, the control screen of the device connected to the I2C bus is indicated. By sending a command of a format listed below("Format of the device set by I2C") in Direct input or File reference, data transmission and reception is possible with respect to devices connected to I2C_SDA and I2C_SCL terminals of I2C. The communication log of transmission and reception by "Format of the device set by I2C" is displayed in the log window. When you press the "Clear" button, the log is cleared. When you press the "Save" button, the log is saved.

Format of the device set by I2C

Method:I2C addr,data length,data1,data2,data3,...

The details of each parameter is shown below.
For specific settings, check on the specifications of the connected device, you must create a command along the format.

MethodPlease specify one of the following:
"Wr" ・・・ Write functions in I2C
"Rd" ・・・ Read functions in I2C
"WrNoP" ・・・ Write functions in I2C(No STOP condition)
"RdNoP" ・・・ Read functions in I2C(No STOP condition)
I2C addrSet the I2C address of device in hexadecimal.
Ex: If the address is 0x90, set the "90"
data lengthIf Method is "Wr" or "WrNoP", set write size(the size of the data portion) in hexadecimal.
Ex: If the write size is 2 byte(data1, data2), set the "02".
If Method is "Rd" or "RdNoP", set read size in hexadecimal.
Ex: If the read size is 10 byte, set the "0A".
dataIf Method is "Wr" or "WrNoP", set write data in 1 byte unit in hexadecimal.
Ex: If the write data is 0x01 0x02, set "01" in the data1 and "02" in the data2.
If Method is "Rd" or "RdNoP", this parameter is omitted.

An example of the format is shown below.

Wr:90,03,25,45,14

To the device of the I2C address 0x90, the data write of 3Byte(0x25 0x45 0x14)

Rd:90,02

To the device of the I2C address 0x90, the data read of 2Byte

LED On/Off

/media/uploads/1050186/led2.jpg
When you click the "LED On/Off" of the menu screen, the LED control screen is indicated. Each switch switches of GR-Boards to ON or OFF. Each switch indicates the current LED state. When the LED is On, the color of switch will change the LED color.

Switch to web page in SD card

Web pages displayed on the Web browser are located in the built-in ROM. file_table_peach.h is saved as table information for GR-PEACH and file_table_lychee.h is saved as table information for GR-LYCHEE. The contents of the saved file are as follows.

When connecting the SD card, SDBlockDevice will be displayed on the terminal and the web page displayed in the web browser will switch from the built-in ROM to the SD card. The top page is index.htm.

Change network connection

You can change the network connection by changing the following macro in main.cpp.

/**** User Selection *********/
#define NETWORK_TYPE           (2)                 /* Select  0(Ethernet), 1(BP3595), 2(ESP32 STA) ,3(ESP32 AP) */
#if (NETWORK_TYPE >= 1)
  #define SCAN_NETWORK         (1)                 /* Select  0(Use WLAN_SSID, WLAN_PSK, WLAN_SECURITY) or 1(To select a network using the terminal.) */
  #define WLAN_SSID            ("SSIDofYourAP")    /* SSID */
  #define WLAN_PSK             ("PSKofYourAP")     /* PSK(Pre-Shared Key) */
  #define WLAN_SECURITY        NSAPI_SECURITY_WPA_WPA2 /* NSAPI_SECURITY_NONE, NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2 or NSAPI_SECURITY_WPA_WPA2 */
#endif

Depending on the value set for NETWORK_TYPE, the connection method changes as follows.

NumberConnectionDescription
0EthernetGR-PEACH only
1reservedIt can not be selected.
2ESP32 STAUse ESP32 in STA mode.
3ESP32 APUse ESP32 in AP mode.

When using GR-LYCHEE, NETWORK_TYPE 2 and 3 can be selected.
GR-PEACH Wireless CAMERA Shield is required separately when using ESP32 with GR-PEACH.

When using Ethernet, the user must provide the MAC address.
To specify MAC address, add fllowing function to main.cpp.

Specify MAC address

// set mac address
void mbed_mac_address(char *mac) {
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xF7;
    mac[3] = 0xF0;
    mac[4] = 0x00;
    mac[5] = 0x00;
}

Camera selection

To select the Camera, add camera-type to mbed_app.json.
See here for details.

mbed_app.json

{
    "config": {
        "camera":{
            "help": "0:disable 1:enable",
            "value": "1"
        },
        "camera-type":{
            "help": "Please see EasyAttach_CameraAndLCD/README.md",
            "value": null
        },
        "lcd":{
            "help": "0:disable 1:enable",
            "value": "0"
        },
        "lcd-type":{
            "help": "Please see EasyAttach_CameraAndLCD/README.md",
            "value": null
        }
    },
    "target_overrides": {
        "RZ_A1H": {
            "camera-type" : "CAMERA_WIRELESS_CAMERA"
        }
    }
}

Appendix


概要

GR-PEACH、および、GR-LYCHEEで動作するサンプルプログラムです。
Webカメラのサンプルです。Webブラウザからアクセスすると以下が表示されます。

  • Camera入力画像
  • I2Cバスに繋がっているデバイスの制御画面
  • LED操作画面

構成

GR-PEACH (Wi-Fi経由)の場合:

  • GR-PEACH
  • GR-PEACH Wireless CAMERA Shield : OV7725

GR-PEACH (Ether経由)の場合:

  • GR-PEACH
  • 以下のいずれか
    • GR-PEACH Wireless CAMERA Shield : OV7725
    • NTSCアナログカメラ
    • MT9V111 and GR-PEACH AUDIO CAMERA Shield
    • OV5642 and GR-PEACH AUDIO CAMERA Shield

GR-LYCHEE(Wi-Fi経由)の場合:

  • GR-LYCHEE

使い方

GR-Boardに電源を入れ、Terminalソフトを立ち上げます。
Mbedでのボーレートのデフォルト値は9600で、このサンプルではボーレート9600を使います。

GR-Boardのリセットボタンを押すと、Terminal上にWifiのスキャン結果が出力されます。

********* PROGRAM START ***********
Network Setting up...
Scan:
No.0 Network: SSID_1 secured:WPA/WPA2 BSSID: xx:xx:xx:xx:xx:xx RSSI: -52 Ch: 1
No.1 Network: SSID_2 secured: Unknown BSSID: xx:xx:xx:xx:xx:xx RSSI: -67 Ch: 2
2 networks available.

Please enter the number of the network you want to connect.
Enter key:[0]-[1], (If inputting the other key, it's scanned again.)

接続したいネットワークの番号をキーボードから入力します。0番のSSID_1を選択する場合はキーボードの "0" を押します。

[SSID_1] is selected.
please enter the PSK.

最後にネットワークに接続するためのパスワードを入力します。

接続に成功すると、Terminal上にIPアドレスが出力されます。

connecting...
MAC Address is xx:xx:xx:xx:xx:xx
IP Address is 192.168.0.2
NetMask is 255.255.255.240
Gateway Address is 192.168.0.1
Network Setup OK

PCのWebブラウザで Terminalに表示された IP Address (上記例では 192.168.0.2)を開くと、トップ画面が表示されます。トップ画面は、左側にメニュー画面、右側にサンプルプログラムの説明画面という構成になっており、左画面の各メニューをクリックすると、メニューに沿った画面が右画面に表示されます。

Page Top 画面

/media/uploads/1050186/web_top2.jpg

Web Camera 画面

/media/uploads/1050186/camera3.jpg
メニュー画面の”Web Camera”をクリックすると、Camera画像が表示されます。
"Wait time"のスライダーバーでCamera画像の更新タイミングが変更できます。(初期値は500msです)

Setting by I2C 画面

/media/uploads/1050186/setting_i2c3.jpg

メニュー画面の"Setting by I2C"をクリックすると、I2Cバスに繋がっているデバイスの制御画面が表示されます。直接入力(Direct input)欄又はファイル参照(File reference)欄にて、下記("I2Cによるデバイス設定のフォーマット")に記載されているフォーマットのコマンドを送信する事で、I2CのI2C_SDA,I2C_SCL端子に繋がっているデバイスに対して、データの送受信が可能です。"I2Cによるデバイス設定のフォーマット"による送受信の通信ログは、ログウィンドウに表示されます。"Clear"ボタンを押すとログのクリア、"Save"ボタンを押すとログの保存ができます。

I2Cによるデバイス設定のフォーマット

Method:I2C addr,data length,data1,data2,data3,...

各パラメータの詳細を以下に示します。
具体的な設定値については、接続先のデバイスの仕様をご確認のうえ、フォーマットに沿ってコマンドを作成して下さい。

Method以下のいづれかを指定して下さい
"Wr" ・・・ I2Cでの書き込み
"Rd" ・・・ I2Cでの読み出し
"WrNoP" ・・・ I2Cでの書き込み(STOPコンディション省略)
"RdNoP" ・・・ I2Cでの読み出し(STOPコンディション省略)
I2C addr接続先デバイスのI2Cアドレスを16進数で設定して下さい。
(例) アドレスが0x90の場合、"90"を設定
data lengthMethodが"Wr"又は"WrNoP"の場合、書き込むサイズ(data部分のサイズ)を16進数で設定して下さい。
(例) 書き込むサイズが2Byte(data1,data2)の場合、"02"を設定
Methodが"Rd"又は"RdNoP"の場合は読み取るサイズを16進数で設定して下さい。
(例) 読み取りサイズが10Byteの場合、"0A"を設定
dataMethodが"Wr"又は"WrNoP"の場合、書き込むデータを16進数で1Byte単位で設定して下さい。
(例) 書き込みデータが0x01,0x02の場合、data1に"01"、data2に"02"を設定
"Rd"又は"RdNoP"の場合は省略して下さい。

フォーマットの例を以下に示します。

Wr:90,03,25,45,14

I2Cアドレス0x90のデバイスに対して0x25 0x45 0x14の計3Byteのデータ書き込み

Rd:90,02

I2Cアドレス0x90のデバイスに対して2Byteのデータ読み出し

LED On/Off 画面

/media/uploads/1050186/led2.jpg
メニュー画面の"LED On/Off"をクリックすると、LED操作画面が表示されます。各スイッチはGR-BoardのLED ON/OFFを切り替えます。スイッチはそれぞれGR-BoardのLEDの現在の状態を表しており、ONにすると対応するLEDの色になります。

SDカード内のWebページに切り替える

Webブラウザで表示されるWebページは内蔵ROMに配置されています。file_table_peach.h はGR-PEACH用、 file_table_lychee.h はGR-LYCHEE用のWebページがテーブル情報として保存されています。保存されているファイルの内容は下記の通りです。

SDカードを接続するとTerminal上に SDBlockDevice と表示され、Webブラウザで表示されるWebページが内蔵ROMからSDカードに切り替わります。トップページは index.htm となります。

ネットワークの接続方法を変更する

main.cppの下記マクロを変更することでネットワークの接続方法を変更できます。

/**** User Selection *********/
#define NETWORK_TYPE           (2)                 /* Select  0(Ethernet), 1(BP3595), 2(ESP32 STA) ,3(ESP32 AP) */
#if (NETWORK_TYPE >= 1)
  #define SCAN_NETWORK         (1)                 /* Select  0(Use WLAN_SSID, WLAN_PSK, WLAN_SECURITY) or 1(To select a network using the terminal.) */
  #define WLAN_SSID            ("SSIDofYourAP")    /* SSID */
  #define WLAN_PSK             ("PSKofYourAP")     /* PSK(Pre-Shared Key) */
  #define WLAN_SECURITY        NSAPI_SECURITY_WPA_WPA2 /* NSAPI_SECURITY_NONE, NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2 or NSAPI_SECURITY_WPA_WPA2 */
#endif

NETWORK_TYPE に設定する値により、以下の接続方法に切り替わります。

番号接続方法説明
0EthernetGR-PEACHのみ。
1reserved選択できません。
2ESP32 STAESP32をSTAモードで使用します。
3ESP32 APESP32をAPモードで使用します。

GR-LYCHEEを使用する場合はNETWORK_TYPE 2と3が選択できます。
GR-PEACHでNETWORK_TYPE 2と3を使用する場合は別途GR-PEACH Wireless/Cameraシールドが必要です。

NETWORK_TYPE 1のEthernetを使う場合はMACアドレスをユーザが用意する必要があります。
"main.cpp"の最後にの下記のように関数を追加し、用意したMACアドレスを設定してください。

Specify MAC address

// set mac address
void mbed_mac_address(char *mac) {
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xF7;
    mac[3] = 0xF0;
    mac[4] = 0x00;
    mac[5] = 0x00;
}

カメラの設定

カメラの指定を行う場合はmbed_app.jsonにcamera-typeを変更して追加してください。
詳細はこちらを参照ください。

mbed_app.json

{
    "config": {
        "camera":{
            "help": "0:disable 1:enable",
            "value": "1"
        },
        "camera-type":{
            "help": "Please see EasyAttach_CameraAndLCD/README.md",
            "value": null
        },
        "lcd":{
            "help": "0:disable 1:enable",
            "value": "0"
        },
        "lcd-type":{
            "help": "Please see EasyAttach_CameraAndLCD/README.md",
            "value": null
        }
    },
    "target_overrides": {
        "RZ_A1H": {
            "camera-type" : "CAMERA_WIRELESS_CAMERA"
        }
    }
}

付録

Committer:
dkato
Date:
Thu Oct 31 02:21:41 2019 +0000
Revision:
27:3bb251724951
Parent:
23:e7fd26563f8f
Minor changes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
1050186 23:e7fd26563f8f 1 /* mbed Microcontroller Library
1050186 23:e7fd26563f8f 2 * Copyright (c) 2006-2013 ARM Limited
1050186 23:e7fd26563f8f 3 *
1050186 23:e7fd26563f8f 4 * Licensed under the Apache License, Version 2.0 (the "License");
1050186 23:e7fd26563f8f 5 * you may not use this file except in compliance with the License.
1050186 23:e7fd26563f8f 6 * You may obtain a copy of the License at
1050186 23:e7fd26563f8f 7 *
1050186 23:e7fd26563f8f 8 * http://www.apache.org/licenses/LICENSE-2.0
1050186 23:e7fd26563f8f 9 *
1050186 23:e7fd26563f8f 10 * Unless required by applicable law or agreed to in writing, software
1050186 23:e7fd26563f8f 11 * distributed under the License is distributed on an "AS IS" BASIS,
1050186 23:e7fd26563f8f 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1050186 23:e7fd26563f8f 13 * See the License for the specific language governing permissions and
1050186 23:e7fd26563f8f 14 * limitations under the License.
1050186 23:e7fd26563f8f 15 */
1050186 23:e7fd26563f8f 16 #ifndef MBED_CLASSES_H
1050186 23:e7fd26563f8f 17 #define MBED_CLASSES_H
1050186 23:e7fd26563f8f 18
1050186 23:e7fd26563f8f 19 #include "rpc.h"
1050186 23:e7fd26563f8f 20
1050186 23:e7fd26563f8f 21 namespace mbed {
1050186 23:e7fd26563f8f 22
1050186 23:e7fd26563f8f 23 class RpcDigitalOut : public RPC {
1050186 23:e7fd26563f8f 24 public:
1050186 23:e7fd26563f8f 25 RpcDigitalOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
1050186 23:e7fd26563f8f 26
1050186 23:e7fd26563f8f 27 void write(int a0) {o.write(a0);}
1050186 23:e7fd26563f8f 28 int read(void) {return o.read();}
1050186 23:e7fd26563f8f 29
1050186 23:e7fd26563f8f 30 virtual const struct rpc_method *get_rpc_methods() {
1050186 23:e7fd26563f8f 31 static const rpc_method rpc_methods[] = {
1050186 23:e7fd26563f8f 32 {"write", rpc_method_caller<RpcDigitalOut, int, &RpcDigitalOut::write>},
1050186 23:e7fd26563f8f 33 {"read", rpc_method_caller<int, RpcDigitalOut, &RpcDigitalOut::read>},
1050186 23:e7fd26563f8f 34 RPC_METHOD_SUPER(RPC)
1050186 23:e7fd26563f8f 35 };
1050186 23:e7fd26563f8f 36 return rpc_methods;
1050186 23:e7fd26563f8f 37 }
1050186 23:e7fd26563f8f 38 static struct rpc_class *get_rpc_class() {
1050186 23:e7fd26563f8f 39 static const rpc_function funcs[] = {
1050186 23:e7fd26563f8f 40 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalOut, PinName, const char*> >},
1050186 23:e7fd26563f8f 41 RPC_METHOD_END
1050186 23:e7fd26563f8f 42 };
1050186 23:e7fd26563f8f 43 static rpc_class c = {"DigitalOut", funcs, NULL};
1050186 23:e7fd26563f8f 44 return &c;
1050186 23:e7fd26563f8f 45 }
1050186 23:e7fd26563f8f 46 private:
1050186 23:e7fd26563f8f 47 DigitalOut o;
1050186 23:e7fd26563f8f 48 };
1050186 23:e7fd26563f8f 49
1050186 23:e7fd26563f8f 50 class RpcDigitalIn : public RPC {
1050186 23:e7fd26563f8f 51 public:
1050186 23:e7fd26563f8f 52 RpcDigitalIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
1050186 23:e7fd26563f8f 53
1050186 23:e7fd26563f8f 54 int read(void) {return o.read();}
1050186 23:e7fd26563f8f 55
1050186 23:e7fd26563f8f 56 virtual const struct rpc_method *get_rpc_methods() {
1050186 23:e7fd26563f8f 57 static const rpc_method rpc_methods[] = {
1050186 23:e7fd26563f8f 58 {"read", rpc_method_caller<int, RpcDigitalIn, &RpcDigitalIn::read>},
1050186 23:e7fd26563f8f 59 RPC_METHOD_SUPER(RPC)
1050186 23:e7fd26563f8f 60 };
1050186 23:e7fd26563f8f 61 return rpc_methods;
1050186 23:e7fd26563f8f 62 }
1050186 23:e7fd26563f8f 63 static struct rpc_class *get_rpc_class() {
1050186 23:e7fd26563f8f 64 static const rpc_function funcs[] = {
1050186 23:e7fd26563f8f 65 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalIn, PinName, const char*> >},
1050186 23:e7fd26563f8f 66 RPC_METHOD_END
1050186 23:e7fd26563f8f 67 };
1050186 23:e7fd26563f8f 68 static rpc_class c = {"DigitalIn", funcs, NULL};
1050186 23:e7fd26563f8f 69 return &c;
1050186 23:e7fd26563f8f 70 }
1050186 23:e7fd26563f8f 71 private:
1050186 23:e7fd26563f8f 72 DigitalIn o;
1050186 23:e7fd26563f8f 73 };
1050186 23:e7fd26563f8f 74
1050186 23:e7fd26563f8f 75 class RpcDigitalInOut : public RPC {
1050186 23:e7fd26563f8f 76 public:
1050186 23:e7fd26563f8f 77 RpcDigitalInOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
1050186 23:e7fd26563f8f 78
1050186 23:e7fd26563f8f 79 int read(void) {return o.read();}
1050186 23:e7fd26563f8f 80 void write(int a0) {o.write(a0);}
1050186 23:e7fd26563f8f 81 void input(void) {o.input();}
1050186 23:e7fd26563f8f 82 void output(void) {o.output();}
1050186 23:e7fd26563f8f 83
1050186 23:e7fd26563f8f 84 virtual const struct rpc_method *get_rpc_methods() {
1050186 23:e7fd26563f8f 85 static const rpc_method rpc_methods[] = {
1050186 23:e7fd26563f8f 86 {"read", rpc_method_caller<int, RpcDigitalInOut, &RpcDigitalInOut::read>},
1050186 23:e7fd26563f8f 87 {"write", rpc_method_caller<RpcDigitalInOut, int, &RpcDigitalInOut::write>},
1050186 23:e7fd26563f8f 88 {"input", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::input>},
1050186 23:e7fd26563f8f 89 {"output", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::output>},
1050186 23:e7fd26563f8f 90 RPC_METHOD_SUPER(RPC)
1050186 23:e7fd26563f8f 91 };
1050186 23:e7fd26563f8f 92 return rpc_methods;
1050186 23:e7fd26563f8f 93 }
1050186 23:e7fd26563f8f 94 static struct rpc_class *get_rpc_class() {
1050186 23:e7fd26563f8f 95 static const rpc_function funcs[] = {
1050186 23:e7fd26563f8f 96 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalInOut, PinName, const char*> >},
1050186 23:e7fd26563f8f 97 RPC_METHOD_END
1050186 23:e7fd26563f8f 98 };
1050186 23:e7fd26563f8f 99 static rpc_class c = {"DigitalInOut", funcs, NULL};
1050186 23:e7fd26563f8f 100 return &c;
1050186 23:e7fd26563f8f 101 }
1050186 23:e7fd26563f8f 102 private:
1050186 23:e7fd26563f8f 103 DigitalInOut o;
1050186 23:e7fd26563f8f 104 };
1050186 23:e7fd26563f8f 105
1050186 23:e7fd26563f8f 106 #if DEVICE_ANALOGIN
1050186 23:e7fd26563f8f 107 class RpcAnalogIn : public RPC {
1050186 23:e7fd26563f8f 108 public:
1050186 23:e7fd26563f8f 109 RpcAnalogIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
1050186 23:e7fd26563f8f 110
1050186 23:e7fd26563f8f 111 float read(void) {return o.read();}
1050186 23:e7fd26563f8f 112 unsigned short read_u16(void) {return o.read_u16();}
1050186 23:e7fd26563f8f 113
1050186 23:e7fd26563f8f 114 virtual const struct rpc_method *get_rpc_methods() {
1050186 23:e7fd26563f8f 115 static const rpc_method rpc_methods[] = {
1050186 23:e7fd26563f8f 116 {"read", rpc_method_caller<float, RpcAnalogIn, &RpcAnalogIn::read>},
1050186 23:e7fd26563f8f 117 {"read_u16", rpc_method_caller<unsigned short, RpcAnalogIn, &RpcAnalogIn::read_u16>},
1050186 23:e7fd26563f8f 118 RPC_METHOD_SUPER(RPC)
1050186 23:e7fd26563f8f 119 };
1050186 23:e7fd26563f8f 120 return rpc_methods;
1050186 23:e7fd26563f8f 121 }
1050186 23:e7fd26563f8f 122 static struct rpc_class *get_rpc_class() {
1050186 23:e7fd26563f8f 123 static const rpc_function funcs[] = {
1050186 23:e7fd26563f8f 124 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogIn, PinName, const char*> >},
1050186 23:e7fd26563f8f 125 RPC_METHOD_END
1050186 23:e7fd26563f8f 126 };
1050186 23:e7fd26563f8f 127 static rpc_class c = {"AnalogIn", funcs, NULL};
1050186 23:e7fd26563f8f 128 return &c;
1050186 23:e7fd26563f8f 129 }
1050186 23:e7fd26563f8f 130 private:
1050186 23:e7fd26563f8f 131 AnalogIn o;
1050186 23:e7fd26563f8f 132 };
1050186 23:e7fd26563f8f 133 #endif
1050186 23:e7fd26563f8f 134
1050186 23:e7fd26563f8f 135 #if DEVICE_ANALOGOUT
1050186 23:e7fd26563f8f 136 class RpcAnalogOut : public RPC {
1050186 23:e7fd26563f8f 137 public:
1050186 23:e7fd26563f8f 138 RpcAnalogOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
1050186 23:e7fd26563f8f 139
1050186 23:e7fd26563f8f 140 float read(void) {return o.read();}
1050186 23:e7fd26563f8f 141 void write(float a0) {o.write(a0);}
1050186 23:e7fd26563f8f 142 void write_u16(unsigned short a0) {o.write_u16(a0);}
1050186 23:e7fd26563f8f 143
1050186 23:e7fd26563f8f 144 virtual const struct rpc_method *get_rpc_methods() {
1050186 23:e7fd26563f8f 145 static const rpc_method rpc_methods[] = {
1050186 23:e7fd26563f8f 146 {"read", rpc_method_caller<float, RpcAnalogOut, &RpcAnalogOut::read>},
1050186 23:e7fd26563f8f 147 {"write", rpc_method_caller<RpcAnalogOut, float, &RpcAnalogOut::write>},
1050186 23:e7fd26563f8f 148 {"write_u16", rpc_method_caller<RpcAnalogOut, unsigned short, &RpcAnalogOut::write_u16>},
1050186 23:e7fd26563f8f 149 RPC_METHOD_SUPER(RPC)
1050186 23:e7fd26563f8f 150 };
1050186 23:e7fd26563f8f 151 return rpc_methods;
1050186 23:e7fd26563f8f 152 }
1050186 23:e7fd26563f8f 153 static struct rpc_class *get_rpc_class() {
1050186 23:e7fd26563f8f 154 static const rpc_function funcs[] = {
1050186 23:e7fd26563f8f 155 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogOut, PinName, const char*> >},
1050186 23:e7fd26563f8f 156 RPC_METHOD_END
1050186 23:e7fd26563f8f 157 };
1050186 23:e7fd26563f8f 158 static rpc_class c = {"AnalogOut", funcs, NULL};
1050186 23:e7fd26563f8f 159 return &c;
1050186 23:e7fd26563f8f 160 }
1050186 23:e7fd26563f8f 161 private:
1050186 23:e7fd26563f8f 162 AnalogOut o;
1050186 23:e7fd26563f8f 163 };
1050186 23:e7fd26563f8f 164 #endif
1050186 23:e7fd26563f8f 165
1050186 23:e7fd26563f8f 166 #if DEVICE_PWMOUT
1050186 23:e7fd26563f8f 167 class RpcPwmOut : public RPC {
1050186 23:e7fd26563f8f 168 public:
1050186 23:e7fd26563f8f 169 RpcPwmOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
1050186 23:e7fd26563f8f 170
1050186 23:e7fd26563f8f 171 float read(void) {return o.read();}
1050186 23:e7fd26563f8f 172 void write(float a0) {o.write(a0);}
1050186 23:e7fd26563f8f 173 void period(float a0) {o.period(a0);}
1050186 23:e7fd26563f8f 174 void period_ms(int a0) {o.period_ms(a0);}
1050186 23:e7fd26563f8f 175 void pulsewidth(float a0) {o.pulsewidth(a0);}
1050186 23:e7fd26563f8f 176 void pulsewidth_ms(int a0) {o.pulsewidth_ms(a0);}
1050186 23:e7fd26563f8f 177
1050186 23:e7fd26563f8f 178 virtual const struct rpc_method *get_rpc_methods() {
1050186 23:e7fd26563f8f 179 static const rpc_method rpc_methods[] = {
1050186 23:e7fd26563f8f 180 {"read", rpc_method_caller<float, RpcPwmOut, &RpcPwmOut::read>},
1050186 23:e7fd26563f8f 181 {"write", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::write>},
1050186 23:e7fd26563f8f 182 {"period", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::period>},
1050186 23:e7fd26563f8f 183 {"period_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::period_ms>},
1050186 23:e7fd26563f8f 184 {"pulsewidth", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::pulsewidth>},
1050186 23:e7fd26563f8f 185 {"pulsewidth_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::pulsewidth_ms>},
1050186 23:e7fd26563f8f 186 RPC_METHOD_SUPER(RPC)
1050186 23:e7fd26563f8f 187 };
1050186 23:e7fd26563f8f 188 return rpc_methods;
1050186 23:e7fd26563f8f 189 }
1050186 23:e7fd26563f8f 190 static struct rpc_class *get_rpc_class() {
1050186 23:e7fd26563f8f 191 static const rpc_function funcs[] = {
1050186 23:e7fd26563f8f 192 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcPwmOut, PinName, const char*> >},
1050186 23:e7fd26563f8f 193 RPC_METHOD_END
1050186 23:e7fd26563f8f 194 };
1050186 23:e7fd26563f8f 195 static rpc_class c = {"PwmOut", funcs, NULL};
1050186 23:e7fd26563f8f 196 return &c;
1050186 23:e7fd26563f8f 197 }
1050186 23:e7fd26563f8f 198 private:
1050186 23:e7fd26563f8f 199 PwmOut o;
1050186 23:e7fd26563f8f 200 };
1050186 23:e7fd26563f8f 201 #endif
1050186 23:e7fd26563f8f 202
1050186 23:e7fd26563f8f 203 #if DEVICE_SPI
1050186 23:e7fd26563f8f 204 class RpcSPI : public RPC {
1050186 23:e7fd26563f8f 205 public:
1050186 23:e7fd26563f8f 206 RpcSPI(PinName a0, PinName a1, PinName a2, const char *name=NULL) : RPC(name), o(a0, a1, a2) {}
1050186 23:e7fd26563f8f 207
1050186 23:e7fd26563f8f 208 void format(int a0, int a1) {o.format(a0, a1);}
1050186 23:e7fd26563f8f 209 void frequency(int a0) {o.frequency(a0);}
1050186 23:e7fd26563f8f 210 int write(int a0) {return o.write(a0);}
1050186 23:e7fd26563f8f 211
1050186 23:e7fd26563f8f 212 virtual const struct rpc_method *get_rpc_methods() {
1050186 23:e7fd26563f8f 213 static const rpc_method rpc_methods[] = {
1050186 23:e7fd26563f8f 214 {"format", rpc_method_caller<RpcSPI, int, int, &RpcSPI::format>},
1050186 23:e7fd26563f8f 215 {"frequency", rpc_method_caller<RpcSPI, int, &RpcSPI::frequency>},
1050186 23:e7fd26563f8f 216 {"write", rpc_method_caller<int, RpcSPI, int, &RpcSPI::write>},
1050186 23:e7fd26563f8f 217 RPC_METHOD_SUPER(RPC)
1050186 23:e7fd26563f8f 218 };
1050186 23:e7fd26563f8f 219 return rpc_methods;
1050186 23:e7fd26563f8f 220 }
1050186 23:e7fd26563f8f 221 static struct rpc_class *get_rpc_class() {
1050186 23:e7fd26563f8f 222 static const rpc_function funcs[] = {
1050186 23:e7fd26563f8f 223 {"new", rpc_function_caller<const char*, PinName, PinName, PinName, const char*, &RPC::construct<RpcSPI, PinName, PinName, PinName, const char*> >},
1050186 23:e7fd26563f8f 224 RPC_METHOD_END
1050186 23:e7fd26563f8f 225 };
1050186 23:e7fd26563f8f 226 static rpc_class c = {"SPI", funcs, NULL};
1050186 23:e7fd26563f8f 227 return &c;
1050186 23:e7fd26563f8f 228 }
1050186 23:e7fd26563f8f 229 private:
1050186 23:e7fd26563f8f 230 SPI o;
1050186 23:e7fd26563f8f 231 };
1050186 23:e7fd26563f8f 232 #endif
1050186 23:e7fd26563f8f 233
1050186 23:e7fd26563f8f 234 #if DEVICE_SERIAL
1050186 23:e7fd26563f8f 235 class RpcSerial : public RPC {
1050186 23:e7fd26563f8f 236 public:
1050186 23:e7fd26563f8f 237 RpcSerial(PinName a0, PinName a1, const char *name=NULL) : RPC(name), o(a0, a1) {}
1050186 23:e7fd26563f8f 238
1050186 23:e7fd26563f8f 239 void baud(int a0) {o.baud(a0);}
1050186 23:e7fd26563f8f 240 int readable(void) {return o.readable();}
1050186 23:e7fd26563f8f 241 int writeable(void) {return o.writeable();}
1050186 23:e7fd26563f8f 242 int putc(int a0) {return o.putc(a0);}
1050186 23:e7fd26563f8f 243 int getc(void) {return o.getc();}
1050186 23:e7fd26563f8f 244 int puts(const char * a0) {return o.puts(a0);}
1050186 23:e7fd26563f8f 245
1050186 23:e7fd26563f8f 246 virtual const struct rpc_method *get_rpc_methods() {
1050186 23:e7fd26563f8f 247 static const rpc_method rpc_methods[] = {
1050186 23:e7fd26563f8f 248 {"baud", rpc_method_caller<RpcSerial, int, &RpcSerial::baud>},
1050186 23:e7fd26563f8f 249 {"readable", rpc_method_caller<int, RpcSerial, &RpcSerial::readable>},
1050186 23:e7fd26563f8f 250 {"writeable", rpc_method_caller<int, RpcSerial, &RpcSerial::writeable>},
1050186 23:e7fd26563f8f 251 {"putc", rpc_method_caller<int, RpcSerial, int, &RpcSerial::putc>},
1050186 23:e7fd26563f8f 252 {"getc", rpc_method_caller<int, RpcSerial, &RpcSerial::getc>},
1050186 23:e7fd26563f8f 253 {"puts", rpc_method_caller<int, RpcSerial, const char *, &RpcSerial::puts>},
1050186 23:e7fd26563f8f 254 RPC_METHOD_SUPER(RPC)
1050186 23:e7fd26563f8f 255 };
1050186 23:e7fd26563f8f 256 return rpc_methods;
1050186 23:e7fd26563f8f 257 }
1050186 23:e7fd26563f8f 258 static struct rpc_class *get_rpc_class() {
1050186 23:e7fd26563f8f 259 static const rpc_function funcs[] = {
1050186 23:e7fd26563f8f 260 {"new", rpc_function_caller<const char*, PinName, PinName, const char*, &RPC::construct<RpcSerial, PinName, PinName, const char*> >},
1050186 23:e7fd26563f8f 261 RPC_METHOD_END
1050186 23:e7fd26563f8f 262 };
1050186 23:e7fd26563f8f 263 static rpc_class c = {"Serial", funcs, NULL};
1050186 23:e7fd26563f8f 264 return &c;
1050186 23:e7fd26563f8f 265 }
1050186 23:e7fd26563f8f 266 private:
1050186 23:e7fd26563f8f 267 Serial o;
1050186 23:e7fd26563f8f 268 };
1050186 23:e7fd26563f8f 269 #endif
1050186 23:e7fd26563f8f 270
1050186 23:e7fd26563f8f 271 class RpcTimer : public RPC {
1050186 23:e7fd26563f8f 272 public:
1050186 23:e7fd26563f8f 273 RpcTimer(const char *name=NULL) : RPC(name), o() {}
1050186 23:e7fd26563f8f 274
1050186 23:e7fd26563f8f 275 void start(void) {o.start();}
1050186 23:e7fd26563f8f 276 void stop(void) {o.stop();}
1050186 23:e7fd26563f8f 277 void reset(void) {o.reset();}
1050186 23:e7fd26563f8f 278 float read(void) {return o.read();}
1050186 23:e7fd26563f8f 279 int read_ms(void) {return o.read_ms();}
1050186 23:e7fd26563f8f 280 int read_us(void) {return o.read_us();}
1050186 23:e7fd26563f8f 281
1050186 23:e7fd26563f8f 282 virtual const struct rpc_method *get_rpc_methods() {
1050186 23:e7fd26563f8f 283 static const rpc_method rpc_methods[] = {
1050186 23:e7fd26563f8f 284 {"start", rpc_method_caller<RpcTimer, &RpcTimer::start>},
1050186 23:e7fd26563f8f 285 {"stop", rpc_method_caller<RpcTimer, &RpcTimer::stop>},
1050186 23:e7fd26563f8f 286 {"reset", rpc_method_caller<RpcTimer, &RpcTimer::reset>},
1050186 23:e7fd26563f8f 287 {"read", rpc_method_caller<float, RpcTimer, &RpcTimer::read>},
1050186 23:e7fd26563f8f 288 {"read_ms", rpc_method_caller<int, RpcTimer, &RpcTimer::read_ms>},
1050186 23:e7fd26563f8f 289 {"read_us", rpc_method_caller<int, RpcTimer, &RpcTimer::read_us>},
1050186 23:e7fd26563f8f 290 RPC_METHOD_SUPER(RPC)
1050186 23:e7fd26563f8f 291 };
1050186 23:e7fd26563f8f 292 return rpc_methods;
1050186 23:e7fd26563f8f 293 }
1050186 23:e7fd26563f8f 294 static struct rpc_class *get_rpc_class() {
1050186 23:e7fd26563f8f 295 static const rpc_function funcs[] = {
1050186 23:e7fd26563f8f 296 {"new", rpc_function_caller<const char*, const char*, &RPC::construct<RpcTimer, const char*> >},
1050186 23:e7fd26563f8f 297 RPC_METHOD_END
1050186 23:e7fd26563f8f 298 };
1050186 23:e7fd26563f8f 299 static rpc_class c = {"Timer", funcs, NULL};
1050186 23:e7fd26563f8f 300 return &c;
1050186 23:e7fd26563f8f 301 }
1050186 23:e7fd26563f8f 302 private:
1050186 23:e7fd26563f8f 303 Timer o;
1050186 23:e7fd26563f8f 304 };
1050186 23:e7fd26563f8f 305
1050186 23:e7fd26563f8f 306 }
1050186 23:e7fd26563f8f 307
1050186 23:e7fd26563f8f 308 #endif
1050186 23:e7fd26563f8f 309