RTnoV3_LED is example program which uses mbed. To know about RTno, visit: http://ysuga.net/robot_e/rtm_e/rtc_e/1065?lang=en
Dependencies: EthernetNetIf mbed RTnoV3
Revision 0:6cfb2284ea53, committed 2012-02-09
- Comitter:
- ysuga
- Date:
- Thu Feb 09 05:56:37 2012 +0000
- Commit message:
- RTnoV3_LED first revision
Changed in this revision
diff -r 000000000000 -r 6cfb2284ea53 EthernetNetIf.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetNetIf.lib Thu Feb 09 05:56:37 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/sherckuith/code/EthernetNetIf/#479ce5546098
diff -r 000000000000 -r 6cfb2284ea53 RTnoV3.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RTnoV3.lib Thu Feb 09 05:56:37 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/ysuga/code/RTnoV3/#9fac71a0bff3
diff -r 000000000000 -r 6cfb2284ea53 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 09 05:56:37 2012 +0000 @@ -0,0 +1,171 @@ +#include "mbed.h" +/** + * RTno_Template.pde + * RTno is RT-middleware and arduino. + * + * Using RTno, arduino device can communicate any RT-components + * through the RTno-proxy component which is launched in PC. + * Connect arduino with USB, and program with RTno library. + * You do not have to define any protocols to establish communication + * between arduino and PC. + * + * Using RTno, you must not define the function "setup" and "loop". + * Those functions are automatically defined in the RTno libarary. + * You, developers, must define following functions: + * int onInitialize(void); + * int onActivated(void); + * int onDeactivated(void); + * int onExecute(void); + * int onError(void); + * int onReset(void); + * These functions are spontaneously called by the RTno-proxy + * RT-component which is launched in the PC. + * @author Yuki Suga + * This code is written/distributed for public-domain. + */ + +#include <RTno.h> + +/** + * This function is called at first. + * conf._default.baudrate: baudrate of serial communication + * exec_cxt.periodic.type: reserved but not used. + */ +void rtcconf(config_str& conf, exec_cxt_str& exec_cxt) { + // If you want to use Serial Connection, configure below: + conf._default.connection_type = ConnectionTypeSerialUSB; // USBTX & USBRX (In Windows, Driver must be updated.) + conf._default.baudrate = 57600; // This value is required when you select ConnectionTypeSerial* + exec_cxt.periodic.type = ProxySynchronousExecutionContext; +} + + +/** + * Declaration Division: + * + * DataPort and Data Buffer should be placed here. + * + * available data types are as follows: + * TimedLong + * TimedDouble + * TimedFloat + * TimedLongSeq + * TimedDoubleSeq + * TimedFloatSeq + * + * Please refer following comments. If you need to use some ports, + * uncomment the line you want to declare. + **/ +TimedLong in0; +InPort<TimedLong> in0In("in0", in0); + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); +////////////////////////////////////////// +// on_initialize +// +// This function is called in the initialization +// sequence. The sequence is triggered by the +// PC. When the RTnoRTC is launched in the PC, +// then, this function is remotely called +// through the USB cable. +// In on_initialize, usually DataPorts are added. +// +////////////////////////////////////////// +int RTno::onInitialize() { + /* Data Ports are added in this section. + */ + + addInPort(in0In); + + // Some initialization (like port direction setting) + led1 = 1; + led2 = 0; + led3 = 0; + led4 = 0; + return RTC_OK; +} + +//////////////////////////////////////////// +// on_activated +// This function is called when the RTnoRTC +// is activated. When the activation, the RTnoRTC +// sends message to call this function remotely. +// If this function is failed (return value +// is RTC_ERROR), RTno will enter ERROR condition. +//////////////////////////////////////////// +int RTno::onActivated() { + // Write here initialization code. + led2 = 1; + led3 = 0; + led4 = 0; + return RTC_OK; +} + +///////////////////////////////////////////// +// on_deactivated +// This function is called when the RTnoRTC +// is deactivated. +///////////////////////////////////////////// +int RTno::onDeactivated() +{ + // Write here finalization code. + led2 = 0; + led3 = 0; + led4 = 0; + return RTC_OK; +} + +////////////////////////////////////////////// +// This function is repeatedly called when the +// RTno is in the ACTIVE condition. +// If this function is failed (return value is +// RTC_ERROR), RTno immediately enter into the +// ERROR condition.r +////////////////////////////////////////////// +int RTno::onExecute() { + static int flag; + if(flag) { + led3 = 1; + flag = 0; + } else { + led3 = 0; + flag++; + } + /** + * Usage of InPort with premitive type. + */ + if(in0In.isNew()) { + in0In.read(); + led4 = in0.data; + } + + return RTC_OK; +} + + +////////////////////////////////////// +// on_error +// This function is repeatedly called when +// the RTno is in the ERROR condition. +// The ERROR condition can be recovered, +// when the RTno is reset. +/////////////////////////////////////// +int RTno::onError() +{ + return RTC_OK; +} + +//////////////////////////////////////// +// This function is called when +// the RTno is reset. If on_reset is +// succeeded, the RTno will enter into +// the INACTIVE condition. If failed +// (return value is RTC_ERROR), RTno +// will stay in ERROR condition.ec +/////////////////////////////////////// +int RTno::onReset() +{ + return RTC_OK; +}
diff -r 000000000000 -r 6cfb2284ea53 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Feb 09 05:56:37 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/14f4805c468c