From a0704ec4fc8a7c5c2b08ab05929b6bab7ef16495 Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Wed, 14 Oct 2015 19:05:11 -0500 Subject: Crappy automatic gain control for the CMP The theory seem to be sound, it just needs tuning and probably filtering. Then we have to figure out how to recover actual data. --- laser-tag software/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'laser-tag software') diff --git a/laser-tag software/main.c b/laser-tag software/main.c index 9f6b52c..da99cbd 100755 --- a/laser-tag software/main.c +++ b/laser-tag software/main.c @@ -169,6 +169,12 @@ void lptmr_call_back(void) PIT_DRV_StopTimer(0, 0); DAC_DRV_Output(0, 0); } + + // AGC decay + if (g_cmpDacConf.dacValue > 0) { + g_cmpDacConf.dacValue--; + CMP_DRV_ConfigDacChn(0, &g_cmpDacConf); + } } @@ -181,6 +187,14 @@ void CMP0_IRQHandler(void) if (CMP_DRV_GetFlag(0, kCmpFlagOfCoutFalling)) { CMP_DRV_ClearFlag(0, kCmpFlagOfCoutFalling); } + + // AGC rise + if (CMP_DRV_GetOutputLogic(0)) { + if (g_cmpDacConf.dacValue < 63) { + g_cmpDacConf.dacValue++; + CMP_DRV_ConfigDacChn(0, &g_cmpDacConf); + } + } } /*! -- cgit v1.2.3-18-g5258