2016-12-06 2 views
0

저는 Silicon Laboratories BGM121 블루투스 저에너지 모듈과 SLWSTK6101C 스타터 키트를 사용하고 있습니다. 이 키트에는 보드 자체의 i2c에 연결되어 있으며 모듈을 통해이 모듈에 연결된 RHT 센서 (Si7021)가 있습니다.I2C 통신 SLMSTK6101C (BGScript)의 온보드 Si7021이 장착 된 BGM121

샘플 프로젝트를 사용하면 Simplicity Studio v4를 통해 컴파일하지 않고 직접 플래시했는데 제대로 작동하고 적절한 값을 얻을 수 있습니다.

문제점 : 모듈을 프로그래밍 할 때 SiLabs BGScript 언어를 사용해야합니다. GCC는 아직 지원되지 않으며 IAR 라이센스가 없습니다.

센서 데이터 (온도)를 읽고 BLE를 통해 Android 앱에 보내려고합니다. BLE 부분은 문제가 아니며 bluetooth.org의 채택 된 서비스에 설명 된 것과 같은 서비스/특성을 구축합니다. SiLabs의 BGScript 예제를 사용하여 작동하는지 테스트하려고했습니다. 그러나 제조업체에서 제공하는 공식 SDK BGScript 예제조차도 작동하지 않습니다.

<!-- I2C configuration --> 
<!-- Settings: SCL pin is PC11 and SDA pin is PC10 --> 
<i2c scl_pin="PC11" sda_pin="PC10"/> 

I2C 통신 코드 :이 I2C 통신을 종료/시작하면

export dim i2c_result 
export dim i2c_len 
export dim i2c_buffer(4) 
export dim temperature(5) 
export dim timeout 
export dim data 
dim result 

const sensor_slave_addr = $40 

export procedure sensorRead() 

    call led1_on() 


    call hardware_write_i2c(0,sensor_slave_addr,1,$f3) 

    i2c_result = 1 
    timeout = 0 
    while (i2c_result != 0) && (timeout < 50) 
     call hardware_read_i2c(0,sensor_slave_addr,2)(i2c_result,i2c_len,i2c_buffer(0:i2c_len)) 
     timeout = timeout + 1 
     if i2c_result = 0 then 
      call led1_off() 
     end if 
    end while 

    call hardware_stop_i2c(0) 

    if(timeout < 50) then 
     # Check that the I2C was read properly and the while loop didn't 
     # end because of the timeout. 
     # Measurement from the I2C read is in big endian format and must be 
     # converted to little-endian by swapping bytes. 
     data = i2c_buffer(0:1) << 8 | i2c_buffer(1:1) 
     #call led1_off() 
    else 
     data = $25 
    end if 


    #Flags field -> 0: °C , 1: °F 
    temperature(0:1)=$00 
    temperature(1:4)=float(data*1757/65536-469, -1) 



    call gatt_server_write_attribute_value(temperature_char, 0, 5, temperature(0:5))(result) 
    call gatt_server_send_characteristic_notification($FF, temperature_char, 5, temperature(0:5))(result) 

    end 

주도 절차에 대한 호출은 단지 테스트를위한

은 여기 내 구성과 내 코드입니다.

나는 "i2c_result"에서 결코 성공하지 못한다는 것을 알아 냈습니다. 따라서 센서의 값을 얻지 못합니다. 그러나 나는 왜 볼 수 없습니다.

아이디어가 있으십니까?

미리 감사드립니다.

답변

0

해결되었습니다. SiLabs 지원으로 며칠 전에 새로운 SDK v2.1을 출시한다는 힌트를 얻을 수있었습니다. 이 업데이트 된 SDK에는 작업 프로젝트가 있습니다.

그러나 작동중인 센서로 이전 프로젝트를 실행할 수 있습니다.

BGM121은 다른 보드처럼 센서에 고정 된 전원을 제공하지 않습니다. 센서에 전원을 공급하려면 "전원 공급 핀"을 로직 1로 설정해야합니다. 다른 모듈은 센서를 정적으로 로직 1에 연결했습니다.

hardware.xml 파일에 GPIO를 추가로 설정하면됩니다.

<gpio port="D" pin="9" mode="pushpull" out="1" /> 

또는 모든 것을 해결

call hardware_configure_gpio(3, 9, hardware_gpio_mode_push_pull, 1) 

에 호출 프로그램으로 설정. 이제는 센서를 사용할 수 있습니다.

관련 문제