swieeprom  2.0.0.7
swi.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 ****************************************************************************/
27 #ifndef SWI_
28 #define SWI_
29 
30 #include "stdint.h"
31 
36 typedef enum
37 {
41 
46 typedef enum
47 {
48  SWI_ACK = 0,
49  SWI_NACK = 1
51 
56 typedef enum
57 {
59  SWI_LOGIC_1 = 1
61 
71 int8_t swi_init ( void );
72 
79 int8_t swi_reset ( void );
80 
87 void swi_start ( void );
88 
95 void swi_stop ( void );
96 
105 void swi_logic_write ( swi_logic_lvl_t logic_level );
106 
114 uint8_t swi_logic_read ( void );
115 
124 uint8_t swi_send_byte ( uint8_t byte_to_send );
125 
135 void swi_receive_byte ( uint8_t *byte_to_receive, swi_acknowledgement_t ack_nack );
136 
137 #endif
138 
139 
140 // ------------------------------------------------------------------------ END
SWI_ACK
Definition: swi.h:47
SWI_NACK
Definition: swi.h:48
swi_logic_read
uint8_t swi_logic_read(void)
Receive logic signal from device.
Definition: swi.c:124
swi_logic_lvl_t
swi_logic_lvl_t
SWI driver logic values.
Definition: swi.h:55
swi_acknowledgement_t
swi_acknowledgement_t
SWI driver acknowledgement values.
Definition: swi.h:45
swi_logic_write
void swi_logic_write(swi_logic_lvl_t logic_level)
Send logic signal to device.
Definition: swi.c:106
SWI_LOGIC_1
Definition: swi.h:58
swi_stop
void swi_stop(void)
Send stop SWI signal.
Definition: swi.c:100
swi_reset
int8_t swi_reset(void)
Resets device and checks devices response.
Definition: swi.c:79
swi_receive_byte
void swi_receive_byte(uint8_t *byte_to_receive, swi_acknowledgement_t ack_nack)
Receive byte from device.
Definition: swi.c:152
swi_return_value_t
swi_return_value_t
SWI driver return values data.
Definition: swi.h:35
swi_send_byte
uint8_t swi_send_byte(uint8_t byte_to_send)
Send byte to device.
Definition: swi.c:135
SWI_RET_VAL_ERROR
Definition: swi.h:38
SWI_RET_VAL_OK
Definition: swi.h:37
swi_start
void swi_start(void)
Send start SWI signal.
Definition: swi.c:94
SWI_LOGIC_0
Definition: swi.h:57
swi_init
int8_t swi_init(void)
Initializes SWI communication.
Definition: swi.c:67