c7seg 2.0.0.0
c7seg.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 C7SEG_H
36#define C7SEG_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// -------------------------------------------------------------- PUBLIC MACROS
67#define C7SEG_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 C7SEG_RETVAL uint8_t
81
82#define C7SEG_OK 0x00
83#define C7SEG_INIT_ERROR 0xFF
90#define C7SEG_DISPLAY_OFF 0
91#define C7SEG_DISPLAY_ON 1
94 // End group macro
95
96// --------------------------------------------------------------- PUBLIC TYPES
105typedef struct
106{
107 digital_out_t cs;
108 // Output pins
109
110 digital_out_t mr;
111 digital_out_t pwm;
112
113 // Modules
114
115 spi_master_t spi;
116 pin_name_t chip_select;
117
118} c7seg_t;
119
123typedef struct
124{
125 // Communication gpio pins
126
127 pin_name_t miso;
128 pin_name_t mosi;
129 pin_name_t sck;
130 pin_name_t cs;
131
132 // Additional gpio pins
133
134 pin_name_t mr;
135 pin_name_t pwm;
136
137 // static variable
138
139 uint32_t spi_speed;
140 spi_master_mode_t spi_mode;
141 spi_master_chip_select_polarity_t cs_polarity;
142
144
145 // End types group
146// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
147
152#ifdef __cplusplus
153extern "C"{
154#endif
155
165
175
194
206void c7seg_generic_transfer ( c7seg_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
207
217void c7seg_write_data ( c7seg_t *ctx, uint8_t write_left, uint8_t write_right );
218
226void c7seg_reset ( c7seg_t *ctx );
227
236void c7seg_display_mode ( c7seg_t *ctx, uint8_t display_mode );
237
247void c7seg_write_data_number ( c7seg_t *ctx, uint8_t left_number, uint8_t right_number );
248
258void c7seg_write_data_character ( c7seg_t *ctx, char left_char, char right_char );
259
260#ifdef __cplusplus
261}
262#endif
263#endif // _C7SEG_H_
264
265 // End public_function group
267
269// ------------------------------------------------------------------------- END
#define C7SEG_RETVAL
Definition c7seg.h:80
void c7seg_write_data(c7seg_t *ctx, uint8_t write_left, uint8_t write_right)
Generic write data function.
C7SEG_RETVAL c7seg_init(c7seg_t *ctx, c7seg_cfg_t *cfg)
Initialization function.
void c7seg_write_data_character(c7seg_t *ctx, char left_char, char right_char)
void c7seg_reset(c7seg_t *ctx)
Click Reset function.
void c7seg_display_mode(c7seg_t *ctx, uint8_t display_mode)
Display mode function.
void c7seg_default_cfg(c7seg_t *ctx)
Click Default Configuration function.
void c7seg_cfg_setup(c7seg_cfg_t *cfg)
Config Object Initialization function.
void c7seg_generic_transfer(c7seg_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void c7seg_write_data_number(c7seg_t *ctx, uint8_t left_number, uint8_t right_number)
Click configuration structure definition.
Definition c7seg.h:124
spi_master_chip_select_polarity_t cs_polarity
Definition c7seg.h:141
pin_name_t mr
Definition c7seg.h:134
pin_name_t sck
Definition c7seg.h:129
spi_master_mode_t spi_mode
Definition c7seg.h:140
pin_name_t mosi
Definition c7seg.h:128
uint32_t spi_speed
Definition c7seg.h:139
pin_name_t pwm
Definition c7seg.h:135
pin_name_t miso
Definition c7seg.h:127
pin_name_t cs
Definition c7seg.h:130
Click ctx object definition.
Definition c7seg.h:106
digital_out_t cs
Definition c7seg.h:107
spi_master_t spi
Definition c7seg.h:115
digital_out_t pwm
Definition c7seg.h:111
digital_out_t mr
Definition c7seg.h:110
pin_name_t chip_select
Definition c7seg.h:116