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 "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define FRAM5_MIN_ADDRESS 0x00000
70 #define FRAM5_MAX_ADDRESS 0x1FFFF
71 
76 #define FRAM5_SLAVE_ID 0x7C
77 
82 #define FRAM5_MANUFACTURER_ID_DENSITY 0x44
83 
89 #define FRAM5_DEVICE_ADDRESS_A2A1_00 0x50
90 #define FRAM5_DEVICE_ADDRESS_A2A1_01 0x52
91 #define FRAM5_DEVICE_ADDRESS_A2A1_10 0x54
92 #define FRAM5_DEVICE_ADDRESS_A2A1_11 0x56
93  // fram5_set
95 
110 #define FRAM5_MAP_MIKROBUS( cfg, mikrobus ) \
111  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
112  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
113  cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM );
114  // fram5_map // fram5
117 
122 typedef struct
123 {
124  // Output pins
125  digital_out_t wp;
127  // Modules
128  i2c_master_t i2c;
130  // I2C slave address
131  uint8_t slave_address;
133 } fram5_t;
134 
139 typedef struct
140 {
141  pin_name_t scl;
142  pin_name_t sda;
144  pin_name_t wp;
146  uint32_t i2c_speed;
147  uint8_t i2c_address;
149 } fram5_cfg_t;
150 
155 typedef enum
156 {
157  FRAM5_OK = 0,
158  FRAM5_ERROR = -1
159 
161 
178 
192 err_t fram5_init ( fram5_t *ctx, fram5_cfg_t *cfg );
193 
208 err_t fram5_memory_write ( fram5_t *ctx, uint32_t address, uint8_t *data_in, uint8_t len );
209 
224 err_t fram5_memory_read ( fram5_t *ctx, uint32_t address, uint8_t *data_out, uint8_t len );
225 
237 
247 
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 #endif // FRAM5_H
262  // fram5
264 
265 // ------------------------------------------------------------------------ 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:140
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:142
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:131
fram5_t::wp
digital_out_t wp
Definition: fram5.h:125
fram5_cfg_t::wp
pin_name_t wp
Definition: fram5.h:144
fram5_t::i2c
i2c_master_t i2c
Definition: fram5.h:128
fram5_write_enable
void fram5_write_enable(fram5_t *ctx)
FRAM 5 write enable function.
FRAM5_ERROR
@ FRAM5_ERROR
Definition: fram5.h:158
fram5_cfg_t::i2c_address
uint8_t i2c_address
Definition: fram5.h:147
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:146
fram5_t
FRAM 5 Click context object.
Definition: fram5.h:123
fram5_init
err_t fram5_init(fram5_t *ctx, fram5_cfg_t *cfg)
FRAM 5 initialization function.
FRAM5_OK
@ FRAM5_OK
Definition: fram5.h:157
fram5_return_value_t
fram5_return_value_t
FRAM 5 Click return value data.
Definition: fram5.h:156
fram5_cfg_t::scl
pin_name_t scl
Definition: fram5.h:141