shuttle 2.0.0.0
shuttle.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 SHUTTLE_H
36#define SHUTTLE_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
54// -------------------------------------------------------------- PUBLIC MACROS
64#define SHUTTLE_MAP_MIKROBUS( cfg, mikrobus ) \
65 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
66 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
67 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
68 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
69 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT ); \
70 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
71 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
72 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
73 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
74 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
75 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
76 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_TX )
83#define SHUTTLE_RETVAL uint8_t
84
85#define SHUTTLE_OK 0x00
86#define SHUTTLE_INIT_ERROR 0xFF
89 // End group macro
90// --------------------------------------------------------------- PUBLIC TYPES
99typedef struct
100{
101 // Communication pins
102
103 digital_out_t scl;
104 digital_out_t sda;
105 digital_out_t sck;
106 digital_out_t miso;
107 digital_out_t mosi;
108 digital_out_t cs;
109 digital_out_t tx_pin;
110 digital_out_t rx_pin;
111
112 // Gpio pins
113
114 digital_out_t an;
115 digital_out_t rst;
116 digital_out_t pwm;
117 digital_out_t int_pin;
118
119} shuttle_t;
120
124typedef struct
125{
126 // Communication pins
127
128 pin_name_t scl;
129 pin_name_t sda;
130 pin_name_t sck;
131 pin_name_t miso;
132 pin_name_t mosi;
133 pin_name_t cs;
134 pin_name_t tx_pin;
135 pin_name_t rx_pin;
136
137 // Gpio pins
138
139 pin_name_t an;
140 pin_name_t rst;
141 pin_name_t pwm;
142 pin_name_t int_pin;
143
145
146 // End types group
147// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
148
154#ifdef __cplusplus
155extern "C"{
156#endif
157
167
176
186void shuttle_set_pin_high ( digital_out_t *pin );
187
197void shuttle_set_pin_low ( digital_out_t *pin );
198
199#ifdef __cplusplus
200}
201#endif
202#endif // _SHUTTLE_H_
203
204 // End public_function group
206
207// ------------------------------------------------------------------------- END
#define SHUTTLE_RETVAL
Definition shuttle.h:83
void shuttle_cfg_setup(shuttle_cfg_t *cfg)
Config Object Initialization function.
void shuttle_set_pin_high(digital_out_t *pin)
Set pin high function.
SHUTTLE_RETVAL shuttle_init(shuttle_t *ctx, shuttle_cfg_t *cfg)
Initialization function.
void shuttle_set_pin_low(digital_out_t *pin)
Set pin low function.
Click configuration structure definition.
Definition shuttle.h:125
pin_name_t sck
Definition shuttle.h:130
pin_name_t tx_pin
Definition shuttle.h:134
pin_name_t mosi
Definition shuttle.h:132
pin_name_t rx_pin
Definition shuttle.h:135
pin_name_t scl
Definition shuttle.h:128
pin_name_t int_pin
Definition shuttle.h:142
pin_name_t pwm
Definition shuttle.h:141
pin_name_t miso
Definition shuttle.h:131
pin_name_t sda
Definition shuttle.h:129
pin_name_t rst
Definition shuttle.h:140
pin_name_t an
Definition shuttle.h:139
pin_name_t cs
Definition shuttle.h:133
Click ctx object definition.
Definition shuttle.h:100
digital_out_t cs
Definition shuttle.h:108
digital_out_t sck
Definition shuttle.h:105
digital_out_t mosi
Definition shuttle.h:107
digital_out_t pwm
Definition shuttle.h:116
digital_out_t sda
Definition shuttle.h:104
digital_out_t int_pin
Definition shuttle.h:117
digital_out_t rst
Definition shuttle.h:115
digital_out_t rx_pin
Definition shuttle.h:110
digital_out_t scl
Definition shuttle.h:103
digital_out_t tx_pin
Definition shuttle.h:109
digital_out_t miso
Definition shuttle.h:106
digital_out_t an
Definition shuttle.h:114