timerrelay 2.1.0.0
timerrelay.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 TIMERRELAY_H
29#define TIMERRELAY_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_spi_master.h"
38#include "spi_specifics.h"
39
61#define TIMERRELAY_PIN_STATE_HIGH 0x01
62#define TIMERRELAY_PIN_STATE_LOW 0x00
63
68#define TIMERRELAY_MAX_DELAY 60
69#define TIMERRELAY_CALCULATION_MULTIPLIER 0.2353f
70
71
80#define TIMERRELAY_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
81#define TIMERRELAY_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
82 // timerrelay_set
84
99#define TIMERRELAY_MAP_MIKROBUS( cfg, mikrobus ) \
100 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
101 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
102 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
103 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
104 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
105 cfg.trg = MIKROBUS( mikrobus, MIKROBUS_INT )
106 // timerrelay_map // timerrelay
109
114typedef struct
115{
116 // Output pins
117 digital_out_t rst;
118 digital_out_t trg;
120 // Modules
121 spi_master_t spi;
123 pin_name_t chip_select;
126
131typedef struct
132{
133 // Communication gpio pins
134 pin_name_t miso;
135 pin_name_t mosi;
136 pin_name_t sck;
137 pin_name_t cs;
139 // Additional gpio pins
140 pin_name_t rst;
141 pin_name_t trg;
143 // static variable
144 uint32_t spi_speed;
145 spi_master_mode_t spi_mode;
146 spi_master_chip_select_polarity_t cs_polarity;
149
154typedef enum
155{
158
160
177
192
206
221err_t timerrelay_generic_write ( timerrelay_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
222
233err_t timerrelay_set_wiper_pos ( timerrelay_t *ctx, uint8_t wiper_pos );
234
246err_t timerrelay_set_delay ( timerrelay_t *ctx, uint8_t delay );
247
258void timerrelay_set_rst_pin ( timerrelay_t *ctx, uint8_t pin_state );
259
270void timerrelay_set_trg_pin ( timerrelay_t *ctx, uint8_t pin_state );
271
282
293
294#ifdef __cplusplus
295}
296#endif
297#endif // TIMERRELAY_H
298 // timerrelay
300
301// ------------------------------------------------------------------------ END
void timerrelay_activate_trigger(timerrelay_t *ctx)
Timer Relay activate trigger function.
void timerrelay_cfg_setup(timerrelay_cfg_t *cfg)
Timer Relay configuration object setup function.
err_t timerrelay_generic_write(timerrelay_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Timer Relay data writing function.
void timerrelay_set_trg_pin(timerrelay_t *ctx, uint8_t pin_state)
Timer Relay set TRG pin state function.
void timerrelay_activate_reset(timerrelay_t *ctx)
Timer Relay reset timer function.
err_t timerrelay_set_wiper_pos(timerrelay_t *ctx, uint8_t wiper_pos)
Timer Relay set wiper position function.
err_t timerrelay_init(timerrelay_t *ctx, timerrelay_cfg_t *cfg)
Timer Relay initialization function.
err_t timerrelay_default_cfg(timerrelay_t *ctx)
Timer Relay default configuration function.
err_t timerrelay_set_delay(timerrelay_t *ctx, uint8_t delay)
Timer Relay set delay function.
void timerrelay_set_rst_pin(timerrelay_t *ctx, uint8_t pin_state)
Timer Relay set RST pin state function.
This file contains SPI specific macros, functions, etc.
Timer Relay Click configuration object.
Definition: timerrelay.h:132
spi_master_chip_select_polarity_t cs_polarity
Definition: timerrelay.h:146
pin_name_t sck
Definition: timerrelay.h:136
spi_master_mode_t spi_mode
Definition: timerrelay.h:145
pin_name_t mosi
Definition: timerrelay.h:135
uint32_t spi_speed
Definition: timerrelay.h:144
pin_name_t trg
Definition: timerrelay.h:141
pin_name_t miso
Definition: timerrelay.h:134
pin_name_t rst
Definition: timerrelay.h:140
pin_name_t cs
Definition: timerrelay.h:137
Timer Relay Click context object.
Definition: timerrelay.h:115
spi_master_t spi
Definition: timerrelay.h:121
digital_out_t trg
Definition: timerrelay.h:118
digital_out_t rst
Definition: timerrelay.h:117
pin_name_t chip_select
Definition: timerrelay.h:123
timerrelay_return_value_t
Timer Relay Click return value data.
Definition: timerrelay.h:155
@ TIMERRELAY_ERROR
Definition: timerrelay.h:157
@ TIMERRELAY_OK
Definition: timerrelay.h:156