aboutsummaryrefslogtreecommitdiff
path: root/laser-tag software
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amatus.name>2015-10-14 19:05:11 -0500
committerDavid Barksdale <amatus@amatus.name>2015-10-14 19:05:11 -0500
commita0704ec4fc8a7c5c2b08ab05929b6bab7ef16495 (patch)
tree3380117266ea49a414b265a9e90f06e7d3d1341c /laser-tag software
parentd15bbe64d55cc05781e1b6bb1b5573f3fc673d45 (diff)
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.
Diffstat (limited to 'laser-tag software')
-rwxr-xr-xlaser-tag software/main.c14
1 files changed, 14 insertions, 0 deletions
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);
+ }
+ }
}
/*!