-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c26f7ce
commit 63b7ddd
Showing
7 changed files
with
147 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @file DRV_HIH_componentSpecific.c | ||
* @brief Source code for HIH driver | ||
*/ | ||
|
||
/****************************************************************************** | ||
* I N C L U D E S | ||
******************************************************************************/ | ||
|
||
#include "DRV_HIH.h" | ||
#include "HW_i2c.h" | ||
|
||
/****************************************************************************** | ||
* P U B L I C V A R S | ||
******************************************************************************/ | ||
|
||
HW_I2C_Device_S I2C_HIH = { | ||
.addr = 0x27, | ||
.handle = &i2c, | ||
}; | ||
|
||
DRV_HIH_S hih_chip = { | ||
.dev = &I2C_HIH, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* @file HW_HIH.c | ||
* @brief Source code for HIH driver | ||
*/ | ||
|
||
/****************************************************************************** | ||
* I N C L U D E S | ||
******************************************************************************/ | ||
|
||
#include "DRV_HIH.h" | ||
#include <string.h> | ||
|
||
/****************************************************************************** | ||
* E X T E R N S | ||
******************************************************************************/ | ||
|
||
extern HW_I2C_Device_S I2C_HIH; | ||
|
||
/****************************************************************************** | ||
* P U B L I C F U N C T I O N S | ||
******************************************************************************/ | ||
|
||
bool DRV_HIH_init(void) | ||
{ | ||
memset(&hih_chip.data, 0x00, sizeof(hih_chip.data)); | ||
|
||
if (!HW_I2C_masterWrite(hih_chip.dev, 0x00, 0, 10)) | ||
{ | ||
hih_chip.data.state = DRV_HIH_ERROR; | ||
return false; | ||
} | ||
|
||
hih_chip.data.state = DRV_HIH_MEASURING; | ||
|
||
return true; | ||
} | ||
|
||
bool DRV_HIH_getData(void) | ||
{ | ||
uint8_t rdat[4] = {0x00}; | ||
if (hih_chip.data.state == DRV_HIH_MEASURING) | ||
{ | ||
if (HW_I2C_masterRead(hih_chip.dev, (uint8_t*)&rdat, 4, 10)) | ||
{ | ||
hih_chip.data.rh = ((rdat[0] & 0x3f) << 8) | rdat[1]; | ||
hih_chip.data.temp = (rdat[2] << 6) | (rdat[3] >> 2); | ||
hih_chip.data.state = DRV_HIH_WAITING; | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
bool DRV_HIH_startConversion(void) | ||
{ | ||
if (hih_chip.data.state == DRV_HIH_WAITING) | ||
{ | ||
if (HW_I2C_masterWrite(hih_chip.dev, 0x00, 0, 10)) | ||
{ | ||
hih_chip.data.state = DRV_HIH_MEASURING; | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* @file HW_HIH.h | ||
* @brief Header file for HIH driver | ||
*/ | ||
|
||
/****************************************************************************** | ||
* I N C L U D E S | ||
******************************************************************************/ | ||
|
||
#include "HW_i2c.h" | ||
#include "LIB_Types.h" | ||
|
||
/****************************************************************************** | ||
* T Y P E D E F S | ||
******************************************************************************/ | ||
|
||
typedef enum { | ||
DRV_HIH_INIT = 0x00, | ||
DRV_HIH_MEASURING, | ||
DRV_HIH_WAITING, | ||
DRV_HIH_ERROR, | ||
} DRV_HIH_State_E; | ||
|
||
typedef struct { | ||
uint16_t temp; | ||
uint16_t rh; | ||
DRV_HIH_State_E state; | ||
} DRV_HIH_Data_S; | ||
|
||
typedef struct { | ||
HW_I2C_Device_S* dev; | ||
DRV_HIH_Data_S data; | ||
} DRV_HIH_S; | ||
|
||
/****************************************************************************** | ||
* E X T E R N S | ||
******************************************************************************/ | ||
|
||
extern DRV_HIH_S hih_chip; | ||
|
||
/****************************************************************************** | ||
* P U B L I C F U N C T I O N P R O T O T Y P E S | ||
******************************************************************************/ | ||
|
||
bool DRV_HIH_init(void); | ||
bool DRV_HIH_getData(void); | ||
bool DRV_HIH_startConversion(void); | ||
|