34 changed files with 856 additions and 1185 deletions
-
12.cproject
-
6.vscode/settings.json
-
3Core/Inc/spi.h
-
5Core/Inc/stm32f4xx_it.h
-
6Core/Inc/usart.h
-
9Core/Src/dma.c
-
20Core/Src/gpio.c
-
3Core/Src/main.c
-
135Core/Src/spi.c
-
65Core/Src/stm32f4xx_it.c
-
224Core/Src/usart.c
-
147camera_light_src_timing_controller_stm32.ioc
-
1libzaf/zaf.h
-
6libzaf/zaf_bean.h
-
19usrc/base_service/config_service.c
-
86usrc/base_service/fpga_if.c
-
67usrc/base_service/fpga_if.h
-
14usrc/base_service/light_ctrl_service.c
-
17usrc/base_service/light_ctrl_service.h
-
0usrc/base_service/mac_generator.h
-
260usrc/base_service/xsync_regs.hpp
-
71usrc/main.cpp
-
63usrc/project_configs.h
-
194usrc/service/extern_if_service.c
-
10usrc/service/extern_if_service.h
-
102usrc/service/reg_manager.c
-
154usrc/service/report_generator_service.c
-
50usrc/service/report_generator_service.h
-
26zaf_protocol/zaf_ecode.c
-
12zaf_protocol/zaf_ecode.h
-
5zaf_protocol/zaf_port.h
-
2zaf_protocol/zaf_protocol.c
-
210zaf_protocol/zaf_protocol.h
-
37zaf_protocol/zaf_regs.hpp
@ -0,0 +1,6 @@ |
|||
#pragma once |
|||
#include <stdint.h> |
|||
typedef struct { |
|||
uint8_t* data; |
|||
uint32_t len; |
|||
} zaf_buf_t; |
@ -0,0 +1,14 @@ |
|||
#include "light_ctrl_service.h" |
|||
zaf_gpio_t rlight; |
|||
zaf_gpio_t glight; |
|||
zaf_gpio_t blight; |
|||
|
|||
void LightCtrlService_init() { |
|||
zaf_gpio_init_as_output(&rlight, LED_R_PIN, kxs_gpio_nopull, false, false); |
|||
zaf_gpio_init_as_output(&glight, LED_G_PIN, kxs_gpio_nopull, false, false); |
|||
zaf_gpio_init_as_output(&blight, LED_B_PIN, kxs_gpio_nopull, false, false); |
|||
} |
|||
|
|||
void LightCtrlService_RedLight_setState(bool state) { zaf_gpio_write(&rlight, state); } |
|||
void LightCtrlService_BlueLight_setState(bool state) { zaf_gpio_write(&blight, state); } |
|||
void LightCtrlService_GreenLight_setState(bool state) { zaf_gpio_write(&glight, state); } |
@ -0,0 +1,17 @@ |
|||
#pragma once |
|||
#include <stdint.h> |
|||
|
|||
#include "project_dep.h" |
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
void LightCtrlService_init(); |
|||
|
|||
void LightCtrlService_RedLight_setState(bool state); |
|||
void LightCtrlService_BlueLight_setState(bool state); |
|||
void LightCtrlService_GreenLight_setState(bool state); |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
@ -1,260 +0,0 @@ |
|||
#pragma once
|
|||
#define REG_ADD_OFF_STM32 (0x0000)
|
|||
#define REG_ADD_OFF_STM32_CONFIG_START_ADD (0x0010)
|
|||
|
|||
#define REGADDOFF__FPGA_INFO (0x0020)
|
|||
#define REGADDOFF__TTLIN (0x0100)
|
|||
#define REGADDOFF__EXTERNAL_TIMECODE (0x0120)
|
|||
#define REGADDOFF__EXTERNAL_GENLOCK (0x0130)
|
|||
#define REGADDOFF__INTERNAL_TIMECODE (0x0300)
|
|||
#define REGADDOFF__INTERNAL_GENLOCK (0x0310)
|
|||
#define REGADDOFF__INTERNAL_CLOCK (0x0320)
|
|||
#define REGADDOFF__TTLOUT1 (0x0200)
|
|||
#define REGADDOFF__TTLOUT2 (0x0210)
|
|||
#define REGADDOFF__TTLOUT3 (0x0220)
|
|||
#define REGADDOFF__TTLOUT4 (0x0230)
|
|||
#define REGADDOFF__TIMECODE_OUT (0x0240)
|
|||
#define REGADDOFF__GENLOCK_OUT (0x0250)
|
|||
#define REGADDOFF__CAMERA_SYNC_OUT (0x0260)
|
|||
#define REGADDOFF__SYS_TIMECODE (0x0400)
|
|||
#define REGADDOFF__SYS_GENLOCK (0x0410)
|
|||
#define REGADDOFF__SYS_CLOCK (0x0420)
|
|||
#define REGADDOFF__RECORD_SIG_GENERATOR (0x0500)
|
|||
|
|||
typedef enum { |
|||
/**
|
|||
* @brief |
|||
* REG 0(16) 设备信息基础寄存器 |
|||
*/ |
|||
ksoftware_version = 0, |
|||
kmanufacturer0 = 1, |
|||
kmanufacturer1 = 2, |
|||
kproduct_type_id = 3, |
|||
ksn_id0 = 4, |
|||
ksn_id1 = 5, |
|||
ksn_id2 = 6, |
|||
kmac0 = 7, |
|||
kmac1 = 8, |
|||
|
|||
/**
|
|||
* @brief |
|||
* REG 16(32) STM32配置寄存器0 |
|||
*/ |
|||
kstm32_obtaining_ip_mode = REG_ADD_OFF_STM32_CONFIG_START_ADD + 0, |
|||
kstm32_ip = REG_ADD_OFF_STM32_CONFIG_START_ADD + 1, |
|||
kstm32_gw = REG_ADD_OFF_STM32_CONFIG_START_ADD + 2, |
|||
kstm32_netmask = REG_ADD_OFF_STM32_CONFIG_START_ADD + 3, |
|||
kstm32_config0 = REG_ADD_OFF_STM32_CONFIG_START_ADD + 4, // bit0: timecode report enable, bit1: camera sync report enable
|
|||
kstm32_camera_sync_signal_count = REG_ADD_OFF_STM32_CONFIG_START_ADD + 5, // 写任意数值之后清零
|
|||
kstm32_camera_sync_signal_count_report_period = REG_ADD_OFF_STM32_CONFIG_START_ADD + 6, // 上报周期,单位为帧数
|
|||
|
|||
kstm32_action0 = REG_ADD_OFF_STM32_CONFIG_START_ADD + 14, // action reg
|
|||
kstm32_action_val0 = REG_ADD_OFF_STM32_CONFIG_START_ADD + 15, // action val reg
|
|||
|
|||
/**
|
|||
* @brief |
|||
* REG 48(32) FPGA配置寄存器0 |
|||
*/ |
|||
kfpga_info_reg0 = REGADDOFF__FPGA_INFO + 0, |
|||
kfpga_info_reg1 = REGADDOFF__FPGA_INFO + 1, |
|||
kfpga_info_reg2 = REGADDOFF__FPGA_INFO + 2, |
|||
kfpga_info_reg3 = REGADDOFF__FPGA_INFO + 3, |
|||
kfpga_info_reg4 = REGADDOFF__FPGA_INFO + 4, |
|||
kfpga_info_reg5 = REGADDOFF__FPGA_INFO + 5, |
|||
kfpga_info_reg6 = REGADDOFF__FPGA_INFO + 6, |
|||
kfpga_info_reg7 = REGADDOFF__FPGA_INFO + 7, |
|||
kfpga_info_reg8 = REGADDOFF__FPGA_INFO + 8, |
|||
kfpga_info_reg9 = REGADDOFF__FPGA_INFO + 9, |
|||
kfpga_info_rega = REGADDOFF__FPGA_INFO + 10, |
|||
kfpga_info_regb = REGADDOFF__FPGA_INFO + 11, |
|||
kfpga_info_regc = REGADDOFF__FPGA_INFO + 12, |
|||
kfpga_info_regd = REGADDOFF__FPGA_INFO + 13, |
|||
kfpga_info_rege = REGADDOFF__FPGA_INFO + 14, |
|||
kfpga_info_regf = REGADDOFF__FPGA_INFO + 15, |
|||
|
|||
/*******************************************************************************
|
|||
* TTL输入模块 * |
|||
*******************************************************************************/ |
|||
|
|||
k_ttlin_module = REGADDOFF__TTLIN + 0, |
|||
k_ttlin_en_reg = REGADDOFF__TTLIN + 1, |
|||
k_ttlin1_freq_detector_reg = REGADDOFF__TTLIN + 2, |
|||
k_ttlin2_freq_detector_reg = REGADDOFF__TTLIN + 3, |
|||
k_ttlin3_freq_detector_reg = REGADDOFF__TTLIN + 4, |
|||
k_ttlin4_freq_detector_reg = REGADDOFF__TTLIN + 5, |
|||
k_ttlin1_filter_factor_reg = REGADDOFF__TTLIN + 6, |
|||
k_ttlin2_filter_factor_reg = REGADDOFF__TTLIN + 7, |
|||
k_ttlin3_filter_factor_reg = REGADDOFF__TTLIN + 8, |
|||
k_ttlin4_filter_factor_reg = REGADDOFF__TTLIN + 9, |
|||
|
|||
/*******************************************************************************
|
|||
* TTL输出模块 * |
|||
*******************************************************************************/ |
|||
|
|||
kreg_ttlout1_module = REGADDOFF__TTLOUT1 + 0, |
|||
kreg_ttlout1_signal_process_mode = REGADDOFF__TTLOUT1 + 1, |
|||
kreg_ttlout1_input_signal_select = REGADDOFF__TTLOUT1 + 2, |
|||
kreg_ttlout1_pllout_freq_division_ctrl = REGADDOFF__TTLOUT1 + 3, |
|||
kreg_ttlout1_pllout_freq_multiplication_ctrl = REGADDOFF__TTLOUT1 + 4, |
|||
kreg_ttlout1_pllout_polarity_ctrl = REGADDOFF__TTLOUT1 + 5, |
|||
kreg_ttlout1_pllout_trigger_edge_select = REGADDOFF__TTLOUT1 + 6, |
|||
kreg_ttlout1_forward_mode_polarity_ctrl = REGADDOFF__TTLOUT1 + 7, |
|||
kreg_ttlout1_placeholder0 = REGADDOFF__TTLOUT1 + 8, |
|||
kreg_ttlout1_freq_detect_bias = REGADDOFF__TTLOUT1 + 9, |
|||
kreg_ttlout1_sig_in_freq_detect = REGADDOFF__TTLOUT1 + 0xE, |
|||
kreg_ttlout1_sig_out_freq_detect = REGADDOFF__TTLOUT1 + 0xF, |
|||
|
|||
kreg_ttlout2_module = REGADDOFF__TTLOUT2 + 0, |
|||
kreg_ttlout2_signal_process_mode = REGADDOFF__TTLOUT2 + 1, |
|||
kreg_ttlout2_input_signal_select = REGADDOFF__TTLOUT2 + 2, |
|||
kreg_ttlout2_pllout_freq_division_ctrl = REGADDOFF__TTLOUT2 + 3, |
|||
kreg_ttlout2_pllout_freq_multiplication_ctrl = REGADDOFF__TTLOUT2 + 4, |
|||
kreg_ttlout2_pllout_polarity_ctrl = REGADDOFF__TTLOUT2 + 5, |
|||
kreg_ttlout2_pllout_trigger_edge_select = REGADDOFF__TTLOUT2 + 6, |
|||
kreg_ttlout2_forward_mode_polarity_ctrl = REGADDOFF__TTLOUT2 + 7, |
|||
kreg_ttlout2_placeholder0 = REGADDOFF__TTLOUT2 + 8, |
|||
kreg_ttlout2_freq_detect_bias = REGADDOFF__TTLOUT2 + 9, |
|||
kreg_ttlout2_sig_in_freq_detect = REGADDOFF__TTLOUT2 + 0xE, |
|||
kreg_ttlout2_sig_out_freq_detect = REGADDOFF__TTLOUT2 + 0xF, |
|||
|
|||
kreg_ttlout3_module = REGADDOFF__TTLOUT3 + 0, |
|||
kreg_ttlout3_signal_process_mode = REGADDOFF__TTLOUT3 + 1, |
|||
kreg_ttlout3_input_signal_select = REGADDOFF__TTLOUT3 + 2, |
|||
kreg_ttlout3_pllout_freq_division_ctrl = REGADDOFF__TTLOUT3 + 3, |
|||
kreg_ttlout3_pllout_freq_multiplication_ctrl = REGADDOFF__TTLOUT3 + 4, |
|||
kreg_ttlout3_pllout_polarity_ctrl = REGADDOFF__TTLOUT3 + 5, |
|||
kreg_ttlout3_pllout_trigger_edge_select = REGADDOFF__TTLOUT3 + 6, |
|||
kreg_ttlout3_forward_mode_polarity_ctrl = REGADDOFF__TTLOUT3 + 7, |
|||
kreg_ttlout3_placeholder0 = REGADDOFF__TTLOUT3 + 8, |
|||
kreg_ttlout3_freq_detect_bias = REGADDOFF__TTLOUT3 + 9, |
|||
kreg_ttlout3_sig_in_freq_detect = REGADDOFF__TTLOUT3 + 0xE, |
|||
kreg_ttlout3_sig_out_freq_detect = REGADDOFF__TTLOUT3 + 0xF, |
|||
|
|||
kreg_ttlout4_module = REGADDOFF__TTLOUT4 + 0, |
|||
kreg_ttlout4_signal_process_mode = REGADDOFF__TTLOUT4 + 1, |
|||
kreg_ttlout4_input_signal_select = REGADDOFF__TTLOUT4 + 2, |
|||
kreg_ttlout4_pllout_freq_division_ctrl = REGADDOFF__TTLOUT4 + 3, |
|||
kreg_ttlout4_pllout_freq_multiplication_ctrl = REGADDOFF__TTLOUT4 + 4, |
|||
kreg_ttlout4_pllout_polarity_ctrl = REGADDOFF__TTLOUT4 + 5, |
|||
kreg_ttlout4_pllout_trigger_edge_select = REGADDOFF__TTLOUT4 + 6, |
|||
kreg_ttlout4_forward_mode_polarity_ctrl = REGADDOFF__TTLOUT4 + 7, |
|||
kreg_ttlout4_placeholder0 = REGADDOFF__TTLOUT4 + 8, |
|||
kreg_ttlout4_freq_detect_bias = REGADDOFF__TTLOUT4 + 9, |
|||
kreg_ttlout4_sig_in_freq_detect = REGADDOFF__TTLOUT4 + 0xE, |
|||
kreg_ttlout4_sig_out_freq_detect = REGADDOFF__TTLOUT4 + 0xF, |
|||
|
|||
/*******************************************************************************
|
|||
* TIMECODE输入模块 * |
|||
*******************************************************************************/ |
|||
|
|||
external_timecode_module = REGADDOFF__EXTERNAL_TIMECODE + 0, |
|||
external_timecode_sig_selt = REGADDOFF__EXTERNAL_TIMECODE + 1, |
|||
external_timecode_format = REGADDOFF__EXTERNAL_TIMECODE + 2, |
|||
external_timecode_code0 = REGADDOFF__EXTERNAL_TIMECODE + 3, |
|||
external_timecode_code1 = REGADDOFF__EXTERNAL_TIMECODE + 4, |
|||
|
|||
/*******************************************************************************
|
|||
* 内部TIMECODE模块 * |
|||
*******************************************************************************/ |
|||
|
|||
internal_timecode_module = REGADDOFF__INTERNAL_TIMECODE + 0, |
|||
internal_timecode_en = REGADDOFF__INTERNAL_TIMECODE + 1, |
|||
internal_timecode_format = REGADDOFF__INTERNAL_TIMECODE + 2, |
|||
internal_timecode_data0 = REGADDOFF__INTERNAL_TIMECODE + 3, |
|||
internal_timecode_data1 = REGADDOFF__INTERNAL_TIMECODE + 4, |
|||
|
|||
/*******************************************************************************
|
|||
* SYS_TIMECODE * |
|||
*******************************************************************************/ |
|||
|
|||
sys_timecode_module = REGADDOFF__SYS_TIMECODE, |
|||
sys_timecode_select = REGADDOFF__SYS_TIMECODE + 1, |
|||
sys_timecode_format = REGADDOFF__SYS_TIMECODE + 2, |
|||
sys_timecode_data0 = REGADDOFF__SYS_TIMECODE + 3, |
|||
sys_timecode_data1 = REGADDOFF__SYS_TIMECODE + 4, |
|||
|
|||
/*******************************************************************************
|
|||
* TIMECODE输出模块 * |
|||
*******************************************************************************/ |
|||
|
|||
timecode_output_module = REGADDOFF__TIMECODE_OUT + 0, |
|||
timecode_output_timecode0 = REGADDOFF__TIMECODE_OUT + 1, |
|||
timecode_output_timecode1 = REGADDOFF__TIMECODE_OUT + 2, |
|||
timecode_output_timecode_format = REGADDOFF__TIMECODE_OUT + 3, |
|||
timecode_output_bnc_outut_level_select = REGADDOFF__TIMECODE_OUT + 4, |
|||
timecode_output_headphone_outut_level_select = REGADDOFF__TIMECODE_OUT + 5, |
|||
|
|||
/*******************************************************************************
|
|||
* 外部GENLOCK * |
|||
*******************************************************************************/ |
|||
|
|||
external_genlock_module = REGADDOFF__EXTERNAL_GENLOCK + 0, |
|||
external_genlock_freq_detect_bias = REGADDOFF__EXTERNAL_GENLOCK + 1, |
|||
external_genlock_freq = REGADDOFF__EXTERNAL_GENLOCK + 2, |
|||
|
|||
/*******************************************************************************
|
|||
* 内部GENLOCK * |
|||
*******************************************************************************/ |
|||
internal_genlock_module = REGADDOFF__INTERNAL_GENLOCK + 0, |
|||
internal_genlock_ctrl_mode = REGADDOFF__INTERNAL_GENLOCK + 1, |
|||
internal_genlock_en = REGADDOFF__INTERNAL_GENLOCK + 2, |
|||
internal_genlock_format = REGADDOFF__INTERNAL_GENLOCK + 3, |
|||
internal_genlock_freq = REGADDOFF__INTERNAL_GENLOCK + 4, |
|||
|
|||
/*******************************************************************************
|
|||
* SYSGENLOCK * |
|||
*******************************************************************************/ |
|||
sys_genlock_module = REGADDOFF__SYS_GENLOCK, |
|||
sys_genlock_source = REGADDOFF__SYS_GENLOCK + 1, |
|||
sys_genlock_freq_detect_bias = REGADDOFF__SYS_GENLOCK + 2, |
|||
sys_genlock_freq = REGADDOFF__SYS_GENLOCK + 3, |
|||
|
|||
/*******************************************************************************
|
|||
* 内部CLOCK * |
|||
*******************************************************************************/ |
|||
|
|||
internal_clock_module = REGADDOFF__INTERNAL_CLOCK + 0, |
|||
internal_clock_ctrl_mode = REGADDOFF__INTERNAL_CLOCK + 1, |
|||
internal_clock_en = REGADDOFF__INTERNAL_CLOCK + 2, |
|||
internal_clock_freq = REGADDOFF__INTERNAL_CLOCK + 3, |
|||
|
|||
/*******************************************************************************
|
|||
* SYSCLOCK * |
|||
*******************************************************************************/ |
|||
sys_clock_module = REGADDOFF__SYS_CLOCK, |
|||
sys_clock_source = REGADDOFF__SYS_CLOCK + 1, |
|||
sys_clock_freq_division_ctrl = REGADDOFF__SYS_CLOCK + 2, |
|||
sys_clock_freq_multiplication_ctrl = REGADDOFF__SYS_CLOCK + 3, |
|||
sys_clock_freq_detect_bias = REGADDOFF__SYS_CLOCK + 4, |
|||
sys_clock_trigger_edge_select = REGADDOFF__SYS_CLOCK + 5, |
|||
sys_clock_infreq_detect = REGADDOFF__SYS_CLOCK + 0xE, |
|||
sys_clock_outfreq_detect = REGADDOFF__SYS_CLOCK + 0xF, |
|||
|
|||
/*******************************************************************************
|
|||
* record_sig_gen * |
|||
*******************************************************************************/ |
|||
record_sig_gen_module = REGADDOFF__RECORD_SIG_GENERATOR + 0, |
|||
record_sig_gen_ctrl_control_mode = REGADDOFF__RECORD_SIG_GENERATOR + 1, |
|||
record_sig_gen_timecode_start0 = REGADDOFF__RECORD_SIG_GENERATOR + 2, |
|||
record_sig_gen_timecode_start1 = REGADDOFF__RECORD_SIG_GENERATOR + 3, |
|||
record_sig_gen_timecode_stop0 = REGADDOFF__RECORD_SIG_GENERATOR + 4, |
|||
record_sig_gen_timecode_stop1 = REGADDOFF__RECORD_SIG_GENERATOR + 5, |
|||
record_sig_gen_timecode_control_flag = REGADDOFF__RECORD_SIG_GENERATOR + 6, |
|||
|
|||
record_sig_gen_ttlin_trigger_sig_source = REGADDOFF__RECORD_SIG_GENERATOR + 7, |
|||
record_sig_gen_ttlin_trigger_level = REGADDOFF__RECORD_SIG_GENERATOR + 8, |
|||
record_sig_gen_exposure_time = REGADDOFF__RECORD_SIG_GENERATOR + 9, |
|||
record_sig_gen_exposure_offset_time = REGADDOFF__RECORD_SIG_GENERATOR + 10, |
|||
record_sig_gen_manual_ctrl = REGADDOFF__RECORD_SIG_GENERATOR + 11, |
|||
|
|||
record_sig_gen_timecode_snapshot0 = REGADDOFF__RECORD_SIG_GENERATOR + 13, |
|||
record_sig_gen_timecode_snapshot1 = REGADDOFF__RECORD_SIG_GENERATOR + 14, |
|||
record_sig_gen_record_state = REGADDOFF__RECORD_SIG_GENERATOR + 15, |
|||
|
|||
/*******************************************************************************
|
|||
* camera_sync_module * |
|||
*******************************************************************************/ |
|||
camera_sync_module = REGADDOFF__CAMERA_SYNC_OUT + 0, |
|||
camera_sync_pulse_mode_valid_len = REGADDOFF__CAMERA_SYNC_OUT + 1, |
|||
|
|||
} RegAdd_t; |
@ -1,154 +0,0 @@ |
|||
#include "report_generator_service.h" |
|||
|
|||
#include "base_service/fpga_if.h" |
|||
#include "base_service/task_level_config.h" |
|||
#include "base_service/xsync_regs.hpp" |
|||
#include "reg_manager.h" |
|||
|
|||
static udp_broadcast_handler_t m_udp_camera_sync_sender; // |
|||
static udp_broadcast_handler_t m_udp_camera_timecode_sender; // |
|||
|
|||
osThreadId timecode_report_thread_id; |
|||
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_xyns_camera_sync_packet_last_report_tp; |
|||
#define TAG "timecode" |
|||
/** |
|||
* @brief 构建并发送时间码数据包 |
|||
* |
|||
* @param client |
|||
* @param timecode0 |
|||
* @param timecode1 |
|||
*/ |
|||
|
|||
static void create_and_send_timecode(uint32_t timecode0, uint32_t timecode1) { |
|||
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; |
|||
zaf_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_record_state_packet(uint32_t workstate, uint32_t timecode0, uint32_t timecode1) { |
|||
static uint8_t txbuf[256]; |
|||
uint32_t packetdatalen = 3; |
|||
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; |
|||
txpacket->data[1] = timecode0; |
|||
txpacket->data[2] = timecode1; |
|||
|
|||
zaf_udp_broadcast(&m_udp_camera_timecode_sender, IFLYTOP_XSYNC_EVENT_REPORT_PC_PORT, txbuf, sizeof(iflytop_xsync_event_report_packet_t) + 4 * packetdatalen); |
|||
} |
|||
/** |
|||
* @brief 构建并发送相机同步数据包 |
|||
* |
|||
* @param count |
|||
*/ |
|||
static void create_and_send_camera_sync_msg(uint32_t count) { |
|||
static uint8_t txbuf[] = { |
|||
0xF0, 0x00, 0x20, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xF0, 0x42, 0x17, 0x00, 0x00, 0x00, 0xE1, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, |
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|||
}; |
|||
|
|||
txbuf[7] = count & 0xFF; |
|||
txbuf[6] = (count >> 8) & 0xFF; |
|||
txbuf[5] = (count >> 16) & 0xFF; |
|||
txbuf[4] = (count >> 24) & 0xFF; |
|||
|
|||
zaf_udp_broadcast(&m_udp_camera_sync_sender, IFLYTOP_XSYNC_CAMERA_SYNC_PACKET_PC_PORT, txbuf, sizeof(txbuf)); |
|||
} |
|||
|
|||
static void timecode_report_thread(void const *argument) { |
|||
while (true) { |
|||
osEvent signal = osSignalWait(0x07, osWaitForever); |
|||
if (signal.value.signals & 0x01) { |
|||
uint32_t timecode0, timecode1; |
|||
fpga_if_get_timecode(&timecode0, &timecode1); |
|||
create_and_send_timecode(timecode0, timecode1); |
|||
} |
|||
if (signal.value.signals & 0x02) { |
|||
// 开始录制 |
|||
uint32_t timecode0 = 0; |
|||
uint32_t timecode1 = 0; |
|||
fpga_if_spi_read_data_02(record_sig_gen_timecode_snapshot0, &timecode0); |
|||
fpga_if_spi_read_data_02(record_sig_gen_timecode_snapshot1, &timecode1); |
|||
create_and_send_sync_record_state_packet(1, timecode0, timecode1); |
|||
} |
|||
if (signal.value.signals & 0x04) { |
|||
// 结束录制 |
|||
uint32_t timecode0 = 0; |
|||
uint32_t timecode1 = 0; |
|||
fpga_if_spi_read_data_02(record_sig_gen_timecode_snapshot0, &timecode0); |
|||
fpga_if_spi_read_data_02(record_sig_gen_timecode_snapshot1, &timecode1); |
|||
create_and_send_sync_record_state_packet(0, timecode0, timecode1); |
|||
m_sync_count = 0; |
|||
} |
|||
} |
|||
} |
|||
static void xync_signal_report_thread(void const *argument) { |
|||
while (true) { |
|||
osEvent signal = osSignalWait(0x01, osWaitForever); |
|||
if (signal.value.signals == 0x01) { |
|||
if (m_sync_count == 0) { |
|||
m_xyns_camera_sync_packet_last_report_tp = HAL_GetTick(); |
|||
create_and_send_camera_sync_msg(m_sync_count); |
|||
m_sync_count++; |
|||
} else if (zaf_has_passedms(m_xyns_camera_sync_packet_last_report_tp) >= 998) { |
|||
// TODO:此处这么写,当拍摄频率大于500HZ的时候,就不能完全满足刚好卡在1s上报一次消息 |
|||
m_xyns_camera_sync_packet_last_report_tp = HAL_GetTick(); |
|||
create_and_send_camera_sync_msg(m_sync_count); |
|||
m_sync_count++; |
|||
} else { |
|||
m_sync_count++; |
|||
} |
|||
} |
|||
// osSignalClear(xync_signal_report_thread_id, 0x01); |
|||
} |
|||
} |
|||
|
|||
void ReportGeneratorService_irq_trigger(uint16_t gpiopin) { |
|||
if (gpiopin == m_timecode_trigger_input_off) { |
|||
// timecode trigger sig |
|||
osSignalSet(timecode_report_thread_id, 0x01); |
|||
} |
|||
if (m_xsync_workstate_start_sig_irq_pin_off == gpiopin) { |
|||
if (zaf_gpio_read(&fpga_if_get_instance()->xsync_workstate_start_sig_irq_io)) { |
|||
osSignalSet(timecode_report_thread_id, 0x02); // 开始工作信号 |
|||
} else { |
|||
osSignalSet(timecode_report_thread_id, 0x04); // 结束工作信号 |
|||
} |
|||
} |
|||
if (gpiopin == m_xync_trigger_input_off) { |
|||
// 相机同步信号 |
|||
osSignalSet(xync_signal_report_thread_id, 0x01); |
|||
} |
|||
} |
|||
|
|||
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_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); |
|||
|
|||
osThreadDef(xync_signal_report_thread, xync_signal_report_thread, CAMERA_SYNC_SIG_REPORT_TASK_LEVEL, 0, 512); |
|||
xync_signal_report_thread_id = osThreadCreate(osThread(xync_signal_report_thread), NULL); |
|||
|
|||
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_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; } |
|||
uint32_t ReportGeneratorService_xsync_get_count(void) { return m_sync_count; } |
@ -1,50 +0,0 @@ |
|||
#pragma once |
|||
#include <stdint.h> |
|||
|
|||
#include "project_dep.h" |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/** |
|||
* @brief 模块说明 |
|||
* 该模块监听FPGA秒时钟中断,和timecode中断 |
|||
* 当中断发生时,上报相应的数据。 |
|||
* |
|||
* 该模块依赖: |
|||
* fpag_if.c |
|||
* config_service.c |
|||
*/ |
|||
|
|||
/** |
|||
* @brief 初始化上报模块 |
|||
* |
|||
* @param timecode_trigger_pin |
|||
* @param xync_trigger_pin |
|||
*/ |
|||
void ReportGeneratorService_init(); |
|||
|
|||
/** |
|||
* @brief 中断触发函数,当IO中断触发时,调用此方法 |
|||
* |
|||
* @param gpiopin |
|||
*/ |
|||
void ReportGeneratorService_irq_trigger(uint16_t gpiopin); |
|||
/** |
|||
* @brief 清除xync计数 |
|||
*/ |
|||
void ReportGeneratorService_xsync_set_count(uint32_t count); |
|||
/** |
|||
* @brief 获取xync计数 |
|||
* |
|||
* @return uint32_t |
|||
*/ |
|||
uint32_t ReportGeneratorService_xsync_get_count(void); |
|||
|
|||
uint32_t ReportGeneratorService_set_camera_sync_code_report_period(uint32_t period); |
|||
uint32_t ReportGeneratorService_get_camera_sync_code_report_period(void); |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
@ -0,0 +1,26 @@ |
|||
#include "zaf_ecode.h" |
|||
|
|||
const char* zaf_error_code_2_str(zaf_error_code_t ecode) { |
|||
switch (ecode) { |
|||
case kxs_ec_success: |
|||
return "success"; |
|||
case kxs_ec_overtime: |
|||
return "overtime"; |
|||
case kxs_ec_socket_fail: |
|||
return "socket fail"; |
|||
case kxs_ec_bind_fail: |
|||
return "bind fail"; |
|||
case kxs_ec_send_fail: |
|||
return "send fail"; |
|||
case kxs_ec_receive_fail: |
|||
return "receive fail"; |
|||
case kxs_ec_setsockopt_rx_timeout_fail: |
|||
return "setsockopt rx timeout fail"; |
|||
case kxs_ec_lose_connect: |
|||
return "lose connect"; |
|||
case kxs_ec_param_error: |
|||
return "param error"; |
|||
default: |
|||
return "unknown error"; |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
#pragma once |
|||
typedef enum { |
|||
kxs_ec_success = 0, |
|||
kxs_ec_overtime = 1, |
|||
kxs_ec_socket_fail = 2, |
|||
kxs_ec_bind_fail = 3, |
|||
kxs_ec_send_fail = 4, |
|||
kxs_ec_receive_fail = 5, |
|||
kxs_ec_setsockopt_rx_timeout_fail = 6, |
|||
kxs_ec_lose_connect = 7, |
|||
kxs_ec_param_error = 8, |
|||
} zaf_error_code_t; |
@ -0,0 +1,5 @@ |
|||
#pragma once |
|||
#include <stdint.h> |
|||
|
|||
#define ZAF_SERVICE_DEVICE_PORT 20000 // 设备 端端口 |
|||
#define ZAF_SERVICE_PC_PORT 20001 // pc 端端口 |
@ -0,0 +1,2 @@ |
|||
#include "zaf_protocol.h" |
|||
|
@ -0,0 +1,37 @@ |
|||
#pragma once
|
|||
#define REGADD__STM32_COMMON (0x0010)
|
|||
#define REGADD__STM32_BUSINESS (0x0020)
|
|||
#define REGADD__FPGA_START (0x0100)
|
|||
|
|||
typedef enum { |
|||
/**
|
|||
* @brief |
|||
* REG 0(16) 设备信息基础寄存器 |
|||
*/ |
|||
kreg_software_version = 0, |
|||
kreg_manufacturer0 = 1, |
|||
kreg_manufacturer1 = 2, |
|||
kreg_product_type_id = 3, |
|||
kreg_sn_id0 = 4, |
|||
kreg_sn_id1 = 5, |
|||
kreg_sn_id2 = 6, |
|||
kreg_mac0 = 7, |
|||
kreg_mac1 = 8, |
|||
|
|||
/**
|
|||
* @brief |
|||
* REG 16(32) STM32配置寄存器0 |
|||
*/ |
|||
kreg_stm32_obtaining_ip_mode = REGADD__STM32_COMMON + 0, |
|||
kreg_stm32_ip = REGADD__STM32_COMMON + 1, |
|||
kreg_stm32_gw = REGADD__STM32_COMMON + 2, |
|||
kreg_stm32_netmask = REGADD__STM32_COMMON + 3, |
|||
kreg_stm32_config0 = REGADD__STM32_COMMON + 4, // bit0: timecode report enable, bit1: camera sync report enable
|
|||
|
|||
kreg_stm32_action0 = REGADD__STM32_COMMON + 14, // action reg
|
|||
kreg_stm32_action_val0 = REGADD__STM32_COMMON + 15, // action val reg
|
|||
|
|||
kreg_stm32_temperature = REGADD__STM32_BUSINESS + 0, |
|||
kreg_stm32_fan0_error_flag = REGADD__STM32_BUSINESS + 1, |
|||
|
|||
} RegAdd_t; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue