31 #include "pios_config.h"
33 #if defined(PIOS_INCLUDE_VIDEO_QUADSPI)
35 #if !defined(PIOS_VIDEO_QUADSPI_Y_OFFSET)
36 #define PIOS_VIDEO_QUADSPI_Y_OFFSET 0
39 #if defined(PIOS_INCLUDE_FREERTOS)
48 #define VSYNC_REDRAW_CNT 2
52 #define GRPAHICS_RIGHT_NTSC 351
53 #define GRPAHICS_RIGHT_PAL 359
57 .graphics_bottom = 239,
62 .graphics_bottom = 265,
65 #define NTSC_BYTES (GRPAHICS_RIGHT_NTSC / (8 / PIOS_VIDEO_BITS_PER_PIXEL) + 1)
66 #define PAL_BYTES (GRPAHICS_RIGHT_PAL / (8 / PIOS_VIDEO_BITS_PER_PIXEL) + 1)
70 .graphics_column_start = 260,
71 .graphics_line_start = 16,
72 .dma_buffer_length = NTSC_BYTES + NTSC_BYTES % 4,
77 .graphics_column_start = 420,
78 .graphics_line_start = 28,
79 .dma_buffer_length = PAL_BYTES + PAL_BYTES % 4,
90 #define buffer0 (buffers.buffer0)
91 #define buffer1 (buffers.buffer1)
101 static int16_t active_line = 0;
102 static uint32_t buffer_offset;
103 static int8_t y_offset = 0;
105 static uint16_t num_video_lines = 0;
108 static const struct pios_video_type_cfg *pios_video_type_cfg_act = &pios_video_type_cfg_pal;
111 static void swap_buffers();
118 static bool woken =
false;
119 static uint16_t Vsync_update = 0;
135 if (video_system_act != video_system_tmp) {
136 video_system_act = video_system_tmp;
138 pios_video_type_boundary_act = &pios_video_type_boundary_ntsc;
139 pios_video_type_cfg_act = &pios_video_type_cfg_ntsc;
141 pios_video_type_boundary_act = &pios_video_type_boundary_pal;
142 pios_video_type_cfg_act = &pios_video_type_cfg_pal;
149 if (++Vsync_update >= VSYNC_REDRAW_CNT) {
159 #if defined(PIOS_INCLUDE_FREERTOS)
161 portEND_SWITCHING_ISR(woken ==
true ? pdTRUE : pdFALSE);
168 static bool woken =
false;
174 if (QUADSPI->SR & 0x20)
178 dev_cfg->dma.tx.channel->CR &= ~(uint32_t)DMA_SxCR_EN;
181 dev_cfg->pixel_dma->HIFCR |= DMA_FLAG_TCIF7 | DMA_FLAG_HTIF7 | DMA_FLAG_FEIF7 | DMA_FLAG_TEIF7 | DMA_FLAG_DMEIF7;
184 dev_cfg->dma.tx.channel->M0AR = (uint32_t)&
disp_buffer[buffer_offset];
187 dev_cfg->dma.tx.channel->NDTR = (uint16_t)pios_video_type_cfg_act->
dma_buffer_length;
191 dev_cfg->dma.tx.channel->CR |= (uint32_t)DMA_SxCR_EN;
197 #if defined(PIOS_INCLUDE_FREERTOS)
199 portEND_SWITCHING_ISR(woken ==
true ? pdTRUE : pdFALSE);
209 static void swap_buffers()
227 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_QSPI, ENABLE);
230 GPIO_PinAFConfig(cfg->sclk.gpio, __builtin_ctz(cfg->sclk.init.GPIO_Pin), GPIO_AF9_QUADSPI);
231 GPIO_PinAFConfig(cfg->bk1_io0.gpio, __builtin_ctz(cfg->bk1_io0.init.GPIO_Pin), GPIO_AF9_QUADSPI);
232 GPIO_PinAFConfig(cfg->bk1_io1.gpio, __builtin_ctz(cfg->bk1_io1.init.GPIO_Pin), GPIO_AF9_QUADSPI);
234 GPIO_Init(cfg->sclk.gpio, (GPIO_InitTypeDef *)&(cfg->sclk.init));
235 GPIO_Init(cfg->bk1_io0.gpio, (GPIO_InitTypeDef *)&(cfg->bk1_io0.init));
236 GPIO_Init(cfg->bk1_io1.gpio, (GPIO_InitTypeDef *)&(cfg->bk1_io1.init));
239 QSPI_Init(&cfg->qspi_init);
241 QSPI_ComConfig_InitTypeDef qspi_com_config;
242 QSPI_ComConfig_StructInit(&qspi_com_config);
244 qspi_com_config.QSPI_ComConfig_FMode = QSPI_ComConfig_FMode_Indirect_Write;
245 qspi_com_config.QSPI_ComConfig_DDRMode = QSPI_ComConfig_DDRMode_Disable;
246 qspi_com_config.QSPI_ComConfig_DHHC = QSPI_ComConfig_DHHC_Disable;
247 qspi_com_config.QSPI_ComConfig_SIOOMode = QSPI_ComConfig_SIOOMode_Disable;
248 qspi_com_config.QSPI_ComConfig_DMode = QSPI_ComConfig_DMode_2Line;
249 qspi_com_config.QSPI_ComConfig_DummyCycles = 0;
250 qspi_com_config.QSPI_ComConfig_ABMode = QSPI_ComConfig_ABMode_NoAlternateByte;
251 qspi_com_config.QSPI_ComConfig_ADMode = QSPI_ComConfig_ADMode_NoAddress;
252 qspi_com_config.QSPI_ComConfig_IMode = QSPI_ComConfig_IMode_NoInstruction;
253 QSPI_ComConfig_Init(&qspi_com_config);
255 QSPI_SetFIFOThreshold(3);
258 DMA_Init(cfg->dma.tx.channel, (DMA_InitTypeDef *)&(cfg->dma.tx.init));
265 QSPI_ITConfig(QSPI_IT_TC, ENABLE);
266 QSPI_ITConfig(QSPI_IT_FT, ENABLE);
284 return num_video_lines;
292 return video_system_act;
310 if (x_offset_in > 20)
312 if (x_offset_in < -20)
315 if (dev_cfg->set_x_offset) {
316 dev_cfg->set_x_offset(x_offset_in);
325 if (y_offset_in > 20)
327 if (y_offset_in < -20)
const struct pios_video_type_boundary * pios_video_type_boundary_act
const struct pios_exti_cfg * vsync
void PIOS_Video_SetXScale(uint8_t x_scale)
Main PiOS header to include all the compiled in PiOS options.
uint8_t graphics_line_start
OSD gen module, handles OSD draw. Parts from CL-OSD and SUPEROSD projects.
int32_t PIOS_EXTI_Init(const struct pios_exti_cfg *cfg)
void(* set_3d_config)(enum pios_video_3d_mode, uint8_t)
uint16_t graphics_height_real
enum pios_video_system PIOS_Video_GetSystem(void)
void(* set_bw_levels)(uint8_t, uint8_t)
bool PIOS_Semaphore_Give_FromISR(struct pios_semaphore *sema, bool *woken)
void PIOS_Video_SetYOffset(int8_t)
static struct flyingpicmd_cfg_fa cfg
void PIOS_Video_Set3DConfig(enum pios_video_3d_mode mode, uint8_t right_eye_x_shift)
#define VIDEO_TYPE_PAL_ROWS
struct pios_semaphore * onScreenDisplaySemaphore
void PIOS_Video_SetXOffset(int8_t)
void PIOS_Video_Init(const struct pios_video_cfg *cfg)
void(* set_x_scale)(uint8_t)
uint16_t PIOS_Video_GetLines(void)
void PIOS_Video_SetLevels(uint8_t, uint8_t)
#define SWAP_BUFFS(tmp, a, b)
#define PIOS_VIDEO_QUADSPI_Y_OFFSET
uint8_t dma_buffer_length