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.
Dependencies: EthernetInterface FATFileSystem GR-PEACH_video GraphicsFramework HttpServer_snapshot R_BSP mbed-rpc mbed-rtos mbed
Diff: main.cpp
- Revision:
- 11:ad8ff26679bb
- Parent:
- 10:3a176dc33f74
- Child:
- 12:6c002b871c4d
--- a/main.cpp Wed Jan 27 09:05:19 2016 +0000
+++ b/main.cpp Thu Mar 03 10:13:39 2016 +0000
@@ -9,9 +9,6 @@
#include "file_table.h" //Binary data of web pages
#include "i2c_setting.h"
-RomRamFileSystem romramfs("romram");
-EthernetInterface eth;
-
#define VIDEO_CVBS (0) /* Analog Video Signal */
#define VIDEO_CMOS_CAMERA (1) /* Digital Video Signal */
#define VIDEO_YCBCR422 (0)
@@ -19,6 +16,14 @@
#define VIDEO_RGB565 (2)
/**** User Selection *********/
+/** Network setting **/
+#define USE_DHCP (1) /* Select 0(static configuration) or 1(use DHCP) */
+#if (USE_DHCP == 0)
+ #define IP_ADDRESS ("192.168.0.2") /* IP address */
+ #define SUBNET_MASK ("255.255.255.0") /* Subnet mask */
+ #define DEFAULT_GATEWAY ("192.168.0.3") /* Default gateway */
+#endif
+/** Camera setting **/
#define VIDEO_INPUT_METHOD (VIDEO_CMOS_CAMERA) /* Select VIDEO_CVBS or VIDEO_CMOS_CAMERA */
#define VIDEO_INPUT_FORMAT (VIDEO_YCBCR422) /* Select VIDEO_YCBCR422 or VIDEO_RGB888 or VIDEO_RGB565 */
#define USE_VIDEO_CH (0) /* Select 0 or 1 If selecting VIDEO_CMOS_CAMERA, should be 0.) */
@@ -47,7 +52,8 @@
#define VIDEO_BUFFER_STRIDE (((PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u)
#define VIDEO_BUFFER_HEIGHT (PIXEL_VW)
-DigitalIn button(USER_BUTTON0);
+EthernetInterface network;
+RomRamFileSystem romramfs("romram");
static uint8_t FrameBuffer_Video[VIDEO_BUFFER_STRIDE * VIDEO_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(16))); //16 bytes aligned!;
static volatile int32_t vsync_count = 0;
@@ -353,20 +359,24 @@
RPCFunction rpcFunc(TerminalWrite, "TerminalWrite");
RPCFunction rpcSetI2C(SetI2CfromWeb, "SetI2CfromWeb");
- printf("EthernetInterface Setting up...\r\n");
- if (eth.init() != 0) { //for DHCP Server
-// if (eth.init("192.168.0.2","255.255.255.0","192.168.0.3") != 0) { //for Static IP Address (IPAddress, NetMasks, Gateway)
- printf("EthernetInterface Initialize Error \r\n");
+ printf("Network Setting up...\r\n");
+#if (USE_DHCP == 1)
+ if (network.init() != 0) { //for DHCP Server
+#else
+ if (network.init(IP_ADDRESS, SUBNET_MASK, DEFAULT_GATEWAY) != 0) { //for Static IP Address (IPAddress, NetMasks, Gateway)
+#endif
+ printf("Network Initialize Error \r\n");
return -1;
}
- if (eth.connect() != 0) {
- printf("EthernetInterface Connect Error \r\n");
+ if (network.connect() != 0) {
+ printf("Network Connect Error \r\n");
return -1;
}
- printf("IP Address is %s\r\n", eth.getIPAddress());
- printf("NetMask is %s\r\n", eth.getNetworkMask());
- printf("Gateway Address is %s\r\n", eth.getGateway());
- printf("Ethernet Setup OK\r\n");
+ printf("MAC Address is %s\r\n", network.getMACAddress());
+ printf("IP Address is %s\r\n", network.getIPAddress());
+ printf("NetMask is %s\r\n", network.getNetworkMask());
+ printf("Gateway Address is %s\r\n", network.getGateway());
+ printf("Network Setup OK\r\n");
SnapshotHandler::attach_req(&snapshot_req);
HTTPServerAddHandler<SnapshotHandler>("/camera"); //Camera