SENtral Simple Serial Host interface for PNI Sensor Corp SENtral-A2 motion coprocessor. For use with the RM3100RTI Arduino shield module on top of an STM4 serial mbed board. Will work with an PNI RM3100RTI module or M&M motion modules. Interaction with unit using built in USB serial serial port set for 115200 baud. Send '?' char for menu. Presently requires SENtral firmware to either be loaded in the RM3100RTI Arduino shield SD Card or preloaded in the RM3100RTI or M&M module's EEPROM. Firmware is typically preloaded on the module's EEPROM by PNI. PNI Sensor, 2019 www.pnicorp.com

Dependencies:   mbed SDFileSystemVSG

SENtral Simple Serial Host interface for PNI Sensor Corp SENtral-A2 motion coprocessor. For use with the RM3100RTI Arduino shield module on top of an STM4 serial mbed board. Will work with an PNI RM3100RTI module or M&M motion modules. Interaction with unit using built in USB serial serial port set for 115200 baud. Send '?' char for menu. Presently requires SENtral firmware to either be loaded in the RM3100RTI Arduino shield SD Card or preloaded in the RM3100RTI or M&M module's EEPROM. Firmware is typically preloaded on the module's EEPROM by PNI. PNI Sensor, 2019 www.pnicorp.com

Committer:
JoeMiller
Date:
Wed Jul 20 23:03:48 2016 +0000
Revision:
0:02c0c2cbc3df
Child:
1:b0a205c9b958
Initial Release as SENtral Simple Serial Host Interface

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JoeMiller 0:02c0c2cbc3df 1 // The purpose of this file and associated header file is to
JoeMiller 0:02c0c2cbc3df 2 // enable globalization of mbed platform specific objects
JoeMiller 0:02c0c2cbc3df 3 // for all source files to utilize
JoeMiller 0:02c0c2cbc3df 4
JoeMiller 0:02c0c2cbc3df 5 #include "mbed_objects.h"
JoeMiller 0:02c0c2cbc3df 6
JoeMiller 0:02c0c2cbc3df 7 //******************************
JoeMiller 0:02c0c2cbc3df 8 // MBED Library instatiations
JoeMiller 0:02c0c2cbc3df 9 //******************************
JoeMiller 0:02c0c2cbc3df 10 //mosi miso sck cs
JoeMiller 0:02c0c2cbc3df 11 SDFileSystem sd(D11, D12, D13, D10, "sd");
JoeMiller 0:02c0c2cbc3df 12 I2C i2c(I2C_SDA, I2C_SCL);
JoeMiller 0:02c0c2cbc3df 13 Serial pc(SERIAL_TX, SERIAL_RX);
JoeMiller 0:02c0c2cbc3df 14 InterruptIn SENtral_InterruptPin(D2);
JoeMiller 0:02c0c2cbc3df 15
JoeMiller 0:02c0c2cbc3df 16 // These LEDs and PBSwitch are Not part of the RM3100RTI Arduino Shield.
JoeMiller 0:02c0c2cbc3df 17 DigitalOut green_LED(D4);
JoeMiller 0:02c0c2cbc3df 18 DigitalOut NucleoRedLED(LED3); // used only to verify mbed program upload success
JoeMiller 0:02c0c2cbc3df 19
JoeMiller 0:02c0c2cbc3df 20 DigitalIn pushButton(D5);
JoeMiller 0:02c0c2cbc3df 21
JoeMiller 0:02c0c2cbc3df 22 //=========================================================================
JoeMiller 0:02c0c2cbc3df 23 // I/O functions customized for MBED platform
JoeMiller 0:02c0c2cbc3df 24 //=========================================================================
JoeMiller 0:02c0c2cbc3df 25
JoeMiller 0:02c0c2cbc3df 26 // MBED native READ/ WRITE functions
JoeMiller 0:02c0c2cbc3df 27 u32 em7186_i2c_write(u8 registerAddress, u8* buffer, u16 length)
JoeMiller 0:02c0c2cbc3df 28 {
JoeMiller 0:02c0c2cbc3df 29 u8 writeBuffer[MAX_I2C_WRITE + 1];
JoeMiller 0:02c0c2cbc3df 30 writeBuffer[0] = registerAddress;
JoeMiller 0:02c0c2cbc3df 31 memcpy(&writeBuffer[1], buffer, length);
JoeMiller 0:02c0c2cbc3df 32 //i2c.write(int address, const u8 *data, int length, bool repeated=false)
JoeMiller 0:02c0c2cbc3df 33 // returns 0 on success (ack), non-0 on failure (nack)
JoeMiller 0:02c0c2cbc3df 34 int status = i2c.write(SENtral_ADDRESS, writeBuffer, length+1, 0);
JoeMiller 0:02c0c2cbc3df 35 return !status; // return True if successfull. mbed:0=Success
JoeMiller 0:02c0c2cbc3df 36 }
JoeMiller 0:02c0c2cbc3df 37
JoeMiller 0:02c0c2cbc3df 38 u32 em7186_i2c_read(u8 registerAddress, u8* buffer, u16 length)
JoeMiller 0:02c0c2cbc3df 39 {
JoeMiller 0:02c0c2cbc3df 40 u8 writeBuffer[1] = {registerAddress};
JoeMiller 0:02c0c2cbc3df 41 i2c.write(SENtral_ADDRESS, writeBuffer, 1, 1);
JoeMiller 0:02c0c2cbc3df 42 int status = i2c.read(SENtral_ADDRESS, buffer, length, 0);
JoeMiller 0:02c0c2cbc3df 43 if (!status) //mbed:0=Success
JoeMiller 0:02c0c2cbc3df 44 return length;
JoeMiller 0:02c0c2cbc3df 45 else
JoeMiller 0:02c0c2cbc3df 46 return 0;
JoeMiller 0:02c0c2cbc3df 47 }
JoeMiller 0:02c0c2cbc3df 48
JoeMiller 0:02c0c2cbc3df 49 u32 EE_Write(u8 I2C_Addr, u16 EE_MemAddr, u8*buffer, u16 length)
JoeMiller 0:02c0c2cbc3df 50 {
JoeMiller 0:02c0c2cbc3df 51 u8 outbuffer[MAX_I2C_WRITE + 2];
JoeMiller 0:02c0c2cbc3df 52
JoeMiller 0:02c0c2cbc3df 53 memcpy((u8 *)&outbuffer[0],&EE_MemAddr, 2);
JoeMiller 0:02c0c2cbc3df 54 u8 temp = outbuffer[0]; outbuffer[0] = outbuffer[1];outbuffer[1]=temp; // swap endian
JoeMiller 0:02c0c2cbc3df 55 memcpy((u8 *)&outbuffer[2],buffer,length );
JoeMiller 0:02c0c2cbc3df 56 int status = i2c.write(I2C_Addr, outbuffer, length+2, 0);
JoeMiller 0:02c0c2cbc3df 57 return !status; // return True if successfull. mbed:0=Success
JoeMiller 0:02c0c2cbc3df 58 }
JoeMiller 0:02c0c2cbc3df 59
JoeMiller 0:02c0c2cbc3df 60 u32 EE_Read(u8 I2C_Addr, u16 EE_MemAddr, u8*buffer, u16 length)
JoeMiller 0:02c0c2cbc3df 61 {
JoeMiller 0:02c0c2cbc3df 62 u8 writeBuffer[2];
JoeMiller 0:02c0c2cbc3df 63 memcpy((u8 *)&writeBuffer[0],&EE_MemAddr, 2);
JoeMiller 0:02c0c2cbc3df 64 u8 temp = writeBuffer[0]; writeBuffer[0] = writeBuffer[1];writeBuffer[1]=temp; // swap endian
JoeMiller 0:02c0c2cbc3df 65 i2c.write(I2C_Addr, writeBuffer, 2, 1);
JoeMiller 0:02c0c2cbc3df 66 int status = i2c.read(I2C_Addr, buffer, length, 0);
JoeMiller 0:02c0c2cbc3df 67 return !status; // return True if successfull. mbed:0=Success
JoeMiller 0:02c0c2cbc3df 68 }
JoeMiller 0:02c0c2cbc3df 69