This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] Sysconfig: ASCStudio mcu.c example code for Arduino I2C

Other Parts Discussed in Thread: SYSCONFIG, TMP102, HDC2080

If you're looking at the blank mcu.c file generated by Sysconfig: ASCStudio and not sure where to begin, have a look at this example for a popular platform. 

/*
 *  Include Generic Header Files Here
 */
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

#include "mcu.h"
#include <Wire.h>

/*
 *  Include MCU Specific Header Files Here
 */

/********* MCU SPECIFIC I2C CODE STARTS HERE**********/

void mcu_i2cInit(uint8_t busId)
{
	Wire.begin();
}

int8_t mcu_i2cTransfer( uint8_t busId, uint8_t i2cAddr,
                        uint8_t *dataToWrite, uint8_t writeLength,
                        uint8_t *dataToRead,  uint8_t readLength)
{
  if (writeLength > 0) {
    Wire.beginTransmission(i2cAddr);
    for (int i = 0; i <= writeLength; i++)
      Wire.write(dataToWrite[i]);
    Wire.endTransmission();
  }
  if (readLength > 0){
    Wire.requestFrom(i2cAddr, readLength);
    int i = 0;
    while(Wire.available()) {
      dataToRead[i] = Wire.read();
      i++;
    }
  }
  return (0);
}
/********* MCU SPECIFIC I2C CODE ENDS HERE**********/


/********* MCU SPECIFIC DELAY CODE STARTS HERE************/
void mcu_msWait(unsigned long msWait)
{
	delay(msWait);
}
/********* MCU SPECIFIC DELAY CODE ENDS HERE************/

Direct link to ASCStudio: https://dev.ti.com/sysconfig/index.html?product=ascstudio

Direct link to ASCStudio TMP102: https://dev.ti.com/sysconfig/index.html?product=ascstudio&module=/ti/sensors/tempsensor/TMP102

Direct link to ASCStudio HDC2080: https://dev.ti.com/sysconfig/index.html?product=ascstudio&module=/ti/sensors/humiditysensor/HDC2080

Disclaimer:

  • This example code was verified on Arduino UNO
  • This example code does not represent a complete project. The user will have to know how to integrate the example code and files generated by Sysconfig  into their project.