tester  2.0.0.0
tester.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef TESTER_H
36 #define TESTER_H
37 
38 #include "drv_digital_out.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
50 #define TESTER_MAP_MIKROBUS( cfg, mikrobus ) \
51  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
52  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
53  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
54  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
55  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT ); \
56  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
57  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
58  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
59  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
60  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
61  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
62  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_TX )
63 
70 #define TESTER_RETVAL uint8_t
71 
72 #define TESTER_OK 0x00
73 #define TESTER_INIT_ERROR 0xFF
74  // End group macro
77 // --------------------------------------------------------------- PUBLIC TYPES
86 typedef struct
87 {
88  // Communication pins
89 
90  digital_out_t scl;
91  digital_out_t sda;
92  digital_out_t sck;
93  digital_out_t miso;
94  digital_out_t mosi;
95  digital_out_t cs;
96  digital_out_t tx_pin;
97  digital_out_t rx_pin;
98 
99  // Gpio pins
100 
101  digital_out_t an;
102  digital_out_t rst;
103  digital_out_t pwm;
104  digital_out_t int_pin;
105 
106 } tester_t;
107 
111 typedef struct
112 {
113  // Communication pins
114 
115  pin_name_t scl;
116  pin_name_t sda;
117  pin_name_t sck;
118  pin_name_t miso;
119  pin_name_t mosi;
120  pin_name_t cs;
121  pin_name_t tx_pin;
122  pin_name_t rx_pin;
123 
124  // Gpio pins
125 
126  pin_name_t an;
127  pin_name_t rst;
128  pin_name_t pwm;
129  pin_name_t int_pin;
130 
131 } tester_cfg_t;
132  // End types group
134 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
135 
141 #ifdef __cplusplus
142 extern "C"{
143 #endif
144 
153 void tester_cfg_setup ( tester_cfg_t *cfg );
154 
163 
173 void tester_set_pin_high ( digital_out_t *pin );
174 
184 void tester_set_pin_low ( digital_out_t *pin );
185 
186 #ifdef __cplusplus
187 }
188 #endif
189 #endif // _TESTER_H_
190  // End public_function group
193 
194 // ------------------------------------------------------------------------- END
pin_name_t rst
Definition: tester.h:127
void tester_set_pin_low(digital_out_t *pin)
Set pin low function.
digital_out_t rst
Definition: tester.h:102
pin_name_t int_pin
Definition: tester.h:129
pin_name_t pwm
Definition: tester.h:128
Click configuration structure definition.
Definition: tester.h:111
digital_out_t tx_pin
Definition: tester.h:96
pin_name_t scl
Definition: tester.h:115
Click ctx object definition.
Definition: tester.h:86
pin_name_t miso
Definition: tester.h:118
digital_out_t rx_pin
Definition: tester.h:97
digital_out_t sck
Definition: tester.h:92
void tester_cfg_setup(tester_cfg_t *cfg)
Config Object Initialization function.
digital_out_t cs
Definition: tester.h:95
pin_name_t cs
Definition: tester.h:120
digital_out_t scl
Definition: tester.h:90
#define TESTER_RETVAL
Definition: tester.h:70
digital_out_t pwm
Definition: tester.h:103
digital_out_t sda
Definition: tester.h:91
digital_out_t an
Definition: tester.h:101
digital_out_t miso
Definition: tester.h:93
pin_name_t rx_pin
Definition: tester.h:122
void tester_set_pin_high(digital_out_t *pin)
Set pin high function.
pin_name_t mosi
Definition: tester.h:119
pin_name_t sck
Definition: tester.h:117
TESTER_RETVAL tester_init(tester_t *ctx, tester_cfg_t *cfg)
Initialization function.
digital_out_t mosi
Definition: tester.h:94
digital_out_t int_pin
Definition: tester.h:104
pin_name_t tx_pin
Definition: tester.h:121
pin_name_t sda
Definition: tester.h:116
pin_name_t an
Definition: tester.h:126