Skip to content

Commit

Permalink
Use internal pullups for 1wire and i2c
Browse files Browse the repository at this point in the history
  • Loading branch information
nurikk committed Aug 14, 2020
1 parent 7f8cd72 commit 44429b4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"configurations": [{
"name": "Mac",
"forcedInclude": ["${workspaceRoot}/Source/preinclude.h"],
"defines": ["HAL_BOARD_FLOWER", "HAL_I2C=TRUE", "HAL_I2C_MASTER"],
"defines": ["HAL_BOARD_FLOWER"],
"includePath": [
"${workspaceRoot}",
"${workspaceRoot}/hal",
"${workspaceRoot}/zstack-lib",
"${workspaceRoot}/BME280_driver",
"${env:ZSTACK_PATH}/Components/mac/include/",
"${env:ZSTACK_PATH}/Components/mt",
Expand Down
10 changes: 9 additions & 1 deletion Source/preinclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
#define BDB_MAX_CLUSTERENDPOINTS_REPORTING 10

#define BME280_32BIT_ENABLE

//TODO: refactor ds18b20 driver
#define DS18B20_PORT 1
#define DS18B20_PIN 3

#define TSENS_SBIT P1_3
#define TSENS_BV BV(3)
Expand All @@ -65,6 +67,12 @@
#endif


//i2c bme280
#define OCM_CLK_PORT 0
#define OCM_DATA_PORT 0
#define OCM_CLK_PIN 5
#define OCM_DATA_PIN 6


#ifdef DO_DEBUG_UART
#define HAL_UART TRUE
Expand Down
7 changes: 7 additions & 0 deletions Source/zcl_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,15 @@ static void zclApp_ReadSoilHumidity(void) {
}

static void zclApp_ReadDS18B20(void) {
IO_PUD_PORT(DS18B20_PORT, IO_PUP);
zclApp_DS18B20_MeasuredValue = readTemperature();
if (zclApp_DS18B20_MeasuredValue != 1) {
LREP("ReadDS18B20 t=%d\r\n", zclApp_DS18B20_MeasuredValue);
bdb_RepChangedAttrValue(zclApp_SecondEP.EndPoint, TEMP, ATTRID_MS_TEMPERATURE_MEASURED_VALUE);
} else {
LREPMaster("ReadDS18B20 error\r\n");
}
IO_PUD_PORT(DS18B20_PORT, IO_PDN);
}

static void zclApp_ReadLumosity(void) {
Expand All @@ -320,6 +322,8 @@ static void zclApp_ReadLumosity(void) {
void user_delay_ms(uint32_t period) { MicroWait(period * 1000); }

static void zclApp_ReadBME280(struct bme280_dev *dev) {
IO_PUD_PORT(OCM_CLK_PORT, IO_PUP);
IO_PUD_PORT(OCM_DATA_PORT, IO_PUP);
int8_t rslt = bme280_init(dev);
if (rslt == BME280_OK) {
uint8_t settings_sel;
Expand Down Expand Up @@ -353,6 +357,9 @@ static void zclApp_ReadBME280(struct bme280_dev *dev) {
} else {
LREP("ReadBME280 init error %d\r\n", rslt);
}

IO_PUD_PORT(OCM_CLK_PORT, IO_PDN);
IO_PUD_PORT(OCM_DATA_PORT, IO_PDN);
}
static void zclApp_Report(void) {
osal_start_reload_timer(zclApp_TaskID, APP_READ_SENSORS_EVT, 100);
Expand Down

0 comments on commit 44429b4

Please sign in to comment.