Skip to content

Commit 08a9062

Browse files
committed
Update v1.8.0
1 parent 6e334b8 commit 08a9062

File tree

48 files changed

+5090
-1498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5090
-1498
lines changed

STM32CubeExpansion_LRWAN/Drivers/BSP/Components/bh1750/bh1750.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include "delay.h"
5151

5252
bool iic_noack=0;
53-
extern bool debug_flags;
5453
/* Private typedef -----------------------------------------------------------*/
5554
/* Private define ------------------------------------------------------------*/
5655

@@ -62,18 +61,18 @@ float bh1750_read(void)
6261
{
6362
uint8_t rxdata[2];
6463
uint16_t AD_code;
65-
float luminance;
64+
uint16_t luminance;
6665

67-
DelayMs(10);//Required
66+
HAL_Delay(10);//Required
6867
IIC_Write_Byte(0x23,0x01); //power on
6968
IIC_Write_Byte(0x23,0x20); //read data
70-
DelayMs(200);
69+
HAL_Delay(200);
7170
IIC_Read_Len(0x23,2,rxdata);
7271
IIC_Write_Byte(0x23,0x07); //clear
7372

7473
if(iic_noack==1)
7574
{
76-
luminance=65535;
75+
luminance=0;
7776
}
7877
else
7978
{
@@ -82,11 +81,7 @@ float bh1750_read(void)
8281
}
8382

8483
iic_noack=0;
85-
if(debug_flags==1)
86-
{
87-
PPRINTF("\r\n");
88-
PPRINTF("Luminance:%d lux\r\n",(int)luminance);
89-
}
84+
9085
return luminance;
9186
}
9287

@@ -107,7 +102,10 @@ void I2C_IoInit(void)
107102
void I2C_DoInit(void)
108103
{
109104
static GPIO_InitTypeDef GPIO_InitStruct;
110-
105+
106+
__HAL_RCC_GPIOA_CLK_ENABLE();
107+
108+
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
111109
GPIO_InitStruct.Pull = GPIO_PULLUP;
112110
GPIO_InitStruct.Pin =IIC_SCL_PIN | IIC_SDA_PIN;
113111

@@ -122,7 +120,6 @@ void SDA_IN(void)
122120

123121
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
124122
GPIO_InitStruct.Pull = GPIO_NOPULL;
125-
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
126123
GPIO_InitStruct.Pin = IIC_SDA_PIN;
127124

128125
HAL_GPIO_Init(GPIO_PORT_IIC, &GPIO_InitStruct);

0 commit comments

Comments
 (0)