alphanumg2 2.1.0.0
alphanumg2.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 ALPHANUMG2_H
29#define ALPHANUMG2_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
52#include "spi_specifics.h"
53
74#define ALPHANUMG2_NIBBLE_LOW 0x000Fu
75#define ALPHANUMG2_BYTE_LOW 0x00FFu
76#define ALPHANUMG2_WORD_BIT_POS_0 0x0001u
77#define ALPHANUMG2_WORD_BIT_POS_14 0x4000u
78#define ALPHANUMG2_WORD_BIT_POS_15 0x8000u
79
84#define ALPHANUMG2_BRIGHTNESS_MIN 0x0000u
85#define ALPHANUMG2_BRIGHTNESS_MAX 0x0FFFu
86
91#define ALPHANUMG2_DEFAULT_DUR_1000_MS 1000
92
101#define ALPHANUMG2_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
102#define ALPHANUMG2_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
103
104 // alphanumg2_set
105
120#define ALPHANUMG2_MAP_MIKROBUS( cfg, mikrobus ) \
121 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
122 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
123 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
124 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
125 cfg.blk = MIKROBUS( mikrobus, MIKROBUS_AN ); \
126 cfg.ca1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
127 cfg.ca2 = MIKROBUS( mikrobus, MIKROBUS_INT )
128
129 // alphanumg2_map
130 // alphanumg2
131
136typedef struct
137{
138 // Output pins
139 digital_out_t blk;
140 digital_out_t ca1;
141 digital_out_t ca2;
143 // Modules
144 spi_master_t spi;
146 pin_name_t chip_select;
148 uint16_t char_duration;
151
156typedef struct
157{
158 // Communication gpio pins
159 pin_name_t miso;
160 pin_name_t mosi;
161 pin_name_t sck;
162 pin_name_t cs;
164 // Additional gpio pins
165 pin_name_t blk;
166 pin_name_t ca1;
167 pin_name_t ca2;
169 // static variable
170 uint32_t spi_speed;
171 spi_master_mode_t spi_mode;
172 spi_master_chip_select_polarity_t cs_polarity;
175
186
197
214
229
243
258err_t alphanumg2_generic_write ( alphanumg2_t *ctx, uint8_t *data_in, uint8_t len );
259
274err_t alphanumg2_generic_read ( alphanumg2_t *ctx, uint8_t *data_out, uint8_t len );
275
285void alphanumg2_set_char_duration ( alphanumg2_t *ctx, uint16_t duration_ms );
286
298
311
323
335
347
359
380err_t alphanumg2_set_led_output ( alphanumg2_t *ctx, uint16_t seg_bit_mask,
381 alphanumg2_dot_t seg_dot, uint16_t brightness );
382
399err_t alphanumg2_display_character ( alphanumg2_t *ctx, uint8_t left_char, uint16_t left_brightness,
400 uint8_t right_char, uint16_t right_brightness );
401
402#ifdef __cplusplus
403}
404#endif
405#endif // ALPHANUMG2_H
406
407 // alphanumg2
408
409// ------------------------------------------------------------------------ END
alphanumg2_dot_t
AlphaNum G 2 Click dot symbol value data.
Definition alphanumg2.h:192
@ ALPHANUMG2_NO_DOT
Definition alphanumg2.h:193
@ ALPHANUMG2_SET_DOT
Definition alphanumg2.h:194
alphanumg2_return_value_t
AlphaNum G 2 Click return value data.
Definition alphanumg2.h:181
@ ALPHANUMG2_ERROR
Definition alphanumg2.h:183
@ ALPHANUMG2_OK
Definition alphanumg2.h:182
void alphanumg2_set_seg_left_off(alphanumg2_t *ctx)
AlphaNum G 2 set segment left OFF function.
err_t alphanumg2_default_cfg(alphanumg2_t *ctx)
AlphaNum G 2 default configuration function.
err_t alphanumg2_generic_read(alphanumg2_t *ctx, uint8_t *data_out, uint8_t len)
AlphaNum G 2 data reading function.
err_t alphanumg2_init(alphanumg2_t *ctx, alphanumg2_cfg_t *cfg)
AlphaNum G 2 initialization function.
void alphanumg2_cfg_setup(alphanumg2_cfg_t *cfg)
AlphaNum G 2 configuration object setup function.
void alphanumg2_set_seg_right_off(alphanumg2_t *ctx)
AlphaNum G 2 set segment right OFF function.
void alphanumg2_set_outputs_on(alphanumg2_t *ctx)
AlphaNum G 2 set outputs ON function.
void alphanumg2_set_outputs_off(alphanumg2_t *ctx)
AlphaNum G 2 set outputs OFF function.
void alphanumg2_set_seg_right_on(alphanumg2_t *ctx)
AlphaNum G 2 set segment right ON function.
err_t alphanumg2_set_led_output(alphanumg2_t *ctx, uint16_t seg_bit_mask, alphanumg2_dot_t seg_dot, uint16_t brightness)
AlphaNum G 2 set LED output function.
void alphanumg2_set_char_duration(alphanumg2_t *ctx, uint16_t duration_ms)
AlphaNum G 2 set character duration function.
void alphanumg2_set_seg_left_on(alphanumg2_t *ctx)
AlphaNum G 2 set segment left ON function.
err_t alphanumg2_generic_write(alphanumg2_t *ctx, uint8_t *data_in, uint8_t len)
AlphaNum G 2 data writing function.
err_t alphanumg2_display_character(alphanumg2_t *ctx, uint8_t left_char, uint16_t left_brightness, uint8_t right_char, uint16_t right_brightness)
AlphaNum G 2 display character function.
This file contains SPI specific macros, functions, etc.
AlphaNum G 2 Click configuration object.
Definition alphanumg2.h:157
spi_master_chip_select_polarity_t cs_polarity
Definition alphanumg2.h:172
pin_name_t sck
Definition alphanumg2.h:161
pin_name_t ca2
Definition alphanumg2.h:167
pin_name_t ca1
Definition alphanumg2.h:166
spi_master_mode_t spi_mode
Definition alphanumg2.h:171
pin_name_t blk
Definition alphanumg2.h:165
pin_name_t mosi
Definition alphanumg2.h:160
uint32_t spi_speed
Definition alphanumg2.h:170
pin_name_t miso
Definition alphanumg2.h:159
pin_name_t cs
Definition alphanumg2.h:162
AlphaNum G 2 Click context object.
Definition alphanumg2.h:137
spi_master_t spi
Definition alphanumg2.h:144
uint16_t char_duration
Definition alphanumg2.h:148
digital_out_t blk
Definition alphanumg2.h:139
digital_out_t ca2
Definition alphanumg2.h:141
pin_name_t chip_select
Definition alphanumg2.h:146
digital_out_t ca1
Definition alphanumg2.h:140