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
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
67#define BIG7SEG_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.mr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
80#define BIG7SEG_RETVAL uint8_t
81
82#define BIG7SEG_OK 0x00
83#define BIG7SEG_INIT_ERROR 0xFF
86 // End group macro
87// --------------------------------------------------------------- PUBLIC TYPES
96typedef struct
97{
98 // Output pins
99
100 digital_out_t mr;
101 digital_out_t pwm;
102 digital_out_t cs;
103
104 // Modules
105
106 spi_master_t spi;
107 pin_name_t chip_select;
108
109} big7seg_t;
110
114typedef struct
115{
116 // Communication gpio pins
117
118 pin_name_t miso;
119 pin_name_t mosi;
120 pin_name_t sck;
121 pin_name_t cs;
122
123 // Additional gpio pins
124
125 pin_name_t mr;
126 pin_name_t pwm;
127
128 // static variable
129
130 uint32_t spi_speed;
131 uint8_t spi_mode;
132 spi_master_chip_select_polarity_t cs_polarity;
133
135
136 // End types group
137// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
138
143#ifdef __cplusplus
144extern "C"{
145#endif
146
156
165
178(
179 big7seg_t *ctx,
180 uint8_t *wr_buf,
181 uint16_t wr_len,
182 uint8_t *rd_buf,
183 uint16_t rd_len
184);
185
194void big7seg_write_data ( big7seg_t *ctx, uint8_t write_data );
195
204
213
222
231
240void big7seg_write_data_number ( big7seg_t *ctx, uint8_t display_number );
241
250void big7seg_write_data_character ( big7seg_t *ctx, char display_char );
251
252#ifdef __cplusplus
253}
254#endif
255#endif // _BIG7SEG_H_
256
257 // End public_function group
259
260// ------------------------------------------------------------------------- END
#define BIG7SEG_RETVAL
Definition big7seg.h:80
void big7seg_set7seg(big7seg_t *ctx)
BIG7SEG_RETVAL big7seg_init(big7seg_t *ctx, big7seg_cfg_t *cfg)
Initialization function.
void big7seg_cfg_setup(big7seg_cfg_t *cfg)
Config Object Initialization function.
void big7seg_write_data_character(big7seg_t *ctx, char display_char)
void big7seg_display_off(big7seg_t *ctx)
void big7seg_write_data_number(big7seg_t *ctx, uint8_t display_number)
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.
void big7seg_write_data(big7seg_t *ctx, uint8_t write_data)
void big7seg_display_on(big7seg_t *ctx)
void big7seg_reset7seg(big7seg_t *ctx)
Click configuration structure definition.
Definition big7seg.h:115
uint8_t spi_mode
Definition big7seg.h:131
spi_master_chip_select_polarity_t cs_polarity
Definition big7seg.h:132
pin_name_t mr
Definition big7seg.h:125
pin_name_t sck
Definition big7seg.h:120
pin_name_t mosi
Definition big7seg.h:119
uint32_t spi_speed
Definition big7seg.h:130
pin_name_t pwm
Definition big7seg.h:126
pin_name_t miso
Definition big7seg.h:118
pin_name_t cs
Definition big7seg.h:121
Click ctx object definition.
Definition big7seg.h:97
digital_out_t cs
Definition big7seg.h:102
spi_master_t spi
Definition big7seg.h:106
digital_out_t pwm
Definition big7seg.h:101
digital_out_t mr
Definition big7seg.h:100
pin_name_t chip_select
Definition big7seg.h:107