LibDriver BH1750FVI  1.0.0
BH1750FVI full-featured driver
driver_bh1750fvi.c
Go to the documentation of this file.
1 
37 #include "driver_bh1750fvi.h"
38 
42 #define CHIP_NAME "ROHM BH1750FVI"
43 #define MANUFACTURER_NAME "ROHM"
44 #define SUPPLY_VOLTAGE_MIN 2.4f
45 #define SUPPLY_VOLTAGE_MAX 3.6f
46 #define MAX_CURRENT 0.19f
47 #define TEMPERATURE_MIN -40.0f
48 #define TEMPERATURE_MAX 85.0f
49 #define DRIVER_VERSION 1000
54 #define BH1750FVI_COMMAND_POWER_DOWN 0x00
55 #define BH1750FVI_COMMAND_POWER_ON 0x01
56 #define BH1750FVI_COMMAND_RESET 0x07
57 #define BH1750FVI_COMMAND_CONTINUOUSLY_H_RESOLUTION_MODE 0x10
58 #define BH1750FVI_COMMAND_CONTINUOUSLY_H_RESOLUTION_MODE2 0x11
59 #define BH1750FVI_COMMAND_CONTINUOUSLY_L_RESOLUTION_MODE 0x13
60 #define BH1750FVI_COMMAND_ONE_TIME_H_RESOLUTION_MODE 0x20
61 #define BH1750FVI_COMMAND_ONE_TIME_H_RESOLUTION_MODE2 0x21
62 #define BH1750FVI_COMMAND_ONE_TIME_L_RESOLUTION_MODE 0x23
63 #define BH1750FVI_COMMAND_CHANGE_MEASUREMENT_TIME_HIGH 0x40
64 #define BH1750FVI_COMMAND_CHANGE_MEASUREMENT_TIME_LOW 0x60
76 static uint8_t a_bh1750fvi_iic_read(bh1750fvi_handle_t *handle, uint8_t *data, uint16_t len)
77 {
78  if (handle->iic_read_cmd(handle->iic_addr, data, len) != 0) /* read the register */
79  {
80  return 1; /* return error */
81  }
82  else
83  {
84  return 0; /* success return 0 */
85  }
86 }
87 
98 static uint8_t a_bh1750fvi_iic_write(bh1750fvi_handle_t *handle, uint8_t *data, uint16_t len)
99 {
100  if (handle->iic_write_cmd(handle->iic_addr, data, len) != 0) /* write the register */
101  {
102  return 1; /* return error */
103  }
104  else
105  {
106  return 0; /* success return 0 */
107  }
108 }
109 
120 {
121  if (handle == NULL) /* check handle */
122  {
123  return 2; /* return error */
124  }
125 
126  handle->iic_addr = addr_pin; /* set iic addr */
127 
128  return 0; /* success return 0 */
129 }
130 
141 {
142  if (handle == NULL) /* check handle */
143  {
144  return 2; /* return error */
145  }
146 
147  *addr_pin = (bh1750fvi_address_t)(handle->iic_addr); /*get iic address */
148 
149  return 0; /* success return 0 */
150 }
151 
163 {
164  if (handle == NULL) /* check handle */
165  {
166  return 2; /* return error */
167  }
168  if (handle->inited != 1) /* check handle initialization */
169  {
170  return 3; /* return error */
171  }
172 
173  handle->mode = (uint8_t)(mode); /* set the mode */
174 
175  return 0; /* success return 0 */
176 }
177 
189 {
190  if (handle == NULL) /* check handle */
191  {
192  return 2; /* return error */
193  }
194  if (handle->inited != 1) /* check handle initialization */
195  {
196  return 3; /* return error */
197  }
198 
199  *mode = (bh1750fvi_mode_t)(handle->mode); /* get the mode */
200 
201  return 0; /* success return 0 */
202 }
203 
217 {
218  uint8_t res;
219  uint8_t prev;
220 
221  if (handle == NULL) /* check handle */
222  {
223  return 2; /* return error */
224  }
225  if (handle->debug_print == NULL) /* check debug_print */
226  {
227  return 3; /* return error */
228  }
229  if (handle->iic_init == NULL) /* check iic_init */
230  {
231  handle->debug_print("bh1750fvi: iic_init is null.\n"); /* iic_init is null */
232 
233  return 3; /* return error */
234  }
235  if (handle->iic_deinit == NULL) /* check iic_deinit */
236  {
237  handle->debug_print("bh1750fvi: iic_deinit is null.\n"); /* iic_deinit is null */
238 
239  return 3; /* return error */
240  }
241  if (handle->iic_read_cmd == NULL) /* check iic_read_cmd */
242  {
243  handle->debug_print("bh1750fvi: iic_read_cmd is null.\n"); /* iic_read_cmd is null */
244 
245  return 3; /* return error */
246  }
247  if (handle->iic_write_cmd == NULL) /* check iic_write_cmd */
248  {
249  handle->debug_print("bh1750fvi: iic_write_cmd is null.\n"); /* iic_write_cmd is null */
250 
251  return 3; /* return error */
252  }
253  if (handle->delay_ms == NULL) /* check delay_ms */
254  {
255  handle->debug_print("bh1750fvi: delay_ms is null.\n"); /* delay_ms is null */
256 
257  return 3; /* return error */
258  }
259 
260  if (handle->iic_init() != 0) /* iic init */
261  {
262  handle->debug_print("bh1750fvi: iic init failed.\n"); /* iic init failed */
263 
264  return 1; /* return error */
265  }
266 
267  prev = BH1750FVI_COMMAND_POWER_ON; /* set the command */
268  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
269  if (res != 0) /* check error */
270  {
271  handle->debug_print("bh1750fvi: power on failed.\n"); /* power on failed */
272  (void)handle->iic_deinit(); /* iic deinit */
273 
274  return 4; /* return error */
275  }
276  handle->delay_ms(5); /* delay 5ms */
277  prev = BH1750FVI_COMMAND_RESET; /* set the command */
278  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
279  if (res != 0) /* check error */
280  {
281  handle->debug_print("bh1750fvi: reset failed.\n"); /* reset failed */
282  (void)handle->iic_deinit(); /* iic deinit */
283 
284  return 5; /* return error */
285  }
286  handle->delay_ms(5); /* delay 5ms */
287  prev = BH1750FVI_COMMAND_CHANGE_MEASUREMENT_TIME_HIGH | ((69 >> 5) & 0x07); /* set the command */
288  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
289  if (res != 0) /* check error */
290  {
291  handle->debug_print("bh1750fvi: set measurement time failed.\n"); /* set measurement time failed */
292 
293  return 1; /* return error */
294  }
295  prev = BH1750FVI_COMMAND_CHANGE_MEASUREMENT_TIME_LOW | ((69 >> 0) & 0x1F); /* set the command */
296  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
297  if (res != 0) /* check error */
298  {
299  handle->debug_print("bh1750fvi: set measurement time failed.\n"); /* set measurement time failed */
300 
301  return 1; /* return error */
302  }
303  handle->delay_ms(5); /* delay 5ms */
304  handle->mode = BH1750FVI_MODE_HIGH_RESOLUTION_MODE; /* high resolution mode */
305  handle->t = 69; /* set default 69 */
306  handle->inited = 1; /* flag finish initialization */
307 
308  return 0; /* success return 0 */
309 }
310 
323 {
324  uint8_t res;
325  uint8_t prev;
326 
327  if (handle == NULL) /* check handle */
328  {
329  return 2; /* return error */
330  }
331  if (handle->inited != 1) /* check handle initialization */
332  {
333  return 3; /* return error */
334  }
335 
336  prev = BH1750FVI_COMMAND_POWER_DOWN; /* set the command */
337  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
338  if (res != 0) /* check error */
339  {
340  handle->debug_print("bh1750fvi: power down failed.\n"); /* power down failed */
341 
342  return 4; /* return error */
343  }
344  res = handle->iic_deinit(); /* iic deinit */
345  if (res != 0) /* check error */
346  {
347  handle->debug_print("bh1750fvi: iic deinit failed.\n"); /* iic deinit failed */
348 
349  return 1; /* return error */
350  }
351  handle->inited = 0; /* flag closed */
352 
353  return 0; /* success return 0 */
354 }
355 
367 {
368  uint8_t res;
369  uint8_t prev;
370 
371  if (handle == NULL) /* check handle */
372  {
373  return 2; /* return error */
374  }
375  if (handle->inited != 1) /* check handle initialization */
376  {
377  return 3; /* return error */
378  }
379 
380  prev = BH1750FVI_COMMAND_POWER_DOWN; /* set the command */
381  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
382  if (res != 0) /* check error */
383  {
384  handle->debug_print("bh1750fvi: power down failed.\n"); /* power down failed */
385 
386  return 1; /* return error */
387  }
388 
389  return 0; /* success return 0 */
390 }
391 
403 {
404  uint8_t res;
405  uint8_t prev;
406 
407  if (handle == NULL) /* check handle */
408  {
409  return 2; /* return error */
410  }
411  if (handle->inited != 1) /* check handle initialization */
412  {
413  return 3; /* return error */
414  }
415 
416  prev = BH1750FVI_COMMAND_POWER_ON; /* set the command */
417  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
418  if (res != 0) /* check error */
419  {
420  handle->debug_print("bh1750fvi: power on failed.\n"); /* power on failed */
421 
422  return 1; /* return error */
423  }
424 
425  return 0; /* success return 0 */
426 }
427 
439 {
440  uint8_t res;
441  uint8_t prev;
442 
443  if (handle == NULL) /* check handle */
444  {
445  return 2; /* return error */
446  }
447  if (handle->inited != 1) /* check handle initialization */
448  {
449  return 3; /* return error */
450  }
451 
452  prev = BH1750FVI_COMMAND_RESET; /* set the command */
453  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
454  if (res != 0) /* check error */
455  {
456  handle->debug_print("bh1750fvi: reset failed.\n"); /* reset failed */
457 
458  return 1; /* return error */
459  }
460 
461  return 0; /* success return 0 */
462 }
463 
477 {
478  uint8_t res;
479  uint8_t prev;
480 
481  if (handle == NULL) /* check handle */
482  {
483  return 2; /* return error */
484  }
485  if (handle->inited != 1) /* check handle initialization */
486  {
487  return 3; /* return error */
488  }
489  if ((t < 31) || (t > 254)) /* check t */
490  {
491  handle->debug_print("bh1750fvi: t < 31 or t > 254.\n"); /* t < 31 or t > 254 */
492 
493  return 4; /* return error */
494  }
495 
496  prev = BH1750FVI_COMMAND_CHANGE_MEASUREMENT_TIME_HIGH | ((t >> 5) & 0x07); /* set the command */
497  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
498  if (res != 0) /* check error */
499  {
500  handle->debug_print("bh1750fvi: set measurement time failed.\n"); /* set measurement time failed */
501 
502  return 1; /* return error */
503  }
504  prev = BH1750FVI_COMMAND_CHANGE_MEASUREMENT_TIME_LOW | ((t >> 0) & 0x1F); /* set the command */
505  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
506  if (res != 0) /* check error */
507  {
508  handle->debug_print("bh1750fvi: set measurement time failed.\n"); /* set measurement time failed */
509 
510  return 1; /* return error */
511  }
512  handle->t = t; /* save the time */
513 
514  return 0; /* success return 0 */
515 }
516 
530 uint8_t bh1750fvi_single_read(bh1750fvi_handle_t *handle, uint16_t *raw, float *lux)
531 {
532  uint8_t res;
533  uint8_t prev;
534  uint8_t buf[2];
535 
536  if (handle == NULL) /* check handle */
537  {
538  return 2; /* return error */
539  }
540  if (handle->inited != 1) /* check handle initialization */
541  {
542  return 3; /* return error */
543  }
544 
545  if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE) /* high resolution mode */
546  {
547  prev = BH1750FVI_COMMAND_ONE_TIME_H_RESOLUTION_MODE; /* high resolution mode command */
548  }
549  else if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE2) /* high resolution mode2 */
550  {
551  prev = BH1750FVI_COMMAND_ONE_TIME_H_RESOLUTION_MODE2; /* high resolution mode2 command */
552  }
553  else if (handle->mode == BH1750FVI_MODE_LOW_RESOLUTION_MODE) /* low resolution mode */
554  {
555  prev = BH1750FVI_COMMAND_ONE_TIME_L_RESOLUTION_MODE; /* low resolution mode command */
556  }
557  else
558  {
559  handle->debug_print("bh1750fvi: mode is invalid.\n"); /* mode is invalid */
560 
561  return 4; /* return error */
562  }
563 
564  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
565  if (res != 0) /* check error */
566  {
567  handle->debug_print("bh1750fvi: set measurement time failed.\n"); /* set measurement time failed */
568 
569  return 1; /* return error */
570  }
571  if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE) /* high resolution mode */
572  {
573  handle->delay_ms((uint32_t)(180.0f * (float)(handle->t) / 69.0f)); /* delay the max time */
574  }
575  else if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE2) /* high resolution mode2 */
576  {
577  handle->delay_ms((uint32_t)(180.0f * (float)(handle->t) / 69.0f)); /* delay the max time */
578  }
579  else /* low resolution mode */
580  {
581  handle->delay_ms((uint32_t)(24.0f * (float)(handle->t) / 69.0f)); /* delay the max time */
582  }
583  res = a_bh1750fvi_iic_read(handle, buf, 2); /* read data */
584  if (res != 0) /* check error */
585  {
586  handle->debug_print("bh1750fvi: read data failed.\n"); /* read data failed */
587 
588  return 1; /* return error */
589  }
590  *raw = (((uint16_t)buf[0]) << 8) | buf[1]; /* get the raw data */
591  if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE) /* high resolution mode */
592  {
593  *lux = (float)(*raw) / 1.2f * (69.0f / ((float)(handle->t))); /* convert */
594  }
595  else if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE2) /* high resolution mode2 */
596  {
597  *lux = (float)(*raw) / 1.2f * (69.0f / ((float)(handle->t))) / 2.0f; /* convert */
598  }
599  else /* low resolution mode */
600  {
601  *lux = (float)(*raw) / 1.2f * (69.0f / ((float)(handle->t))); /* convert */
602  }
603 
604  return 0; /* success return 0 */
605 }
606 
620 uint8_t bh1750fvi_continuous_read(bh1750fvi_handle_t *handle, uint16_t *raw, float *lux)
621 {
622  uint8_t res;
623  uint8_t buf[2];
624 
625  if (handle == NULL) /* check handle */
626  {
627  return 2; /* return error */
628  }
629  if (handle->inited != 1) /* check handle initialization */
630  {
631  return 3; /* return error */
632  }
633 
634  res = a_bh1750fvi_iic_read(handle, buf, 2); /* read data */
635  if (res != 0) /* check error */
636  {
637  handle->debug_print("bh1750fvi: read data failed.\n"); /* read data failed */
638 
639  return 1; /* return error */
640  }
641  *raw = (((uint16_t)buf[0]) << 8) | buf[1]; /* get the raw data */
642  if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE) /* high resolution mode */
643  {
644  *lux = (float)(*raw) / 1.2f * (69.0f / ((float)(handle->t))); /* convert */
645  }
646  else if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE2) /* high resolution mode2 */
647  {
648  *lux = (float)(*raw) / 1.2f * (69.0f / ((float)(handle->t))) / 2.0f; /* convert */
649  }
650  else /* low resolution mode */
651  {
652  *lux = (float)(*raw) / 1.2f * (69.0f / ((float)(handle->t))); /* convert */
653  }
654 
655  return 0; /* success return 0 */
656 }
657 
670 {
671  uint8_t res;
672  uint8_t prev;
673 
674  if (handle == NULL) /* check handle */
675  {
676  return 2; /* return error */
677  }
678  if (handle->inited != 1) /* check handle initialization */
679  {
680  return 3; /* return error */
681  }
682 
683  if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE) /* high resolution mode */
684  {
685  prev = BH1750FVI_COMMAND_CONTINUOUSLY_H_RESOLUTION_MODE; /* high resolution mode command */
686  }
687  else if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE2) /* high resolution mode2 */
688  {
689  prev = BH1750FVI_COMMAND_CONTINUOUSLY_H_RESOLUTION_MODE2; /* high resolution mode2 command */
690  }
691  else if (handle->mode == BH1750FVI_MODE_LOW_RESOLUTION_MODE) /* low resolution mode */
692  {
693  prev = BH1750FVI_COMMAND_CONTINUOUSLY_L_RESOLUTION_MODE; /* low resolution mode command */
694  }
695  else
696  {
697  handle->debug_print("bh1750fvi: mode is invalid.\n"); /* mode is invalid */
698 
699  return 4; /* return error */
700  }
701 
702  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
703  if (res != 0) /* check error */
704  {
705  handle->debug_print("bh1750fvi: set measurement time failed.\n"); /* set measurement time failed */
706 
707  return 1; /* return error */
708  }
709 
710  return 0; /* success return 0 */
711 }
712 
725 {
726  uint8_t res;
727  uint8_t prev;
728 
729  if (handle == NULL) /* check handle */
730  {
731  return 2; /* return error */
732  }
733  if (handle->inited != 1) /* check handle initialization */
734  {
735  return 3; /* return error */
736  }
737 
738  if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE) /* high resolution mode */
739  {
740  prev = BH1750FVI_COMMAND_ONE_TIME_H_RESOLUTION_MODE; /* high resolution mode command */
741  }
742  else if (handle->mode == BH1750FVI_MODE_HIGH_RESOLUTION_MODE2) /* high resolution mode2 */
743  {
744  prev = BH1750FVI_COMMAND_ONE_TIME_H_RESOLUTION_MODE2; /* high resolution mode2 command */
745  }
746  else if (handle->mode == BH1750FVI_MODE_LOW_RESOLUTION_MODE) /* low resolution mode */
747  {
748  prev = BH1750FVI_COMMAND_ONE_TIME_L_RESOLUTION_MODE; /* low resolution mode command */
749  }
750  else
751  {
752  handle->debug_print("bh1750fvi: mode is invalid.\n"); /* mode is invalid */
753 
754  return 4; /* return error */
755  }
756 
757  res = a_bh1750fvi_iic_write(handle, &prev, 1); /* write the command */
758  if (res != 0) /* check error */
759  {
760  handle->debug_print("bh1750fvi: set measurement time failed.\n"); /* set measurement time failed */
761 
762  return 1; /* return error */
763  }
764 
765  return 0; /* success return 0 */
766 }
767 
780 uint8_t bh1750fvi_set_reg(bh1750fvi_handle_t *handle, uint8_t *buf, uint16_t len)
781 {
782  if (handle == NULL) /* check handle */
783  {
784  return 2; /* return error */
785  }
786  if (handle->inited != 1) /* check handle initialization */
787  {
788  return 3; /* return error */
789  }
790 
791  return a_bh1750fvi_iic_write(handle, buf, len); /* write command */
792 }
793 
806 uint8_t bh1750fvi_get_reg(bh1750fvi_handle_t *handle, uint8_t *buf, uint16_t len)
807 {
808  if (handle == NULL) /* check handle */
809  {
810  return 2; /* return error */
811  }
812  if (handle->inited != 1) /* check handle initialization */
813  {
814  return 3; /* return error */
815  }
816 
817  return a_bh1750fvi_iic_read(handle, buf, len); /* read command */
818 }
819 
829 {
830  if (info == NULL) /* check handle */
831  {
832  return 2; /* return error */
833  }
834 
835  memset(info, 0, sizeof(bh1750fvi_info_t)); /* initialize bh1750fvi info structure */
836  strncpy(info->chip_name, CHIP_NAME, 32); /* copy chip name */
837  strncpy(info->manufacturer_name, MANUFACTURER_NAME, 32); /* copy manufacturer name */
838  strncpy(info->interface, "IIC", 8); /* copy interface name */
839  info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; /* set minimal supply voltage */
840  info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; /* set maximum supply voltage */
841  info->max_current_ma = MAX_CURRENT; /* set maximum current */
842  info->temperature_max = TEMPERATURE_MAX; /* set minimal temperature */
843  info->temperature_min = TEMPERATURE_MIN; /* set maximum temperature */
844  info->driver_version = DRIVER_VERSION; /* set driver version */
845 
846  return 0; /* success return 0 */
847 }
#define BH1750FVI_COMMAND_CHANGE_MEASUREMENT_TIME_LOW
#define MAX_CURRENT
#define BH1750FVI_COMMAND_POWER_DOWN
chip command definition
#define BH1750FVI_COMMAND_CHANGE_MEASUREMENT_TIME_HIGH
#define BH1750FVI_COMMAND_CONTINUOUSLY_L_RESOLUTION_MODE
#define BH1750FVI_COMMAND_CONTINUOUSLY_H_RESOLUTION_MODE2
#define BH1750FVI_COMMAND_POWER_ON
#define SUPPLY_VOLTAGE_MAX
#define BH1750FVI_COMMAND_CONTINUOUSLY_H_RESOLUTION_MODE
#define TEMPERATURE_MAX
#define BH1750FVI_COMMAND_ONE_TIME_L_RESOLUTION_MODE
#define BH1750FVI_COMMAND_RESET
#define BH1750FVI_COMMAND_ONE_TIME_H_RESOLUTION_MODE2
#define MANUFACTURER_NAME
#define TEMPERATURE_MIN
#define SUPPLY_VOLTAGE_MIN
#define BH1750FVI_COMMAND_ONE_TIME_H_RESOLUTION_MODE
#define CHIP_NAME
chip information definition
#define DRIVER_VERSION
driver bh1750fvi header file
uint8_t bh1750fvi_stop_continuous_read(bh1750fvi_handle_t *handle)
stop chip reading
uint8_t bh1750fvi_reset(bh1750fvi_handle_t *handle)
reset
uint8_t bh1750fvi_single_read(bh1750fvi_handle_t *handle, uint16_t *raw, float *lux)
read data from the chip once
uint8_t bh1750fvi_get_addr_pin(bh1750fvi_handle_t *handle, bh1750fvi_address_t *addr_pin)
get the address pin
uint8_t bh1750fvi_deinit(bh1750fvi_handle_t *handle)
close the chip
uint8_t bh1750fvi_start_continuous_read(bh1750fvi_handle_t *handle)
start chip reading
uint8_t bh1750fvi_set_measurement_time(bh1750fvi_handle_t *handle, uint8_t t)
set the measurement time
uint8_t bh1750fvi_continuous_read(bh1750fvi_handle_t *handle, uint16_t *raw, float *lux)
read data from the chip continuously
uint8_t bh1750fvi_set_addr_pin(bh1750fvi_handle_t *handle, bh1750fvi_address_t addr_pin)
set the address pin
uint8_t bh1750fvi_info(bh1750fvi_info_t *info)
get chip's information
uint8_t bh1750fvi_power_down(bh1750fvi_handle_t *handle)
power down
bh1750fvi_mode_t
bh1750fvi mode enumeration definition
uint8_t bh1750fvi_power_on(bh1750fvi_handle_t *handle)
power on
uint8_t bh1750fvi_init(bh1750fvi_handle_t *handle)
initialize the chip
bh1750fvi_address_t
bh1750fvi address enumeration definition
uint8_t bh1750fvi_get_mode(bh1750fvi_handle_t *handle, bh1750fvi_mode_t *mode)
get the mode
uint8_t bh1750fvi_set_mode(bh1750fvi_handle_t *handle, bh1750fvi_mode_t mode)
set the mode
@ BH1750FVI_MODE_HIGH_RESOLUTION_MODE
@ BH1750FVI_MODE_LOW_RESOLUTION_MODE
@ BH1750FVI_MODE_HIGH_RESOLUTION_MODE2
uint8_t bh1750fvi_get_reg(bh1750fvi_handle_t *handle, uint8_t *buf, uint16_t len)
get the chip register
uint8_t bh1750fvi_set_reg(bh1750fvi_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
bh1750fvi handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
uint8_t(* iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
bh1750fvi information structure definition
char manufacturer_name[32]