alphanumg  2.0.0.0
alphanumg.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 ALPHANUMG_H
29 #define ALPHANUMG_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_spi_master.h"
48 
69 #define ALPHANUMG_MAP_MIKROBUS( cfg, mikrobus ) \
70  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
71  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
72  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
73  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
74  cfg.le2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
75  cfg.ns1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
76  cfg.ns = MIKROBUS( mikrobus, MIKROBUS_INT )
77  // alphanumg_map // alphanumg
80 
85 typedef struct
86 {
87  // Output pins
88  digital_out_t le2;
89  digital_out_t ns1;
90  digital_out_t ns;
91 
92  // Modules
93  spi_master_t spi;
95  pin_name_t chip_select;
97  uint16_t display_speed;
98 } alphanumg_t;
99 
104 typedef struct
105 {
106  // Communication gpio pins
107  pin_name_t miso;
108  pin_name_t mosi;
109  pin_name_t sck;
110  pin_name_t cs;
112  // Additional gpio pins
113  pin_name_t le2;
114  pin_name_t ns1;
115  pin_name_t ns;
116 
117  // static variable
118  uint32_t spi_speed;
119  spi_master_mode_t spi_mode;
120  spi_master_chip_select_polarity_t cs_polarity;
123 
128 typedef enum
129 {
131  ALPHANUMG_ERROR = -1
132 
134 
151 
167 
177 void alphanumg_set_display_interval ( alphanumg_t *ctx, uint16_t delay_char_display );
178 
189 void alphanumg_display_write ( alphanumg_t *ctx, uint16_t left_char, uint16_t right_char );
190 
201 void alphanumg_write_character ( alphanumg_t *ctx, uint8_t left_char, uint8_t right_char );
202 
213 void alphanumg_write_number ( alphanumg_t *ctx, uint8_t left_char, uint8_t right_char );
214 
224 
234 
244 
254 
264 
274 
275 #ifdef __cplusplus
276 }
277 #endif
278 #endif // ALPHANUMG_H
279  // alphanumg
281 
282 // ------------------------------------------------------------------------ END
alphanumg_set_display_interval
void alphanumg_set_display_interval(alphanumg_t *ctx, uint16_t delay_char_display)
Delay character display function.
alphanumg_cfg_t::spi_speed
uint32_t spi_speed
Definition: alphanumg.h:118
alphanumg_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: alphanumg.h:119
alphanumg_set_pwm_low
void alphanumg_set_pwm_low(alphanumg_t *ctx)
PWM set low function.
alphanumg_cfg_t
AlphaNum G Click configuration object.
Definition: alphanumg.h:105
alphanumg_init
err_t alphanumg_init(alphanumg_t *ctx, alphanumg_cfg_t *cfg)
AlphaNum G initialization function.
alphanumg_cfg_t::miso
pin_name_t miso
Definition: alphanumg.h:107
alphanumg_t::display_speed
uint16_t display_speed
Definition: alphanumg.h:97
alphanumg_cfg_t::cs
pin_name_t cs
Definition: alphanumg.h:110
alphanumg_display_write
void alphanumg_display_write(alphanumg_t *ctx, uint16_t left_char, uint16_t right_char)
Display write function.
alphanumg_t::le2
digital_out_t le2
Definition: alphanumg.h:88
alphanumg_cfg_t::sck
pin_name_t sck
Definition: alphanumg.h:109
alphanumg_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: alphanumg.h:120
alphanumg_return_value_t
alphanumg_return_value_t
AlphaNum G Click return value data.
Definition: alphanumg.h:129
ALPHANUMG_ERROR
@ ALPHANUMG_ERROR
Definition: alphanumg.h:131
alphanumg_set_int_high
void alphanumg_set_int_high(alphanumg_t *ctx)
Interrupt set high function.
alphanumg_cfg_t::ns1
pin_name_t ns1
Definition: alphanumg.h:114
alphanumg_t::ns
digital_out_t ns
Definition: alphanumg.h:90
alphanumg_set_rst_low
void alphanumg_set_rst_low(alphanumg_t *ctx)
Reset set low function.
alphanumg_set_rst_high
void alphanumg_set_rst_high(alphanumg_t *ctx)
Reset set high function.
alphanumg_cfg_t::le2
pin_name_t le2
Definition: alphanumg.h:113
alphanumg_write_character
void alphanumg_write_character(alphanumg_t *ctx, uint8_t left_char, uint8_t right_char)
Character write function.
alphanumg_t::spi
spi_master_t spi
Definition: alphanumg.h:93
alphanumg_set_int_low
void alphanumg_set_int_low(alphanumg_t *ctx)
Interrupt set low function.
alphanumg_write_number
void alphanumg_write_number(alphanumg_t *ctx, uint8_t left_char, uint8_t right_char)
Number write function.
alphanumg_cfg_t::ns
pin_name_t ns
Definition: alphanumg.h:115
alphanumg_cfg_setup
void alphanumg_cfg_setup(alphanumg_cfg_t *cfg)
AlphaNum G configuration object setup function.
alphanumg_cfg_t::mosi
pin_name_t mosi
Definition: alphanumg.h:108
alphanumg_t
AlphaNum G Click context object.
Definition: alphanumg.h:86
alphanumg_set_pwm_high
void alphanumg_set_pwm_high(alphanumg_t *ctx)
PWM set high function.
alphanumg_t::chip_select
pin_name_t chip_select
Definition: alphanumg.h:95
ALPHANUMG_OK
@ ALPHANUMG_OK
Definition: alphanumg.h:130
alphanumg_t::ns1
digital_out_t ns1
Definition: alphanumg.h:89