First Revision of sample code for interfacing ROHM Multi-Sensor Shield board with MultiTech's DragonFly Host Board

Dependencies:   mbed

Fork of ROHM-DragonFly-MultiSensorShield_Interface by Francis Lee

Code Example for ROHM Mutli-Sensor Shield interfaced onto the MultiTech DragonFly Host Cell Board

This code was written to be used with the MultiTech DragonFly Evaluation Kit.

This is the basic example code for interfacing ROHM's Multi-sensor Shield Board onto this board.

Additional information about the ROHM MultiSensor Shield Board can be found at the following link: https://github.com/ROHMUSDC/ROHM_SensorPlatform_Multi-Sensor-Shield

Operation

Ultimately, this code will initialize all the sensors on the Multi-sensor shield board and then poll the sensors. The sensor data will then be returned through the on-board USB to UART interface and can be viewable on any PC with a standard COM port reader (Terminal, TeraTerm, HyperTerm, etc...)

Supported ROHM Sensor Devices

  • BDE0600G Temperature Sensor
  • BM1383GLV Pressure Sensor
  • BU52014 Hall Sensor
  • ML8511 UV Sensor
  • RPR-0521 ALS/PROX Sensor
  • BH1745NUC Color Sensor
  • KMX62 Accel/Mag Sensor
  • KX122 Accel Sensor
  • KXG03 Gyro/Accel Sensor

Sensor Applicable Code Sections

  • All functionality can be found in the function main()
  • Ultimately code is split up into an "initalization" and "main loop" section
  • Specific sensor information can be found using the #ifdef statements at the beginning of the code

Questions/Feedback

Please feel free to let us know any questions/feedback/comments/concerns you may have by addressing the following e-mail:

main.cpp

Committer:
BlueShadow
Date:
2015-05-28
Revision:
0:698b236430f4
Child:
1:8d2af54ac542

File content as of revision 0:698b236430f4:

#include "mbed.h"


/* Simple Hello World program that outputs "Hello World!" every 
    five seconds to the serial debug port, and blinks at the user
    defined hertz
*/

// LED blink rate: higher -> faster blinking
#define LED_BLINK_RATE 8  //Hertz

//Define the LED pin output
DigitalOut data00(PA_3);    //Blinds D0 LED
DigitalOut data01(PA_2);    //Blinds D1 LED
DigitalOut data02(PB_15);   //Blinds D2 LED
DigitalOut data03(PA_0);    //Blinds D3 LED
DigitalOut data04(PA_7);    //Blinds D4 LED
DigitalOut data05(PA_9);    //Blinds D5 LED
DigitalOut data06(PA_1);    //Blinds D6 LED
DigitalOut data07(PA_8);    //Blinds D7 LED
DigitalOut data08(PB_1);    //Blinds D8 LED
int temp;

//Define timers
Timer print_timer;
Timer led_timer;

int main() {
    data00 = 1;                            //Initialize LED off
    data01 = 1;                            //Initialize LED off
    data02 = 1;                            //Initialize LED off
    data03 = 1;                            //Initialize LED off
    data04 = 1;                            //Initialize LED off
    data05 = 1;                            //Initialize LED off
    data06 = 1;                            //Initialize LED off
    data07 = 1;                            //Initialize LED off
    data08 = 0;                            //Initialize LED off
    print_timer.start();                //Start timers, will count until stopped
    led_timer.start();
    
    while (1) {
        if (print_timer.read() >= 5) {  //print_timer.read() returns time in seconds
            printf("Hello World!\n");
            print_timer.reset();        //Resets timer count to 0
        }
        
        //Calculates interval needed for specified frequency
        if ( led_timer.read_ms() >= (2000.0/(2*LED_BLINK_RATE))) {     
            temp   =  data02;                 //Invert LED output
            data02 =  data01;                 //Invert LED output
            data01 =  data00;                 //Invert LED output
            data00 =  data03;                 //Invert LED output
            data03 =  data06;                 //Invert LED output
            data06 =  data08;                 //Invert LED output
            data08 =  data05;                 //Invert LED output
            data05 =  data04;                 //Invert LED output
            data04 =  data07;                 //Invert LED output
            data07 =  temp;                 //Invert LED output
            led_timer.reset();          //Resets timer count to 0
        }
    }
}