alphanumr  2.0.0.0
alphanumr.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 ALPHANUMR_H
29 #define ALPHANUMR_H
30 
31 #ifdef __cplusplus
32 extern "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 
73 #define ALPHANUMR_MAP_MIKROBUS( cfg, mikrobus ) \
74  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
75  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
76  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
77  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
78  cfg.le2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
79  cfg.ns1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
80  cfg.ns = MIKROBUS( mikrobus, MIKROBUS_INT )
81  // alphanumr_map // alphanumr
84 
89 typedef struct
90 {
91  // Output pins
92  digital_out_t le2;
93  digital_out_t ns1;
94  digital_out_t ns;
95 
96  // Modules
97  spi_master_t spi;
99  pin_name_t chip_select;
101  uint16_t display_speed;
102 } alphanumr_t;
103 
108 typedef struct
109 {
110  // Communication gpio pins
111  pin_name_t miso;
112  pin_name_t mosi;
113  pin_name_t sck;
114  pin_name_t cs;
116  // Additional gpio pins
117  pin_name_t le2;
118  pin_name_t ns1;
119  pin_name_t ns;
120 
121  // static variable
122  uint32_t spi_speed;
123  spi_master_mode_t spi_mode;
124  spi_master_chip_select_polarity_t cs_polarity;
127 
132 typedef enum
133 {
135  ALPHANUMR_ERROR = -1
136 
138 
155 
171 
181 void alphanumr_set_display_interval ( alphanumr_t *ctx, uint16_t delay_char_display );
182 
193 void alphanumr_display_write ( alphanumr_t *ctx, uint16_t left_char, uint16_t right_char );
194 
205 void alphanumr_write_character ( alphanumr_t *ctx, uint8_t left_char, uint8_t right_char );
206 
217 void alphanumr_write_number ( alphanumr_t *ctx, uint8_t left_char, uint8_t right_char );
218 
228 
238 
248 
258 
268 
278 
279 #ifdef __cplusplus
280 }
281 #endif
282 #endif // ALPHANUMR_H
283  // alphanumr
285 
286 // ------------------------------------------------------------------------ END
alphanumr_cfg_t::spi_speed
uint32_t spi_speed
Definition: alphanumr.h:122
alphanumr_set_pwm_low
void alphanumr_set_pwm_low(alphanumr_t *ctx)
PWM set low function.
alphanumr_cfg_t::miso
pin_name_t miso
Definition: alphanumr.h:111
alphanumr_set_display_interval
void alphanumr_set_display_interval(alphanumr_t *ctx, uint16_t delay_char_display)
Delay character display function.
alphanumr_cfg_t::le2
pin_name_t le2
Definition: alphanumr.h:117
alphanumr_t::display_speed
uint16_t display_speed
Definition: alphanumr.h:101
alphanumr_t::chip_select
pin_name_t chip_select
Definition: alphanumr.h:99
alphanumr_t
AlphaNum R Click context object.
Definition: alphanumr.h:90
alphanumr_init
err_t alphanumr_init(alphanumr_t *ctx, alphanumr_cfg_t *cfg)
AlphaNum R initialization function.
alphanumr_cfg_t::ns
pin_name_t ns
Definition: alphanumr.h:119
ALPHANUMR_ERROR
@ ALPHANUMR_ERROR
Definition: alphanumr.h:135
alphanumr_t::ns
digital_out_t ns
Definition: alphanumr.h:94
alphanumr_cfg_t::cs
pin_name_t cs
Definition: alphanumr.h:114
alphanumr_t::le2
digital_out_t le2
Definition: alphanumr.h:92
alphanumr_set_pwm_high
void alphanumr_set_pwm_high(alphanumr_t *ctx)
PWM set high function.
alphanumr_return_value_t
alphanumr_return_value_t
AlphaNum R Click return value data.
Definition: alphanumr.h:133
alphanumr_cfg_t::sck
pin_name_t sck
Definition: alphanumr.h:113
alphanumr_cfg_t
AlphaNum R Click configuration object.
Definition: alphanumr.h:109
alphanumr_set_rst_low
void alphanumr_set_rst_low(alphanumr_t *ctx)
Reset set low function.
alphanumr_cfg_setup
void alphanumr_cfg_setup(alphanumr_cfg_t *cfg)
AlphaNum R configuration object setup function.
alphanumr_set_int_high
void alphanumr_set_int_high(alphanumr_t *ctx)
Interrupt set high function.
alphanumr_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: alphanumr.h:124
alphanumr_set_int_low
void alphanumr_set_int_low(alphanumr_t *ctx)
Interrupt set low function.
alphanumr_cfg_t::mosi
pin_name_t mosi
Definition: alphanumr.h:112
alphanumr_display_write
void alphanumr_display_write(alphanumr_t *ctx, uint16_t left_char, uint16_t right_char)
Display write function.
alphanumr_t::spi
spi_master_t spi
Definition: alphanumr.h:97
alphanumr_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: alphanumr.h:123
alphanumr_cfg_t::ns1
pin_name_t ns1
Definition: alphanumr.h:118
ALPHANUMR_OK
@ ALPHANUMR_OK
Definition: alphanumr.h:134
alphanumr_write_number
void alphanumr_write_number(alphanumr_t *ctx, uint8_t left_char, uint8_t right_char)
Number write function.
alphanumr_write_character
void alphanumr_write_character(alphanumr_t *ctx, uint8_t left_char, uint8_t right_char)
Character write function.
alphanumr_t::ns1
digital_out_t ns1
Definition: alphanumr.h:93
alphanumr_set_rst_high
void alphanumr_set_rst_high(alphanumr_t *ctx)
Reset set high function.