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.

[参考译文] TMP118EVM:USB 命令驱动程序

Guru**** 2460850 points
Other Parts Discussed in Thread: TMP118EVM, TMP118

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/sensors-group/sensors/f/sensors-forum/1494770/tmp118evm-usb-command-driver

器件型号:TMP118EVM
主题中讨论的其他器件: TMP118

工具与软件:

尊敬的专家:

可否知道我们是否可以让 TMP118EVM 的 USB 转 I2C 命令/驱动程序与客户共享用于系统集成开发?  

谢谢!

解决了  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Allan:

    您是否在要求客户可以用于 TMP118器件的单独代码? 或 TMP118EVM 软件的源代码?

    我为附加了一些基于 C 的示例代码 Arduino 设置。 如果客户在开发基于 C 的驱动程序方面需要帮助、我强烈建议查看我们的 SysConfig 页面。

    //TMP118 Example Code to allow users to read from the TMP118 temperature sensor using a C-based program.
    //Author: Harry Gill
    //v0.2
    
     #include <Wire.h>
    
    //|| Device Definitions ||\\
    
    // Register Configurations
    #define DEVICE_CONFIG_REG_ADDR 0x0 //
    #define DEVICE_ADDR 0x48 //
    #define DEVICE_TEMP_REG_ADDR 0x0 //
    
    // Device Mode Options \\
    
    // One-Shot
    #define CONFIG_OS 0x1 //
    // Continuous
    #define CONFIG_CONTINUOUS 0x0 //
    
    
    void setup() {
      
      // put your setup code here, to run once:
      Wire.begin();
      Serial.println("TMP118 Arduino Example");
      Serial.begin(9600);
    
      //initialize device
      device_init();
      
      //wait 8ms
      delay(8);
    
    }
    
    void loop() {
    
      // put your main code here, to run repeatedly:
    
      // Pass device address and temp reg addr
      int16_t tempData = getData(DEVICE_ADDR, DEVICE_TEMP_REG_ADDR);
    
      float celcius = tempData * 0.0078125;
    
      Serial.print("Temp (C): ");
      Serial.println(celcius);
    
      //wait one second until next temp read
      delay(1000); 
    
    }
    
        // initialize device and load configuration into sensor
        void device_init(){
    
          //initiate contact with sensor
          Wire.beginTransmission(DEVICE_ADDR);
    
          //write to config register
          Wire.write(DEVICE_CONFIG_REG_ADDR);
          
          //write OS mode to config register
          Wire.write(CONFIG_OS);
          
          Wire.endTransmission();
    
        }
    
        int16_t getData(int8_t sensorAddr, int8_t tempReg) {
          
          Wire.beginTransmission(sensorAddr);
          Wire.write(tempReg);
          Wire.endTransmission();
          Wire.requestFrom(sensorAddr, 2);
    
          int16_t bytes = Wire.read() << 8;
          bytes |= Wire.read();
    
          return bytes;
          
        }
     
    

    此致、

    哈利