zhaohe 2 years ago
parent
commit
bd6f2a2173
  1. 15
      README.md
  2. 2
      iflytop_xsync_protocol
  3. 18
      usrc/base_service/fpga_if.c
  4. 6
      usrc/base_service/fpga_if.h
  5. 2
      usrc/main.cpp
  6. 42
      usrc/service/report_generator_service.c

15
README.md

@ -3,18 +3,7 @@ ref:https://iflytop1.feishu.cn/docx/FPqjdaTtkoBeU9x4qbjcD6vxnUc
```
```
FPGA
V1
单片机程序基本稳定
1. 将XyncInternal内部信号导出到ttl输出模块(包括内部timecode信号,外部timecode信号)OK
2. 完成XyncInternalPC端上位机相关配置 OK
2. 创建Timecode输出模块,监听Timecode输出信号到debug接口,完成timecodePC端上位机相关配置(输出同时输出到STM32)
影响网口输出
影响TIMECODE物理接口输出
3. 创建Genlock输出模块,完成Genlock输出模块PC端上位机相关配置(输出同时输出到STM32),计数清空信号
影响网口输出
影响GENLOCK物理接口输出
5. 实现Timecode输入解析。测试Timecode
```

2
iflytop_xsync_protocol

@ -1 +1 @@
Subproject commit 783e2a9d35175268db50f271f1d7eea1f60467ba
Subproject commit 055f9672881d39e8fddcec7bc4e0a164245c797f

18
usrc/base_service/fpga_if.c

@ -25,12 +25,21 @@ void fpga_if_init() { //
// fpga_if.spi2 = &hspi1;
// HAL_SPI_Receive(fpga_if.spi2, rxbuf, 1, 1000);
fpga_if.timecode_irq_pin = PD6;
fpga_if.camera_sync_code_irq_pin = PD4;
fpga_if.timecode_irq_pin = PD6;
fpga_if.camera_sync_code_irq_pin = PD4;
fpga_if.xsync_workstate_start_sig_irq_io_pin = PD5;
fpga_if.reset_pin = PD7;
#if 1
xs_gpio_init_as_input(&fpga_if.camera_sync_code_irq_io, fpga_if.camera_sync_code_irq_pin, kxs_gpio_pulldown, kxs_gpio_rising_irq, false);
xs_gpio_init_as_input(&fpga_if.timecode_irq_io, fpga_if.timecode_irq_pin, kxs_gpio_pulldown, kxs_gpio_rising_irq, false);
xs_gpio_init_as_input(&fpga_if.xsync_workstate_start_sig_irq_io, fpga_if.xsync_workstate_start_sig_irq_io_pin, kxs_gpio_pulldown, kxs_gpio_rising_and_falling_irq, false);
xs_gpio_init_as_output(&fpga_if.reset_pin_io, fpga_if.reset_pin, kxs_gpio_nopull, false, false);
xs_gpio_write(&fpga_if.reset_pin_io, false);
xs_delay_us(1);
xs_gpio_write(&fpga_if.reset_pin_io, true);
// for (size_t i = 0; i < 4; i++) {
// xs_gpio_init_as_output(&fpga_if.timecode_add[i], fpga_if.timecode_add_pin[i], kxs_gpio_nopull, false, false);
// }
@ -79,7 +88,10 @@ void fpga_if_get_timecode(uint32_t *timecode0, uint32_t *timecode1) {
return;
}
void fpga_if_get_workstate(uint32_t *workstate) {
fpga_if_spi_read_data_02(60, workstate);
return;
}
/**
* @brief SPI¼Ä´æÆ÷дָÁî
*

6
usrc/base_service/fpga_if.h

@ -25,9 +25,13 @@ typedef struct {
Pin_t timecode_irq_pin;
Pin_t camera_sync_code_irq_pin;
Pin_t xsync_workstate_start_sig_irq_io_pin;
Pin_t reset_pin;
xs_gpio_t timecode_irq_io;
xs_gpio_t camera_sync_code_irq_io;
xs_gpio_t xsync_workstate_start_sig_irq_io;
xs_gpio_t reset_pin_io;
} fpga_if_t;
/**
@ -74,6 +78,8 @@ void fpga_if_spi_write_data_02(uint32_t add, uint32_t txdata, uint32_t *rxdata);
*/
void fpga_if_spi_read_data_02(uint32_t add, uint32_t *rxdata);
void fpga_if_get_workstate(uint32_t *workstate);
fpga_if_t *fpga_if_get_instance();
#ifdef __cplusplus

2
usrc/main.cpp

@ -159,6 +159,8 @@ void umain() {
// }
// count++;
// ZLOGI(TAG, "fpga_if_init: %d", xs_gpio_read(&fpga_if_get_instance()->xsync_workstate_start_sig_irq_io));
// ZLOGI(TAG, "rxdata: %x", rxdata);
}
}

42
usrc/service/report_generator_service.c

@ -16,8 +16,10 @@ osThreadId xync_signal_report_thread_id;
static uint32_t m_sync_count = 0;
static uint32_t m_camera_sync_packet_report_period = 1;
static uint32_t m_xsync_workstate_start_sig_irq_pin_off;
static uint32_t m_timecode_trigger_input_off;
static uint32_t m_xync_trigger_input_off;
static uint32_t m_xync_trigger_input_off;
#define TAG "timecode"
/**
* @brief
@ -26,12 +28,21 @@ static uint32_t m_xync_trigger_input_off;
* @param timecode0
* @param timecode1
*/
static void create_and_send_timecode(uint32_t timecode0, uint32_t timecode1) {
static uint8_t txbuf[256];
iflytop_timecode_report_packet_t *txpacket = (iflytop_timecode_report_packet_t *)txbuf;
txpacket->timecode0 = timecode0;
txpacket->timecode1 = timecode1;
xs_udp_broadcast(&m_udp_camera_timecode_sender, IFLYTOP_XSYNC_TIMECODE_REPORT_PC_PORT, txbuf, sizeof(iflytop_timecode_report_packet_t));
static uint8_t txbuf[256];
iflytop_xsync_event_report_packet_t *txpacket = (iflytop_xsync_event_report_packet_t *)txbuf;
txpacket->eventid = ktimecode_report_event;
txpacket->data[0] = timecode0;
txpacket->data[1] = timecode1;
xs_udp_broadcast(&m_udp_camera_timecode_sender, IFLYTOP_XSYNC_EVENT_REPORT_PC_PORT, txbuf, sizeof(iflytop_xsync_event_report_packet_t) + 8);
}
static void create_and_send_sync_workstate_packet(uint32_t workstate) {
static uint8_t txbuf[256];
iflytop_xsync_event_report_packet_t *txpacket = (iflytop_xsync_event_report_packet_t *)txbuf;
txpacket->eventid = kxsync_work_state_report_event;
txpacket->data[0] = workstate;
xs_udp_broadcast(&m_udp_camera_timecode_sender, IFLYTOP_XSYNC_EVENT_REPORT_PC_PORT, txbuf, sizeof(iflytop_xsync_event_report_packet_t) + 4);
}
/**
* @brief
@ -54,13 +65,16 @@ static void create_and_send_camera_sync_msg(uint32_t count) {
static void timecode_report_thread(void const *argument) {
while (true) {
osEvent signal = osSignalWait(0x01, osWaitForever);
if (signal.value.signals == 0x01) {
osEvent signal = osSignalWait(0x03, osWaitForever);
if (signal.value.signals & 0x01) {
uint32_t timecode0, timecode1;
fpga_if_get_timecode(&timecode0, &timecode1);
create_and_send_timecode(timecode0, timecode1);
} else if (signal.value.signals & 0x02) {
uint32_t workstate;
fpga_if_get_workstate(&workstate);
create_and_send_sync_workstate_packet(workstate);
}
// osSignalClear(timecode_report_thread_id, 0x01);
}
}
static void xync_signal_report_thread(void const *argument) {
@ -78,9 +92,11 @@ static void xync_signal_report_thread(void const *argument) {
void ReportGeneratorService_irq_trigger(uint16_t gpiopin) {
if (gpiopin == m_timecode_trigger_input_off) {
// printf("1trigger\n");
osSignalSet(timecode_report_thread_id, 0x01);
}
if (m_xsync_workstate_start_sig_irq_pin_off == gpiopin) {
osSignalSet(timecode_report_thread_id, 0x02);
}
if (gpiopin == m_xync_trigger_input_off) {
// printf("2trigger\n");
osSignalSet(xync_signal_report_thread_id, 0x01);
@ -89,8 +105,9 @@ void ReportGeneratorService_irq_trigger(uint16_t gpiopin) {
void ReportGeneratorService_init() {
ZASSERT(xs_udp_broadcast_init(&m_udp_camera_sync_sender, IFLYTOP_XSYNC_CAMERA_SYNC_PACKET_XSYNC_PORT));
ZASSERT(xs_udp_broadcast_init(&m_udp_camera_timecode_sender, IFLYTOP_XSYNC_TIMECODE_REPORT_XSYNC_PORT));
ZASSERT(xs_udp_broadcast_init(&m_udp_camera_timecode_sender, IFLYTOP_XSYNC_EVENT_REPORT_XSYNC_PORT));
//
osThreadDef(timecode_report_thread, timecode_report_thread, TIMECODE_REPORT_TASK_LEVEL, 0, 512);
timecode_report_thread_id = osThreadCreate(osThread(timecode_report_thread), NULL);
@ -100,8 +117,9 @@ void ReportGeneratorService_init() {
ZASSERT(timecode_report_thread_id != NULL);
ZASSERT(xync_signal_report_thread_id != NULL);
m_timecode_trigger_input_off = fpga_if_get_instance()->timecode_irq_io.pinoff;
m_xync_trigger_input_off = fpga_if_get_instance()->camera_sync_code_irq_io.pinoff;
m_timecode_trigger_input_off = fpga_if_get_instance()->timecode_irq_io.pinoff;
m_xync_trigger_input_off = fpga_if_get_instance()->camera_sync_code_irq_io.pinoff;
m_xsync_workstate_start_sig_irq_pin_off = fpga_if_get_instance()->xsync_workstate_start_sig_irq_io.pinoff;
}
void ReportGeneratorService_xsync_set_count(uint32_t count) { m_sync_count = count; }

Loading…
Cancel
Save