osd 2.0.0.0
osd.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 OSD_H
36#define OSD_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
58// -------------------------------------------------------------- PUBLIC MACROS
69#define OSD_MAP_MIKROBUS( cfg, mikrobus ) \
70 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
71 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
72 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
73 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
74 cfg.los = MIKROBUS( mikrobus, MIKROBUS_AN ); \
75 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
76 cfg.hsy = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
77 cfg.vsy = MIKROBUS( mikrobus, MIKROBUS_INT )
84#define OSD_OK 0x00
85#define OSD_ERROR -1
92#define OSD_VM0_REG 0x00
93#define OSD_VM1_REG 0x01
94#define OSD_HOS_REG 0x02
95#define OSD_VOS_REG 0x03
96#define OSD_DMM_REG 0x04
97#define OSD_DMAH_REG 0x05
98#define OSD_DMAL_REG 0x06
99#define OSD_DMDI_REG 0x07
100#define OSD_CMM_REG 0x08
101#define OSD_CMAH_REG 0x09
102#define OSD_RB0_REG 0x10
103#define OSD_CMAL_REG 0x0A
104#define OSD_CMDI_REG 0x0B
105#define OSD_OSDM_REG 0x0C
106#define OSD_OSDBL_REG 0x6C
107#define OSD_STAT_REG 0xA0
108#define OSD_DMDO_REG 0xB0
109#define OSD_CMDO_REG 0xC0
116#define OSD_WRITE_CMD 0x7F
117#define OSD_READ_CMD 0x80
118
119#define OSD_CLEAR_DISPLAY 0x04
120#define OSD_CLEAR_DISPLAY_VERT 0x06
121#define OSD_END_STRING 0xFF
122#define OSD_WRITE_NVR 0xA0
123
124#define OSD_WHITE_LEVEL_80 0x03
125#define OSD_WHITE_LEVEL_90 0x02
126#define OSD_WHITE_LEVEL_100 0x01
127#define OSD_WHITE_LEVEL_120 0x00
128
129#define OSD_MAX_FONT_ROM 0xFF
130#define OSD_STATUS_REG_NVR_BUSY 0x20
131#define OSD_NVM_RAM_SIZE 0x36
135 // End group macro
136// --------------------------------------------------------------- PUBLIC TYPES
145typedef struct
146{
147 // Output pins
148 digital_out_t rst;
149
150 // Input pins
151 digital_in_t los;
152 digital_in_t hsy;
153 digital_in_t vsy;
154
155 // Modules
156 spi_master_t spi;
157 pin_name_t chip_select;
158
159} osd_t;
160
164typedef struct
165{
166 // Communication gpio pins
167 pin_name_t miso;
168 pin_name_t mosi;
169 pin_name_t sck;
170 pin_name_t cs;
171
172 // Additional gpio pins
173 pin_name_t los;
174 pin_name_t rst;
175 pin_name_t hsy;
176 pin_name_t vsy;
177
178 // static variable
179 uint32_t spi_speed;
180 spi_master_mode_t spi_mode;
181 spi_master_chip_select_polarity_t cs_polarity;
182
183} osd_cfg_t;
184
188typedef struct
189{
190 uint8_t n_byte; // number of bytes
191 uint8_t flags; // flags: 1 <==> blink; 2 <==> invert
192 uint8_t line_pos; // line position value
193 uint8_t row_pos; // row position value
194
196
197 // End types group
198// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
199
204#ifdef __cplusplus
205extern "C"{
206#endif
207
217
225err_t osd_init ( osd_t *ctx, osd_cfg_t *cfg );
226
234void osd_default_cfg ( osd_t *ctx );
235
248void osd_write_byte ( osd_t *ctx, uint8_t reg_address, uint8_t write_data );
249
261uint8_t osd_read_byte ( osd_t *ctx, uint8_t reg_address );
262
277void osd_hw_reset ( osd_t *ctx );
278
289void osd_enable ( osd_t *ctx );
290
299void osd_disable ( osd_t *ctx );
300
313void osd_write_character ( osd_t *ctx, uint8_t line_pos, uint8_t row_pos, uint8_t symbol );
314
326void osd_insert_custom_char ( osd_t *ctx, uint8_t chr_address, uint8_t custom_char );
327
341void osd_clears_char_places ( osd_t *ctx, uint8_t start_x, uint8_t start_y, uint8_t end_x,
342 uint8_t end_y );
343
354void osd_set_ntsc ( osd_t *ctx );
355
366void osd_set_pal ( osd_t *ctx );
367
368
387void osd_set_video_sync_mode ( osd_t *ctx, uint8_t sync_mode );
388
400
412
431void osd_vertical_sync_screen ( osd_t *ctx, uint8_t vsync );
432
449void osd_soft_reset ( osd_t *ctx );
450
462
474
491void osd_set_background_mode ( osd_t *ctx, uint8_t b_mode );
492
513void osd_set_background_brightness ( osd_t *ctx, uint8_t brightness );
514
532void osd_set_blinking_time ( osd_t *ctx, uint8_t blinking_time );
533
553void osd_set_blinking_duty_cycle ( osd_t *ctx, uint8_t blink_duty_cycle );
554
577void osd_set_horizontal_offset ( osd_t *ctx, uint8_t h_offset );
578
601void osd_set_vertical_offset ( osd_t *ctx, uint8_t v_offset );
602
620void osd_set_operation_mode ( osd_t *ctx, uint8_t op_mode );
621
637void osd_set_local_background_control ( osd_t *ctx, uint8_t lb_mode );
638
648void osd_blinking_on ( osd_t *ctx );
649
661
670
679
698
717void osd_write_chars ( osd_t *ctx, uint8_t *symbol_buff, osd_write_chars_t *write_ctx );
718
730void osd_write_nvm_character ( osd_t *ctx, uint8_t v_chars, uint16_t v_index );
731
740
749
761
770
779
788
811void osd_set_sharpness ( osd_t *ctx, uint8_t s_data );
812
821
833
871uint8_t osd_get_status ( osd_t *ctx );
872
901
923
941uint8_t osd_get_los ( osd_t *ctx );
942
960uint8_t osd_get_vsync ( osd_t *ctx );
961
979uint8_t osd_get_hsync ( osd_t *ctx );
980
981#ifdef __cplusplus
982}
983#endif
984#endif // _OSD_H_
985
986 // End public_function group
988
989// ------------------------------------------------------------------------- END
void osd_enable_display_image(osd_t *ctx)
Enable display of OSD image function.
void osd_clears_char_places(osd_t *ctx, uint8_t start_x, uint8_t start_y, uint8_t end_x, uint8_t end_y)
Clears the character places function.
void osd_enable(osd_t *ctx)
Enable OSD function.
uint8_t osd_get_character_data_out(osd_t *ctx)
Get character memory data out function.
err_t osd_init(osd_t *ctx, osd_cfg_t *cfg)
Initialization function.
void osd_disable_video_buffer(osd_t *ctx)
Disable video buffer.
void osd_disable(osd_t *ctx)
Disable OSD function.
void osd_invert_pixels_display(osd_t *ctx)
Invert color of pixels on display function.
void osd_normal_pixels_display(osd_t *ctx)
Normal color of pixels on display function.
void osd_disable_auto_black(osd_t *ctx)
Disable automatic OSD black function.
void osd_write_nvm_character(osd_t *ctx, uint8_t v_chars, uint16_t v_index)
Write NVM character function.
uint8_t osd_get_status(osd_t *ctx)
Get status data function.
void osd_set_blinking_duty_cycle(osd_t *ctx, uint8_t blink_duty_cycle)
Set blinking duty cycle function.
void osd_write_character(osd_t *ctx, uint8_t line_pos, uint8_t row_pos, uint8_t symbol)
Write character by position function.
void osd_disable_display_image(osd_t *ctx)
Disable display of OSD image function.
void osd_write_chars(osd_t *ctx, uint8_t *symbol_buff, osd_write_chars_t *write_ctx)
Write character function.
void osd_blinking_off(osd_t *ctx)
Set blinking OFF function.
void osd_enable_auto_black(osd_t *ctx)
Enable automatic OSD black function.
void osd_character_blinking_off(osd_t *ctx)
Set blinking OFF function.
void osd_soft_reset(osd_t *ctx)
Software reset function.
uint8_t osd_get_hsync(osd_t *ctx)
Get horizontal sync status function.
void osd_clear_display_memory(osd_t *ctx)
Clear display memory.
uint8_t osd_get_vsync(osd_t *ctx)
Get vertical sync status function.
void osd_set_local_background_control(osd_t *ctx, uint8_t lb_mode)
Set local background control function.
void osd_cfg_setup(osd_cfg_t *cfg)
Config Object Initialization function.
void osd_hw_reset(osd_t *ctx)
Hardware reset function.
void osd_set_sharpness(osd_t *ctx, uint8_t s_data)
Set sharpness function.
void osd_write_byte(osd_t *ctx, uint8_t reg_address, uint8_t write_data)
Write the byte of data.
void osd_set_background_mode(osd_t *ctx, uint8_t b_mode)
Set background mode.
void osd_set_operation_mode(osd_t *ctx, uint8_t op_mode)
Set operation mode function.
void osd_set_ntsc(osd_t *ctx)
Set NTSC video standard function.
void osd_default_cfg(osd_t *ctx)
Click Default Configuration function.
uint8_t osd_read_byte(osd_t *ctx, uint8_t reg_address)
Read the byte of data function.
void osd_set_blinking_time(osd_t *ctx, uint8_t blinking_time)
Set blinking time.
void osd_set_pal(osd_t *ctx)
Set PAL video standard function.
uint8_t osd_get_los(osd_t *ctx)
Get loss of sync status function.
void osd_set_character_color_white(osd_t *ctx)
Set the white background of the character function.
void osd_normal_pixels_character(osd_t *ctx)
Normal color of character pixels on display.
void osd_set_video_sync_mode(osd_t *ctx, uint8_t sync_mode)
Set video sync mode function.
void osd_character_blinking_on(osd_t *ctx)
Set blinking ON function.
void osd_set_vertical_offset(osd_t *ctx, uint8_t v_offset)
Set vertical offset function.
void osd_insert_custom_char(osd_t *ctx, uint8_t chr_address, uint8_t custom_char)
Write custom character function.
void osd_set_background_brightness(osd_t *ctx, uint8_t brightness)
Set background brightness function.
void osd_enable_video_buffer(osd_t *ctx)
Enable video buffer.
void osd_set_character_color_black(osd_t *ctx)
Set the black background of the character function.
void osd_set_horizontal_offset(osd_t *ctx, uint8_t h_offset)
Set horizontal offset function.
void osd_blinking_on(osd_t *ctx)
Set blinking ON function.
uint8_t osd_get_display_data_out(osd_t *ctx)
Get display memory data out function.
void osd_invert_pixels_character(osd_t *ctx)
Invert color of character pixels on display.
void osd_vertical_sync_screen(osd_t *ctx, uint8_t vsync)
Enable vertical synchronization of on-screen data function.
Click configuration structure definition.
Definition osd.h:165
pin_name_t hsy
Definition osd.h:175
pin_name_t vsy
Definition osd.h:176
spi_master_chip_select_polarity_t cs_polarity
Definition osd.h:181
pin_name_t los
Definition osd.h:173
pin_name_t sck
Definition osd.h:169
spi_master_mode_t spi_mode
Definition osd.h:180
pin_name_t mosi
Definition osd.h:168
uint32_t spi_speed
Definition osd.h:179
pin_name_t miso
Definition osd.h:167
pin_name_t rst
Definition osd.h:174
pin_name_t cs
Definition osd.h:170
Click ctx object definition.
Definition osd.h:146
spi_master_t spi
Definition osd.h:156
digital_in_t los
Definition osd.h:151
digital_in_t vsy
Definition osd.h:153
digital_in_t hsy
Definition osd.h:152
digital_out_t rst
Definition osd.h:148
pin_name_t chip_select
Definition osd.h:157
Structure for osd_write_chars() call.
Definition osd.h:189
uint8_t line_pos
Definition osd.h:192
uint8_t flags
Definition osd.h:191
uint8_t row_pos
Definition osd.h:193
uint8_t n_byte
Definition osd.h:190