monoZ docs
MZ_Addon_Si1133.c File Reference
#include "MZ_Addon_Si1133.h"
#include "MZ_error_handler.h"
#include "stm32l4xx_hal.h"
#include "MZ_Addon_board_Si1133_i2c.h"

Go to the source code of this file.

Macros

#define X_ORDER_MASK   0x0070
 
#define Y_ORDER_MASK   0x0007
 
#define SIGN_MASK   0x0080
 
#define GET_X_ORDER(m)   ( ((m) & X_ORDER_MASK) >> 4)
 
#define GET_Y_ORDER(m)   ( ((m) & Y_ORDER_MASK) )
 
#define GET_SIGN(m)   ( ((m) & SIGN_MASK) >> 7)
 
#define UV_INPUT_FRACTION   15
 
#define UV_OUTPUT_FRACTION   12
 
#define UV_NUMCOEFF   2
 
#define ADC_THRESHOLD   16000
 
#define INPUT_FRACTION_HIGH   7
 
#define INPUT_FRACTION_LOW   15
 
#define LUX_OUTPUT_FRACTION   12
 
#define NUMCOEFF_LOW   9
 
#define NUMCOEFF_HIGH   4
 
#define UV_I2C_SEND(ADDRESS, LEN, TIME)   MZ_I2C_Master_Transmit(MZ_ADDONUV_I2C_INSTANCE,SLAVE_ADD,(uint8_t *) ADDRESS,LEN,TIME)
 
#define UV_I2C_GET(ADDRESS, LEN, TIME)   MZ_I2C_Master_Receive(MZ_ADDONUV_I2C_INSTANCE,SLAVE_ADD,(uint8_t *) ADDRESS,LEN,TIME)
 
#define SI1133_CONFIRM_COUNT   (5)
 

Functions

static Si1133_error SI1133_Write_Reg (Si1133_register w_addr, uint8_t data)
 
static Si1133_error SI1133_Write_Reg_block (Si1133_register w_addr, uint8_t len, uint8_t *data)
 
static Si1133_error SI1133_Read_Reg (Si1133_register r_addr, uint8_t *buf)
 
static Si1133_error SI1133_Read_Reg_block (Si1133_register r_addr, uint8_t len, uint8_t *buf)
 
static Si1133_error SI1133_reset (void)
 
static Si1133_error SI1133_wait_until_sleep (void)
 
static Si1133_error SI1133_send_cmd (Si1133_command command)
 
static Si1133_error SI1133_force_measurement (void)
 
static Si1133_error SI1133_pause_measurement (void)
 
static Si1133_error SI1133_set_parameter (Si1133_parameter address, uint8_t value)
 
static int32_t SI1133_calculate_polynomial_helper (int32_t input, int8_t fraction, uint16_t mag, int8_t shift)
 
static int32_t SI1133_calculate_polynomial (int32_t x, int32_t y, uint8_t input_fraction, uint8_t output_fraction, uint8_t num_coeff, const Si1133_coeff *kp)
 
static int32_t SI1133_get_uv (int32_t uv)
 
static int32_t SI1133_get_lux (int32_t vis_high, int32_t vis_low, int32_t ir)
 
Si1133_error SI1133_init (void)
 
Si1133_error SI1133_deinit (void)
 
static Si1133_error SI1133_measure (Si1133_samples *_s1)
 
Si1133_error SI1133_get_hardware_id (uint8_t *hardware_id)
 
Si1133_error SI1133_measure_lux_uv (float *lux, float *uvi)
 
Si1133_error SI1133_get_measurement (float *lux, float *uvi)
 
float SI1133_get_light_level (void)
 
float SI1133_get_uv_index (void)
 

Variables

const Si1133_LuxCoeff Si1133_lk
 
const Si1133_coeff Si1133_uk [2]
 

Macro Definition Documentation

◆ X_ORDER_MASK

#define X_ORDER_MASK   0x0070

Definition at line 18 of file MZ_Addon_Si1133.c.

◆ Y_ORDER_MASK

#define Y_ORDER_MASK   0x0007

Definition at line 19 of file MZ_Addon_Si1133.c.

