ambient20 2.1.0.0
ambient20.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef AMBIENT20_H
29#define AMBIENT20_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
38
59#define AMBIENT20_SYSTEM_CONTROL_REG 0x40
60#define AMBIENT20_MODE_CONTROL1_REG 0x41
61#define AMBIENT20_MODE_CONTROL2_REG 0x42
62#define AMBIENT20_MODE_CONTROL3_REG 0x43
63#define AMBIENT20_DATA0_LSB_REG 0x50
64#define AMBIENT20_DATA0_MSB_REG 0x51
65#define AMBIENT20_DATA1_LSB_REG 0x52
66#define AMBIENT20_DATA1_MSB_REG 0x53
67#define AMBIENT20_MANUFACTURER_ID_REG 0x92
68 // ambient20_reg
70
85#define AMBIENT20_GAIN_X1 0x02
86#define AMBIENT20_GAIN_X32 0x0A
87#define AMBIENT20_GAIN_X128 0x0C
88#define AMBIENT20_100mS_MODE 0x00
89#define AMBIENT20_55mS_MODE 0x01
90#define AMBIENT20_VALID_MASK 0x80
91#define AMBIENT20_ENABLE 0x01
92#define AMBIENT20_DISABLE 0x00
93#define AMBIENT20_MANUFACTURER_ID 0xE0
94#define AMBIENT20_PART_ID 0x12
95#define AMBIENT20_PART_ID_MASK 0x3F
96
102#define AMBIENT20_DEVICE_ADDRESS 0x38
103 // ambient20_set
105
120#define AMBIENT20_MAP_MIKROBUS( cfg, mikrobus ) \
121 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
122 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
123 // ambient20_map // ambient20
126
131typedef struct
132{
133 // Modules
134 i2c_master_t i2c;
136 // I2C slave address
140
145typedef struct
146{
147 pin_name_t scl;
148 pin_name_t sda;
150 uint32_t i2c_speed;
151 uint8_t i2c_address;
154
159typedef enum
160{
162 AMBIENT20_ERROR = -1
163
165
182
197
211
226err_t ambient20_generic_write ( ambient20_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
227
242err_t ambient20_generic_read ( ambient20_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
243
256
269err_t ambient20_get_manufacturer_id ( ambient20_t *ctx, uint8_t *manufacturer_id );
270
283err_t ambient20_get_part_id ( ambient20_t *ctx, uint8_t *part_id );
284
297
310
323err_t ambient20_set_meas_mode ( ambient20_t *ctx, uint8_t meas_mode );
324
338err_t ambient20_set_gain ( ambient20_t *ctx, uint8_t data0_gain, uint8_t data1_gain );
339
351
363
376
387err_t ambient20_read_data0 ( ambient20_t *ctx, uint16_t *data0_out );
388
399err_t ambient20_read_data1 ( ambient20_t *ctx, uint16_t *data1_out );
400
401#ifdef __cplusplus
402}
403#endif
404#endif // AMBIENT20_H
405 // ambient20
407
408// ------------------------------------------------------------------------ END
ambient20_return_value_t
Ambient 20 Click return value data.
Definition: ambient20.h:160
@ AMBIENT20_OK
Definition: ambient20.h:161
@ AMBIENT20_ERROR
Definition: ambient20.h:162
err_t ambient20_default_cfg(ambient20_t *ctx)
Ambient 20 default configuration function.
err_t ambient20_generic_read(ambient20_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Ambient 20 I2C reading function.
err_t ambient20_get_manufacturer_id(ambient20_t *ctx, uint8_t *manufacturer_id)
Ambient 20 read manufacturer id function.
void ambient20_cfg_setup(ambient20_cfg_t *cfg)
Ambient 20 configuration object setup function.
err_t ambient20_get_part_id(ambient20_t *ctx, uint8_t *part_id)
Ambient 20 read part id function.
err_t ambient20_enable_wait_mode(ambient20_t *ctx)
Ambient 20 enable wait mode function.
err_t ambient20_generic_write(ambient20_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Ambient 20 I2C writing function.
err_t ambient20_enable_meas(ambient20_t *ctx)
Ambient 20 enable measurements function.
err_t ambient20_set_gain(ambient20_t *ctx, uint8_t data0_gain, uint8_t data1_gain)
Ambient 20 set data gain function.
err_t ambient20_set_meas_mode(ambient20_t *ctx, uint8_t meas_mode)
Ambient 20 set measurement mode function.
err_t ambient20_disable_meas(ambient20_t *ctx)
Ambient 20 disable measurements function.
err_t ambient20_disable_wait_mode(ambient20_t *ctx)
Ambient 20 disable wait mode function.
err_t ambient20_init(ambient20_t *ctx, ambient20_cfg_t *cfg)
Ambient 20 initialization function.
err_t ambient20_check_valid(ambient20_t *ctx)
Ambient 20 check valid bit function.
err_t ambient20_read_data1(ambient20_t *ctx, uint16_t *data1_out)
Ambient 20 read data1 function.
err_t ambient20_sw_reset(ambient20_t *ctx)
Ambient 20 software reset function.
err_t ambient20_read_data0(ambient20_t *ctx, uint16_t *data0_out)
Ambient 20 read data0 function.
Ambient 20 Click configuration object.
Definition: ambient20.h:146
uint32_t i2c_speed
Definition: ambient20.h:150
pin_name_t scl
Definition: ambient20.h:147
pin_name_t sda
Definition: ambient20.h:148
uint8_t i2c_address
Definition: ambient20.h:151
Ambient 20 Click context object.
Definition: ambient20.h:132
i2c_master_t i2c
Definition: ambient20.h:134
uint8_t slave_address
Definition: ambient20.h:137