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
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
73#define FRAM5_MIN_ADDRESS 0x00000
74#define FRAM5_MAX_ADDRESS 0x1FFFF
75
80#define FRAM5_SLAVE_ID 0x7C
81
86#define FRAM5_MANUFACTURER_ID_DENSITY 0x44
87
93#define FRAM5_DEVICE_ADDRESS_A2A1_00 0x50
94#define FRAM5_DEVICE_ADDRESS_A2A1_01 0x52
95#define FRAM5_DEVICE_ADDRESS_A2A1_10 0x54
96#define FRAM5_DEVICE_ADDRESS_A2A1_11 0x56
97
98 // fram5_set
99
114#define FRAM5_MAP_MIKROBUS( cfg, mikrobus ) \
115 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
116 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
117 cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM );
118
119 // fram5_map
120 // fram5
121
126typedef struct
127{
128 // Output pins
129 digital_out_t wp;
131 // Modules
132 i2c_master_t i2c;
134 // I2C slave address
137} fram5_t;
138
143typedef struct
144{
145 pin_name_t scl;
146 pin_name_t sda;
148 pin_name_t wp;
150 uint32_t i2c_speed;
151 uint8_t i2c_address;
154
159typedef enum
160{
162 FRAM5_ERROR = -1
163
165
182
196err_t fram5_init ( fram5_t *ctx, fram5_cfg_t *cfg );
197
212err_t fram5_memory_write ( fram5_t *ctx, uint32_t address, uint8_t *data_in, uint8_t len );
213
228err_t fram5_memory_read ( fram5_t *ctx, uint32_t address, uint8_t *data_out, uint8_t len );
229
241
251
261
262#ifdef __cplusplus
263}
264#endif
265#endif // FRAM5_H
266
267 // fram5
268
269// ------------------------------------------------------------------------ END
fram5_return_value_t
FRAM 5 Click return value data.
Definition fram5.h:160
@ FRAM5_OK
Definition fram5.h:161
@ FRAM5_ERROR
Definition fram5.h:162
err_t fram5_memory_read(fram5_t *ctx, uint32_t address, uint8_t *data_out, uint8_t len)
FRAM 5 memory read function.
err_t fram5_check_communication(fram5_t *ctx)
FRAM 5 check communication function.
void fram5_write_protect(fram5_t *ctx)
FRAM 5 write protect function.
void fram5_cfg_setup(fram5_cfg_t *cfg)
FRAM 5 configuration object setup function.
err_t fram5_init(fram5_t *ctx, fram5_cfg_t *cfg)
FRAM 5 initialization function.
err_t fram5_memory_write(fram5_t *ctx, uint32_t address, uint8_t *data_in, uint8_t len)
FRAM 5 memory write function.
void fram5_write_enable(fram5_t *ctx)
FRAM 5 write enable function.
FRAM 5 Click configuration object.
Definition fram5.h:144
uint32_t i2c_speed
Definition fram5.h:150
pin_name_t wp
Definition fram5.h:148
pin_name_t scl
Definition fram5.h:145
pin_name_t sda
Definition fram5.h:146
uint8_t i2c_address
Definition fram5.h:151
FRAM 5 Click context object.
Definition fram5.h:127
i2c_master_t i2c
Definition fram5.h:132
uint8_t slave_address
Definition fram5.h:135
digital_out_t wp
Definition fram5.h:129