Skip to content

ExamplePrograms

Yutaka Matsubara edited this page Jul 6, 2016 · 1 revision

Example programs

blinky (blink the RGB LED)

  1. Connect your GR-PEACH to your PC by Micro USB cable.
  2. Push the RESET button.
  3. You can see the blinking RGB LED.

httpsample (example for http server)

  1. Connect your GR-PEACH to your PC by Micro USB cable.
  2. Connect your GR-PEACH and your PC by using an Ethernet cable.
  3. Push the RESET button.
  4. You can find the IP address assigned to your GR-PEACH in the serial output, check the serial output.
  5. Access the IP address (e.x. http://192.168.2.30/web_top.htm) by your web browser.

Multiple loops program for Arduino programming style.

  1. Connect your GR-PEACH to your PC by Micro USB cable.
  2. Push the RESET button.
  3. You can see the blinking RGB LED.

Notice: Multiple loops programming

  • As you know, Arduino provides simple setup-loop programming style. The setup() is called at once when the program starts. After the function, loop() is called.
  • In this example, multiple loop functions can be defined such like loop1(), loop2(), ... , and loop5() in addition to loop().
  • You should specify the number of additional loops you use by 'ADDITIONAL_LOOP_NUM' macro defined in arduino_app.h.
  • For example, '#define LOOP_NUM 2' means that you need to define loop1() and loop2() in the cpp file.
  • Note that you don't need to add CRE_TSK, which is static API to create a task, in multitask_arduino.cfg because they are defined in ./mbed-lib/arduino-lib/core/arduino_main.cfg.
  • In the default, every loop functions including loop() have the same priority (LOOP_PRI = 5).
  • If you expect that every loop functions run concurrently, use a cyclic handler and irot_rdq() service call as used in this sample.
  • For more detail specification, refer the specification of TOPPERS/ASP kernel.

Display serial output from GR-PEACH.

  1. Check the device name of the serial port by 'ls /dev/tty.usbmodem'.
  2. If the name is tty.usbmodem1412, you can see serial output by the following command.

$ screen /dev/tty.usbmodem1412 115200

  1. to exit the screen, type Ctrl A+K.