fram5  2.0.0.0
fram5.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 FRAM5_H
29 #define FRAM5_H
30 
31 #ifdef __cplusplus
32 extern "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 FRAM5_MIN_ADDRESS 0x00000
60 #define FRAM5_MAX_ADDRESS 0x1FFFF
61 
66 #define FRAM5_SLAVE_ID 0x7C
67 
72 #define FRAM5_MANUFACTURER_ID_DENSITY 0x44
73 
79 #define FRAM5_DEVICE_ADDRESS_A2A1_00 0x50
80 #define FRAM5_DEVICE_ADDRESS_A2A1_01 0x52
81 #define FRAM5_DEVICE_ADDRESS_A2A1_10 0x54
82 #define FRAM5_DEVICE_ADDRESS_A2A1_11 0x56
83  // fram5_set
85 
100 #define FRAM5_MAP_MIKROBUS( cfg, mikrobus ) \
101  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
102  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
103  cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM );
104  // fram5_map // fram5
107 
112 typedef struct
113 {
114  // Output pins
115  digital_out_t wp;
117  // Modules
118  i2c_master_t i2c;
120  // I2C slave address
121  uint8_t slave_address;
123 } fram5_t;
124 
129 typedef struct
130 {
131  pin_name_t scl;
132  pin_name_t sda;
134  pin_name_t wp;
136  uint32_t i2c_speed;
137  uint8_t i2c_address;
139 } fram5_cfg_t;
140 
145 typedef enum
146 {
147  FRAM5_OK = 0,
148  FRAM5_ERROR = -1
149 
151 
168 
182 err_t fram5_init ( fram5_t *ctx, fram5_cfg_t *cfg );
183 
198 err_t fram5_memory_write ( fram5_t *ctx, uint32_t address, uint8_t *data_in, uint8_t len );
199 
214 err_t fram5_memory_read ( fram5_t *ctx, uint32_t address, uint8_t *data_out, uint8_t len );
215 
227 
237 
247 
248 #ifdef __cplusplus
249 }
250 #endif
251 #endif // FRAM5_H
252  // fram5
254 
255 // ------------------------------------------------------------------------ END
fram5_memory_write
err_t fram5_memory_write(fram5_t *ctx, uint32_t address, uint8_t *data_in, uint8_t len)
FRAM 5 memory write function.
fram5_cfg_t
FRAM 5 Click configuration object.
Definition: fram5.h:130
fram5_write_protect
void fram5_write_protect(fram5_t *ctx)
FRAM 5 write protect function.
fram5_cfg_t::sda
pin_name_t sda
Definition: fram5.h:132
fram5_cfg_setup
void fram5_cfg_setup(fram5_cfg_t *cfg)
FRAM 5 configuration object setup function.
fram5_t::slave_address
uint8_t slave_address
Definition: fram5.h:121
fram5_t::wp
digital_out_t wp
Definition: fram5.h:115
fram5_cfg_t::wp
pin_name_t wp
Definition: fram5.h:134
fram5_t::i2c
i2c_master_t i2c
Definition: fram5.h:118
fram5_write_enable
void fram5_write_enable(fram5_t *ctx)
FRAM 5 write enable function.
FRAM5_ERROR
@ FRAM5_ERROR
Definition: fram5.h:148
fram5_cfg_t::i2c_address
uint8_t i2c_address
Definition: fram5.h:137
fram5_check_communication
err_t fram5_check_communication(fram5_t *ctx)
FRAM 5 check communication function.
fram5_memory_read
err_t fram5_memory_read(fram5_t *ctx, uint32_t address, uint8_t *data_out, uint8_t len)
FRAM 5 memory read function.
fram5_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: fram5.h:136
fram5_t
FRAM 5 Click context object.
Definition: fram5.h:113
fram5_init
err_t fram5_init(fram5_t *ctx, fram5_cfg_t *cfg)
FRAM 5 initialization function.
FRAM5_OK
@ FRAM5_OK
Definition: fram5.h:147
fram5_return_value_t
fram5_return_value_t
FRAM 5 Click return value data.
Definition: fram5.h:146
fram5_cfg_t::scl
pin_name_t scl
Definition: fram5.h:131