swieeprom  2.1.0.0
swieeprom.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 SWIEEPROM_H
29 #define SWIEEPROM_H
30 
31 #ifdef __cplusplus
32 extern "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 
62 #define SWIEEPROM_OP_CODE_EEPROM 0xA0
63 #define SWIEEPROM_OP_CODE_SECURITY 0xB0
64 #define SWIEEPROM_OP_CODE_LOCK 0x20
65 #define SWIEEPROM_OP_CODE_ROM 0x70
66 #define SWIEEPROM_OP_CODE_FREEZE_ROM 0x10
67 #define SWIEEPROM_OP_CODE_ID 0xC0
68 #define SWIEEPROM_OP_CODE_STDN_SPEED 0xD0
69 #define SWIEEPROM_OP_CODE_HIGH_SPEED 0xE0
70 
80 #define SWIEEPROM_DEVICE_ID 0x00D200
81  // swieeprom_set // swieeprom
84 
85 
90 typedef err_t ( *drv_reset_t ) ( void );
91 typedef void ( *drv_set_t ) ( void );
92 typedef uint8_t ( *drv_get_t ) ( void );
93 
98 typedef struct
99 {
100  uint8_t slave_address;
108 } swieeprom_t;
109 
114 typedef enum
115 {
117  SWIEEPROM_ERROR = -1
118 
120 
139 
151 
164 err_t swieeprom_mem_write ( swieeprom_t *ctx, uint8_t start_addr, uint8_t data_in );
165 
179 err_t swieeprom_mem_write_page ( swieeprom_t *ctx, uint8_t start_addr, uint8_t *data_in, uint8_t len );
180 
194 err_t swieeprom_mem_read ( swieeprom_t *ctx, uint8_t start_addr, uint8_t *data_out, uint8_t len );
195 
207 
208 #ifdef __cplusplus
209 }
210 #endif
211 #endif // SWIEEPROM_H
212  // swieeprom
214 
215 // ------------------------------------------------------------------------ END
SWIEEPROM_OK
@ SWIEEPROM_OK
Definition: swieeprom.h:116
swieeprom_t::swi_logic_read
drv_get_t swi_logic_read
Definition: swieeprom.h:106
swieeprom_t::swi_logic_0
drv_set_t swi_logic_0
Definition: swieeprom.h:104
swieeprom_t::slave_address
uint8_t slave_address
Definition: swieeprom.h:100
drv_get_t
uint8_t(* drv_get_t)(void)
Definition: swieeprom.h:92
swieeprom_mem_write
err_t swieeprom_mem_write(swieeprom_t *ctx, uint8_t start_addr, uint8_t data_in)
SWI EEPROM memory write function.
swieeprom_t::swi_logic_1
drv_set_t swi_logic_1
Definition: swieeprom.h:105
drv_reset_t
err_t(* drv_reset_t)(void)
Function pointers for gpio settings.
Definition: swieeprom.h:90
swieeprom_mem_write_page
err_t swieeprom_mem_write_page(swieeprom_t *ctx, uint8_t start_addr, uint8_t *data_in, uint8_t len)
SWI EEPROM memory write page function.
swieeprom_mem_read
err_t swieeprom_mem_read(swieeprom_t *ctx, uint8_t start_addr, uint8_t *data_out, uint8_t len)
SWI EEPROM memory read function.
swieeprom_init
err_t swieeprom_init(swieeprom_t *ctx)
SWI EEPROM initialization function.
swieeprom_mem_clear
err_t swieeprom_mem_clear(swieeprom_t *ctx)
SWI EEPROM memory clear function.
swieeprom_t
SWI EEPROM Click context object.
Definition: swieeprom.h:99
swieeprom_t::swi_reset
drv_reset_t swi_reset
Definition: swieeprom.h:102
swieeprom_t::swi_start_stop
drv_set_t swi_start_stop
Definition: swieeprom.h:103
swieeprom_return_value_t
swieeprom_return_value_t
SWI EEPROM Click return value data.
Definition: swieeprom.h:115
drv_set_t
void(* drv_set_t)(void)
Definition: swieeprom.h:91
swieeprom_check_communication
err_t swieeprom_check_communication(swieeprom_t *ctx)
SWI EEPROM check communication function.
SWIEEPROM_ERROR
@ SWIEEPROM_ERROR
Definition: swieeprom.h:117