◆ SIGN_MASK

#define SIGN_MASK   0x0080

Definition at line 20 of file MZ_Addon_Si1133.c.

◆ GET_X_ORDER

#define GET_X_ORDER (   m)    ( ((m) & X_ORDER_MASK) >> 4)

Definition at line 21 of file MZ_Addon_Si1133.c.

◆ GET_Y_ORDER

#define GET_Y_ORDER (   m)    ( ((m) & Y_ORDER_MASK) )

Definition at line 22 of file MZ_Addon_Si1133.c.

◆ GET_SIGN

#define GET_SIGN (   m)    ( ((m) & SIGN_MASK) >> 7)

Definition at line 23 of file MZ_Addon_Si1133.c.

◆ UV_INPUT_FRACTION

#define UV_INPUT_FRACTION   15

Definition at line 25 of file MZ_Addon_Si1133.c.

◆ UV_OUTPUT_FRACTION

#define UV_OUTPUT_FRACTION   12

Definition at line 26 of file MZ_Addon_Si1133.c.

◆ UV_NUMCOEFF

#define UV_NUMCOEFF   2

Definition at line 27 of file MZ_Addon_Si1133.c.

◆ ADC_THRESHOLD

#define ADC_THRESHOLD   16000

Definition at line 29 of file MZ_Addon_Si1133.c.

◆ INPUT_FRACTION_HIGH

#define INPUT_FRACTION_HIGH   7

Definition at line 30 of file MZ_Addon_Si1133.c.

◆ INPUT_FRACTION_LOW

#define INPUT_FRACTION_LOW   15

Definition at line 31 of file MZ_Addon_Si1133.c.

◆ LUX_OUTPUT_FRACTION

#define LUX_OUTPUT_FRACTION   12

Definition at line 32 of file MZ_Addon_Si1133.c.

◆ NUMCOEFF_LOW

#define NUMCOEFF_LOW   9

Definition at line 33 of file MZ_Addon_Si1133.c.

◆ NUMCOEFF_HIGH

#define NUMCOEFF_HIGH   4

Definition at line 34 of file MZ_Addon_Si1133.c.

◆ UV_I2C_SEND

#define UV_I2C_SEND (   ADDRESS,
  LEN,
  TIME 
)    MZ_I2C_Master_Transmit(MZ_ADDONUV_I2C_INSTANCE,SLAVE_ADD,(uint8_t *) ADDRESS,LEN,TIME)

Definition at line 37 of file MZ_Addon_Si1133.c.

◆ UV_I2C_GET

#define UV_I2C_GET (   ADDRESS,
  LEN,
  TIME 
)    MZ_I2C_Master_Receive(MZ_ADDONUV_I2C_INSTANCE,SLAVE_ADD,(uint8_t *) ADDRESS,LEN,TIME)

Definition at line 38 of file MZ_Addon_Si1133.c.

◆ SI1133_CONFIRM_COUNT

#define SI1133_CONFIRM_COUNT   (5)

Definition at line 39 of file MZ_Addon_Si1133.c.

Function Documentation

◆ SI1133_Write_Reg()

static Si1133_error SI1133_Write_Reg ( Si1133_register  w_addr,
uint8_t  data 
)
static

Definition at line 73 of file MZ_Addon_Si1133.c.

◆ SI1133_Write_Reg_block()

static Si1133_error SI1133_Write_Reg_block ( Si1133_register  w_addr,
uint8_t  len,
uint8_t *  data 
)
static

Definition at line 87 of file MZ_Addon_Si1133.c.

◆ SI1133_Read_Reg()

static Si1133_error SI1133_Read_Reg ( Si1133_register  r_addr,
uint8_t *  buf 
)
static

Definition at line 106 of file MZ_Addon_Si1133.c.

◆ SI1133_Read_Reg_block()

static Si1133_error SI1133_Read_Reg_block ( Si1133_register  r_addr,
uint8_t  len,
uint8_t *  buf 
)
static

Definition at line 123 of file MZ_Addon_Si1133.c.

◆ SI1133_reset()

static Si1133_error SI1133_reset ( void  )
static

