big7seg  2.0.0.0
big7seg.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * 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 
89  // Modules
90 
91  spi_master_t spi;
92 
93 } big7seg_t;
94 
98 typedef struct
99 {
100  // Communication gpio pins
101 
102  pin_name_t miso;
103  pin_name_t mosi;
104  pin_name_t sck;
105  pin_name_t cs;
106 
107  // Additional gpio pins
108 
109  pin_name_t mr;
110  pin_name_t pwm;
111 
112  // static variable
113 
114  hal_spi_speed_t spi_speed;
115  hal_spi_mode_t spi_mode;
116 
117 } big7seg_cfg_t;
118  // End types group
120 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
121 
126 #ifdef __cplusplus
127 extern "C"{
128 #endif
129 
138 void big7seg_cfg_setup ( big7seg_cfg_t *cfg );
139 
148 
157 void big7seg_generic_transfer ( big7seg_t *ctx, spi_master_transfer_data_t *block );
158 
167 void big7seg_write_data ( big7seg_t *ctx, uint8_t write_data );
168 
176 void big7seg_set7seg ( big7seg_t *ctx );
177 
185 void big7seg_reset7seg ( big7seg_t *ctx );
186 
194 void big7seg_display_on ( big7seg_t *ctx );
195 
203 void big7seg_display_off ( big7seg_t *ctx );
204 
213 void big7seg_write_data_number ( big7seg_t *ctx, uint8_t display_number );
214 
223 void big7seg_write_data_character ( big7seg_t *ctx, char display_char );
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 #endif // _BIG7SEG_H_
229  // End public_function group
232 
233 // ------------------------------------------------------------------------- END
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:98
big7seg_cfg_t::miso
pin_name_t miso
Definition: big7seg.h:102
big7seg_t::spi
spi_master_t spi
Definition: big7seg.h:91
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:110
big7seg_write_data
void big7seg_write_data(big7seg_t *ctx, uint8_t write_data)
big7seg_generic_transfer
void big7seg_generic_transfer(big7seg_t *ctx, spi_master_transfer_data_t *block)
Generic transfer function.
big7seg_t::pwm
digital_out_t pwm
Definition: big7seg.h:87
big7seg_cfg_t::mr
pin_name_t mr
Definition: big7seg.h:109
big7seg_t
Click ctx object definition.
Definition: big7seg.h:82
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_cfg_t::spi_speed
hal_spi_speed_t spi_speed
Definition: big7seg.h:114
BIG7SEG_RETVAL
#define BIG7SEG_RETVAL
Definition: big7seg.h:66
big7seg_cfg_t::spi_mode
hal_spi_mode_t spi_mode
Definition: big7seg.h:115
big7seg_reset7seg
void big7seg_reset7seg(big7seg_t *ctx)
big7seg_cfg_t::cs
pin_name_t cs
Definition: big7seg.h:105
big7seg_cfg_t::mosi
pin_name_t mosi
Definition: big7seg.h:103
big7seg_cfg_t::sck
pin_name_t sck
Definition: big7seg.h:104
big7seg_init
BIG7SEG_RETVAL big7seg_init(big7seg_t *ctx, big7seg_cfg_t *cfg)
Initialization function.