eeram3v3  2.0.0.0
eeram3v3.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 
27 // ----------------------------------------------------------------------------
28 
29 #ifndef EERAM3V3_H
30 #define EERAM3V3_H
31 
32 #ifdef __cplusplus
33 extern "C"{
34 #endif
35 
36 #include "mikrosdk_version.h"
37 
38 #ifdef __GNUC__
39 #if mikroSDK_GET_VERSION < 20800ul
40 #include "rcu_delays.h"
41 #else
42 #include "delays.h"
43 #endif
44 #endif
45 
46 #include "drv_digital_out.h"
47 #include "drv_digital_in.h"
48 #include "drv_i2c_master.h"
49 
70 #define EERAM3V3_ADDRESS_SRAM 0x50
71 #define EERAM3V3_ADDRESS_CONTROL 0x18
72 #define EERAM3V3_CMD_STORE 0x33
73 #define EERAM3V3_CMD_RECALL 0xDD
74  // eeram3v3_const
76 
91 #define EERAM3V3_MAP_MIKROBUS( cfg, mikrobus ) \
92  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
93  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
94  cfg.hs = MIKROBUS( mikrobus, MIKROBUS_INT )
95  // eeram3v3_map // eeram3v3
98 
103 typedef struct
104 {
105 
106  digital_out_t hs;
108  // Modules
109 
110  i2c_master_t i2c;
112  // I2C slave address
113 
114  uint8_t slave_address;
116 } eeram3v3_t;
117 
122 typedef struct
123 {
124  pin_name_t scl;
125  pin_name_t sda;
127  pin_name_t hs;
129  uint32_t i2c_speed;
130  uint8_t i2c_address;
133 
138 typedef enum
139 {
141  EERAM3V3_ERROR = -1
142 
144 
162 
179 
196 void eeram3v3_generic_write ( eeram3v3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
197 
214 void eeram3v3_generic_read ( eeram3v3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
215 
226 void eeram3v3_status_write ( eeram3v3_t *ctx, uint8_t command );
227 
237 
250 void eeram3v3_read ( eeram3v3_t *ctx, uint16_t address, uint8_t *data_out, uint8_t count_out );
251 
263  void eeram3v3_write ( eeram3v3_t *ctx, uint16_t address, uint8_t * data_in, uint8_t count_in );
264 
265 #ifdef __cplusplus
266 }
267 #endif
268 #endif // EERAM3V3_H
269  // eeram3v3
271 
272 // ------------------------------------------------------------------------ END
EERAM3V3_ERROR
@ EERAM3V3_ERROR
Definition: eeram3v3.h:141
eeram3v3_cfg_t::scl
pin_name_t scl
Definition: eeram3v3.h:124
eeram3v3_status_read
uint8_t eeram3v3_status_read(eeram3v3_t *ctx)
EERAM Click Status Read.
eeram3v3_generic_read
void eeram3v3_generic_read(eeram3v3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
EERAM 3v3 I2C reading function.
eeram3v3_cfg_t::hs
pin_name_t hs
Definition: eeram3v3.h:127
eeram3v3_t::i2c
i2c_master_t i2c
Definition: eeram3v3.h:110
eeram3v3_read
void eeram3v3_read(eeram3v3_t *ctx, uint16_t address, uint8_t *data_out, uint8_t count_out)
EERAM Click SRAM Read.
eeram3v3_generic_write
void eeram3v3_generic_write(eeram3v3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
EERAM 3v3 I2C writing function.
eeram3v3_cfg_t::i2c_address
uint8_t i2c_address
Definition: eeram3v3.h:130
eeram3v3_init
err_t eeram3v3_init(eeram3v3_t *ctx, eeram3v3_cfg_t *cfg)
EERAM 3v3 initialization function.
eeram3v3_cfg_t
EERAM 3v3 Click configuration object.
Definition: eeram3v3.h:123
eeram3v3_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: eeram3v3.h:129
eeram3v3_status_write
void eeram3v3_status_write(eeram3v3_t *ctx, uint8_t command)
EERAM 3v3 Click Status Write.
EERAM3V3_OK
@ EERAM3V3_OK
Definition: eeram3v3.h:140
eeram3v3_t
EERAM 3v3 Click context object.
Definition: eeram3v3.h:104
eeram3v3_cfg_setup
void eeram3v3_cfg_setup(eeram3v3_cfg_t *cfg)
EERAM 3v3 configuration object setup function.
eeram3v3_t::hs
digital_out_t hs
Definition: eeram3v3.h:106
eeram3v3_t::slave_address
uint8_t slave_address
Definition: eeram3v3.h:114
eeram3v3_cfg_t::sda
pin_name_t sda
Definition: eeram3v3.h:125
eeram3v3_return_value_t
eeram3v3_return_value_t
EERAM 3v3 Click return value data.
Definition: eeram3v3.h:139
eeram3v3_write
void eeram3v3_write(eeram3v3_t *ctx, uint16_t address, uint8_t *data_in, uint8_t count_in)
EERAM Click SRAM Write.