Definition at line 139 of file MZ_Addon_Si1133.c.

◆ SI1133_wait_until_sleep()

static Si1133_error SI1133_wait_until_sleep ( void  )
static

Definition at line 158 of file MZ_Addon_Si1133.c.

◆ SI1133_send_cmd()

static Si1133_error SI1133_send_cmd ( Si1133_command  command)
static

Definition at line 184 of file MZ_Addon_Si1133.c.

◆ SI1133_force_measurement()

static Si1133_error SI1133_force_measurement ( void  )
static

Definition at line 261 of file MZ_Addon_Si1133.c.

◆ SI1133_pause_measurement()

static Si1133_error SI1133_pause_measurement ( void  )
static

Definition at line 271 of file MZ_Addon_Si1133.c.

◆ SI1133_set_parameter()

static Si1133_error SI1133_set_parameter ( Si1133_parameter  address,
uint8_t  value 
)
static

Definition at line 276 of file MZ_Addon_Si1133.c.

◆ SI1133_calculate_polynomial_helper()

static int32_t SI1133_calculate_polynomial_helper ( int32_t  input,
int8_t  fraction,
uint16_t  mag,
int8_t  shift 
)
static

Definition at line 322 of file MZ_Addon_Si1133.c.

◆ SI1133_calculate_polynomial()

static int32_t SI1133_calculate_polynomial ( int32_t  x,
int32_t  y,
uint8_t  input_fraction,
uint8_t  output_fraction,
uint8_t  num_coeff,
const Si1133_coeff kp 
)
static

Definition at line 338 of file MZ_Addon_Si1133.c.

◆ SI1133_get_uv()

static int32_t SI1133_get_uv ( int32_t  uv)
static

Definition at line 408 of file MZ_Addon_Si1133.c.

◆ SI1133_get_lux()

static int32_t SI1133_get_lux ( int32_t  vis_high,
int32_t  vis_low,
int32_t  ir 
)
static

Definition at line 417 of file MZ_Addon_Si1133.c.

◆ SI1133_init()

Si1133_error SI1133_init ( void  )

Definition at line 444 of file MZ_Addon_Si1133.c.

◆ SI1133_deinit()

Si1133_error SI1133_deinit ( void  )

Definition at line 474 of file MZ_Addon_Si1133.c.

◆ SI1133_measure()

static Si1133_error SI1133_measure ( Si1133_samples _s1)
static

Definition at line 485 of file MZ_Addon_Si1133.c.

◆ SI1133_get_hardware_id()

Si1133_error SI1133_get_hardware_id ( uint8_t *  hardware_id)

Definition at line 529 of file MZ_Addon_Si1133.c.

◆ SI1133_measure_lux_uv()

Si1133_error SI1133_measure_lux_uv ( float *  lux,
float *  uvi 
)

Definition at line 534 of file MZ_Addon_Si1133.c.

◆ SI1133_get_measurement()

Si1133_error SI1133_get_measurement ( float *  lux,
float *  uvi 
)

Definition at line 569 of file MZ_Addon_Si1133.c.

◆ SI1133_get_light_level()

float SI1133_get_light_level ( void  )

Definition at line 588 of file MZ_Addon_Si1133.c.

◆ SI1133_get_uv_index()

float SI1133_get_uv_index ( void  )

Definition at line 595 of file MZ_Addon_Si1133.c.

Variable Documentation

◆ Si1133_lk

const Si1133_LuxCoeff Si1133_lk
Initial value:
=
{
{ { 0, 209 },
{ 1665, 93 },
{ 2064, 65 },
{ -2671, 234 } },
{ { 0, 0 },
{ 1921, 29053 },
{ -1022, 36363 },
{ 2320, 20789 },
{ -367, 57909 },
{ -1774, 38240 },
{ -608, 46775 },
{ -1503, 51831 },
{ -1886, 58928 } }
}

Definition at line 45 of file MZ_Addon_Si1133.c.

◆ Si1133_uk

const Si1133_coeff Si1133_uk[2]
Initial value:
=
{
{ 1281, 30902 },
{ -638, 46301 }
}

Definition at line 67 of file MZ_Addon_Si1133.c.