diff --git a/keilp/cc_as_stc02_ps5ws.uvprojx b/keilp/cc_as_stc02_ps5ws.uvprojx index 60abb09..2c8a7a6 100644 --- a/keilp/cc_as_stc02_ps5ws.uvprojx +++ b/keilp/cc_as_stc02_ps5ws.uvprojx @@ -13,14 +13,14 @@ 0 - STC8F2K64S4 - STC - IRAM(0-0xFF) XRAM(0-0x07FF) IROM(0-0xFFF8) CLOCK(35000000) MODP2 + stc8a8k64s4a12 + stc + - "LIB\STARTUP.A51" ("Standard 8051 Startup Code") + - 63032 - STC8.H + 0 + @@ -36,8 +36,8 @@ d:\Keil\C51\BIN\ - STC\ - STC\ + + 0 0 @@ -107,14 +107,14 @@ 65535 - S8051.DLL + - DP51.DLL - -pDP8051 - S8051.DLL + + + - TP51.DLL - -p51 + + @@ -136,7 +136,7 @@ 0 - "" () + @@ -154,12 +154,12 @@ 0 0 0 - 1 - 1 - 1 + 0 + 0 + 0 0 0 - 1 + 0 0 0 0 @@ -232,17 +232,17 @@ 1 0x0 - 0xfff9 + 0x0 0 0x0 - 0x100 + 0x0 0 0x0 - 0x800 + 0x0 0 @@ -277,7 +277,7 @@ 2 0 1 - 0 + 1 0 @@ -341,19 +341,34 @@ ..\source\app\main.c - common.c + task_adc.c + 1 + ..\source\app\task_adc.c + + + task_debug.c 1 - ..\source\app\common.c + ..\source\app\task_debug.c - app_task_uart0.c + task_register.c 1 - ..\source\app\app_task_uart0.c + ..\source\app\task_register.c - app_task_adc.c + task_modbus.c 1 - ..\source\app\app_task_adc.c + ..\source\app\task_modbus.c + + + app_config.c + 1 + ..\source\app\app_config.c + + + task_encrypt.c + 1 + ..\source\app\task_encrypt.c @@ -381,19 +396,14 @@ ..\source\msp\UART0.C - msp_eeprom.c - 1 - ..\source\msp\msp_eeprom.c - - - msp_id.c + eeprom.c 1 - ..\source\msp\msp_id.c + ..\source\msp\eeprom.c - UARTN.C + uart_x.c 1 - ..\source\msp\UARTN.C + ..\source\msp\uart_x.c @@ -401,19 +411,24 @@ bsp - bsp_cs1232.c + bsp_config.c 1 - ..\source\bsp\bsp_cs1232.c + ..\source\bsp\bsp_config.c - bsp_485.c + chipid.c 1 - ..\source\bsp\bsp_485.c + ..\source\bsp\chipid.c - bsp_config.c + cs1232.c 1 - ..\source\bsp\bsp_config.c + ..\source\bsp\cs1232.c + + + rs485.c + 1 + ..\source\bsp\rs485.c @@ -436,24 +451,9 @@ tpc - tpc_modbus.c - 1 - ..\source\tpc\tpc_modbus.c - - - tpc_0d0a.c - 1 - ..\source\tpc\tpc_0d0a.c - - - tpc_ccmodbus.c + modbus.c 1 - ..\source\tpc\tpc_ccmodbus.c - - - tpc_debug.c - 1 - ..\source\tpc\tpc_debug.c + ..\source\tpc\modbus.c @@ -467,16 +467,6 @@ - - debug - - - cc_as_stc01_main.ini - 5 - ..\source\debug\cc_as_stc01_main.ini - - - diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_sym b/si4/ps5ws.si4project/soft_ps5ws.sip_sym index f734da4..418885b 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_sym and b/si4/ps5ws.si4project/soft_ps5ws.sip_sym differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xab b/si4/ps5ws.si4project/soft_ps5ws.sip_xab index 28241b7..5bf140e 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xab and b/si4/ps5ws.si4project/soft_ps5ws.sip_xab differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xad b/si4/ps5ws.si4project/soft_ps5ws.sip_xad index e4c7691..01d23be 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xad and b/si4/ps5ws.si4project/soft_ps5ws.sip_xad differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xc b/si4/ps5ws.si4project/soft_ps5ws.sip_xc index 86e6e41..9fc6263 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xc and b/si4/ps5ws.si4project/soft_ps5ws.sip_xc differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xf b/si4/ps5ws.si4project/soft_ps5ws.sip_xf index 204ad71..781c4cb 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xf and b/si4/ps5ws.si4project/soft_ps5ws.sip_xf differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xm b/si4/ps5ws.si4project/soft_ps5ws.sip_xm index 9a0d508..552e261 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xm and b/si4/ps5ws.si4project/soft_ps5ws.sip_xm differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xr b/si4/ps5ws.si4project/soft_ps5ws.sip_xr index e4319c6..5e3a885 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xr and b/si4/ps5ws.si4project/soft_ps5ws.sip_xr differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xsb b/si4/ps5ws.si4project/soft_ps5ws.sip_xsb index 57d1b12..4dba72f 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xsb and b/si4/ps5ws.si4project/soft_ps5ws.sip_xsb differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.sip_xsd b/si4/ps5ws.si4project/soft_ps5ws.sip_xsd index e6a6da5..62ef520 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.sip_xsd and b/si4/ps5ws.si4project/soft_ps5ws.sip_xsd differ diff --git a/si4/ps5ws.si4project/soft_ps5ws.siproj b/si4/ps5ws.si4project/soft_ps5ws.siproj index 4ab4c6a..df6d35c 100644 Binary files a/si4/ps5ws.si4project/soft_ps5ws.siproj and b/si4/ps5ws.si4project/soft_ps5ws.siproj differ diff --git a/source/app/app_algorithm.c b/source/app/app_algorithm.c deleted file mode 100644 index 8714b19..0000000 --- a/source/app/app_algorithm.c +++ /dev/null @@ -1,1005 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -/// COPYRIGHT NOTICE -/// Copyright (c) 2015, 传控科技 -/// All rights reserved. -/// -/// @file app_ALGOration.c -/// @brief app_ALGOration app -/// -///(本文件实现的功能的详述) -/// -/// @version 1.1 CCsens technology -/// @author CC -/// @date 20190105 -/// -/// -/// 修订说明:最初版本 -/// Modified by: -/// Modified date: -/// Version: -/// Descriptions: -/// 算法等 -////////////////////////////////////////////////////////////////////////// -///#include "app_calibration.h" - -#include "app_algorithm.h" -#include "app_flow.h" -#include "app_paraid.h" - -////#include "app_rfSend.h" - -#include "../clib/Clib.h" -#include "../clib/bit.h" -/// - -#ifdef D_buf_test -U8 test_buf[]; -U8 test_buf2[660]; -#endif - -#include "../bsp/bsp_power.h" - -#if 0 -s1 波形一定要去掉尖峰 -s2 波形通过滤波平滑或基本平滑,并保持单调 -s3 单点管道式算法 -s4 根据特性 必须有过零点或过相对零点 - low=0 low=0 - ```````\ /````````````\ /`````` - \ / \ / - \ low++ / \ low++ / - 0 zero....\.low_zero=low....../..................\.................../........ - \ / \ / - \ ___/ \ ___/ - \___ / \___ / - \ /high++ \ / - \___/ \___/ - high=0 - low - - /`````````\ - / \ -__________________/ \______________ - -#endif - - -//>>>>>>>>>>>>>>>>>>>>>0开机task -///L2_task_C2_init(); -#if 0 -1 尖峰 中值 -2 求零点 -3 归零及削峰 求值 -4 曲线求数量 - -1 尖峰 中值 -2 上下削峰 求值 -4 曲线求数量 - -求值 纸张 -0 ,0 -sum, 100 - -x*k = Sum -100k = Sum100 -k=Sum100/100; -x=Sum/k - Sum -x=------- - k - - Sum -x=------------ - Sum100/100 - - Sum*100 -x = ---------- - Sum100 - -U8 L2_task_ALGO_at(void) -{ - - - -} - -#endif - -vU16 L2_line_algo_media(U8 *buf,vU16 len); -TS_task_ALGO_ ts_task_ALGO; -void L2_task_ALGO_init(void) -{ -/// ts_task_ALGO.status = 0; - L1_task_init(&ts_task_ALGO.task); -/// ts_task_ALGO.p_buf2 = s_task_GC032A.buf; -/// ts_task_ALGO.t = 0; - L3_task_s_go(ts_task_ALGO,D_task_init); -} - -//>>>>>>>>>>>>>>>>>>>>>0开机task -///L2_task_ALGO_init(); - - -///L2_task_ALGO_handle(&ts_task_ALGO); - -/// 捕获到需要的行采集完成的标志后, 先中值滤波消除尖峰,然后进行整理(平移 阀值),求和 -void L2_task_ALGO_handle(TS_task_ALGO_ *s) -{ - TTSS_Task_init(): - s->ok = D_clear; - s->cali_mode = D_clear; - L2_task_go(D_task_ALGO_wait); - TTSS_Task_step(D_task_ALGO_wait): - - TTSS_Task_step(D_task_ALGO_median): - /// s->usSum = L2_line_algo_media(s_task_GC032A.buf,D_pclk_per_hs_570); - L2_task_go(D_task_ALGO_updown); - TTSS_Task_step(D_task_ALGO_updown): - s->usPaperNum = 0xAAAA; - if(s->usSum >= D_paper_EE)///摄像头外放或者强光 - { - - } - else if(s->usSum > D_paper_MAX)////纸张处于满量程 - { - s->usPaperSection = D_cam_top; - } - else if(s->usSum > D_paper_150at_bottom)///bottom --top - {/// - s->usPaperSection = D_cam_150at; - } - else if(s->usSum > D_paper_00)//// 0---max 纸张发生变化 并且 小于满量程 - { - s->usPaperSection = D_cam_00; - //s->usSum - - } - else - { - s->usPaperSection = D_cam_erro; - } - /*** - if(s_task_GC032A.buf[4] < D_F_low) - { - TS_paer_value.r123.work_mode = D_ready; - }else - { - TS_paer_value.r123.work_mode = D_clear; - } - ************/ - - /// 0----0 - /// x -----usSum - ///150----usPaper150 - /// 3000 - - s->usPaperNum = s->usSum*15; - s->ustMP = s->usPaper150 / 10; - s->usPaperNum /= s->ustMP; - /// - - #define D_debug_add_send - #ifdef D_debug_add_send - PrintAlgo_D_send_us(s->usSum);PrintAlgo_L0_uart0_uc(0x09); - PrintAlgo_D_send_us(s->usPaper150);PrintAlgo_L0_uart0_uc(0x09); - PrintAlgo_D_send_us(s->usPaperNum); - //PrintCam_L0_uart0_uc(0x0d);/PrintCam_L0_uart0_uc(0x0a); - #endif - L2_task_go(D_task_ALGO_wait); - /// L2_task_go(D_task_ALGO_cali_mode); - - - /************** - TTSS_Task_step(D_task_ALGO_cali_mode) - if(D_ON == s->cali_mode) - {///PrintFlow_L0_uart0_uc(0x30+s->cali_delay); - L2_task_go(D_task_ALGO_cali_save); - }else - { - /// ts_task_FLOW.t_stamp_set = 5;// 20s * = - /// LD_gsensor_power(D_PowerMode_suspend); - if(D_cam_EE == s->usPaperSection) - {PrintAlgo_L0_uart0_uc('a'); - LD_gsensor_power(D_PowerMode_low); - L3_task_s_go(ts_task_FLOW,0); - - L2_task_go(D_task_ALGO_cali_wait); - }else - { - L2_task_go(D_task_ALGO_cali_end); - } - } - - - - - - - - TTSS_Task_step(D_task_ALGO_cali_save) - if(s->cali_delay ++ > 8) - {///PrintFlow_L0_uart0_uc('c'); - L2_task_go(D_task_ALGO_cali_end); - }else - {///延时未溢出 - L2_task_go(D_task_ALGO_sa); - if(D_cam_150at == s->usPaperSection) - { - //PrintFlow_L0_uart0_uc('a'); - if(s->cali_timer ++ > 2) - { - s->usPaper150 = s->usSum; /// - L1_Iap_Write_us(D_paraAdd0_paper150,s->usPaper150); - L1_Iap_Write_us(D_paraAdd1_paper150,s->usPaper150); - PrintAlgo_L0_uart0_uc('f');///PrintFlow_str("flash", 5); - TS_paer_value.r123.cali_timer ++; - L2_task_go(D_task_ALGO_cali_end); - } - } - } - TTSS_Task_step(D_task_ALGO_cali_wait) - /// 只有没有中断的连续多少次的敲击才可以地进入cali 模式 - Lc_delay_ms(1); - L0_mcu_WKTC(D_WKTC_500MS); //掉电计时器 - L0_mcu_mode_powerdown();//进入休眠状态 - if(BITN_G(DR_who_wakeup, DRB_who_wakeup_action)) - { - BITN_0(DR_who_wakeup, DRB_who_wakeup_action); - PrintAlgo_L0_uart0_uc(s->cali_hit+0x30); - // PrintCam_L0_uart0_uc('#'); - if(s->cali_hit++ > 22) - {s->cali_hit = 0; - s->hit_ok = D_ready; - PrintAlgo_L0_uart0_uc('L'); - s->cali_mode = D_ON;s->cali_timer = s->cali_mode; - TS_paer_value.r123.cali_mode = 1; - L2_task_go(D_task_ALGO_sa); - } - }else - { - s->cali_hit = 0; - if(s->cali_over ++ > 25)///500ms*25 = 50s - { - s->cali_over = 0; - L2_task_go(D_task_ALGO_cali_end); - } - } - - TTSS_Task_step(D_task_ALGO_cali_end) - // PrintFlow_str("cali end", 9);// - // PrintAlgo_L0_uart0_uc('E'); - s->cali_mode = D_clear; - TS_paer_value.r123.cali_mode = s->cali_mode; - s->cali_delay = 0; -/// L3_task_s_go(ts_task_FLOW,D_task_init); -// - L2_task_go(D_task_ALGO_wait); - TTSS_Task_step(D_task_ALGO_sa) - L3_task_s_go(ts_task_FLOW,D_task_FLOW_wakeup); - L2_task_go(D_task_ALGO_wait); - - - *****************/ - TTSS_Task_end(); -} - -/**************************** - - -TTSS_Task_step(D_task_ALGO_updown) - L0_uart0_sendArray("paper =", 7); - D_send_ushex(s->usSum);L0_uart0_uc('-'); - #define D_paper_max 0x0b10 - ///0x0b1d 2845 - - - L2_task_go(D_task_ALGO_cal) -//L1_task_Tdelay(D_Tdelay_10ms); -TTSS_Task_step(D_task_ALGO_cal) - #ifdef D_debug_add_send - // L2_line_send();/// 把数据发送上去供测试使用 s_task_GC032A.buf - // D_send_us(DR_pclk_n); - // - #endif - s->usSum *= 10; // sum的最大值不能超出 - s->usPaper = s->usSum/s->usSum100; - s->ok = D_ready; - L2_task_go(D_task_ALGO_wait); - -#define D_F_low 30 -#define D_F_high 40 -#define D_F_diff 10 //D_F_high - D_F_low -cam 输出的一行数据的前一部分 -16 -16 -16 -16 -17 -18 -19 -22 -25 -26 -26 -27 -29 -28 -28 -27 -27 -26 -26 -26 -25 -25 -/// 去尖峰 削波 -/// ______/\___________ -/// / \ -/// / ...............................\--high -/// / \ -/// / \ -/// / low \---low -///-16 17-- \ -/// -***************************/ -///#define D_F_low 23 -///#define D_F_high 30 -///#define D_F_diff 5 //D_F_high - D_F_low -///#define D_F_diff (D_F_high - D_F_low) - - -vU16 L2_line_algo_media(U8 *buf,vU16 len) -{ - vU16 i,usV = 0;//,usi = 0; - U8 cache[3]; - U8 f1; - for(i = 1;i < len;i ++) - { - - cache[2] = cache[1]; - cache[1] = cache[0]; - cache[0] = buf[i]; - f1 = Lc_U8_media3(cache[2],cache[1],cache[0]); - ///-------------------------------------------------- - if(f1 > D_F_low)//> - { - if(f1 > D_F_high)//>40 - { - f1 = D_F_diff;// 10 - }else - { - f1 -= D_F_low;// 40 30 - } - }else - {// <=low - f1 = 0; - } - ///-------------------------------------------------- - /// buf[i] = f1; - usV += f1;///最大值 570*7 640*10 =6,400 65,535 - - } - return usV; -} - - - -#if 0 - - /// // s->usSum = L2_line_algo_media(test_buf,639); - if(ts_task_ALGO.usSum_temp > D_line_sum) - { - ////L3_task_s_go(ts_task_CALIB,D_task_CALIB_wait); - } - if(s->usSum_temp != s->usSum) - { - s->t++; - }else - { - s->t = 0; - } - if(s->t > 5) - { - L0_uart0_uc('X'); - }else - { - L0_uart0_uc('F'); - } - D_send_ushex(s->t);L0_uart0_uc(0x09); - - - TTSS_Task_step(D_task_ALGO_updown); - /// // s->usSum = L2_line_algo_media(test_buf,639); - if(ts_task_ALGO.usSum_temp > D_line_sum) - { - ////L3_task_s_go(ts_task_CALIB,D_task_CALIB_wait); - } - if(s->usSum_temp >= s->usSum) - { - s->t = s->usSum_temp - s->usSum; - }else - { - s->t = s->usSum - s->usSum_temp; - } - /// L0_uart0_uc(0x09); - L0_uart0_sendArray("paper =", 9); - D_send_ushex(s->usSum);L0_uart0_uc('-'); - D_send_ushex(s->usSum_temp);L0_uart0_uc('='); - s->usSum_temp = s->usSum; - #define D_paper_max 2000 - ///0x0b1d 2845 - - if(s->usSum > 0x0b10) - { - s->paperMode = D_max; - }else - { - s->paperMode = D_diff; - } - - if(s->t > D_paper_max) - { - - L0_uart0_uc('X'); - - }else - { - L0_uart0_uc('F'); - - - } - D_send_ushex(s->t);L0_uart0_uc(0x09); - L2_task_go(D_task_ALGO_cal); - //L1_task_Tdelay(D_Tdelay_10ms); - - L2_task_go(D_task_ALGO_updown); -TTSS_Task_step(D_task_ALGO_updown); - s->usLong = L2_line_algo_updown(s->p_buf2,639); - -vU16 L2_line_algo_updown(U8 *p_buf,U8 len) -{ - vU16 us_i = 0,up_point = 0,down_point = 0; - down_point = DR_pclk_n; - for(us_i = 1;us_i < len ;us_i ++) - { - if((p_buf[us_i - 1] == 0)&& - (p_buf[us_i] == 1))//// _/``上升沿 - { - if(p_buf[us_i + 1] == 0) - {//_/`\_ 尖峰需要过滤 - gRccUs03 ++; - }else - {// ___/````上升沿开始高电平 - up_point = us_i; - } - }else if((p_buf[us_i - 1] == 1)&& - (p_buf[us_i] == 0))//// ``\_ 下降沿 - { - down_point = gRccUs03; - }else - { - - } - } - us_i = down_point - up_point; - return us_i; -} - -#endif - - -#if 0 ///def D_buf_test -U8 test_buf[] -={ -19 ,// 0 -19 ,// 1 -19 ,// 2 -20 ,// 3 -20 ,// 4 -20 ,// 5 -20 ,// 6 -20 ,// 7 -20 ,// 8 -20 ,// 9 -19 ,// 10 -119 ,// 11 -19 ,// 12 -19 ,// 13 -19 ,// 14 -19 ,// 15 -19 ,// 16 -20 ,// 17 -20 ,// 18 -20 ,// 19 -20 ,// 20 -20 ,// 21 -20 ,// 22 -20 ,// 23 -20 ,// 24 -20 ,// 25 -19 ,// 26 -19 ,// 27 -19 ,// 28 -119 ,// 29 -19 ,// 30 -19 ,// 31 -19 ,// 32 -19 ,// 33 -19 ,// 34 -19 ,// 35 -19 ,// 36 -19 ,// 37 -19 ,// 38 -19 ,// 39 -19 ,// 40 -20 ,// 41 -20 ,// 42 -19 ,// 43 -19 ,// 44 -19 ,// 45 -19 ,// 46 -20 ,// 47 -20 ,// 48 -20 ,// 49 -19 ,// 50 -19 ,// 51 -19 ,// 52 -19 ,// 53 -19 ,// 54 -20 ,// 55 -20 ,// 56 -20 ,// 57 -19 ,// 58 -19 ,// 59 -19 ,// 60 -20 ,// 61 -20 ,// 62 -20 ,// 63 -20 ,// 64 -20 ,// 65 -20 ,// 66 -20 ,// 67 -20 ,// 68 -20 ,// 69 -120 ,// 70 -19 ,// 71 -19 ,// 72 -19 ,// 73 -20 ,// 74 -20 ,// 75 -20 ,// 76 -20 ,// 77 -20 ,// 78 -20 ,// 79 -20 ,// 80 -20 ,// 81 -20 ,// 82 -20 ,// 83 -20 ,// 84 -20 ,// 85 -20 ,// 86 -20 ,// 87 -20 ,// 88 -20 ,// 89 -20 ,// 90 -20 ,// 91 -20 ,// 92 -121 ,// 93 -20 ,// 94 -20 ,// 95 -20 ,// 96 -20 ,// 97 -20 ,// 98 -21 ,// 99 -21 ,// 100 -21 ,// 101 -22 ,// 102 -24 ,// 103 -26 ,// 104 -28 ,// 105 -30 ,// 106 -32 ,// 107 -35 ,// 108 -38 ,// 109 -40 ,// 110 -42 ,// 111 -44 ,// 112 -146 ,// 113 -50 ,// 114 -51 ,// 115 -52 ,// 116 -52 ,// 117 -53 ,// 118 -53 ,// 119 -54 ,// 120 -54 ,// 121 -55 ,// 122 -55 ,// 123 -55 ,// 124 -55 ,// 125 -55 ,// 126 -56 ,// 127 -55 ,// 128 -55 ,// 129 -55 ,// 130 -56 ,// 131 -55 ,// 132 -155 ,// 133 -54 ,// 134 -53 ,// 135 -53 ,// 136 -52 ,// 137 -52 ,// 138 -52 ,// 139 -51 ,// 140 -49 ,// 141 -45 ,// 142 -43 ,// 143 -41 ,// 144 -39 ,// 145 -38 ,// 146 -36 ,// 147 -34 ,// 148 -31 ,// 149 -129 ,// 150 -28 ,// 151 -28 ,// 152 -27 ,// 153 -27 ,// 154 -27 ,// 155 -27 ,// 156 -27 ,// 157 -27 ,// 158 -26 ,// 159 -26 ,// 160 -26 ,// 161 -25 ,// 162 -25 ,// 163 -24 ,// 164 -25 ,// 165 -25 ,// 166 -25 ,// 167 -25 ,// 168 -25 ,// 169 -24 ,// 170 -24 ,// 171 -24 ,// 172 -23 ,// 173 -23 ,// 174 -22 ,// 175 -23 ,// 176 -22 ,// 177 -22 ,// 178 -22 ,// 179 -22 ,// 180 -22 ,// 181 -22 ,// 182 -22 ,// 183 -21 ,// 184 -21 ,// 185 -21 ,// 186 -21 ,// 187 -21 ,// 188 -22 ,// 189 -21 ,// 190 -21 ,// 191 -21 ,// 192 -21 ,// 193 -21 ,// 194 -21 ,// 195 -21 ,// 196 -21 ,// 197 -21 ,// 198 -121 ,// 199 -21 ,// 200 -21 ,// 201 -21 ,// 202 -21 ,// 203 -21 ,// 204 -21 ,// 205 -21 ,// 206 -21 ,// 207 -21 ,// 208 -21 ,// 209 -20 ,// 210 -20 ,// 211 -20 ,// 212 -20 ,// 213 -20 ,// 214 -20 ,// 215 -21 ,// 216 -21 ,// 217 -21 ,// 218 -20 ,// 219 -21 ,// 220 -21 ,// 221 -20 ,// 222 -120 ,// 223 -20 ,// 224 -20 ,// 225 -20 ,// 226 -20 ,// 227 -20 ,// 228 -20 ,// 229 -20 ,// 230 -20 ,// 231 -20 ,// 232 -19 ,// 233 -19 ,// 234 -19 ,// 235 -19 ,// 236 -20 ,// 237 -21 ,// 238 -21 ,// 239 -21 ,// 240 -20 ,// 241 -20 ,// 242 -20 ,// 243 -20 ,// 244 -20 ,// 245 -20 ,// 246 -20 ,// 247 -20 ,// 248 -20 ,// 249 -20 ,// 250 -21 ,// 251 -21 ,// 252 -21 ,// 253 -21 ,// 254 -21 ,// 255 -20 ,// 256 -20 ,// 257 -20 ,// 258 -20 ,// 259 -20 ,// 260 -20 ,// 261 -20 ,// 262 -20 ,// 263 -20 ,// 264 -20 ,// 265 -19 ,// 266 -19 ,// 267 -19 ,// 268 -19 ,// 269 -19 ,// 270 -19 ,// 271 -19 ,// 272 -19 ,// 273 -19 ,// 274 -19 ,// 275 -19 ,// 276 -19 ,// 277 -19 ,// 278 -19 ,// 279 -19 ,// 280 -19 ,// 281 -19 ,// 282 -20 ,// 283 -20 ,// 284 -20 ,// 285 -20 ,// 286 -119 ,// 287 -19 ,// 288 -19 ,// 289 -19 ,// 290 -19 ,// 291 -19 ,// 292 -19 ,// 293 -19 ,// 294 -19 ,// 295 -19 ,// 296 -19 ,// 297 -19 ,// 298 -19 ,// 299 -19 ,// 300 -19 ,// 301 -19 ,// 302 -19 ,// 303 -19 ,// 304 -19 ,// 305 -19 ,// 306 -19 ,// 307 -49 ,// 308 -19 ,// 309 -20 ,// 310 -19 ,// 311 -19 ,// 312 -19 ,// 313 -19 ,// 314 -19 ,// 315 -20 ,// 316 -19 ,// 317 -19 ,// 318 -19 ,// 319 -19 ,// 320 -19 ,// 321 -19 ,// 322 -19 ,// 323 -19 ,// 324 -19 ,// 325 -19 ,// 326 -19 ,// 327 -19 ,// 328 -19 ,// 329 -20 ,// 330 -20 ,// 331 -20 ,// 332 -19 ,// 333 -20 ,// 334 -20 ,// 335 -20 ,// 336 -20 ,// 337 -20 ,// 338 -19 ,// 339 -19 ,// 340 -19 ,// 341 -19 ,// 342 -19 ,// 343 -19 ,// 344 -19 ,// 345 -19 ,// 346 -19 ,// 347 -20 ,// 348 -20 ,// 349 -20 ,// 350 -20 ,// 351 -20 ,// 352 -20 ,// 353 -20 ,// 354 -20 ,// 355 -19 ,// 356 -19 ,// 357 -19 ,// 358 -19 ,// 359 -19 ,// 360 -19 ,// 361 -19 ,// 362 -19 ,// 363 -19 ,// 364 -19 ,// 365 -19 ,// 366 -19 ,// 367 -19 ,// 368 -19 ,// 369 -19 ,// 370 -19 ,// 371 -19 ,// 372 -19 ,// 373 -19 ,// 374 -19 ,// 375 -19 ,// 376 -19 ,// 377 -19 ,// 378 -19 ,// 379 -19 ,// 380 -19 ,// 381 -19 ,// 382 -19 ,// 383 -19 ,// 384 -19 ,// 385 -19 ,// 386 -19 ,// 387 -20 ,// 388 -20 ,// 389 -19 ,// 390 -19 ,// 391 -19 ,// 392 -19 ,// 393 -19 ,// 394 -19 ,// 395 -19 ,// 396 -19 ,// 397 -19 ,// 398 -19 ,// 399 -19 ,// 400 -19 ,// 401 -19 ,// 402 -19 ,// 403 -19 ,// 404 -19 ,// 405 -19 ,// 406 -19 ,// 407 -19 ,// 408 -19 ,// 409 -19 ,// 410 -20 ,// 411 -19 ,// 412 -19 ,// 413 -19 ,// 414 -19 ,// 415 -19 ,// 416 -19 ,// 417 -19 ,// 418 -19 ,// 419 -19 ,// 420 -19 ,// 421 -19 ,// 422 -19 ,// 423 -19 ,// 424 -19 ,// 425 -19 ,// 426 -19 ,// 427 -19 ,// 428 -19 ,// 429 -19 ,// 430 -19 ,// 431 -19 ,// 432 -19 ,// 433 -19 ,// 434 -19 ,// 435 -19 ,// 436 -20 ,// 437 -19 ,// 438 -19 ,// 439 -19 ,// 440 -19 ,// 441 -19 ,// 442 -19 ,// 443 -19 ,// 444 -19 ,// 445 -19 ,// 446 -19 ,// 447 -19 ,// 448 -19 ,// 449 -19 ,// 450 -19 ,// 451 -19 ,// 452 -19 ,// 453 -19 ,// 454 -19 ,// 455 -19 ,// 456 -19 ,// 457 -19 ,// 458 -19 ,// 459 -19 ,// 460 -19 ,// 461 -19 ,// 462 -19 ,// 463 -19 ,// 464 -19 ,// 465 -19 ,// 466 -19 ,// 467 -19 ,// 468 -19 ,// 469 -19 ,// 470 -19 ,// 471 -19 ,// 472 -19 ,// 473 -19 ,// 474 -19 ,// 475 -19 ,// 476 -19 ,// 477 -19 ,// 478 -19 ,// 479 -19 ,// 480 -19 ,// 481 -19 ,// 482 -19 ,// 483 -19 ,// 484 -19 ,// 485 -19 ,// 486 -19 ,// 487 -19 ,// 488 -19 ,// 489 -19 ,// 490 -19 ,// 491 -19 ,// 492 -19 ,// 493 -19 ,// 494 -19 ,// 495 -19 ,// 496 -19 ,// 497 -18 ,// 498 -18 ,// 499 -18 ,// 500 -19 ,// 501 -19 ,// 502 -19 ,// 503 -19 ,// 504 -19 ,// 505 -19 ,// 506 -19 ,// 507 -19 ,// 508 -19 // 509 -}; -#endif diff --git a/source/app/app_algorithm.h b/source/app/app_algorithm.h deleted file mode 100644 index b855959..0000000 --- a/source/app/app_algorithm.h +++ /dev/null @@ -1,168 +0,0 @@ - -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file algorithm.h -/// @brief bsp @ driver config -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20180331 -/// @note cc_AS_stc02 -/// -/// -///algorithm///英 [??lg?r?e?m] 美 [??l???r?e?m] ///n.演算法;运算法则;计算程序 -/// -/// -/// -////////////////////////////////////////////////////////////////////////////// - - - - - - - - - - -#ifndef _APP_algorithm_H -#define _APP_algorithm_H - -#include "../clib/Type.h" -#include "../ctask/task.h" -#include "../msp/uart0.h" -#include "../clib/clib.h" -//#include "../debug/debug_drv.h"// -//#include "../msp/msp_plcd.h" - -//#include "../msp/SHC6601_rtc.h" -///#include "app_rf.h" -//#include "app_as.h" - -#include "../tpc/tpc_uart.h" - -//>>>>>>>>>>>>>>>>>>>>>0开机task - - -#define D_task_ALGO_median 0x51 -#define D_task_ALGO_wait 0x52 - -#define D_task_ALGO_cal 0x53 -#define D_task_ALGO_updown 0x54 -#define D_task_ALGO_section 0x57 - -#define D_task_ALGO_cali_mode 0x63 -#define D_task_ALGO_para 0x64 -#define D_task_ALGO_200in 0x66 - -#define D_task_ALGO_cali_end 0x69 - -#define D_task_ALGO_cali_wait 0x70 -#define D_task_ALGO_cali_save 0x73 - - -#define D_task_ALGO_sa 0x6b - -#define D_line_sum 1000 ///判定白屏的阀值 - - - -typedef struct -{ - TS_task task; - vU16 usSum; - vU16 ustMP; - vU16 usPaper150; - vU16 usPaperNum; -// vU32 ul2; -// vU32 ul3; -// vU16 t; -/// vU16 usSum_temp; -// vU16 usSum100; -// vU16 usLong; /// 白区长度 -/// vU8 *p_buf2;// - vU8 usPaperSection; ///纸张的段数 - vU8 cali_delay; - vU8 cali_timer; - vU8 cali_over; - vU8 cali_hit; - vU8 hit_ok:1; - vU8 ok:1; - vU8 cali_mode:1; //D_OK - vU8 ok2:1; - vU8 paperMode:3;// - -// vU8 buf3[520];// - -}TS_task_ALGO_; -extern TS_task_ALGO_ ts_task_ALGO; - -extern void L2_task_ALGO_handle(TS_task_ALGO_ *s); -extern void L2_task_ALGO_init(void); -extern void L2_task_ALGO_handle22(TS_task_ALGO_ *s); - -/*********************** -10 0.93 - -20张 1.88mm --->0.094mm/paper -100 9.4 2.97mm-> 31.59574468 -150 14.1 15.9---> 169.1489362 2330 0x0924 -200 18.8 0 - - -****************/ - -#define D_paper_EE 0x0B10 ///0b1f - -#define D_paper_MAX 0x09AA ///2555 //170张 - -#define D_paper_150LR 250 ///上下浮动值 大概150/15 =10页 -#define D_paper_150at 0x087f ///150张校准 2330/150 = 15point/张纸 -#define D_paper_00 0x0015 -#define D_paper_150at_top (D_paper_150at + D_paper_150LR) -#define D_paper_150at_bottom (D_paper_150at - D_paper_150LR) - -#define D_cam_EE 0 -#define D_cam_top 1 -#define D_cam_150at 2 -#define D_cam_00 3 -#define D_cam_erro 4 -#define D_cam_noee 5 - -//<<<<<<<<<<<<<<<<<<<0开机task -#if 0 -#define PrintAlgo_L0_uart0_uchex(x) L0_uart0_uchex((x)) -#define PrintAlgo_L0_uart0_uc(x) L0_uart0_uc((x)) -#define PrintAlgo_D_send_us(x) D_send_ushex((x)) - -#define PrintAlgo_str(x,len) L0_uart0_sendArray((x),len) -#else - -#define PrintAlgo_L0_uart0_uchex(x) -#define PrintAlgo_L0_uart0_uc(x) -#define PrintAlgo_D_send_us(x) - -#define PrintAlgo_str(x,len) - -#endif -/************************************************************ -/// 去尖峰 削波 -/// ______/\___________ -/// / \ -/// / ...............................\--high -/// / \ -/// / \ -/// / low \---low -///-16 17-- \ -/// -*******************************************/ -#define D_F_low 23 -#define D_F_high 30 -#define D_F_diff 5 //D_F_high - D_F_low -///#define D_F_diff (D_F_high - D_F_low) - -#endif //_APP_algorithm_H ALGO - - - diff --git a/source/app/app_calibration.c b/source/app/app_calibration.c deleted file mode 100644 index 12ecec7..0000000 --- a/source/app/app_calibration.c +++ /dev/null @@ -1,149 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -/// COPYRIGHT NOTICE -/// Copyright (c) 2015, 传控科技 -/// All rights reserved. -/// -/// @file app_calibration.c -/// @brief app_calibration app -/// -///(本文件实现的功能的详述) -/// -/// @version 1.1 CCsens technology -/// @author CC -/// @date 20170101 -/// -/// -/// 修订说明:最初版本 -/// Modified by: -/// Modified date: -/// Version: -/// Descriptions: -/// 应用流程 一般包括上电时序等 -////////////////////////////////////////////////////////////////////////// - -#include "app_calibration.h" -#include "../clib/Clib.h" -#include "../clib/bit.h" -#include "../bsp/bsp_cam.h" -/// - -#include "../bsp/bsp_power.h" - -TS_task_CALIB_ ts_task_CALIB; - -void L2_task_CALIB_init(void) -{ - ts_task_CALIB.status = 0; - L1_task_init(&ts_task_CALIB.task); - L3_task_s_go(ts_task_CALIB,D_task_init); -} - -//>>>>>>>>>>>>>>>>>>>>>0开机task -///L2_task_CALIB_init(); - -///L2_task_CALIB_handle(&ts_task_CALIB); -void L2_task_CALIB_handle(TS_task_CALIB_ *s) -{ - TTSS_Task_init(); - if(D_ready == ts_task_power.power2) - { - ts_task_power.power2 = D_clear; - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - L1_as_readXYZ(0); - - - } - - -#if 0 - L0_uart0_uc('a'); - - ts_task_power.power2 = D_clear; - ts_task_CALIB.calib_time = D_clear; - L1_task_Tdelay(D_Tdelay_1s); - - - L2_task_go(D_task_CALIB_wait); - #endif - TTSS_Task_step(D_task_CALIB_rr); - - - TTSS_Task_step(D_task_CALIB_wait); - - if(D_ready == ts_task_power.power2) - { - ts_task_power.power2 = D_clear; - L0_uart0_uc('#'); - ts_task_CALIB.status ++; - if(ts_task_CALIB.status <= 8) - { - }else - { - L0_uart0_uc('!'); - ts_task_CALIB.status = 0; - ts_task_CALIB.calib_time = D_ready; - } - }else - { - ts_task_CALIB.status = 0; - ts_task_CALIB.calib_time = D_clear; - L0_uart0_uc('0'); - } - L2_task_go(D_task_CALIB_wait); - //L1_task_Tdelay(D_Tdelay_1s); - L1_task_Tdelay(D_Tdelay_500ms);////固定的间隔内是否连续收到校准敲击 - TTSS_Task_step(D_task_CALIB_sleep); - - L2_task_go(D_task_CALIB_init_sensor); - L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_end(); -} - -/********* -if(D_ready == ts_task_power.power2) -{ - ts_task_power.power2 = D_clear; - L0_uart0_uc('#'); - ts_task_CALIB.status ++; - if(ts_task_CALIB.status <= 4) - { - }else - { - L0_uart0_uc('!'); - // L1_task_Tdelay(D_Tdelay_1s); - // L2_task_go(D_task_CALIB_wait); - - } - /// L1_task_Tdelay(D_Tdelay_1s); - L2_task_go(D_task_CALIB_wait); -}else -{ - ts_task_CALIB.status = 0; - L0_uart0_uc('0'); - L1_task_Tdelay(D_Tdelay_2s); -} - - - - - -*********/ - - diff --git a/source/app/app_calibration.h b/source/app/app_calibration.h deleted file mode 100644 index a7dae87..0000000 --- a/source/app/app_calibration.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _APP_calibration_H -#define _APP_calibration_H - -#include "../clib/Type.h" -#include "../ctask/task.h" -#include "../msp/uart0.h" -#include "../clib/clib.h" -//#include "../debug/debug_drv.h"// -//#include "../msp/msp_plcd.h" - -//#include "../msp/SHC6601_rtc.h" -///#include "app_rf.h" -//#include "app_as.h" -#include "../bsp/cw63xx.h" -#include "../bsp/bsp_msa300.h" -#include "../tpc/tpc_uart.h" -#include "../bsp/bsp_cam_isr.h" - -//>>>>>>>>>>>>>>>>>>>>>0开机task - -///#define D_task_CALIB_ask 0x56 -///#define D_task_CALIB_enter 0x57 -///#define D_task_CALIB_init 0x10 - -///#define D_task_OSD_init_key 0x11 -///#define D_task_CALIB_STEP 0x30 -///#define D_task_CALIB_heratbeat 0x70 - - -#define D_task_CALIB_send 0x40 -#define D_task_CALIB_send2 0x41 -#define D_task_CALIB_send3 0x42 - -#define D_task_CALIB_PreSend 0x43 -#define D_task_CALIB_PreSend2 0x44 - - - -#define D_task_CALIB_wait 0x51 -#define D_task_CALIB_rr 0x52 - -#define D_task_CALIB_sleep 0x53 -#define D_task_CALIB_init_sensor 0x54 -#define D_task_CALIB_wait_sensor 0x55 -#define D_task_CALIB_wakeup 0x56 -#define D_task_CALIB_wakeup2 0x57 -#define D_task_CALIB_overtime 0x58 -#define D_task_CALIB_wakeup3 0x59 - -typedef struct -{ - TS_task task; -// vU8 t_stamp;// -// vU8 first_run;// - unsigned char calib_time;// - unsigned char status;// -// unsigned char key;// -}TS_task_CALIB_; -extern TS_task_CALIB_ ts_task_CALIB; - -extern void L2_task_CALIB_handle(TS_task_CALIB_ *s); -extern void L2_task_CALIB_init(void); -extern void L2_task_CALIB_handle22(TS_task_CALIB_ *s); - - -//<<<<<<<<<<<<<<<<<<<0开机task - -#endif //_APP_calibration_H calib - - - diff --git a/source/app/app_config.c b/source/app/app_config.c new file mode 100644 index 0000000..2489081 --- /dev/null +++ b/source/app/app_config.c @@ -0,0 +1,107 @@ +#include "app_config.h" +#include "../bsp/cs1232.h" +#include "../bsp/chipid.h" +#include "../msp/eeprom.h" + +GlobalParam G; +GlobalRegister R; + +void L3_param_init(void) +{ +#if 0 + int i; + for(i=0;i>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Register CONFIG +//瀵勫瓨鍣ㄧ紪鍙蜂粠1寮濮 +//#define D_COUNT_WEIGHT(adc) (U32)(1000.0 * R.p.weight_max * (adc) / (2 * 0x7FFFFF / 1000 * D_ADS1213_GAIN_VAL * R.p.lmd)) +//#define D_blur_threshold_2_1(threshold) (U32) ( 1.0 * threshold *(2 * 0x7FFFFF / 1000 * D_ADS1213_GAIN_VAL * R.p.lmd) / (1000.0 * R.p.weight_max )) +#define D_COUNT_WEIGHT(adc) (U32)((adc) / D_ADS1213_GAIN_VAL / R.p.lmd * R.p.weight_max * 1000 / (2 * 0x7FFFFF / 1000 )) +#define D_COUNT_ADC(wInG) (U32)((wInG) * D_ADS1213_GAIN_VAL * R.p.lmd * (2 * 0x7FFFFF / 1000) / R.p.weight_max / 1000) + +#define ADC_status_chx_Ready_BASE 0x01 +#define ADC_status_ch1_Ready 0x01 +#define ADC_status_ch2_Ready 0x02 +#define ADC_status_ch3_Ready 0x04 +#define ADC_status_ch4_Ready 0x08 +#define D_ADC_CHANNEL_NUM 4 +typedef struct global_register +{ + //RO Register + U16 reserved1; + U32 total_weight; //鍑閲嶏紙鏄剧ず閲嶉噺锛*100 + U32 total_zweight; //鐨噸*100 + //RW Register + U16 reserved2; + U16 zero; //娓0鏍囧織锛屽啓鍏ヤ换浣曞兼竻0锛堝幓鐨級 + U16 status_eep_save; //eep鍐欏叆瀵勫瓨鍣紝1鍒欏啓鍏ep骞舵竻0 + //U16 reset; //reset鏍囧織锛屽啓鍏ヤ换浣曞硷紝鎵鏈夊弬鏁版仮澶嶅垵濮嬪 + struct + { //闇瑕佹寔涔呭寲鐨勫弬鏁帮紝涓嶈兘瓒呰繃72瀛楄妭锛屽惁鍒欎細瀵艰嚧eeprom婧㈠嚭 + U16 slaver_id; + U16 adc_ch_status; + U16 weight_max; //閲忕▼ + U16 lmd; //2mv/v + U16 adc_blur_mid; //涓兼护娉 + U16 adc_blur_avg; //鍧囧兼护娉 + U16 adc_blur_shift[3]; //绉讳綅婊ゆ尝鐐规暟 + U16 adc_blur_threshold[2]; //绉讳綅婊ゆ尝闃鍊 + }p; + U16 reserved3; + U32 adval[D_ADC_CHANNEL_NUM]; //4璺噸閲 + U32 ch_weight[D_ADC_CHANNEL_NUM]; //4璺噸閲 + U32 rough_weight; // 姣涢噸 +}GlobalRegister; + +extern GlobalRegister R; + +//瀵勫瓨鍣ㄥ唴瀛樺熀鍦板潃 +#define REG_MEM_BASE ((U16*)(&R)) //瀵勫瓨鍣ㄥ熀纭鍦板潃锛堟湰鏂囦欢澶栭儴涓嶅簲璇ヤ娇鐢ㄨ瀹忓畾涔夛級 +//鍙橀噺鍦板潃杞瘎瀛樺櫒 +#define MEM_2_REG(mem) (((U16*)(mem) - REG_MEM_BASE) + 1) +//瀵勫瓨鍣ㄨ浆鍙橀噺鍦板潃 +#define REG_2_MEM(reg) (REG_MEM_BASE + (U16)((reg) - 1)) +//STEP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Global Variables CONFIG +typedef struct global_param +{ + U8 xx; +}GlobalParam; +extern struct global_param G; +//STEP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>0开机task -#define D_FLOW_t_stamp 10 - -void L2_task_FLOW_handle33(TS_task_FLOW_ *s) -{ - TTSS_Task_init(): -/// PrintFlow_L0_uart0_uc('F'); - ts_task_ALGO.paperMode = D_max; - - L2_task_go(D_task_FLOW_wakeup); - - TTSS_Task_end(); -} - - - - diff --git a/source/app/app_flow.h b/source/app/app_flow.h deleted file mode 100644 index 52a504f..0000000 --- a/source/app/app_flow.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef _APP_FLOW_H -#define _APP_FLOW_H - - - -#include "../clib/Type.h" -#include "../ctask/task.h" -#include "../msp/uart0.h" -#include "../clib/clib.h" -//#include "../debug/debug_drv.h"// -//#include "../msp/msp_plcd.h" - -//#include "../msp/SHC6601_rtc.h" -///#include "app_rf.h" -//#include "app_as.h" -#include "../tpc/tpc_uart.h" - -//>>>>>>>>>>>>>>>>>>>>>0开机task - -///#define D_task_FLOW_ask 0x56 -///#define D_task_FLOW_enter 0x57 -///#define D_task_FLOW_init 0x10 - -///#define D_task_OSD_init_key 0x11 -///#define D_task_FLOW_STEP 0x30 -///#define D_task_FLOW_heratbeat 0x70 - -#define D_task_FLOW_wait_cam1 0x51 -#define D_task_FLOW_wait_cam 0x52 - -#define D_task_FLOW_lowPower 0x53 -#define D_task_FLOW_work 0x5b -#define D_task_FLOW_cali 0x5c - -#define D_task_FLOW_init_sensor 0x54 -#define D_task_FLOW_wait_sensor 0x55 -#define D_task_FLOW_wakeup 0x56 -#define D_task_FLOW_wakeup2 0x57 -#define D_task_FLOW_overtime 0x58 -#define D_task_FLOW_wakeup3 0x59 - -typedef struct -{ - TS_task task; - vU8 t_stamp; - vU16 t_stamp2; - vU16 wakeup_timer; - - vU8 long_hit; -// vU8 first_run;// -// unsigned char area;// -// unsigned char status;// -// unsigned char key;// -}TS_task_FLOW_; -extern TS_task_FLOW_ ts_task_FLOW; - -extern void L2_task_FLOW_handle(TS_task_FLOW_ *s); -extern void L2_task_FLOW_init(void); -extern void L2_task_FLOW_handle33(TS_task_FLOW_ *s); - - -extern TS_P_rf433 TS_paer_value; -#if 0 -#define PrintFlow_L0_uart0_uchex(x) L0_uart0_uchex((x)) -#define PrintFlow_L0_uart0_uc(x) L0_uart0_uc((x)) -#define PrintFlow_D_send_us(x) D_send_ushex((x)) - -#define PrintFlow_str(x,len) L0_uart0_sendArray((x),len) -#else - -#define PrintFlow_L0_uart0_uchex(x) -#define PrintFlow_L0_uart0_uc(x) -#define PrintFlow_D_send_us(x) - -#define PrintFlow_str(x,len) - -#endif - -//<<<<<<<<<<<<<<<<<<<0开机task - -#endif - - - diff --git a/source/app/app_paraid.c b/source/app/app_paraid.c deleted file mode 100644 index bd61ebb..0000000 --- a/source/app/app_paraid.c +++ /dev/null @@ -1,124 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -/// COPYRIGHT NOTICE -/// Copyright (c) 2015, 传控科技 -/// All rights reserved. -/// -/// @file app_paraid.c -/// @brief parameter & id app -/// -///(本文件实现的功能的详述) -/// -/// @version 1.1 CCsens technology -/// @author CC -/// @date 20190107 -/// -/// -/// 修订说明:最初版本 -/// Modified by: -/// Modified date: -/// Version: -/// Descriptions: -/// -////////////////////////////////////////////////////////////////////////// - -#include "app_algorithm.h" -#include "app_paraid.h" -#include "../clib/Clib.h" -#include "../clib/bit.h" -#include "../msp/msp_eeprom.h" -// - -/// - -#define D_paraid_debug_print -/// 本机id -/// 纸张的配置参数 - -void L1_paraid_init(void) -{ - vU16 pa[2]; - -/// char *ID; -/// ID = (char idata *)0xf1;/// for (i=0; i<7; i++) { UartSend(ID[i]); } - ///UartSend(ID[i]); - -// L1_Iap_Read_us(D_paraAdd_paper150,&ts_task_ALGO.usPaper150); -// L1_Iap_Read_us(D_paraAdd_paper150,&ts_task_ALGO.usPaper150); -// L1_Iap_main(); - - - L1_Iap_Read_us(D_paraAdd0_paper150,&pa[0]); - L1_Iap_Read_us(D_paraAdd1_paper150,&pa[1]); - #ifdef D_paraid_debug_print - L0_uart0_us(pa[0]);L0_uart0_us(pa[1]); L0_uart0_uc(0xAA); - #endif - if(pa[1] == pa[0]) - { - if(0xffff != pa[1]) - { - if(pa[0] < D_paper_150at_top) - { - if(pa[0] > D_paper_150at_bottom) - { - goto GOTO_PARA_OK; - } - } - } - } - - - -/// GOTO_PARA_ERRO: - L1_Iap_Write_us(D_paraAdd0_paper150,D_paper_150at); - L1_Iap_Write_us(D_paraAdd1_paper150,D_paper_150at); - pa[0] = D_paper_150at; - - GOTO_PARA_OK: - ts_task_ALGO.usPaper150 = pa[0]; - #ifdef D_paraid_debug_print - L0_uart0_us(ts_task_ALGO.usPaper150);L0_uart0_uc(0xBB); - #endif - ///nothing - -} - - - - -void L1_Iap_Write_us(vU16 addr,vU16 val) -{ - EA = 0; - /********* - IAP_CONTR = WT_12M; //使能IAP - IAP_CMD = 3; //设置IAP擦除命令 - IAP_ADDRL = addr; //设置IAP低地址 - IAP_ADDRH = addr >> 8; //设置IAP高地址 - IAP_TRIG = 0x5a; //写触发命令(0x5a) - IAP_TRIG = 0xa5; //写触发命令(0xa5) - _nop_(); // - _nop_(); - - - IAP_CMD = 2; //设置IAP写命令 - IAP_DATA = dat; //写IAP数据 - IAP_TRIG = 0x5a; //写触发命令(0x5a) - IAP_TRIG = 0xa5; //写触发命令(0xa5) - _nop_(); - L0_Iap_Idle(); //关闭IAP功能 - ***************/ - L0_Iap_Erase(addr); - L0_Iap_Program(addr,val>>8); - L0_Iap_Program(addr+1,val&0x00ff); - EA = 1; -} - - -void L1_Iap_Read_us(vU16 addr,vU16 *val) -{ - EA = 0; - *val = L0_Iap_Read(addr); - *val <<= 8; - *val |= L0_Iap_Read(addr+1); - EA = 1; - -} diff --git a/source/app/app_paraid.h b/source/app/app_paraid.h deleted file mode 100644 index f17c65b..0000000 --- a/source/app/app_paraid.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _app_paraid_H -#define _app_paraid_H - -#include "../clib/clib.h" -extern void L1_Iap_Read_us(vU16 addr,vU16 *val); - -extern void L1_Iap_Write_us(vU16 addr,vU16 val); -#define D_paraAdd0_paper150 0x0000 -#define D_paraAdd1_paper150 0x0200 -extern void L1_paraid_init(void); - -#endif //_app_paraid_H calib - - - diff --git a/source/app/app_task_adc.c b/source/app/app_task_adc.c deleted file mode 100644 index 2b5f684..0000000 --- a/source/app/app_task_adc.c +++ /dev/null @@ -1,351 +0,0 @@ -#include "app_task_adc.h" -#include "../msp/UART0.h" - -//TS_ADC_CH_SWITCH ts_adc_ch_switch; -TS_ADC_CH_SAMPLE ts_adc_ch_sample[D_ch_max_num]; -TS_ADC_CH_BLUR ts_adc_ch_blur[D_ch_max_num]; -TS_ADC_ALL_BLUR ts_adc_all_blur; -TS_ADC_ALL_OUT ts_adc_all_out; -TS_ADC_SHOW ts_adc_show; - -void L3_task_adc_init(void) -{ - U8 i = 0; - for(i=0;ich_n)) - { - L2_task_go(D_task_ADC_CHx_WAIT_LOW_LEVEL); - } - else - { - s->adcval = s->pool; - L2_task_go(D_task_ADC_CHx_OUT); - } - - TTSS_Task_step(D_task_ADC_CHx_WAIT_LOW_LEVEL) - if(0 == L0_2dc_DOUT_AT(s->ch)) - { - L2_task_go(D_task_ADC_CHx_READ); - } - - TTSS_Task_step(D_task_ADC_CHx_READ) - s->adcval = L0_ADS1231_readCH(s->ch); - L2_task_go(D_task_ADC_CHx_OUT); - - TTSS_Task_step(D_task_ADC_CHx_OUT) - s->pool = s->adcval; - s->sum += s->adcval; - ++s->n; - if(s->n >= D_ADC_CH_SAMPLE_BUF_MAX) - { - s->n = 0; - s->sum = 0; - } - L2_task_go(D_task_ADC_CHx_SAMPLE); - - TTSS_Task_end(); -} - -//鍗曡矾婊ゆ尝浠诲姟 -#define D_task_ADC_CHx_BLUR_GET 0x51 -#define D_task_ADC_CHx_BLUR_AVG 0x52 -#define D_task_ADC_CHx_BLUR_SHIFT 0x53 -#define D_task_ADC_CHx_BLUR_COUNT 0x54 - -void L3_task_adc_ch_blur(TS_ADC_CH_BLUR *s) -{ - TTSS_Task_init() - L2_task_go(D_task_ADC_CHx_BLUR_GET); - - TTSS_Task_step(D_task_ADC_CHx_BLUR_GET) - if(ts_adc_ch_sample[s->ch_n].n >= R.p.cc_blur_ch_avg) - { - s->SA_sum = ts_adc_ch_sample[s->ch_n].sum; - s->SA_n = ts_adc_ch_sample[s->ch_n].n; - ts_adc_ch_sample[s->ch_n].sum = 0; - ts_adc_ch_sample[s->ch_n].n = 0; - L2_task_go(D_task_ADC_CHx_BLUR_AVG); - } - - TTSS_Task_step(D_task_ADC_CHx_BLUR_AVG) - s->SA_avg = s->SA_sum / s->SA_n; - L2_task_go(D_task_ADC_CHx_BLUR_SHIFT); - - TTSS_Task_step(D_task_ADC_CHx_BLUR_SHIFT) - s->SHA_sum -= s->SHA_avg; - s->SHA_sum += s->SA_avg; - s->SHA_avg = (S32)(s->SHA_sum >> R.p.cc_blur_ch_shift); - s->n++; - L2_task_go(D_task_ADC_CHx_BLUR_COUNT); - - TTSS_Task_step(D_task_ADC_CHx_BLUR_COUNT) - G.weight[s->ch_n] = D_COUNT_WEIGHT(s->SHA_avg); - L2_task_go(D_task_ADC_CHx_BLUR_GET); - - TTSS_Task_end(); -} - - -//鍗曡矾婊ゆ尝浠诲姟 -#define D_task_ADC_ALL_BLUR_GET 0x51 -#define D_task_ADC_ALL_BLUR_SHIFT0 0x52 -#define D_task_ADC_ALL_BLUR_SHIFT1 0x53 - -void L3_task_adc_all_blur(TS_ADC_ALL_BLUR *s) -{ - TTSS_Task_init() - L2_task_go(D_task_ADC_CHx_BLUR_GET); - - TTSS_Task_step(D_task_ADC_CHx_BLUR_GET) - //if(ts_adc_ch_blur[D_ch_max_num-1].n >= 1) - if(ts_adc_ch_blur[0].n >= 1) - { - ts_adc_ch_blur[0].n = 0; - ts_adc_ch_blur[1].n = 0; - ts_adc_ch_blur[2].n = 0; - ts_adc_ch_blur[3].n = 0; - s->sum = G.weight[0] + G.weight[1] + G.weight[2] + G.weight[3]; - L2_task_go(D_task_ADC_ALL_BLUR_SHIFT0); - } - - TTSS_Task_step(D_task_ADC_ALL_BLUR_SHIFT0) - s->SHA_sum_0 -= s->SHA_avg_0; - s->SHA_sum_0 += s->sum; - s->SHA_avg_0 = (S32)(s->SHA_sum_0 >> R.p.cc_blur_all_shift0); - s->SHA_pool_0[0] = s->SHA_pool_0[1]; - s->SHA_pool_0[1] = s->SHA_pool_0[2]; - s->SHA_pool_0[2] = s->SHA_avg_0; - L2_task_go(D_task_ADC_ALL_BLUR_SHIFT1); - - TTSS_Task_step(D_task_ADC_ALL_BLUR_SHIFT1) - s->SHA_sum_1 -= s->SHA_avg_1; - s->SHA_sum_1 += s->sum; - s->SHA_avg_1 = (S32)(s->SHA_sum_1 >> R.p.cc_blur_all_shift1); - //s->SHA_pool_1[0] = s->SHA_pool_1[1]; - //s->SHA_pool_1[1] = s->SHA_pool_1[2]; - //s->SHA_pool_1[2] = s->SHA_avg_1; - - s->n++; - L2_task_go(D_task_ADC_CHx_BLUR_GET); - - TTSS_Task_end(); -} - -#define D_task_ADC_ALL_OUT_GET 0x51 -#define D_task_ADC_ALL_OUT_DECIDE 0x52 -#define D_task_ADC_ALL_OUT_SHOW 0x53 -#define D_task_ADC_ALL_OUT_SHOW_1 0x54 -#define D_task_ADC_ALL_OUT_DEBUG 0x55 - -void L3_task_adc_all_out(TS_ADC_ALL_OUT *s) -{ - TTSS_Task_init() - //s->diff_threshold = (R.p.cc_blur_all_out_threshold); - //s->diff_threshold1 = (R.p.cc_blur_all_out_threshold1); - //s->diff_threshold2 = (R.p.cc_blur_all_out_threshold2); - //s->should_show_times_threshold = (R.p.cc_blur_all_out_should_show_times_threshold); - L2_task_go(D_task_ADC_ALL_OUT_GET); - - TTSS_Task_step(D_task_ADC_ALL_OUT_GET) - if(ts_adc_all_blur.n >= 1) - { - ts_adc_all_blur.n = 0; - Lc_buf_copy_uc((U8*)s->SHA_pool, (U8*)ts_adc_all_blur.SHA_pool_0, D_ADC_CH_BLUE_POOL_NUM * sizeof(S32)); - s->SHA_diff[0] = Lc_abs(s->SHA_pool[1] , s->SHA_pool[0]); - s->SHA_diff[1] = Lc_abs(s->SHA_pool[2] , s->SHA_pool[1]); - s->SHA_ddiff[0] = Lc_abs(s->SHA_diff[1] , s->SHA_diff[0]); - L2_task_go(D_task_ADC_ALL_OUT_DECIDE); - } - - TTSS_Task_step(D_task_ADC_ALL_OUT_DECIDE) - if((s->SHA_diff[1] >= R.p.cc_blur_all_out_d_threshold) || (s->SHA_diff[0] >= R.p.cc_blur_all_out_d_threshold) || (s->SHA_ddiff[0] >= R.p.cc_blur_all_out_dd_threshold)) - { - #if 1 - s->sum = s->SHA_pool[2] + s->SHA_pool[1] + s->SHA_pool[0]; - ts_adc_all_blur.SHA_sum_1 = s->sum; - ts_adc_all_blur.SHA_sum_1 <<= R.p.cc_blur_all_shift1; - ts_adc_all_blur.SHA_sum_1 /= 3; - ts_adc_all_blur.SHA_avg_1 = (S32)(ts_adc_all_blur.SHA_sum_1 >> R.p.cc_blur_all_shift1); - //s->val = ts_adc_all_blur.SHA_avg_0; - s->val = s->sum / 3; - //s->t = 0; - #else - ts_adc_all_blur.SHA_sum_1 = ts_adc_all_blur.SHA_avg_0 << R.p.cc_blur_all_shift1; - ts_adc_all_blur.SHA_avg_1 = ts_adc_all_blur.SHA_avg_0; - s->val = ts_adc_all_blur.SHA_avg_0; - //s->t = 0; - #endif - } - else - { - s->val = ts_adc_all_blur.SHA_avg_1; - //s->t = 1; - } - s->n++; - L2_task_go(D_task_ADC_ALL_OUT_GET); - TTSS_Task_end(); -} - -#define D_task_ADC_SHOW_GET 0x53 -#define D_task_ADC_SHOW_1 0x54 -#define D_task_ADC_SHOW_DEBUG 0x55 -void L3_task_adc_show(TS_ADC_SHOW *s) -{ - U8 i = 0,find = 0,j = 0; - TTSS_Task_init() - L2_task_go(D_task_ADC_SHOW_GET); - - TTSS_Task_step(D_task_ADC_SHOW_GET) - if(ts_adc_all_out.n >= 1) - { - ts_adc_all_out.n = 0; - s->val = ts_adc_all_out.val; - L2_task_go(D_task_ADC_SHOW_1); - } - - TTSS_Task_step(D_task_ADC_SHOW_1) - if((s->val - s->pool_val) * s->pool_gt < 0) - { - //绗﹀彿鏀瑰彉锛岃鏁版竻0 - //L0_uart0_uc('-'); - L3_task_show_times_reset(); - } - s->pool_gt = (s->val >= s->pool_val) ? 1 : -1; - - s->diff_val = Lc_abs(s->val,s->pool_val); - for(i=0;idiff_val >= R.p.weight_show_limit[i].weight) - { - find = 1; - break; - } - } - if(find) - { - s->times[i]++; - for(j=0;jtimes[j] = 0; - } - } - } - else //灏忎簬鏄剧ず鍒嗚鲸鐜(<0.02kg) - { - L3_task_show_times_reset(); - } - - for(i=0;itimes[i] >= R.p.weight_show_limit[i].times) - { - L3_task_show_times_reset(); - s->pool_val = s->val; - G._total_weight = s->pool_val; - R.total_weight = L3_count_std_weight(G._total_weight); - break; - } - } - - L2_task_go(D_task_ADC_SHOW_GET); - //L2_task_go(D_task_ADC_SHOW_DEBUG); -#if 0 - TTSS_Task_step(D_task_ADC_SHOW_DEBUG) - //L0_uart0_uc(s->t == 0 ? '0' : '1'); - s->u16_v = (vU16)(s->pool_val >> 16); - L0_uart0_ushex(s->u16_v); - s->u16_v = (vU16)(s->pool_val & 0x0000ffff); - L0_uart0_ushex(s->u16_v);//Lc_delay_us(500); - //L0_uart0_uc(0x0d); L0_uart0_uc(0x0a); - //L0_uart0_uc(' '); - //L0_uart0_uc(' '); - L2_task_go(D_task_ADC_SHOW_GET); -#endif - TTSS_Task_end(); -} - - -void L3_task_show_times_reset() -{ - U8 i = 0; - for(i=0;iok) - { - TS_PH4_modbus *ts_modbus = (TS_PH4_modbus *)ph4->buf; - if(ts_modbus->slaver == R.p.slaver_id || ts_modbus->slaver == D_UART0_485_SLAVER_ID_BROADCAST) //浠庢満 - { - U16 acklen = L3_modbus_slaver_ack(ts_modbus,&s_uart0_ack); - L0_uart0_sendArray((U8*)&s_uart0_ack, acklen); - - switch(ts_modbus->oper) - { - case 0x06: - case 0x10: - //閲嶆柊璁$畻閲嶉噺 - R.total_weight = L3_count_std_weight(G._total_weight); - //鎸佷箙鍖 - L3_eeprom_persist_param(); - break; - } - } - } - #endif -} - - diff --git a/source/app/app_task_uart0.h b/source/app/app_task_uart0.h deleted file mode 100644 index 347829a..0000000 --- a/source/app/app_task_uart0.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef APP_TASK_UART0_H -#define APP_TASK_UART0_H - -#include "common.h" -#include "../ctask/task.h" -#include "../tpc/tpc_modbus.h" - -//extern void L3_task_uart0_handler(TS_Handle_PH3 *ph3); -extern void L3_task_uart0_modbus_handler(TP_Handler_X *ph4); - -#endif diff --git a/source/app/common.c b/source/app/common.c deleted file mode 100644 index 3b5bf8d..0000000 --- a/source/app/common.c +++ /dev/null @@ -1,230 +0,0 @@ -#include "common.h" -//#include "../tpc/tpc_uart.h" -#include "../bsp/bsp_cs1232.h" -#include "../msp/msp_eeprom.h" -#include "../msp/msp_id.h" - -struct global_param G; -struct ts_eeprom_param eep_param; -struct ts_eeprom_enc eep_enc; - -#define EEP_SECTOR_SIZE 0x200 -#define EEP_PARAM_ADDR (EEP_SECTOR_SIZE * 1) -#define EEP_ENC_ADDR (EEP_SECTOR_SIZE * 0) - -void L3_eeprom_read_param() -{ - U8 dlen = 0; - L0_Iap_Read_array(EEP_PARAM_ADDR, (U8*)&eep_param, 2 + EEPROM_PARAM_DATA_MAX + 2); - if(eep_param.filter == EEPROM_PARAM_FILTER) - { - dlen = eep_param.len - 2; - crc16(eep_param.crc,(U8*)&eep_param,2+dlen); - if(eep_param.crc[0] == eep_param.buf[dlen] && eep_param.crc[1] == eep_param.buf[dlen+1]) - { - L0_uart0_uc('#'); - //Lc_buf_copy_uc((U8*)&G.p,(U8*)eep_param.buf,dlen); - Lc_buf_copy_uc((U8*)&R.p,(U8*)eep_param.buf,sizeof(R.p));//闃叉dlen>sizeof(G.P)寮曡捣鐨勫唴瀛橀敊璇 - } - } -} - -void L3_eeprom_persist_param() -{ - U8 dlen = sizeof(R.p); - eep_param.filter = EEPROM_PARAM_FILTER; - eep_param.len = dlen + 2; - Lc_buf_copy_uc((U8*)eep_param.buf,(U8*)&R.p,dlen); - crc16(eep_param.crc, &eep_param, 2+dlen); - eep_param.buf[dlen] = eep_param.crc[0]; - eep_param.buf[dlen+1] = eep_param.crc[1]; - - L0_Iap_Erase(EEP_PARAM_ADDR); - L0_Iap_Program_array(EEP_PARAM_ADDR, (U8*)&eep_param, 2 + dlen + 2); -} - -int L3_mcu_id_ok(void) -{ - U8 i = 0,crc[2]; - U32 enc_key; - //1.鑾峰彇MCU_ID - L0_id_get_rom(G.e.mcu_id); - for(i=0;i= weight) - { - break; - } - } - if(isalver = G.p.slaver_id; - pmodbus->oper = oper; - Lc_buf_copy_uc(pmodbus->buf,buf,bufsize); - crc16(pmodbus->crc,&pmodbus->salver,2 + bufsize); - pmodbus->buf[bufsize] = pmodbus->crc[0]; - pmodbus->buf[bufsize + 1] = pmodbus->crc[1]; - - return bufsize + 2 + 2; -} - -TS_PH4_modbus modbusack; -Modbus03 modbus03; -Modbus03Ack modbus03Ack; -Modbus06 modbus06; -Modbus06Ack modbus06Ack; -Modbus10 modbus10; -Modbus10Ack modbus10Ack; - -int L3_ph4_common_handler(TS_PH4_modbus *pmodbus) -{ - U8 handlerStatus = TP_HANDLED, modbuslen = 0; - switch(pmodbus->oper) - { - case 0x03: - { - U16 i = 0,j = 0,regval = 0; - modbus03.reg = ((U16)pmodbus->buf[0]) << 8 | ((U16)pmodbus->buf[1]); - modbus03.num = ((U16)pmodbus->buf[2]) << 8 | ((U16)pmodbus->buf[3]); - if((modbus03.num < 5) && (modbus03.reg < sizeof(G)/2)) //姣忔鏈澶氳鍙4涓瘎瀛樺櫒 8涓瓧鑺傦紝浠ラ槻姝㈣秺鐣 - { - for(i=0; i> 8 & 0xFF; - modbus03Ack.buf[j++] = regval & 0xFF; - } - modbus03Ack.bytes = modbus03.num * 2; - modbuslen = L3_pack_PH4(&modbusack, 0x03, &modbus03Ack, modbus03Ack.bytes + 1); - L0_uart0_sendArray((U8*)&modbusack, modbuslen); - } - break; - } - case 0x06: - { - modbus06.reg = ((U16)pmodbus->buf[0]) << 8 | ((U16)pmodbus->buf[1]); - modbus06.val = ((U16)pmodbus->buf[2]) << 8 | ((U16)pmodbus->buf[3]); - if(modbus06.reg < sizeof(G)/2) - { - if(modbus06.reg == MEM_2_REG(&G.p.zero)) - { - G._total_zweight = G._total_weight; - G.total_zweight = G._total_zweight/10; - G.total_weight = 0; - } - else if(modbus06.reg == MEM_2_REG(&G.p.reset)) - { - L3_reg_reset(); - } - else - { - *(REG_2_MEM(modbus06.reg)) = modbus06.val; - } - modbus06Ack.reg = modbus06.reg; - modbus06Ack.val = *(REG_2_MEM(modbus06.reg)); - modbuslen = L3_pack_PH4(&modbusack, 0x06, &modbus06Ack, 4); - L0_uart0_sendArray((U8*)&modbusack, modbuslen); - } - - //閲嶆柊璁$畻閲嶉噺 - G.total_weight = L3_count_std_weight(G._total_weight); - - //鎸佷箙鍖 - if(modbus06.reg > MEM_2_REG(&G.reserved2) && modbus06.reg < MEM_2_REG(&G.reserved3)) - { - L3_eeprom_persist_param(); - } - break; - } - case 0x10: - { - U16 i = 0,j = 0,regval = 0; - modbus10.reg = ((U16)pmodbus->buf[0]) << 8 | ((U16)pmodbus->buf[1]); - modbus10.num = ((U16)pmodbus->buf[2]) << 8 | ((U16)pmodbus->buf[3]); - modbus10.count = pmodbus->buf[4]; - if((modbus10.num < 21) && (modbus10.reg < sizeof(G)/2)) //姣忔鏈澶氬啓鍏20涓瘎瀛樺櫒 40涓瓧鑺傦紝浠ラ槻姝㈣秺鐣 - { - for(i=0; ibuf[5+i*2]) << 8 | ((U16)pmodbus->buf[5+i*2+1]); - *(REG_2_MEM(modbus10.reg + i)) = regval; - } - modbus10Ack.reg = modbus10.reg; - modbus10Ack.num = modbus10.num; - modbuslen = L3_pack_PH4(&modbusack, 0x10, &modbus10Ack, 4); - L0_uart0_sendArray((U8*)&modbusack, modbuslen); - } - - //閲嶆柊璁$畻閲嶉噺 - G.total_weight = L3_count_std_weight(G._total_weight); - - //鎸佷箙鍖 - if(modbus10.reg > MEM_2_REG(&G.reserved2) && modbus10.reg < MEM_2_REG(&G.reserved3)) - { - L3_eeprom_persist_param(); - } - break; - } - default: - //L3_ph4_send_error_pkg(MODBUS_ERR_OPCODE); - break; - } - return handlerStatus; -} -#endif - diff --git a/source/app/common.h b/source/app/common.h deleted file mode 100644 index fb88fb8..0000000 --- a/source/app/common.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef APP_COMMON_H -#define APP_COMMON_H - -#include "../clib/type.h" - -#define APP_VERSION 0x10 - -#define D_MCU_BIGENDIAN 1 -// #define D_MCU_LITTLEENDIAN 1 - -#define D_COUNT_WEIGHT(adc) ((S32)((1000.0 * R.p.weight_max * (adc)) / (2 * 0x7FFFFF / 1000 * D_ADS1213_GAIN_VAL * R.p.lmd))) - -enum tp_handle -{ - TP_HANDLED, - TP_UNHANDLE -}; - -/** - * EEPROM 瀛樺偍缁撴瀯 - */ -#define EEPROM_PARAM_DATA_MAX 90 -#define EEPROM_PARAM_FILTER 0xAA - -typedef struct ts_eeprom_param -{ - U8 filter; - U8 len; - U8 buf[EEPROM_PARAM_DATA_MAX]; - U8 crc[2]; -}EEPROM_PARAM; - -#define MCU_ID_LEN 7 -#define MCU_ID_KEY_LEN 4 -#define EEPROM_ENC_DATA_MAX 64 -#define EEPROM_ENC_FILTER 0xAA -typedef struct ts_eeprom_enc -{ - U8 enc_key[MCU_ID_KEY_LEN]; - U8 enc_val[MCU_ID_LEN]; - U8 crc[2]; -}EEPROM_ENC; - -#define baud_rade L3_baud_rate_change(G.p.baud_rate) - -typedef struct mcu_encrypt_info -{ - U8 enc_key[MCU_ID_KEY_LEN]; - U8 mcu_id[MCU_ID_LEN]; - U8 mcu_enc_id[MCU_ID_LEN]; -}McuEncryptInfo; - -#define D_ch_max_num 4 -typedef struct global_param -{ - //EncryptInfo - McuEncryptInfo e; - - //Global Variables - S32 weight[D_ch_max_num]; //4璺噸閲 - S32 _total_weight; //瀹為檯閲嶉噺*1000 - S32 _total_zweight; //瀹為檯鐨噸*1000 -}GlobalParam; - -extern struct global_param G; -extern struct ts_eeprom_param eep_param; -extern struct ts_eeprom_enc eep_enc; - -extern void L3_param_init(void); -extern int L3_mcu_id_ok(); -extern S32 L3_count_std_weight(S32 weight); -extern void L3_eeprom_persist_param(void); - -#endif - diff --git a/source/app/main.c b/source/app/main.c index 1ead5a2..daf14a2 100644 --- a/source/app/main.c +++ b/source/app/main.c @@ -79,23 +79,29 @@ stc5ac32s #include "main.h" - -/// main init -/// @param a 琚祴璇曠殑鍙橀噺锛坧aram鎻忚堪鍙傛暟锛 -/// @param s 鎸囧悜鎻忚堪娴嬭瘯淇℃伅鐨勫瓧绗︿覆 -/// @return 娴嬭瘯缁撴灉锛坮eturn鎻忚堪杩斿洖鍊硷級 -/// @see Test() 锛堟湰鍑芥暟鍙傝冨叾瀹冪殑鐩稿叧鐨勫嚱鏁帮紝杩欓噷浣滀竴涓摼鎺ワ級 -/// @note (note鎻忚堪闇瑕佹敞鎰忕殑闂) - void L0_main_init(void) { //Lc_delay_ms(200); + L0_board_config(); L0_uart0_buf_init();//涓插彛鍒濆鍖 EA = 1; //Lc_delay_ms(100); L1_tick_init(); L0_timer0_Init(); - //L0_timer1_Init(); + + L3_reg_init(); + L3_param_init(); + L2_485_init(); + L0_ADS1213_INIT(); + + L3_task_adc_init(0); + L3_task_adc_init(1); + L3_task_adc_init(2); + L3_task_adc_init(3); + //L3_task_debug_init(); + L3_task_show_init(); + L3_task_reglisten_init(); + L0_uart0_sendArray("v2.7",4); } //=============================================== @@ -103,72 +109,39 @@ void L0_main_init(void) //=============================================== void main(void) { -//----------------------------------------------- -//绯荤粺鍒濆鍖 -//---------------------------------------------- + //鍒濆鍖 L0_main_init(); - L0_reg_init(); - L3_param_init(); - L2_485_init(); - L0_ADS1213_INIT(); - L3_task_adc_init(); - L0_uart0_sendArray("v2.7",4); - P35 = 0;//led on - -//----------------------------------------------- -//绯荤粺涓诲惊鐜 -//----------------------------------------------- -#if 0 //鐪嬮棬鐙 - if(!L3_mcu_id_ok()) - { - P35 = 0; - P10 = 0; - while(1) - { - if(1 == s_nos_tick.t1s_heatbeart) - { - s_nos_tick.t1s_heatbeart = 0; - L0_uart0_uc('X'); - } - } - } -#endif - //L1_ADS1213_main(); - + //楠岃瘉鍔犲瘑淇℃伅 + //L3_encrypt_handler(); + //涓诲惊鐜 while(1) { if(1 == s_nos_tick.t1s_heatbeart) { s_nos_tick.t1s_heatbeart = 0; LED1 ^= 1; - //L0_uart0_sendArray("abcdefg",7); } - #if 1 - //鍗曡矾閲囬泦 - L3_task_adc_ch_sample(&ts_adc_ch_sample[0]); - L3_task_adc_ch_sample(&ts_adc_ch_sample[1]); - L3_task_adc_ch_sample(&ts_adc_ch_sample[2]); - L3_task_adc_ch_sample(&ts_adc_ch_sample[3]); - //鍗曡矾婊ゆ尝 - L3_task_adc_ch_blur(&ts_adc_ch_blur[0]); - L3_task_adc_ch_blur(&ts_adc_ch_blur[1]); - L3_task_adc_ch_blur(&ts_adc_ch_blur[2]); - L3_task_adc_ch_blur(&ts_adc_ch_blur[3]); - - //鍜屽兼护娉 - L3_task_adc_all_blur(&ts_adc_all_blur); - - //绉讳綅鍒囨崲杈撳嚭鏈缁堟暟鎹 - L3_task_adc_all_out(&ts_adc_all_out); - - //鏇存柊鏄剧ず鏁版嵁 - L3_task_adc_show(&ts_adc_show); - #endif + //L1_ADS1213_main(); + + //鍗曡矾閲囬泦婊ゆ尝 + L3_task_adc_handler(0); + L3_task_adc_handler(1); + L3_task_adc_handler(2); + L3_task_adc_handler(3); + //鏄剧ず + L3_task_adc_filter_show(&ts_adc_blur_show); + + //瀵勫瓨鍣ㄥ肩洃鎺 + L3_task_reglisten_handle(&s_task_reglisten); + //杈撳嚭,鍝嶅簲485鍗忚 - L3_task_uart0_modbus_handler(&s_uart0_rec); - } + L3_task_modbus_handler(&s_uart0_rec); + + //璋冭瘯杈撳嚭 + //L3_task_debug(&_s_task_debug); + } } //end main diff --git a/source/app/main.h b/source/app/main.h index bc0a59e..ba525f9 100644 --- a/source/app/main.h +++ b/source/app/main.h @@ -36,61 +36,25 @@ #ifndef _MAIN_H #define _MAIN_H -#include "../bsp/bsp_config.h" -//#include "../bsp/adxl362.h" -//#include "../msp/stc_adc.h" #include "../msp/uart0.h" -//#include "../msp/uart2.h" -//#include "../msp/uart4.h" -//#include "../msp/uart3.h" -//#include "../msp/time.h" -//#include "../msp/msp_buzz.h" -//#include "../msp/msp_rtc.h" -//#include "../msp/msp_plcd.h" -//#include "../msp/iic_sim.h" -#include "../msp/msp_eeprom.h" -#include "../msp/msp_id.h" - - -#include "../clib/Clib.h" -#include "../clib/bit.h" - -//#include "../debug/debug_drv.h" -//#include "../uartcom/uprotocol.h" -//#include "../uartcom/Uartcom0.h" -#include "../ctask/task.h" -#include "../ctask/tick.h" - -//#include "../bsp/bsp_led.h" - -#include "../bsp/bsp_power.h" - - -//#include "../bsp/Bsp_debug.h" - - -//#include "app_yeelink.h" -//#include "app_flow.h" - -//#include "app_Gsensor.h" -//#include "app_io.h" -//#include "../tpc/tpc_uart.h" - -//#include "stdio.h" -#include "app_paraid.h" -//#include "app_algorithm.h"/// +#include "../msp/eeprom.h" +#include "../bsp/bsp_config.h" +#include "../bsp/chipid.h" +#include "../bsp/cs1232.h" +#include "../bsp/rs485.h" -#include "../bsp/bsp_cs1232.h" -#include "../bsp/bsp_485.h" -#include "../app/app_task_uart0.h" -#include "../app/app_task_adc.h" +#include "../app/app_config.h" +#include "../app/task_modbus.h" +#include "../app/task_adc.h" +#include "../app/task_debug.h" +#include "../app/task_register.h" +#include "../app/task_encrypt.h" ////////////////////////////////////////////////////////////////// - #endif //#ifndef _MAIN_H diff --git a/source/app/task_adc.c b/source/app/task_adc.c new file mode 100644 index 0000000..ce38ace --- /dev/null +++ b/source/app/task_adc.c @@ -0,0 +1,418 @@ +//////////////////////////////////////////////////////////////////////////// +///@copyright Copyright (c) 2018, 浼犳帶绉戞妧 All rights reserved. +///------------------------------------------------------------------------- +/// @file bsp_drv.c +/// @brief bsp @ driver config +///------------------------------------------------------------------------- +/// @version 1.0 +/// @author CC +/// @date 20180331 +/// @note cc_AS_stc02 +////////////////////////////////////////////////////////////////////////////// + +#include "task_adc.h" +#include "../bsp/bsp_config.h" +#include "../bsp/cs1232.h" +#include "../msp/uart0.h" + +//============================================= + +//S_TASK_ADC_CHANNEL_BLUR ts_adc_channel_blurs[D_ADC_CHANNEL_NUM]; +//S_TASK_ADC_CHANNEL_SHOW ts_adc_channel_show; + +S_TASK_ADC_CHANNEL_SAMPLE ts_adc_channel_samples[D_ADC_CHANNEL_NUM]; +//S_TASK_ADC_BLUR_MID ts_adc_blur_mid[D_ADC_CHANNEL_NUM]; +S_TASK_ADC_BLUR_AVG ts_adc_blur_avg[D_ADC_CHANNEL_NUM]; +S_TASK_ADC_BLUR_SHIFT ts_adc_blur_shift[D_ADC_CHANNEL_NUM]; +S_TASK_ADC_BLUR_OUT ts_adc_blur_out[D_ADC_CHANNEL_NUM]; +S_TASK_ADC_BLUR_SHOW ts_adc_blur_show; + +static U8 count_n(u8 n,u8 d) +{ + if(n < d) + { + return MAX_OUT_NUM + n - d ; + } + else + { + return n-d; + } +} + +U32 Abs(S32 a) +{ + if(a < 0) + { + a = -a; + } + return a; +} +//ch鏄0123锛屼唬琛4閫氶亾 +void L3_task_adc_init(U8 ch) +{ + //閫氶亾閲囬泦浠诲姟鍒濆鍖 + L1_task_init(&ts_adc_channel_samples[ch].task); + L3_task_s_go(ts_adc_channel_samples[ch],D_task_init); + ts_adc_channel_samples[ch].status = (R.p.adc_ch_status >> ch) & 0x1; + ts_adc_channel_samples[ch].pool = 0; + ts_adc_channel_samples[ch].adcval = 0; + ts_adc_channel_samples[ch].n = 0; + ts_adc_channel_samples[ch].ch = D_ADCCH_1 + ch; + +#if 0 + //閫氶亾涓兼护娉换鍔″垵濮嬪寲 + L1_task_init(&ts_adc_blur_mid[ch].task); + L3_task_s_go(ts_adc_blur_mid[ch],D_task_init); + ts_adc_blur_mid[ch].n = 0; + ts_adc_blur_mid[ch].max = R.p.adc_blur_mid; + ts_adc_blur_mid[ch].ch = D_ADCCH_1 + ch; +#endif + + //閫氶亾鍧囧兼护娉换鍔″垵濮嬪寲 + L1_task_init(&ts_adc_blur_avg[ch].task); + L3_task_s_go(ts_adc_blur_avg[ch],D_task_init); + ts_adc_blur_avg[ch].max = R.p.adc_blur_avg; + ts_adc_blur_avg[ch].avgval = 0; + ts_adc_blur_avg[ch].n = 0; + ts_adc_blur_avg[ch].ch = D_ADCCH_1 + ch; + + //閫氶亾绉讳綅婊ゆ尝浠诲姟鍒濆鍖 + L1_task_init(&ts_adc_blur_shift[ch].task); + L3_task_s_go(ts_adc_blur_shift[ch],D_task_init); + ts_adc_blur_shift[ch].n = 0; + ts_adc_blur_shift[ch].h = 0; + ts_adc_blur_shift[ch].shiftreg[0] = R.p.adc_blur_shift[0]; + ts_adc_blur_shift[ch].shiftreg[1] = R.p.adc_blur_shift[1]; + ts_adc_blur_shift[ch].shiftreg[2] = R.p.adc_blur_shift[2]; + ts_adc_blur_shift[ch].sum[0] = 0; + ts_adc_blur_shift[ch].sum[1] = 0; + ts_adc_blur_shift[ch].sum[2] = 0; + ts_adc_blur_shift[ch].shiftval[0] = 0; + ts_adc_blur_shift[ch].shiftval[1] = 0; + ts_adc_blur_shift[ch].shiftval[2] = 0; + ts_adc_blur_shift[ch].ch = D_ADCCH_1 + ch; + + //杈撳嚭鍒ゅ畾浠诲姟鍒濆鍖 + L1_task_init(&ts_adc_blur_out[ch].task); + L3_task_s_go(ts_adc_blur_out[ch],D_task_init); + ts_adc_blur_out[ch].h= 0; + ts_adc_blur_out[ch].threshold[0] = D_COUNT_ADC(R.p.adc_blur_threshold[0]); //2KG + ts_adc_blur_out[ch].threshold[1] = D_COUNT_ADC(R.p.adc_blur_threshold[1]); //0.5KG + ts_adc_blur_out[ch].newnum = 0; + ts_adc_blur_out[ch].oldnum = 0; + ts_adc_blur_out[ch].newout = 0; + ts_adc_blur_out[ch].n = 0; + ts_adc_blur_out[ch].ch = D_ADCCH_1 + ch; + +#if 0 + //閫氶亾鍒囨崲浠诲姟鍒濆鍖 + //L1_task_init(&ts_adc_channel_switch.task); + L3_task_s_go(ts_adc_channel_switch,D_task_init); +#endif + +} + + +void L3_task_show_init(void) +{ + //鏄剧ず浠诲姟鍒濆鍖 + L1_task_init(&ts_adc_blur_show.task); + L3_task_s_go(ts_adc_blur_show,D_task_init); + ts_adc_blur_show.rough_weight = 0; +} + + +//ADC Channel 閲囨牱浠诲姟 +#define D_task_ADC_CHx_SAMPLE_WAIT_LOW 0x53 +#define D_task_ADC_CHx_SAMPLE_READ 0x54 +#define D_task_ADC_CHx_SAMPLE_OUT 0x55 +void L3_task_adc_channel_sample(S_TASK_ADC_CHANNEL_SAMPLE *s) +{ + TTSS_Task_init() + L2_task_go(D_task_ADC_CHx_SAMPLE_WAIT_LOW); + + TTSS_Task_step(D_task_ADC_CHx_SAMPLE_WAIT_LOW) + if(s->status == ADC_CHANNEL_STATUS_READY) //闇瑕佸垽鏂璼tatus鏄惁ready锛宺eady鍒欒鍙栵紝鍚﹀垯浣跨敤pool鍊 + { + if(0 == L0_2dc_DOUT_AT(s->ch)) + { + L2_task_go(D_task_ADC_CHx_SAMPLE_READ); + } + } + else + { + s->adcval = s->pool; + L2_task_go_Tdelay(D_task_ADC_CHx_SAMPLE_OUT,D_Tdelay_Msec(15)); //寤舵椂15ms锛屾ā鎷熶竴娆¢噰鏍疯繃绋 + } + + TTSS_Task_step(D_task_ADC_CHx_SAMPLE_READ) + if(s->status == ADC_CHANNEL_STATUS_READY) //闇瑕侀噸鏂板垽鏂璼tatus鏄惁ready锛屽洜涓篶hannel_switch浠诲姟闅忔椂鍙兘淇敼status鐘舵 + { + s->adcval = Abs(L0_ADS1231_readCH(s->ch)); + L2_task_go(D_task_ADC_CHx_SAMPLE_OUT); + } + else + { + L2_task_go(D_task_ADC_CHx_SAMPLE_WAIT_LOW); + } + + TTSS_Task_step(D_task_ADC_CHx_SAMPLE_OUT) + //涓嶅垽鏂璻eady,涓嶇鏄噰闆嗗埌鐨勭湡瀹炴暟鎹繕鏄痯ool鏁版嵁锛岄兘缁х画鎵ц + s->pool = s->adcval; + s->out[s->n] = s->adcval; + //R.adval[s->ch] = s->out[s->n]; + //L0_uart0_ulhex(R.adval[s->ch]);L0_uart0_0d0a(); + s->n++; + #if 0 + L0_uart0_ulhex(s->out[count_n(s->n,1)]); + L0_uart0_uc(' '); + //L0_uart0_ulhex(ts_adc_blur_mid[s->ch].out[count_n(ts_adc_blur_mid[s->ch].n,1)]); + //L0_uart0_uc(' '); + L0_uart0_ulhex(ts_adc_blur_avg[s->ch].out[count_n(ts_adc_blur_avg[s->ch].n,1)]); + L0_uart0_uc(' '); + L0_uart0_ulhex(ts_adc_blur_shift[s->ch].shiftval[0]); + L0_uart0_uc(' '); + L0_uart0_ulhex(ts_adc_blur_shift[s->ch].shiftval[1]); + L0_uart0_uc(' '); + L0_uart0_ulhex(ts_adc_blur_shift[s->ch].shiftval[2]); + L0_uart0_uc(' '); + L0_uart0_ulhex(R.adval[s->ch]); + L0_uart0_uc(' '); + L0_uart0_ulhex(ts_adc_blur_out[s->ch].oldnum); + L0_uart0_0d0a(); + #endif + + if(s->n >= MAX_OUT_NUM) + { + s->n = 0; + } + L2_task_go(D_task_ADC_CHx_SAMPLE_WAIT_LOW); + + TTSS_Task_end(); +} + +#if 0 +//涓兼护娉换鍔 +#define D_task_ADC_CHx_FILTER_MID_GET 0x50 +#define D_task_ADC_CHx_FILTER_MID_COUNT 0x51 +#define D_task_ADC_CHx_FILTER_MID_OUT 0x52 +void L3_task_adc_filter_mid(S_TASK_ADC_BLUR_MID *s) +{ + TTSS_Task_init() + L2_task_go(D_task_ADC_CHx_FILTER_MID_GET); + + TTSS_Task_step(D_task_ADC_CHx_FILTER_MID_GET) + if(ts_adc_channel_samples[s->ch].n >= s->max) + { + U8 i = 0; + for(i=0;imax;i++) + { + s->in[i] = ts_adc_channel_samples[s->ch].out[i]; + } + ts_adc_channel_samples[s->ch].n = 0; + L2_task_go(D_task_ADC_CHx_FILTER_MID_COUNT); + } + + TTSS_Task_step(D_task_ADC_CHx_FILTER_MID_COUNT) + s->midval = Lc_vS32_media(s->in, s->max); + L2_task_go(D_task_ADC_CHx_FILTER_MID_OUT); + + TTSS_Task_step(D_task_ADC_CHx_FILTER_MID_OUT) + s->out[s->n] = s->midval; + //R.adval[s->ch] = s->out[s->n]; + s->n++; + if(s->n >= MAX_OUT_NUM) + { + s->n = 0; + } + L2_task_go(D_task_ADC_CHx_FILTER_MID_GET); + + TTSS_Task_end(); +} +#endif + + +//鍧囧兼护娉换鍔 +#define D_task_ADC_CHx_FILTER_AVG_GET 0x50 +#define D_task_ADC_CHx_FILTER_AVG_COUNT 0x51 +#define D_task_ADC_CHx_FILTER_AVG_OUT 0x52 +void L3_task_adc_filter_avg(S_TASK_ADC_BLUR_AVG *s) +{ + TTSS_Task_init() + L2_task_go(D_task_ADC_CHx_FILTER_AVG_GET); + + TTSS_Task_step(D_task_ADC_CHx_FILTER_AVG_GET) + if(ts_adc_channel_samples[s->ch].n >= s->max) + { + U8 i = 0; + ts_adc_channel_samples[s->ch].n = 0; + for(i=0;imax;i++) + { + s->in[i] = ts_adc_channel_samples[s->ch].out[i]; + } + L2_task_go(D_task_ADC_CHx_FILTER_AVG_COUNT); + } + + TTSS_Task_step(D_task_ADC_CHx_FILTER_AVG_COUNT) + s->avgval = Lc_vU32_avg(s->in,s->max); + L2_task_go(D_task_ADC_CHx_FILTER_AVG_OUT); + + TTSS_Task_step(D_task_ADC_CHx_FILTER_AVG_OUT) + s->out[s->n] = s->avgval; + //R.adval[s->ch] = s->out[s->n]; + s->n++; + if(s->n >= MAX_OUT_NUM) + { + s->n = 0; + } + L2_task_go(D_task_ADC_CHx_FILTER_AVG_GET); + + TTSS_Task_end(); + + +} + + +//绉讳綅婊ゆ尝浠诲姟 +#define D_task_ADC_CHx_FILTER_SHIFT_GET 0x50 +#define D_task_ADC_CHx_FILTER_SHIFT_COUNT 0x51 +#define D_task_ADC_CHx_FILTER_SHIFT_OUT 0x52 +void L3_task_adc_filter_shift(S_TASK_ADC_BLUR_SHIFT *s) +{ + TTSS_Task_init() + L2_task_go(D_task_ADC_CHx_FILTER_SHIFT_GET); + + TTSS_Task_step(D_task_ADC_CHx_FILTER_SHIFT_GET) + if(s->h != ts_adc_blur_avg[s->ch].n) + { + s->in = ts_adc_blur_avg[s->ch].out[count_n(ts_adc_blur_avg[s->ch].n,1)]; + s->h = ts_adc_blur_avg[s->ch].n; + L2_task_go(D_task_ADC_CHx_FILTER_SHIFT_COUNT); + } + + TTSS_Task_step(D_task_ADC_CHx_FILTER_SHIFT_COUNT) + s->sum[0] -= s->shiftval[0]; + s->sum[0] += s->in; + s->shiftval[0] = s->sum[0] >> s->shiftreg[0]; + s->sum[1] -= s->shiftval[1]; + s->sum[1] += s->in; + s->shiftval[1] = s->sum[1] >> s->shiftreg[1]; + s->sum[2] -= s->shiftval[2]; + s->sum[2] += s->in; + s->shiftval[2] = s->sum[2] >> s->shiftreg[2]; + L2_task_go(D_task_ADC_CHx_FILTER_SHIFT_OUT); + + TTSS_Task_step(D_task_ADC_CHx_FILTER_SHIFT_OUT) + s->out[0][s->n] = s->shiftval[0]; + s->out[1][s->n] = s->shiftval[1]; + s->out[2][s->n] = s->shiftval[2]; + + + //R.adval[s->ch] = s->out[0][s->n] = s->shiftval[0]; + s->n++; + if(s->n >= MAX_OUT_NUM) + { + s->n = 0; + } + L2_task_go(D_task_ADC_CHx_FILTER_SHIFT_GET); + + TTSS_Task_end(); + +} + +//杈撳嚭鍒ゅ畾浠诲姟 +#define D_task_ADC_CHx_FILTER_OUT_GET 0x50 +#define D_task_ADC_CHx_FILTER_OUT_COUNT 0x51 +#define D_task_ADC_CHx_FILTER_OUT_CHANGE 0x52 +#define D_task_ADC_CHx_FILTER_OUT_OUT 0x53 +void L3_task_adc_filter_out(S_TASK_ADC_BLUR_OUT *s) +{ + TTSS_Task_init() + L2_task_go(D_task_ADC_CHx_FILTER_OUT_GET); + + TTSS_Task_step(D_task_ADC_CHx_FILTER_OUT_GET) + if(s->h != ts_adc_blur_shift[s->ch].n) + { + s->h = ts_adc_blur_shift[s->ch].n; + s->in[0] = ts_adc_blur_avg[s->ch].out[count_n(ts_adc_blur_avg[s->ch].n, 1)]; + s->in[1] = ts_adc_blur_avg[s->ch].out[count_n(ts_adc_blur_avg[s->ch].n, 2)]; + //鑾峰彇杈撳嚭鏇茬嚎val + s->newout = ts_adc_blur_shift[s->ch].out[s->oldnum][count_n(ts_adc_blur_shift[s->ch].n, 1)]; + L2_task_go(D_task_ADC_CHx_FILTER_OUT_COUNT); + } + + TTSS_Task_step(D_task_ADC_CHx_FILTER_OUT_COUNT) //鏍规嵁闃鍊奸夋嫨杈撳嚭鐨勬洸绾 + //鍒ゆ柇閫夋嫨鏂版洸绾 + if(Lc_abs(s->in[0] , s->in[1]) >= s->threshold[0])//2KG + { + s->newnum = 0; + } + else if(Lc_abs(s->in[0] , s->in[1]) >= s->threshold[1]) //0.5KG + { + s->newnum = 1; + } + else + { + s->newnum = 2; + } + //L2_task_go(D_task_ADC_CHx_FILTER_OUT_OUT); + L2_task_go(D_task_ADC_CHx_FILTER_OUT_CHANGE); + + TTSS_Task_step(D_task_ADC_CHx_FILTER_OUT_CHANGE) + if(s->newnum != s->oldnum)//鍒囨崲绉讳綅婊ゆ尝鏃惰皟鏁村叾浠栨护娉㈢殑SUM + { + s->oldnum = s->newnum; //涓嶈兘鍙皟鏁存柊鍊硷紝鎵鏈夋洸绾块兘瑕佷竴璧疯皟鏁 + //ts_adc_blur_shift[s->ch].sum[1] = (ts_adc_blur_avg[s->ch].out[ts_adc_blur_avg[s->ch].n] * R.adc_blur_avg); + ts_adc_blur_shift[s->ch].sum[0] = s->newout << ts_adc_blur_shift[s->ch].shiftreg[0]; + ts_adc_blur_shift[s->ch].shiftval[0] = s->newout; + ts_adc_blur_shift[s->ch].sum[1] = s->newout << ts_adc_blur_shift[s->ch].shiftreg[1]; + ts_adc_blur_shift[s->ch].shiftval[1] = s->newout; + ts_adc_blur_shift[s->ch].sum[2] = s->newout << ts_adc_blur_shift[s->ch].shiftreg[2]; + ts_adc_blur_shift[s->ch].shiftval[2] = s->newout; + } + L2_task_go(D_task_ADC_CHx_FILTER_OUT_OUT); + + TTSS_Task_step(D_task_ADC_CHx_FILTER_OUT_OUT) + R.adval[s->ch] = s->newout; + //R.adval[s->ch] = ts_adc_channel_samples[s->ch].adcval; + L2_task_go(D_task_ADC_CHx_FILTER_OUT_GET); + + TTSS_Task_end(); + +} + + +//鏄剧ず浠诲姟 +#define D_task_ADC_CHx_SHOW 0x50 +void L3_task_adc_filter_show(S_TASK_ADC_BLUR_SHOW *s) +{ + TTSS_Task_init() + L2_task_go(D_task_ADC_CHx_SHOW); + + TTSS_Task_step(D_task_ADC_CHx_SHOW) + R.ch_weight[0] = D_COUNT_WEIGHT(R.adval[0]); + R.ch_weight[1] = D_COUNT_WEIGHT(R.adval[1]); + R.ch_weight[2] = D_COUNT_WEIGHT(R.adval[2]); + R.ch_weight[3] = D_COUNT_WEIGHT(R.adval[3]); + s->rough_weight = R.ch_weight[0] + R.ch_weight[1] + R.ch_weight[2] + R.ch_weight[3]; //姣涢噸 + if( ABS(R.rough_weight,s->rough_weight) >= 50) //鍙樺寲瓒呰繃0.05KG + { + R.rough_weight = s->rough_weight; + R.total_weight = (R.rough_weight > R.total_zweight) ? (R.rough_weight - R.total_zweight) : (0);//鍑閲 + } + L2_task_go_Tdelay(D_task_ADC_CHx_SHOW,D_Tdelay_Msec(15)); //寤舵椂15ms + + TTSS_Task_end(); +} + +void L3_task_adc_handler(u8 ch) +{ + L3_task_adc_channel_sample(&ts_adc_channel_samples[ch]); + //L3_task_adc_filter_mid(&ts_adc_blur_mid[ch]); + L3_task_adc_filter_avg(&ts_adc_blur_avg[ch]); + L3_task_adc_filter_shift(&ts_adc_blur_shift[ch]); + L3_task_adc_filter_out(&ts_adc_blur_out[ch]); +} + + + diff --git a/source/app/task_adc.h b/source/app/task_adc.h new file mode 100644 index 0000000..327b972 --- /dev/null +++ b/source/app/task_adc.h @@ -0,0 +1,119 @@ +//////////////////////////////////////////////////////////////////////////// +///@copyright Copyright (c) 2018, 浼犳帶绉戞妧 All rights reserved. +///------------------------------------------------------------------------- +/// @file bsp_drv.h +/// @brief bsp @ driver config +///------------------------------------------------------------------------- +/// @version 1.0 +/// @author CC +/// @date 20180331 +/// @note cc_AS_stc02 + +////////////////////////////////////////////////////////////////////////////// + +#ifndef _APP_TASK_ADC_H +#define _APP_TASK_ADC_H + +#include "../app/app_config.h" +#include "../ctask/task.h" +#include "../clib/clib.h" + + +#define ADC_CHANNEL_STATUS_UNREADY 0 //UnReady鐘舵侊紝涓嶈兘璇诲彇 +#define ADC_CHANNEL_STATUS_READY 1 //ready鐘舵侊紝鍙互璇诲彇 + +//AD_CHANNEL_SAMPLE 閲囨牱 +#define MAX_OUT_NUM 6 +typedef struct _s_task_adc_channel_sample +{ + TS_task task; + vU8 status; + vU8 ch; + vU32 adcval; + vU32 pool; + vU8 n; + vU32 out[MAX_OUT_NUM]; +}S_TASK_ADC_CHANNEL_SAMPLE; + +//AD_BLUR_MID 涓兼护娉 +typedef struct _s_task_adc_blur_mid + +{ + TS_task task; + vU8 ch; + vU8 max; + vU32 in[MAX_OUT_NUM]; + vU32 midval; + vU8 n; + vU32 out[MAX_OUT_NUM]; +}S_TASK_ADC_BLUR_MID; + +//AD_BLUR_AVG 鍧囧兼护娉 +typedef struct _s_task_adc_blur_avg +{ + TS_task task; + vU8 ch; + vU8 max; + vU32 in[MAX_OUT_NUM]; + vU32 avgval; + vU8 n; + vU32 out[MAX_OUT_NUM]; +}S_TASK_ADC_BLUR_AVG; + +//AD_BLUR_SHIFT 绉讳綅婊ゆ尝 +typedef struct _s_task_adc_blur_shift +{ + TS_task task; + vU8 ch; + vU8 n; + vU8 h; + vU8 shiftreg[3]; + //vU8 max; + vU32 in; + vU32 sum[3]; + vU32 shiftval[3]; + vU32 out[3][MAX_OUT_NUM]; +}S_TASK_ADC_BLUR_SHIFT; + +//AD_BLUR_DECIDE 杈撳嚭鍒ゅ畾 +typedef struct _s_task_adc_blur_out +{ + TS_task task; + vU8 ch; + vU32 in[2]; + U32 threshold[2]; + vU8 h; + vU8 oldnum; + vU8 newnum; + vU32 newout; + vU8 n; +}S_TASK_ADC_BLUR_OUT; + +//AD_BLUR_SHOW 鏄剧ず +typedef struct _s_task_adc_blur_show +{ + TS_task task; + vU32 rough_weight; +}S_TASK_ADC_BLUR_SHOW; + + +extern S_TASK_ADC_CHANNEL_SAMPLE ts_adc_channel_samples[D_ADC_CHANNEL_NUM]; +//extern S_TASK_ADC_BLUR_MID ts_adc_blur_mid[D_ADC_CHANNEL_NUM]; +extern S_TASK_ADC_BLUR_AVG ts_adc_blur_avg[D_ADC_CHANNEL_NUM]; +extern S_TASK_ADC_BLUR_SHIFT ts_adc_blur_shift[D_ADC_CHANNEL_NUM]; +extern S_TASK_ADC_BLUR_OUT ts_adc_blur_out[D_ADC_CHANNEL_NUM]; +extern S_TASK_ADC_BLUR_SHOW ts_adc_blur_show; + + +extern void L3_task_adc_init(U8 ch); +extern void L3_task_show_init(void); +extern void L3_task_adc_handler(U8 ch); +extern void L3_task_adc_init_handler(void); +extern void L3_task_adc_channel_switch_handler(void); +extern void L3_task_adc_filter_show(S_TASK_ADC_BLUR_SHOW *s); + + + + +#endif // #ifndef _APP_TASK_ADC_H + diff --git a/source/app/task_debug.c b/source/app/task_debug.c new file mode 100644 index 0000000..9380cda --- /dev/null +++ b/source/app/task_debug.c @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////// +///@copyright Copyright (c) 2018, 浼犳帶绉戞妧 All rights reserved. +///------------------------------------------------------------------------- +/// @file bsp_drv.c +/// @brief bsp @ driver config +///------------------------------------------------------------------------- +/// @version 1.0 +/// @author CC +/// @date 20180331 +/// @note cc_AS_stc02 +////////////////////////////////////////////////////////////////////////////// + +#include "task_debug.h" +#include "../app/app_config.h" +#include "../bsp/bsp_config.h" +#include "../msp/uart0.h" + +S_TASK_DEBUG _s_task_debug; + +//============================================= +void L3_task_debug_init(void) +{ + L1_task_init(&_s_task_debug.task); + L3_task_s_go(_s_task_debug,D_task_init); +} + +#define D_task_ADC_CHx_DEBUG 0x53 +void L3_task_debug(S_TASK_DEBUG *s) +{ + TTSS_Task_init() + L2_task_go(D_task_ADC_CHx_DEBUG); + + TTSS_Task_step(D_task_ADC_CHx_DEBUG) + /* L0_uart0_ulhex(R.adval[0]); + L0_uart0_uc(' '); + L0_uart0_ulhex(R.adval[1]); + L0_uart0_uc(' '); + L0_uart0_ulhex(R.adval[2]); + L0_uart0_uc(' '); + L0_uart0_ulhex(R.adval[3]); + L0_uart0_uc(' ');*/ + L0_uart0_ulhex(R.total_weight); + L0_uart0_0d0a(); + L2_task_go_Tdelay(D_task_ADC_CHx_DEBUG,D_Tdelay_Msec(15)); //寤舵椂15ms + + TTSS_Task_end(); +} + + + + diff --git a/source/bsp/bsp_debug.h b/source/app/task_debug.h similarity index 50% rename from source/bsp/bsp_debug.h rename to source/app/task_debug.h index 6940097..7e96363 100644 --- a/source/bsp/bsp_debug.h +++ b/source/app/task_debug.h @@ -1,5 +1,5 @@ //////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. +///@copyright Copyright (c) 2018, 浼犳帶绉戞妧 All rights reserved. ///------------------------------------------------------------------------- /// @file bsp_drv.h /// @brief bsp @ driver config @@ -11,26 +11,22 @@ ////////////////////////////////////////////////////////////////////////////// -#ifndef _bsp_debug_H -#define _bsp_debug_H +#ifndef _APP_TASK_DEBUG_H +#define _APP_TASK_DEBUG_H -#include "../bsp/bsp_config.h" +#include "../ctask/task.h" +#include "../clib/clib.h" -#include "../tpc/tpc_uart.h" - -#include "../msp/uart0.h" - -#define TS_debug_MAX 6 -typedef struct +typedef struct _s_task_debug { - vU8 add; - void (*p2fun)(U8 *pPara); -}TS_debug_; + TS_task task; +}S_TASK_DEBUG; + +extern S_TASK_DEBUG _s_task_debug; -extern void L3_debug_exp_protocol(TS_Handle_PH1 *p); -//extern void L3_UARTcom0_exp_protocol(void); -extern TS_debug_ volatile ts_debug[TS_debug_MAX]; +extern void L3_task_debug_init(void); +extern void L3_task_debug(S_TASK_DEBUG *s); -#endif // #ifndef _bsp_drv_H +#endif // #ifndef _APP_TASK_ADC_H diff --git a/source/app/task_encrypt.c b/source/app/task_encrypt.c new file mode 100644 index 0000000..51c2e70 --- /dev/null +++ b/source/app/task_encrypt.c @@ -0,0 +1,78 @@ +//////////////////////////////////////////////////////////////////////////// +///@copyright Copyright (c) 2018, 浼犳帶绉戞妧 All rights reserved. +///------------------------------------------------------------------------- +/// @file bsp_drv.c +/// @brief bsp @ driver config +///------------------------------------------------------------------------- +/// @version 1.0 +/// @author CC +/// @date 20180331 +/// @note cc_AS_stc02 +////////////////////////////////////////////////////////////////////////////// + +#include "task_encrypt.h" +#include "../bsp/bsp_config.h" +#include "../msp/uart0.h" +#include "../msp/eeprom.h" +#include "../bsp/chipid.h" + +struct ts_eeprom_enc eep_enc; +struct mcu_encrypt_info enc_info; + +/** + * + * @brief: eeprom鐨凞_EEP_ENC_IN_SECTOR銆丏_EEP_ENC_IN_BLOCK涓彁鍓嶅瓨鏀句簡鍔犲瘑淇℃伅: enc_key, enc_val(enc_key+chipid璁$畻鎵寰) + * @param: void + * @return: 1 is ok , 0 is failed + * + */ +int L3_mcu_id_ok(void) +{ + U8 i = 0; + + //1. 鑾峰彇eeprom涓瓨鍌ㄧ殑enc淇℃伅 + if(L1_eep_read_block(D_EEP_ENC_IN_SECTOR, D_EEP_ENC_IN_BLOCK, D_EEP_ENC_BLOCK_SIZE, (U8*)&eep_enc,NULL) == 1) + { + //L0_uart0_sendstr("e2p read enc failed"); + return 0; + } + //L0_uart0_sendstr("e2p read enc success"); + + //2.鑾峰彇MCU_ID + L0_id_get_rom(enc_info.mcu_id); + //L0_uart0_sendArray(enc_info.mcu_id,MCU_ID_LEN); + + //3.鏍规嵁mcu_id鍜宔nc_key璁$畻enc_val + //enc_key = ((U32)eep_enc.enc_key[0] << 24) | (eep_enc.enc_key[1] << 16) | (eep_enc.enc_key[2] << 8) |(eep_enc.enc_key[3] << 0); + Lc_encrypt_id1((U8*)enc_info.mcu_enc_id, (U8*)enc_info.mcu_id, eep_enc.enc_key, MCU_ID_LEN); + +#if 1 + //4.鍒ゆ柇enc_val鏄惁涓鑷 + for(i=0;i>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Encryption CONFIG +#define MCU_ID_LEN 7 +#define MCU_ID_KEY_LEN 4 +#define EEPROM_ENC_DATA_MAX 64 +#define EEPROM_ENC_FILTER 0xAA +typedef struct ts_eeprom_enc +{ + U8 enc_key[MCU_ID_KEY_LEN]; + U8 enc_val[MCU_ID_LEN]; + //U8 crc[2]; +}EEPROM_ENC; + +typedef struct mcu_encrypt_info +{ + U8 enc_key[MCU_ID_KEY_LEN]; + U8 mcu_id[MCU_ID_LEN]; + U8 mcu_enc_id[MCU_ID_LEN]; +}McuEncryptInfo; + +extern struct ts_eeprom_enc eep_enc; +extern struct mcu_encrypt_info enc_info; +//STEP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<buf; @@ -157,6 +127,7 @@ U16 L3_modbus_slaver_ack(TS_PH4_modbus *pmodbus,TS_PH4_modbus *pModbusAck) } break; } +#endif case MODBUS_OPER_WRITE_M: { U16 i = 0; @@ -205,50 +176,21 @@ void L3_modbus_master_handler(TS_PH4_modbus *pmodbus,MD_SLAVER_INFO *p_slaver_in } } -//MODBUS鍗忚瑙f瀽鍑芥暟 -//瓒呭嚭D_tp_handle_x_len锛屼笉缁х画淇濆瓨鏁版嵁 -void L1_s2b_PH4(struct _tp_handler_x *p) -{ - //p->modbusstmp = D_sys_now; - if(p->head == 0) - { - p->head = 1; - p->max = D_tp_handle_x_len; - p->sp = p->buf; - p->num = 0; - p->sp[p->num++] = p->reg; - } - else - { - if(p->num < p->max) - { - p->sp[p->num++] = p->reg; - } - } -} -#if 0 -//MODBUS鍗忚鍒嗗壊鍑芥暟锛岃鍑芥暟搴旇琚玹imer0涓柇璋冪敤 -//鏈嚱鏁拌礋璐f鏌odbus crc锛屼笉璐熻矗鏍¢獙涓氬姟ID -//鏍¢獙涓氬姟ID锛屽湪鍏蜂綋鐨勪笟鍔″鐞嗗嚱鏁颁腑瀹炵幇 -void L1_modbus_split(struct _tp_handler_x *p) +void L3_task_modbus_handler(TP_Handler_X *ph4) { - if((p->head == 1) && (p->num >= D_s_modbus_min)) + if(ph4->ok) { - crc16_irq(p->crc,p->buf,p->num - 2); //鏍¢獙CRC - if(p->crc[0] == p->buf[p->num-2] && p->crc[1] == p->buf[p->num-1]) + TS_PH4_modbus *ts_modbus = (TS_PH4_modbus *)ph4->buf; + //L0_uart0_sendArray(ph4->buf, 8); + //L0_uart0_sendArray("abcdefgh", 8); + ph4->ok = 0; + if(ts_modbus->slaver == R.p.slaver_id || ts_modbus->slaver == D_UART0_485_SLAVER_ID_BROADCAST) //浠庢満 { - if(p->ok == 0) - { - p->ok = 1; - } + U16 acklen = L3_modbus_slaver_ack(ts_modbus,&s_uart0_ack); + L0_uart0_sendArray((U8*)&s_uart0_ack, acklen); } - p->head = 0; } } -#endif -/****************************************************************************** -** End Of File -******************************************************************************/ diff --git a/source/app/task_modbus.h b/source/app/task_modbus.h new file mode 100644 index 0000000..98b32ef --- /dev/null +++ b/source/app/task_modbus.h @@ -0,0 +1,9 @@ +#ifndef APP_TASK_UART0_H +#define APP_TASK_UART0_H + +#include "../ctask/task.h" +#include "../tpc/modbus.h" + +extern void L3_task_modbus_handler(TP_Handler_X *ph4); + +#endif diff --git a/source/app/task_register.c b/source/app/task_register.c new file mode 100644 index 0000000..ac3b364 --- /dev/null +++ b/source/app/task_register.c @@ -0,0 +1,63 @@ +//////////////////////////////////////////////////////////////////////////// +///@copyright Copyright (c) 2018, 浼犳帶绉戞妧 All rights reserved. +///------------------------------------------------------------------------- +/// @file bsp_drv.c +/// @brief bsp @ driver config +///------------------------------------------------------------------------- +/// @version 1.0 +/// @author CC +/// @date 20180331 +/// @note cc_AS_stc02 +////////////////////////////////////////////////////////////////////////////// + +#include "task_register.h" +#include "../app/app_config.h" +#include "../bsp/bsp_config.h" +#include "../msp/uart0.h" + +//============================================= + +S_TASK_REGVAL_LISTEN s_task_reglisten; + +void L3_task_reglisten_init(void) +{ + L1_task_init(&s_task_reglisten.task); + L3_task_s_go(s_task_reglisten,D_task_init); +} + +//娓呴浂浠诲姟 +#define D_task_WEIGHT_COUNT 0x50 +#define D_task_IAP 0x51 +void L3_task_reglisten_handle(S_TASK_REGVAL_LISTEN *s) +{ + + TTSS_Task_init() + L2_task_go(D_task_WEIGHT_COUNT); + + TTSS_Task_step(D_task_WEIGHT_COUNT) + if(R.zero != 0) + { + R.total_zweight = R.rough_weight; //鐨噸 = 姣涢噸 + R.total_weight = (R.rough_weight > R.total_zweight) ? (R.rough_weight - R.total_zweight) : (0);//鍑閲 + R.zero = 0; + } + L2_task_go(D_task_IAP); //寤舵椂100ms + + + TTSS_Task_step(D_task_IAP) + if(R.status_eep_save != 0) + { + R.status_eep_save = 0; + L3_reg_2_iap();//鍐欏叆IAP + } + L2_task_go_Tdelay(D_task_WEIGHT_COUNT,D_Tdelay_Msec(100)); //寤舵椂100ms + + + TTSS_Task_end(); + +} + + + + + diff --git a/source/app/task_register.h b/source/app/task_register.h new file mode 100644 index 0000000..d675a43 --- /dev/null +++ b/source/app/task_register.h @@ -0,0 +1,32 @@ +//////////////////////////////////////////////////////////////////////////// +///@copyright Copyright (c) 2018, 浼犳帶绉戞妧 All rights reserved. +///------------------------------------------------------------------------- +/// @file bsp_drv.h +/// @brief bsp @ driver config +///------------------------------------------------------------------------- +/// @version 1.0 +/// @author CC +/// @date 20180331 +/// @note cc_AS_stc02 + +////////////////////////////////////////////////////////////////////////////// + +#ifndef _APP_TASK_REG_H +#define _APP_TASK_REG_H + +#include "../ctask/task.h" +#include "../clib/clib.h" + +typedef struct _s_task_reglisten +{ + TS_task task; +}S_TASK_REGVAL_LISTEN; + +extern S_TASK_REGVAL_LISTEN s_task_reglisten; + +extern void L3_task_reglisten_init(void); +extern void L3_task_reglisten_handle(S_TASK_REGVAL_LISTEN *s); + + +#endif // #ifndef _APP_TASK_ADC_H + diff --git a/source/bsp/backu/bsp2019浣庡姛鑰楅噰鏍穕ine鐗堟湰 20200301073727.rar b/source/bsp/backu/bsp2019浣庡姛鑰楅噰鏍穕ine鐗堟湰 20200301073727.rar deleted file mode 100644 index f3236c8..0000000 Binary files a/source/bsp/backu/bsp2019浣庡姛鑰楅噰鏍穕ine鐗堟湰 20200301073727.rar and /dev/null differ diff --git a/source/bsp/backu/bsp_433.c b/source/bsp/backu/bsp_433.c deleted file mode 100644 index 42c4d12..0000000 --- a/source/bsp/backu/bsp_433.c +++ /dev/null @@ -1,34 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file APP_433.c -/// @brief APP_POWER driver app 电源管理 - -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20181010 -/// @note cc_AS_stc01 -////////////////////////////////////////////////////////////////////////////// - - - -/******************************************************************************/ -/***************************** Include Files **********************************/ -/******************************************************************************/ -//#include "app_Gsensor.h" - -#include "bsp_433.h" - - - - -////L0_uart0_sendArray( (unsigned char *)&TS_paer_value,5); - - - - - - - - diff --git a/source/bsp/backu/bsp_433.h b/source/bsp/backu/bsp_433.h deleted file mode 100644 index f224617..0000000 --- a/source/bsp/backu/bsp_433.h +++ /dev/null @@ -1,19 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file APP_433.c -/// @brief APP_POWER driver app 电源管理 - -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20181010 -/// @note cc_AS_stc01 -////////////////////////////////////////////////////////////////////////////// - - -#ifndef _BSP_433_H -#define _BSP_433_H -#include "../msp/uart0.h" -#endif // #ifndef _BSP_433_H - diff --git a/source/bsp/backu/bsp_cam - 鍓湰 (2).c b/source/bsp/backu/bsp_cam - 鍓湰 (2).c deleted file mode 100644 index 83e114f..0000000 --- a/source/bsp/backu/bsp_cam - 鍓湰 (2).c +++ /dev/null @@ -1,574 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file bsp_gc6133.c.c -/// @brief bsp @ driver config -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20180331 -/// @note cc_AS_stc02 -////////////////////////////////////////////////////////////////////////////// - -#include "Bsp_debug.h" -#include "bsp_func.h" -#include "bsp_power.h" -#include "bsp_cam_isr.h" -#include "bsp_cam.h" -#include "../msp/uart0.h" -#include "cw63xx.h" -#include "../clib/Clib.h" -#include "../clib/bit.h" -#include "../msp/time.h" - -TS_P_rf433 TS_paer_value= -{ - 0xaa,///vU8 ha; -// 0xaa,///vU8 hb; - 0xad, - 0x0123, -// 0x00,///U16 paperNum:12; //12bit纸张数据 - ///U8 cameraIndex:2; //摄像头编号 - ///U8 cameraWorking:1; //是否正常工作 - ///U8 reserved: 1; //保留 - 0x56,///U8 cameraBoardPower; //电量 - 0xcc//, 0xaa///vU8 hc; - -}; - -void GC032A_port_init(void) -{ - ///00 准双向口 灌电流20mA 拉电流270-150uS - ///01 推挽输出 20mA 加限流 - ///10 高阻 - ///11 开漏 open-Drain 内部上拉电阻断开 开漏模式既可以度外部状态也可以对外输出高低电平 - - //p3.6 --HSYNC -// BITN_0(P3M1,BITN6);BITN_0(P3M0,BITN6); - ///P3.7 -- VSYNC -// BITN_0(P3M1,BITN7);BITN_0(P3M0,BITN7); - L0_GC032A_standby(); - D_cam_AVDD_on(); - -} -////>>>>>>>>>>>>>>>>>>>>>_s_task_GC032A_>>>>>>>>>>>>>>>>>>>>>> - - - - -struct _s_task_GC032A_ s_task_GC032A; - -void L2_task_GC032A_init(void) -{ - L0_cam_isr_init(); - - L1_task_init(&s_task_GC032A.task); - ///L3_task_s_go(s_task_GC032A,D_task_init); - s_task_GC032A.next_line = D_clear; - s_task_GC032A.run = D_run; - s_task_GC032A.line_get = D_clear; - s_task_GC032A.cal_ok = D_clear; - s_task_GC032A.frames = 0; - s_task_GC032A.vs_ok = D_clear; - s_task_GC032A.line_en = D_ON; - s_task_GC032A.cal_en = D_OFF; -/// D_HSYNCS_open();//BITN_1(INT_CLKO, INT_EX2);//使能INT2中断 -} - -#if 10 - -///// get -void L2_task_GC032A_handle(struct _s_task_GC032A_ *s) -{ - - TTSS_Task_init(); - //PWDN引脚拉低(0 -- 正常工作,1 -- 休眠) - L0_GC032A_standby(); - L0_uart0_uc('2'); - L2_task_go(D_task_GC032A_init_DVDD); - TTSS_Task_step(D_task_GC032A_init_DVDD); - L0_GC032A_work(); - //IOVDD上电,并延时50us以上; - D_cam_DVDD_on(); - // L0_uart0_uc('3'); - L2_task_go(D_task_GC032A_init_AVDD); - //L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_init_AVDD); - //AVDD28上电,并延时0us以上 - D_cam_AVDD_on(); - L0_uart0_uc('4'); - L2_task_go(D_task_GC032A_init_pwdn); - TTSS_Task_step(D_task_GC032A_init_pwdn); - //提供032A系统频率 - /// L0_MCLKO_init(D_ON); - //L0_uart0_uc('n'); - //PWDN引脚拉高,延时,拉低 - L0_GC032A_standby();DL0_WDT();// - L2_task_go(D_task_GC032A_init_pwdn_wait); - L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_init_pwdn_wait); - L0_GC032A_work(); - GC032a_L0_uart0_uc('5');/// Lc_delay_ms(20); - gRccUs03 = 0; - // L0_GC032A_write(GC6133_init_reg_tbl[gRccUs03][0],GC6133_init_reg_tbl[gRccUs03][1]);/// - L2_task_go(D_task_GC032A_write_reg); - //L2_task_go(0); - L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_write_reg); - //设置摄像头参数 大约2s时间 - if(0 != GC6133_init_reg_tbl[gRccUs03][0]) - { - //GC032a_L0_uart0_uc('k'); - L0_GC032A_write(GC6133_init_reg_tbl[gRccUs03][0],GC6133_init_reg_tbl[gRccUs03][1]);/// - gRccUs03 ++; - }else - { - L2_task_go(D_task_GC032A_div); - ///L1_task_Tdelay(D_Tdelay_500ms); - L1_task_Tdelay(D_Tdelay_1s);///重要 这个时间很关键aaaaaa - } - TTSS_Task_step(D_task_GC032A_div); - //L0_GC032A_write(0xfc,0x02); //复位?? - L0_GC032A_write(0xf8,0x03);/// 恢复分频 - L0_GC032A_write(0xfa,D_0xfa);DL0_WDT();// - GC032a_L0_uart0_uc('6'); - L2_task_go(D_task_GC032A_start_time); -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over - -////等待 其他任务的启动后才工作 - TTSS_Task_step(D_task_GC032A_start_time); - D_cam_led_on();D_VSYNCS_open(); - L1_GC032A_sleep(D_wakeup); - GC032a_L0_uart0_uc('7'); -/// s->one_line_ok = D_clear;D_ledb_OFF(); - L2_task_go(D_task_GC032A_led); - TTSS_Task_step(D_task_GC032A_led); - ///vs /```24.8ms````\__________________________..1.16s...____________________________/````````\___________ - ///cam_led ```````````\_________________________________________________________/`````````````````\____ - if(D_ready == s->vs_ok)///为了关灯 - { - s_task_GC032A.vs_ok = D_clear; - D_cam_led_off(); GC032a_L0_uart0_uc('D'); - L2_task_go(D_task_GC032A_wait); - } - TTSS_Task_step(D_task_GC032A_wait);////>>>>>>>>>>>>>>>>>>>>>>>--- - ///捕获到需要的行 - - if(D_ready == s->line_get) - {DL0_WDT();// - s->line_get = D_clear; - /// 1.standby - /// D_cam_led_off(); - if(D_ON == s->line_en) - { - GC032a_L0_uart0_uc(0xfe); - GC032a_L0_uart0_uc(0xfd); - D_send_us(DR_pclk_n); - //D_send_us(s->lines); - L2_task_go(D_task_GC032A_send_line); - }else - { - L2_task_go(D_task_GC032A_cal); - } - - L1_task_Tdelay(D_Tdelay_10ms); - } - TTSS_Task_step(D_task_GC032A_send_line); - if(D_uart0_free()) - { - L0_uart0_sendArraylong(s->buf,0,199); - L2_task_go(D_task_GC032A_send2); - } - TTSS_Task_step(D_task_GC032A_send2); - if(D_uart0_free()) - { - L0_uart0_sendArraylong(s->buf,200,399); - L2_task_go(D_task_GC032A_send3); - } - TTSS_Task_step(D_task_GC032A_send3); - if(D_uart0_free()) - { - L0_uart0_sendArraylong(s->buf,400,599); - L2_task_go(D_task_GC032A_send4); - } - TTSS_Task_step(D_task_GC032A_send4); - if(D_uart0_free()) - { - L0_uart0_sendArraylong(s->buf,600,639); - L2_task_go(D_task_GC032A_send5); - } - TTSS_Task_step(D_task_GC032A_send5); - if(D_uart0_free()) - { - // 'fe','fd','fd','fc' - // GC032a_L0_uart0_uc(0xfd); - // GC032a_L0_uart0_uc(0xfc); - L2_task_go(D_task_GC032A_line1); - //L2_task_go(D_task_GC032A_sleep); - } - - TTSS_Task_step(D_task_GC032A_line1) - for(gRccUs03 = 1;gRccUs03 < 568;gRccUs03 ++) - { - if((s->buf[gRccUs03 - 1] == 0)&& - (s->buf[gRccUs03] == 1))//// _/``上升沿 - { - if(s->buf[gRccUs03 + 1] == 0) - {//_/`\_ 尖峰需要过滤 - - }else - {// ___/````上升沿开始高电平 - s->up_point = gRccUs03; - } - }else if((s->buf[gRccUs03 - 1] == 1)&& - (s->buf[gRccUs03] == 0))//// ``\_ 下降沿 - { - s->down_point = gRccUs03; - - }else - { - - } - } - L2_task_go(D_task_GC032A_line2); - - TTSS_Task_step(D_task_GC032A_line2) - - D_send_us(s->up_point); - D_send_us(s->down_point); - D_send_us(s->down_point - s->up_point); - // DR_pdata_n =0; - // 'fe','fd','fd','fc' - GC032a_L0_uart0_uc(0xfd); - GC032a_L0_uart0_uc(0xfc); - if(D_ON == s->cal_en) - { - L2_task_go(D_task_GC032A_cal); - }else - { - L2_task_go(D_task_GC032A_sleep); - } - TTSS_Task_step(D_task_GC032A_cal) - - - GC032a_L0_uart0_uc('8');//2.1ms - L2_task_go(D_task_GC032A_sleep); - - - TTSS_Task_step(D_task_GC032A_sample); - ///20181007本想调试成 分段的led 不通过vs 关断 但是发现不好调整 - ///采样的时候led打开照亮 - D_cam_led_on();GC032a_L0_uart0_uc('`'); - L2_task_go(D_task_GC032A_sleep); - // L1_task_Tdelay(D_Tdelay_500ms+6); - TTSS_Task_step(D_task_GC032A_sleep); - /// 收到外部命令run后 决定进入睡眠状态 ,低功耗处理 - ////CAL 10MS 433 10MS 总共20ms / 1160ms/vs 取行数消耗10ms - /////1160-10 - 20 = 1130ms - /// GC032a_L0_uart0_uc(0x88); - if(D_run == s->run) - { - GC032a_L0_uart0_uc('9');//2.1ms - L2_task_go(D_task_GC032A_led); - L1_task_Tdelay(D_Tdelay_10ms); - }else - { - D_cam_led_off(); - L1_GC032A_sleep(D_sleep); - L2_task_go(0); - } -///<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - TTSS_Task_end(); -} - -#else - -///// get -void L2_task_GC032A_handle(struct _s_task_GC032A_ *s) -{ - - TTSS_Task_init(); - //PWDN引脚拉低(0 -- 正常工作,1 -- 休眠) - L0_GC032A_standby(); - L0_uart0_uc('2'); - L2_task_go(D_task_GC032A_init_DVDD); - TTSS_Task_step(D_task_GC032A_init_DVDD); - L0_GC032A_work(); - //IOVDD上电,并延时50us以上; - D_cam_DVDD_on(); - // L0_uart0_uc('3'); - L2_task_go(D_task_GC032A_init_AVDD); - //L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_init_AVDD); - //AVDD28上电,并延时0us以上 - D_cam_AVDD_on(); - L0_uart0_uc('4'); - L2_task_go(D_task_GC032A_init_pwdn); - TTSS_Task_step(D_task_GC032A_init_pwdn); - //提供032A系统频率 - /// L0_MCLKO_init(D_ON); - //L0_uart0_uc('n'); - //PWDN引脚拉高,延时,拉低 - L0_GC032A_standby();DL0_WDT();// - L2_task_go(D_task_GC032A_init_pwdn_wait); - L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_init_pwdn_wait); - L0_GC032A_work(); - GC032a_L0_uart0_uc('5');/// Lc_delay_ms(20); - gRccUs03 = 0; - // L0_GC032A_write(GC6133_init_reg_tbl[gRccUs03][0],GC6133_init_reg_tbl[gRccUs03][1]);/// - L2_task_go(D_task_GC032A_write_reg); - //L2_task_go(0); - L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_write_reg); - //设置摄像头参数 大约2s时间 - if(0 != GC6133_init_reg_tbl[gRccUs03][0]) - { - //GC032a_L0_uart0_uc('k'); - L0_GC032A_write(GC6133_init_reg_tbl[gRccUs03][0],GC6133_init_reg_tbl[gRccUs03][1]);/// - gRccUs03 ++; - }else - { - L2_task_go(D_task_GC032A_div); - ///L1_task_Tdelay(D_Tdelay_500ms); - L1_task_Tdelay(D_Tdelay_1s);///重要 这个时间很关键aaaaaa - } - TTSS_Task_step(D_task_GC032A_div); - //L0_GC032A_write(0xfc,0x02); //复位?? - L0_GC032A_write(0xf8,0x03);/// 恢复分频 - L0_GC032A_write(0xfa,D_0xfa);DL0_WDT();// - GC032a_L0_uart0_uc('6'); - L2_task_go(D_task_GC032A_start_time); -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over - -////等待 其他任务的启动后才工作 - TTSS_Task_step(D_task_GC032A_start_time); - D_cam_led_on();D_VSYNCS_open(); - L1_GC032A_sleep(D_wakeup); - GC032a_L0_uart0_uc('7'); -/// s->one_line_ok = D_clear;D_ledb_OFF(); - L2_task_go(D_task_GC032A_led); - TTSS_Task_step(D_task_GC032A_led); - ///vs /```24.8ms````\__________________________..1.16s...____________________________/````````\___________ - ///cam_led ```````````\_________________________________________________________/`````````````````\____ - if(D_ready == s->vs_ok)///为了关灯 - { - s_task_GC032A.vs_ok = D_clear; - D_cam_led_off(); GC032a_L0_uart0_uc('_'); - L2_task_go(D_task_GC032A_wait); - } - TTSS_Task_step(D_task_GC032A_wait);////>>>>>>>>>>>>>>>>>>>>>>>--- - ///捕获到需要的行 - if(1 == s->line_get) - {DL0_WDT();// - s->line_get = 0; - L2_task_go(D_task_GC032A_cal);//// 单行计算 - } - TTSS_Task_step(D_task_GC032A_cal); - ///计算一个 line的数据 - ///D_txd4_wakeup(); - ///GC032a_L0_uart0_uc(0xd); GC032a_L0_uart0_uc(0xa);// - s->buf[D_pclk_per_hs + 1] =s->buf[30]; - ///GC032a_L0_uart0_uchex(s->buf[D_pclk_per_hs + 1]); - gRccUs04 = 0; - for(gRccUs03 = 0;gRccUs03 < D_pclk_per_hs_2;gRccUs03 ++) - { //s->buf[gRccUs03] = 0x10; - //debug 开关 显示当前收到的数据 - //L0_uart0_uc(s->buf[gRccUs03]); - if(s->buf[gRccUs03] >= 0x10) - { - s->buf[gRccUs03] -= 0x10; - } - s->buf[gRccUs03] >>= 1; - gRccUs04 += s->buf[gRccUs03]; - } - gRccUs04 >>= 2;//gRccUs04 >>= 4; - TS_paer_value.r123.paperNum = gRccUs04; - ///GC032a_L0_uart0_uchex((unsigned char)(gRccUs04>>8)); - s_task_GC032A.cal_ok = D_ready; - - L2_task_go(D_task_GC032A_sample);/// 发送完成延时后开始采样, - L1_task_Tdelay(D_Tdelay_300ms); //700=1a 600=1e 500 21 400 25 300 26 - - TTSS_Task_step(D_task_GC032A_sample); - ///20181007本想调试成 分段的led 不通过vs 关断 但是发现不好调整 - ///采样的时候led打开照亮 - D_cam_led_on();GC032a_L0_uart0_uc('`'); - L2_task_go(D_task_GC032A_sleep); - // L1_task_Tdelay(D_Tdelay_500ms+6); - TTSS_Task_step(D_task_GC032A_sleep); - /// 收到外部命令run后 决定进入睡眠状态 ,低功耗处理 - ////CAL 10MS 433 10MS 总共20ms / 1160ms/vs 取行数消耗10ms - /////1160-10 - 20 = 1130ms - /// GC032a_L0_uart0_uc(0x88); - if(D_run == s->run) - { - GC032a_L0_uart0_uc('r');//2.1ms - L2_task_go(D_task_GC032A_led); - }else - { - D_cam_led_off(); - L1_GC032A_sleep(D_sleep); - L2_task_go(0); - } -///<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - TTSS_Task_end(); -} - - - - -#endif - -void L1_GC032A_sleep(unsigned char onf) -{///FE 15 Fd 33 44//standby -///FE 05 Fd 33 44//wakeup - if(D_sleep == onf) - { - GC032a_L0_uart0_uc('L'); - /// 进入standby: - L0_GC032A_write(0xfc,0x03); L0_GC032A_write(0xf7,0x00); L0_GC032A_write(0xf9,0xcf); L0_GC032A_write(0xf3,0x00); - Lc_delay_nop(30); - Lc_delay_nop(30); - /// D_cam_AVDD_off(); - // D_cam_led_off(); - }else - { - GC032a_L0_uart0_uc('X'); - /// 退出standby: - L0_GC032A_write(0xfc,0x02); L0_GC032A_write(0xf7,0x01); L0_GC032A_write(0xf9,0xce); L0_GC032A_write(0xf3,0xff); - /// D_cam_led_on(); - } -} - -#if 10 -void L3_GC032A_fun(U8 *pPara) -{ - - -} -#else - -//// fe 01 reg data 0cx -/// Ac 01 02 03 ocr ---bsp_debug.c -/// p.cmd p.R2 p.R3 p.ocr -///Ac 00 03 01 00/// ACC_X[13:6] - -void L3_GC032A_fun(U8 *pPara) -{ - U8 i,val[2]; -// unsigned short j; - TS_P_debug *p = pPara; - switch(p->cmd) - { - - case 0x01: - ///AE 01 FE 33 44 // L0_GC032A_read(0xFE,&i,1); 读取当前页面 - ///AE 01 F0 33 44 // L0_GC032A_read(0xF0,&i,1); 读取id i= 0x23 - L0_GC032A_read(p->R2,&i,1); - L0_uart0_uc(i); - break; - //修改摄像头配置参数 - case 0x02: - /// fe 02 r2 r3 xx 设置寄存器(r2) = r3 - /// sysreg FE 02 FE 01 44 //设置当前页面01 - L0_GC032A_write(p->R2,p->R3); - L0_uart0_uc(p->R2); - L0_uart0_uc(p->R3); - break; - //启动摄像头进行拍照; - case 0x03:/// sysreg FE 03 03 04 05 //设置是否发送一line数据(数据分为一帧=640Line = 640line*480pclk ) - ///AE 03 01 33 44 //s_task_GC032A.line_onf = 01 - ///AE 03 00 33 44 //s_task_GC032A.line_onf = 00 - s_task_GC032A.line_onf = p->R2; - L0_uart0_uc(0x30|s_task_GC032A.line_onf); - break; - case 0x05: - ///AE 05 01 33 44 //进入 standby - ///AE 05 00 33 44 //退出 standby - L1_GC032A_sleep(p->R2); - L0_uart0_uc(0x30|s_task_GC032A.line_onf); - break; - case 6:///AE 06 22 33 44 - D_cam_led_off(); - break; - case 7:///AE 07 22 33 44 - D_cam_led_on(); - - break; - /******************* - case 0x00: - L0_GC032A_read(p->R2,val,p->R3); - L0_uart0_uc(p->cmd); - L0_uart0_uc(p->R2); - L0_uart0_uc(p->R3); - L0_uart0_uc('G'); - for(i = 0;i < p->R3;i++) - { - L0_uart0_uc(val[i]); - } - break; - //读取摄像头配置参数 - case 0x35: - L0_GC032A_standby();// led 17.1-16.9ma standby 6.2ma - L0_uart0_uc(0x31); - break; - case 0x36: - /// 退出standby: - L0_GC032A_work(); - L0_uart0_uc(0x30); - break; - - - ****************************/ - - default: - break; - }; -} - -#endif - - - -#if 0 -FE 02 88 15 10 13 11 15 11 16 12 14 11 15 12 16 12 16 14 17 13 17 13 16 13 16 12 16 13 16 12 18 -14 15 12 15 13 15 12 16 14 15 13 15 12 15 13 16 14 18 14 17 13 16 10 16 15 1A 15 22 2D 3A 3F 47 -41 53 5E 63 65 69 6C 6F 71 7A 72 73 75 7A 7B 7E 7D 82 85 8B 8F 90 8F 93 96 9A 9D 9A 97 98 96 99 -9A 9B 9A 9C 9E 9F 9F 9D 9A 9A 99 9C 9B 9B 9A 9A 9B 9C 9D 9F 9F A0 A1 A2 A3 A2 A2 A3 A1 A3 A4 A4 -A4 A4 A3 A3 A2 A2 A3 A5 A6 A7 A8 A7 A6 A6 A5 A6 A6 A8 AA AA AA AA AA AB AB AB AC AC AB AC AC AD -AF AE AD AD AC AC AB AC AC AD AD AE AE AE AF AD AE AE AD AE AE AE AE AE AF AF AF AF AF AF B0 B1 -B1 B1 B2 B1 B1 B1 B1 B1 B1 B2 B2 B2 B3 B2 B2 B2 B3 B3 B3 B4 B4 B4 B4 B4 B4 B4 B4 B4 B4 B4 B4 B5 -B4 B5 B6 B5 B5 B4 B4 B4 B3 B4 B5 B5 B5 B5 B5 B5 B5 B5 B5 B5 B5 B5 B6 B6 B5 B6 B6 B6 B6 B6 B6 B6 -B6 B6 B6 B6 B6 B6 B6 B6 B7 B6 B6 B7 B6 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 -B8 B7 B7 B8 B8 B7 B8 B8 B7 B8 B9 B8 B8 B8 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B8 B7 B7 B8 B8 -B8 B8 B8 B8 B8 B8 B7 B7 B7 B7 B8 B8 B9 B8 B9 B8 B8 B8 B8 B7 B7 B7 B7 B7 B8 B8 B8 B8 B8 B8 B8 B8 -B9 B8 B8 B8 B8 B9 BA B8 B8 B8 B7 B8 B8 B8 B8 B8 B8 B8 B9 B8 B7 B7 B7 B7 B7 B7 B6 B6 B7 B7 B7 B7 -B7 B7 B7 B8 B8 B8 B8 B8 B8 B8 B8 B8 B9 B9 B9 B8 B9 B8 B8 B9 BA B9 B8 B8 B8 B8 B9 B8 B9 B8 B8 B8 -B8 B8 B9 B9 B8 B9 B9 B9 B9 B8 B8 B8 B8 B8 B8 B8 B8 B8 B8 B8 B8 B9 B9 B8 B9 B9 B9 B9 B9 B9 BA B9 -B9 B9 B9 B9 B8 B9 B9 B9 B9 B9 B9 B9 B8 B9 B9 B9 B9 B9 B9 B9 B9 B9 BB B9 B9 B9 B9 B9 B9 B9 BA BA -BB B9 B8 B8 B8 B8 B8 B9 B9 BA BA B9 BA B9 B9 B9 B9 B9 B8 B8 B8 B8 B9 B9 B9 B9 BA BA BB B9 B9 B9 -B9 B9 B9 B9 B9 B9 B9 B9 B9 B9 B9 B9 BA B9 B9 B9 B9 BA BA BB BB BA BB BA B9 B9 B9 B9 B9 B9 B9 BA -BB BA BA BA BA B9 B8 B8 B8 B8 B8 B9 B9 BA BB BB BB BA BA B9 B9 B9 B9 B9 BA fd fc - - - -#endif - - - - - - - - - - - - - - diff --git a/source/bsp/backu/bsp_cam - 鍓湰.c b/source/bsp/backu/bsp_cam - 鍓湰.c deleted file mode 100644 index e9c132c..0000000 --- a/source/bsp/backu/bsp_cam - 鍓湰.c +++ /dev/null @@ -1,574 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file bsp_gc6133.c.c -/// @brief bsp @ driver config -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20180331 -/// @note cc_AS_stc02 -////////////////////////////////////////////////////////////////////////////// - -#include "Bsp_debug.h" -#include "bsp_func.h" -#include "bsp_power.h" -#include "bsp_cam_isr.h" -#include "bsp_cam.h" -#include "../msp/uart0.h" -#include "cw63xx.h" -#include "../clib/Clib.h" -#include "../clib/bit.h" -#include "../msp/time.h" - -TS_P_rf433 TS_paer_value= -{ - 0xaa,///vU8 ha; -// 0xaa,///vU8 hb; - 0xad, - 0x0123, -// 0x00,///U16 paperNum:12; //12bit纸张数据 - ///U8 cameraIndex:2; //摄像头编号 - ///U8 cameraWorking:1; //是否正常工作 - ///U8 reserved: 1; //保留 - 0x56,///U8 cameraBoardPower; //电量 - 0xcc//, 0xaa///vU8 hc; - -}; - -void GC032A_port_init(void) -{ - ///00 准双向口 灌电流20mA 拉电流270-150uS - ///01 推挽输出 20mA 加限流 - ///10 高阻 - ///11 开漏 open-Drain 内部上拉电阻断开 开漏模式既可以度外部状态也可以对外输出高低电平 - - //p3.6 --HSYNC -// BITN_0(P3M1,BITN6);BITN_0(P3M0,BITN6); - ///P3.7 -- VSYNC -// BITN_0(P3M1,BITN7);BITN_0(P3M0,BITN7); - L0_GC032A_standby(); - D_cam_AVDD_on(); - -} -////>>>>>>>>>>>>>>>>>>>>>_s_task_GC032A_>>>>>>>>>>>>>>>>>>>>>> - - - - -struct _s_task_GC032A_ s_task_GC032A; - -void L2_task_GC032A_init(void) -{ - L0_cam_isr_init(); - - L1_task_init(&s_task_GC032A.task); - ///L3_task_s_go(s_task_GC032A,D_task_init); - s_task_GC032A.next_line = D_clear; - s_task_GC032A.run = D_run; - s_task_GC032A.line_get = D_clear; - s_task_GC032A.cal_ok = D_clear; - s_task_GC032A.frames = 0; - s_task_GC032A.vs_ok = D_clear; - s_task_GC032A.line_en = D_ON; - s_task_GC032A.cal_en = D_OFF; -/// D_HSYNCS_open();//BITN_1(INT_CLKO, INT_EX2);//使能INT2中断 -} - -#if 10 - -///// get -void L2_task_GC032A_handle(struct _s_task_GC032A_ *s) -{ - - TTSS_Task_init(); - //PWDN引脚拉低(0 -- 正常工作,1 -- 休眠) - L0_GC032A_standby(); - L0_uart0_uc('2'); - L2_task_go(D_task_GC032A_init_DVDD); - TTSS_Task_step(D_task_GC032A_init_DVDD); - L0_GC032A_work(); - //IOVDD上电,并延时50us以上; - D_cam_DVDD_on(); - // L0_uart0_uc('3'); - L2_task_go(D_task_GC032A_init_AVDD); - //L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_init_AVDD); - //AVDD28上电,并延时0us以上 - D_cam_AVDD_on(); - L0_uart0_uc('4'); - L2_task_go(D_task_GC032A_init_pwdn); - TTSS_Task_step(D_task_GC032A_init_pwdn); - //提供032A系统频率 - /// L0_MCLKO_init(D_ON); - //L0_uart0_uc('n'); - //PWDN引脚拉高,延时,拉低 - L0_GC032A_standby();DL0_WDT();// - L2_task_go(D_task_GC032A_init_pwdn_wait); - L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_init_pwdn_wait); - L0_GC032A_work(); - GC032a_L0_uart0_uc('5');/// Lc_delay_ms(20); - gRccUs03 = 0; - // L0_GC032A_write(GC6133_init_reg_tbl[gRccUs03][0],GC6133_init_reg_tbl[gRccUs03][1]);/// - L2_task_go(D_task_GC032A_write_reg); - //L2_task_go(0); - L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_write_reg); - //设置摄像头参数 大约2s时间 - if(0 != GC6133_init_reg_tbl[gRccUs03][0]) - { - //GC032a_L0_uart0_uc('k'); - L0_GC032A_write(GC6133_init_reg_tbl[gRccUs03][0],GC6133_init_reg_tbl[gRccUs03][1]);/// - gRccUs03 ++; - }else - { - L2_task_go(D_task_GC032A_div); - ///L1_task_Tdelay(D_Tdelay_500ms); - L1_task_Tdelay(D_Tdelay_1s);///重要 这个时间很关键aaaaaa - } - TTSS_Task_step(D_task_GC032A_div); - //L0_GC032A_write(0xfc,0x02); //复位?? - L0_GC032A_write(0xf8,0x03);/// 恢复分频 - L0_GC032A_write(0xfa,D_0xfa);DL0_WDT();// - GC032a_L0_uart0_uc('6'); - L2_task_go(D_task_GC032A_start_time); -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over - -////等待 其他任务的启动后才工作 - TTSS_Task_step(D_task_GC032A_start_time); - D_cam_led_on();D_VSYNCS_open(); - L1_GC032A_sleep(D_wakeup); - GC032a_L0_uart0_uc('7'); -/// s->one_line_ok = D_clear;D_ledb_OFF(); - L2_task_go(D_task_GC032A_led); - TTSS_Task_step(D_task_GC032A_led); - ///vs /```24.8ms````\__________________________..1.16s...____________________________/````````\___________ - ///cam_led ```````````\_________________________________________________________/`````````````````\____ - if(D_ready == s->vs_ok)///为了关灯 - { - s_task_GC032A.vs_ok = D_clear; - D_cam_led_off(); GC032a_L0_uart0_uc('D'); - L2_task_go(D_task_GC032A_wait); - } - TTSS_Task_step(D_task_GC032A_wait);////>>>>>>>>>>>>>>>>>>>>>>>--- - ///捕获到需要的行 - - if(D_ready == s->line_get) - {DL0_WDT();// - s->line_get = D_clear; - /// 1.standby - /// D_cam_led_off(); - if(D_ON == s->line_en) - { - GC032a_L0_uart0_uc(0xfe); - GC032a_L0_uart0_uc(0xfd); - D_send_us(DR_pclk_n); - //D_send_us(s->lines); - L2_task_go(D_task_GC032A_send_line); - }else - { - L2_task_go(D_task_GC032A_cal); - } - - L1_task_Tdelay(D_Tdelay_10ms); - } - TTSS_Task_step(D_task_GC032A_send_line); - if(D_uart0_free()) - { - L0_uart0_sendArraylong(s->buf,0,199); - L2_task_go(D_task_GC032A_send2); - } - TTSS_Task_step(D_task_GC032A_send2); - if(D_uart0_free()) - { - L0_uart0_sendArraylong(s->buf,200,399); - L2_task_go(D_task_GC032A_send3); - } - TTSS_Task_step(D_task_GC032A_send3); - if(D_uart0_free()) - { - L0_uart0_sendArraylong(s->buf,400,509); - L2_task_go(D_task_GC032A_send5); - } - TTSS_Task_step(D_task_GC032A_send4); - if(D_uart0_free()) - { - L0_uart0_sendArraylong(s->buf,600,639); - L2_task_go(D_task_GC032A_send5); - } - TTSS_Task_step(D_task_GC032A_send5); - if(D_uart0_free()) - { - // 'fe','fd','fd','fc' - // GC032a_L0_uart0_uc(0xfd); - // GC032a_L0_uart0_uc(0xfc); - L2_task_go(D_task_GC032A_line1); - //L2_task_go(D_task_GC032A_sleep); - } - - TTSS_Task_step(D_task_GC032A_line1) - for(gRccUs03 = 1;gRccUs03 < 568;gRccUs03 ++) - { - if((s->buf[gRccUs03 - 1] == 0)&& - (s->buf[gRccUs03] == 1))//// _/``上升沿 - { - if(s->buf[gRccUs03 + 1] == 0) - {//_/`\_ 尖峰需要过滤 - - }else - {// ___/````上升沿开始高电平 - s->up_point = gRccUs03; - } - }else if((s->buf[gRccUs03 - 1] == 1)&& - (s->buf[gRccUs03] == 0))//// ``\_ 下降沿 - { - s->down_point = gRccUs03; - - }else - { - - } - } - L2_task_go(D_task_GC032A_line2); - - TTSS_Task_step(D_task_GC032A_line2) - - D_send_us(s->up_point); - D_send_us(s->down_point); - D_send_us(s->down_point - s->up_point); - // DR_pdata_n =0; - // 'fe','fd','fd','fc' - GC032a_L0_uart0_uc(0xfd); - GC032a_L0_uart0_uc(0xfc); - if(D_ON == s->cal_en) - { - L2_task_go(D_task_GC032A_cal); - }else - { - L2_task_go(D_task_GC032A_sleep); - } - TTSS_Task_step(D_task_GC032A_cal) - - - GC032a_L0_uart0_uc('8');//2.1ms - L2_task_go(D_task_GC032A_sleep); - - - TTSS_Task_step(D_task_GC032A_sample); - ///20181007本想调试成 分段的led 不通过vs 关断 但是发现不好调整 - ///采样的时候led打开照亮 - D_cam_led_on();GC032a_L0_uart0_uc('`'); - L2_task_go(D_task_GC032A_sleep); - // L1_task_Tdelay(D_Tdelay_500ms+6); - TTSS_Task_step(D_task_GC032A_sleep); - /// 收到外部命令run后 决定进入睡眠状态 ,低功耗处理 - ////CAL 10MS 433 10MS 总共20ms / 1160ms/vs 取行数消耗10ms - /////1160-10 - 20 = 1130ms - /// GC032a_L0_uart0_uc(0x88); - if(D_run == s->run) - { - GC032a_L0_uart0_uc('9');//2.1ms - L2_task_go(D_task_GC032A_led); - L1_task_Tdelay(D_Tdelay_10ms); - }else - { - D_cam_led_off(); - L1_GC032A_sleep(D_sleep); - L2_task_go(0); - } -///<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - TTSS_Task_end(); -} - -#else - -///// get -void L2_task_GC032A_handle(struct _s_task_GC032A_ *s) -{ - - TTSS_Task_init(); - //PWDN引脚拉低(0 -- 正常工作,1 -- 休眠) - L0_GC032A_standby(); - L0_uart0_uc('2'); - L2_task_go(D_task_GC032A_init_DVDD); - TTSS_Task_step(D_task_GC032A_init_DVDD); - L0_GC032A_work(); - //IOVDD上电,并延时50us以上; - D_cam_DVDD_on(); - // L0_uart0_uc('3'); - L2_task_go(D_task_GC032A_init_AVDD); - //L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_init_AVDD); - //AVDD28上电,并延时0us以上 - D_cam_AVDD_on(); - L0_uart0_uc('4'); - L2_task_go(D_task_GC032A_init_pwdn); - TTSS_Task_step(D_task_GC032A_init_pwdn); - //提供032A系统频率 - /// L0_MCLKO_init(D_ON); - //L0_uart0_uc('n'); - //PWDN引脚拉高,延时,拉低 - L0_GC032A_standby();DL0_WDT();// - L2_task_go(D_task_GC032A_init_pwdn_wait); - L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_init_pwdn_wait); - L0_GC032A_work(); - GC032a_L0_uart0_uc('5');/// Lc_delay_ms(20); - gRccUs03 = 0; - // L0_GC032A_write(GC6133_init_reg_tbl[gRccUs03][0],GC6133_init_reg_tbl[gRccUs03][1]);/// - L2_task_go(D_task_GC032A_write_reg); - //L2_task_go(0); - L1_task_Tdelay(D_Tdelay_10ms); - TTSS_Task_step(D_task_GC032A_write_reg); - //设置摄像头参数 大约2s时间 - if(0 != GC6133_init_reg_tbl[gRccUs03][0]) - { - //GC032a_L0_uart0_uc('k'); - L0_GC032A_write(GC6133_init_reg_tbl[gRccUs03][0],GC6133_init_reg_tbl[gRccUs03][1]);/// - gRccUs03 ++; - }else - { - L2_task_go(D_task_GC032A_div); - ///L1_task_Tdelay(D_Tdelay_500ms); - L1_task_Tdelay(D_Tdelay_1s);///重要 这个时间很关键aaaaaa - } - TTSS_Task_step(D_task_GC032A_div); - //L0_GC032A_write(0xfc,0x02); //复位?? - L0_GC032A_write(0xf8,0x03);/// 恢复分频 - L0_GC032A_write(0xfa,D_0xfa);DL0_WDT();// - GC032a_L0_uart0_uc('6'); - L2_task_go(D_task_GC032A_start_time); -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over - -////等待 其他任务的启动后才工作 - TTSS_Task_step(D_task_GC032A_start_time); - D_cam_led_on();D_VSYNCS_open(); - L1_GC032A_sleep(D_wakeup); - GC032a_L0_uart0_uc('7'); -/// s->one_line_ok = D_clear;D_ledb_OFF(); - L2_task_go(D_task_GC032A_led); - TTSS_Task_step(D_task_GC032A_led); - ///vs /```24.8ms````\__________________________..1.16s...____________________________/````````\___________ - ///cam_led ```````````\_________________________________________________________/`````````````````\____ - if(D_ready == s->vs_ok)///为了关灯 - { - s_task_GC032A.vs_ok = D_clear; - D_cam_led_off(); GC032a_L0_uart0_uc('_'); - L2_task_go(D_task_GC032A_wait); - } - TTSS_Task_step(D_task_GC032A_wait);////>>>>>>>>>>>>>>>>>>>>>>>--- - ///捕获到需要的行 - if(1 == s->line_get) - {DL0_WDT();// - s->line_get = 0; - L2_task_go(D_task_GC032A_cal);//// 单行计算 - } - TTSS_Task_step(D_task_GC032A_cal); - ///计算一个 line的数据 - ///D_txd4_wakeup(); - ///GC032a_L0_uart0_uc(0xd); GC032a_L0_uart0_uc(0xa);// - s->buf[D_pclk_per_hs + 1] =s->buf[30]; - ///GC032a_L0_uart0_uchex(s->buf[D_pclk_per_hs + 1]); - gRccUs04 = 0; - for(gRccUs03 = 0;gRccUs03 < D_pclk_per_hs_2;gRccUs03 ++) - { //s->buf[gRccUs03] = 0x10; - //debug 开关 显示当前收到的数据 - //L0_uart0_uc(s->buf[gRccUs03]); - if(s->buf[gRccUs03] >= 0x10) - { - s->buf[gRccUs03] -= 0x10; - } - s->buf[gRccUs03] >>= 1; - gRccUs04 += s->buf[gRccUs03]; - } - gRccUs04 >>= 2;//gRccUs04 >>= 4; - TS_paer_value.r123.paperNum = gRccUs04; - ///GC032a_L0_uart0_uchex((unsigned char)(gRccUs04>>8)); - s_task_GC032A.cal_ok = D_ready; - - L2_task_go(D_task_GC032A_sample);/// 发送完成延时后开始采样, - L1_task_Tdelay(D_Tdelay_300ms); //700=1a 600=1e 500 21 400 25 300 26 - - TTSS_Task_step(D_task_GC032A_sample); - ///20181007本想调试成 分段的led 不通过vs 关断 但是发现不好调整 - ///采样的时候led打开照亮 - D_cam_led_on();GC032a_L0_uart0_uc('`'); - L2_task_go(D_task_GC032A_sleep); - // L1_task_Tdelay(D_Tdelay_500ms+6); - TTSS_Task_step(D_task_GC032A_sleep); - /// 收到外部命令run后 决定进入睡眠状态 ,低功耗处理 - ////CAL 10MS 433 10MS 总共20ms / 1160ms/vs 取行数消耗10ms - /////1160-10 - 20 = 1130ms - /// GC032a_L0_uart0_uc(0x88); - if(D_run == s->run) - { - GC032a_L0_uart0_uc('r');//2.1ms - L2_task_go(D_task_GC032A_led); - }else - { - D_cam_led_off(); - L1_GC032A_sleep(D_sleep); - L2_task_go(0); - } -///<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - TTSS_Task_end(); -} - - - - -#endif - -void L1_GC032A_sleep(unsigned char onf) -{///FE 15 Fd 33 44//standby -///FE 05 Fd 33 44//wakeup - if(D_sleep == onf) - { - GC032a_L0_uart0_uc('L'); - /// 进入standby: - L0_GC032A_write(0xfc,0x03); L0_GC032A_write(0xf7,0x00); L0_GC032A_write(0xf9,0xcf); L0_GC032A_write(0xf3,0x00); - Lc_delay_nop(30); - Lc_delay_nop(30); - /// D_cam_AVDD_off(); - // D_cam_led_off(); - }else - { - GC032a_L0_uart0_uc('X'); - /// 退出standby: - L0_GC032A_write(0xfc,0x02); L0_GC032A_write(0xf7,0x01); L0_GC032A_write(0xf9,0xce); L0_GC032A_write(0xf3,0xff); - /// D_cam_led_on(); - } -} - -#if 10 -void L3_GC032A_fun(U8 *pPara) -{ - - -} -#else - -//// fe 01 reg data 0cx -/// Ac 01 02 03 ocr ---bsp_debug.c -/// p.cmd p.R2 p.R3 p.ocr -///Ac 00 03 01 00/// ACC_X[13:6] - -void L3_GC032A_fun(U8 *pPara) -{ - U8 i,val[2]; -// unsigned short j; - TS_P_debug *p = pPara; - switch(p->cmd) - { - - case 0x01: - ///AE 01 FE 33 44 // L0_GC032A_read(0xFE,&i,1); 读取当前页面 - ///AE 01 F0 33 44 // L0_GC032A_read(0xF0,&i,1); 读取id i= 0x23 - L0_GC032A_read(p->R2,&i,1); - L0_uart0_uc(i); - break; - //修改摄像头配置参数 - case 0x02: - /// fe 02 r2 r3 xx 设置寄存器(r2) = r3 - /// sysreg FE 02 FE 01 44 //设置当前页面01 - L0_GC032A_write(p->R2,p->R3); - L0_uart0_uc(p->R2); - L0_uart0_uc(p->R3); - break; - //启动摄像头进行拍照; - case 0x03:/// sysreg FE 03 03 04 05 //设置是否发送一line数据(数据分为一帧=640Line = 640line*480pclk ) - ///AE 03 01 33 44 //s_task_GC032A.line_onf = 01 - ///AE 03 00 33 44 //s_task_GC032A.line_onf = 00 - s_task_GC032A.line_onf = p->R2; - L0_uart0_uc(0x30|s_task_GC032A.line_onf); - break; - case 0x05: - ///AE 05 01 33 44 //进入 standby - ///AE 05 00 33 44 //退出 standby - L1_GC032A_sleep(p->R2); - L0_uart0_uc(0x30|s_task_GC032A.line_onf); - break; - case 6:///AE 06 22 33 44 - D_cam_led_off(); - break; - case 7:///AE 07 22 33 44 - D_cam_led_on(); - - break; - /******************* - case 0x00: - L0_GC032A_read(p->R2,val,p->R3); - L0_uart0_uc(p->cmd); - L0_uart0_uc(p->R2); - L0_uart0_uc(p->R3); - L0_uart0_uc('G'); - for(i = 0;i < p->R3;i++) - { - L0_uart0_uc(val[i]); - } - break; - //读取摄像头配置参数 - case 0x35: - L0_GC032A_standby();// led 17.1-16.9ma standby 6.2ma - L0_uart0_uc(0x31); - break; - case 0x36: - /// 退出standby: - L0_GC032A_work(); - L0_uart0_uc(0x30); - break; - - - ****************************/ - - default: - break; - }; -} - -#endif - - - -#if 0 -FE 02 88 15 10 13 11 15 11 16 12 14 11 15 12 16 12 16 14 17 13 17 13 16 13 16 12 16 13 16 12 18 -14 15 12 15 13 15 12 16 14 15 13 15 12 15 13 16 14 18 14 17 13 16 10 16 15 1A 15 22 2D 3A 3F 47 -41 53 5E 63 65 69 6C 6F 71 7A 72 73 75 7A 7B 7E 7D 82 85 8B 8F 90 8F 93 96 9A 9D 9A 97 98 96 99 -9A 9B 9A 9C 9E 9F 9F 9D 9A 9A 99 9C 9B 9B 9A 9A 9B 9C 9D 9F 9F A0 A1 A2 A3 A2 A2 A3 A1 A3 A4 A4 -A4 A4 A3 A3 A2 A2 A3 A5 A6 A7 A8 A7 A6 A6 A5 A6 A6 A8 AA AA AA AA AA AB AB AB AC AC AB AC AC AD -AF AE AD AD AC AC AB AC AC AD AD AE AE AE AF AD AE AE AD AE AE AE AE AE AF AF AF AF AF AF B0 B1 -B1 B1 B2 B1 B1 B1 B1 B1 B1 B2 B2 B2 B3 B2 B2 B2 B3 B3 B3 B4 B4 B4 B4 B4 B4 B4 B4 B4 B4 B4 B4 B5 -B4 B5 B6 B5 B5 B4 B4 B4 B3 B4 B5 B5 B5 B5 B5 B5 B5 B5 B5 B5 B5 B5 B6 B6 B5 B6 B6 B6 B6 B6 B6 B6 -B6 B6 B6 B6 B6 B6 B6 B6 B7 B6 B6 B7 B6 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 -B8 B7 B7 B8 B8 B7 B8 B8 B7 B8 B9 B8 B8 B8 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B7 B8 B7 B7 B8 B8 -B8 B8 B8 B8 B8 B8 B7 B7 B7 B7 B8 B8 B9 B8 B9 B8 B8 B8 B8 B7 B7 B7 B7 B7 B8 B8 B8 B8 B8 B8 B8 B8 -B9 B8 B8 B8 B8 B9 BA B8 B8 B8 B7 B8 B8 B8 B8 B8 B8 B8 B9 B8 B7 B7 B7 B7 B7 B7 B6 B6 B7 B7 B7 B7 -B7 B7 B7 B8 B8 B8 B8 B8 B8 B8 B8 B8 B9 B9 B9 B8 B9 B8 B8 B9 BA B9 B8 B8 B8 B8 B9 B8 B9 B8 B8 B8 -B8 B8 B9 B9 B8 B9 B9 B9 B9 B8 B8 B8 B8 B8 B8 B8 B8 B8 B8 B8 B8 B9 B9 B8 B9 B9 B9 B9 B9 B9 BA B9 -B9 B9 B9 B9 B8 B9 B9 B9 B9 B9 B9 B9 B8 B9 B9 B9 B9 B9 B9 B9 B9 B9 BB B9 B9 B9 B9 B9 B9 B9 BA BA -BB B9 B8 B8 B8 B8 B8 B9 B9 BA BA B9 BA B9 B9 B9 B9 B9 B8 B8 B8 B8 B9 B9 B9 B9 BA BA BB B9 B9 B9 -B9 B9 B9 B9 B9 B9 B9 B9 B9 B9 B9 B9 BA B9 B9 B9 B9 BA BA BB BB BA BB BA B9 B9 B9 B9 B9 B9 B9 BA -BB BA BA BA BA B9 B8 B8 B8 B8 B8 B9 B9 BA BB BB BB BA BA B9 B9 B9 B9 B9 BA fd fc - - - -#endif - - - - - - - - - - - - - - diff --git a/source/bsp/backu/bsp_cam.c b/source/bsp/backu/bsp_cam.c deleted file mode 100644 index 00e44f6..0000000 --- a/source/bsp/backu/bsp_cam.c +++ /dev/null @@ -1,706 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file bsp_gc6133.c.c -/// @brief bsp @ driver config -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20180331 -/// @note cc_AS_stc02 -////////////////////////////////////////////////////////////////////////////// - -#include "Bsp_debug.h" -#include "bsp_func.h" -#include "bsp_power.h" -#include "bsp_cam_isr.h" -#include "bsp_cam.h" -#include "../msp/uart0.h" -#include "cw63xx.h" -#include "../clib/Clib.h" -#include "../clib/bit.h" -#include "../msp/time.h" - -/// 第一个比第二个延迟20ms 发送 这样同样触发后,第一个10.5ms发送完成 第二个还没有发送,不构成干扰 - -#define D_p_send_delay(); L1_task_Cdelay(D_Cdelay_15ms*(1+D_cameralIndex)); - -////>>>>>>>>>>>>>>>>>>>>>_s_task_GC032A_>>>>>>>>>>>>>>>>>>>>>> - - -void L0_p_send(void); -extern TS_P_rf433 TS_paer_value; - - -struct _s_task_GC032A_ s_task_GC032A; - -void L2_task_GC032A_init(void) -{ - L0_cam_isr_init(); - - L1_task_init(&s_task_GC032A.task); - - s_task_GC032A.next_line = D_clear; - s_task_GC032A.line_ok = D_run; - s_task_GC032A.line_get = D_clear; - s_task_GC032A.cal_ok = D_clear; - s_task_GC032A.vs_ok = D_clear; -} - -//// 采集单行的程序 20190217 -//// step01 上电时序初始化 -///step02 输入配置寄存器 -///step03 打开中断进入采集模式 -///step04 捕捉第一帧数据 开始采样每一行 同时可以关闭led节约电 -/// step05 捕获到需要的行数 采集到需要的一行数据 -/// step06------>进入休眠状态 -/// |----->持续采集下一行 - - -#if(MODE_CAM_LINE == MODE_CAM) - - -#if 0 - -/// 采集完后延时一定时间 打开led灯 为下次的cam工作提供光源 -/// 等待run信号 如果关闭工作,休眠 fixme:冷启动还是热启动 -void L2_task_GC032A_handle(struct _s_task_GC032A_ *s) -{ - TTSS_Task_init() - //#define D_pclk_per_hs 6 -// PrintCam_L0_uart0_uc('$'); - L2_task_go(D_task_GC032A_init_standby); - TTSS_Task_step(D_task_GC032A_init_standby) - L0_GC032A_standby(); - D_cam_led_on(); - //PWDN引脚拉低(0 -- 正常工作,1 -- 休眠) - // PrintCam_L0_uart0_uc('2'); - L2_task_go(D_task_GC032A_init_DVDD); - TTSS_step01(D_task_GC032A_init_DVDD); - L0_GC032A_work(); - //IOVDD上电,并延时50us以上; - L2_task_go(D_task_GC032A_init_AVDD); - TTSS_Task_step(D_task_GC032A_init_AVDD); - //AVDD28上电,并延时0us以上 - D_cam_AVDD_on(); - L2_task_go(D_task_GC032A_init_pwdn); - TTSS_Task_step(D_task_GC032A_init_pwdn); - //提供032A系统频率 - L0_MCLKO_init(D_ON); - L2_task_GC032A_init(); - //PWDN引脚拉高,延时,拉低 - L0_GC032A_standby(); - DL0_WDT();// - L2_task_go(D_task_GC032A_init_pwdn_wait); - L1_task_Cdelay(D_Cdelay_15ms); - TTSS_Task_step(D_task_GC032A_init_pwdn_wait); - L0_GC032A_work(); - gRccUs03 = 0; - L2_task_go(D_task_GC032A_write_reg); - L1_task_Cdelay(D_Cdelay_15ms); - TTSS_Task_step(D_task_GC032A_write_reg); - //设置摄像头参数 大约2s时间 - if(0 != GC6133_init_reg_tbl[gRccUs03][0]) - { - //GC032a_L0_uart0_uc('k'); - L0_GC032A_write(GC6133_init_reg_tbl[gRccUs03][0],GC6133_init_reg_tbl[gRccUs03][1]);/// - gRccUs03 ++; - }else - { - L2_task_go(D_task_GC032A_div); - L1_task_Tdelay(D_Tdelay_1s);///重要 这个时间很关键aaaaaa - } - TTSS_Task_step(D_task_GC032A_div); - //L0_GC032A_write(0xfc,0x02); //复位?? - L0_GC032A_write(0xf8,0x03);/// 恢复分频 - L0_GC032A_write(0xfa,D_0xfa);DL0_WDT(); - L2_task_go(D_task_GC032A_wakup_sample); -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over - -////等待 其他任务的启动后才工作 - TTSS_step03(D_task_GC032A_wakup_sample) - L1_GC032A_sleep(D_wakeup); - GC032a_L0_uart0_uc('w'); - ///D_ledb_OFF(); - L2_task_go((D_task_GC032A_wakup_sample2)); - L1_task_Tdelay(D_Tdelay_1s5); - TTSS_step04(D_task_GC032A_wakup_sample2); - D_VSYNCS_open();////后台的中断开始工作 - L2_task_go(D_task_GC032A_one_frame); -////////////////////////////////////////////////////////////////////////////// - TTSS_step04(D_task_GC032A_one_frame); - ////捕获到一帧数据的开始((来自于后台的中断)) - ///vs /```24.8ms````\__________________________..1.16s...____________________________/````````\___________ - ///cam_led ```````````\_________________________________________________________/`````````````````\____ - if(D_ready == s->vs_ok)///为了关灯 - { - /// PrintCam_L0_uart0_uc('V'); - s_task_GC032A.vs_ok = D_clear; - D_cam_led_off(); - L2_task_go(D_task_GC032A_wait); - //L1_task_Tdelay(D_Tdelay_50ms); ////取决于getline的行数 和cam需要亮灯的时间 - } - TTSS_step05(D_task_GC032A_wait);////>>>>>>>>>>>>>>>>>>>>>>>--- - ///捕获到需要的Line(来自于后台的中断) - if(D_clear != s->line_get) - {DL0_WDT(); ////memo20190217 : 间隔1.15s - //PrintCam_L0_uart0_uc(s->line_get);// L2_line_send(); - s->buf2_ok = D_ready;///buf2_ok数据准备好可供算法查询 - L2_task_go(D_task_GC032A_sleep); - /// L1_task_Tdelay(D_Tdelay_10ms); - } - TTSS_Task_step(D_task_GC032A_sleep) - ///采样结束 - L1_GC032A_sleep(D_sleep); - L0_GC032A_standby(); - L0_MCLKO_init(D_OFF); - D_cam_led_off(); - L2_task_go(D_task_FLOW_PreSend); - - ////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - TTSS_Task_step(D_task_FLOW_PreSend); - D_txd4_wakeup();///上升沿 1ms后433 从sleep到可以发送 - /// TS_paer_value.r123.cameraBoardPower = s->t_stamp+0x30; - L0_p_send(); - //D_txd4_low(); - L2_task_go(D_task_FLOW_send); - // L1_task_Tdelay(D_Tdelay_10ms); - ///L1_task_Cdelay(60);//2ms---mcu+433无法接收 - TTSS_Task_step(D_task_FLOW_send); - //D_txd4_wakeup(); - L0_uart0_sendArray((unsigned char *)&TS_paer_value,6); - L2_task_go(D_task_FLOW_send2); - TTSS_Task_step(D_task_FLOW_send2); - if(D_uart0_free()) - { - L2_task_go(D_task_FLOW_send3);/// - D_p_send_delay(); - - } - TTSS_Task_step(D_task_FLOW_send3); - L0_uart0_sendArray((unsigned char *)&TS_paer_value,6); - L2_task_go(D_task_FLOW_send4); - TTSS_Task_step(D_task_FLOW_send4); - if(D_uart0_free()) - { - L2_task_go(D_task_FLOW_send5); - } - TTSS_Task_step(D_task_FLOW_send5); - D_txd4_low();///共计耗时15ms - D_cam_AVDD_off();///注意影响发送 - L2_task_go(0); - -///<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - TTSS_Task_end(); -} -#endif - -#elif(MODE_CAM_FRAME == MODE_CAM) - -#elif(MODE_CAM_TEST == MODE_CAM) - -#define PrintCam_L0_uart0_uc(x) L0_uart0_uc(x) -#define PrintCam_D_send_us(x) L0_uart0_us(x) - -///#define L0_uart0_sendArraylong(a,start,end) L0_uart0_sendArray(a(start)) - -/// 采集完后延时一定时间 打开led灯 为下次的cam工作提供光源 -/// 等待run信号 如果关闭工作,休眠 fixme:冷启动还是热启动 -void L2_task_GC032A_handleTest(struct _s_task_GC032A_ *s) -{ - TTSS_Task_init() - //#define D_pclk_per_hs 6 -// PrintCam_L0_uart0_uc('$'); - L2_task_go(D_task_GC032A_init_standby); - TTSS_Task_step(D_task_GC032A_init_standby) - L0_GC032A_standby(); - D_cam_led_on(); - //PWDN引脚拉低(0 -- 正常工作,1 -- 休眠) - // PrintCam_L0_uart0_uc('2'); - L2_task_go(D_task_GC032A_init_DVDD); - TTSS_step01(D_task_GC032A_init_DVDD); - L0_GC032A_work(); - //IOVDD上电,并延时50us以上; - L2_task_go(D_task_GC032A_init_AVDD); - TTSS_Task_step(D_task_GC032A_init_AVDD); - //AVDD28上电,并延时0us以上 - D_cam_AVDD_on(); - L2_task_go(D_task_GC032A_init_pwdn); - TTSS_Task_step(D_task_GC032A_init_pwdn); - //提供032A系统频率 - L0_MCLKO_init(D_ON); - L2_task_GC032A_init(); - //PWDN引脚拉高,延时,拉低 - L0_GC032A_standby(); - DL0_WDT();// - L2_task_go(D_task_GC032A_init_pwdn_wait); - L1_task_Cdelay(D_Cdelay_15ms); - TTSS_Task_step(D_task_GC032A_init_pwdn_wait); - L0_GC032A_work(); - gRccUs03 = 0; - L2_task_go(D_task_GC032A_write_reg); - L1_task_Cdelay(D_Cdelay_15ms); - TTSS_Task_step(D_task_GC032A_write_reg); - //设置摄像头参数 大约2s时间 - if(0 != GC6133_init_reg_tbl[gRccUs03][0]) - { - L0_GC032A_write(GC6133_init_reg_tbl[gRccUs03][0],GC6133_init_reg_tbl[gRccUs03][1]);/// - gRccUs03 ++; - }else - { - L2_task_go(D_task_GC032A_div); - L1_task_Tdelay(D_Tdelay_1s);///重要 这个时间很关键aaaaaa - } - TTSS_Task_step(D_task_GC032A_div); - //L0_GC032A_write(0xfc,0x02); //复位?? - L0_GC032A_write(0xf8,0x03);/// 恢复分频 - L0_GC032A_write(0xfa,D_0xfa);DL0_WDT(); - L2_task_go(D_task_GC032A_wakup_sample); -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over -///------------------------------------------------------cam init over - -////等待 其他任务的启动后才工作 - TTSS_step03(D_task_GC032A_wakup_sample) - L1_GC032A_sleep(D_wakeup); - ///D_ledb_OFF(); - L2_task_go((D_task_GC032A_wakup_sample2)); - L1_task_Tdelay(D_Tdelay_1s5); - TTSS_step04(D_task_GC032A_wakup_sample2); - D_VSYNCS_open();////后台的中断开始工作 - PrintCam_L0_uart0_uc('w'); - L2_task_go(D_task_GC032A_one_frame); -////////////////////////////////////////////////////////////////////////////// - TTSS_step04(D_task_GC032A_one_frame); - - - PrintCam_L0_uart0_uc('.'); - - ////捕获到一帧数据的开始((来自于后台的中断)) - ///vs /```24.8ms````\__________________________..1.16s...____________________________/````````\___________ - ///cam_led ```````````\_________________________________________________________/`````````````````\____ - if(D_ready == s->vs_ok)///为了关灯 - { - s->vs_ok = D_clear; - PrintCam_L0_uart0_uc('V'); -/// D_cam_led_off(); - D_HSYNCS_open(); - L2_task_go(D_task_GC032A_send2); - //L1_task_Tdelay(D_Tdelay_50ms); ////取决于getline的行数 和cam需要亮灯的时间 - } - - TTSS_Task_step(D_task_GC032A_send2)///----------------------开始一行一行的发送 - - if(1 == s_task_GC032A.line_ok) - { - s_task_GC032A.line_ok = 0; - ///采样结束 - PrintCam_L0_uart0_uc(0xfe); - PrintCam_L0_uart0_uc(0xfd); - ///PrintCam_D_send_us(DR_pclk_n); - PrintCam_D_send_us(DR_line_n); - L0_uart0_sendArray(&s_task_GC032A.buf[0],200); - - L2_task_go(D_task_GC032A_06); - /// L1_task_Tdelay(D_Tdelay_50ms); - }else { } - TTSS_step06(D_task_GC032A_06); - /********************************************************* - TTS_for_add(s_task_GC032A.lines,0,627)///[0]--[199]199 - - /// s_task_GC032A.buf[s_task_GC032A.lines] = s_task_GC032A.lines; - s_task_GC032A.buf[s_task_GC032A.lines] = 0; - TTS_for_add_end() - - **************************************************/ - if(D_uart0_send_over()) - { - L0_uart0_sendArray(&s_task_GC032A.buf[200],200); - L2_task_go(D_task_GC032A_07); - } - TTSS_step06(D_task_GC032A_07); - if(D_uart0_send_over()) - { - L0_uart0_sendArray(&s_task_GC032A.buf[400],200); - L2_task_go(D_task_GC032A_08); - } - TTSS_step06(D_task_GC032A_08); - if(D_uart0_send_over()) - { - L0_uart0_sendArray(&s_task_GC032A.buf[600],D_pclk_per_hs-600);/// 628point - - // 'fe','fd','fd','fc' 46 44 20 46 43 0d 0a - PrintCam_L0_uart0_uc(0xfd); - PrintCam_L0_uart0_uc(0xfc); - s_task_GC032A.next_line = 1; - L2_task_go(D_task_GC032A_send2); - L1_task_Tdelay(D_Tdelay_10ms); - } -///<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - TTSS_Task_end(); -} -#endif - -void L1_GC032A_sleep(unsigned char onf) -{///FE 15 Fd 33 44//standby -///FE 05 Fd 33 44//wakeup - if(D_sleep == onf) - { - // GC032a_L0_uart0_uc('L'); - /// 进入standby: - L0_GC032A_write(0xfc,0x03); L0_GC032A_write(0xf7,0x00); L0_GC032A_write(0xf9,0xcf); L0_GC032A_write(0xf3,0x00); - Lc_delay_nop(30); - Lc_delay_nop(30); - }else - { - // GC032a_L0_uart0_uc('X'); - /// 退出standby: - L0_GC032A_write(0xfc,0x02); L0_GC032A_write(0xf7,0x01); L0_GC032A_write(0xf9,0xce); L0_GC032A_write(0xf3,0xff); - } -} - -void L2_line_send(void) -{ -#if 0 - PrintCam_L0_uart0_uc(0x0d); - PrintCam_L0_uart0_uc(0x0a); -// PrintCam_L0_uart0_uc(0xfe); -// PrintCam_L0_uart0_uc(0xfd); -PrintCam_D_send_us(DR_pclk_n); -/// PrintCam_D_send_us(s_task_GC032A.usSum); - PrintCam_L0_uart0_uc(0x09); -// PrintCam_D_send_us(0x1234); PrintCam_D_send_us(0x5678); PrintCam_D_send_us(0xabcd); - -// PrintCam_L0_uart0_uc(0x0d); -// PrintCam_L0_uart0_uc(0x0a); - PrintCam_L0_uart0_sendArray(&(s_task_GC032A.buf[50]),40); - - PrintCam_L0_uart0_uc(0x09); - PrintCam_L0_uart0_sendArray(&(s_task_GC032A.buf[50]),40); - PrintCam_L0_uart0_uc(0x09); - PrintCam_L0_uart0_sendArray(&s_task_GC032A.buf[D_pclk_per_hs_570-21],20); - - ///Lc_hex2ascii(&(s_task_GC032A.buf[0]),10,ts_uart_send_shop.buf); -// Lc_hex2ascii(&s_task_GC032A.buf[D_pclk_per_hs_570-10],2,ts_uart_send_shop.buf2); -// L0_uart0_sendArray(ts_uart_send_shop.buf2,2*3); -///#ifdef D_debug_add_send - -// PrintCam_L0_uart0_uc('P'); - - ///L0_uart0_sendArraylong(s_task_GC032A.buf,D_pclk_per_hs_570-10,D_pclk_per_hs_570); - // 'fe','fd','fd','fc' -// PrintCam_L0_uart0_uc(0xfd); -// PrintCam_L0_uart0_uc(0xfc); - PrintCam_L0_uart0_uc(0x0d); - PrintCam_L0_uart0_uc(0x0a); -///#else - /***** - ?? - 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 11 11 11 11 11 11 - 11 11 11 11 11 11 11 11 11 11 - 11 11 - 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 10 - CRpaper =04F8-g-offdiff :. - - ******/ - ///vU16 i; for(i = 0;i <= D_pclk_per_hs_570; i ++) {s_task_GC032A.buf[i]=i; } - PrintCam_L0_uart0_uc(0xfe); - PrintCam_L0_uart0_uc(0xfd); - PrintCam_D_send_us(DR_pclk_n); - L0_uart0_sendArray(s_task_GC032A.buf,200); - L0_uart0_sendArray(&s_task_GC032A.buf[200],200); - L0_uart0_sendArray(&s_task_GC032A.buf[400],(D_pclk_per_hs_570-400)); - -// PrintCam_D_send_us(ts_task_ALGO.usSum_temp); -//// PrintCam_D_send_us(s_task_GC032A.down_point); -// PrintCam_D_send_us(s_task_GC032A.down_point - s_task_GC032A.up_point); - // DR_pdata_n =0; -// PrintCam_D_send_us(0x1234); - // 'fe','fd','fd','fc' -// PrintCam_L0_uart0_uc(0xfd); -// PrintCam_L0_uart0_uc(0xfc); - #endif -/* */ -} - - -#if 0 - -void GC032A_port_init(void) -{ - ///00 准双向口 灌电流20mA 拉电流270-150uS - ///01 推挽输出 20mA 加限流 - ///10 高阻 - ///11 开漏 open-Drain 内部上拉电阻断开 开漏模式既可以度外部状态也可以对外输出高低电平 - - //p3.6 --HSYNC -// BITN_0(P3M1,BITN6);BITN_0(P3M0,BITN6); - ///P3.7 -- VSYNC -// BITN_0(P3M1,BITN7);BITN_0(P3M0,BITN7); - L0_GC032A_standby(); - D_cam_AVDD_on(); - -} - - - - - - - -//// AX CMD R2 R3 R4 -/// Ae 01 01 03 04 -void L3_GC032A_fun(U8 *pPara) -{ - *pPara = 0; -} - /******** -void L3_GC032A_fun(U8 *pPara) -{ - U8 i,val[2]; - // unsigned short j; - TS_P_debug *p = pPara; - switch(p->cmd) - { - - case 3: //Ae 03 03 04 00 - //xx 03 R2 R3 xx - - PrintCam_L0_uart0_uc(0x0d); - PrintCam_L0_uart0_uc(0x0a); - PrintCam_L0_uart0_uc('l'); - Lc_delay_ms(12); - s_task_GC032A.vline_get = p->R2 << 8; - s_task_GC032A.vline_get |= p->R3; - L0_uart0_uchex(p->R2); - Lc_delay_ms(12); - L0_uart0_uchex(p->R3); - Lc_delay_ms(1200); - PrintCam_L0_uart0_uc(0x0d); - PrintCam_L0_uart0_uc(0x0a); - PrintCam_L0_uart0_uc(0x0d); - PrintCam_L0_uart0_uc(0x0a); - PrintCam_L0_uart0_uc(0x0d); - PrintCam_L0_uart0_uc(0x0a); - - break; - - default: - break; - }; - - -} -********/ -///#else - -//// fe 01 reg data 0cx -/// Ac 01 02 03 ocr ---bsp_debug.c -/// U8 i,val[2]; -// unsigned short j; - TS_P_debug *p = pPara; - switch(p->cmd) - { - - case 0x01: p.cmd p.R2 p.R3 p.ocr -///Ac 00 03 01 00/// ACC_X[13:6] - -void L3_GC032A_fun(U8 *pPara) -{ - U8 i,val[2]; -// unsigned short j; - TS_P_debug *p = pPara; - switch(p->cmd) - { - - case 0x01: - ///AE 01 FE 33 44 // L0_GC032A_read(0xFE,&i,1); 读取当前页面 - ///AE 01 F0 33 44 // L0_GC032A_read(0xF0,&i,1); 读取id i= 0x23 - L0_GC032A_read(p->R2,&i,1); - PrintCam_L0_uart0_uc(i); - break; - //修改摄像头配置参数 - case 0x02: - /// fe 02 r2 r3 xx 设置寄存器(r2) = r3 - /// sysreg FE 02 FE 01 44 //设置当前页面01 - L0_GC032A_write(p->R2,p->R3); - PrintCam_L0_uart0_uc(p->R2); - PrintCam_L0_uart0_uc(p->R3); - break; - //启动摄像头进行拍照; - case 0x03:/// sysreg FE 03 03 04 05 //设置是否发送一line数据(数据分为一帧=640Line = 640line*480pclk ) - ///AE 03 01 33 44 //s_task_GC032A.line_onf = 01 - ///AE 03 00 33 44 //s_task_GC032A.line_onf = 00 - s_task_GC032A.line_onf = p->R2; - PrintCam_L0_uart0_uc(0x30|s_task_GC032A.line_onf); - break; - case 0x05: - ///AE 05 01 33 44 //进入 standby - ///AE 05 00 33 44 //退出 standby - L1_GC032A_sleep(p->R2); - PrintCam_L0_uart0_uc(0x30|s_task_GC032A.line_onf); - break; - case 6:///AE 06 22 33 44 - D_cam_led_off(); - break; - case 7:///AE 07 22 33 44 - D_cam_led_on(); - - break; - /******************* - case 0x00: - L0_GC032A_read(p->R2,val,p->R3); - PrintCam_L0_uart0_uc(p->cmd); - PrintCam_L0_uart0_uc(p->R2); - PrintCam_L0_uart0_uc(p->R3); - PrintCam_L0_uart0_uc('G'); - for(i = 0;i < p->R3;i++) - { - PrintCam_L0_uart0_uc(val[i]); - } - break; - //读取摄像头配置参数 - case 0x35: - L0_GC032A_standby();// led 17.1-16.9ma standby 6.2ma - PrintCam_L0_uart0_uc(0x31); - break; - case 0x36: - /// 退出standby: - L0_GC032A_work(); - PrintCam_L0_uart0_uc(0x30); - break; - - - ****************************/ - - default: - break; - }; -} - -#endif - - - -#if 0 -254 253 - -FE FD 02 7F ///639 -1A 1B 1B 1B 1B 1B 1A 1C 1B 1B 1B 1A 1A 19 19 1A 19 1A 19 1A 19 1A 19 19 18 19 19 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 17 16 17 16 18 18 18 18 18 18 18 18 18 18 18 18 17 17 17 17 18 18 17 17 17 17 17 16 17 17 17 17 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 17 17 17 17 17 17 17 17 17 17 18 18 18 18 18 19 19 19 19 19 19 18 18 19 19 19 18 18 18 1A 19 19 19 19 19 1A 1A 1A 1A 1A 1A 19 19 18 19 19 19 1A 1A 1A 1B 1B 1B 1C 1C 1C 1C 1C 1C 1C 1D 1D 1D 1C 1C 1C 1C 1D 1E 1C 1C 1C 1D 1C 1C 1C 1C 1C 1C 1C 1D 1D 1D 1D 1C 1B 1A 1B 1A 1B 1D 1D 1D 1D 1D 1C 1C 1C 1C 1C 1C 1C 1C 1C 1C 1C 1B 1B 1B 1B 1B 1B 1C 1C 1C 1C 1B 1B 1C 1C 1C 1E 1C 1C 1C 1C 1C 1C 1C 1C 1C 1C 1C 1C 1B 1C 1B 1C 1C 1D 1D 1C 1C 1C 1C 1C 1C 1C 1C 1C 1C 1C 1C 1D 1D 1D 1C 1C 1C 1C 1C 1D 1D 1E 1D 1E 1F 1F 1E 1E 1E 1E 1E 1E 1E 1E 1D 1D 1C 1C 1C 1C 1C 1C 1C 1C 1C 1D 1D 1D 1D 1C 1D 1D 1D 1D 1D 1E 1E 1E 1E 1E 1E 1E 1E 1E 1E 1E 1E 1D 1C 1C 1C 1C 1C 1C 1C 1B 1C 1C 1C 1C 1C 1C 1C 1C 1C 1C 1B 1C 1C 1C 1C 1C 1C 1D 1C 1C 1C 1C 1D 1F 1F 1D 1C 1C 1B 1C 1C 1C 1C 1C 1C 1B 1B 1B 1B 1B 1B 1B 1C 1C 1C 1C 1C 1D 1C 1C 1C 1D 1D 1D 1D 1E 1D 1C 1C 1C 1C 1C 1C 1C 1C 1D 1D 1E 1E 1E 1D 1D 1D 1D 1C 1D 1C 1C 1C 1C 1D 1D 1D 1D 1C 1C 1C 1C 1C 1C 1B 1B 1C 1C 1C 1C 1B 1B 1B 1B 1D 1B 1C 1B 1B 1B 1C 1D 1C 1B 19 1A 19 1B 1C 1A 1A 1A 1A 1A 1A 1B 1B 1B 1A 1B 19 1B 1A 1A 1A 1A 1A 19 18 19 19 1A 1A 1A 1A 1A 19 19 18 18 18 18 18 1A 18 18 18 18 18 18 18 18 19 1A 19 19 19 19 19 19 19 1A 1A 1A 1A 19 19 18 18 18 18 18 18 19 18 18 18 19 18 18 18 18 18 1A 18 18 18 18 18 18 18 18 17 17 17 18 18 18 18 17 17 17 17 17 16 17 17 18 18 19 19 19 19 19 19 18 18 18 18 18 18 17 17 18 18 17 17 17 17 17 17 19 17 17 17 17 17 17 17 17 17 17 17 17 18 17 17 17 17 17 17 17 17 16 16 17 17 17 17 17 16 16 17 17 17 17 16 16 16 16 16 16 16 17 16 16 16 16 16 16 16 16 16 16 18 19 16 16 16 16 15 16 17 17 16 15 15 16 16 16 15 14 14 15 17 15 15 15 15 16 16 16 16 16 15 16 16 16 15 15 15 15 15 -FD FC -253 252 - -254 253 /639./ 253 252 - - -#endif - - - - - -#if 0/// memo -//memo20190217 : 间隔1.15s - /********* - [15:37:04.337]收←◆v 4.337 - [15:37:05.487]收←◆v 5.487 1.15 - [15:37:06.637]收←◆v 6.637 1.15 - [15:37:07.787]收←◆k 7.787 1.15 - [15:37:08.947]收←◆v 8.947 1.16 - [15:37:10.097]收←◆v 10.097 1.15 - [15:37:11.247]收←◆v 11.247 1.15 - [15:37:12.397]收←◆v 12.397 1.15 - [15:37:13.547]收←◆k 13.547 1.15 - 48 31 61 77 77 77 77 2E 56 77 77 77 33 76 01 D3 56 2E 77 77 77 00 - - ***/ - -void GC032A_port_init(void) -{ - ///00 准双向口 灌电流20mA 拉电流270-150uS - ///01 推挽输出 20mA 加限流 - ///10 高阻 - ///11 开漏 open-Drain 内部上拉电阻断开 开漏模式既可以度外部状态也可以对外输出高低电平 - //p3.6 --HSYNC -// BITN_0(P3M1,BITN6);BITN_0(P3M0,BITN6); - ///P3.7 -- VSYNC -// BITN_0(P3M1,BITN7);BITN_0(P3M0,BITN7); -// L0_GC032A_standby(); -// D_cam_AVDD_on(); -} - -void L2_line_send(void) -{ -// /// vU16 usi; - PrintCam_D_send_us(0x1234); - PrintCam_D_send_us(0x5678); - PrintCam_D_send_us(0xabcd); -#if 0 - - PrintCam_L0_uart0_uc(0x0d); - PrintCam_L0_uart0_uc(0x0a); -// PrintCam_L0_uart0_uc(0xfe); -// PrintCam_L0_uart0_uc(0xfd); - PrintCam_D_send_us(DR_pclk_n); - PrintCam_D_send_us(0x1234); - PrintCam_D_send_us(0x5678); - PrintCam_D_send_us(0xabcd); - - PrintCam_L0_uart0_uc(0x0d); - PrintCam_L0_uart0_uc(0x0a); - - PrintCam_L0_uart0_sendArray(&(s_task_GC032A.buf[0]),2); - - PrintCam_L0_uart0_uc(0x09); -/// PrintCam_L0_uart0_sendArray(&s_task_GC032A.buf[D_pclk_per_hs_570-10],9); - ///Lc_hex2ascii(&(s_task_GC032A.buf[0]),10,ts_uart_send_shop.buf); - Lc_hex2ascii(&s_task_GC032A.buf[D_pclk_per_hs_570-10],2,ts_uart_send_shop.buf2); - L0_uart0_sendArray(ts_uart_send_shop.buf2,2*3); -///#ifdef D_debug_add_send - - PrintCam_L0_uart0_uc('P'); - - ///L0_uart0_sendArraylong(s_task_GC032A.buf,D_pclk_per_hs_570-10,D_pclk_per_hs_570); - // 'fe','fd','fd','fc' -// PrintCam_L0_uart0_uc(0xfd); -// PrintCam_L0_uart0_uc(0xfc); -// PrintCam_L0_uart0_uc(0x0d); -// PrintCam_L0_uart0_uc(0x0a); -///#else - - [18:41:16.591]ê?????02 FE FD 02 42 12 12 12 12 12 12 12 12 12 12 12 11 11 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 11 11 11 11 11 11 11 12 12 12 13 13 14 15 16 16 17 18 18 17 17 16 16 17 19 1C 1F 25 28 2A 2C 2D 2E 2F 30 31 31 32 32 32 32 31 31 32 32 32 32 33 33 33 33 33 33 33 33 33 33 33 33 33 32 32 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 34 33 34 34 34 34 34 34 34 34 34 34 34 35 35 34 35 35 35 35 35 35 36 35 35 36 36 11 11 11 FD FC - - - - PrintCam_L0_uart0_uc(0xfe); - PrintCam_L0_uart0_uc(0xfd); - PrintCam_D_send_us(DR_pclk_n); - L0_uart0_sendArraylong(s_task_GC032A.buf,0,199); - L0_uart0_sendArraylong(s_task_GC032A.buf,200,399); - if(D_pclk_per_hs < 600) - { - L0_uart0_sendArraylong(s_task_GC032A.buf,400,599); - }else - { - L0_uart0_sendArraylong(s_task_GC032A.buf,400,599); - L0_uart0_sendArraylong(s_task_GC032A.buf,600,(D_pclk_per_hs-1)); - } -// PrintCam_D_send_us(ts_task_ALGO.usSum_temp); -//// PrintCam_D_send_us(s_task_GC032A.down_point); -// PrintCam_D_send_us(s_task_GC032A.down_point - s_task_GC032A.up_point); - // DR_pdata_n =0; -// PrintCam_D_send_us(0x1234); - // 'fe','fd','fd','fc' - PrintCam_L0_uart0_uc(0xfd); - PrintCam_L0_uart0_uc(0xfc); - #endif -/* */ -} - -#endif - - diff --git a/source/bsp/backu/bsp_cam.h b/source/bsp/backu/bsp_cam.h deleted file mode 100644 index bc1f645..0000000 --- a/source/bsp/backu/bsp_cam.h +++ /dev/null @@ -1,189 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file bsp_gc6133.c.h -/// @brief bsp @ driver config -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20180331 -/// @note cc_AS_stc02 - -////////////////////////////////////////////////////////////////////////////// - -#ifndef _bsp_cam_H -#define _bsp_cam_H - -#include "../bsp/bsp_config.h" - -#include "../tpc/tpc_uart.h" - -#include "../msp/uart0.h" - -#include "bsp_gc032a.h" - -//>>>>>>>>>>>>>>>>>>>>>0gc63xxtask - -//#define D_i2c_addr_gc61xx 0x80 //page8/30 @pdf -#define D_i2c_addr_gc032A 0x42 //page15/31 @pdf -///// 400KHz Tlow > 1.3us -#define L0_GC032A_write(R,D) L2_I2C_WriteCmd(D_i2c_addr_gc032A,(R),(D)) -#define L0_GC032A_read(R,D,N) L2_I2C_ReadReg(D_i2c_addr_gc032A,(R),(D),(N)) -#define L0_GC032A_reg(R,D) L2_tws_ReadReg(D_i2c_addr_gc032A,(R),(D)) - - /// p55 pwdn - /// p54 inclk - /// p3.7 vsync - /// p3.6 hsync -#if 0 -#define L0_GC032A_work() D_P55_OFF(); -#define L0_GC032A_standby() - -#else -#define L0_GC032A_work() D_P55_OFF();D_stdIO_P1_ALL();\ - D_stdIO_P5(BITN4);\ - D_stdIO_P5(BITN5);\ - D_stdIO_P3(BITN7);\ - D_stdIO_P3(BITN6); -#define L0_GC032A_standby() D_HighR_P1_ALL();\ - D_HighI_P5(BITN4);\ - D_HighI_P5(BITN5);\ - D_HighI_P3(BITN7);\ - D_HighI_P3(BITN6);D_P55_ON(); -///pwdn 100uAD_P55_OFF();// - - -#endif - - - -#define GC6123_SERIAL_write_cmos_sensor L0_GC032A_write - -///#define D_pclk_per_hs 628 -///#define D_pclk_per_hs 688 -#define D_pclk_per_hs 639 ///027F - -#define D_pclk_per_hs_570 570 - -//#define D_pclk_per_hs 580 - -#define D_pclk_per_hs_2 D_pclk_per_hs -///#define D_pclk_per_hs_2 (110) - -//#define D_pclk_per_hs 6 - -struct _s_task_GC032A_ -{ - TS_task task; -/// vU32 t_stamp; - unsigned short lines; ///当前行采样结束 - unsigned short frames; ///当前行采样结束 - - unsigned char next_line:1; ///下一行采样开始 - unsigned char cal_ok:1; ///当前行采样结束// - unsigned char lamp:1; ///当前灯的标志 - unsigned char line_get:1; ///当前需要的行采样结束 可以计算了 - unsigned char line_ok:1; /// 采样的开关 - unsigned char vs_ok:1; /// 开始一帧的采样 代表收到了vs信号 - unsigned char line_onf:2; /// D_line_onf_get=0发送需要发送的一个line\\ D_line_onf_all=1 发送连续line - - -// volatile unsigned short usHs_count; -// volatile unsigned short usPclk; - unsigned char buf2_ok; - -/// volatile unsigned short usN; -////// unsigned short usMax; - unsigned char buf[D_pclk_per_hs +2]; -}; -#define D_line_onf_all 1 -#define D_line_onf_get 0 - - -extern struct _s_task_GC032A_ s_task_GC032A; - - -void L2_task_GC032A_init(void); - -#define D_task_GC032A_init_standby 0x36 - -#define D_task_GC032A_init_DVDD 0x30 -#define D_task_GC032A_init_AVDD 0x31 -#define D_task_GC032A_init_pwdn 0x32 -#define D_task_GC032A_init_pwdn_wait 0x33 - - -#define D_task_FLOW_PreSend 0xa3 -#define D_task_FLOW_PreSend2 0xa4 - - - - -#define D_task_FLOW_send 0x90 -#define D_task_FLOW_send2 0x91 -#define D_task_FLOW_send3 0x92 -#define D_task_FLOW_send4 0x93 -#define D_task_FLOW_send5 0x94 - - - -#define D_task_GC032A_write_reg 0x40 -#define D_task_GC032A_wakup_sample 0x41 -#define D_task_GC032A_start_time2 0x43 - -#define D_task_GC032A_wakup_sample2 0x44 - - -#define D_task_GC032A_wait 0x51 -#define D_task_GC032A_one_frame 0x52 -#define D_task_GC032A_write_reg2 0x53 -#define D_task_GC032A_div 0x54 -#define D_task_GC032A_dat 0x55 - - -#define D_task_GC032A_led 0x56 - - - -#define D_task_GC032A_send_line 0x61 -#define D_task_GC032A_send2 0x62 -#define D_task_GC032A_send3 0x63 -#define D_task_GC032A_send4 0x64 - -////#define D_task_GC032A_over 0x63 -#define D_task_GC032A_cal 0x65 -///#define D_task_GC032A_send_over 0x64 - -#define D_task_GC032A_sleep 0x67 -#define D_task_GC032A_06 0x68 -#define D_task_GC032A_07 0x69 -#define D_task_GC032A_08 0x6a -#define D_task_GC032A_09 0x6b - -#define D_task_GC032A_sample 0x68 - -#define D_task_GC032A_end 0x69 - -#define D_task_GC032A_next_line 0x70 - - -extern void L2_task_GC032A_handle(struct _s_task_GC032A_ *s); -extern void L2_task_GC032A_handleTest(struct _s_task_GC032A_ *s); - - -//////////////////////////////////////////////////////////////////// - - -extern void GC032A_port_init(void); -extern void L3_GC032A_fun(U8 *pPara); - -extern void L1_GC032A_sleep(unsigned char onf); - -#define D_cam_led_on(); L1_cw63_reg_set(D_power_VCC2,D_CW63XX_ON|D_CW63XX_3V2);//P34 = 1;/////s_task_GC032A.lamp = D_ON; -#define D_cam_led_off(); L1_cw63_reg_set(D_power_VCC2,D_CW63XX_OFF|D_CW63XX_3V2);///P34 = 0;/////s_task_GC032A.lamp = D_OFF; - - - - -#endif // #ifndef _bsp_gc6133_H - diff --git a/source/bsp/backu/bsp_cam_isr.c b/source/bsp/backu/bsp_cam_isr.c deleted file mode 100644 index f3a7f8f..0000000 --- a/source/bsp/backu/bsp_cam_isr.c +++ /dev/null @@ -1,218 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file bsp_gc6133.c.c -/// @brief bsp @ driver config -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20180331 -/// @note cc_AS_stc02 -///------------------------------------------------------------------------- -/// @version 1.2 -/// @author CC -/// @date 20180703 -/// @note cc_AS_stc02 -////////////////////////////////////////////////////////////////////////////// - -//#include "Bsp_debug.h" -#include "bsp_func.h" -#include "bsp_cam_isr.h" -#include "bsp_cam.h" -#include "../msp/uart0.h" -#include "cw63xx.h" -#include "../clib/Clib.h" -#include "../clib/bit.h" -#include "../msp/time.h" -#define D_pclk_div_hs 1 ///D_pclk_per_hs*D_pclk_div_hs < 680 - -///vs p3.7 int3 -///hs p3.6 int2 -///pclk p3.2 int0 -/// row line确可以表示一条线 一行的意思.而column则形象的表示一个纵向的“列 - -#define D_line_get 10 -#define D_row_get2 4 -#ifdef doc_98989 -vs /```24.8ms````\_______________________________..1.16s..._____________________________________________/```````````\__________ -hs /\————————/\_2.14MS_/\____/\____/\____ ...... __/\____/\____/\__480个__/\____/\____/\____/\————————/\ - -hs /``\________________________hs______________________/``\ -pclk |||||||||||||||||||||||||||||||||||||||||||||||640 - - -Line0 L1 L2 L1 L1 L1 L1 L1 L1 L480 ----------------------------------------------------------------------- - 1 1 1 1 1 1 1 1 1 --- --- 1 - 2 2 2 2 2 2 2 2 2 --- --- 2 - 3 3 3 3 3 3 3 3 3 --- --- 3 - 4 4 4 4 4 4 4 4 4 --- --- 4 - 5 5 5 5 5 5 5 5 5 --- --- 5 - 6 6 6 6 6 6 6 6 6 --- --- 6 - 7 7 7 7 7 7 7 7 7 --- --- 7 - 8 8 8 8 8 8 8 8 8 --- --- 8 - 9 9 9 9 9 9 9 9 9 --- --- 9 - 10 10 10 10 10 10 10 10 10 --- --- 10 - 11 11 11 11 11 11 11 11 11 --- --- 11 - 12 12 12 12 12 12 12 12 12 --- --- 12 - 13 13 13 13 13 13 13 13 13 --- --- 13 - 14 14 14 14 14 14 14 14 14 --- --- 14 - . . . . . . . . . --- --- . - . . . . . . . . . --- --- . - . . . . . . . . . --- --- . - . . . . . . . . . --- --- . - 640 640 640 640 640 640 640 640 640 --- --- 640 - -#endif ///doc_98989 - - -void L0_cam_isr_init(void) -{ - IT0 = 1;///int0 下降沿触发 = 0 上下沿均可触发 -/// IT0 = 0;////int0 下降沿触发 = 0 上下沿均可触发 -/// L0_INT0_OPEN(); - D_HSYNCS_close(); - D_VSYNCS_open(); - D_PCLK_close(); - -} - -#if(MODE_CAM_LINE == MODE_CAM) - - -#if 0 -////////// -/////一帧数据的开始 -void L0_VSYNCS_Isr (void) interrupt D_ISR_int3////下降沿 -{////找到一帧数据的开头:第一行 - L0_INT3_CLEAR(); - ///s_task_GC032A.usHs_count = 0; - DR_line_n = 0; -/// s_task_GC032A.next_line = D_ready;///启动第一行 这样确保帧头是第一行,对齐的/// -/// s_task_GC032A.one_line_ok = D_clear; - s_task_GC032A.line_get = D_clear; - s_task_GC032A.vs_ok = D_ready; - //s_task_GC032A.frames ++; - //if(s_task_GC032A.frames > 10) - {/// 时间溢出 - ///s_task_GC032A.frames = 0; - } - D_ledb_OFF(); -/// D_leda_ON(); - D_HSYNCS_open(); -} - -/////一行line row数据的开始 -void L0_HSYNCS_Isr(void) interrupt D_ISR_int2/// using 1 /下降沿 -{///hs 下沿有效 - L0_INT2_CLEAR(); - //// hs信号的计数在vs有效的时候清零,这样usHs_count=D_row_get就代表 - //// 当前一帧画面里面的第D_row_get个hs,也就是一个画面中的第几行数据 - ///if(D_ready == s_task_GC032A.next_line) - {///D_P33_REV(); - //D_leda_OFF(); - /// s_task_GC032A.next_line = D_clear;///因为接收一行数据的时间远远小于发送的时间 - ///因此添加这个为了提高可靠性 - ///发送完了后由“gc032a任务”启动 - s_task_GC032A.lines = DR_line_n;////保存当前的行号到缓存中,因为行号变化的速度超过 - ////发送的速度,当在"gc032A任务"中使用的时候DR_line_n 已经变化了 - ///0 24 58 94 129 165 200 236 271 307 342 378 - D_PCLK_open(); - //D_P35_REV() ; - DR_pclk_n = 0; - if(DR_line_n >= D_line_get) - { - s_task_GC032A.line_get = D_ready; - D_HSYNCS_close();D_PCLK_close(); - } - } - DR_line_n ++;///当前行数增加 -} - -////s_task_GC032A.buf 存放的是一行的数据 -//// pclk int0 每个点的采样 -void L0_PCLK_Isr(void) interrupt D_ISR_int0 /// using 10/// -{///PCLK -// D_P34_REV(); - DR_Dat = P1; - s_task_GC032A.buf[DR_pclk_n] = DR_Dat; // s_task_GC032A.buf[DR_pclk_n] = 0xaa;//P1&0xf0; //s_task_GC032A.buf[s_task_GC032A.usN] = s_task_GC032A.usN; - DR_pclk_n++;// D_P34_REV(); - if(DR_pclk_n > D_pclk_per_hs)////一行的有效数据接收完成 采样了 D_pclk_per_hs个固定数据 - { - D_PCLK_close(); - - //D_ledb_REV() ; - DR_pclk_n = D_pclk_per_hs; ///fixme - DR_pclk_n = 0; -/// s_task_GC032A.one_line_ok = D_ready;////给“gc032a任务”传递消息 可以开始计算或者发送了 - D_ledb_ON(); - } -} -#endif - -#elif(MODE_CAM_FRAME == MODE_CAM) - -#elif(MODE_CAM_TEST == MODE_CAM) -/////连续发送 -void L0_VSYNCS_Isr (void) interrupt D_ISR_int3////下降沿 -{////找到一帧数据的开头:第一行 - ///s_task_GC032A.usHs_count = 0; - DR_line_n = 0; - s_task_GC032A.next_line = 1;///启动第一行 这样确保帧头是第一行,对齐的/// - s_task_GC032A.vs_ok = D_ready; -} - -/////一行line row数据的开始 -void L0_HSYNCS_Isr(void) interrupt D_ISR_int2/// using 1 /下降沿 -{///hs 下沿有效 - //// hs信号的计数在vs有效的时候清零,这样usHs_count=D_row_get就代表 - //// 当前一帧画面里面的第D_row_get个hs,也就是一个画面中的第几行数据 - if(s_task_GC032A.next_line) - {///D_P33_REV(); - s_task_GC032A.next_line = 0;///因为接收一行数据的时间远远小于发送的时间 - ///因此添加这个为了提高可靠性 - ///发送完了后由“gc032a任务”启动 - s_task_GC032A.lines = DR_line_n;////保存当前的行号到缓存中,因为行号变化的速度超过 - ////发送的速度,当在"gc032A任务"中使用的时候DR_line_n 已经变化了 - ///0 24 58 94 129 165 200 236 271 307 342 378 - - /***** - if(D_line_get == DR_line_n) - { - s_task_GC032A.line_get = 1; - } - ******/ - D_PCLK_open();///启动记录下一行数据 - DR_pclk_n = 0; - } - DR_line_n ++;///当前行数增加 -} - -////s_task_GC032A.buf 存放的是一行的数据 -//// pclk int0 每个点的采样 -void L0_PCLK_Isr(void) interrupt D_ISR_int0 //// using 10/// -{///PCLK -// D_P34_REV(); -//// DR_Dat = P1; s_task_GC032A.buf[DR_pclk_n] = DR_Dat; - s_task_GC032A.buf[DR_pclk_n] = P1; - - - ////s_task_GC032A.buf[DR_pclk_n] = 0xcc; - ///s_task_GC032A.buf[DR_pclk_n] = DR_pclk_n; - DR_pclk_n++;// D_P34_REV(); - if(DR_pclk_n > D_pclk_per_hs) ////一行的有效数据接收完成 采样了 D_pclk_per_hs个固定数据 - { - D_PCLK_close(); - DR_pclk_n = D_pclk_per_hs; ///fixme - - s_task_GC032A.line_ok = 1; ////给“gc032a任务”传递消息 可以开始计算或者发送了 - } -} - - -////收到 next_line 记录当前第几行lines,启动 pclk,采集数据到buf中,然后line_ok -///// send buf, set next_line after send buf over - -#endif - - diff --git a/source/bsp/backu/bsp_cam_isr.h b/source/bsp/backu/bsp_cam_isr.h deleted file mode 100644 index bac07b9..0000000 --- a/source/bsp/backu/bsp_cam_isr.h +++ /dev/null @@ -1,62 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file bsp_gc6133.c.h -/// @brief bsp @ driver config -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20180331 -/// @note cc_AS_stc02 - -////////////////////////////////////////////////////////////////////////////// - -#ifndef _bsp_cam_isr_H -#define _bsp_cam_isr_H - -#include "../bsp/bsp_config.h" - -#include "../tpc/tpc_uart.h" - -#include "../msp/uart0.h" - -#include "bsp_gc032a.h" - -#define D_VSYNCS_open(); L0_INT3_OPEN(); -#define D_VSYNCS_close(); L0_INT3_CLOSE(); - -#define D_HSYNCS_open(); L0_INT2_OPEN(); -#define D_HSYNCS_close(); L0_INT2_CLOSE(); - -#define D_PCLK_open(); L0_INT0_OPEN(); -#define D_PCLK_close(); L0_INT0_CLOSE(); - - -#define DR_pclk_n gRccUs05 - -#define DR_line_n gRccUs01 -#define DR_line_n_H gRccUs01_H -#define DR_line_n_L gRccUs01_L - - -///// #define DR_Hs_count gRccUs02//s_task_GC032A.usPclk -///#define DR_Dat CCAP1L -#define DR_Dat SPDAT - -//>>>>>>>>>>>>>>>>>>>>>0gc63xxtask - -//#define D_row_max 640 - -//////////////////////////////////////////////////////////////////// - - -extern void L0_cam_isr_init(void) ; - - - - - - - -#endif // #ifndef _bsp_cam_isr_H - diff --git a/source/bsp/backu/bsp_func.c b/source/bsp/backu/bsp_func.c deleted file mode 100644 index bcc170f..0000000 --- a/source/bsp/backu/bsp_func.c +++ /dev/null @@ -1,53 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file bsp_func.c -/// @brief bsp @ fuctiong ; io复用选择等,和cpu型号息息相关 -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20180308 -/// @note cc_AS_stc02 - - - -////////////////////////////////////////////////////////////////////////////// - -#include "bsp_func.h" -#include "../msp/uart0.h" -//#include "../tpc/tpc_modbus.h" - -///struct _s_sysclk s_sysclk; - - -////MCLK0 配置 不需要的时候关闭以节约电 -void L0_MCLKO_init(U8 onf) -{ - BITN_1(P_SW2,EAXFR); - CKSEL &= B0000_0011; - if (D_ON == onf) - { - ///----------------------------------------------------- - // p107@stc8.pdf - ///step 1 :设置system out clock - //BITS_CLR(CKSEL,BITC_4,BIT4); /// 对REG的 从BITx开始 清除 N位 - ///多位配置,一定要配对使用,先清除再设置。 - BITS_SET(CKSEL,D_CLKODIV_DIV8);/// sytem out clock 300k - ///step 2 :设置IO - BITN_0(CKSEL,MCLKO_S);/// P5.4 SELECTED - BITN_0(P5M1,BITN4);BITN_1(P5M0,BITN4);/// 01 推挽 - } - else - { - BITS_CLR(CKSEL,BITC_4,BIT4); - BITN_1(P5M1,BITN4);BITN_0(P5M0,BITN4);/// 00 准双向口01 推挽输出10 高阻11 开漏 - //// 32k 下L1_task_Tdelay(D_Tdelay_ms); 变成了大约8s - ///fixme - /// BITN_1(P5M1,BITN4);BITN_0(P5M0,BITN4);/// 00 准双向口01 推挽输出10 高阻11 开漏 - ///? 使用10 功耗增加11.130 使用01 功耗为10.65 - //P54 = 1; 推挽 居然比高阻省电 另外推挽下面 =1比=0省电 10uA - } - BITN_0(P_SW2,EAXFR); -} - - diff --git a/source/bsp/backu/bsp_func.h b/source/bsp/backu/bsp_func.h deleted file mode 100644 index 194f7f0..0000000 --- a/source/bsp/backu/bsp_func.h +++ /dev/null @@ -1,52 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file bsp_func.c -/// @brief bsp_func -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20170122 -/// @note cc_AS_stc01 -////////////////////////////////////////////////////////////////////////////// - -#ifndef _bsp_func_H -#define _bsp_func_H - -#include "../bsp/bsp_config.h" -#include "../clib/bit.h" -struct _s_sysclk -{ - U32 m; - U32 clk; - U32 out; -}; - -extern struct _s_sysclk s_sysclk; - -#define P3130 0 -//#define P1617 0 -#define P3736 1 - -extern void L0_MCLKO_init(U8 onf); - - -#define D_CLKODIV_NONE 0 - -#define D_CLKODIV_DIV1 B0001_0000 -#define D_CLKODIV_DIV2 B0010_0000 -#define D_CLKODIV_DIV4 B0100_0000 -#define D_CLKODIV_DIV8 B0110_0000 -#define D_CLKODIV_DIV16 B1000_0000 -#define D_CLKODIV_DIV32 B1010_0000 -#define D_CLKODIV_DIV64 B1100_0000 -#define D_CLKODIV_DIV128 B1110_0000 - -#define D_CLKODIV_MCLKO_S BITN3 - -#define D_CLKODIV_MCKSEL_IN24M B0000_0000 -#define D_CLKODIV_MCKSEL_EXTERN B0000_0001 -#define D_CLKODIV_MCKSEL_IN32K B0000_0011 - -#endif // #ifndef _bsp_func_H - diff --git a/source/bsp/backu/bsp_gc032a.c b/source/bsp/backu/bsp_gc032a.c deleted file mode 100644 index 6650b50..0000000 --- a/source/bsp/backu/bsp_gc032a.c +++ /dev/null @@ -1,773 +0,0 @@ -#include "bsp_gc032a.h" -#if 0 -const U8 GC6133_init_reg_sys[][2]= { - - /*System*/ - {0xf3,0xff}, - {0xf5,0x06}, - {0xf7,0x01}, - {0xf9,0xce}, - {0xfa,0x00}, -//1002 {0xf8,0x03},//////分频 {0xf8,0x03}, -{0xf8,0x0f},//////分频 {0xf8,0x03}, - // {0xfa,D_0xfa}, // cc add - /// {0xfd,D_0xfa}, // cc add - /// {0xfa,D_0xfa}, // cc add - /// {0xfd,D_0xfa}, // cc add -///20181002启动时使用较高频率 当启动后恢复低频率 - {0xfc,0x02}, - {0x00,0x00} -/// ///20181003 -// -}; - - -const U8 GC6133_init_reg_tbl[][2]= { - {0xfe,0x02},//page 2 - {0x81,0x03}, - - {0xfe,0x00}, - {0x77,0x64}, - {0x78,0x40}, - {0x79,0x60}, - /*ANALOG & CISCTL*/ - {0xfe,0x00},//page 0 - {0x03,0x01}, - {0x04,0xce}, - {0x05,0x01}, - {0x06,0xad}, - {0x07,0x00}, - {0x08,0x10}, - {0x0a,0x00}, - {0x0c,0x00}, - {0x0d,0x01}, - {0x0e,0xe8}, - {0x0f,0x02}, - {0x10,0x88}, - {0x17,0x54}, - {0x19,0x08}, - {0x1a,0x0a}, - {0x1f,0x40}, - {0x20,0x30}, - {0x2e,0x80}, - {0x2f,0x2b}, - {0x30,0x1a}, - {0xfe,0x02}, - {0x03,0x02}, - {0x05,0xd7}, - {0x06,0x60}, - {0x08,0x80}, - {0x12,0x89}, - - /* BLK*/ - {0xfe,0x00},//page 1 - {0x18,0x02}, - {0xfe,0x02},//page 2 - {0x40,0x22}, - {0x45,0x00}, - {0x46,0x00}, - {0x49,0x20}, - {0x4b,0x3c}, - {0x50,0x20}, - {0x42,0x10}, - - /*ISP*/ - {0xfe,0x01},//page 1 - {0x0a,0xc5}, - {0x45,0x00}, - {0xfe,0x00},//page 0 - {0x40,0xff}, - {0x41,0x25}, - {0x42,0xcd},///cc201805 close AWB{0x42,0xcf}, -/// {0x44,0x83},///P0:0x44 Output_format [7] YUV420_row_switch 5’h03: Y Cr Y Cb - {0x44,B1001_0000},///P0:0x44 Output_format [7] YUV420_row_switch 5’h10: only Y - - {0x43,0x12},////{0x43,D_P00x43},// ///EABLE CrCb fixed en 02 -/** P0:0x43 special_effect 7 0x00 RW [7] NA - [6] subsample2 - [5] subsample4 - [4] GAMMA_en - [3:2] only_edge_map - [1] CrCb_ fixed_en - [0] inverse color*/ - {0xda,0x00}, - {0xdb,0x00}, - /////{0x46,0x22}, -////------------------------------------- -{0x46,B0010_1000},// hs high pclk polarity {0x46,0x22}, -/* P0:0x46 sync_mode 8 0x0f RW -[7] data delay half -[6] hsync delay half -[5] odd_even_col_switch -[4] odd_even_row_switch - -[3] opclk gated in HB -[2] opclk polarity -[1] hsync polarity -[0] vsync polarity*/ -// {0x4c,D_P00x4c},//lsc test image -// {0x4D,0xfc},//lsc test image - -// {0x4a,0x86},//////div_gate+clk_en 82 -/**P0:0x4a Clock_gating_e -n -8 0x82 RW [7] ISP quiet mode -[6] close AAA pclk -[5]vb change -[4]vb chang flop ---------------------- -[3]hb change -[2] DIV_gatedclk_en -[1] exception -[0] AEC_delay_mode*/ - -////------------------------------------- - {0x49,0x03}, - {0x52,0x02}, - {0x54,0x00}, - {0xfe,0x02}, - {0x22,0xf6}, - - /*Shading*/ - {0xfe,0x01},//page 1 - {0xc1,0x38}, - {0xc2,0x4c}, - {0xc3,0x00}, - {0xc4,0x32}, - {0xc5,0x24}, - {0xc6,0x16}, - {0xc7,0x08}, - {0xc8,0x08}, - {0xc9,0x00}, - {0xca,0x20}, - {0xdc,0x8a}, - {0xdd,0xa0}, - {0xde,0xa6}, - {0xdf,0x75}, - - /*AWB*//*20170110*/ - {0xfe, 0x01},//page 1 - {0x7c, 0x09}, - {0x65, 0x06}, - {0x7c, 0x08}, - {0x56, 0xf4}, - {0x66, 0x0f}, - {0x67, 0x84}, - {0x6b, 0x80}, - {0x6d, 0x12}, - {0x6e, 0xb0}, - {0xfe, 0x01}, - {0x90, 0x00}, - {0x91, 0x00}, - {0x92, 0xf4}, - {0x93, 0xd5}, - {0x95, 0x0f}, - {0x96, 0xf4}, - {0x97, 0x2d}, - {0x98, 0x0f}, - {0x9a, 0x2d}, - {0x9b, 0x0f}, - {0x9c, 0x59}, - {0x9d, 0x2d}, - {0x9f, 0x67}, - {0xa0, 0x59}, - {0xa1, 0x00}, - {0xa2, 0x00}, - {0x86, 0x00}, - {0x87, 0x00}, - {0x88, 0x00}, - {0x89, 0x00}, - {0xa4, 0x00}, - {0xa5, 0x00}, - {0xa6, 0xd4}, - {0xa7, 0x9f}, - {0xa9, 0xd4}, - {0xaa, 0x9f}, - {0xab, 0xac}, - {0xac, 0x9f}, - {0xae, 0xd4}, - {0xaf, 0xac}, - {0xb0, 0xd4}, - {0xb1, 0xa3}, - {0xb3, 0xd4}, - {0xb4, 0xac}, - {0xb5, 0x00}, - {0xb6, 0x00}, - {0x8b, 0x00}, - {0x8c, 0x00}, - {0x8d, 0x00}, - {0x8e, 0x00}, - {0x94, 0x50}, - {0x99, 0xa6}, - {0x9e, 0xaa}, - {0xa3, 0x0a}, - {0x8a, 0x00}, - {0xa8, 0x50}, - {0xad, 0x55}, - {0xb2, 0x55}, - {0xb7, 0x05}, - {0x8f, 0x00}, - {0xb8, 0xb3}, - {0xb9, 0xb6}, - - - /*CC*/ - {0xfe,0x01},//page 0 - {0xd0,0x40}, - {0xd1,0xf8}, - {0xd2,0x00}, - {0xd3,0xfa}, - {0xd4,0x45}, - {0xd5,0x02}, - - {0xd6,0x30}, - {0xd7,0xfa}, - {0xd8,0x08}, - {0xd9,0x08}, - {0xda,0x58}, - {0xdb,0x02}, - {0xfe,0x00}, - - /*Gamma*/ - {0xfe,0x00},//page 0 - {0xba,0x00}, - {0xbb,0x04}, - {0xbc,0x0a}, - {0xbd,0x0e}, - {0xbe,0x22}, - {0xbf,0x30}, - {0xc0,0x3d}, - {0xc1,0x4a}, - {0xc2,0x5d}, - {0xc3,0x6b}, - {0xc4,0x7a}, - {0xc5,0x85}, - {0xc6,0x90}, - {0xc7,0xa5}, - {0xc8,0xb5}, - {0xc9,0xc2}, - {0xca,0xcc}, - {0xcb,0xd5}, - {0xcc,0xde}, - {0xcd,0xea}, - {0xce,0xf5}, - {0xcf,0xff}, - - /*Auto Gamma*/ - {0xfe,0x00}, - {0x5a,0x08}, - {0x5b,0x0f}, - {0x5c,0x15}, - {0x5d,0x1c}, - {0x5e,0x28}, - {0x5f,0x36}, - {0x60,0x45}, - {0x61,0x51}, - {0x62,0x6a}, - {0x63,0x7d}, - {0x64,0x8d}, - {0x65,0x98}, - {0x66,0xa2}, - {0x67,0xb5}, - {0x68,0xc3}, - {0x69,0xcd}, - {0x6a,0xd4}, - {0x6b,0xdc}, - {0x6c,0xe3}, - {0x6d,0xf0}, - {0x6e,0xf9}, - {0x6f,0xff}, - - /*Gain*/ - {0xfe,0x00}, - {0x70,0x50}, - - /*AEC*/ - {0xfe,0x00},//page 0 - {0x4f,0x00},///cc201805 close ACE /// {0x4f,0x01}, - {0xfe,0x01},//page 1 - {0x0d,0x00},//08 add 20170110 - {0x12,0xa0}, - {0x13,0x3a}, - {0x44,0x04}, - {0x1f,0x30}, - {0x20,0x40}, - {0x26,0x9a}, - {0x3e,0x20}, - {0x3f,0x2d}, - {0x40,0x40}, - {0x41,0x5b}, - {0x42,0x82}, - {0x43,0xb7}, - {0x04,0x0a}, - {0x02,0x79}, - {0x03,0xc0}, - - /*measure window*/ - {0xfe,0x01},//page 1 - {0xcc,0x08}, - {0xcd,0x08}, - {0xce,0xa4}, - {0xcf,0xec}, - - /*DNDD*/ - {0xfe,0x00}, - {0x81,0xb8}, - {0x82,0x12}, - {0x83,0x0a}, - {0x84,0x01}, - {0x86,0x50}, - {0x87,0x18}, - {0x88,0x10}, - {0x89,0x70}, - {0x8a,0x20}, - {0x8b,0x10}, - {0x8c,0x08}, - {0x8d,0x0a}, - - /*Intpee*/ - {0xfe,0x00}, - {0x8f,0xaa}, - {0x90,0x9c}, - {0x91,0x52}, - {0x92,0x03}, - {0x93,0x03}, - {0x94,0x08}, - {0x95,0x44}, - {0x97,0x00}, - {0x98,0x00}, - - /*ASDE*/ - {0xfe,0x00}, - {0xa1,0x30}, - {0xa2,0x41}, - {0xa4,0x30}, - {0xa5,0x20}, - {0xaa,0x30}, - {0xac,0x32}, - - /*YCP*/ - {0xfe,0x00}, - {0xd1,0x3c}, - {0xd2,0x3c}, - {0xd3,0x38}, - {0xd6,0xf4}, - {0xd7,0x1d}, - {0xdd,0x73}, - {0xde,0x84}, - - /*Banding*/ - {0xfe,0x00}, - {0x05,0x01}, - {0x06,0xad}, - {0x07,0x00}, - {0x08,0x10}, - - {0xfe,0x01}, - {0x25,0x00}, - {0x26,0x9a}, - - {0x27,0x01}, - {0x28,0xce}, - {0x29,0x03}, - {0x2a,0x02}, - {0x2b,0x04}, - {0x2c,0x36}, - {0x2d,0x07}, - {0x2e,0xd2}, - {0x2f,0x0b}, - {0x30,0x6e}, - {0x31,0x0e}, - {0x32,0x70}, - {0x33,0x12}, - {0x34,0x0c}, - {0x3c,0x30}, - {0xfe,0x00}, - {0x00,0x00} - -}; -#else - -const U8 code GC6133_init_reg_tbl[][2]= { - - /*System*/ - {0xf3,0xff}, - {0xf5,0x06}, - {0xf7,0x01}, - {0xf9,0xce}, - {0xfa,0x00}, -//1002 {0xf8,0x03},//////分频 {0xf8,0x03}, -{0xf8,0x0f},//////分频 {0xf8,0x03}, - // {0xfa,D_0xfa}, // cc add - /// {0xfd,D_0xfa}, // cc add - /// {0xfa,D_0xfa}, // cc add - /// {0xfd,D_0xfa}, // cc add -///20181002启动时使用较高频率 当启动后恢复低频率 - {0xfc,0x02}, - - {0xfe,0x02},//page 2 - {0x81,0x03}, - - {0xfe,0x00}, - {0x77,0x64}, - {0x78,0x40}, - {0x79,0x60}, - /*ANALOG & CISCTL*/ - {0xfe,0x00},//page 0 - {0x03,0x01}, - {0x04,0xce}, - {0x05,0x01}, - {0x06,0xad}, - {0x07,0x00}, - {0x08,0x10}, - {0x0a,0x00}, - {0x0c,0x00}, - {0x0d,0x01}, - {0x0e,0xe8}, - {0x0f,0x02}, - {0x10,0x88}, - {0x17,0x54}, - {0x19,0x08}, - {0x1a,0x0a}, - {0x1f,0x40}, - {0x20,0x30}, - {0x2e,0x80}, - {0x2f,0x2b}, - {0x30,0x1a}, - {0xfe,0x02}, - {0x03,0x02}, - {0x05,0xd7}, - {0x06,0x60}, - {0x08,0x80}, - {0x12,0x89}, - - /* BLK*/ - {0xfe,0x00},//page 1 - {0x18,0x02}, - {0xfe,0x02},//page 2 - {0x40,0x22}, - {0x45,0x00}, - {0x46,0x00}, - {0x49,0x20}, - {0x4b,0x3c}, - {0x50,0x20}, - {0x42,0x10}, - - /*ISP*/ - {0xfe,0x01},//page 1 - {0x0a,0xc5}, - {0x45,0x00}, - {0xfe,0x00},//page 0 - {0x40,0xff}, - {0x41,0x25}, - {0x42,0xcd},///cc201805 close AWB{0x42,0xcf}, -/// {0x44,0x83},///P0:0x44 Output_format [7] YUV420_row_switch 5’h03: Y Cr Y Cb - {0x44,B1001_0000},///P0:0x44 Output_format [7] YUV420_row_switch 5’h10: only Y - - {0x43,0x12},////{0x43,D_P00x43},// ///EABLE CrCb fixed en 02 -/** P0:0x43 special_effect 7 0x00 RW [7] NA - [6] subsample2 - [5] subsample4 - [4] GAMMA_en - [3:2] only_edge_map - [1] CrCb_ fixed_en - [0] inverse color*/ - {0xda,0x00}, - {0xdb,0x00}, - /////{0x46,0x22}, -////------------------------------------- -{0x46,B0010_1000},// hs high pclk polarity {0x46,0x22}, -/* P0:0x46 sync_mode 8 0x0f RW -[7] data delay half -[6] hsync delay half -[5] odd_even_col_switch -[4] odd_even_row_switch - -[3] opclk gated in HB -[2] opclk polarity -[1] hsync polarity -[0] vsync polarity*/ -// {0x4c,D_P00x4c},//lsc test image -// {0x4D,0xfc},//lsc test image - -// {0x4a,0x86},//////div_gate+clk_en 82 -/**P0:0x4a Clock_gating_e -n -8 0x82 RW [7] ISP quiet mode -[6] close AAA pclk -[5]vb change -[4]vb chang flop ---------------------- -[3]hb change -[2] DIV_gatedclk_en -[1] exception -[0] AEC_delay_mode*/ - -////------------------------------------- - {0x49,0x03}, - {0x52,0x02}, - {0x54,0x00}, - {0xfe,0x02}, - {0x22,0xf6}, - - /*Shading*/ - {0xfe,0x01},//page 1 - {0xc1,0x38}, - {0xc2,0x4c}, - {0xc3,0x00}, - {0xc4,0x32}, - {0xc5,0x24}, - {0xc6,0x16}, - {0xc7,0x08}, - {0xc8,0x08}, - {0xc9,0x00}, - {0xca,0x20}, - {0xdc,0x8a}, - {0xdd,0xa0}, - {0xde,0xa6}, - {0xdf,0x75}, - - /*AWB*//*20170110*/ - {0xfe, 0x01},//page 1 - {0x7c, 0x09}, - {0x65, 0x06}, - {0x7c, 0x08}, - {0x56, 0xf4}, - {0x66, 0x0f}, - {0x67, 0x84}, - {0x6b, 0x80}, - {0x6d, 0x12}, - {0x6e, 0xb0}, - {0xfe, 0x01}, - {0x90, 0x00}, - {0x91, 0x00}, - {0x92, 0xf4}, - {0x93, 0xd5}, - {0x95, 0x0f}, - {0x96, 0xf4}, - {0x97, 0x2d}, - {0x98, 0x0f}, - {0x9a, 0x2d}, - {0x9b, 0x0f}, - {0x9c, 0x59}, - {0x9d, 0x2d}, - {0x9f, 0x67}, - {0xa0, 0x59}, - {0xa1, 0x00}, - {0xa2, 0x00}, - {0x86, 0x00}, - {0x87, 0x00}, - {0x88, 0x00}, - {0x89, 0x00}, - {0xa4, 0x00}, - {0xa5, 0x00}, - {0xa6, 0xd4}, - {0xa7, 0x9f}, - {0xa9, 0xd4}, - {0xaa, 0x9f}, - {0xab, 0xac}, - {0xac, 0x9f}, - {0xae, 0xd4}, - {0xaf, 0xac}, - {0xb0, 0xd4}, - {0xb1, 0xa3}, - {0xb3, 0xd4}, - {0xb4, 0xac}, - {0xb5, 0x00}, - {0xb6, 0x00}, - {0x8b, 0x00}, - {0x8c, 0x00}, - {0x8d, 0x00}, - {0x8e, 0x00}, - {0x94, 0x50}, - {0x99, 0xa6}, - {0x9e, 0xaa}, - {0xa3, 0x0a}, - {0x8a, 0x00}, - {0xa8, 0x50}, - {0xad, 0x55}, - {0xb2, 0x55}, - {0xb7, 0x05}, - {0x8f, 0x00}, - {0xb8, 0xb3}, - {0xb9, 0xb6}, - - - /*CC*/ - {0xfe,0x01},//page 0 - {0xd0,0x40}, - {0xd1,0xf8}, - {0xd2,0x00}, - {0xd3,0xfa}, - {0xd4,0x45}, - {0xd5,0x02}, - - {0xd6,0x30}, - {0xd7,0xfa}, - {0xd8,0x08}, - {0xd9,0x08}, - {0xda,0x58}, - {0xdb,0x02}, - {0xfe,0x00}, - - /*Gamma*/ - {0xfe,0x00},//page 0 - {0xba,0x00}, - {0xbb,0x04}, - {0xbc,0x0a}, - {0xbd,0x0e}, - {0xbe,0x22}, - {0xbf,0x30}, - {0xc0,0x3d}, - {0xc1,0x4a}, - {0xc2,0x5d}, - {0xc3,0x6b}, - {0xc4,0x7a}, - {0xc5,0x85}, - {0xc6,0x90}, - {0xc7,0xa5}, - {0xc8,0xb5}, - {0xc9,0xc2}, - {0xca,0xcc}, - {0xcb,0xd5}, - {0xcc,0xde}, - {0xcd,0xea}, - {0xce,0xf5}, - {0xcf,0xff}, - - /*Auto Gamma*/ - {0xfe,0x00}, - {0x5a,0x08}, - {0x5b,0x0f}, - {0x5c,0x15}, - {0x5d,0x1c}, - {0x5e,0x28}, - {0x5f,0x36}, - {0x60,0x45}, - {0x61,0x51}, - {0x62,0x6a}, - {0x63,0x7d}, - {0x64,0x8d}, - {0x65,0x98}, - {0x66,0xa2}, - {0x67,0xb5}, - {0x68,0xc3}, - {0x69,0xcd}, - {0x6a,0xd4}, - {0x6b,0xdc}, - {0x6c,0xe3}, - {0x6d,0xf0}, - {0x6e,0xf9}, - {0x6f,0xff}, - - /*Gain*/ - {0xfe,0x00}, - {0x70,0x50}, - - /*AEC*/ - {0xfe,0x00},//page 0 - {0x4f,0x00},///cc201805 close ACE /// {0x4f,0x01}, - {0xfe,0x01},//page 1 - {0x0d,0x00},//08 add 20170110 - {0x12,0xa0}, - {0x13,0x3a}, - {0x44,0x04}, - {0x1f,0x30}, - {0x20,0x40}, - {0x26,0x9a}, - {0x3e,0x20}, - {0x3f,0x2d}, - {0x40,0x40}, - {0x41,0x5b}, - {0x42,0x82}, - {0x43,0xb7}, - {0x04,0x0a}, - {0x02,0x79}, - {0x03,0xc0}, - - /*measure window*/ - {0xfe,0x01},//page 1 - {0xcc,0x08}, - {0xcd,0x08}, - {0xce,0xa4}, - {0xcf,0xec}, - - /*DNDD*/ - {0xfe,0x00}, - {0x81,0xb8}, - {0x82,0x12}, - {0x83,0x0a}, - {0x84,0x01}, - {0x86,0x50}, - {0x87,0x18}, - {0x88,0x10}, - {0x89,0x70}, - {0x8a,0x20}, - {0x8b,0x10}, - {0x8c,0x08}, - {0x8d,0x0a}, - - /*Intpee*/ - {0xfe,0x00}, - {0x8f,0xaa}, - {0x90,0x9c}, - {0x91,0x52}, - {0x92,0x03}, - {0x93,0x03}, - {0x94,0x08}, - {0x95,0x44}, - {0x97,0x00}, - {0x98,0x00}, - - /*ASDE*/ - {0xfe,0x00}, - {0xa1,0x30}, - {0xa2,0x41}, - {0xa4,0x30}, - {0xa5,0x20}, - {0xaa,0x30}, - {0xac,0x32}, - - /*YCP*/ - {0xfe,0x00}, - {0xd1,0x3c}, - {0xd2,0x3c}, - {0xd3,0x38}, - {0xd6,0xf4}, - {0xd7,0x1d}, - {0xdd,0x73}, - {0xde,0x84}, - - /*Banding*/ - {0xfe,0x00}, - {0x05,0x01}, - {0x06,0xad}, - {0x07,0x00}, - {0x08,0x10}, - - {0xfe,0x01}, - {0x25,0x00}, - {0x26,0x9a}, - - {0x27,0x01}, - {0x28,0xce}, - {0x29,0x03}, - {0x2a,0x02}, - {0x2b,0x04}, - {0x2c,0x36}, - {0x2d,0x07}, - {0x2e,0xd2}, - {0x2f,0x0b}, - {0x30,0x6e}, - {0x31,0x0e}, - {0x32,0x70}, - {0x33,0x12}, - {0x34,0x0c}, - {0x3c,0x30}, - {0xfe,0x00}, - {0x00,0x00} - -}; - - -#endif diff --git a/source/bsp/backu/bsp_gc032a.h b/source/bsp/backu/bsp_gc032a.h deleted file mode 100644 index 7be8e1a..0000000 --- a/source/bsp/backu/bsp_gc032a.h +++ /dev/null @@ -1,19 +0,0 @@ - -#ifndef _gc_032a_H_ -#define _gc_032a_H_ - -#include "../bsp/bsp_config.h" - -#include "../clib/type.h" -#include "../clib/clib.h" -#include "../ctask/tick.h" - -//#define GC6133_reg_tbl_len 291 GC6133_reg_tbl_len+1 - -#define GC6133_reg_tbl_len (292) - - -extern U8 code GC6133_init_reg_tbl[][2]; - - -#endif///_gc_032a_H_ diff --git a/source/bsp/backu/bsp_msa300.c b/source/bsp/backu/bsp_msa300.c deleted file mode 100644 index 3e152fe..0000000 --- a/source/bsp/backu/bsp_msa300.c +++ /dev/null @@ -1,261 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2017, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file msa300.c -/// @brief msa300 driver app -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20170122 -/// @note cc_AS_stc01 -////////////////////////////////////////////////////////////////////////////// - -/******************************************************************************/ -/***************************** Include Files **********************************/ -/******************************************************************************/ -#include "bsp_msa300.h" -#include "../msp/uart0.h" -struct _s_gsens_ s_as;//[D_as_ch_mun]; - - -// data*3.91mg/LSB 1g = 90 1/2g = 45 1/3g = 30 333mg/3.91mg = 85d=0x55 -/// 倾斜30度就启动 -//#define D_actionTH_init 0x02 -#define D_actionTH_init 0x0f -//#define D_actionTH_init 0x25 /// z轴调到25算是临界值 -////#define D_actionTH_init 0x0c -////#define D_actionTH_init 0x04 -/// 中断持续的时间为4s 4s后中断结束 产生下降沿 -// #define D_latch_time_init D_latch_4s -#define D_latch_time_init D_latch_50ms - - - - -#if 0 -void L1_as_power_mode(unsigned char dev,unsigned char ps) -{ - // s_as[0].reg_power - s_as[0].reg_power &= 0x3f; - s_as[0].reg_power |= ps; - L2_I2C_WriteCmd(dev,MSA_REG_POWERMODE_BW,s_as[0].reg_power); // 进入normal 模式 -} - - -/// D_sensor_active_close();DL_ms300_int_close(); - -/// L1_as_WorkStatus(D_wakeup); - -///extern void L1_as_WorkStatus(unsigned char d); -void L1_as_WorkStatus(unsigned char d) -{ - if(D_wakeup == d) - { -/// L1_ms300_reg_set(MSA_REG_INTERRUPT_MAPPING3,D_INT2_S_TAP|D_INT2_ACTIVE); - D_sensor_active_open();BITN_0(DR_who_wakeup, DRB_who_wakeup_action); - }else - { -/// L1_ms300_reg_set(MSA_REG_INTERRUPT_MAPPING3,0); - D_sensor_active_close(); - } -} -void L1_as_action(void) -{ - L2_I2C_ReadReg(D_i2c_addr_Gsensor,MSA_REG_Tape_Active_Status,&s_as[0].reg_temp,1); /// read only - ///L0_uart0_uc('.'); - s_as[0].reg_temp &= B0111_0111;/// 去掉符号位 - if(s_as[0].reg_action == s_as[0].reg_temp) - { - }else - { - - s_as[0].action_ok = 1; - s_as[0].reg_action = s_as[0].reg_temp; - } -/// L0_uart0_uchex(s_as[0].reg_temp) -} -#endif - -/// msa300 初始化 调用前必须使用iic的初始化 -/// 如需使用中断 还必须EA 启动 -void L1_msa300_init(void) -{ - /// -///step 1: 读取power reg - LD_gsensor_power(D_PowerMode_normal ); - /// 上电后是standby 模式 需要设置 00:normal mode, 01:low power mode, 10/11 suspend mode - -///step 2: 设置分辨率和加速度范围 -/// L1_ms300_reg_set(MSA_REG_G_RANGE,((D_MSA_14BIT)|(D_MSA_2G))); // 8b8t 2g - L1_ms300_reg_set(MSA_REG_G_RANGE,((D_MSA_8BIT)|(D_MSA_2G))); // 8b8t 2g -// L1_ms300_reg_set(NSA_REG_ODR_AXIS_DISABLE, -// D_ODR_31Hz25); - -///step 3: 设置 输出频率和带宽bandwidth 带宽总是输出频率的一半 -/// ODR BW -/// 15.63Hz (0100) 7.81Hz -/// CLOSE Y关闭 y轴 因为模块是竖着的 - L1_ms300_reg_set(MSA_REG_ODR_AXIS_DISABLE,D_AXIS_DIS_Y|D_ODR_15P63Hz); -// L1_ms300_reg_set(MSA_REG_ODR_AXIS_DISABLE,D_ODR_31Hz25); -////-------------------------------------------------------------------------- - //CC-MD-VH06 - /// for pcb (INT1 PIN5 ) --- SENSINT2---(P3.0 INT1) - /// (INT2 PIN6 ) --- SENSINT3---(P3.1/INT0) - -///step 4: active 中断 使能XZ轴 - L1_ms300_reg_set(MSA_REG_INTERRUPT_SETTINGS1, - ACTIVE_INT_EN_Y|ACTIVE_INT_EN_X); /// fixme:需要调试ACTIVE_INT_EN_Y - L1_ms300_reg_set(D_Active_TH,D_actionTH_init); - -///step 5: - /// ACTIVE 中断和 single tap中断映射到 int2上,也就是int2电平变化,通知mcu处理 - /// ps3.sch msa300.int1==sensint2 msa300.int2==sensint3 ---rxd -/// L1_ms300_reg_set(MSA_REG_INTERRUPT_MAPPING1,INT1_ACTIVE|INT1_S_TAP_INT); -// L1_ms300_reg_set(MSA_REG_INTERRUPT_MAPPING3,D_INT2_ACTIVE); - L1_ms300_reg_set(MSA_REG_INTERRUPT_MAPPING3,D_INT2_S_TAP|D_INT2_ACTIVE); - -/// INT2_OD 0: push-pull -/// INT2_LVL 0: low, 1:high -/// L1_ms300_reg_set(MSA_REG_INT_PIN_CONFIG,D_INT2_OD|D_INT2_LVL_low); - L1_ms300_reg_set(MSA_REG_INT_PIN_CONFIG,D_INT2_pull|D_INT2_LVL_low); - ///L1_ms300_reg_set(MSA_REG_INT_PIN_CONFIG,0|D_INT2_LVL_high); - -////-------------------------------------------------------------------------- -///step 6 : 锁定1s的时间 ···\_____1s______/```` - L1_ms300_reg_set(MSA_REG_INT_LATCH,D_latch_time_init); - ///L1_i2c_Configure(0);DL_ms300_int_open - ///();D_sensor_active_open(); -/// L1_as_WorkStatus(D_wakeup); - -// LD_gsensor_power(D_PowerMode_normal ); - LD_gsensor_power(D_PowerMode_low ); -} -#if 0///nouse - -///0x02 ACC_X[5:0] 0x00 -//0x03 ACC_X[13:6] 0x00 -//0x04 ACC_Y[5:0] 0x00 -//0x05 ACC_Y[13:6] 0x00 -//0x06 ACC_Z[5:0] 0x00 -//0x07 ACC_Z[13:6] 0x00 -/// 0 1 2 3 4 5 -// x5:0 x13:6 y5:0 y13:6 z5:0 z13:6 -void L1_as_readXYZ(unsigned char CH) -{ - -/********************************************** -///read data -//S ADD W A REG A -//S ADD R A D1 A D2 A.....DX N P - L2_I2C_ReadReg(D_i2c_addr_AS1,0x02,(unsigned char *)s_as[CH].d,6); - -////d 0 1 2 3 4 5 -//// 02 03 04 05 06 07 -//// XL XH YL YH ZL ZH -/// -L0_uart0_uc(0x09); -// L0_uart0_uchex(s_as[0].d[0]); L0_uart0_uc(0x09); - L0_uart0_uchex(s_as[0].d[1]); L0_uart0_uc(0x09); -// L0_uart0_uchex(s_as[0].d[2]); L0_uart0_uc(0x09); - L0_uart0_uchex(s_as[0].d[3]); L0_uart0_uc(0x09); -// L0_uart0_uchex(s_as[0].d[4]); L0_uart0_uc(0x09); - L0_uart0_uchex(s_as[0].d[5]); -/// L0_uart0_sendArray((unsigned char *)&s_as[CH],6); -L0_uart0_uc(0x0d); -L0_uart0_uc(0x0a); - - - -Lc_delay_ms(10); - *****************************************/ - -} - -#endif //////nouse -/***************** - -L2_I2C_ReadReg(D_i2c_addr_HP303B,0x0d,d,1); - L0_MUART_uc(d[0]); -L2_I2C_ReadReg(D_i2c_addr_AS1,0x05,d,1);// 11 =0f - L0_MUART_uc(d[0]); -L2_I2C_ReadReg(D_i2c_addr_AS2,0x05,d,1);//10 =0f - L0_MUART_uc(d[0]); - - L1_as1_readXYZ(); - s_p_rf.ucR1 = (U8)(s_as1.x>>8); - s_p_rf.ucR2 = (U8)(s_as1.y>>8); - s_p_rf.ucR3 = (U8)(s_as1.z>>8); -p = (U8*)&s_p_rf; - - L0_MUART_uc(s_p_rf.ucR1); - L0_MUART_uc(s_p_rf.ucR2); - L0_MUART_uc(s_p_rf.ucR3); - L0_MUART_uc(0xc7); - *********************/ -#if 0 - -void L3_msa300_fun(U8 *pPara) -{ - U8 val = 0; - TS_P_debug *p = pPara; - /// Ac 01 02 03 ocr ---bsp_debug.c - /// p.cmd p.R2 p.R3 p.ocr - ///Ac 00 03 01 00/// ACC_X[13:6] - switch(p->cmd) - { - case 0: - /// fc 00 02 01 xx 读取reg02 中的一个数据 - ///0x02 ACC_X[5:0] 0x00 - //0x03 ACC_X[13:6] 0x00 - //0x04 ACC_Y[5:0] 0x00 - //0x05 ACC_Y[13:6] 0x00 - //0x06 ACC_Z[5:0] 0x00 - //0x07 ACC_Z[13:6] 0x00 - //// Ac 00 03 01 00/// ACC_X[13:6] - //// Ac 00 05 01 00/// ACC_Y[13:6] - //// Ac 00 07 01 00/// ACC_Z[13:6] - L2_I2C_ReadReg(D_i2c_addr_AS1,p->R2 ,&val,p->R3); - ///L0_uart0_uc(p->R2); - ///L0_uart0_uc(p->R3); - L0_uart0_uc(val); - break; - case 2: - ///Ac 02 22 01 00/// (05)=01 - L0_uart0_uc('W'); - ///L2_I2C_WriteCmd(D_i2c_addr_AS1,p->R2,p->R3); - //L0_uart0_uc(pPara[2]); - // L0_uart0_uc(p->R2); - // L0_uart0_uc(p->R3); - break; - case 3: - ///Ac 03 22 01 00/// (05)=01 - L1_as_action(); - if(1 == s_as[0].action_ok) - { - s_as[0].action_ok = 0; - L0_uart0_uc(s_as[0].reg_action); - } - /********************* - L2_I2C_ReadReg(D_i2c_addr_Gsensor,MSA_REG_Tape_Active_Status,&s_as[0].reg_temp,1); /// read only - ///L0_uart0_uc('.'); - s_as[0].reg_temp &= B0111_0111; - if(s_as[0].reg_power == s_as[0].reg_temp) - { - - }else - { - L0_uart0_uc(s_as[0].reg_temp); - s_as[0].reg_power = s_as[0].reg_temp; - }*************************/ - break; - default: - break; - }; -} -///#else -void L3_msa300_fun(U8 *pPara) -{ -} -#endif - - diff --git a/source/bsp/backu/bsp_msa300.h b/source/bsp/backu/bsp_msa300.h deleted file mode 100644 index 4069586..0000000 --- a/source/bsp/backu/bsp_msa300.h +++ /dev/null @@ -1,473 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2017, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file msa300.c -/// @brief msa300 driver app -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20170122 -/// @note cc_AS_stc01 -////////////////////////////////////////////////////////////////////////////// - - - -#ifndef _MSA300_H -#define _MSA300_H - - -#include "../clib/bit.h" - -#include "../msp/iic_sim.h" - - - - -/*********************************************************************** - - U51(SDO=1) int2 P33 ----------------U10(SDO=0) int2 P32----------------MCU----USB - 0x4c 0x4e - AS1 AS2 - -**************************************************************************/ - - -#define D_i2c_addr_AS1 0x4c // u51 -//#define D_i2c_addr_AS2 0x4e -/* Register define for NSA asic */ -#define MSA_REG_SPI_I2C 0x00 -#define MSA_REG_WHO_AM_I 0x01 -#define MSA_REG_ACC_X_LSB 0x02 -#define MSA_REG_ACC_X_MSB 0x03 -#define MSA_REG_ACC_Y_LSB 0x04 -#define MSA_REG_ACC_Y_MSB 0x05 -#define MSA_REG_ACC_Z_LSB 0x06 -#define MSA_REG_ACC_Z_MSB 0x07 - - -#define MSA_REG_Tape_Active_Status 0x0B - -#define MSA_REG_G_RANGE 0x0f -#define MSA_REG_ODR_AXIS_DISABLE 0x10 -#define MSA_REG_POWERMODE_BW 0x11 -#define MSA_REG_SWAP_POLARITY 0x12 -#define MSA_REG_FIFO_CTRL 0x14 -#define MSA_REG_INTERRUPT_SETTINGS1 0x16 -#define MSA_REG_INTERRUPT_SETTINGS2 0x17 -#define MSA_REG_INTERRUPT_MAPPING1 0x19 -#define MSA_REG_INTERRUPT_MAPPING2 0x1a -#define MSA_REG_INTERRUPT_MAPPING3 0x1b -#define MSA_REG_INT_PIN_CONFIG 0x20 -#define MSA_REG_INT_LATCH 0x21 -#define MSA_REG_ACTIVE_DURATION 0x27 -#define MSA_REG_ACTIVE_THRESHOLD 0x28 -#define MSA_REG_TAP_DURATION 0x2A -#define MSA_REG_TAP_THRESHOLD 0x2B -#define MSA_REG_CUSTOM_OFFSET_X 0x38 -#define MSA_REG_CUSTOM_OFFSET_Y 0x39 -#define MSA_REG_CUSTOM_OFFSET_Z 0x3a -#define MSA_REG_ENGINEERING_MODE 0x7f -#define MSA_REG_SENSITIVITY_TRIM_X 0x80 -#define MSA_REG_SENSITIVITY_TRIM_Y 0x81 -#define MSA_REG_SENSITIVITY_TRIM_Z 0x82 -#define MSA_REG_COARSE_OFFSET_TRIM_X 0x83 -#define MSA_REG_COARSE_OFFSET_TRIM_Y 0x84 -#define MSA_REG_COARSE_OFFSET_TRIM_Z 0x85 -#define MSA_REG_FINE_OFFSET_TRIM_X 0x86 -#define MSA_REG_FINE_OFFSET_TRIM_Y 0x87 -#define MSA_REG_FINE_OFFSET_TRIM_Z 0x88 -#define MSA_REG_SENS_COMP 0x8c -#define MSA_REG_MEMS_OPTION 0x8f -#define MSA_REG_CHIP_INFO 0xc0 -#define MSA_REG_CHIP_INFO_SECOND 0xc1 -#define MSA_REG_SENS_COARSE_TRIM 0xd1 - -/************* - -------------------------------------------------------------------- -Reg 0x0F(Resolution/Range):Read/Write -Bit7 Bit6 Bit5 Bit4 |Bit3 Bit2 |Bit1 Bit0 | Default - |RESOLUTION[1:0] | FS[1:0] | 0X00 - - -RESOLUTION[1:0]: resolution of x/y/z axes, -00:14bit, 01:12bit, 10:10bit, 11:8bit - - -FS[1:0]: acceleration range of x/y/z axes, -00:+/-2g, 01:+/-4g, 10:+/-8g, 11:+/-16g - - -*********/ -#define D_MSA_8BIT B0000_1100 -#define D_MSA_12BIT B0000_0100 -#define D_MSA_10BIT B0000_1000 -#define D_MSA_14BIT B0000_0000 - -#define D_MSA_16G B0000_0011 -#define D_MSA_8G B0000_0001 -#define D_MSA_4G B0000_0010 -#define D_MSA_2G B0000_0000 -/********** -ODR Output data rate 1 1000 Hz - -Reg0x10(ODR) :Read/Write Default 0X0F -Bit7 Bit6 Bit5 -X_AXIS_DIS Y_AXIS_DIS Z_AXIS_DIS -Bit4 -Bit3 Bit2 Bit1 Bit0 -ODR[3:0] - -X_AXIS_DIS: 0:enable, 1:disable Y_AXIS_DIS: 0:enable, 1:disable Z_AXIS_DIS: 0:enable, 1:disable -ODR[3:0]: -0000:1Hz (not available in normal mode) -0001:1.95Hz (not available in normal mode) -0010:3.9Hz 0011:7.81Hz -0100:15.63Hz 0101: 31.25Hz 0110: 62.5Hz 0111: 125Hz 1000: 250Hz -1001: 500Hz (not available in low power mode) -1010-1111: (not available in low power mode) - - -Table 5: bandwidth under different ODR and BW settings in normal mode -ODR BW -1000Hz (1010-1111) 500Hz -500Hz (1001) 250Hz -250Hz (1000) 125Hz -125Hz (0111) 62.5Hz -62.5Hz (0110) 31.25Hz -31.25Hz (0101) 15.63Hz -15.63Hz (0100) 7.81Hz -7.81Hz (0011) 3.9Hz -3.9Hz (0010) 1.95Hz -MSA300 supports four different acceleration measurement ranges, it is selected -ODR BW -15.63Hz (0100) 7.81Hz - -*********/ -/// fixme: 实测和规格书不一致 -#define D_AXIS_DIS_Y B1000_0000 -#define D_AXIS_DIS_X B0100_0000 -#define D_AXIS_DIS_Z B0010_0000 - -#define D_ODR_31Hz25 0x05 -#define D_ODR_250Hz 0x08 -#define D_ODR_125Hz 0x0f -#define D_ODR_15P63Hz B0000_0100 - - - -/********** -Reg0x11(Power Mode/Bandwidth) : Read/Write ------------------------------------------------------------------- -Bit7 Bit6 |Bit5 Bit4 Bit3 Bit2 Bit1 |Bit0 Default 0X9E ----------------------------------------------------------------------- -PWR_MODE | LOW_POWER_BW[3:0] | --------------------------------------------------------------------- -PWR_MODE: 00:normal mode, 01:low power mode, 10/11 suspend mode -LOW_POWER_BW[3:0]: -0000-0010:1.95Hz -0011:3.9Hz, -0100:7.81Hz -0101:15.63Hz, -0110: 31.25Hz, -0111: 62.5Hz, -1000: 125Hz, -1001: 250Hz, -1010-1111:500Hz -***********/ -//#define D_PowerMode_normal 0x00 -//#define D_PowerMode_low 0x40 -//#define D_PowerMode_suspend 0x80 -#define D_lowPower_BW (0x0F<<1) - -#define D_PowerMode_normal 0x1e -#define D_PowerMode_suspend 0x9e - -#define D_gs_LPBW1H9 (0<<1) -#define D_gs_LPBW3H9 (3<<1) -#define D_gs_LPBW7H8 (4<<1) -#define D_gs_LPBW15H (5<<1) -#define D_gs_LPBW31H (6<<1) -#define D_gs_LPBW62H (7<<1) -#define D_gs_LPBW125H (8<<1) -#define D_gs_LPBW250H (9<<1) -#define D_gs_LPBW500H (10<<1) - - -///#define D_PowerMode_low 0x5e - -#define D_PowerMode_low (0x50|D_gs_LPBW1H9) -//#define D_PowerMode_low 0x5e///(0x40|D_gs_LPBW62H) - -#define LD_gsensor_power(Pmode) L2_I2C_WriteCmd(D_i2c_addr_Gsensor,MSA_REG_POWERMODE_BW,Pmode);s_as.power=Pmode - - -/********** - - -/************************************** -Reg 0x1B (Int_Map_2) :Read/Write -Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 Default - -Bit6 INT2_ORIENT -Bit5 INT2_S_TAP -Bit4 INT2_D_TAP -Bit2 INT2_ACTIVE -Bit1 RESERVED -Bit0 INT2_FREEFALL -0X00 -INT2_ORIENT: map orientation interrupt to INT2, 0:disable, 1:enable INT2_S_TAP: map single tap interrupt to INT2, 0:disable, 1:enable INT2_D_TAP: map double tap interrupt to INT2, 0:disable, 1:enable INT2_ACTIVE: map active interrupt to INT2, 0:disable, 1:enable INT2_FREEFALL: map freefall interrupt to INT2, 0:disable, 1:enable -***************************************/ -#define D_INT2_ORIENT BITN6 -#define D_INT2_S_TAP BITN5 -#define D_INT2_D_TAP BITN4 -#define D_INT2_ACTIVE BITN2 -#define D_INT2_FREEFALL BITN1 -/********************************************** - -Reg 0x20 (Int_Map_2) :Read/Write -Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 Default 0X00 -Bit3 INT2_OD -Bit2 NT2_LVL -Bit1 IINT1_OD -Bit0 INT1_LVL -INT2_OD: select output for INT2, 0: push-pull, 1:OD -INT2_LVL: select active level for INT2, 0: low, 1:high -INT1_OD: select output for INT1, 0: push-pull, 1:OD -INT1_LVL: select active level for INT1, 0: low, 1:high -***************************************/ -#define D_INT2_pull 0 -#define D_INT2_OD BITN3 -#define D_INT2_LVL_high BITN2 -#define D_INT2_LVL_low 0 - - -#define D_INT1_pull 0 -#define D_INT1_OD BITN1 -#define D_INT1_LVL_high BITN0 -#define D_INT1_LVL_low 0 - - - -/************************************************************* - - U51(SDO=1) int2 P33 ----------------U10(SDO=0) int2 P32----------------MCU----USB - 0x4c 0x4e - AS1 AS2 - --------------------------------------------------------------------- -Reg 0x16(Int_Set_0) : Read/Write -Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 Default 0X00 -------------------------------------------------------------------- -象限应该 是 方位识别 -Tap 功能 -双击和单击 -使能单击 s_tap_en 使能双击d_tap_en -中断状态保存: )s_tap_int , d_tap_int -通过检查加速度斜率是否超过设定的阈值来判断是否有单击事件 - -Bit6 ORIENT_INT_EN -Bit5 S_TAP_INT_EN -Bit4 D_TAP_INT_EN -Bit2 ACTIVE_INT_EN_Z -Bit1 ACTIVE_INT_EN_Y -Bit0 ACTIVE_INT_EN_X - -------------------------------------------------------------------- -ORIENT_INT_EN: orient interrupt, 0:disable, 1:enable -S_TAP_INT_EN: single tap interrupt, 0:disable, 1:enable -D_TAP_INT_EN: double tap interrupt, 0:disable, 1:enable -ACTIVE_INT_EN_Z: active interrupt for the z axis, 0:disable, 1:enable -ACTIVE_INT_EN_Y: active interrupt for the y axis, 0:disable, 1:enable -ACTIVE_INT_EN_X: active interrupt for the x axis, 0:disable, 1:enable - - -reg 0x16对应的Reg 0x19 -------------------------------------------------------------------- -Reg 0x19(Int_Map_0) : Read/Write -Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 Default -------------------------------------------------------------------- - INT1_ORIENT - INT1_S_TAP - INT1_D_TAP - INT1_ACTIVE - INT1_FREEFALL - 0X00 -------------------------------------------------------------------- -INT1_ORIENT: map orientation interrupt to INT1, 0:disable, 1:enable -INT1_S_TAP: map single tap interrupt to INT1, 0:disable, 1:enable -INT1_D_TAP: map double tap interrupt to INT1, 0:disable, 1:enable -INT1_ACTIVE: map active interrupt to INT1, 0:disable, 1:enable -INT1_FREEFALL: map freefall interrupt to INT1, 0:disable, 1:enable - - -------------------------------------------------------------------- -Reg 0x27 (Active_Dur) : Read/Write -Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 Default - ACTIVE_DUR[1:0] 0X00 -ACTIVE_DUR[1:0]: active duration time is (ACTIVE_DUR[1:0]+1)ms -------------------------------------------------------------------- -Reg 0x28(Active_Th) : Read/Write - -Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 Default -ACTIVE_TH[7:0] 0X14 -ACTIVE_TH[7:0]: threshold of active interrupt -3.91mg/LSB(2g range) -7.81mg/LSB(4g range) -15.625mg/LSB(8g range) -31.25mg/LSB(16g range) - - - -**************************************************************************/ - -#define ACTIVE_INT_EN_Z BITN2 -#define ACTIVE_INT_EN_Y BITN1 -#define ACTIVE_INT_EN_X BITN0 - - -/*************************************** -0x21 RESET_INT LATCH_INT[3:0] 0x00 - latch_int Interrupt mode - 0000 non-latched - 0001 temporary latched 250ms - 0010 temporary latched 500ms - 0011 temporary latched 1s - 0100 temporary latched 2s - 0101 temporary latched 4s - 0110 temporary latched 8s - 0111 Latched - 1000 non-latched - 1001 temporary latched 1ms - 1010 temporary latched 1ms - 1011 temporary latched 2ms - 1100 temporary latched 25ms - 1101 temporary latched 50ms - 1110 temporary latched 100ms - 1111 Latched - - _______/``latch period````\_______ -****************************************/ -#define D_no_latched 0x01 -#define D_latch_250ms 0x01 -#define D_latch_500ms 0x02 -#define D_latch_1s 0x03 -#define D_latch_2s 0x04 -#define D_latch_4s 0x05 -#define D_latch_8s 0x06 -#define D_latched 0x07 -#define D_no_latched2 0x08 -#define D_latch_1ms 0x09 -#define D_latch_1ms2 0x0a -#define D_latch_2ms 0x0B -#define D_latch_25ms 0x0C -#define D_latch_50ms 0x0D -#define D_latch_100ms 0x0E -#define D_latched2 0x0f - -/**************************************************** -Reg 0x09(Motion_Interrupt) :Read only -Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 Default 0X00 -Bit6 ORIENT_INT -Bit5 S_TAP_INT -Bit4 D_TAP_INT -Bit2 ACTIVE_INT -Bit0 FREEFALL_INT -运输的时候不停的动怎么办 需要方位判定?? -如果图像不是黑暗中 则 -运输的动静大 需要关闭 -也就是有大的动静时需要5s以上之后再工作 如果动静大 再休息5秒 这样把耗电 -降到最小 - -ORIENT_INT: orientation interrupt status,0:inactive,1:active -S_TAP_INT: single tap interrupt status,0:inactive,1:active -D_TAP_INT: double tap interrupt status,0:inactive,1:active -ACTIVE_INT: active interrupt status,0:inactive,1:active -FREEFALL_INT: freefall interrupt status,0:inactive,1:active -------------------------------------------------------------------- -Reg 0x0B(Tape_Active_Status) :Read only -Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 Default -TAP_SIGN - TAP_FIRST_X - TAP_FIRST_Y - TAP_FIRST_Z - ACTIVE_SIGN - ACTIVE_FIRST_X - ACTIVE_FIRST_Y - ACTIVE_FIRST_Z - 0X00 -------------------------------------------------------------------- -TAP_SIGN: sign of tap triggering signal, 0:positive,1:negative -TAP_FIRST_X: tap interrupt triggered by x axis, 1:positive,0:negative -TAP_FIRST_Y: tap interrupt triggered by y axis, 1:positive,0:negative -TAP_FIRST_Z: tap interrupt triggered by z axis, 1:positive,0:negative -ACTIVE_SIGN: sign of active interrupt, 0:positive,1:negative -ACTIVE_FIRST_X: active interrupt triggered by x axis, 1:positive,0:negative -ACTIVE_FIRST_Y: active interrupt triggered by y axis, 1:positive,0:negative -ACTIVE_FIRST_Z: active interrupt triggered by z axis, 1:positive,0:negative - - -***************************************************/ - -#define INT1_S_TAP_INT BITN5 ///单击中断 -#define INT1_D_TAP_INT BITN4 ///双击中断 -#define INT1_ACTIVE BITN2 /// 振动中断 - -#define D_Active_TH 0x28 -#define D_Active_Dur 0x27 - - -#define D_i2c_addr_AS1 0x4c // u51 -#define D_i2c_addr_AS2 0x4e - - -#define D_i2c_addr_Gsensor 0x4c // u51 - - -#define D_i2c_addr_AS1 0x4c // u51 -#define D_i2c_addr_AS2 0x4e - -/******************************************************************************/ -/***************************** Include Files **********************************/ -/******************************************************************************/ - -// 最高400Khz 1/400 ms 2.5us - -//Symbol Parameter Condition Min Max Unit -//fscl Clock frequency 400 kHz -#define D_as_ch_mun 1 -struct _s_gsens_ -{//8byte - U8 d[6]; -// U8 reg_action; - U8 power; -// U8 reg_temp; -// U8 action_ok; - - // U16 x; - // U16 y; - // U16 z; - -}; -extern struct _s_gsens_ s_as; -extern void L1_as_readXYZ(unsigned char CH); -extern void L1_msa300_init(void); -extern void L3_msa300_fun(U8 *pPara); -extern void L1_as_action(void); - -extern void L1_as_WorkStatus(unsigned char d); -///L1_msa300_power(D_sleep); -extern void L1_msa300_power(U8 mode); - -#define L1_ms300_reg_set(x,y) L2_I2C_WriteCmd(D_i2c_addr_Gsensor, (x),(y) ) -#define L1_ms300_reg_get(x,y) L2_I2C_ReadReg(D_i2c_addr_Gsensor,(x),1) -#define DL_ms300_int_open(); L1_ms300_reg_set(MSA_REG_INTERRUPT_MAPPING3,D_INT2_S_TAP|D_INT2_ACTIVE); -#define DL_ms300_int_close(); L1_ms300_reg_set(MSA_REG_INTERRUPT_MAPPING3,0); - - - - -#endif // #ifndef _MSA300_H - - - diff --git a/source/bsp/backu/cw63xx.c b/source/bsp/backu/cw63xx.c deleted file mode 100644 index c171c3e..0000000 --- a/source/bsp/backu/cw63xx.c +++ /dev/null @@ -1,191 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2017, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file cw63xx.c -/// @brief cw630x driver app -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20170122 -/// @note cc_AS_stc01 - -/// @version 1.1 -/// @author CC -/// @date 20170619 -/// @note for - - -////////////////////////////////////////////////////////////////////////////// - -#include "cw63xx.h" -//#include "../debug/debug_drv.h" -#include "../msp/iic_sim.h" -#include "../msp/uart0.h" -//#include "msa300.h" - -///------------------------------------------------------------------------- -/// @breif L1_cw63xx_init -/// @param a s_task_PWON -/// @param s "L1_cw63xx_init" -/// @return none -/// @see Test() (本函数参考其它的相关的函数,这里作一个链接) -/// @note (note描述需要注意的问题) -///------------------------------------------------------------------------- -#define D_lowPower_warnning 0x02 -#define D_lowPower_BAT_FULL 0x08 - - - - -/***************************** - -if(BITN_G(I2CTXD,BITN1)) - -CHG_IN:如果 DCIN 有 5V 电源接入,则检测到充电并触发中断,寄存器 0x03[5]由 0 变成 1。 -BAT_FULL:如果电池充满电,电流变为 0,则触发中断,寄存器 0x03[4]由 0 变成 1。 -BAT_OT:如果电池温度过高(默认值 60℃左右),则触发中断并停止充电,寄存器 0x03[3]由 0 变成1。 -BAT_UT:如果电池温度过低(默认值 0℃左右),则触发中断并停止充电,寄存器 0x03[2]由 0 变成1。 -LOW_BAT:如果电池电压低于告警值时(默认为 3.4V),则触发中断,寄存器 0x03[1]由 0 变成 1。 -BUTTON:按键按下,会触发一个中断,寄存器 0x03[0]由 0 变成 1 - -实际中,去掉电池后产生的是 BAT_FULL中断。 - -***************************/ -void L1_cw63xx_sta(void) -{ - U8 d; - L2_I2C_ReadReg(D_i2c_addr_cw63xx,D_CW63X_REG_Interrupt,&d,1); - if(BITN_G(d, BITN1))///收到低电压警告 - { - I2CTXD = 1; - } - - if(BITN_G(d, BITN4))///只有充满电后才低压标志被清零 - { - I2CTXD = 0; - } - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_Interrupt,0); -} -#if 0 -void L1_cw63xx_init(void) -{ - U8 val = 0; - // LDO1 LDO2 LDO3 LDO4 - #if 0 - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_LDO1,D_CW63XX_ON|D_CW63XX_3V2); // 进入normal 模式 - Lc_delay_ms(100);// 2000--7s - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_LDO2,D_CW63XX_ON|D_CW63XX_3V2); // 打开 LDO1 并设置为1.8v - Lc_delay_ms(100); - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_LDO3,D_CW63XX_ON|D_CW63XX_3V2); // 进入normal 模式 - Lc_delay_ms(100);// 2000--7s - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_LDO4,D_CW63XX_ON|D_CW63XX_3V2); // 打开 LDO1 并设置为1.8v -//#else - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC,D_CW63XX_ON|D_CW63XX_2V5); // mcu gsensor - Lc_delay_ms(10);// 2000--7s - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC1,D_CW63XX_ON|D_CW63XX_3V); // uart4 sed ch430 mcu_program - Lc_delay_ms(10); - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC2,D_CW63XX_ON|D_CW63XX_2V5); //uart 4 receive - Lc_delay_ms(10);// 2000--7s - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC3,D_CW63XX_ON|D_CW63XX_2V5); // 设置 AS cpu 供电2.5v - - //L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC2,D_CW63XX_ON|D_CW63XX_1V8); // 设置 AS cpu 供电2.5v - //Lc_delay_ms(600); - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC3,D_CW63XX_ON|D_CW63XX_2V8); // 设置 AS cpu 供电2.5v - Lc_delay_ms(10); - - #endif - - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_Charge,0x3F);///150mA CHARGE - ///L2_I2C_ReadReg(D_i2c_addr_cw63xx,D_CW63X_REG_Charge,&val,1); -// L0_uart0_uchex(val); -// Lc_delay_ms(10); - //// Lc_delay_ms(10); - //// L2_I2C_ReadReg(D_i2c_addr_cw63xx,D_CW63X_REG_Charge,&val,1); - //// L0_uart0_uc(val); - //// Lc_delay_ms(10); - /****************** - while(9) - { - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC2,D_CW63XX_ON|D_CW63XX_2V8); L0_uart0_uc('e'); - Lc_delay_ms(30); - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_VCC2,D_CW63XX_OFF|D_CW63XX_2V8); - Lc_delay_ms(30); - - } -*****************/ - -///-------------------------------------------------------------------- -// L2_I2C_ReadReg(D_i2c_addr_cw63xx,D_CW63X_REG_LDO1,s_as1.d,4);// press -// L0_uart0_uchex(s_as1.d[0]); L0_uart0_uchex(s_as1.d[1]); L0_uart0_uchex(s_as1.d[2]); L0_uart0_uchex(s_as1.d[3]); - -} - -void L3_cw63xx_fun(U8 *pPara) -{ -*pPara=0; -} - -///#else - -//// FX CMD R2 R3 4 -void L3_cw63xx_fun(U8 *pPara) -{ - U8 val = 0; - TS_P_debug *p = pPara; - switch(p->cmd) - { - /********** - case 0: - L1_cw63xx_init(); - L0_uart0_uc('C'); - L0_uart0_uc(p->R1); - L0_uart0_uc(p->R2); - L0_uart0_uc(p->R3); - break; - ***********/ - case 1: //// - //// AX CMDR2 R3 R4 - /// AD 01 01 03 04 读取reg 01的数值 - //void L2_I2C_ReadReg(unsigned char sla,unsigned char reg, - // unsigned char *r,unsigned char n) - L2_I2C_ReadReg(D_i2c_addr_cw63xx,p->R2,&val,1); - L0_uart0_uc(val); - break; - - - case 2: //FD 02 03 04 00 - ///aD 02 0A 38 00 //vcc1 off - ///aD 02 0A B8 00 //vcc1 ON - ///FD 02 0B 04 00 B0011_1000 - ///FD 02 0C 04 00 - ///FD 02 01 3a 00 100mA充电 - - L0_uart0_uc('W'); - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,p->R2,p->R3); - //L0_uart0_uc(pPara[2]); - - L0_uart0_uc(p->R2); - L0_uart0_uc(p->R3); - break; - - - default: - break; - }; -} - -L2_I2C_ReadReg(D_i2c_addr_cw63xx,0,s_as.d,4); -L0_uart0_sendArray(s_as.d,4); -L2_I2C_WriteCmd(D_i2c_addr_cw63xx,0x03,0);////读完中断后需要写零才能清空中断 -CHG_IN:如果 DCIN 有 5V 电源接入,则检测到充电并触发中断,寄存器 0x03[5]由 0 变成 1。 -BAT_FULL:如果电池充满电,电流变为 0,则触发中断,寄存器 0x03[4]由 0 变成 1。 -BAT_OT:如果电池温度过高(默认值 60℃左右),则触发中断并停止充电,寄存器 0x03[3]由 0 变成1。 -BAT_UT:如果电池温度过低(默认值 0℃左右),则触发中断并停止充电,寄存器 0x03[2]由 0 变成1。 -LOW_BAT:如果电池电压低于告警值时(默认为 3.4V),则触发中断,寄存器 0x03[1]由 0 变成 1。 -BUTTON:按键按下,会触发一个中断,寄存器 0x03[0]由 0 变成 1 - -实际中,去掉电池后产生的是 BAT_FULL中断。 - -#endif - - diff --git a/source/bsp/backu/cw63xx.h b/source/bsp/backu/cw63xx.h deleted file mode 100644 index 5b741bb..0000000 --- a/source/bsp/backu/cw63xx.h +++ /dev/null @@ -1,123 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2017, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file msa300.c -/// @brief msa300 driver app -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20170122 -/// @note cc_AS_stc01 -////////////////////////////////////////////////////////////////////////////// - -#ifndef _cw63xx_H -#define _cw63xx_H - -#define D_i2c_addr_cw63xx 0x12 - - -#include "../msp/iic_sim.h" -//#include "../bsp/type_hs.h" -///-------------------------------------------------------------------- -#define D_CW63X_REG_system 0X00 -#define D_CW63X_REG_Charge 0X01 -#define D_CW63X_EN_NTC BITN7 ///Enable NTC check -#define D_CW63X_EN_CHG BITN6 /// Enable charging -#define D_CW63X_EN_TIMER BITN5 // Enalble charging timer - -// in power-off state,the IC will turn off LDO1,2,3,B ut hte LDORTC/LDO4 will remain on -#define D_CW63X_power_off 0x0a -//L1_cw63xx_set(D_CW63X_REG_Safety,D_CW63X_EN_NTC|D_CW63X_EN_CHG|D_CW63X_EN_TIMER|D_CW63X_power_off); -//L1_cw63xx_set(D_CW63X_REG_Safety,D_CW63X_EN_NTC|D_CW63X_EN_CHG|D_CW63X_EN_TIMER); - -///-------------------------------------------------------------------- - -#define D_CW63X_REG_Safety 0X02 -#define D_CW63X_LowBateryThreshold 0 -#define L0_set_LBT(x) ((x) - 28) -// L0_set_LBT(28) -/// L1_cw63xx_set(D_CW63X_REG_Safety,L0_set_LBT(28));/// 2.8v报警 -/// fixme 依靠这个实现电源的测量 -///-------------------------------------------------------------------- -#define D_CW63X_REG_Interrupt 0X03 -#define D_CW63X_REG_Interrupt_type 0X04 -#define D_CW63X_INT_CHG_OUT BITN7 ///Charging unplugged -#define D_CW63X_INT_TIMER_EXPIRE BITN6 ///Charging timer expire -#define D_CW63X_INT_CHG_INT BITN5 ///Charger detected -#define D_CW63X_INT_BAT_FULL BITN4 ///Battery full - -#define D_CW63X_INT_BAT_OT BITN3 ///Battery over temperature -#define D_CW63X_INT_BAT_UT BITN2 ///Battery under temperature -#define D_CW63X_INT_LOW_BAT BITN1 ///Battery low voltage -#define D_CW63X_INT_BUTTON BITN0 ///button detected - -///-------------------------------------------------------------------- - -#define D_CW63X_REG_LDO1 0X0A -#define D_CW63X_REG_LDO2 0X0B -#define D_CW63X_REG_LDO3 0X0C -#define D_CW63X_REG_LDO4 0X0D - - -//// reg[]543] reg[210] -//// 54 3 -//// || |210 -#define D_CW63XX_V800 B0000_0000 -#define D_CW63XX_V975 B0000_0111 -#define D_CW63XX_1V4 B0001_0100 - - -#define D_CW63XX_1V8 B0001_1100 -#define D_CW63XX_2V1 B0011_0001 -#define D_CW63XX_2V5 B0011_0101 -#define D_CW63XX_2V8 B0011_1000 -#define D_CW63XX_3V B0011_1010 -#define D_CW63XX_3V2 B0011_1100 - -#define D_CW63XX_ON B1000_0000 -#define D_CW63XX_OFF B0000_0000 - - -////extern void L1_cw63xx_init(void); -extern void L3_cw63xx_fun(U8 *pPara); -extern void L1_cw63xx_sta(void); - -///debug 使用U8 -////ine L3_cw63xx_fun(x); - - -///--------------------------------- - - - - - -#define D_power_VCC1 D_CW63X_REG_LDO1 -#define D_power_VCC2 D_CW63X_REG_LDO2 -#define D_power_VCC3 D_CW63X_REG_LDO3 -#define D_power_VCC D_CW63X_REG_LDO4 -/* -#define D_power_rf_Rxd D_power_VCC2 /// rf接收模块 -#define D_power_rf_Txd D_power_VCC1 /// rf 发送模块 - -#define D_power_AS D_power_VCC3 /// AS模块 - -#define L2_power_AS_OFF(); L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_AS,D_CW63XX_OFF|D_CW63XX_3V); -#define L2_power_AS_ON(); L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_AS,D_CW63XX_ON|D_CW63XX_3V); -#define L2_power_rf_Rxd_OFF(); L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_rf_Rxd,D_CW63XX_OFF|D_CW63XX_3V); -#define L2_power_rf_Rxd_ON(); L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_rf_Rxd,D_CW63XX_ON|D_CW63XX_3V); - -//#define L2_power_rf_Txd_OFF(); //L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_rf_Txd,D_CW63XX_OFF|D_CW63XX_3V); -//#define L2_power_rf_Txd_ON(); //L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_rf_Txd,D_CW63XX_ON|D_CW63XX_3V); - -/// fixme for the -#define L2_power_rf_Txd_OFF(); //L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_rf_Rxd,D_CW63XX_OFF|D_CW63XX_3V); -#define L2_power_rf_Txd_ON(); //L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_power_rf_Rxd,D_CW63XX_ON|D_CW63XX_3V); -*/ - -#define L1_cw63xx_init() L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_Charge,0x3F);\ - L2_I2C_WriteCmd(D_i2c_addr_cw63xx,D_CW63X_REG_Safety,0x05);///n3.3v baongjin - - -#endif // #ifndef _cw63xx_H - diff --git a/source/bsp/board support/msa300.c b/source/bsp/board support/msa300.c deleted file mode 100644 index 85331b9..0000000 --- a/source/bsp/board support/msa300.c +++ /dev/null @@ -1,75 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2017, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file msa300.c -/// @brief msa300 driver app -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20170122 -/// @note cc_AS_stc01 -////////////////////////////////////////////////////////////////////////////// - - - -/******************************************************************************/ -/***************************** Include Files **********************************/ -/******************************************************************************/ -#include "msa300.h" -struct _s_gsens_ s_as1,s_as2; -void L1_msa300_init(void) -{ - /// 上电后是standby 模式 需要设置 - L2_I2C_WriteCmd(D_i2c_addr_AS1,0x11,0x1e); // 进入normal 模式 - L2_I2C_WriteCmd(D_i2c_addr_AS2,0x11,0x1e); // 进入normal 模式 - -} - -void L1_as1_readXYZ(void) -{ -///read data -//S ADD W A REG A -//S ADD R A D1 A D2 A.....DX N P - L2_I2C_ReadReg(D_i2c_addr_AS1,0x02,(unsigned char *)&s_as1,6); -// L2_I2C_ReadReg(D_i2c_addr_AS2,0,(unsigned char *)&s_as2,3); -} - -void L1_as2_readXYZ(void) -{ -///read data -//S ADD W A REG A -//S ADD R A D1 A D2 A.....DX N P - L2_I2C_ReadReg(D_i2c_addr_AS2,0x02,(unsigned char *)&s_as2,6); -} - - - - - - -#if 0 - -L2_I2C_ReadReg(D_i2c_addr_HP303B,0x0d,d,1); - L0_MUART_uc(d[0]); -L2_I2C_ReadReg(D_i2c_addr_AS1,0x05,d,1);// 11 =0f - L0_MUART_uc(d[0]); -L2_I2C_ReadReg(D_i2c_addr_AS2,0x05,d,1);//10 =0f - L0_MUART_uc(d[0]); - - - L1_as1_readXYZ(); - s_p_rf.ucR1 = (U8)(s_as1.x>>8); - s_p_rf.ucR2 = (U8)(s_as1.y>>8); - s_p_rf.ucR3 = (U8)(s_as1.z>>8); -p = (U8*)&s_p_rf; - - L0_MUART_uc(s_p_rf.ucR1); - L0_MUART_uc(s_p_rf.ucR2); - L0_MUART_uc(s_p_rf.ucR3); - L0_MUART_uc(0xc7); - - -#endif - - - diff --git a/source/bsp/board support/msa300.h b/source/bsp/board support/msa300.h deleted file mode 100644 index 34b0714..0000000 --- a/source/bsp/board support/msa300.h +++ /dev/null @@ -1,63 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2017, 传控科技 All rights reserved. -///------------------------------------------------------------------------- -/// @file msa300.c -/// @brief msa300 driver app -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20170122 -/// @note cc_AS_stc01 -////////////////////////////////////////////////////////////////////////////// - - - -#ifndef _MSA300_H -#define _MSA300_H - - -#include "../msp/iic_sim.h" - - - - -/*********************************************************************** - - U51(SDO=1) int2 P33 ----------------U10(SDO=0) int2 P32----------------MCU----USB - 0x4c 0x4e - AS1 AS2 - -**************************************************************************/ - - -#define D_i2c_addr_AS1 0x4c // u51 -#define D_i2c_addr_AS2 0x4e - -/******************************************************************************/ -/***************************** Include Files **********************************/ -/******************************************************************************/ - -// 最高400Khz 1/400 ms 2.5us - -//Symbol Parameter Condition Min Max Unit -//fscl Clock frequency 400 kHz - -struct _s_gsens_ -{//8byte - - U8 d[6]; - // U16 x; - // U16 y; - // U16 z; - -}; -extern struct _s_gsens_ s_as1,s_as2; - -extern void L1_as1_readXYZ(void); -extern void L1_as2_readXYZ(void); -extern void L1_msa300_init(void); - -#endif // #ifndef _MSA300_H - - - diff --git a/source/bsp/bsp_config.c b/source/bsp/bsp_config.c index 9145292..33f0363 100644 --- a/source/bsp/bsp_config.c +++ b/source/bsp/bsp_config.c @@ -1,5 +1,6 @@ #include "bsp_config.h" -#include "../tpc/tpc_modbus.h" +#include "../msp/UART0.h" +#include "../msp/eeprom.h" //////////////////////////////////////////////////////////////////////////// ///@copyright Copyright (c) 2018, 浼犳帶绉戞妧 All rights reserved. @@ -15,58 +16,6 @@ ////////////////////////////////////////////////////////////////////////////// //struct _s_sysclk s_sysclk; -GlobalRegister R; - -void L0_reg_reset() -{ - U8 i = 0; - //R.p.reset = 0; - R.p.adc_ch_status = ADC_status_ch2_Ready | ADC_status_ch3_Ready | ADC_status_ch4_Ready; //淇敼閲囬泦閫氶亾 - R.p.slaver_id = D_UART0_485_SLAVER_ID; - //R.p.zero = 0; - R.p.weight_max = 500; //500kg - R.p.lmd = 2; //2mv/v - - R.p.cc_blur_ch_avg = 6; - R.p.cc_blur_ch_shift = 2; - R.p.cc_blur_all_shift0 = 2; - R.p.cc_blur_all_shift1 = 4; - R.p.cc_blur_all_out_d_threshold = 200; //0.2kg - R.p.cc_blur_all_out_dd_threshold = 200; //0.2kg - - for(i=0;i +#include "../bsp/bsp_config_const.h" #include "../clib/type.h" #include "../clib/bit.h" -//>>>>>>>>>>>>>>>>>>>>>>.BORAD TYPE -#define TYPE_BOARD_hhnew 1 -#define TYPE_BOARD_st_sleep04_01 4 -#define TYPE_BOARD_st_sleep03 5 -#define TYPE_BOARD_SMMM_MB_VH032_0E 6 -#define TYPE_BOARD_LPC17xx_ 8 -#define TYPE_BOARD_STM32F_103ZET6_READBULL 1036 -#define TYPE_BOARD_hh_CC_MD_VH05_anyriny_simple_m51 0x0551 -#define TYPE_BOARD_hh_CC_MD_VH06_asMain_m6a7 0x6a7 -#define TYPE_BOARD_TI26_MT01_M178 0x178 //浼氳璁℃椂鍣ㄧ増v TI26_MT01-M178 -#define TYPE_BOARD_stc5as32_WIFIBV01 532 -#define TYPE_BOARD_SHC16LAXXQN32 1632 //SHC16LAXXQN32 -#define TYPE_BOARD_PAPER6133_M0A6 0xa6 //鎵撳嵃鏈虹焊寮犱紶鎰 -#define TYPE_BOARD_GSM_MAIN_V07 0xa7 //鎵撳嵃鏈鸿繍缁存澘 -#define TYPE_BOARD_ADDA_MAIN_V02 0xa8 //ADDA -#define TYPE_BOARD_433_0A 0xa9 //433 -#define TYPE_BOARD_WEIGH_0B 0xaa //绉伴噸 -//<<<<<<<<<<<<<<<<<<<<<<<<<<<.BORAD TYPE end - -//>>>>>>>>>>>>>>>>>>>>>>MCU TYPE -#define TYPE_MCU_STC_8A 51 -#define TYPE_MCU_STC_8F 52 -#define TYPE_MCU_STC_8G 53 -#define TYPE_MCU_SHC6601 66 -#define TYPE_MCU_LPC17xx 3217 -#define TYPE_MCU_STM32 3232 - -#define D_CPUfamily_8bits 8 -#define D_CPUfamily_16bits 16 -#define D_CPUfamily_32bits 32 -//<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>IDE TYPE -#define TYPE_IDE_KEIL 1 -#define TYPE_IDE_MDK 2 -#define TYPE_IDE_IAR 3 -//<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>.SysTimer TYPE -#define TYPE_JIFFIES_5MS 1 -#define TYPE_JIFFIES_10MS 2 -#define TYPE_JIFFIES_25MS 3 -//<<<<<<<<<<<<<<<<<<<<<<<<<<<.SysTimer TYPE end - -//>>>>>>>>>>>>>>>>>>>>>>.WDT TYPE -#define TYPE_WDT_DISABLE 1 -#define TYPE_WDT_ENABLE 2 -#define WDT_FEED() WDT_CONTR |= 0x10 -//<<<<<<<<<<<<<<<<<<<<<<<<<<<.SysTimer TYPE end - -//>>>>>>>>>>>>>>>>>>>>>>.ByteOrder TYPE -#define TYPE_MCU_BIGENDIAN 1 -#define TYPE_MCU_LITENDIAN 2 -//<<<<<<<<<<<<<<<<<<<<<<<<<<<.ByteOrder TYPE end - -//>>>>>>>>>>>>>>>>>>>>>>BUADRATE & StopBit -#define SBIT_1 1 //1 stop bit -#define SBIT_2 2 //2 stop bit -#define BRT_115200 115200 -#define BRT_19200 19200 -#define BRT_9600 9600 -#define BRT_4800 4800 -//<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>MainFre -#define MainFre_5M 5529600L -#define MainFre_11M 11059200L -#define MainFre_22M 22118400L -#define MainFre_24M 24000000L -#define MainFre_27M 27000000L -//<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>UART0 PIN -#define PIN_UART0_Rxd_30_Txd_31 1 -#define PIN_UART0_Rxd_36_Txd_37 2 -#define PIN_UART0_Rxd_16_Txd_17 3 -#define PIN_UART0_Rxd_43_Txd_44 4 -//<<<<<<<<<<<<<<<<<<<<<<<<<<<.UART0 PIN - -//>>>>>>>>>>>>>>>>>>>>>>485 Type -#define TYPE_485_NONE 0 -#define TYPE_485_MASTER 1 -#define TYPE_485_SLAVER 2 -//<<<<<<<<<<<<<<<<<<<<<<485 Type end - -//>>>>>>>>>>>>>>>>>>>>>>G-SENSOR TYPE -#define TYPE_ASENSOR_ADXL362 362 -#define TYPE_ASENSOR_MSA300 300 -#define TYPE_ASENSOR TYPE_ASENSOR_MSA300 -//<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +//STEP 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>TYPE_UASER_BOARD SELECT #define TYPE_UASER_BOARD TYPE_BOARD_WEIGH_0B +//STEP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + +//STEP 2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>TYPE_UASER_BOARD CONFIG #if(TYPE_UASER_BOARD == TYPE_BOARD_WEIGH_0B) - #include - #include #include - #include "../cpu/stc_stc8f.h" + #include "../cpu/stc_stc8hxx.h" #include "../cpu/stc_macro.h" //鍩烘湰閰嶇疆(宸ヤ綔棰戠巼銆佹椂閽熴佺湅闂ㄧ嫍銆佸瓧鑺傚簭) - #define TYPE_MCU TYPE_MCU_STC_8F + #define TYPE_MCU TYPE_MCU_STC_8H #define TYPE_IDE TYPE_IDE_KEIL #define D_CPUfamily_type D_CPUfamily_8bits - #define D_sys_MainFre MainFre_11M + #define D_sys_MainFre MainFre_22M #define D_sys_Jiffies TYPE_JIFFIES_10MS #define D_WDT_STATUS TYPE_WDT_DISABLE //濡傛灉閰嶇疆涓篹nable锛岃鍦╞sp_config.c涓缃畐dt婧㈠嚭鏃堕棿 #define D_MCU_ENDIAN TYPE_MCU_BIGENDIAN + #define D_CODE_ENCRYPTION_TYPE TYPE_ENCRYPTION_ENABLE //鏄惁浠g爜鍔犲瘑 + + + #define D_MCU_NAME "STC8H3K48S4" + //瀛樺偍鍣ㄧ壒娈婂弬鏁板湴鍧閰嶇疆 + #define D_MCU_SPEC_PARAM_CHIPID 0xBFF9 + //...鍏朵粬鍙傛暟 //涓插彛閰嶇疆 #define D_uart0_BRT BRT_115200 @@ -151,8 +92,8 @@ #define D_UART0_485_TYPE TYPE_485_SLAVER //UART0鍚敤485 #define D_UART0_485_SLAVER_ID_BROADCAST 0xFF //485浠庢満鎬绘槸鍝嶅簲0xFF娑堟伅 #define D_UART0_485_SLAVER_ID 0x01 //鏉垮崱浣滀负485浠庢満 slaverId - #define D_UART0_485_TX() P32 = 1; - #define D_UART0_485_RX() P32 = 0; + #define D_UART0_485_TX() P55 = 1; + #define D_UART0_485_RX() P55 = 0; #define D_UART2_485_TYPE TYPE_485_NONE //UART2涓嶅惎鐢485 #define D_UART3_485_TYPE TYPE_485_NONE //UART2涓嶅惎鐢485 #define D_UART4_485_TYPE TYPE_485_NONE //UART2涓嶅惎鐢485 @@ -163,111 +104,38 @@ #define D_MODBUS_REG_MAX_NUM 32 //姣忔鏈澶氳鍙/鍐欏叆鐨勫瘎瀛樺櫒鏁伴噺锛屾澶勭殑鏁伴噺瑕佹敞鎰忓拰 D_tp_handle_x_len 瀵瑰簲 //澶栬瀹氫箟 - #define LED0 P10 //D4 - #define LED1 P35 //D4 + #define LED0 P17 //D4 + #define LED1 P54 //D4 //EEP瀛樺偍鍦板潃瀹氫箟 - #define D_EEP_SECTOR_SIZE 0x200 - #define D_EEP_PARAM_ADDR (D_EEP_SECTOR_SIZE * 0) //eeprom鍙傛暟鍖烘墖鍖哄湴鍧 - - #if(MainFre_5M == D_sys_MainFre) - #define D_Cdelay_200us 20 - #define D_Cdelay_1us 1 ////while p21缈昏浆鏃舵祴瀹 500k 2us 涓涓寚浠 - #elif(MainFre_22M == D_sys_MainFre) - #define D_Cdelay_200us 20 - #define D_Cdelay_1us 1 ////while p21缈昏浆鏃舵祴瀹 500k 2us 涓涓寚浠 - #define D_Cdelay_1us 1 ////while p21缈昏浆鏃舵祴瀹 500k 2us 涓涓寚浠 - #define L0_delay_1us() Lc_delay_nop(0) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us - #define L0_delay_10us() Lc_delay_nop(4) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us - #define L0_delay_40us() Lc_delay_nop(18) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us - #elif(MainFre_27M == D_sys_MainFre) - #define D_Cdelay_200us 20 - #define D_Cdelay_1us 1 ////while p21缈昏浆鏃舵祴瀹 500k 2us 涓涓寚浠 - #else ///MainFre_11M - #define D_Cdelay_200us 20 - #define D_Cdelay_1us 1 ////while p21缈昏浆鏃舵祴瀹 500k 2us 涓涓寚浠 - #define L0_delay_1us() Lc_delay_nop(0) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us - #define L0_delay_10us() Lc_delay_nop(4) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us - #define L0_delay_40us() Lc_delay_nop(18) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us - //xx - #endif//D_sys_MainFre) - -#elif(TYPE_UASER_BOARD == TYPE_BOARD_433_0A) + #define D_EEP_SECTOR_SIZE 0x200 //姣忎釜鎵囧尯0x200==512bytes + #define D_EEP_SECTOR_BLOCK_SIZE 0x40 //鎵囧尯涓瘡涓暟鎹潡0x40==64bytes锛屽彲閫夊糩32,64,128]绛 + #define D_EEP_SECTOR_BLOCK_NUM (D_EEP_SECTOR_SIZE / D_EEP_PARAM_BLOCK_SIZE) //姣忎釜鎵囧尯鏁版嵁鍧楃殑鏁伴噺 + #define D_EEP_BLOCK_FILTER0 0xAA //鎵囧尯涓瘡涓暟鎹潡鐨凢ilter瀛楁鍊 + #define D_EEP_BLOCK_FILTER1 0x55 + //EEP User Defined 鍙傛暟鍖哄瓨鍌ㄩ厤缃 + #define D_EEP_PARAM_IN_SECTOR 1 //eeprom鍙傛暟鍖烘墖鍖哄湴鍧锛屼粠0寮濮 + #define D_EEP_PARAM_IN_BLOCK 0 //eeprom鍙傛暟鍖烘暟鎹潡鍦板潃锛屼粠0寮濮 + #define D_EEP_PARAM_BLOCK_SIZE (D_EEP_SECTOR_BLOCK_SIZE) //鍙傛暟鍖烘瘡涓潡澶у皬锛屽繀椤伙細D_EEP_PARAM_BLOCK_SIZE<=D_EEP_SECTOR_BLOCK_SIZE!!!锛屽洜涓篹eprom.h涓槸鎸夌収D_EEP_SECTOR_BLOCK_SIZE鍒嗛厤鐨刡uf + #define D_EEP_PARAM_BLOCK_NUM (D_EEP_SECTOR_SIZE / D_EEP_PARAM_BLOCK_SIZE) //姣忎釜鎵囧尯鏁版嵁鍧楃殑鏁伴噺 + //EEP 鍔犲瘑鍖哄瓨鍌ㄩ厤缃 + #if(D_CODE_ENCRYPTION_TYPE == TYPE_ENCRYPTION_ENABLE) + #define D_EEP_ENC_IN_SECTOR 0 //eeprom鍔犲瘑鍖烘墖鍖哄湴鍧锛屼粠0寮濮 + #define D_EEP_ENC_IN_BLOCK 0 //eeprom鍔犲瘑鍖烘暟鎹潡鍦板潃锛屼粠0寮濮 + #define D_EEP_ENC_BLOCK_SIZE 0x20 //ENC_BLOCK_SIZE蹇呴』涓庡姞瀵嗙▼搴忎腑鐨凟NC_BLOCK_SIZE鍖归厤锛屾澶勪笉寤鸿淇敼锛屽闇淇敼锛岃鍚屾椂淇敼鍔犲瘑绋嬪簭 + #endif +#elif xxx #endif +//STEP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -#if 0 -搴忓彿 閲忕▼ 绯绘暟 -1 100kg 100% -2 200kg 100% -3 300kg 100% -4 400kg 100% -5 500kg 100% -6 600kg 100% -7 700kg 100% -8 800kg 100% -9 900kg 100% -10 1000kg 100% -#endif -#define ADC_status_chx_Ready_BASE 0x01 -#define ADC_status_ch1_Ready 0x01 -#define ADC_status_ch2_Ready 0x02 -#define ADC_status_ch3_Ready 0x04 -#define ADC_status_ch4_Ready 0x08 - -#define D_weight_show_limit_num 5 -#define D_weight_std_num 10 -typedef struct global_register -{ - //RO Register - S16 reserved1; - S32 total_weight; //鍑閲嶏紙鏄剧ず閲嶉噺锛*100 - S32 total_zweight; //鐨噸*100 - //RW Register - S16 reserved2; - struct { //闇瑕佹寔涔呭寲鐨勫弬鏁帮紝涓嶈兘瓒呰繃72瀛楄妭锛屽惁鍒欎細瀵艰嚧eeprom婧㈠嚭 - U16 reset; //reset鏍囧織锛屽啓鍏ヤ换浣曞硷紝鎵鏈夊弬鏁版仮澶嶅垵濮嬪 - U16 adc_ch_status; - S16 slaver_id; - S16 zero; //娓0鏍囧織锛屽啓鍏ヤ换浣曞兼竻0锛堝幓鐨級 - S16 weight_max; //閲忕▼ - S16 lmd; //2mv/v - S16 cc_blur_ch_avg; //鍧囧兼护娉㈢偣鏁 - S16 cc_blur_ch_shift; //绉讳綅婊ゆ尝鐐规暟 - S16 cc_blur_all_shift0; //鍜屽肩Щ浣嶆护娉㈢偣鏁1 - S16 cc_blur_all_shift1; //鍜屽肩Щ浣嶆护娉㈢偣鏁2 - S16 cc_blur_all_out_d_threshold; //绉讳綅闃堝1 - S16 cc_blur_all_out_dd_threshold;//绉讳綅闃堝2 - struct{ - S16 weight; - S16 times; - } weight_show_limit[D_weight_show_limit_num]; - struct { - S16 weight_range; //閲忕▼ x 100 - S16 ratio; //閲嶉噺璁$畻绯绘暟锛岄粯璁100锛屼繚鐣欎袱浣嶅皬鏁帮紝鐩稿綋浜巟1 - } weight_std[D_weight_std_num]; - U16 baud_rate; //娉㈢壒鐜 - U16 stop_bits; //鍋滄浣 - }p; - S16 reserved3; -}GlobalRegister; - -//瀵勫瓨鍣ㄥ唴瀛樺熀鍦板潃 -#define REG_MEM_BASE ((U16*)(&R)) //瀵勫瓨鍣ㄥ熀纭鍦板潃锛堟湰鏂囦欢澶栭儴涓嶅簲璇ヤ娇鐢ㄨ瀹忓畾涔夛級 -//鍙橀噺鍦板潃杞瘎瀛樺櫒 -#define MEM_2_REG(mem) (((U16*)(mem) - REG_MEM_BASE) + 1) -//瀵勫瓨鍣ㄨ浆鍙橀噺鍦板潃 -#define REG_2_MEM(reg) (REG_MEM_BASE + (U16)((reg) - 1)) - -extern GlobalRegister R; - -//Step4: IRQ Config -#if (TYPE_MCU == TYPE_MCU_STC_8A || TYPE_MCU == TYPE_MCU_STC_8F) +//Step3: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>IRQ Config +#if ((TYPE_MCU & TYPE_MCU_VENDOR_MSK) == TYPE_MCU_VENDOR_STC) #define D_SERVE_INT0 interrupt 0 #define D_SERVE_TIMER0 interrupt 1 #define D_SERVE_INT1 interrupt 2 @@ -292,20 +160,71 @@ extern GlobalRegister R; #define D_SERVE_PWMFD interrupt 23 #define D_SERVE_I2C interrupt 24 #endif +//STEP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Cdelay CONFIG +#if(MainFre_5M == D_sys_MainFre) +#define D_Cdelay_200us 20 +#define D_Cdelay_1us 1 ////while p21缈昏浆鏃舵祴瀹 500k 2us 涓涓寚浠 +#elif(MainFre_22M == D_sys_MainFre) +#define D_Cdelay_200us 20 +#define D_Cdelay_1us 1 ////while p21缈昏浆鏃舵祴瀹 500k 2us 涓涓寚浠 +#define D_Cdelay_1us 1 ////while p21缈昏浆鏃舵祴瀹 500k 2us 涓涓寚浠 +#define L0_delay_1us() Lc_delay_nop(0) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us +#define L0_delay_10us() Lc_delay_nop(4) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us +#define L0_delay_40us() Lc_delay_nop(18) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us +#elif(MainFre_27M == D_sys_MainFre) +#define D_Cdelay_200us 20 +#define D_Cdelay_1us 1 ////while p21缈昏浆鏃舵祴瀹 500k 2us 涓涓寚浠 +#else ///MainFre_11M +#define D_Cdelay_200us 20 +#define D_Cdelay_1us 1 ////while p21缈昏浆鏃舵祴瀹 500k 2us 涓涓寚浠 +#define L0_delay_1us() Lc_delay_nop(0) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us +#define L0_delay_10us() Lc_delay_nop(4) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us +#define L0_delay_40us() Lc_delay_nop(18) // 5涓猲op() 100ns 50涓猲op() 1us (20)=10us (2)1.5us + //xx +#endif//D_sys_MainFre) +//STEP 4 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +#include "../clib/type.h" +#include "../clib/bit.h" + +//>>>>>>>>>>>>>>>>>>>>>>.BORAD TYPE +#define TYPE_BOARD_hhnew 1 +#define TYPE_BOARD_st_sleep04_01 4 +#define TYPE_BOARD_st_sleep03 5 +#define TYPE_BOARD_SMMM_MB_VH032_0E 6 +#define TYPE_BOARD_LPC17xx_ 8 +#define TYPE_BOARD_STM32F_103ZET6_READBULL 1036 +#define TYPE_BOARD_hh_CC_MD_VH05_anyriny_simple_m51 0x0551 +#define TYPE_BOARD_hh_CC_MD_VH06_asMain_m6a7 0x6a7 +#define TYPE_BOARD_TI26_MT01_M178 0x178 //浼氳璁℃椂鍣ㄧ増v TI26_MT01-M178 +#define TYPE_BOARD_stc5as32_WIFIBV01 532 +#define TYPE_BOARD_SHC16LAXXQN32 1632 //SHC16LAXXQN32 +#define TYPE_BOARD_PAPER6133_M0A6 0xa6 //鎵撳嵃鏈虹焊寮犱紶鎰 +#define TYPE_BOARD_GSM_MAIN_V07 0xa7 //鎵撳嵃鏈鸿繍缁存澘 +#define TYPE_BOARD_ADDA_MAIN_V02 0xa8 //ADDA +#define TYPE_BOARD_433_0A 0xa9 //433 +#define TYPE_BOARD_WEIGH_0B 0xaa //绉伴噸 +//<<<<<<<<<<<<<<<<<<<<<<<<<<<.BORAD TYPE end + +//>>>>>>>>>>>>>>>>>>>>>>MCU TYPE +#define TYPE_MCU_VENDOR_MSK 0xF0 +#define TYPE_MCU_VENDOR_STC 0x10 +#define TYPE_MCU_STC_8A 0x11 +#define TYPE_MCU_STC_8F 0x12 +#define TYPE_MCU_STC_8G 0x13 +#define TYPE_MCU_STC_8H 0x14 + +#define TYPE_MCU_VENDOR_TI 0x60 +#define TYPE_MCU_SHC6601 0x66 +#define TYPE_MCU_LPC17xx 0x67 +#define TYPE_MCU_STM32 0x68 + +#define D_CPUfamily_8bits 8 +#define D_CPUfamily_16bits 16 +#define D_CPUfamily_32bits 32 +//<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>IDE TYPE +#define TYPE_IDE_KEIL 1 +#define TYPE_IDE_MDK 2 +#define TYPE_IDE_IAR 3 +//<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>SysTimer TYPE +#define TYPE_JIFFIES_5MS 5 +#define TYPE_JIFFIES_10MS 10 +#define TYPE_JIFFIES_25MS 25 +//<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>.WDT TYPE +#define TYPE_WDT_DISABLE 1 +#define TYPE_WDT_ENABLE 2 +//#define WDT_FEED() WDT_CONTR |= 0x10 +//<<<<<<<<<<<<<<<<<<<<<<<<<<<.SysTimer TYPE end + +//>>>>>>>>>>>>>>>>>>>>>>.ByteOrder TYPE +#define TYPE_MCU_BIGENDIAN 1 //澶х瀛楄妭搴 +#define TYPE_MCU_LITENDIAN 2 //灏忕瀛楄妭搴 +//<<<<<<<<<<<<<<<<<<<<<<<<<<<.ByteOrder TYPE end + +//>>>>>>>>>>>>>>>>>>>>>>.浠g爜鍔犲瘑 TYPE +#define TYPE_ENCRYPTION_ENABLE 1 //浠g爜鍔犲瘑 +#define TYPE_ENCRYPTION_DISABLE 2 //浠g爜涓嶅姞瀵 +//<<<<<<<<<<<<<<<<<<<<<<<<<<<.ByteOrder TYPE end + +//>>>>>>>>>>>>>>>>>>>>>>BUADRATE & StopBit +#define SBIT_1 1 //1 stop bit +#define SBIT_2 2 //2 stop bit +#define BRT_115200 115200 +#define BRT_19200 19200 +#define BRT_9600 9600 +#define BRT_4800 4800 +//<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>MainFre +#define MainFre_5M 5529600L +#define MainFre_11M 11059200L +#define MainFre_22M 22118400L +#define MainFre_24M 24000000L +#define MainFre_27M 27000000L +//<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>UART0 PIN +#define PIN_UART0_Rxd_30_Txd_31 1 +#define PIN_UART0_Rxd_36_Txd_37 2 +#define PIN_UART0_Rxd_16_Txd_17 3 +#define PIN_UART0_Rxd_43_Txd_44 4 +//<<<<<<<<<<<<<<<<<<<<<<<<<<<.UART0 PIN + +//>>>>>>>>>>>>>>>>>>>>>>485 Type +#define TYPE_485_NONE 0 +#define TYPE_485_MASTER 1 +#define TYPE_485_SLAVER 2 +//<<<<<<<<<<<<<<<<<<<<<<485 Type end + +//>>>>>>>>>>>>>>>>>>>>>>G-SENSOR TYPE +#define TYPE_ASENSOR_ADXL362 362 +#define TYPE_ASENSOR_MSA300 300 +#define TYPE_ASENSOR TYPE_ASENSOR_MSA300 +//<<<<<<<<<<<<<<<<<<<<<>>绔彛浣嶅畾涔夛紝鍙慨鏀!!!!!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #include "../bsp/bsp_config.h" - - -#include "uart0.h" +#include "../msp/uart0.h" extern void L0_id_get(U8 *id); extern void L0_id_get_rom(U8 *id); diff --git a/source/bsp/bsp_cs1232.c b/source/bsp/cs1232.c similarity index 93% rename from source/bsp/bsp_cs1232.c rename to source/bsp/cs1232.c index 45ffb11..9aa2073 100644 --- a/source/bsp/bsp_cs1232.c +++ b/source/bsp/cs1232.c @@ -14,11 +14,11 @@ /// @note ////////////////////////////////////////////////////////////////////////////// -#include "bsp_cs1232.h" +#include "cs1232.h" TSS_FLOW_ tss_ads; //#define D_ADC_GATHER_Way1 1 - +#if 0 u8 Read_byte_adcIC(void) { u8 i; @@ -40,17 +40,6 @@ u8 Read_byte_adcIC(void) return(rdata); } -void L0_ADS1213_INIT(void) -{ - D_ADS1213_INIT(); - - L0_ADS1213_CH(D_ADCCH_1); - Lc_delay_ms(100);///57ms 寤虹珛鏃堕棿 - - //L0_ADS1213_CH(D_ADCCH_3); - //Lc_delay_ms(100);///57ms 寤虹珛鏃堕棿 -} - void L0_ADS1213_CH(u8 ch) { /// /// SPEED = 1 57--57 ms 纭欢閰嶇疆鎴愰珮鐢靛钩 @@ -99,6 +88,21 @@ void L0_ADS1213_T(u8 onff) } } +#endif +void L0_ADS1213_INIT(void) +{ + D_ADS1213_INIT(); + D_stdIO_P3(BITN2); + D_stdIO_P3(BITN3); + + //L0_ADS1213_CH(D_ADCCH_1); //4涓嫭绔嬭姱鐗囷紝涓嶉渶瑕佸垏鎹 + Lc_delay_ms(100);///57ms 寤虹珛鏃堕棿 + + //L0_ADS1213_CH(D_ADCCH_3); + //Lc_delay_ms(100);///57ms 寤虹珛鏃堕棿 +} + + void L0_2dc_SCLK(vtype ch,vtype onf) { switch (ch) @@ -144,12 +148,10 @@ vtype L0_2dc_DOUT_AT(vtype ch) return r; } - -vtype i; vU32 rdata = 0; - +//浠诲姟璇 vS32 L0_ADS1231_readCH(vtype ch) { - rdata = 0; + vtype i; vU32 rdata = 0; for(i = 0; i < 24; i++) { L0_2dc_SCLK(ch,1);/// D_ADC_SCLK1_ON(); @@ -171,23 +173,15 @@ vS32 L0_ADS1231_readCH(vtype ch) return rdata; } - +//璋冭瘯闃诲璇 vS32 L0_ADS1231_read(U8 ch) { vU32 e = 0;u8 i;vS32 rdata = 0; - while(0 == L0_2dc_DOUT_AT(ch)) - { - if(e ++ > 100000) - { - return 0; - } - } - e = 0; while(1 == L0_2dc_DOUT_AT(ch)) { if(e ++ > 100000) { - return 0; + //return 0; } } for(i = 0; i < 24; i++) @@ -200,6 +194,7 @@ vS32 L0_ADS1231_read(U8 ch) rdata += 1; } } + L0_2dc_SCLK(ch,1); if(rdata & 0x800000) //???位?1??<0?? { rdata |= 0xFF000000; @@ -210,7 +205,7 @@ vS32 L0_ADS1231_read(U8 ch) void L1_ADS1213_main(void) { - U8 ch = D_ADCCH_4; + U8 ch = D_ADCCH_2; while(1) { while(1 == L0_2dc_DOUT_AT(ch)) diff --git a/source/bsp/bsp_cs1232.h b/source/bsp/cs1232.h similarity index 76% rename from source/bsp/bsp_cs1232.h rename to source/bsp/cs1232.h index b39f16d..bab0040 100644 --- a/source/bsp/bsp_cs1232.h +++ b/source/bsp/cs1232.h @@ -23,14 +23,15 @@ #include "../msp/uart0.h" #include "../ctask/task.h" -#define D_ADCCH_T 0 -#define D_ADCCH_1 1 -#define D_ADCCH_2 2 -#define D_ADCCH_3 3 -#define D_ADCCH_4 4 - -#define D_ADCCH_Toff 5 + +#define D_ADCCH_1 0 +#define D_ADCCH_2 1 +#define D_ADCCH_3 2 +#define D_ADCCH_4 3 + +#define D_ADCCH_T 8 +#define D_ADCCH_Toff 9 ///鏁板瓧閮ㄥ垎闇瑕佹湁鍥涗釜鏁版嵁杞崲鍛ㄦ湡婊¤冻妯℃嫙杈撳叆淇″彿鐨勫缓绔嬪拰婊ゆ尝鍣ㄧ殑寤虹珛鏃堕棿瑕佹眰銆傝姱 ///鐗囦粠澶栭儴宸垎杈撳叆淇″彿鍒囨崲鍒版俯搴︿紶鎰熷櫒銆佷粠娓╁害浼犳劅鍣ㄥ垏鎹㈠埌澶栭儴宸垎杈撳叆淇″彿锛屾垨閫 @@ -70,65 +71,62 @@ /************** IO DEFINE PIN -P1.2 TEMP 1 -P1.3 SCLK3 2 -P1.4 DOUT1 3 -P1.5 SCLK1 4 -P1.6 DOUT2 5 -P1.7 SCLK2 6 -P5.4 PDWN 7 -P5.5 CS_A0 9 -P1.1 DOUT3 20 -P1.0 LED1 19 -P3.7 GAIN1 18 -P3.6 GAIN0 17 -P3.5 LED2 16 -P3.4 DOUT4 15 -P3.3 SCLK4 14 -P3.2 485_RE 13 +P1.0 DOUT2 1 +P1.6 SCLK2 2 +P1.7 LED1 3 +P5.4 LED2 7 +P5.5 485_RE 9 +P1.1 PDWN 20 +P1.2 GAIN0 19 +P3.7 DOUT3 18 +P3.6 DOUT1 17 +P3.5 SCLK1 16 +P3.4 SCLK3 15 +P3.3 DOUT4 14 +P3.2 SCLK4 13 P3.1 TXD0 12 P3.0 RXD0 11 *****************/ -#define D_ADC_DOUT1_INIT() ///D_P16_INIT() -#define D_ADC_SCLK1_INIT() ///D_P17_INIT() +#define D_ADC_DOUT1_INIT() ///D_P17_INIT() +#define D_ADC_SCLK1_INIT() ///D_P16_INIT() #define D_ADC_CS_A0_INIT() ///D_P55_INIT() -#define D_ADC_DOUT1_AT() D_P14_AT() -#define D_ADC_DOUT1_ON() D_P14_ON() -#define D_ADC_SCLK1_ON() D_P15_ON();D_adc_delay2(); -#define D_ADC_CS_A0_ON() D_P55_ON() -#define D_ADC_DOUT1_OFF() D_P14_OFF() -#define D_ADC_SCLK1_OFF() D_P15_OFF();D_adc_delay(); -#define D_ADC_CS_A0_OFF() D_P55_OFF() +#define D_ADC_DOUT1_AT() D_P36_AT() +#define D_ADC_DOUT1_ON() D_P36_ON() +#define D_ADC_SCLK1_ON() D_P35_ON();D_adc_delay2(); +#define D_ADC_CS_A0_ON() //D_P55_ON() +#define D_ADC_DOUT1_OFF() D_P36_OFF() +#define D_ADC_SCLK1_OFF() D_P35_OFF();D_adc_delay(); +#define D_ADC_CS_A0_OFF() //D_P55_OFF() //#define D_ADC_CS2_A0_ON() D_P13_ON() -#define D_ADC_DOUT2_ON() D_P16_ON() -#define D_ADC_DOUT2_AT() D_P16_AT() -#define D_ADC_SCLK2_ON() D_P17_ON();D_adc_delay2(); +#define D_ADC_DOUT2_ON() D_P10_ON() +#define D_ADC_DOUT2_AT() D_P10_AT() +#define D_ADC_SCLK2_ON() D_P16_ON();D_adc_delay2(); //#define D_ADC_CS2_A0_INIT() ///D_P13_INIT() #define D_ADC_DOUT2_INIT() ///D_P14_IN() ///D_P14_INIT() #define D_ADC_SCLK2_INIT() ///D_P15_INIT() //#define D_ADC_CS2_A0_OFF() D_P13_OFF() -#define D_ADC_DOUT2_OFF() D_P16_OFF() -#define D_ADC_SCLK2_OFF() D_P17_OFF();D_adc_delay(); +#define D_ADC_DOUT2_OFF() D_P10_OFF() +#define D_ADC_SCLK2_OFF() D_P16_OFF();D_adc_delay(); #define D_ADC_DOUT3_INIT() ///D_P11_INIT() #define D_ADC_SCLK3_INIT() ///D_P13_INIT() -#define D_ADC_DOUT3_AT() D_P11_AT() -#define D_ADC_DOUT3_ON() D_P11_ON() -#define D_ADC_SCLK3_ON() D_P13_ON();D_adc_delay2(); -#define D_ADC_DOUT3_OFF() D_P11_OFF() -#define D_ADC_SCLK3_OFF() D_P13_OFF();D_adc_delay(); +#define D_ADC_DOUT3_AT() D_P37_AT() +#define D_ADC_DOUT3_ON() D_P37_ON() +#define D_ADC_SCLK3_ON() D_P34_ON();D_adc_delay2(); +#define D_ADC_DOUT3_OFF() D_P37_OFF() +#define D_ADC_SCLK3_OFF() D_P34_OFF();D_adc_delay(); #define D_ADC_DOUT4_INIT() ///D_P34_INIT() #define D_ADC_SCLK4_INIT() ///D_P33_INIT() -#define D_ADC_DOUT4_AT() D_P34_AT() -#define D_ADC_DOUT4_ON() D_P34_ON() -#define D_ADC_SCLK4_ON() D_P33_ON();D_adc_delay2(); -#define D_ADC_DOUT4_OFF() D_P34_OFF() -#define D_ADC_SCLK4_OFF() D_P33_OFF();D_adc_delay(); +#define D_ADC_DOUT4_AT() D_P33_AT() +#define D_ADC_DOUT4_ON() D_P33_ON() +#define D_ADC_SCLK4_ON() D_P32_ON();D_adc_delay2(); +#define D_ADC_DOUT4_OFF() D_P33_OFF() +#define D_ADC_SCLK4_OFF() D_P32_OFF();D_adc_delay(); @@ -137,14 +135,14 @@ P3.0 RXD0 11 #define D_ADC_TEMP_INIT() ///D_P12_INIT() -#define D_ADC_TEMP_ON() D_P12_ON() -#define D_ADC_TEMP_OFF() D_P12_OFF() +#define D_ADC_TEMP_ON() //D_P12_ON() +#define D_ADC_TEMP_OFF() //D_P12_OFF() #define D_ADC_PDWN_INIT() ///D_P54_INIT() -#define D_ADC_PDWN_OFF() D_P54_OFF() -#define D_ADC_PDWN_ON() D_P54_ON() +#define D_ADC_PDWN_OFF() D_P11_OFF() +#define D_ADC_PDWN_ON() D_P11_ON() @@ -152,15 +150,15 @@ P3.0 RXD0 11 #define D_ADC_GAIN1_INIT() ///D_P37_INIT() #define D_ADC_GAIN0_INIT() ///D_P36_INIT() -#define D_ADC_GAIN1_OFF() D_P37_OFF() -#define D_ADC_GAIN0_OFF() D_P36_OFF() -#define D_ADC_GAIN1_ON() D_P37_ON() -#define D_ADC_GAIN0_ON() D_P36_ON() +#define D_ADC_GAIN1_OFF() //D_P37_OFF() +#define D_ADC_GAIN0_OFF() D_P12_OFF() +#define D_ADC_GAIN1_ON() //D_P37_ON() +#define D_ADC_GAIN0_ON() D_P12_ON() // #define D_ADS1213_GAIN_VAL 1 // #define D_ADS1213_GAIN_VAL 2 -//#define D_ADS1213_GAIN_VAL 64 -#define D_ADS1213_GAIN_VAL 128 +#define D_ADS1213_GAIN_VAL 64 +//#define D_ADS1213_GAIN_VAL 128 #if (D_ADS1213_GAIN_VAL == 128) #define D_ADS1213_INIT() D_ADC_GAIN1_ON();D_ADC_GAIN0_ON();\ @@ -168,6 +166,7 @@ P3.0 RXD0 11 D_ADC_CS_A0_ON();\ D_ADC_SCLK1_OFF();D_ADC_SCLK2_OFF();\ D_ADC_SCLK3_OFF();D_ADC_SCLK4_OFF(); + #elif (D_ADS1213_GAIN_VAL == 64) #define D_ADS1213_INIT() D_ADC_GAIN1_ON();D_ADC_GAIN0_OFF();\ D_ADC_TEMP_OFF();\ diff --git a/source/bsp/bsp_485.c b/source/bsp/rs485.c similarity index 63% rename from source/bsp/bsp_485.c rename to source/bsp/rs485.c index b2efe0e..5c00a48 100644 --- a/source/bsp/bsp_485.c +++ b/source/bsp/rs485.c @@ -1,8 +1,8 @@ -#include "bsp_485.h" +#include "rs485.h" void L2_485_init(void) { //485閰嶇疆寮烘帹鎸借緭鍑 P33 P32 //BITN_0(P3M1,BITN3);BITN_1(P3M0,BITN3); - BITN_0(P3M1,BITN2);BITN_1(P3M0,BITN2); + BITN_0(P5M1,BITN5);BITN_1(P5M0,BITN5); } \ No newline at end of file diff --git a/source/bsp/bsp_485.h b/source/bsp/rs485.h similarity index 69% rename from source/bsp/bsp_485.h rename to source/bsp/rs485.h index e3629e4..0bdba72 100644 --- a/source/bsp/bsp_485.h +++ b/source/bsp/rs485.h @@ -6,8 +6,8 @@ //485_RE P33 //485_DE P32 -#define D_485_TX() P32 = 1;// >750us -#define D_485_RX() P32 = 0; +#define D_485_TX() P55 = 1;// >750us +#define D_485_RX() P55 = 0; extern void L2_485_init(void); #endif \ No newline at end of file diff --git a/source/clib/clib.c b/source/clib/clib.c index c8250bf..f7f8633 100644 --- a/source/clib/clib.c +++ b/source/clib/clib.c @@ -307,6 +307,51 @@ vS32 Lc_S32_media(vS32 val[],S16 num) return val[num/2]; } } +U32 Lc_vS32_media(U32 *d, U8 n) +{ + U8 i = 0,j = 0; + U32 h = 0; + if(n == 1) + { + return d[0]; + } + for(i=0;i d[j]) + { + h = d[i]; + d[i] = d[j]; + d[j] = h; + } + } + } + if(n%2 != 0) //濂囨暟 + { + return d[n/2]; + } + else//鍋舵暟 + { + return ((d[n/2] + d[n/2-1])/2); + } +} + + +U32 Lc_vU32_avg(U32 *d, U8 n) +{ + U8 i = 0; + U32 sum = 0; + if(n == 1) + { + return d[0]; + } + for(i=0;i 0x31 0x31 0x32 0x32 '1' '1' '2' '2' extern void Lc_hex2ascii(U8 *buf,U16 len,U8 *ascii); -extern void crc16(unsigned char *CRC,void *dat,unsigned int len) reentrant; +extern void crc16(unsigned char *CRC,void *dat,unsigned int len) /*reentrant*/; //extern void crc16_irq(unsigned char *CRC,void *dat,unsigned int len); extern int isBigEndianOrder(void); extern U32 ntohl(U32 dat); @@ -106,7 +106,13 @@ extern U16 ntohs(U16 dat); extern U16 htons(U16 dat); extern U32 Lc_abs(vS32 a,vS32 b); extern void Lc_encrypt_id(U8 *enc_dst, U8 *enc_src, U32 enc_key, U8 src_len); -extern int libc_strlen(char *str); +extern void Lc_encrypt_id1(U8 *enc_dst, U8 *enc_src, U8 enc_key[], U8 src_len); +extern int Lc_strlen(char *str); +extern U32 Lc_vU32_avg(U32 *d, U8 n); +extern U32 Lc_vS32_media(U32 *d, U8 n); +extern int Lc_memset(U8 *buf,U8 c,U16 len); + + #endif /* end __UART_H */ /***************************************************************************** diff --git a/source/clib/type.h b/source/clib/type.h index a07b789..439b662 100644 --- a/source/clib/type.h +++ b/source/clib/type.h @@ -80,6 +80,7 @@ #ifndef TRUE #define TRUE (1) #endif + /********************************************************************************************************* 定义与编译器无关的数据类型 *********************************************************************************************************/ @@ -267,7 +268,7 @@ typedef struct #define HIGHT 1 #define LOW 0 - +#if 0 #ifndef MIN #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif @@ -275,7 +276,7 @@ typedef struct #ifndef MAX #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif - +#endif #ifndef ABS #define ABS(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) #endif diff --git a/source/cpu/STARTUP.A51 b/source/cpu/STARTUP.A51 index a84d004..65daedc 100644 --- a/source/cpu/STARTUP.A51 +++ b/source/cpu/STARTUP.A51 @@ -35,7 +35,7 @@ XDATASTART EQU 0 ; ; XDATALEN: XDATA memory size <0x0-0xFFFF> ; The length of XDATA memory in bytes. -XDATALEN EQU 2048 +XDATALEN EQU 3072 ; ; PDATASTART: PDATA memory start address <0x0-0xFFFF> ; The absolute start address of PDATA memory diff --git a/source/cpu/stc_stc8hxx.h b/source/cpu/stc_stc8hxx.h new file mode 100644 index 0000000..a279eea --- /dev/null +++ b/source/cpu/stc_stc8hxx.h @@ -0,0 +1,640 @@ +#ifndef __STC8H_H__ +#define __STC8H_H__ + +///////////////////////////////////////////////// + +//包含本头文件后,不用另外再包含"REG51.H" + +sfr P0 = 0x80; +sbit P00 = P0^0; +sbit P01 = P0^1; +sbit P02 = P0^2; +sbit P03 = P0^3; +sbit P04 = P0^4; +sbit P05 = P0^5; +sbit P06 = P0^6; +sbit P07 = P0^7; +sfr SP = 0x81; +sfr DPL = 0x82; +sfr DPH = 0x83; +sfr S4CON = 0x84; +sfr S4BUF = 0x85; +sfr PCON = 0x87; +sfr TCON = 0x88; +sbit TF1 = TCON^7; +sbit TR1 = TCON^6; +sbit TF0 = TCON^5; +sbit TR0 = TCON^4; +sbit IE1 = TCON^3; +sbit IT1 = TCON^2; +sbit IE0 = TCON^1; +sbit IT0 = TCON^0; +sfr TMOD = 0x89; +sfr TL0 = 0x8a; +sfr TL1 = 0x8b; +sfr TH0 = 0x8c; +sfr TH1 = 0x8d; +sfr AUXR = 0x8e; +sfr INTCLKO = 0x8f; +sfr P1 = 0x90; +sbit P10 = P1^0; +sbit P11 = P1^1; +sbit P12 = P1^2; +sbit P13 = P1^3; +sbit P14 = P1^4; +sbit P15 = P1^5; +sbit P16 = P1^6; +sbit P17 = P1^7; +sfr P1M1 = 0x91; +sfr P1M0 = 0x92; +sfr P0M1 = 0x93; +sfr P0M0 = 0x94; +sfr P2M1 = 0x95; +sfr P2M0 = 0x96; +sfr SCON = 0x98; +sbit SM0 = SCON^7; +sbit SM1 = SCON^6; +sbit SM2 = SCON^5; +sbit REN = SCON^4; +sbit TB8 = SCON^3; +sbit RB8 = SCON^2; +sbit TI = SCON^1; +sbit RI = SCON^0; +sfr SBUF = 0x99; +sfr S2CON = 0x9a; +sfr S2BUF = 0x9b; +sfr IRCBAND = 0x9d; +sfr LIRTRIM = 0x9e; +sfr IRTRIM = 0x9f; +sfr P2 = 0xa0; +sbit P20 = P2^0; +sbit P21 = P2^1; +sbit P22 = P2^2; +sbit P23 = P2^3; +sbit P24 = P2^4; +sbit P25 = P2^5; +sbit P26 = P2^6; +sbit P27 = P2^7; +sfr P_SW1 = 0xa2; +sfr IE = 0xa8; +sbit EA = IE^7; +sbit ELVD = IE^6; +sbit EADC = IE^5; +sbit ES = IE^4; +sbit ET1 = IE^3; +sbit EX1 = IE^2; +sbit ET0 = IE^1; +sbit EX0 = IE^0; +sfr SADDR = 0xa9; +sfr WKTCL = 0xaa; +sfr WKTCH = 0xab; +sfr S3CON = 0xac; +sfr S3BUF = 0xad; +sfr TA = 0xae; +sfr IE2 = 0xaf; +sfr P3 = 0xb0; +sbit P30 = P3^0; +sbit P31 = P3^1; +sbit P32 = P3^2; +sbit P33 = P3^3; +sbit P34 = P3^4; +sbit P35 = P3^5; +sbit P36 = P3^6; +sbit P37 = P3^7; +sfr P3M1 = 0xb1; +sfr P3M0 = 0xb2; +sfr P4M1 = 0xb3; +sfr P4M0 = 0xb4; +sfr IP2 = 0xb5; +sfr IP2H = 0xb6; +sfr IPH = 0xb7; +sfr IP = 0xb8; +sbit PPCA = IP^7; +sbit PLVD = IP^6; +sbit PADC = IP^5; +sbit PS = IP^4; +sbit PT1 = IP^3; +sbit PX1 = IP^2; +sbit PT0 = IP^1; +sbit PX0 = IP^0; +sfr SADEN = 0xb9; +sfr P_SW2 = 0xba; +sfr ADC_CONTR = 0xbc; +sfr ADC_RES = 0xbd; +sfr ADC_RESL = 0xbe; +sfr P4 = 0xc0; +sbit P40 = P4^0; +sbit P41 = P4^1; +sbit P42 = P4^2; +sbit P43 = P4^3; +sbit P44 = P4^4; +sbit P45 = P4^5; +sbit P46 = P4^6; +sbit P47 = P4^7; +sfr WDT_CONTR = 0xc1; +sfr IAP_DATA = 0xc2; +sfr IAP_ADDRH = 0xc3; +sfr IAP_ADDRL = 0xc4; +sfr IAP_CMD = 0xc5; +sfr IAP_TRIG = 0xc6; +sfr IAP_CONTR = 0xc7; +sfr P5 = 0xc8; +sbit P50 = P5^0; +sbit P51 = P5^1; +sbit P52 = P5^2; +sbit P53 = P5^3; +sbit P54 = P5^4; +sbit P55 = P5^5; +sbit P56 = P5^6; +sbit P57 = P5^7; +sfr P5M1 = 0xc9; +sfr P5M0 = 0xca; +sfr P6M1 = 0xcb; +sfr P6M0 = 0xcc; +sfr SPSTAT = 0xcd; +sfr SPCTL = 0xce; +sfr SPDAT = 0xcf; +sfr PSW = 0xd0; +sbit CY = PSW^7; +sbit AC = PSW^6; +sbit F0 = PSW^5; +sbit RS1 = PSW^4; +sbit RS0 = PSW^3; +sbit OV = PSW^2; +sbit F1 = PSW^1; +sbit P = PSW^0; +sfr T4T3M = 0xd1; +sfr T4H = 0xd2; +sfr T4L = 0xd3; +sfr T3H = 0xd4; +sfr T3L = 0xd5; +sfr T2H = 0xd6; +sfr T2L = 0xd7; +sfr USBCLK = 0xdc; +sfr ADCCFG = 0xde; +sfr IP3 = 0xdf; +sfr ACC = 0xe0; +sfr P7M1 = 0xe1; +sfr P7M0 = 0xe2; +sfr DPS = 0xe3; +sfr DPL1 = 0xe4; +sfr DPH1 = 0xe5; +sfr CMPCR1 = 0xe6; +sfr CMPCR2 = 0xe7; +sfr P6 = 0xe8; +sfr USBDAT = 0xec; +sfr IP3H = 0xee; +sfr AUXINTIF = 0xef; +sfr B = 0xf0; +sfr USBCON = 0xf4; +sfr IAP_TPS = 0xf5; +sfr P7 = 0xf8; +sfr USBADR = 0xfc; +sfr RSTCFG = 0xff; + +//如下特殊功能寄存器位于扩展RAM区域 +//访问这些寄存器,需先将P_SW2的BIT7设置为1,才可正常读写 + +///////////////////////////////////////////////// +//FF00H-FFFFH +///////////////////////////////////////////////// + + + +///////////////////////////////////////////////// +//FE00H-FEFFH +///////////////////////////////////////////////// + +#define CKSEL (*(unsigned char volatile xdata *)0xfe00) +#define CLKDIV (*(unsigned char volatile xdata *)0xfe01) +#define HIRCCR (*(unsigned char volatile xdata *)0xfe02) +#define XOSCCR (*(unsigned char volatile xdata *)0xfe03) +#define IRC32KCR (*(unsigned char volatile xdata *)0xfe04) +#define MCLKOCR (*(unsigned char volatile xdata *)0xfe05) +#define IRCDB (*(unsigned char volatile xdata *)0xfe06) +#define X32KCR (*(unsigned char volatile xdata *)0xfe08) + +#define P0PU (*(unsigned char volatile xdata *)0xfe10) +#define P1PU (*(unsigned char volatile xdata *)0xfe11) +#define P2PU (*(unsigned char volatile xdata *)0xfe12) +#define P3PU (*(unsigned char volatile xdata *)0xfe13) +#define P4PU (*(unsigned char volatile xdata *)0xfe14) +#define P5PU (*(unsigned char volatile xdata *)0xfe15) +#define P6PU (*(unsigned char volatile xdata *)0xfe16) +#define P7PU (*(unsigned char volatile xdata *)0xfe17) +#define P0NCS (*(unsigned char volatile xdata *)0xfe18) +#define P1NCS (*(unsigned char volatile xdata *)0xfe19) +#define P2NCS (*(unsigned char volatile xdata *)0xfe1a) +#define P3NCS (*(unsigned char volatile xdata *)0xfe1b) +#define P4NCS (*(unsigned char volatile xdata *)0xfe1c) +#define P5NCS (*(unsigned char volatile xdata *)0xfe1d) +#define P6NCS (*(unsigned char volatile xdata *)0xfe1e) +#define P7NCS (*(unsigned char volatile xdata *)0xfe1f) +#define P0SR (*(unsigned char volatile xdata *)0xfe20) +#define P1SR (*(unsigned char volatile xdata *)0xfe21) +#define P2SR (*(unsigned char volatile xdata *)0xfe22) +#define P3SR (*(unsigned char volatile xdata *)0xfe23) +#define P4SR (*(unsigned char volatile xdata *)0xfe24) +#define P5SR (*(unsigned char volatile xdata *)0xfe25) +#define P6SR (*(unsigned char volatile xdata *)0xfe26) +#define P7SR (*(unsigned char volatile xdata *)0xfe27) +#define P0DR (*(unsigned char volatile xdata *)0xfe28) +#define P1DR (*(unsigned char volatile xdata *)0xfe29) +#define P2DR (*(unsigned char volatile xdata *)0xfe2a) +#define P3DR (*(unsigned char volatile xdata *)0xfe2b) +#define P4DR (*(unsigned char volatile xdata *)0xfe2c) +#define P5DR (*(unsigned char volatile xdata *)0xfe2d) +#define P6DR (*(unsigned char volatile xdata *)0xfe2e) +#define P7DR (*(unsigned char volatile xdata *)0xfe2f) +#define P0IE (*(unsigned char volatile xdata *)0xfe30) +#define P1IE (*(unsigned char volatile xdata *)0xfe31) +#define P2IE (*(unsigned char volatile xdata *)0xfe32) +#define P3IE (*(unsigned char volatile xdata *)0xfe33) +#define P4IE (*(unsigned char volatile xdata *)0xfe34) +#define P5IE (*(unsigned char volatile xdata *)0xfe35) +#define P6IE (*(unsigned char volatile xdata *)0xfe36) +#define P7IE (*(unsigned char volatile xdata *)0xfe37) + +#define RTCCR (*(unsigned char volatile xdata *)0xfe60) +#define RTCCFG (*(unsigned char volatile xdata *)0xfe61) +#define RTCIEN (*(unsigned char volatile xdata *)0xfe62) +#define RTCIF (*(unsigned char volatile xdata *)0xfe63) +#define ALAHOUR (*(unsigned char volatile xdata *)0xfe64) +#define ALAMIN (*(unsigned char volatile xdata *)0xfe65) +#define ALASEC (*(unsigned char volatile xdata *)0xfe66) +#define ALASSEC (*(unsigned char volatile xdata *)0xfe67) +#define INIYEAR (*(unsigned char volatile xdata *)0xfe68) +#define INIMONTH (*(unsigned char volatile xdata *)0xfe69) +#define INIDAY (*(unsigned char volatile xdata *)0xfe6a) +#define INIHOUR (*(unsigned char volatile xdata *)0xfe6b) +#define INIMIN (*(unsigned char volatile xdata *)0xfe6c) +#define INISEC (*(unsigned char volatile xdata *)0xfe6d) +#define INISSEC (*(unsigned char volatile xdata *)0xfe6e) +#define YEAR (*(unsigned char volatile xdata *)0xfe70) +#define MONTH (*(unsigned char volatile xdata *)0xfe71) +#define DAY (*(unsigned char volatile xdata *)0xfe72) +#define HOUR (*(unsigned char volatile xdata *)0xfe73) +#define MIN (*(unsigned char volatile xdata *)0xfe74) +#define SEC (*(unsigned char volatile xdata *)0xfe75) +#define SSEC (*(unsigned char volatile xdata *)0xfe76) + +#define I2CCFG (*(unsigned char volatile xdata *)0xfe80) +#define I2CMSCR (*(unsigned char volatile xdata *)0xfe81) +#define I2CMSST (*(unsigned char volatile xdata *)0xfe82) +#define I2CSLCR (*(unsigned char volatile xdata *)0xfe83) +#define I2CSLST (*(unsigned char volatile xdata *)0xfe84) +#define I2CSLADR (*(unsigned char volatile xdata *)0xfe85) +#define I2CTXD (*(unsigned char volatile xdata *)0xfe86) +#define I2CRXD (*(unsigned char volatile xdata *)0xfe87) +#define I2CMSAUX (*(unsigned char volatile xdata *)0xfe88) +#define TM2PS (*(unsigned char volatile xdata *)0xfea2) +#define TM3PS (*(unsigned char volatile xdata *)0xfea3) +#define TM4PS (*(unsigned char volatile xdata *)0xfea4) +#define ADCTIM (*(unsigned char volatile xdata *)0xfea8) + +#define PWM1_ETRPS (*(unsigned char volatile xdata *)0xfeb0) +#define PWM1_ENO (*(unsigned char volatile xdata *)0xfeb1) +#define PWM1_PS (*(unsigned char volatile xdata *)0xfeb2) +#define PWM1_IOAUX (*(unsigned char volatile xdata *)0xfeb3) +#define PWM2_ETRPS (*(unsigned char volatile xdata *)0xfeb4) +#define PWM2_ENO (*(unsigned char volatile xdata *)0xfeb5) +#define PWM2_PS (*(unsigned char volatile xdata *)0xfeb6) +#define PWM2_IOAUX (*(unsigned char volatile xdata *)0xfeb7) +#define PWM1_CR1 (*(unsigned char volatile xdata *)0xfec0) +#define PWM1_CR2 (*(unsigned char volatile xdata *)0xfec1) +#define PWM1_SMCR (*(unsigned char volatile xdata *)0xfec2) +#define PWM1_ETR (*(unsigned char volatile xdata *)0xfec3) +#define PWM1_IER (*(unsigned char volatile xdata *)0xfec4) +#define PWM1_SR1 (*(unsigned char volatile xdata *)0xfec5) +#define PWM1_SR2 (*(unsigned char volatile xdata *)0xfec6) +#define PWM1_EGR (*(unsigned char volatile xdata *)0xfec7) +#define PWM1_CCMR1 (*(unsigned char volatile xdata *)0xfec8) +#define PWM1_CCMR2 (*(unsigned char volatile xdata *)0xfec9) +#define PWM1_CCMR3 (*(unsigned char volatile xdata *)0xfeca) +#define PWM1_CCMR4 (*(unsigned char volatile xdata *)0xfecb) +#define PWM1_CCER1 (*(unsigned char volatile xdata *)0xfecc) +#define PWM1_CCER2 (*(unsigned char volatile xdata *)0xfecd) +#define PWM1_CNTR (*(unsigned int volatile xdata *)0xfece) +#define PWM1_CNTRH (*(unsigned char volatile xdata *)0xfece) +#define PWM1_CNTRL (*(unsigned char volatile xdata *)0xfecf) +#define PWM1_PSCR (*(unsigned int volatile xdata *)0xfed0) +#define PWM1_PSCRH (*(unsigned char volatile xdata *)0xfed0) +#define PWM1_PSCRL (*(unsigned char volatile xdata *)0xfed1) +#define PWM1_ARR (*(unsigned int volatile xdata *)0xfed2) +#define PWM1_ARRH (*(unsigned char volatile xdata *)0xfed2) +#define PWM1_ARRL (*(unsigned char volatile xdata *)0xfed3) +#define PWM1_RCR (*(unsigned char volatile xdata *)0xfed4) +#define PWM1_CCR1 (*(unsigned int volatile xdata *)0xfed5) +#define PWM1_CCR1H (*(unsigned char volatile xdata *)0xfed5) +#define PWM1_CCR1L (*(unsigned char volatile xdata *)0xfed6) +#define PWM1_CCR2 (*(unsigned int volatile xdata *)0xfed7) +#define PWM1_CCR2H (*(unsigned char volatile xdata *)0xfed7) +#define PWM1_CCR2L (*(unsigned char volatile xdata *)0xfed8) +#define PWM1_CCR3 (*(unsigned int volatile xdata *)0xfed9) +#define PWM1_CCR3H (*(unsigned char volatile xdata *)0xfed9) +#define PWM1_CCR3L (*(unsigned char volatile xdata *)0xfeda) +#define PWM1_CCR4 (*(unsigned int volatile xdata *)0xfedb) +#define PWM1_CCR4H (*(unsigned char volatile xdata *)0xfedb) +#define PWM1_CCR4L (*(unsigned char volatile xdata *)0xfedc) +#define PWM1_BKR (*(unsigned char volatile xdata *)0xfedd) +#define PWM1_DTR (*(unsigned char volatile xdata *)0xfede) +#define PWM1_OISR (*(unsigned char volatile xdata *)0xfedf) +#define PWM2_CR1 (*(unsigned char volatile xdata *)0xfee0) +#define PWM2_CR2 (*(unsigned char volatile xdata *)0xfee1) +#define PWM2_SMCR (*(unsigned char volatile xdata *)0xfee2) +#define PWM2_ETR (*(unsigned char volatile xdata *)0xfee3) +#define PWM2_IER (*(unsigned char volatile xdata *)0xfee4) +#define PWM2_SR1 (*(unsigned char volatile xdata *)0xfee5) +#define PWM2_SR2 (*(unsigned char volatile xdata *)0xfee6) +#define PWM2_EGR (*(unsigned char volatile xdata *)0xfee7) +#define PWM2_CCMR1 (*(unsigned char volatile xdata *)0xfee8) +#define PWM2_CCMR2 (*(unsigned char volatile xdata *)0xfee9) +#define PWM2_CCMR3 (*(unsigned char volatile xdata *)0xfeea) +#define PWM2_CCMR4 (*(unsigned char volatile xdata *)0xfeeb) +#define PWM2_CCER1 (*(unsigned char volatile xdata *)0xfeec) +#define PWM2_CCER2 (*(unsigned char volatile xdata *)0xfeed) +#define PWM2_CNTR (*(unsigned int volatile xdata *)0xfeee) +#define PWM2_CNTRH (*(unsigned char volatile xdata *)0xfeee) +#define PWM2_CNTRL (*(unsigned char volatile xdata *)0xfeef) +#define PWM2_PSCR (*(unsigned int volatile xdata *)0xfef0) +#define PWM2_PSCRH (*(unsigned char volatile xdata *)0xfef0) +#define PWM2_PSCRL (*(unsigned char volatile xdata *)0xfef1) +#define PWM2_ARR (*(unsigned int volatile xdata *)0xfef2) +#define PWM2_ARRH (*(unsigned char volatile xdata *)0xfef2) +#define PWM2_ARRL (*(unsigned char volatile xdata *)0xfef3) +#define PWM2_RCR (*(unsigned char volatile xdata *)0xfef4) +#define PWM2_CCR1 (*(unsigned int volatile xdata *)0xfef5) +#define PWM2_CCR1H (*(unsigned char volatile xdata *)0xfef5) +#define PWM2_CCR1L (*(unsigned char volatile xdata *)0xfef6) +#define PWM2_CCR2 (*(unsigned int volatile xdata *)0xfef7) +#define PWM2_CCR2H (*(unsigned char volatile xdata *)0xfef7) +#define PWM2_CCR2L (*(unsigned char volatile xdata *)0xfef8) +#define PWM2_CCR3 (*(unsigned int volatile xdata *)0xfef9) +#define PWM2_CCR3H (*(unsigned char volatile xdata *)0xfef9) +#define PWM2_CCR3L (*(unsigned char volatile xdata *)0xfefa) +#define PWM2_CCR4 (*(unsigned int volatile xdata *)0xfefb) +#define PWM2_CCR4H (*(unsigned char volatile xdata *)0xfefb) +#define PWM2_CCR4L (*(unsigned char volatile xdata *)0xfefc) +#define PWM2_BKR (*(unsigned char volatile xdata *)0xfefd) +#define PWM2_DTR (*(unsigned char volatile xdata *)0xfefe) +#define PWM2_OISR (*(unsigned char volatile xdata *)0xfeff) + +#define PWMA_ETRPS (*(unsigned char volatile xdata *)0xfeb0) +#define PWMA_ENO (*(unsigned char volatile xdata *)0xfeb1) +#define PWMA_PS (*(unsigned char volatile xdata *)0xfeb2) +#define PWMA_IOAUX (*(unsigned char volatile xdata *)0xfeb3) +#define PWMB_ETRPS (*(unsigned char volatile xdata *)0xfeb4) +#define PWMB_ENO (*(unsigned char volatile xdata *)0xfeb5) +#define PWMB_PS (*(unsigned char volatile xdata *)0xfeb6) +#define PWMB_IOAUX (*(unsigned char volatile xdata *)0xfeb7) +#define PWMA_CR1 (*(unsigned char volatile xdata *)0xfec0) +#define PWMA_CR2 (*(unsigned char volatile xdata *)0xfec1) +#define PWMA_SMCR (*(unsigned char volatile xdata *)0xfec2) +#define PWMA_ETR (*(unsigned char volatile xdata *)0xfec3) +#define PWMA_IER (*(unsigned char volatile xdata *)0xfec4) +#define PWMA_SR1 (*(unsigned char volatile xdata *)0xfec5) +#define PWMA_SR2 (*(unsigned char volatile xdata *)0xfec6) +#define PWMA_EGR (*(unsigned char volatile xdata *)0xfec7) +#define PWMA_CCMR1 (*(unsigned char volatile xdata *)0xfec8) +#define PWMA_CCMR2 (*(unsigned char volatile xdata *)0xfec9) +#define PWMA_CCMR3 (*(unsigned char volatile xdata *)0xfeca) +#define PWMA_CCMR4 (*(unsigned char volatile xdata *)0xfecb) +#define PWMA_CCER1 (*(unsigned char volatile xdata *)0xfecc) +#define PWMA_CCER2 (*(unsigned char volatile xdata *)0xfecd) +#define PWMA_CNTR (*(unsigned int volatile xdata *)0xfece) +#define PWMA_CNTRH (*(unsigned char volatile xdata *)0xfece) +#define PWMA_CNTRL (*(unsigned char volatile xdata *)0xfecf) +#define PWMA_PSCR (*(unsigned int volatile xdata *)0xfed0) +#define PWMA_PSCRH (*(unsigned char volatile xdata *)0xfed0) +#define PWMA_PSCRL (*(unsigned char volatile xdata *)0xfed1) +#define PWMA_ARR (*(unsigned int volatile xdata *)0xfed2) +#define PWMA_ARRH (*(unsigned char volatile xdata *)0xfed2) +#define PWMA_ARRL (*(unsigned char volatile xdata *)0xfed3) +#define PWMA_RCR (*(unsigned char volatile xdata *)0xfed4) +#define PWMA_CCR1 (*(unsigned int volatile xdata *)0xfed5) +#define PWMA_CCR1H (*(unsigned char volatile xdata *)0xfed5) +#define PWMA_CCR1L (*(unsigned char volatile xdata *)0xfed6) +#define PWMA_CCR2 (*(unsigned int volatile xdata *)0xfed7) +#define PWMA_CCR2H (*(unsigned char volatile xdata *)0xfed7) +#define PWMA_CCR2L (*(unsigned char volatile xdata *)0xfed8) +#define PWMA_CCR3 (*(unsigned int volatile xdata *)0xfed9) +#define PWMA_CCR3H (*(unsigned char volatile xdata *)0xfed9) +#define PWMA_CCR3L (*(unsigned char volatile xdata *)0xfeda) +#define PWMA_CCR4 (*(unsigned int volatile xdata *)0xfedb) +#define PWMA_CCR4H (*(unsigned char volatile xdata *)0xfedb) +#define PWMA_CCR4L (*(unsigned char volatile xdata *)0xfedc) +#define PWMA_BKR (*(unsigned char volatile xdata *)0xfedd) +#define PWMA_DTR (*(unsigned char volatile xdata *)0xfede) +#define PWMA_OISR (*(unsigned char volatile xdata *)0xfedf) +#define PWMB_CR1 (*(unsigned char volatile xdata *)0xfee0) +#define PWMB_CR2 (*(unsigned char volatile xdata *)0xfee1) +#define PWMB_SMCR (*(unsigned char volatile xdata *)0xfee2) +#define PWMB_ETR (*(unsigned char volatile xdata *)0xfee3) +#define PWMB_IER (*(unsigned char volatile xdata *)0xfee4) +#define PWMB_SR1 (*(unsigned char volatile xdata *)0xfee5) +#define PWMB_SR2 (*(unsigned char volatile xdata *)0xfee6) +#define PWMB_EGR (*(unsigned char volatile xdata *)0xfee7) +#define PWMB_CCMR1 (*(unsigned char volatile xdata *)0xfee8) +#define PWMB_CCMR2 (*(unsigned char volatile xdata *)0xfee9) +#define PWMB_CCMR3 (*(unsigned char volatile xdata *)0xfeea) +#define PWMB_CCMR4 (*(unsigned char volatile xdata *)0xfeeb) +#define PWMB_CCER1 (*(unsigned char volatile xdata *)0xfeec) +#define PWMB_CCER2 (*(unsigned char volatile xdata *)0xfeed) +#define PWMB_CNTR (*(unsigned int volatile xdata *)0xfeee) +#define PWMB_CNTRH (*(unsigned char volatile xdata *)0xfeee) +#define PWMB_CNTRL (*(unsigned char volatile xdata *)0xfeef) +#define PWMB_PSCR (*(unsigned int volatile xdata *)0xfef0) +#define PWMB_PSCRH (*(unsigned char volatile xdata *)0xfef0) +#define PWMB_PSCRL (*(unsigned char volatile xdata *)0xfef1) +#define PWMB_ARR (*(unsigned int volatile xdata *)0xfef2) +#define PWMB_ARRH (*(unsigned char volatile xdata *)0xfef2) +#define PWMB_ARRL (*(unsigned char volatile xdata *)0xfef3) +#define PWMB_RCR (*(unsigned char volatile xdata *)0xfef4) +#define PWMB_CCR5 (*(unsigned int volatile xdata *)0xfef5) +#define PWMB_CCR5H (*(unsigned char volatile xdata *)0xfef5) +#define PWMB_CCR5L (*(unsigned char volatile xdata *)0xfef6) +#define PWMB_CCR6 (*(unsigned int volatile xdata *)0xfef7) +#define PWMB_CCR6H (*(unsigned char volatile xdata *)0xfef7) +#define PWMB_CCR6L (*(unsigned char volatile xdata *)0xfef8) +#define PWMB_CCR7 (*(unsigned int volatile xdata *)0xfef9) +#define PWMB_CCR7H (*(unsigned char volatile xdata *)0xfef9) +#define PWMB_CCR7L (*(unsigned char volatile xdata *)0xfefa) +#define PWMB_CCR8 (*(unsigned int volatile xdata *)0xfefb) +#define PWMB_CCR8H (*(unsigned char volatile xdata *)0xfefb) +#define PWMB_CCR8L (*(unsigned char volatile xdata *)0xfefc) +#define PWMB_BKR (*(unsigned char volatile xdata *)0xfefd) +#define PWMB_DTR (*(unsigned char volatile xdata *)0xfefe) +#define PWMB_OISR (*(unsigned char volatile xdata *)0xfeff) + +///////////////////////////////////////////////// +//FD00H-FDFFH +///////////////////////////////////////////////// + +#define P0INTE (*(unsigned char volatile xdata *)0xfd00) +#define P1INTE (*(unsigned char volatile xdata *)0xfd01) +#define P2INTE (*(unsigned char volatile xdata *)0xfd02) +#define P3INTE (*(unsigned char volatile xdata *)0xfd03) +#define P4INTE (*(unsigned char volatile xdata *)0xfd04) +#define P5INTE (*(unsigned char volatile xdata *)0xfd05) +#define P6INTE (*(unsigned char volatile xdata *)0xfd06) +#define P7INTE (*(unsigned char volatile xdata *)0xfd07) +#define P0INTF (*(unsigned char volatile xdata *)0xfd10) +#define P1INTF (*(unsigned char volatile xdata *)0xfd11) +#define P2INTF (*(unsigned char volatile xdata *)0xfd12) +#define P3INTF (*(unsigned char volatile xdata *)0xfd13) +#define P4INTF (*(unsigned char volatile xdata *)0xfd14) +#define P5INTF (*(unsigned char volatile xdata *)0xfd15) +#define P6INTF (*(unsigned char volatile xdata *)0xfd16) +#define P7INTF (*(unsigned char volatile xdata *)0xfd17) +#define P0IM0 (*(unsigned char volatile xdata *)0xfd20) +#define P1IM0 (*(unsigned char volatile xdata *)0xfd21) +#define P2IM0 (*(unsigned char volatile xdata *)0xfd22) +#define P3IM0 (*(unsigned char volatile xdata *)0xfd23) +#define P4IM0 (*(unsigned char volatile xdata *)0xfd24) +#define P5IM0 (*(unsigned char volatile xdata *)0xfd25) +#define P6IM0 (*(unsigned char volatile xdata *)0xfd26) +#define P7IM0 (*(unsigned char volatile xdata *)0xfd27) +#define P0IM1 (*(unsigned char volatile xdata *)0xfd30) +#define P1IM1 (*(unsigned char volatile xdata *)0xfd31) +#define P2IM1 (*(unsigned char volatile xdata *)0xfd32) +#define P3IM1 (*(unsigned char volatile xdata *)0xfd33) +#define P4IM1 (*(unsigned char volatile xdata *)0xfd34) +#define P5IM1 (*(unsigned char volatile xdata *)0xfd35) +#define P6IM1 (*(unsigned char volatile xdata *)0xfd36) +#define P7IM1 (*(unsigned char volatile xdata *)0xfd37) +#define P0WKUE (*(unsigned char volatile xdata *)0xfd40) +#define P1WKUE (*(unsigned char volatile xdata *)0xfd41) +#define P2WKUE (*(unsigned char volatile xdata *)0xfd42) +#define P3WKUE (*(unsigned char volatile xdata *)0xfd43) +#define P4WKUE (*(unsigned char volatile xdata *)0xfd44) +#define P5WKUE (*(unsigned char volatile xdata *)0xfd45) +#define P6WKUE (*(unsigned char volatile xdata *)0xfd46) +#define P7WKUE (*(unsigned char volatile xdata *)0xfd47) +#define PIN_IP (*(unsigned char volatile xdata *)0xfd60) +#define PIN_IPH (*(unsigned char volatile xdata *)0xfd61) + +///////////////////////////////////////////////// +//FC00H-FCFFH +///////////////////////////////////////////////// + +#define MD3 (*(unsigned char volatile xdata *)0xfcf0) +#define MD2 (*(unsigned char volatile xdata *)0xfcf1) +#define MD1 (*(unsigned char volatile xdata *)0xfcf2) +#define MD0 (*(unsigned char volatile xdata *)0xfcf3) +#define MD5 (*(unsigned char volatile xdata *)0xfcf4) +#define MD4 (*(unsigned char volatile xdata *)0xfcf5) +#define ARCON (*(unsigned char volatile xdata *)0xfcf6) +#define OPCON (*(unsigned char volatile xdata *)0xfcf7) + +///////////////////////////////////////////////// +//FB00H-FBFFH +///////////////////////////////////////////////// + +#define COMEN (*(unsigned char volatile xdata *)0xfb00) +#define SEGENL (*(unsigned char volatile xdata *)0xfb01) +#define SEGENH (*(unsigned char volatile xdata *)0xfb02) +#define LEDCTRL (*(unsigned char volatile xdata *)0xfb03) +#define LEDCKS (*(unsigned char volatile xdata *)0xfb04) +#define COM0_DA_L (*(unsigned char volatile xdata *)0xfb10) +#define COM1_DA_L (*(unsigned char volatile xdata *)0xfb11) +#define COM2_DA_L (*(unsigned char volatile xdata *)0xfb12) +#define COM3_DA_L (*(unsigned char volatile xdata *)0xfb13) +#define COM4_DA_L (*(unsigned char volatile xdata *)0xfb14) +#define COM5_DA_L (*(unsigned char volatile xdata *)0xfb15) +#define COM6_DA_L (*(unsigned char volatile xdata *)0xfb16) +#define COM7_DA_L (*(unsigned char volatile xdata *)0xfb17) +#define COM0_DA_H (*(unsigned char volatile xdata *)0xfb18) +#define COM1_DA_H (*(unsigned char volatile xdata *)0xfb19) +#define COM2_DA_H (*(unsigned char volatile xdata *)0xfb1a) +#define COM3_DA_H (*(unsigned char volatile xdata *)0xfb1b) +#define COM4_DA_H (*(unsigned char volatile xdata *)0xfb1c) +#define COM5_DA_H (*(unsigned char volatile xdata *)0xfb1d) +#define COM6_DA_H (*(unsigned char volatile xdata *)0xfb1e) +#define COM7_DA_H (*(unsigned char volatile xdata *)0xfb1f) +#define COM0_DC_L (*(unsigned char volatile xdata *)0xfb20) +#define COM1_DC_L (*(unsigned char volatile xdata *)0xfb21) +#define COM2_DC_L (*(unsigned char volatile xdata *)0xfb22) +#define COM3_DC_L (*(unsigned char volatile xdata *)0xfb23) +#define COM4_DC_L (*(unsigned char volatile xdata *)0xfb24) +#define COM5_DC_L (*(unsigned char volatile xdata *)0xfb25) +#define COM6_DC_L (*(unsigned char volatile xdata *)0xfb26) +#define COM7_DC_L (*(unsigned char volatile xdata *)0xfb27) +#define COM0_DC_H (*(unsigned char volatile xdata *)0xfb28) +#define COM1_DC_H (*(unsigned char volatile xdata *)0xfb29) +#define COM2_DC_H (*(unsigned char volatile xdata *)0xfb2a) +#define COM3_DC_H (*(unsigned char volatile xdata *)0xfb2b) +#define COM4_DC_H (*(unsigned char volatile xdata *)0xfb2c) +#define COM5_DC_H (*(unsigned char volatile xdata *)0xfb2d) +#define COM6_DC_H (*(unsigned char volatile xdata *)0xfb2e) +#define COM7_DC_H (*(unsigned char volatile xdata *)0xfb2f) + +#define TSCHEN1 (*(unsigned char volatile xdata *)0xfb40) +#define TSCHEN2 (*(unsigned char volatile xdata *)0xfb41) +#define TSCFG1 (*(unsigned char volatile xdata *)0xfb42) +#define TSCFG2 (*(unsigned char volatile xdata *)0xfb43) +#define TSWUTC (*(unsigned char volatile xdata *)0xfb44) +#define TSCTRL (*(unsigned char volatile xdata *)0xfb45) +#define TSSTA1 (*(unsigned char volatile xdata *)0xfb46) +#define TSSTA2 (*(unsigned char volatile xdata *)0xfb47) +#define TSRT (*(unsigned char volatile xdata *)0xfb48) +#define TSDAT (*(unsigned int volatile xdata *)0xfb49) +#define TSDATH (*(unsigned char volatile xdata *)0xfb49) +#define TSDATL (*(unsigned char volatile xdata *)0xfb4A) +#define TSTH00 (*(unsigned int volatile xdata *)0xfb50) +#define TSTH00H (*(unsigned char volatile xdata *)0xfb50) +#define TSTH00L (*(unsigned char volatile xdata *)0xfb51) +#define TSTH01 (*(unsigned int volatile xdata *)0xfb52) +#define TSTH01H (*(unsigned char volatile xdata *)0xfb52) +#define TSTH01L (*(unsigned char volatile xdata *)0xfb53) +#define TSTH02 (*(unsigned int volatile xdata *)0xfb54) +#define TSTH02H (*(unsigned char volatile xdata *)0xfb54) +#define TSTH02L (*(unsigned char volatile xdata *)0xfb55) +#define TSTH03 (*(unsigned int volatile xdata *)0xfb56) +#define TSTH03H (*(unsigned char volatile xdata *)0xfb56) +#define TSTH03L (*(unsigned char volatile xdata *)0xfb57) +#define TSTH04 (*(unsigned int volatile xdata *)0xfb58) +#define TSTH04H (*(unsigned char volatile xdata *)0xfb58) +#define TSTH04L (*(unsigned char volatile xdata *)0xfb59) +#define TSTH05 (*(unsigned int volatile xdata *)0xfb5a) +#define TSTH05H (*(unsigned char volatile xdata *)0xfb5a) +#define TSTH05L (*(unsigned char volatile xdata *)0xfb5b) +#define TSTH06 (*(unsigned int volatile xdata *)0xfb5c) +#define TSTH06H (*(unsigned char volatile xdata *)0xfb5c) +#define TSTH06L (*(unsigned char volatile xdata *)0xfb5d) +#define TSTH07 (*(unsigned int volatile xdata *)0xfb5e) +#define TSTH07H (*(unsigned char volatile xdata *)0xfb5e) +#define TSTH07L (*(unsigned char volatile xdata *)0xfb5f) +#define TSTH08 (*(unsigned int volatile xdata *)0xfb60) +#define TSTH08H (*(unsigned char volatile xdata *)0xfb60) +#define TSTH08L (*(unsigned char volatile xdata *)0xfb61) +#define TSTH09 (*(unsigned int volatile xdata *)0xfb62) +#define TSTH09H (*(unsigned char volatile xdata *)0xfb62) +#define TSTH09L (*(unsigned char volatile xdata *)0xfb63) +#define TSTH10 (*(unsigned int volatile xdata *)0xfb64) +#define TSTH10H (*(unsigned char volatile xdata *)0xfb64) +#define TSTH10L (*(unsigned char volatile xdata *)0xfb65) +#define TSTH11 (*(unsigned int volatile xdata *)0xfb66) +#define TSTH11H (*(unsigned char volatile xdata *)0xfb66) +#define TSTH11L (*(unsigned char volatile xdata *)0xfb67) +#define TSTH12 (*(unsigned int volatile xdata *)0xfb68) +#define TSTH12H (*(unsigned char volatile xdata *)0xfb68) +#define TSTH12L (*(unsigned char volatile xdata *)0xfb69) +#define TSTH13 (*(unsigned int volatile xdata *)0xfb6a) +#define TSTH13H (*(unsigned char volatile xdata *)0xfb6a) +#define TSTH13L (*(unsigned char volatile xdata *)0xfb6b) +#define TSTH14 (*(unsigned int volatile xdata *)0xfb6c) +#define TSTH14H (*(unsigned char volatile xdata *)0xfb6c) +#define TSTH14L (*(unsigned char volatile xdata *)0xfb6d) +#define TSTH15 (*(unsigned int volatile xdata *)0xfb6e) +#define TSTH15H (*(unsigned char volatile xdata *)0xfb6e) +#define TSTH15L (*(unsigned char volatile xdata *)0xfb6f) + +///////////////////////////////////////////////// +//FA00H-FAFFH +///////////////////////////////////////////////// + + +///////////////////////////////////////////////// + +#endif + diff --git a/source/ctask/task.h b/source/ctask/task.h index ee75f39..33cde0e 100644 --- a/source/ctask/task.h +++ b/source/ctask/task.h @@ -52,6 +52,7 @@ typedef struct _ts_task //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>鍐呴儴璋冪敤 s->task #define L2_task_delay_over() s->task.sh = s->task.sh_next #define L2_task_go(next) s->task.sh = next; +//#define L2_task_gogogo(next) s->task.sh = next; #define L2_task_en(onf) s->task.en = onf; #define L2_task_busy(s) (D_task_close != s.task.sh) diff --git a/source/ctask/tick.h b/source/ctask/tick.h index 29c91ac..bc47af5 100644 --- a/source/ctask/tick.h +++ b/source/ctask/tick.h @@ -15,7 +15,7 @@ struct _s_nos_tick_ { - vU32 jiffies; // noos绯荤粺瀹氭椂鍣ㄦ渶灏忔妧鏈崟鍏 + vU32 jiffies; // noos绯荤粺瀹氭椂鍣ㄦ渶灏忚鏃跺崟鍏 vU32 t_1s; vU8 t1s_heatbeart; //noos 绯荤粺瀹氭椂鍣ㄦ暣绉掓椂鍒绘爣蹇,闇瑕佽蒋浠舵竻闄 }; @@ -26,7 +26,7 @@ extern struct _s_nos_tick_ s_nos_tick; #elif(TYPE_JIFFIES_10MS == D_sys_Jiffies) #define HZ 100 #elif(TYPE_JIFFIES_25MS == D_sys_Jiffies) - #define HZ 50 + #define HZ 40 #endif #define JIFFIES (1000/HZ) diff --git a/source/debug/cc_as_stc01_main.ini b/source/debug/cc_as_stc01_main.ini deleted file mode 100644 index 7636777..0000000 --- a/source/debug/cc_as_stc01_main.ini +++ /dev/null @@ -1,7 +0,0 @@ -//MODE COM4 9600,0,8,1 -//ASSIGN COM4 < SIN > SOUT -// please "dir vtreg" and show the -MODE COM2 115200,0,8,1 -ASSIGN COM2 < S0IN > S0OUT -//MODE COM1 9600,0,8,1 -//ASSIGN COM1 < S0IN > S0OUT diff --git a/source/debug/cc_ls_03_debug.ini b/source/debug/cc_ls_03_debug.ini deleted file mode 100644 index 87a0def..0000000 --- a/source/debug/cc_ls_03_debug.ini +++ /dev/null @@ -1,6 +0,0 @@ -//MODE COM4 9600,0,8,1 -//ASSIGN COM4 < SIN > SOUT -MODE COM6 9600,0,8,1 -ASSIGN COM6 < S0IN > S0OUT -//MODE COM1 9600,0,8,1 -//ASSIGN COM1 < S0IN > S0OUT diff --git a/source/debug/debug.ini b/source/debug/debug.ini deleted file mode 100644 index 203177f..0000000 --- a/source/debug/debug.ini +++ /dev/null @@ -1,123 +0,0 @@ -MODE COM1 9600,0,8,1 -//assign com1 SOUT -ASSIGN COM1 < SIN > SOUT -//ASSIGN WIN SOUT -KILL FUNC * -KILL BUTTON * - - -//swatch(0.5) -DEFINE BUTTON "adc", "adc()" -signal void adc (void) { -// while (1) { /* repeat forever */ - P14= 0; /* set PORTA bit 0 */ - printf("adc is on\n"); - twatch(500); - //} /* repeat */ -} - -DEFINE BUTTON "k1 ", "k1()" -signal void k1 (void) { -P2.0= 0; - //P20= 0; - printf("K1 down\n"); - swatch(0.17); - P2.0= 1; - //P20= 1; - swatch(0.17); - printf("K1 up\n"); -} - - -DEFINE BUTTON "k2 ", "k2()" -signal void k2 (void) { - P2.1= 0; - //P21= 0; - printf("K2 down\n"); - swatch(0.17); - P2.1= 1; - //P21= 1; - swatch(0.17); - printf("K2 up\n"); -} - - -DEFINE BUTTON "k3 ", "k3()" -signal void k3 (void) { - P2.2= 0; - //P22= 0; - printf("K3 down\n"); - swatch(0.07); - P2.2= 1; - //P22= 1; - swatch(0.07); - printf("K3 up\n"); -} - - - - -DEFINE BUTTON "kx4 enter/", "kx4()" -signal void kx4 (void) { - - P13= 0; /* set PORTA bit 0 */ - printf("Kx4 down\n"); - swatch(0.07); - - P13= 1; - swatch(0.07); - printf("Kx4 up\n"); -} - -DEFINE BUTTON "<-- kx1_left ", "kx1_left()" -signal void kx1_left (void) { - - P12= 0; /* set PORTA bit 0 */ - - printf("kx1_left down\n"); - swatch(0.07); - P11= 0; - swatch(0.07); - - P12= 1; - swatch(0.07); - P11= 1; - swatch(0.07); - printf("kx1_left up\n"); - -} - -DEFINE BUTTON "kx1_right--> ", "kx1_right()" -signal void kx1_right (void) { - - P11= 0; /* set PORTA bit 0 */ - - printf("kx1_right down\n"); - swatch(0.07); - P12= 0; - swatch(0.07); - - P11= 1; - swatch(0.07); - P12= 1; - swatch(0.07); - printf("kx1_right up\n"); - -} -DEFINE BUTTON "My Registers", "MyRegs()" - -FUNC void MyRegs (void) { - printf ("---------- MyRegs() ----------\n"); - printf (" R4 R8 R9 R10 R11 R12\n"); - printf (" %04X %04X %04X %04X %04X %04X\n", - R0, R1, R2, R3, R4, R5); - printf ("------------------------------\n"); -} - - - -//bs write P3,1,"check_moto()"//如果有写p2的动作则会执行这个 signal函数。 -//signal void check_moto (void) - - - diff --git a/source/debug/testiic.uvla b/source/debug/testiic.uvla deleted file mode 100644 index 95fb5b0..0000000 Binary files a/source/debug/testiic.uvla and /dev/null differ diff --git a/source/msp/UART0.C b/source/msp/UART0.C index ed7c42e..999ac97 100644 --- a/source/msp/UART0.C +++ b/source/msp/UART0.C @@ -59,71 +59,33 @@ msp/uartx.c 搴曞眰浠g爜 鍜宑pu鐩稿叧 缂撳瓨鍙戦佷篃鏀惧湪閲岄潰 //#define _USE_485 static volatile Ts_uart_send_buf idata ts_uart_send_shop; + TP_Handler_X s_uart0_rec; TS_PH4_modbus s_uart0_ack; void L0_uart0_init(void) { -#if(MainFre_22M == D_sys_MainFre) //115200bps@22.1184MHz - SCON = 0x50; //8浣嶆暟鎹,鍙彉娉㈢壒鐜 - AUXR |= 0x40; //瀹氭椂鍣1鏃堕挓涓篎osc,鍗1T - AUXR &= 0xFE; //涓插彛1閫夋嫨瀹氭椂鍣1涓烘尝鐗圭巼鍙戠敓鍣 - TMOD &= 0x0F; //璁惧畾瀹氭椂鍣1涓16浣嶈嚜鍔ㄩ噸瑁呮柟寮 - TL1 = 0xD0; //璁惧畾瀹氭椂鍒濆 - TH1 = 0xFF; //璁惧畾瀹氭椂鍒濆 - ET1 = 0; //绂佹瀹氭椂鍣1涓柇 - TR1 = 1; //鍚姩瀹氭椂鍣1 - -#elif(MainFre_11M == D_sys_MainFre) //115200bps@22.1184MHz - -#if(BRT_115200 == D_uart0_BRT && SBIT_1 == D_uart0_SBIT) //115200bps@11.0592MHz + U16 val = D_BRT_COUNT(12,D_sys_MainFre,D_uart0_BRT); SCON = 0x50; //8浣嶆暟鎹,鍙彉娉㈢壒鐜 AUXR |= 0x01; //涓插彛1閫夋嫨瀹氭椂鍣2涓烘尝鐗圭巼鍙戠敓鍣 AUXR &= 0xFB; //瀹氭椂鍣2鏃堕挓涓篎osc/12,鍗12T - T2L = 0xFE; //璁惧畾瀹氭椂鍒濆 - T2H = 0xFF; //璁惧畾瀹氭椂鍒濆 + //T2L = 0xFE; //璁惧畾瀹氭椂鍒濆 + //T2H = 0xFF; //璁惧畾瀹氭椂鍒濆 + T2L = val; + T2H = val >> 8; AUXR |= 0x10; //鍚姩瀹氭椂鍣2 - -#elif(BRT_19200 == D_uart0_BRT && SBIT_1 == D_uart0_SBIT) //19200@11.0592MHz - xxxx - SCON = 0x50; //8浣嶆暟鎹,鍙彉娉㈢壒鐜 - AUXR |= 0x01; //涓插彛1閫夋嫨瀹氭椂鍣2涓烘尝鐗圭巼鍙戠敓鍣 - AUXR |= 0x04; //瀹氭椂鍣2鏃堕挓涓篎osc,鍗1T - T2L = 0x70; //璁惧畾瀹氭椂鍒濆 - T2H = 0xFF; //璁惧畾瀹氭椂鍒濆 - AUXR |= 0x10; //鍚姩瀹氭椂鍣2 -#elif(BRT_19200 == D_uart0_BRT && SBIT_2 == D_uart0_SBIT) //19200@11.0592MHz - xxx - //浣跨敤绗9浣嶆暟鎹ā鎷1涓仠姝綅,鍙彉娉㈢壒鐜;SM2=0, TB8=1(绗9bit鎬讳负1妯℃嫙1涓仠姝綅) - SCON = 0xD8; - AUXR |= 0x01; //涓插彛1閫夋嫨瀹氭椂鍣2涓烘尝鐗圭巼鍙戠敓鍣 - AUXR |= 0x04; //瀹氭椂鍣2鏃堕挓涓篎osc,鍗1T - T2L = 0x70; //璁惧畾瀹氭椂鍒濆 - T2H = 0xFF; //璁惧畾瀹氭椂鍒濆 - AUXR |= 0x10; //鍚姩瀹氭椂鍣2 -#elif (BRT_9600 == D_uart0_BRT) //9600bps@11.0592MHz - xxx - SCON = 0x50; //8浣嶆暟鎹,鍙彉娉㈢壒鐜 - AUXR |= 0x01; //涓插彛1閫夋嫨瀹氭椂鍣2涓烘尝鐗圭巼鍙戠敓鍣 - AUXR &= 0xFB; //瀹氭椂鍣2鏃堕挓涓篎osc/12,鍗12T - T2L = 0xE8; //璁惧畾瀹氭椂鍒濆 - T2H = 0xFF; //璁惧畾瀹氭椂鍒濆 - AUXR |= 0x10; //鍚姩瀹氭椂鍣2 -#endif -#endif//D_sys_MainFre) } void L0_uart0_buf_init(void) { ts_uart[uNum0].p = &ts_uart_send_shop; - ts_uart[uNum0].p->now = 0; + ts_uart[uNum0].p->max = ts_uart[uNum0].p->now = 0; ts_uart[uNum0].p->ok = D_ready; ts_uart[uNum0].t = &s_uart0_rec; - //ts_uart[uNum0].t->head_0 = D_CMD_Filter1_ff; - //ts_uart[uNum0].t->head_1 = D_CMD_Filter1_fe; ts_uart[uNum0].t->head = 0; ts_uart[uNum0].t->ok = 0; - ts_uart[uNum0].tp_handler = L1_s2b_PH4; + //ts_uart[uNum0].tp_handler = L1_s2b_PH4; + ts_uart[uNum0].tp_handler = NULL; //浣跨敤鍑芥暟鎸囬拡瀵艰嚧閿欒 ts_uart[uNum0].ack = (U8*)&s_uart0_ack; L0_uart0_init(); D_uart0_ES_INT(1); //鎵撳紑涓插彛涓柇 @@ -150,9 +112,10 @@ void INTERRUPT_UART(void) D_SERVE_UART if(L0_uart0_IntRI()) //濡傛灉鏄疷0鎺ユ敹涓柇 { L0_uart0_IntRIClear(); //娓呴櫎鎺ユ敹涓柇鏍囧織 - L0_timer1_start(0); ts_uart[uNum0].t->reg = L0_uartN_get(uNum0); - ts_uart[uNum0].tp_handler(ts_uart[uNum0].t); + //ts_uart[uNum0].tp_handler(ts_uart[uNum0].t); + L1_s2b_PH4(ts_uart[uNum0].t); + L0_timer1_restart(); } if(L0_uart0_IntTI()) //濡傛灉鏄疷0鍙戦佷腑鏂 { @@ -168,50 +131,30 @@ void INTERRUPT_UART(void) D_SERVE_UART ts_uart[uNum0].p->max = 0; ts_uart[uNum0].p->now = 0;//鍙互鍙戦佷笅涓涓暟鎹 #if (D_UART0_485_TYPE != TYPE_485_NONE) - D_UART0_485_RX() //鍒囨崲鍒版帴鏀剁姸鎬 + D_UART0_485_RX() //鍒囨崲鍒版帴鏀剁姸鎬 #endif } } //NOP(); NOP(); NOP(); } -#if 0 -void timer1_isrHanddle (void) D_SERVE_TIMER1 -{// - TF1 = 0; - //s_nos_tick.uart0_free = 1; - //if(s_uart0_rec.head == 1) //鏀跺埌涓鏉″崗璁 - if(s_uart0_rec.head == 1) //鏀跺埌涓鏉″崗璁 - { - s_uart0_rec.head = 0; - P10 ^= 1; - if(s_uart0_rec.ok == 0) - { - s_uart0_rec.ok = 1; - //Lc_buf_copy_uc(); - } - } -} -#else void timer1_isrHanddle(void) D_SERVE_TIMER1 { struct _tp_handler_x *p = &s_uart0_rec; + if((p->head == 1) && (p->num >= D_s_modbus_min)) { + //LED1 ^= 1; p->head = 0; crc16(p->crc,p->buf,p->num - 2); //鏍¢獙CRC if(p->crc[0] == p->buf[p->num-2] && p->crc[1] == p->buf[p->num-1]) - { - if(p->ok == 0) - { - p->ok = 1; - } + { + p->ok = 1; + LED0 ^= 1; } - LED0 ^= 1; } L0_timer1_stop(); } -#endif diff --git a/source/msp/UART0.h b/source/msp/UART0.h index 91224b6..37bd779 100644 --- a/source/msp/UART0.h +++ b/source/msp/UART0.h @@ -53,8 +53,8 @@ msp/uartx.c 搴曞眰浠g爜 鍜宑pu鐩稿叧 缂撳瓨鍙戦佷篃鏀惧湪閲岄潰 #ifndef _uart0_H #define _uart0_H #include "../bsp/bsp_config.h" -#include "../tpc/tpc_modbus.h" -#include "uartN.h" +#include "../tpc/modbus.h" +#include "uart_x.h" //#include "../tpc/tpc_x.h" diff --git a/source/msp/eeprom.c b/source/msp/eeprom.c new file mode 100644 index 0000000..78ff57c --- /dev/null +++ b/source/msp/eeprom.c @@ -0,0 +1,222 @@ +//////////////////////////////////////////////////////////////////////////// +///@copyright Copyright (c) 2018, 浼犳帶绉戞妧 All rights reserved. +///------------------------------------------------------------------------- +/// @file msp_eeprom.c +/// @brief msp @ driver config +///------------------------------------------------------------------------- +/// @version 1.0 +/// @author CC +/// @date 20190106 +/// @note cc_AS_stc02 鐢眘tc-isp v6.0860 +////////////////////////////////////////////////////////////////////////////// +#include "eeprom.h" +#include "../bsp/bsp_config.h" + +struct eeprom_block_t eep_block; + +#if(TYPE_MCU == TYPE_MCU_STC_8A || TYPE_MCU == TYPE_MCU_STC_8F) +#define WT_30M 0x80 +#define WT_24M 0x81 +#define WT_20M 0x82 +#define WT_12M 0x83 +#define WT_6M 0x84 +#define WT_3M 0x85 +#define WT_2M 0x86 +#define WT_1M 0x87 + + +void L0_Iap_Idle() +{ + IAP_CONTR = 0; //鍏抽棴IAP鍔熻兘 + IAP_CMD = 0; //娓呴櫎鍛戒护瀵勫瓨鍣 + IAP_TRIG = 0; //娓呴櫎瑙﹀彂瀵勫瓨鍣 + IAP_ADDRH = 0x80; //灏嗗湴鍧璁剧疆鍒伴潪IAP鍖哄煙 + IAP_ADDRL = 0; +} + +char L0_Iap_Read(vU16 addr) +{ + char dat; + + IAP_CONTR = WT_12M; //浣胯兘IAP + IAP_CMD = 1; //璁剧疆IAP璇诲懡浠 + IAP_ADDRL = addr; //璁剧疆IAP浣庡湴鍧 + IAP_ADDRH = addr >> 8; //璁剧疆IAP楂樺湴鍧 + IAP_TRIG = 0x5a; //鍐欒Е鍙戝懡浠(0x5a) + IAP_TRIG = 0xa5; //鍐欒Е鍙戝懡浠(0xa5) + _nop_(); + dat = IAP_DATA; //璇籌AP鏁版嵁 + L0_Iap_Idle(); //鍏抽棴IAP鍔熻兘 + + return dat; +} + +void L0_Iap_Program(vU16 addr, char dat) +{ + IAP_CONTR = WT_12M; //浣胯兘IAP + IAP_CMD = 2; //璁剧疆IAP鍐欏懡浠 + IAP_ADDRL = addr; //璁剧疆IAP浣庡湴鍧 + IAP_ADDRH = addr >> 8; //璁剧疆IAP楂樺湴鍧 + IAP_DATA = dat; //鍐橧AP鏁版嵁 + IAP_TRIG = 0x5a; //鍐欒Е鍙戝懡浠(0x5a) + IAP_TRIG = 0xa5; //鍐欒Е鍙戝懡浠(0xa5) + _nop_(); + L0_Iap_Idle(); //鍏抽棴IAP鍔熻兘 +} + +///姣忎釜鎵囧尯512瀛楄妭 +///鎸囧畾鍦板潃鍙互涓哄綋鍓嶆墖鍖哄唴鐨勪换鎰忓湴鍧锛岄兘浼氬畬鏁存摝闄ゅ綋鍓嶆墖鍖 +void L0_Iap_Erase(vU16 addr) +{ + IAP_CONTR = WT_12M; //浣胯兘IAP + IAP_CMD = 3; //璁剧疆IAP鎿﹂櫎鍛戒护 + IAP_ADDRL = addr; //璁剧疆IAP浣庡湴鍧 + IAP_ADDRH = addr >> 8; //璁剧疆IAP楂樺湴鍧 + IAP_TRIG = 0x5a; //鍐欒Е鍙戝懡浠(0x5a) + IAP_TRIG = 0xa5; //鍐欒Е鍙戝懡浠(0xa5) + _nop_(); // + L0_Iap_Idle(); //鍏抽棴IAP鍔熻兘 +} + +#elif (TYPE_MCU == TYPE_MCU_STC_8G || TYPE_MCU == TYPE_MCU_STC_8H) +void L0_Iap_Idle() +{ + IAP_CONTR = 0; //鍏抽棴IAP鍔熻兘 + IAP_CMD = 0; //娓呴櫎鍛戒护瀵勫瓨鍣 + IAP_TRIG = 0; //娓呴櫎瑙﹀彂瀵勫瓨鍣 + IAP_ADDRH = 0x80; //灏嗗湴鍧璁剧疆鍒伴潪IAP鍖哄煙 + IAP_ADDRL = 0; +} + +char L0_Iap_Read(vU16 addr) +{ + char dat; + + IAP_CONTR = 0x80; //浣胯兘IAP + IAP_TPS = 12; + IAP_CMD = 1; //璁剧疆IAP璇诲懡浠 + IAP_ADDRL = addr; //璁剧疆IAP浣庡湴鍧 + IAP_ADDRH = addr >> 8; //璁剧疆IAP楂樺湴鍧 + IAP_TRIG = 0x5a; //鍐欒Е鍙戝懡浠(0x5a) + IAP_TRIG = 0xa5; //鍐欒Е鍙戝懡浠(0xa5) + _nop_(); + dat = IAP_DATA; //璇籌AP鏁版嵁 + L0_Iap_Idle(); //鍏抽棴IAP鍔熻兘 + + return dat; +} + +void L0_Iap_Program(vU16 addr, char dat) +{ + IAP_CONTR = 0x80; //浣胯兘IAP + IAP_TPS = 12; //璁剧疆鎿﹂櫎绛夊緟鍙傛暟 12MHz + IAP_CMD = 2; //璁剧疆IAP鍐欏懡浠 + IAP_ADDRL = addr; //璁剧疆IAP浣庡湴鍧 + IAP_ADDRH = addr >> 8; //璁剧疆IAP楂樺湴鍧 + IAP_DATA = dat; //鍐橧AP鏁版嵁 + IAP_TRIG = 0x5a; //鍐欒Е鍙戝懡浠(0x5a) + IAP_TRIG = 0xa5; //鍐欒Е鍙戝懡浠(0xa5) + _nop_(); + L0_Iap_Idle(); //鍏抽棴IAP鍔熻兘 +} + +///姣忎釜鎵囧尯512瀛楄妭 +///鎸囧畾鍦板潃鍙互涓哄綋鍓嶆墖鍖哄唴鐨勪换鎰忓湴鍧锛岄兘浼氬畬鏁存摝闄ゅ綋鍓嶆墖鍖 +void L0_Iap_Erase(vU16 addr) +{ + IAP_CONTR = 0x80; //浣胯兘IAP + IAP_TPS = 12; //璁剧疆鎿﹂櫎绛夊緟鍙傛暟 12MHz + IAP_CMD = 3; //璁剧疆IAP鎿﹂櫎鍛戒护 + IAP_ADDRL = addr; //璁剧疆IAP浣庡湴鍧 + IAP_ADDRH = addr >> 8; //璁剧疆IAP楂樺湴鍧 + IAP_TRIG = 0x5a; //鍐欒Е鍙戝懡浠(0x5a) + IAP_TRIG = 0xa5; //鍐欒Е鍙戝懡浠(0xa5) + _nop_(); // + L0_Iap_Idle(); //鍏抽棴IAP鍔熻兘 +} +#endif + + +void L0_Iap_Program_array(vU16 addr,U8 *buf,U8 len) +{ + U8 i = 0; + for(i=0;i D_EEP_SECTOR_BLOCK_BUF_SIZE) + { + return 1; + } + + Lc_memset((U8*)&eep_block,0,sizeof(eep_block)); + eep_block.filter[0] = D_EEP_BLOCK_FILTER0; + eep_block.filter[1] = D_EEP_BLOCK_FILTER1; + eep_block.len[0] = len >> 8 & 0xFF; + eep_block.len[1] = len >> 0 & 0xFF; + for(i=0;i>>绔彛浣嶅畾涔夛紝鍙慨鏀!!!!!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -#include "../bsp/bsp_config.h" #include "uart0.h" -extern void L3_eeprom_fun(U8 *pPara); +/** + * EEPROM 瀛樺偍缁撴瀯 + * filter0 + filter1 + len0 + len1 + {data} + crc0 + crc1 + */ +#define D_EEP_SECTOR_BLOCK_BUF_SIZE (D_EEP_SECTOR_BLOCK_SIZE - 6) +typedef struct eeprom_block_t +{ + U8 filter[2]; //filter + U8 len[2]; //鏈夋晥鏁版嵁鐨勪釜鏁 + U8 buf[D_EEP_SECTOR_BLOCK_BUF_SIZE]; + U8 crc[2]; //浠巉ilter寮濮嬭繘琛屾暣浣撴牎楠 +}EEPROM_BLOCK; + +extern struct eeprom_block_t eep_block; +extern U8 L1_eep_read_block(U8 sector, U8 block, U16 blocksize, U8 *buf, U16 *plen); +extern U8 L1_eep_write_block(U8 sector, U8 block, U16 blocksize, const U8 *buf, U16 len, U8 sectorEraseFlag); +extern U8 L1_eep_erase_sector(U8 sector); + ///姣忎釜鎵囧尯512瀛楄妭 extern void L0_Iap_Erase(vU16 addr); @@ -37,6 +49,7 @@ extern char L0_Iap_Read(vU16 addr); extern void L0_Iap_Program_array(vU16 addr,U8 *buf,U8 len); extern void L0_Iap_Read_array(vU16 addr,U8 *buf,U8 len); extern void L1_Iap_main(void); +extern void L3_eeprom_fun(U8 *pPara); #endif// #ifndef _msp_eeprom_H_ diff --git a/source/msp/msp_eeprom.c b/source/msp/msp_eeprom.c deleted file mode 100644 index 51ace62..0000000 --- a/source/msp/msp_eeprom.c +++ /dev/null @@ -1,151 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -///@copyright Copyright (c) 2018, 浼犳帶绉戞妧 All rights reserved. -///------------------------------------------------------------------------- -/// @file msp_eeprom.c -/// @brief msp @ driver config -///------------------------------------------------------------------------- -/// @version 1.0 -/// @author CC -/// @date 20190106 -/// @note cc_AS_stc02 鐢眘tc-isp v6.0860 -////////////////////////////////////////////////////////////////////////////// -#include "msp_eeprom.h" - - -#define WT_30M 0x80 -#define WT_24M 0x81 -#define WT_20M 0x82 -#define WT_12M 0x83 -#define WT_6M 0x84 -#define WT_3M 0x85 -#define WT_2M 0x86 -#define WT_1M 0x87 - - -U_F16 uf_ee_add; - - -void L0_Iap_Idle() -{ - IAP_CONTR = 0; //鍏抽棴IAP鍔熻兘 - IAP_CMD = 0; //娓呴櫎鍛戒护瀵勫瓨鍣 - IAP_TRIG = 0; //娓呴櫎瑙﹀彂瀵勫瓨鍣 - IAP_ADDRH = 0x80; //灏嗗湴鍧璁剧疆鍒伴潪IAP鍖哄煙 - IAP_ADDRL = 0; -} - -char L0_Iap_Read(vU16 addr) -{ - char dat; - - IAP_CONTR = WT_12M; //浣胯兘IAP - IAP_CMD = 1; //璁剧疆IAP璇诲懡浠 - IAP_ADDRL = addr; //璁剧疆IAP浣庡湴鍧 - IAP_ADDRH = addr >> 8; //璁剧疆IAP楂樺湴鍧 - IAP_TRIG = 0x5a; //鍐欒Е鍙戝懡浠(0x5a) - IAP_TRIG = 0xa5; //鍐欒Е鍙戝懡浠(0xa5) - _nop_(); - dat = IAP_DATA; //璇籌AP鏁版嵁 - L0_Iap_Idle(); //鍏抽棴IAP鍔熻兘 - - return dat; -} - -void L0_Iap_Program(vU16 addr, char dat) -{ - IAP_CONTR = WT_12M; //浣胯兘IAP - IAP_CMD = 2; //璁剧疆IAP鍐欏懡浠 - IAP_ADDRL = addr; //璁剧疆IAP浣庡湴鍧 - IAP_ADDRH = addr >> 8; //璁剧疆IAP楂樺湴鍧 - IAP_DATA = dat; //鍐橧AP鏁版嵁 - IAP_TRIG = 0x5a; //鍐欒Е鍙戝懡浠(0x5a) - IAP_TRIG = 0xa5; //鍐欒Е鍙戝懡浠(0xa5) - _nop_(); - L0_Iap_Idle(); //鍏抽棴IAP鍔熻兘 -} - -///姣忎釜鎵囧尯512瀛楄妭 -///鎸囧畾鍦板潃鍙互涓哄綋鍓嶆墖鍖哄唴鐨勪换鎰忓湴鍧锛岄兘浼氬畬鏁存摝闄ゅ綋鍓嶆墖鍖 -void L0_Iap_Erase(vU16 addr) -{ - IAP_CONTR = WT_12M; //浣胯兘IAP - IAP_CMD = 3; //璁剧疆IAP鎿﹂櫎鍛戒护 - IAP_ADDRL = addr; //璁剧疆IAP浣庡湴鍧 - IAP_ADDRH = addr >> 8; //璁剧疆IAP楂樺湴鍧 - IAP_TRIG = 0x5a; //鍐欒Е鍙戝懡浠(0x5a) - IAP_TRIG = 0xa5; //鍐欒Е鍙戝懡浠(0xa5) - _nop_(); // - L0_Iap_Idle(); //鍏抽棴IAP鍔熻兘 -} - -void L0_Iap_Program_array(vU16 addr,U8 *buf,U8 len) -{ - U8 i = 0; - for(i=0;i>8 & 0xFF); - L0_uart0_uchex(i>>0 & 0xFF); - } - } -#endif - Lc_delay_ms(100); - L0_uart0_uc('%'); - - while(1); -} -#endif - diff --git a/source/msp/time.c b/source/msp/time.c index 7131189..8007b26 100644 --- a/source/msp/time.c +++ b/source/msp/time.c @@ -1,84 +1,28 @@ -#include "Time.h" +#include "time.h" +#define D_TIMER_COUNT(t,clk,timeInUs) (U16)(65536 - 1.0 * (clk) / 1000 * (1.0 * timeInUs / 1000) / t) +//#define D_TIMER_COUNT(t,clk,timeInUs) (U16)(65536 - (clk) / 1000 * timeInUs / 1000 / t) /*************鍒濆鍖栧畾鏃跺櫒0鐢 stc-isp v6.86L瀹氭椂鍣ㄨ绠楀櫒鐢熸垚******************/ -#if(MainFre_5M == D_sys_MainFre) -#elif(MainFre_27M == D_sys_MainFre) -#elif(MainFre_22M == D_sys_MainFre) -void L0_timer0_Init(void) //25姣@22.1184MHz +void L0_timer0_Init(void) { + U16 val = D_TIMER_COUNT(12,D_sys_MainFre,D_sys_Jiffies * 1000); AUXR &= 0x7F; //瀹氭椂鍣ㄦ椂閽12T妯″紡 TMOD &= 0xF0; //璁剧疆瀹氭椂鍣ㄦā寮 - TL0 = 0x00; //璁剧疆瀹氭椂鍒濆 - TH0 = 0x4C; //璁剧疆瀹氭椂鍒濆 + //TL0 = 0x00; //璁剧疆瀹氭椂鍒濆 + //TH0 = 0x4C; //璁剧疆瀹氭椂鍒濆 + TL0 = val; //璁剧疆瀹氭椂鍒濆 + TH0 = val >> 8; //璁剧疆瀹氭椂鍒濆 TF0 = 0; //娓呴櫎TF0鏍囧織 TR0 = 1; //瀹氭椂鍣0寮濮嬭鏃 ET0 = 1; //add by cc } -/******************************************** -void L0_timer0_Init(void) //10姣@22.1184MHz -{ - AUXR &= 0x7F; //瀹氭椂鍣ㄦ椂閽12T妯″紡 - TMOD &= 0xF0; //璁剧疆瀹氭椂鍣ㄦā寮 - TL0 = 0x00; //璁剧疆瀹氭椂鍒濆 - TH0 = 0xB8; //璁剧疆瀹氭椂鍒濆 - TF0 = 0; //娓呴櫎TF0鏍囧織 - TR0 = 1; //瀹氭椂鍣0寮濮嬭鏃 - ET0 = 1; //add by cc -} - -void L0_timer0_Init_32k(void) //4fen@32kHz -{ - AUXR &= 0x7F; //瀹氭椂鍣ㄦ椂閽12T妯″紡 - TMOD &= 0xF0; //璁剧疆瀹氭椂鍣ㄦā寮 - #if 0 - TL0 = 0x00; //璁剧疆瀹氭椂鍒濆 - TH0 = 0xB8; //璁剧疆瀹氭椂鍒濆/// 4m20s 71 - #else - TL0 = 0x00; //璁剧疆瀹氭椂鍒濆 - TH0 = 0xcc; //璁剧疆瀹氭椂鍒濆// ff 4s - - - #endif - TF0 = 0; //娓呴櫎TF0鏍囧織 - TR0 = 1; //瀹氭椂鍣0寮濮嬭鏃 - ET0 = 1; //add by cc - BITN_0(DR_who_wakeup, DRB_who_wakeup_timer0); /// 鏍囧織涓柇绫诲瀷: 瀹氭椂鍣 -} -****************************************************/ - -#else ///MainFre_11M -void L0_timer0_Init(void) //10姣@11.0592MHz -{ - AUXR &= 0x7F; //瀹氭椂鍣ㄦ椂閽12T妯″紡 - TMOD &= 0xF0; //璁剧疆瀹氭椂鍣ㄦā寮 - TL0 = 0x00; //璁剧疆瀹氭椂鍒濆 - TH0 = 0xDC; //璁剧疆瀹氭椂鍒濆 - TF0 = 0; //娓呴櫎TF0鏍囧織 - TR0 = 1; //瀹氭椂鍣0寮濮嬭鏃 - ET0 = 1; //add by cc -} - -/******************************************** -void L0_timer0_Init(void) //25姣@11.0592MHz -{ - AUXR &= 0x7F; //瀹氭椂鍣ㄦ椂閽12T妯″紡 - TMOD &= 0xF0; //璁剧疆瀹氭椂鍣ㄦā寮 - TL0 = 0x00; //璁剧疆瀹氭椂鍒濆 - TH0 = 0xA6; //璁剧疆瀹氭椂鍒濆 - TF0 = 0; //娓呴櫎TF0鏍囧織 - TR0 = 1; //瀹氭椂鍣0寮濮嬭鏃 - ET0 = 1; //add by cc -} -****************************************************/ -#endif//D_sys_MainFre) - //10---87 10s /********************** Timer0涓柇鍑芥暟************************/ /// 鍜 L0_timer0_Init 鍏宠仈,闇瑕侀厤缃 bsp_config.h涓殑 D_sys_MainFre /// 榛樿10ms 浣滀负TTSS绯荤粺鐨勫畾鏃跺紩鎿 -void timer0_isrHanddle (void) D_SERVE_TIMER0 +void timer0_isrHandle (void) D_SERVE_TIMER0 {// NOP(); NOP(); NOP(); TF0 = 0; @@ -99,96 +43,56 @@ void timer0_isrHanddle (void) D_SERVE_TIMER0 - - - - - - -#if(MainFre_5M == D_sys_MainFre) -#elif(MainFre_27M == D_sys_MainFre) -#elif(MainFre_22M == D_sys_MainFre) -/****************************** -void L0_Timer1_Init(void) //35姣@22.1184MHz -{///鑷姩閲嶈浇 - AUXR &= 0xFB; //瀹氭椂鍣ㄦ椂閽12T妯″紡 - T2L = 0x00; //璁剧疆瀹氭椂鍒濆 - T2H = 0x04; //璁剧疆瀹氭椂鍒濆 - AUXR |= 0x10; //瀹氭椂鍣2寮濮嬭鏃 - - BITN_1(IE2, ET2);// IE2 = ET2; //浣胯兘瀹氭椂鍣ㄤ腑鏂 -} -**********************************/ -#else ///MainFre_11M - -void L0_timer1_Init_7ms(void) //7姣@11.0592MHz +void L0_timer1_Init() //600寰@11.0592MHz { - AUXR &= 0xBF; //瀹氭椂鍣ㄦ椂閽12T妯″紡 +#if 0 + AUXR |= 0x40; //瀹氭椂鍣ㄦ椂閽1T妯″紡 TMOD &= 0x0F; //璁剧疆瀹氭椂鍣ㄦā寮 - TL1 = 0xCD; //璁剧疆瀹氭椂鍒濆 + TL1 = 0x14; //璁剧疆瀹氭椂鍒濆 TH1 = 0xE6; //璁剧疆瀹氭椂鍒濆 TF1 = 0; //娓呴櫎TF1鏍囧織 TR1 = 1; //瀹氭椂鍣1寮濮嬭鏃 ET1 = 1; //add by cc -} - -void L0_timer1_Init_5ms(void) //5姣@11.0592MHz -{//0x7F绀烘尝鍣ㄦ祴璇曞ぇ绾40ms锛宭ed闂儊 鑲夌溂鍙 - AUXR &= 0xBF; //瀹氭椂鍣ㄦ椂閽12T妯″紡 - TMOD &= 0x0F; //璁剧疆瀹氭椂鍣ㄦā寮 - TL1 = 0x00; //璁剧疆瀹氭椂鍒濆 - TH1 = 0xEE; //璁剧疆瀹氭椂鍒濆 - TF1 = 0; //娓呴櫎TF1鏍囧織 - TR1 = 1; //瀹氭椂鍣1寮濮嬭鏃 - ET1 = 1; //add by cc -} -void L0_timer1_Init_1ms(void) //1姣@11.0592MHz -{ +#else + U16 val = D_TIMER_COUNT(1,D_sys_MainFre,600); AUXR |= 0x40; //瀹氭椂鍣ㄦ椂閽1T妯″紡 TMOD &= 0x0F; //璁剧疆瀹氭椂鍣ㄦā寮 - TL1 = 0xCD; //璁剧疆瀹氭椂鍒濆 - TH1 = 0xD4; //璁剧疆瀹氭椂鍒濆 + //TL1 = 0xCD; //璁剧疆瀹氭椂鍒濆鍊 + //TH1 = 0xD4; //璁剧疆瀹氭椂鍒濆鍊 + TL1 = val; //璁剧疆瀹氭椂鍒濆 + TH1 = val >>8; //璁剧疆瀹氭椂鍒濆 TF1 = 0; //娓呴櫎TF1鏍囧織 TR1 = 1; //瀹氭椂鍣1寮濮嬭鏃 ET1 = 1; //add by cc +#endif } -void L0_timer1_Init(void) //600寰@11.0592MHz + +void L0_timer1_restart() //600寰@11.0592MHz { + U16 val = D_TIMER_COUNT(1,D_sys_MainFre,600); + TR1 = 0; //鍏堝叧闂紝鍚﹀垯浼氶噸澶嶄腑鏂紝璧蜂笉鍒皉esetart鏁堟灉 +#if 1 AUXR |= 0x40; //瀹氭椂鍣ㄦ椂閽1T妯″紡 TMOD &= 0x0F; //璁剧疆瀹氭椂鍣ㄦā寮 - TL1 = 0x14; //璁剧疆瀹氭椂鍒濆 - TH1 = 0xE6; //璁剧疆瀹氭椂鍒濆 + //TL1 = 0x14; //璁剧疆瀹氭椂鍒濆 + //TH1 = 0xE6; //璁剧疆瀹氭椂鍒濆 + TL1 = val; //璁剧疆瀹氭椂鍒濆 + TH1 = val >>8; //璁剧疆瀹氭椂鍒濆 TF1 = 0; //娓呴櫎TF1鏍囧織 TR1 = 1; //瀹氭椂鍣1寮濮嬭鏃 ET1 = 1; //add by cc -} - - -//0x7F绀烘尝鍣ㄦ祴璇曞ぇ绾40ms锛宭ed闂儊 鑲夌溂鍙 -void L0_timer1_reset(void) -{ - TR1 = 0; - TL1 = 0x14; //璁剧疆瀹氭椂鍒濆 - TH1 = 0xE6; //璁剧疆瀹氭椂鍒濆 - TR1 = 1; - TF1 = 0; -} -#endif//D_sys_MainFre) - - - -void L0_timer1_start(U16 v) //600寰@11.0592MHz -{ +#else AUXR |= 0x40; //瀹氭椂鍣ㄦ椂閽1T妯″紡 TMOD &= 0x0F; //璁剧疆瀹氭椂鍣ㄦā寮 - TL1 = 0x14; //璁剧疆瀹氭椂鍒濆 - TH1 = 0xE6; //璁剧疆瀹氭椂鍒濆 + TL1 = 0xCD; //璁剧疆瀹氭椂鍒濆鍊 + TH1 = 0xD4; //璁剧疆瀹氭椂鍒濆鍊 TF1 = 0; //娓呴櫎TF1鏍囧織 TR1 = 1; //瀹氭椂鍣1寮濮嬭鏃 ET1 = 1; //add by cc +#endif } void L0_timer1_stop(void) diff --git a/source/msp/time.h b/source/msp/time.h index f923c0b..6d78f09 100644 --- a/source/msp/time.h +++ b/source/msp/time.h @@ -7,7 +7,8 @@ #include "../ctask/tick.h" extern void L0_timer1_stop(void); -extern void L0_timer1_start(U16 v); +extern void L0_timer1_start(); +extern void L0_timer1_restart(void); //600寰@11.0592MHz extern void L0_timer1_Init(void); extern void L0_timer1_reset(void); extern void L0_timer1_off(void); diff --git a/source/msp/UARTN.C b/source/msp/uart_x.c similarity index 86% rename from source/msp/UARTN.C rename to source/msp/uart_x.c index 6f84292..3be3670 100644 --- a/source/msp/UARTN.C +++ b/source/msp/uart_x.c @@ -54,11 +54,11 @@ msp/uartx.c 搴曞眰浠g爜 鍜宑pu鐩稿叧 缂撳瓨鍙戦佷篃鏀惧湪閲岄潰 L0_Usend_uc------UserDef ----------------------------------------------------------------------------------------- ********************************************************************************/ -#include "uartN.h" +#include "uart_x.h" TS_uart_reg idata ts_uart[SERIAL_MAX_NUM] = {0}; -void L0_uartN_set(U8 uartx,U8 x) reentrant +void L0_uartN_set(U8 uartx,U8 x) /*reentrant*/ { switch(uartx) { @@ -99,30 +99,27 @@ void L0_waitFree_uartN(U8 uartx) } void L0_uartN_sendArray(U8 uartx,void *buf,U16 len) -{ - if(len > 0) +{ + L0_waitFree_uartN(uartx); + ts_uart[uartx].p->ok = D_clear; + ts_uart[uartx].p->over = 0; + ts_uart[uartx].p->max = len; + ts_uart[uartx].p->now = 1; + if(len <= D_UART_send_buf_max) { - L0_waitFree_uartN(uartx); - ts_uart[uartx].p->ok = D_clear; - ts_uart[uartx].p->over = 0; - ts_uart[uartx].p->max = len; - ts_uart[uartx].p->now = 1; - if(len <= D_send_buf_max) - { - //灏嗗弬鏁癰uf鎷疯礉鑷冲唴閮╞uf - for(ts_uart[uartx].p->num = 0;ts_uart[uartx].p->num < len;ts_uart[uartx].p->num ++) - { - ts_uart[uartx].p->buf[ts_uart[uartx].p->num] = ((U8*)buf)[ts_uart[uartx].p->num]; - } - ts_uart[uartx].p->p = ts_uart[uartx].p->buf; - } - else + //灏嗗弬鏁癰uf鎷疯礉鑷冲唴閮╞uf + for(ts_uart[uartx].p->num = 0;ts_uart[uartx].p->num < len;ts_uart[uartx].p->num ++) { - //涓嶄娇鐢ㄥ唴閮╞uf,濡傛灉鍐嶅彂閫佸畬姣曚箣鍓,鍙傛暟buf琚洖鏀,鍙戦佷細鍑洪敊 - ts_uart[uartx].p->p = (U8 *)buf; + ts_uart[uartx].p->buf[ts_uart[uartx].p->num] = ((U8*)buf)[ts_uart[uartx].p->num]; } - L0_uartN_set(uartx,ts_uart[uartx].p->p[0]); + ts_uart[uartx].p->p = ts_uart[uartx].p->buf; + } + else + { + //涓嶄娇鐢ㄥ唴閮╞uf,濡傛灉鍐嶅彂閫佸畬姣曚箣鍓,鍙傛暟buf琚洖鏀,鍙戦佷細鍑洪敊 + ts_uart[uartx].p->p = (U8 *)buf; } + L0_uartN_set(uartx,ts_uart[uartx].p->p[0]); } void L0_uartN_uc(U8 uartx,U8 ww) @@ -142,6 +139,7 @@ void L0_uartN_us(U8 uartx,vU16 ww) void L0_uartN_ul(U8 uartx,vU32 ww) { U_U32 uStemp; + L0_waitFree_uartN(uartx); uStemp.dWord = ww; ts_uart[uartx].p->buf3[0] = uStemp.BYTE4.byte0; ts_uart[uartx].p->buf3[1] = uStemp.BYTE4.byte1; @@ -152,6 +150,7 @@ void L0_uartN_ul(U8 uartx,vU32 ww) void L0_uartN_0d0a(U8 uartx) { + L0_waitFree_uartN(uartx); ts_uart[uartx].p->buf3[0] = 0x0d; ts_uart[uartx].p->buf3[1] = 0x0a; L0_uartN_sendArray(uartx,ts_uart[uartx].p->buf3,2); @@ -159,6 +158,7 @@ void L0_uartN_0d0a(U8 uartx) void L0_uartN_uchex(U8 uartx,U8 ww) { + L0_waitFree_uartN(uartx); ts_uart[uartx].p->buf3[0] = cguHex2Char[D_uc_high(ww)][1]; ts_uart[uartx].p->buf3[1] = cguHex2Char[D_uc_low (ww)][1]; L0_uartN_sendArray(uartx,ts_uart[uartx].p->buf3,2); @@ -167,6 +167,7 @@ void L0_uartN_uchex(U8 uartx,U8 ww) void L0_uartN_ushex(U8 uartx,vU16 ww) { U_F16 k; + L0_waitFree_uartN(uartx); k.us = ww; ts_uart[uartx].p->buf3[0] = cguHex2Char[D_uc_high(k.BYTE2.H)][1]; ts_uart[uartx].p->buf3[1] = cguHex2Char[D_uc_low (k.BYTE2.H)][1]; @@ -178,6 +179,7 @@ void L0_uartN_ushex(U8 uartx,vU16 ww) void L0_uartN_ulhex(U8 uartx,U32 ww) { U_U32 k; + L0_waitFree_uartN(uartx); k.dWord = ww; ts_uart[uartx].p->buf3[0] = cguHex2Char[D_uc_high(k.BYTE4.byte0)][1]; ts_uart[uartx].p->buf3[1] = cguHex2Char[D_uc_low (k.BYTE4.byte0)][1]; @@ -192,7 +194,7 @@ void L0_uartN_ulhex(U8 uartx,U32 ww) void L0_uartN_sendstr(U8 uartx,U8 *str) { - L0_uartN_sendArray(uartx,str,libc_strlen(str)); + L0_uartN_sendArray(uartx,str,Lc_strlen(str)); } void L0_uartN_uchexArray(U8 uartx,vU8 *buf,U16 n) diff --git a/source/msp/UARTN.h b/source/msp/uart_x.h similarity index 82% rename from source/msp/UARTN.h rename to source/msp/uart_x.h index ce65476..bb8abf2 100644 --- a/source/msp/UARTN.h +++ b/source/msp/uart_x.h @@ -52,30 +52,26 @@ msp/uartx.c 搴曞眰浠g爜 鍜宑pu鐩稿叧 缂撳瓨鍙戦佷篃鏀惧湪閲岄潰 #ifndef _uartN_H #define _uartN_H -#include "../clib/Clib.h" +#include "../clib/clib.h" #include "../tpc/tpc_x.h" +#include "../bsp/bsp_config.h" #define D_uartN_free() (0 == ts_uart_send_shop[uartx].max) #define D_uartN_busy() (0 != ts_uart_send_shop[uartx].max) +#define D_BRT_COUNT(t,clk,uartBRT) (U16)(65536- (clk / (4 * uartBRT * t))) -//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -////fixme:鍜宑pu鐨勭▼搴忓閲忔伅鎭浉鍏 -#define D_send_buf_max 16 /// 9600bps = 10000bps = 1000 Bps = 1Byte/ms - /// 19200bps = 20000bps = 2000Bps = 2Byte/ms = 1Byte/0.5ms - /// 128Bytes = 128*0.5ms = 64ms -#define D_send_buf2_max 8 //姝ゅ鏀瑰姩浼氬奖鍝峀0_uartN_ulhex鍑芥暟 typedef struct _ts_uart0_send_buf_ -{//8byte +{ vU8 num; //鎺ユ敹鍒扮殑鏁扮洰娉ㄦ剰鏁版嵁闀垮害鐨勮寖鍥 vU8 *p; vU16 now; /// 褰撳墠buf鎵鍦ㄧ殑浣嶇疆 0------(max-1) vU16 max; /// 褰撳墠buf鐨勬渶澶у,涔熷氨鏄渶瑕佸彂閫佺殑闀垮害 vU32 over; /// 缁撴潫绛夊緟鏍囧織锛宱ver绱姞鍒版煇涓兼椂锛岀粨鏉熺瓑寰 vU8 ok; /// 鍙戦佸畬鎴愭爣蹇 - vU8 buf[D_send_buf_max + 1]; + vU8 buf[D_UART_send_buf_max + 1]; /// U8 buf2[D_send_buf2_max]; - vU8 buf3[D_send_buf2_max]; + vU8 buf3[D_UART_send_buf2_max]; //// U8 buf4[D_send_buf_max]; /// U8 buf[D_send_buf_max + 1];//buffer 鐨勭涓浣嶆槸 闀垮害 }Ts_uart_send_buf; @@ -83,20 +79,15 @@ typedef struct _ts_uart0_send_buf_ typedef struct _TS_uart_reg { Ts_uart_send_buf idata *p; - //eUSCI_UART_Config *c; - //int sta; - //U8 heartbeat; TP_Handler_X *t; - void (*tp_handler)(TP_Handler_X *); //reentrant; + void (*tp_handler)(TP_Handler_X *); U8 *ack; //ack }TS_uart_reg; -//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -#define SERIAL_MAX_NUM 1 extern TS_uart_reg idata ts_uart[SERIAL_MAX_NUM]; extern void L0_uartN_init(U8 uartx); -extern void L0_uartN_set(U8 uartx,U8 x) reentrant; +extern void L0_uartN_set(U8 uartx,U8 x); extern U8 L0_uartN_get(U8 uartx); extern void L0_uartN_sendArray(U8 uartx,void *buf,U16 len); extern void L0_uartN_uc(U8 uartx,U8 ww); diff --git a/source/tpc/tpc_0d0a.c b/source/tpc/0d0a.c similarity index 98% rename from source/tpc/tpc_0d0a.c rename to source/tpc/0d0a.c index e713210..da7a66f 100644 --- a/source/tpc/tpc_0d0a.c +++ b/source/tpc/0d0a.c @@ -1,4 +1,4 @@ -#include "tpc_0d0a.h" +锘#include "0d0a.h" #include "../clib/clib.h" //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> diff --git a/source/tpc/tpc_0d0a.h b/source/tpc/0d0a.h similarity index 100% rename from source/tpc/tpc_0d0a.h rename to source/tpc/0d0a.h diff --git a/source/tpc/tpc_ccmodbus.c b/source/tpc/ccmodbus.c similarity index 99% rename from source/tpc/tpc_ccmodbus.c rename to source/tpc/ccmodbus.c index 1ef753f..b847efa 100644 --- a/source/tpc/tpc_ccmodbus.c +++ b/source/tpc/ccmodbus.c @@ -1,4 +1,4 @@ - +锘 /***************************************************************************** update by cc @201501101001 閽堝澶氫覆鍙 鍜 鍗曚竴涓插彛 鏈夊尯鍒 姣忎釜涓插彛鏄嫭绔嬬殑杩樻槸鍒嗗紑鐨勬湁璁茬┒ 绋嬪簭鏄鏉傜殑杩樻槸杞欢搴旂敤绠鍗曟槸 @@ -29,7 +29,7 @@ msp/uartx.c 搴曞眰浠g爜 鍜宑pu鐩稿叧 ----------------------------------------------------------------------------------------- ********************************************************************************/ -#include "tpc_ccmodbus.h" +#include "ccmodbus.h" #include "../clib/clib.h" #if 0 diff --git a/source/tpc/tpc_ccmodbus.h b/source/tpc/ccmodbus.h similarity index 100% rename from source/tpc/tpc_ccmodbus.h rename to source/tpc/ccmodbus.h diff --git a/source/tpc/tpc_debug.c b/source/tpc/debug.c similarity index 99% rename from source/tpc/tpc_debug.c rename to source/tpc/debug.c index 639cc5f..59a0e4a 100644 --- a/source/tpc/tpc_debug.c +++ b/source/tpc/debug.c @@ -1,4 +1,4 @@ - +锘 /***************************************************************************** update by cc @201501101001 閽堝澶氫覆鍙 鍜 鍗曚竴涓插彛 鏈夊尯鍒 姣忎釜涓插彛鏄嫭绔嬬殑杩樻槸鍒嗗紑鐨勬湁璁茬┒ 绋嬪簭鏄鏉傜殑杩樻槸杞欢搴旂敤绠鍗曟槸 @@ -29,7 +29,7 @@ msp/uartx.c 搴曞眰浠g爜 鍜宑pu鐩稿叧 ----------------------------------------------------------------------------------------- ********************************************************************************/ -#include "tpc_debug.h" +#include "debug.h" #include "../clib/clib.h" //NUM: 0 1 2 3 4 diff --git a/source/tpc/tpc_debug.h b/source/tpc/debug.h similarity index 100% rename from source/tpc/tpc_debug.h rename to source/tpc/debug.h diff --git a/source/tpc/modbus.c b/source/tpc/modbus.c new file mode 100644 index 0000000..f858244 --- /dev/null +++ b/source/tpc/modbus.c @@ -0,0 +1,62 @@ + +/***************************************************************************** +update by cc @201501101001 +閽堝澶氫覆鍙 鍜 鍗曚竴涓插彛 鏈夊尯鍒 姣忎釜涓插彛鏄嫭绔嬬殑杩樻槸鍒嗗紑鐨勬湁璁茬┒ 绋嬪簭鏄鏉傜殑杩樻槸杞欢搴旂敤绠鍗曟槸 +涓渶瑕佸钩琛$殑浜嬫儏.d + +uartcom/uartlib.c: +鍏敤鐨勫嚱鏁 鍜岀‖浠舵棤鍏 +鏀剧疆涓茶妯″紡(涓插彛绛夊叾浠栭氳鎬荤嚎绫荤殑杈撳嚭)杈撳嚭鐨勫嚱鏁, +涓浜涜鐩栨ā寮忚緭鍑虹殑(lcd绛夊浐灞忚緭鍑虹殑)鐨勪篃鍙娇鐢 + void Lc_print(void (*L0pf_send_uc)(char ww), char *dat,...) +----------------------------------------------------------------------------------------- +uartcom/uartcom0 + 鍜寀art鐩稿叧鐨勯氳鍗忚 com + n + 涓轰簡閫傚簲涓嶅悓鐨勯氳鍗忚闇瑕佷笉鍚岀殑uart鍙f潵瀵瑰簲 鍜屽簲鐢ㄧ浉鍏 + +typedef struct _ts_lcm_pro_; 搴旂敤鍗忚鍖呯殑瀹氫箟? LCM鐨勫崗璁------------ + L3_UARTcom0_exp_protocol 瑙f瀽搴旂敤鍗忚 +----------------------------------------------------------------------------------------- +uartcom/uprotocol: 涓昏鏄负 uartcom + n鏈嶅姟鐨 椹卞姩灞傚埌搴旂敤灞傜紦瀛樼殑杩囧害 +鍏敤鐨勪覆鍙i氳瀹氫箟 + struct _s_protocol_ 鐨勫叕鍏卞崗璁寘(鍏抽敭鐨勭粨鏋勪綋)鐨勫0鏄------struct _s_protocol_ + void L1_uart_2buf(struct _s_protocol_ *p)涓茶鏁版嵁淇濆瓨鍒扮紦鍐蹭腑 +-------------------------------------------------------------------------------------------- +msp/uartx.c 搴曞眰浠g爜 鍜宑pu鐩稿叧 + L0_UART0_Init + UART0_IRQHandler + L0_Usend_uc----------s_at0 +----------------------------------------------------------------------------------------- +********************************************************************************/ + +#include "modbus.h" +#include "../bsp/bsp_config.h" +#include "../ctask/tick.h" +#include "../clib/clib.h" + +//MODBUS鍗忚瑙f瀽鍑芥暟 +//瓒呭嚭D_tp_handle_x_len锛屼笉缁х画淇濆瓨鏁版嵁 +void L1_s2b_PH4(struct _tp_handler_x *p) +{ + //p->modbusstmp = D_sys_now; + if(p->head == 0) + { + p->head = 1; + p->max = D_TPC_HANDLER_X_LEN; + p->sp = p->buf; + p->num = 0; + p->sp[p->num++] = p->reg; + } + else + { + if(p->num < p->max) + { + p->sp[p->num++] = p->reg; + } + } +} + +/****************************************************************************** +** End Of File +******************************************************************************/ + diff --git a/source/tpc/tpc_modbus.h b/source/tpc/modbus.h similarity index 97% rename from source/tpc/tpc_modbus.h rename to source/tpc/modbus.h index 80e0890..491bf66 100644 --- a/source/tpc/tpc_modbus.h +++ b/source/tpc/modbus.h @@ -49,14 +49,14 @@ typedef struct ts_ph4_modbus { U8 slaver; //浠庢満鍦板潃 U8 oper; //鍔熻兘鐮 - U8 buf[D_tp_handle_x_len + 8]; + U8 buf[D_TPC_HANDLER_X_LEN + 8]; U8 crc[2]; }TS_PH4_modbus; typedef struct s_modbus_03_ack { U8 bytes; - U8 buf[D_tp_handle_x_len-1]; + U8 buf[D_TPC_HANDLER_X_LEN-1]; }Modbus03Ack; typedef struct s_modbus_06_ack diff --git a/source/tpc/tpc_x.h b/source/tpc/tpc_x.h index b54545d..8956284 100644 --- a/source/tpc/tpc_x.h +++ b/source/tpc/tpc_x.h @@ -1,13 +1,8 @@ -#ifndef TPC_X_H -#define TPC_X_H +#ifndef TPC_CONFIG_H +#define TPC_CONFIG_H #include "../bsp/bsp_config.h" -#if 0 -#include "tpc_debug.h" -#include "tpc_ccmodbus.h" -#include "tpc_modbus.h" -#include "tpc_0d0a.h" -#endif +#include "../clib/type.h" typedef struct _tp_handler_x {//8byte @@ -16,17 +11,14 @@ typedef struct _tp_handler_x vU8 cashe[2]; vU8 head_0; vU8 head_1; - vU8 num; //鎺ユ敹鍒扮殑鏁版嵁鐨勮鏁帮紝 闅忕潃鏁版嵁鎺ユ敹鑰屽彉鍖栨敞鎰忔暟鎹暱搴︾殑鑼冨洿 + vU8 num; //鎺ユ敹鍒扮殑鏁版嵁鐨勮鏁帮紝 闅忕潃鏁版嵁鎺ユ敹鑰屽彉鍖栨敞鎰忔暟鎹暱搴︾殑鑼冨洿 vU8 ok; //鎺ユ敹鍗忚ok鏍囧織 vU8 max; //鎺ユ敹鍒扮殑鏁扮洰鐨勬渶澶у - //vU8 __buf[D_tp_handle_x_len+1];//buffer - vU8 buf[D_tp_handle_x_len+16];//array鐨勭涓浣嶆槸 闀垮害 //鍗忚缂撳啿 + vU8 buf[D_TPC_HANDLER_X_LEN+16];////鍗忚缂撳啿 vU8 *sp; vU8 *sp2; //澶囦唤鍊硷紝濡傛灉鍗忚闇瑕佸浠斤紝鍗曠嫭鎻愪緵澶囦唤缂撳啿鍖 vU8 ocr; vU8 crc[2]; - vU32 modbusstmp; - U8 i; }TP_Handler_X; #endif