Browse Source

添加相机同步消息上报

v5
zhaohe 2 years ago
parent
commit
ba1f301e52
  1. 2
      .cproject
  2. 2
      iflytop_xsync_protocol
  3. 4
      usrc/main.cpp
  4. 15
      usrc/service/reg_manager.c
  5. 27
      usrc/service/report_generator_service.c
  6. 11
      usrc/service/report_generator_service.h

2
.cproject

@ -40,7 +40,7 @@
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.782799112" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1115926827" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.390305872" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.390305872" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.ofast" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1156405800" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>

2
iflytop_xsync_protocol

@ -1 +1 @@
Subproject commit cb1114b21bf415053cdaeb7ed2940406e48d378b
Subproject commit 84282337481ec1cfd91a621e245b0a73cf3b1bd5

4
usrc/main.cpp

@ -39,7 +39,7 @@ xs_gpio_t m_debug_led;
xs_gpio_t m_factory_reset_key;
xs_gpio_t m_power_led;
extern "C" {
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { report_generator_service_irq_trigger(GPIO_Pin); }
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { ReportGeneratorService_irq_trigger(GPIO_Pin); }
}
void debug_light_ctrl() {
@ -120,7 +120,7 @@ void umain() {
/**
* @brief report_generator init
*/
report_generator_service_init(fpga_if_get_instance()->timecode_irq_pin, fpga_if_get_instance()->camera_sync_code_irq_pin);
ReportGeneratorService_init(fpga_if_get_instance()->timecode_irq_pin, fpga_if_get_instance()->camera_sync_code_irq_pin);
/**
* @brief reg_manager init

15
usrc/service/reg_manager.c

@ -69,11 +69,14 @@ uint32_t reg_manager_read_reg(uint32_t addr) {
readbak = config_get()->gw;
} else if (addr == kxsync_reg_stm32_netmask) {
readbak = config_get()->netmask;
} else if (addr == kxsync_reg_stm32_camera_sync_signal_count) {
readbak = report_generator_service_xsync_get_count();
} else if (addr == kxsync_reg_stm32_config0) {
readbak = config_get()->config0;
} else if (addr == kxsync_reg_stm32_camera_sync_signal_count) {
readbak = ReportGeneratorService_xsync_get_count();
} else if (addr == kxsync_reg_stm32_camera_sync_signal_report_period) {
readbak = ReportGeneratorService_get_camera_sync_code_report_period();
}
/*******************************************************************************
* ACTION *
*******************************************************************************/
@ -121,11 +124,13 @@ uint32_t reg_manager_write_reg(uint32_t addr, uint32_t value) {
} else if (addr == kxsync_reg_stm32_netmask) {
config_get()->netmask = value;
readbak = config_get()->netmask;
} else if (addr == kxsync_reg_stm32_camera_sync_signal_count) {
report_generator_service_xsync_set_count(value);
readbak = report_generator_service_xsync_get_count();
} else if (addr == kxsync_reg_stm32_config0) {
readbak = config_get()->config0;
} else if (addr == kxsync_reg_stm32_camera_sync_signal_count) {
ReportGeneratorService_xsync_set_count(value);
readbak = ReportGeneratorService_xsync_get_count();
} else if (addr == kxsync_reg_stm32_camera_sync_signal_report_period) {
readbak = ReportGeneratorService_set_camera_sync_code_report_period(value);
}
/*******************************************************************************

27
usrc/service/report_generator_service.c

@ -3,9 +3,9 @@
#include "project_dep.h"
//
#include "base_service/fpga_if.h"
#include "base_service/task_level_config.h"
#include "iflytop_xsync\xs_udp.h"
#include "reg_manager.h"
#include "base_service/task_level_config.h"
static udp_broadcast_handler_t m_udp_camera_sync_sender; //
static udp_broadcast_handler_t m_udp_camera_timecode_sender; //
@ -13,7 +13,8 @@ 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_sync_count = 0;
static uint32_t m_camera_sync_packet_report_period = 1;
static uint32_t m_timecode_trigger_input_off;
static uint32_t m_xync_trigger_input_off;
@ -65,12 +66,17 @@ static void timecode_report_thread(void const *argument) {
static void xync_signal_report_thread(void const *argument) {
while (true) {
osEvent signal = osSignalWait(0x01, osWaitForever);
if (signal.value.signals == 0x01) create_and_send_camera_sync_msg(m_sync_count++);
if (signal.value.signals == 0x01) {
if (m_sync_count % m_camera_sync_packet_report_period == 0) {
create_and_send_camera_sync_msg(m_sync_count);
}
m_sync_count++;
}
// osSignalClear(xync_signal_report_thread_id, 0x01);
}
}
void report_generator_service_irq_trigger(uint16_t gpiopin) {
void ReportGeneratorService_irq_trigger(uint16_t gpiopin) {
if (gpiopin == m_timecode_trigger_input_off) {
// printf("1trigger\n");
osSignalSet(timecode_report_thread_id, 0x01);
@ -81,7 +87,7 @@ void report_generator_service_irq_trigger(uint16_t gpiopin) {
}
}
void report_generator_service_init() {
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));
@ -98,7 +104,12 @@ void report_generator_service_init() {
m_xync_trigger_input_off = fpga_if_get_instance()->camera_sync_code_irq_io.pinoff;
}
void report_generator_service_xsync_set_count(uint32_t count){
m_sync_count = count;
void ReportGeneratorService_xsync_set_count(uint32_t count) { m_sync_count = count; }
uint32_t ReportGeneratorService_xsync_get_count(void) { return m_sync_count; }
uint32_t ReportGeneratorService_set_camera_sync_code_report_period(uint32_t period) {
if (period == 0) period = 1;
m_camera_sync_packet_report_period = period;
return period;
}
uint32_t report_generator_service_xsync_get_count(void) { return m_sync_count; }
uint32_t ReportGeneratorService_get_camera_sync_code_report_period(void) { return m_camera_sync_packet_report_period; }

11
usrc/service/report_generator_service.h

@ -23,24 +23,27 @@ extern "C" {
* @param timecode_trigger_pin
* @param xync_trigger_pin
*/
void report_generator_service_init(Pin_t timecode_trigger_pin, Pin_t xync_trigger_pin);
void ReportGeneratorService_init(Pin_t timecode_trigger_pin, Pin_t xync_trigger_pin);
/**
* @brief IO中断触发时
*
* @param gpiopin
*/
void report_generator_service_irq_trigger(uint16_t gpiopin);
void ReportGeneratorService_irq_trigger(uint16_t gpiopin);
/**
* @brief xync计数
*/
void report_generator_service_xsync_set_count(uint32_t count);
void ReportGeneratorService_xsync_set_count(uint32_t count);
/**
* @brief xync计数
*
* @return uint32_t
*/
uint32_t report_generator_service_xsync_get_count(void);
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
}
Loading…
Cancel
Save