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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 
48 #define SWIEEPROM_OP_CODE_EEPROM 0xA0
49 #define SWIEEPROM_OP_CODE_SECURITY 0xB0
50 #define SWIEEPROM_OP_CODE_LOCK 0x20
51 #define SWIEEPROM_OP_CODE_ROM 0x70
52 #define SWIEEPROM_OP_CODE_FREEZE_ROM 0x10
53 #define SWIEEPROM_OP_CODE_ID 0xC0
54 #define SWIEEPROM_OP_CODE_STDN_SPEED 0xD0
55 #define SWIEEPROM_OP_CODE_HIGH_SPEED 0xE0
56 
66 #define SWIEEPROM_DEVICE_ID 0x00D200
67  // swieeprom_set // swieeprom
70 
71 
76 typedef err_t ( *drv_reset_t ) ( void );
77 typedef void ( *drv_set_t ) ( void );
78 typedef uint8_t ( *drv_get_t ) ( void );
79 
84 typedef struct
85 {
86  uint8_t slave_address;
94 } swieeprom_t;
95 
100 typedef enum
101 {
103  SWIEEPROM_ERROR = -1
104 
106 
125 
137 
150 err_t swieeprom_mem_write ( swieeprom_t *ctx, uint8_t start_addr, uint8_t data_in );
151 
165 err_t swieeprom_mem_write_page ( swieeprom_t *ctx, uint8_t start_addr, uint8_t *data_in, uint8_t len );
166 
180 err_t swieeprom_mem_read ( swieeprom_t *ctx, uint8_t start_addr, uint8_t *data_out, uint8_t len );
181 
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 #endif // SWIEEPROM_H
198  // swieeprom
200 
201 // ------------------------------------------------------------------------ END
SWIEEPROM_OK
@ SWIEEPROM_OK
Definition: swieeprom.h:102
swieeprom_t::swi_logic_read
drv_get_t swi_logic_read
Definition: swieeprom.h:92
swieeprom_t::swi_logic_0
drv_set_t swi_logic_0
Definition: swieeprom.h:90
swieeprom_t::slave_address
uint8_t slave_address
Definition: swieeprom.h:86
drv_get_t
uint8_t(* drv_get_t)(void)
Definition: swieeprom.h:78
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:91
drv_reset_t
err_t(* drv_reset_t)(void)
Function pointers for gpio settings.
Definition: swieeprom.h:76
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:85
swieeprom_t::swi_reset
drv_reset_t swi_reset
Definition: swieeprom.h:88
swieeprom_t::swi_start_stop
drv_set_t swi_start_stop
Definition: swieeprom.h:89
swieeprom_return_value_t
swieeprom_return_value_t
SWI EEPROM Click return value data.
Definition: swieeprom.h:101
drv_set_t
void(* drv_set_t)(void)
Definition: swieeprom.h:77
swieeprom_check_communication
err_t swieeprom_check_communication(swieeprom_t *ctx)
SWI EEPROM check communication function.
SWIEEPROM_ERROR
@ SWIEEPROM_ERROR
Definition: swieeprom.h:103