big7seg  2.0.0.0
big7seg.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 BIG7SEG_H
36 #define BIG7SEG_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
53 #define BIG7SEG_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.mr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
59  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
60 
66 #define BIG7SEG_RETVAL uint8_t
67 
68 #define BIG7SEG_OK 0x00
69 #define BIG7SEG_INIT_ERROR 0xFF
70  // End group macro
73 // --------------------------------------------------------------- PUBLIC TYPES
82 typedef struct
83 {
84  // Output pins
85 
86  digital_out_t mr;
87  digital_out_t pwm;
88  digital_out_t cs;
89 
90  // Modules
91 
92  spi_master_t spi;
93  pin_name_t chip_select;
94 
95 } big7seg_t;
96 
100 typedef struct
101 {
102  // Communication gpio pins
103 
104  pin_name_t miso;
105  pin_name_t mosi;
106  pin_name_t sck;
107  pin_name_t cs;
108 
109  // Additional gpio pins
110 
111  pin_name_t mr;
112  pin_name_t pwm;
113 
114  // static variable
115 
116  uint32_t spi_speed;
117  uint8_t spi_mode;
118  spi_master_chip_select_polarity_t cs_polarity;
119 
120 } big7seg_cfg_t;
121  // End types group
123 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
124 
129 #ifdef __cplusplus
130 extern "C"{
131 #endif
132 
142 
151 
164 (
165  big7seg_t *ctx,
166  uint8_t *wr_buf,
167  uint16_t wr_len,
168  uint8_t *rd_buf,
169  uint16_t rd_len
170 );
171 
180 void big7seg_write_data ( big7seg_t *ctx, uint8_t write_data );
181 
190 
199 
208 
217 
226 void big7seg_write_data_number ( big7seg_t *ctx, uint8_t display_number );
227 
236 void big7seg_write_data_character ( big7seg_t *ctx, char display_char );
237 
238 #ifdef __cplusplus
239 }
240 #endif
241 #endif // _BIG7SEG_H_
242  // End public_function group
245 
246 // ------------------------------------------------------------------------- END
big7seg_cfg_t::spi_mode
uint8_t spi_mode
Definition: big7seg.h:117
big7seg_write_data_character
void big7seg_write_data_character(big7seg_t *ctx, char display_char)
big7seg_cfg_t
Click configuration structure definition.
Definition: big7seg.h:101
big7seg_generic_transfer
void big7seg_generic_transfer(big7seg_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
big7seg_cfg_t::miso
pin_name_t miso
Definition: big7seg.h:104
big7seg_t::spi
spi_master_t spi
Definition: big7seg.h:92
big7seg_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: big7seg.h:118
big7seg_write_data_number
void big7seg_write_data_number(big7seg_t *ctx, uint8_t display_number)
big7seg_t::mr
digital_out_t mr
Definition: big7seg.h:86
big7seg_cfg_setup
void big7seg_cfg_setup(big7seg_cfg_t *cfg)
Config Object Initialization function.
big7seg_cfg_t::pwm
pin_name_t pwm
Definition: big7seg.h:112
big7seg_write_data
void big7seg_write_data(big7seg_t *ctx, uint8_t write_data)
big7seg_t::pwm
digital_out_t pwm
Definition: big7seg.h:87
big7seg_cfg_t::mr
pin_name_t mr
Definition: big7seg.h:111
big7seg_t
Click ctx object definition.
Definition: big7seg.h:83
big7seg_set7seg
void big7seg_set7seg(big7seg_t *ctx)
big7seg_display_off
void big7seg_display_off(big7seg_t *ctx)
big7seg_display_on
void big7seg_display_on(big7seg_t *ctx)
BIG7SEG_RETVAL
#define BIG7SEG_RETVAL
Definition: big7seg.h:66
big7seg_reset7seg
void big7seg_reset7seg(big7seg_t *ctx)
big7seg_cfg_t::spi_speed
uint32_t spi_speed
Definition: big7seg.h:116
big7seg_cfg_t::cs
pin_name_t cs
Definition: big7seg.h:107
big7seg_t::chip_select
pin_name_t chip_select
Definition: big7seg.h:93
big7seg_cfg_t::mosi
pin_name_t mosi
Definition: big7seg.h:105
big7seg_cfg_t::sck
pin_name_t sck
Definition: big7seg.h:106
big7seg_init
BIG7SEG_RETVAL big7seg_init(big7seg_t *ctx, big7seg_cfg_t *cfg)
Initialization function.
big7seg_t::cs
digital_out_t cs
Definition: big7seg.h:88