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 
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 
58 #define SWIEEPROM_OP_CODE_EEPROM 0xA0
59 #define SWIEEPROM_OP_CODE_SECURITY 0xB0
60 #define SWIEEPROM_OP_CODE_LOCK 0x20
61 #define SWIEEPROM_OP_CODE_ROM 0x70
62 #define SWIEEPROM_OP_CODE_FREEZE_ROM 0x10
63 #define SWIEEPROM_OP_CODE_ID 0xC0
64 #define SWIEEPROM_OP_CODE_STDN_SPEED 0xD0
65 #define SWIEEPROM_OP_CODE_HIGH_SPEED 0xE0
66 
76 #define SWIEEPROM_DEVICE_ID 0x00D200
77  // swieeprom_set // swieeprom
80 
81 
86 typedef err_t ( *drv_reset_t ) ( void );
87 typedef void ( *drv_set_t ) ( void );
88 typedef uint8_t ( *drv_get_t ) ( void );
89 
94 typedef struct
95 {
96  uint8_t slave_address;
104 } swieeprom_t;
105 
110 typedef enum
111 {
113  SWIEEPROM_ERROR = -1
114 
116 
135 
147 
160 err_t swieeprom_mem_write ( swieeprom_t *ctx, uint8_t start_addr, uint8_t data_in );
161 
175 err_t swieeprom_mem_write_page ( swieeprom_t *ctx, uint8_t start_addr, uint8_t *data_in, uint8_t len );
176 
190 err_t swieeprom_mem_read ( swieeprom_t *ctx, uint8_t start_addr, uint8_t *data_out, uint8_t len );
191 
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 #endif // SWIEEPROM_H
208  // swieeprom
210 
211 // ------------------------------------------------------------------------ END
SWIEEPROM_OK
@ SWIEEPROM_OK
Definition: swieeprom.h:112
swieeprom_t::swi_logic_read
drv_get_t swi_logic_read
Definition: swieeprom.h:102
swieeprom_t::swi_logic_0
drv_set_t swi_logic_0
Definition: swieeprom.h:100
swieeprom_t::slave_address
uint8_t slave_address
Definition: swieeprom.h:96
drv_get_t
uint8_t(* drv_get_t)(void)
Definition: swieeprom.h:88
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:101
drv_reset_t
err_t(* drv_reset_t)(void)
Function pointers for gpio settings.
Definition: swieeprom.h:86
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:95
swieeprom_t::swi_reset
drv_reset_t swi_reset
Definition: swieeprom.h:98
swieeprom_t::swi_start_stop
drv_set_t swi_start_stop
Definition: swieeprom.h:99
swieeprom_return_value_t
swieeprom_return_value_t
SWI EEPROM Click return value data.
Definition: swieeprom.h:111
drv_set_t
void(* drv_set_t)(void)
Definition: swieeprom.h:87
swieeprom_check_communication
err_t swieeprom_check_communication(swieeprom_t *ctx)
SWI EEPROM check communication function.
SWIEEPROM_ERROR
@ SWIEEPROM_ERROR
Definition: swieeprom.h:113