llci2c 2.0.0.0
llcspi.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef LLCSPI_H
36#define LLCSPI_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
68#define LLCSPI_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
70 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
71 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
72 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
79#define LLCSPI_RETVAL uint8_t
80
81#define LLCSPI_OK 0x00
82#define LLCSPI_INIT_ERROR 0xFF
89#define NULL 0
92 // End group macro
93// --------------------------------------------------------------- PUBLIC TYPES
102typedef struct
103{
104 // Modules
105
106 spi_master_t spi;
107
108} llcspi_t;
109
113typedef struct
114{
115 // Communication gpio pins
116
117 pin_name_t miso;
118 pin_name_t mosi;
119 pin_name_t sck;
120 pin_name_t cs;
121
122 // static variable
123
124 hal_spi_speed_t spi_speed;
125 hal_spi_mode_t spi_mode;
126
128
129 // End types group
130// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
131
136#ifdef __cplusplus
137extern "C"{
138#endif
139
149
158
167void llcspi_generic_transfer ( llcspi_t *ctx, spi_master_transfer_data_t *block );
168
175void spillc_set_cs_pin ( llcspi_t *ctx, uint8_t state);
176
189void spillc_generic_write ( llcspi_t *ctx, uint8_t *p_buf, uint16_t n_bytes );
190
203void spillc_generic_read ( llcspi_t *ctx, uint8_t *p_buf, uint16_t n_bytes );
204
205#ifdef __cplusplus
206}
207#endif
208#endif // _LLCSPI_H_
209
210 // End public_function group
212
213// ------------------------------------------------------------------------- END
#define LLCSPI_RETVAL
Definition llcspi.h:79
void spillc_set_cs_pin(llcspi_t *ctx, uint8_t state)
Function for set CS pin state.
void spillc_generic_write(llcspi_t *ctx, uint8_t *p_buf, uint16_t n_bytes)
LLC SPI write.
void llcspi_generic_transfer(llcspi_t *ctx, spi_master_transfer_data_t *block)
Generic transfer function.
void llcspi_cfg_setup(llcspi_cfg_t *cfg)
Config Object Initialization function.
void spillc_generic_read(llcspi_t *ctx, uint8_t *p_buf, uint16_t n_bytes)
LLC SPI read.
LLCSPI_RETVAL llcspi_init(llcspi_t *ctx, llcspi_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition llcspi.h:114
pin_name_t sck
Definition llcspi.h:119
hal_spi_mode_t spi_mode
Definition llcspi.h:125
pin_name_t mosi
Definition llcspi.h:118
pin_name_t miso
Definition llcspi.h:117
hal_spi_speed_t spi_speed
Definition llcspi.h:124
pin_name_t cs
Definition llcspi.h:120
Click ctx object definition.
Definition llcspi.h:103
spi_master_t spi
Definition llcspi.h:106