Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystemVSG
mbed_objects.cpp@9:fd5bf0a4c774, 2019-08-07 (annotated)
- Committer:
 - pni_olesik
 - Date:
 - Wed Aug 07 23:38:35 2019 +0000
 - Revision:
 - 9:fd5bf0a4c774
 - Parent:
 - 1:b0a205c9b958
 
em7186.cpp line 927 missing brackets around one of the cases causes a warning, but in later Mbed OS causes an Error.
Who changed what in which revision?
| User | Revision | Line number | New 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 | |
| JoeMiller | 0:02c0c2cbc3df | 19 | DigitalIn pushButton(D5); | 
| JoeMiller | 0:02c0c2cbc3df | 20 | |
| JoeMiller | 0:02c0c2cbc3df | 21 | //========================================================================= | 
| JoeMiller | 0:02c0c2cbc3df | 22 | // I/O functions customized for MBED platform | 
| JoeMiller | 0:02c0c2cbc3df | 23 | //========================================================================= | 
| JoeMiller | 0:02c0c2cbc3df | 24 | |
| JoeMiller | 0:02c0c2cbc3df | 25 | // MBED native READ/ WRITE functions | 
| JoeMiller | 0:02c0c2cbc3df | 26 | u32 em7186_i2c_write(u8 registerAddress, u8* buffer, u16 length) | 
| JoeMiller | 0:02c0c2cbc3df | 27 | { | 
| JoeMiller | 0:02c0c2cbc3df | 28 | u8 writeBuffer[MAX_I2C_WRITE + 1]; | 
| JoeMiller | 0:02c0c2cbc3df | 29 | writeBuffer[0] = registerAddress; | 
| JoeMiller | 0:02c0c2cbc3df | 30 | memcpy(&writeBuffer[1], buffer, length); | 
| JoeMiller | 0:02c0c2cbc3df | 31 | //i2c.write(int address, const u8 *data, int length, bool repeated=false) | 
| JoeMiller | 0:02c0c2cbc3df | 32 | // returns 0 on success (ack), non-0 on failure (nack) | 
| JoeMiller | 0:02c0c2cbc3df | 33 | int status = i2c.write(SENtral_ADDRESS, writeBuffer, length+1, 0); | 
| JoeMiller | 0:02c0c2cbc3df | 34 | return !status; // return True if successfull. mbed:0=Success | 
| JoeMiller | 0:02c0c2cbc3df | 35 | } | 
| JoeMiller | 0:02c0c2cbc3df | 36 | |
| JoeMiller | 0:02c0c2cbc3df | 37 | u32 em7186_i2c_read(u8 registerAddress, u8* buffer, u16 length) | 
| JoeMiller | 0:02c0c2cbc3df | 38 | { | 
| JoeMiller | 0:02c0c2cbc3df | 39 | u8 writeBuffer[1] = {registerAddress}; | 
| JoeMiller | 0:02c0c2cbc3df | 40 | i2c.write(SENtral_ADDRESS, writeBuffer, 1, 1); | 
| JoeMiller | 0:02c0c2cbc3df | 41 | int status = i2c.read(SENtral_ADDRESS, buffer, length, 0); | 
| JoeMiller | 0:02c0c2cbc3df | 42 | if (!status) //mbed:0=Success | 
| JoeMiller | 0:02c0c2cbc3df | 43 | return length; | 
| JoeMiller | 0:02c0c2cbc3df | 44 | else | 
| JoeMiller | 0:02c0c2cbc3df | 45 | return 0; | 
| JoeMiller | 0:02c0c2cbc3df | 46 | } | 
| JoeMiller | 0:02c0c2cbc3df | 47 | |
| JoeMiller | 0:02c0c2cbc3df | 48 | u32 EE_Write(u8 I2C_Addr, u16 EE_MemAddr, u8*buffer, u16 length) | 
| JoeMiller | 0:02c0c2cbc3df | 49 | { | 
| JoeMiller | 0:02c0c2cbc3df | 50 | u8 outbuffer[MAX_I2C_WRITE + 2]; | 
| JoeMiller | 0:02c0c2cbc3df | 51 | |
| JoeMiller | 0:02c0c2cbc3df | 52 | memcpy((u8 *)&outbuffer[0],&EE_MemAddr, 2); | 
| JoeMiller | 0:02c0c2cbc3df | 53 | u8 temp = outbuffer[0]; outbuffer[0] = outbuffer[1];outbuffer[1]=temp; // swap endian | 
| JoeMiller | 0:02c0c2cbc3df | 54 | memcpy((u8 *)&outbuffer[2],buffer,length ); | 
| JoeMiller | 0:02c0c2cbc3df | 55 | int status = i2c.write(I2C_Addr, outbuffer, length+2, 0); | 
| JoeMiller | 0:02c0c2cbc3df | 56 | return !status; // return True if successfull. mbed:0=Success | 
| JoeMiller | 0:02c0c2cbc3df | 57 | } | 
| JoeMiller | 0:02c0c2cbc3df | 58 | |
| JoeMiller | 0:02c0c2cbc3df | 59 | u32 EE_Read(u8 I2C_Addr, u16 EE_MemAddr, u8*buffer, u16 length) | 
| JoeMiller | 0:02c0c2cbc3df | 60 | { | 
| JoeMiller | 0:02c0c2cbc3df | 61 | u8 writeBuffer[2]; | 
| JoeMiller | 0:02c0c2cbc3df | 62 | memcpy((u8 *)&writeBuffer[0],&EE_MemAddr, 2); | 
| JoeMiller | 0:02c0c2cbc3df | 63 | u8 temp = writeBuffer[0]; writeBuffer[0] = writeBuffer[1];writeBuffer[1]=temp; // swap endian | 
| JoeMiller | 0:02c0c2cbc3df | 64 | i2c.write(I2C_Addr, writeBuffer, 2, 1); | 
| JoeMiller | 0:02c0c2cbc3df | 65 | int status = i2c.read(I2C_Addr, buffer, length, 0); | 
| JoeMiller | 0:02c0c2cbc3df | 66 | return !status; // return True if successfull. mbed:0=Success | 
| JoeMiller | 0:02c0c2cbc3df | 67 | } | 
| JoeMiller | 0:02c0c2cbc3df | 68 | 
            PNI M&M Amber Module