저는 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"에서 결코 성공하지 못한다는 것을 알아 냈습니다. 따라서 센서의 값을 얻지 못합니다. 그러나 나는 왜 볼 수 없습니다.
아이디어가 있으십니까?
미리 감사드립니다.