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:

Committer:
BlueShadow
Date:
Thu May 28 22:51:24 2015 +0000
Revision:
0:698b236430f4
Child:
1:8d2af54ac542
rotating LED example;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BlueShadow 0:698b236430f4 1 #include "mbed.h"
BlueShadow 0:698b236430f4 2
BlueShadow 0:698b236430f4 3
BlueShadow 0:698b236430f4 4 /* Simple Hello World program that outputs "Hello World!" every
BlueShadow 0:698b236430f4 5 five seconds to the serial debug port, and blinks at the user
BlueShadow 0:698b236430f4 6 defined hertz
BlueShadow 0:698b236430f4 7 */
BlueShadow 0:698b236430f4 8
BlueShadow 0:698b236430f4 9 // LED blink rate: higher -> faster blinking
BlueShadow 0:698b236430f4 10 #define LED_BLINK_RATE 8 //Hertz
BlueShadow 0:698b236430f4 11
BlueShadow 0:698b236430f4 12 //Define the LED pin output
BlueShadow 0:698b236430f4 13 DigitalOut data00(PA_3); //Blinds D0 LED
BlueShadow 0:698b236430f4 14 DigitalOut data01(PA_2); //Blinds D1 LED
BlueShadow 0:698b236430f4 15 DigitalOut data02(PB_15); //Blinds D2 LED
BlueShadow 0:698b236430f4 16 DigitalOut data03(PA_0); //Blinds D3 LED
BlueShadow 0:698b236430f4 17 DigitalOut data04(PA_7); //Blinds D4 LED
BlueShadow 0:698b236430f4 18 DigitalOut data05(PA_9); //Blinds D5 LED
BlueShadow 0:698b236430f4 19 DigitalOut data06(PA_1); //Blinds D6 LED
BlueShadow 0:698b236430f4 20 DigitalOut data07(PA_8); //Blinds D7 LED
BlueShadow 0:698b236430f4 21 DigitalOut data08(PB_1); //Blinds D8 LED
BlueShadow 0:698b236430f4 22 int temp;
BlueShadow 0:698b236430f4 23
BlueShadow 0:698b236430f4 24 //Define timers
BlueShadow 0:698b236430f4 25 Timer print_timer;
BlueShadow 0:698b236430f4 26 Timer led_timer;
BlueShadow 0:698b236430f4 27
BlueShadow 0:698b236430f4 28 int main() {
BlueShadow 0:698b236430f4 29 data00 = 1; //Initialize LED off
BlueShadow 0:698b236430f4 30 data01 = 1; //Initialize LED off
BlueShadow 0:698b236430f4 31 data02 = 1; //Initialize LED off
BlueShadow 0:698b236430f4 32 data03 = 1; //Initialize LED off
BlueShadow 0:698b236430f4 33 data04 = 1; //Initialize LED off
BlueShadow 0:698b236430f4 34 data05 = 1; //Initialize LED off
BlueShadow 0:698b236430f4 35 data06 = 1; //Initialize LED off
BlueShadow 0:698b236430f4 36 data07 = 1; //Initialize LED off
BlueShadow 0:698b236430f4 37 data08 = 0; //Initialize LED off
BlueShadow 0:698b236430f4 38 print_timer.start(); //Start timers, will count until stopped
BlueShadow 0:698b236430f4 39 led_timer.start();
BlueShadow 0:698b236430f4 40
BlueShadow 0:698b236430f4 41 while (1) {
BlueShadow 0:698b236430f4 42 if (print_timer.read() >= 5) { //print_timer.read() returns time in seconds
BlueShadow 0:698b236430f4 43 printf("Hello World!\n");
BlueShadow 0:698b236430f4 44 print_timer.reset(); //Resets timer count to 0
BlueShadow 0:698b236430f4 45 }
BlueShadow 0:698b236430f4 46
BlueShadow 0:698b236430f4 47 //Calculates interval needed for specified frequency
BlueShadow 0:698b236430f4 48 if ( led_timer.read_ms() >= (2000.0/(2*LED_BLINK_RATE))) {
BlueShadow 0:698b236430f4 49 temp = data02; //Invert LED output
BlueShadow 0:698b236430f4 50 data02 = data01; //Invert LED output
BlueShadow 0:698b236430f4 51 data01 = data00; //Invert LED output
BlueShadow 0:698b236430f4 52 data00 = data03; //Invert LED output
BlueShadow 0:698b236430f4 53 data03 = data06; //Invert LED output
BlueShadow 0:698b236430f4 54 data06 = data08; //Invert LED output
BlueShadow 0:698b236430f4 55 data08 = data05; //Invert LED output
BlueShadow 0:698b236430f4 56 data05 = data04; //Invert LED output
BlueShadow 0:698b236430f4 57 data04 = data07; //Invert LED output
BlueShadow 0:698b236430f4 58 data07 = temp; //Invert LED output
BlueShadow 0:698b236430f4 59 led_timer.reset(); //Resets timer count to 0
BlueShadow 0:698b236430f4 60 }
BlueShadow 0:698b236430f4 61 }
BlueShadow 0:698b236430f4 62 }
BlueShadow 0:698b236430f4 63
BlueShadow 0:698b236430f4 64