expand4 2.0.0.0
expand4.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 EXPAND4_H
36#define EXPAND4_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_spi_master.h"
41
42// -------------------------------------------------------------- PUBLIC MACROS
53#define EXPAND4_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
55 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
56 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
57 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58 cfg.clr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
59 cfg.en = MIKROBUS( mikrobus, MIKROBUS_PWM )
66#define EXPAND4_RETVAL uint8_t
67
68#define EXPAND4_OK 0x00
69#define EXPAND4_INIT_ERROR 0xFF
76#define EXPAND4_D0 0x01
77#define EXPAND4_D1 0x02
78#define EXPAND4_D2 0x04
79#define EXPAND4_D3 0x08
80#define EXPAND4_D4 0x10
81#define EXPAND4_D5 0x20
82#define EXPAND4_D6 0x40
83#define EXPAND4_D7 0x80 // End group macro
87// --------------------------------------------------------------- PUBLIC TYPES
96typedef struct
97{
98 // Output pins
99
100 digital_out_t cs;
101 digital_out_t clr;
102 digital_out_t en;
103
104 // Modules
105
106 spi_master_t spi;
107 pin_name_t chip_select;
108
109} expand4_t;
110
114typedef struct
115{
116 // Communication gpio pins
117
118 pin_name_t miso;
119 pin_name_t mosi;
120 pin_name_t sck;
121 pin_name_t cs;
122
123 // Additional gpio pins
124
125 pin_name_t clr;
126 pin_name_t en;
127
128 // static variable
129
130 uint32_t spi_speed;
131 spi_master_mode_t spi_mode;
132 spi_master_chip_select_polarity_t cs_polarity;
133
135 // End types group
137
138// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
139
144#ifdef __cplusplus
145extern "C"{
146#endif
147
157
167
176
185
194
203void expand4_write_data ( expand4_t *ctx, uint8_t write_command );
204
221void expand4_turn_on_by_position ( expand4_t *ctx, uint8_t position );
222
223#ifdef __cplusplus
224}
225#endif
226#endif // _EXPAND4_H_
227 // End public_function group
230
231// ------------------------------------------------------------------------- END
#define EXPAND4_RETVAL
Definition: expand4.h:66
EXPAND4_RETVAL expand4_init(expand4_t *ctx, expand4_cfg_t *cfg)
Initialization function.
void expand4_turn_on_by_position(expand4_t *ctx, uint8_t position)
void expand4_cfg_setup(expand4_cfg_t *cfg)
Config Object Initialization function.
void expand4_write_data(expand4_t *ctx, uint8_t write_command)
void expand4_enable_output(expand4_t *ctx)
Enable output function.
void expand4_reset(expand4_t *ctx)
Clear register function.
void expand4_disable_output(expand4_t *ctx)
Disable output function.
Click configuration structure definition.
Definition: expand4.h:115
pin_name_t clr
Definition: expand4.h:125
spi_master_chip_select_polarity_t cs_polarity
Definition: expand4.h:132
pin_name_t sck
Definition: expand4.h:120
spi_master_mode_t spi_mode
Definition: expand4.h:131
pin_name_t mosi
Definition: expand4.h:119
uint32_t spi_speed
Definition: expand4.h:130
pin_name_t en
Definition: expand4.h:126
pin_name_t miso
Definition: expand4.h:118
pin_name_t cs
Definition: expand4.h:121
Click ctx object definition.
Definition: expand4.h:97
digital_out_t cs
Definition: expand4.h:100
spi_master_t spi
Definition: expand4.h:106
digital_out_t en
Definition: expand4.h:102
digital_out_t clr
Definition: expand4.h:101
pin_name_t chip_select
Definition: expand4.h:107