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 "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_spi_master.h"
51 
52 
53 // -------------------------------------------------------------- PUBLIC MACROS
63 #define BIG7SEG_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
65  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
66  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
67  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
68  cfg.mr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
69  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
70 
76 #define BIG7SEG_RETVAL uint8_t
77 
78 #define BIG7SEG_OK 0x00
79 #define BIG7SEG_INIT_ERROR 0xFF
80  // End group macro
83 // --------------------------------------------------------------- PUBLIC TYPES
92 typedef struct
93 {
94  // Output pins
95 
96  digital_out_t mr;
97  digital_out_t pwm;
98  digital_out_t cs;
99 
100  // Modules
101 
102  spi_master_t spi;
103  pin_name_t chip_select;
104 
105 } big7seg_t;
106 
110 typedef struct
111 {
112  // Communication gpio pins
113 
114  pin_name_t miso;
115  pin_name_t mosi;
116  pin_name_t sck;
117  pin_name_t cs;
118 
119  // Additional gpio pins
120 
121  pin_name_t mr;
122  pin_name_t pwm;
123 
124  // static variable
125 
126  uint32_t spi_speed;
127  uint8_t spi_mode;
128  spi_master_chip_select_polarity_t cs_polarity;
129 
130 } big7seg_cfg_t;
131  // End types group
133 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
134 
139 #ifdef __cplusplus
140 extern "C"{
141 #endif
142 
152 
161 
174 (
175  big7seg_t *ctx,
176  uint8_t *wr_buf,
177  uint16_t wr_len,
178  uint8_t *rd_buf,
179  uint16_t rd_len
180 );
181 
190 void big7seg_write_data ( big7seg_t *ctx, uint8_t write_data );
191 
200 
209 
218 
227 
236 void big7seg_write_data_number ( big7seg_t *ctx, uint8_t display_number );
237 
246 void big7seg_write_data_character ( big7seg_t *ctx, char display_char );
247 
248 #ifdef __cplusplus
249 }
250 #endif
251 #endif // _BIG7SEG_H_
252  // End public_function group
255 
256 // ------------------------------------------------------------------------- END
big7seg_cfg_t::spi_mode
uint8_t spi_mode
Definition: big7seg.h:127
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:111
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:114
big7seg_t::spi
spi_master_t spi
Definition: big7seg.h:102
big7seg_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: big7seg.h:128
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:96
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:122
big7seg_write_data
void big7seg_write_data(big7seg_t *ctx, uint8_t write_data)
big7seg_t::pwm
digital_out_t pwm
Definition: big7seg.h:97
big7seg_cfg_t::mr
pin_name_t mr
Definition: big7seg.h:121
big7seg_t
Click ctx object definition.
Definition: big7seg.h:93
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:76
big7seg_reset7seg
void big7seg_reset7seg(big7seg_t *ctx)
big7seg_cfg_t::spi_speed
uint32_t spi_speed
Definition: big7seg.h:126
big7seg_cfg_t::cs
pin_name_t cs
Definition: big7seg.h:117
big7seg_t::chip_select
pin_name_t chip_select
Definition: big7seg.h:103
big7seg_cfg_t::mosi
pin_name_t mosi
Definition: big7seg.h:115
big7seg_cfg_t::sck
pin_name_t sck
Definition: big7seg.h:116
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:98