From 53b3abb197c797840e01e920fb82bfc6c9578368 Mon Sep 17 00:00:00 2001
From: dkk0918 <13262679180@163.com>
Date: Wed, 9 Dec 2020 20:21:44 +0800
Subject: [PATCH] test pass
---
.../TencentOS_tiny_STM32L496ZGTx.dbgconf | 77 +++++++++++++++++++
.../RTE/_TencentOS_tiny/RTE_Components.h | 21 +++++
.../tflitemicro_person_detection.c | 24 +++++-
3 files changed, 121 insertions(+), 1 deletion(-)
create mode 100644 board/NUCLEO_STM32L496ZG/KEIL/tflitemicro_person_detection/DebugConfig/TencentOS_tiny_STM32L496ZGTx.dbgconf
create mode 100644 board/NUCLEO_STM32L496ZG/KEIL/tflitemicro_person_detection/RTE/_TencentOS_tiny/RTE_Components.h
diff --git a/board/NUCLEO_STM32L496ZG/KEIL/tflitemicro_person_detection/DebugConfig/TencentOS_tiny_STM32L496ZGTx.dbgconf b/board/NUCLEO_STM32L496ZG/KEIL/tflitemicro_person_detection/DebugConfig/TencentOS_tiny_STM32L496ZGTx.dbgconf
new file mode 100644
index 00000000..979440d7
--- /dev/null
+++ b/board/NUCLEO_STM32L496ZG/KEIL/tflitemicro_person_detection/DebugConfig/TencentOS_tiny_STM32L496ZGTx.dbgconf
@@ -0,0 +1,77 @@
+// File: STM32L4x5_4x6.dbgconf
+// Version: 1.0.0
+// Note: refer to STM32L4x5 and STM32L4x6 Reference manual (RM0351)
+// refer to STM32L475xx STM32L476xx STM32L486xx STM32L496xx STM32L4A6xx datasheets
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+// Debug MCU configuration register (DBGMCU_CR)
+// DBG_STANDBY Debug Standby mode
+// DBG_STOP Debug Stop mode
+// DBG_SLEEP Debug Sleep mode
+//
+DbgMCU_CR = 0x00000007;
+
+// Debug MCU APB1 freeze register1 (DBGMCU_APB1FZR1)
+// Reserved bits must be kept at reset value
+// DBG_LPTIM1_STOP LPTIM1 counter stopped when core is halted
+// DBG_CAN2_STOP bxCAN2 stopped when core is halted
+// DBG_CAN1_STOP bxCAN1 stopped when core is halted
+// DBG_I2C3_STOP I2C3 SMBUS timeout counter stopped when core is halted
+// DBG_I2C2_STOP I2C2 SMBUS timeout counter stopped when core is halted
+// DBG_I2C1_STOP I2C1 SMBUS timeout counter stopped when core is halted
+// DBG_IWDG_STOP Independent watchdog counter stopped when core is halted
+// DBG_WWDG_STOP Window watchdog counter stopped when core is halted
+// DBG_RTC_STOP RTC counter stopped when core is halted
+// DBG_TIM7_STOP TIM7 counter stopped when core is halted
+// DBG_TIM6_STOP TIM6 counter stopped when core is halted
+// DBG_TIM5_STOP TIM5 counter stopped when core is halted
+// DBG_TIM4_STOP TIM4 counter stopped when core is halted
+// DBG_TIM3_STOP TIM3 counter stopped when core is halted
+// DBG_TIM2_STOP TIM2 counter stopped when core is halted
+//
+DbgMCU_APB1_Fz1 = 0x00000000;
+
+// Debug MCU APB1 freeze register 2 (DBGMCU_APB1FZR2)
+// Reserved bits must be kept at reset value
+// DBG_LPTIM2_STOP LPTIM2 counter stopped when core is halted
+// DBG_I2C4_STOP I2C4 SMBUS timeout counter stopped when core is halted
+//
+DbgMCU_APB1_Fz2 = 0x00000000;
+
+// Debug MCU APB2 freeze register (DBGMCU_APB2FZR)
+// Reserved bits must be kept at reset value
+// DBG_TIM17_STOP TIM17 counter stopped when core is halted
+// DBG_TIM16_STOP TIM16 counter stopped when core is halted
+// DBG_TIM15_STOP TIM15 counter stopped when core is halted
+// DBG_TIM8_STOP TIM8 counter stopped when core is halted
+// DBG_TIM1_STOP TIM1 counter stopped when core is halted
+//
+DbgMCU_APB2_Fz = 0x00000000;
+
+// TPIU Pin Routing (TRACECLK fixed on Pin PE2)
+// TRACECLK: Pin PE2
+// TRACED0
+// ETM Trace Data 0
+// <0x00040003=> Pin PE3
+// <0x00020001=> Pin PC1
+// TRACED1
+// ETM Trace Data 1
+// <0x00040004=> Pin PE4
+// <0x0002000A=> Pin PC10
+// TRACED2
+// ETM Trace Data 2
+// <0x00040005=> Pin PE5
+// <0x00030002=> Pin PD2
+// TRACED3
+// ETM Trace Data 3
+// <0x00040006=> Pin PE6
+// <0x0002000C=> Pin PC12
+//
+TraceClk_Pin = 0x00040002;
+TraceD0_Pin = 0x00040003;
+TraceD1_Pin = 0x00040004;
+TraceD2_Pin = 0x00040005;
+TraceD3_Pin = 0x00040006;
+
+// <<< end of configuration section >>>
diff --git a/board/NUCLEO_STM32L496ZG/KEIL/tflitemicro_person_detection/RTE/_TencentOS_tiny/RTE_Components.h b/board/NUCLEO_STM32L496ZG/KEIL/tflitemicro_person_detection/RTE/_TencentOS_tiny/RTE_Components.h
new file mode 100644
index 00000000..248f644f
--- /dev/null
+++ b/board/NUCLEO_STM32L496ZG/KEIL/tflitemicro_person_detection/RTE/_TencentOS_tiny/RTE_Components.h
@@ -0,0 +1,21 @@
+
+/*
+ * Auto generated Run-Time-Environment Configuration File
+ * *** Do not modify ! ***
+ *
+ * Project: 'TencentOS_tiny'
+ * Target: 'TencentOS_tiny'
+ */
+
+#ifndef RTE_COMPONENTS_H
+#define RTE_COMPONENTS_H
+
+
+/*
+ * Define the Device Header File:
+ */
+#define CMSIS_device_header "stm32l4xx.h"
+
+
+
+#endif /* RTE_COMPONENTS_H */
diff --git a/examples/tflitemicro_person_detection/tflitemicro_person_detection.c b/examples/tflitemicro_person_detection/tflitemicro_person_detection.c
index e68bb3bb..c6a2726e 100644
--- a/examples/tflitemicro_person_detection/tflitemicro_person_detection.c
+++ b/examples/tflitemicro_person_detection/tflitemicro_person_detection.c
@@ -3,6 +3,7 @@
extern uint16_t camBuffer[];
extern uint8_t frame_flag;
+static uint8_t modBuffer[96*96];
#define TASK1_STK_SIZE 1024
void task1(void *arg);
@@ -12,13 +13,34 @@ osThreadDef(task1, osPriorityNormal, 1, TASK1_STK_SIZE);
void task2(void *arg);
osThreadDef(task2, osPriorityNormal, 1, TASK2_STK_SIZE);
+uint8_t RGB565toGRAY(uint16_t bg_color)
+{
+ uint8_t bg_r = 0;
+ uint8_t bg_g = 0;
+ uint8_t bg_b = 0;
+ bg_r = ((bg_color>>11)&0xff)<<3;
+ bg_g = ((bg_color>>5)&0x3f)<<2;
+ bg_b = (bg_color&0x1f)<<2;
+ uint8_t gray = (bg_r*299 + bg_g*587 + bg_b*114 + 500) / 1000;
+ return gray;
+}
+
+void input_convert(uint16_t* camera_buffer , uint8_t* model_buffer)
+{
+ for(int i=0 ; i