diff options
author | David Barksdale <amatus@amatus.name> | 2015-10-19 22:57:44 -0500 |
---|---|---|
committer | David Barksdale <amatus@amatus.name> | 2015-10-19 22:57:44 -0500 |
commit | 8ae1b98d5ae5599eb033f6d51f16c2b281268b71 (patch) | |
tree | fe303b5bf9c8e7dcbacfeba4dad65b2730a987ab | |
parent | a3a58a3d8afe1d38ab0c0d0da7ec87989c3bd8e3 (diff) |
Tweak AGC, wire laser to switch1
-rw-r--r-- | laser-tag badge/laser-tag.brd | 32 | ||||
-rw-r--r-- | laser-tag badge/laser-tag.sch | 65 | ||||
-rwxr-xr-x | laser-tag software/main.c | 67 |
3 files changed, 88 insertions, 76 deletions
diff --git a/laser-tag badge/laser-tag.brd b/laser-tag badge/laser-tag.brd index ed0141a..1e90d19 100644 --- a/laser-tag badge/laser-tag.brd +++ b/laser-tag badge/laser-tag.brd @@ -3200,16 +3200,14 @@ design rules under a new name.</description> <wire x1="27.94" y1="33.02" x2="26.67" y2="34.29" width="0.254" layer="16"/> </signal> <signal name="PTB3"> -<contactref element="U1" pad="38"/> <contactref element="BREAKOUT2" pad="6"/> -<wire x1="37.5464125" y1="40.858628125" x2="31.115" y2="34.42721875" width="0.254" layer="16"/> <wire x1="31.115" y1="34.42721875" x2="31.115" y2="33.02" width="0.254" layer="16"/> <wire x1="31.115" y1="33.02" x2="29.845" y2="31.75" width="0.254" layer="16"/> <wire x1="29.845" y1="31.75" x2="29.21" y2="31.75" width="0.254" layer="16"/> <contactref element="S4" pad="2"/> <contactref element="S4" pad="1"/> <wire x1="63.11" y1="50.51" x2="71.51" y2="50.51" width="0" layer="19" extent="1-1"/> -<wire x1="37.5464125" y1="40.858628125" x2="63.11" y2="50.51" width="0" layer="19" extent="1-16"/> +<wire x1="31.115" y1="34.42721875" x2="63.11" y2="50.51" width="0" layer="19" extent="1-16"/> </signal> <signal name="PTB2"> <contactref element="U1" pad="37"/> @@ -3221,10 +3219,6 @@ design rules under a new name.</description> <wire x1="30.48" y1="31.115" x2="29.845" y2="30.48" width="0.254" layer="16"/> <wire x1="29.845" y1="30.48" x2="27.94" y2="30.48" width="0.254" layer="16"/> <wire x1="27.94" y1="30.48" x2="26.67" y2="31.75" width="0.254" layer="16"/> -<contactref element="S3" pad="2"/> -<contactref element="S3" pad="1"/> -<wire x1="63.11" y1="61.94" x2="71.51" y2="61.94" width="0" layer="19" extent="1-1"/> -<wire x1="37.899965625" y1="40.505075" x2="63.11" y2="61.94" width="0" layer="19" extent="1-16"/> </signal> <signal name="PTB1"> <contactref element="U1" pad="36"/> @@ -3235,10 +3229,6 @@ design rules under a new name.</description> <wire x1="31.115" y1="31.75" x2="31.115" y2="30.48" width="0.254" layer="16"/> <wire x1="31.115" y1="30.48" x2="29.845" y2="29.21" width="0.254" layer="16"/> <wire x1="29.845" y1="29.21" x2="29.21" y2="29.21" width="0.254" layer="16"/> -<contactref element="S2" pad="2"/> -<contactref element="S2" pad="1"/> -<wire x1="9.77" y1="50.51" x2="18.17" y2="50.51" width="0" layer="19" extent="1-1"/> -<wire x1="32.385" y1="34.28300625" x2="18.17" y2="50.51" width="0" layer="19" extent="1-16"/> </signal> <signal name="PTB0"> <contactref element="U1" pad="35"/> @@ -3253,10 +3243,6 @@ design rules under a new name.</description> <wire x1="29.845" y1="27.94" x2="28.575" y2="27.94" width="0.254" layer="16"/> <wire x1="28.575" y1="27.94" x2="27.305" y2="29.21" width="0.254" layer="16"/> <wire x1="27.305" y1="29.21" x2="26.67" y2="29.21" width="0.254" layer="16"/> -<contactref element="S1" pad="2"/> -<contactref element="S1" pad="1"/> -<wire x1="9.77" y1="61.94" x2="18.17" y2="61.94" width="0" layer="19" extent="1-1"/> -<wire x1="38.60706875" y1="39.79796875" x2="18.17" y2="61.94" width="0" layer="19" extent="1-16"/> </signal> <signal name="PTA19"> <contactref element="U1" pad="33"/> @@ -3406,6 +3392,22 @@ design rules under a new name.</description> <contactref element="J10" pad="2"/> <wire x1="46.355" y1="67.5894" x2="46.64" y2="69.73" width="0" layer="19" extent="1-1"/> </signal> +<signal name="N$2"> +<contactref element="U1" pad="38"/> +</signal> +<signal name="N$4"> +<contactref element="S3" pad="2"/> +<contactref element="S3" pad="1"/> +<wire x1="63.11" y1="61.94" x2="71.51" y2="61.94" width="0" layer="19" extent="1-1"/> +</signal> +<signal name="N$12"> +<contactref element="S2" pad="2"/> +<contactref element="S2" pad="1"/> +<wire x1="9.77" y1="50.51" x2="18.17" y2="50.51" width="0" layer="19" extent="1-1"/> +</signal> +<signal name="N$20"> +<contactref element="S1" pad="1"/> +</signal> </signals> </board> </drawing> diff --git a/laser-tag badge/laser-tag.sch b/laser-tag badge/laser-tag.sch index 7189384..54b6652 100644 --- a/laser-tag badge/laser-tag.sch +++ b/laser-tag badge/laser-tag.sch @@ -10695,12 +10695,9 @@ support interrupts</text> </net> <net name="PTB3" class="0"> <segment> -<pinref part="U1" gate="A" pin="PTB3"/> <pinref part="S4" gate="G$1" pin="1.2"/> <wire x1="142.24" y1="71.12" x2="139.7" y2="71.12" width="0.1524" layer="91"/> <wire x1="139.7" y1="71.12" x2="132.08" y2="71.12" width="0.1524" layer="91"/> -<wire x1="132.08" y1="71.12" x2="132.08" y2="33.02" width="0.1524" layer="91"/> -<wire x1="132.08" y1="33.02" x2="116.84" y2="33.02" width="0.1524" layer="91"/> <pinref part="S4" gate="G$1" pin="1.1"/> <wire x1="142.24" y1="73.66" x2="139.7" y2="73.66" width="0.1524" layer="91"/> <wire x1="139.7" y1="73.66" x2="139.7" y2="71.12" width="0.1524" layer="91"/> @@ -10715,15 +10712,7 @@ support interrupts</text> <net name="PTB2" class="0"> <segment> <pinref part="U1" gate="A" pin="PTB2"/> -<pinref part="S3" gate="G$1" pin="1.2"/> -<wire x1="142.24" y1="55.88" x2="139.7" y2="55.88" width="0.1524" layer="91"/> -<wire x1="139.7" y1="55.88" x2="134.62" y2="55.88" width="0.1524" layer="91"/> -<wire x1="134.62" y1="55.88" x2="134.62" y2="30.48" width="0.1524" layer="91"/> -<wire x1="134.62" y1="30.48" x2="116.84" y2="30.48" width="0.1524" layer="91"/> -<pinref part="S3" gate="G$1" pin="1.1"/> -<wire x1="142.24" y1="58.42" x2="139.7" y2="58.42" width="0.1524" layer="91"/> -<wire x1="139.7" y1="58.42" x2="139.7" y2="55.88" width="0.1524" layer="91"/> -<junction x="139.7" y="55.88"/> +<wire x1="119.38" y1="30.48" x2="116.84" y2="30.48" width="0.1524" layer="91"/> </segment> <segment> <pinref part="BREAKOUT2" gate="A" pin="5"/> @@ -10734,15 +10723,7 @@ support interrupts</text> <net name="PTB1" class="0"> <segment> <pinref part="U1" gate="A" pin="PTB1"/> -<pinref part="S2" gate="G$1" pin="1.2"/> -<wire x1="142.24" y1="40.64" x2="139.7" y2="40.64" width="0.1524" layer="91"/> -<wire x1="139.7" y1="40.64" x2="137.16" y2="40.64" width="0.1524" layer="91"/> -<wire x1="137.16" y1="40.64" x2="137.16" y2="27.94" width="0.1524" layer="91"/> -<wire x1="137.16" y1="27.94" x2="116.84" y2="27.94" width="0.1524" layer="91"/> -<pinref part="S2" gate="G$1" pin="1.1"/> -<wire x1="142.24" y1="43.18" x2="139.7" y2="43.18" width="0.1524" layer="91"/> -<wire x1="139.7" y1="43.18" x2="139.7" y2="40.64" width="0.1524" layer="91"/> -<junction x="139.7" y="40.64"/> +<wire x1="119.38" y1="27.94" x2="116.84" y2="27.94" width="0.1524" layer="91"/> </segment> <segment> <pinref part="BREAKOUT2" gate="A" pin="4"/> @@ -10753,13 +10734,7 @@ support interrupts</text> <net name="PTB0" class="0"> <segment> <pinref part="U1" gate="A" pin="PTB0/LLWU_P5"/> -<pinref part="S1" gate="G$1" pin="1.2"/> -<wire x1="142.24" y1="25.4" x2="139.7" y2="25.4" width="0.1524" layer="91"/> -<pinref part="S1" gate="G$1" pin="1.1"/> -<wire x1="139.7" y1="25.4" x2="116.84" y2="25.4" width="0.1524" layer="91"/> -<wire x1="142.24" y1="27.94" x2="139.7" y2="27.94" width="0.1524" layer="91"/> -<wire x1="139.7" y1="27.94" x2="139.7" y2="25.4" width="0.1524" layer="91"/> -<junction x="139.7" y="25.4"/> +<wire x1="119.38" y1="25.4" x2="116.84" y2="25.4" width="0.1524" layer="91"/> </segment> <segment> <pinref part="BREAKOUT2" gate="A" pin="3"/> @@ -10948,6 +10923,40 @@ support interrupts</text> <pinref part="J10" gate="J" pin="2"/> </segment> </net> +<net name="N$2" class="0"> +<segment> +<pinref part="U1" gate="A" pin="PTB3"/> +<wire x1="119.38" y1="33.02" x2="116.84" y2="33.02" width="0.1524" layer="91"/> +</segment> +</net> +<net name="N$4" class="0"> +<segment> +<pinref part="S3" gate="G$1" pin="1.2"/> +<wire x1="142.24" y1="55.88" x2="139.7" y2="55.88" width="0.1524" layer="91"/> +<pinref part="S3" gate="G$1" pin="1.1"/> +<wire x1="142.24" y1="58.42" x2="139.7" y2="58.42" width="0.1524" layer="91"/> +<wire x1="139.7" y1="58.42" x2="139.7" y2="55.88" width="0.1524" layer="91"/> +<junction x="139.7" y="55.88"/> +<wire x1="139.7" y1="55.88" x2="134.62" y2="55.88" width="0.1524" layer="91"/> +</segment> +</net> +<net name="N$12" class="0"> +<segment> +<pinref part="S2" gate="G$1" pin="1.2"/> +<wire x1="142.24" y1="40.64" x2="139.7" y2="40.64" width="0.1524" layer="91"/> +<pinref part="S2" gate="G$1" pin="1.1"/> +<wire x1="142.24" y1="43.18" x2="139.7" y2="43.18" width="0.1524" layer="91"/> +<wire x1="139.7" y1="43.18" x2="139.7" y2="40.64" width="0.1524" layer="91"/> +<junction x="139.7" y="40.64"/> +<wire x1="139.7" y1="40.64" x2="137.16" y2="40.64" width="0.1524" layer="91"/> +</segment> +</net> +<net name="N$20" class="0"> +<segment> +<pinref part="S1" gate="G$1" pin="1.1"/> +<wire x1="142.24" y1="27.94" x2="139.7" y2="27.94" width="0.1524" layer="91"/> +</segment> +</net> </nets> </sheet> </sheets> diff --git a/laser-tag software/main.c b/laser-tag software/main.c index da99cbd..0eb69b1 100755 --- a/laser-tag software/main.c +++ b/laser-tag software/main.c @@ -107,6 +107,14 @@ static const gpio_output_pin_user_config_t g_lcdBacklight = { .config.driveStrength = kPortLowDriveStrength, }; +// Switch1 GPIO pin +static const gpio_input_pin_user_config_t g_switch1 = { + .pinName = GPIO_MAKE_PIN(GPIOA_IDX, 1U), + .config.isPullEnable = true, + .config.pullSelect = kPortPullUp, + .config.interrupt = kPortIntEitherEdge, +}; + // LPTMR configurations static const lptmr_user_config_t g_lptmrConfig = { .timerMode = kLptmrTimerModeTimeCounter, @@ -130,8 +138,8 @@ static const cmp_comparator_config_t g_cmpConf = { .invertEnable = false, .highSpeedEnable = false, .dmaEnable = false, - .risingIntEnable = true, - .fallingIntEnable = true, + .risingIntEnable = false, + .fallingIntEnable = false, .plusChnMux = kCmpInputChn5, .minusChnMux = kCmpInputChnDac, .triggerEnable = false, @@ -139,7 +147,7 @@ static const cmp_comparator_config_t g_cmpConf = { static cmp_dac_config_t g_cmpDacConf = { .dacEnable = true, - .refVoltSrcMode = kCmpDacRefVoltSrcOf1, + .refVoltSrcMode = kCmpDacRefVoltSrcOf2, .dacValue = 32, }; @@ -159,41 +167,31 @@ void lptmr_call_back(void) // Toggle LED1 GPIO_DRV_TogglePinOutput(g_lcdBacklight.pinName); - // Toggle PIT timer - static bool enable; - enable = !enable; - if (enable) { - DMA_HAL_SetTransferCount(g_dmaBase[0], g_chan.channel, 0xffff0); - PIT_DRV_StartTimer(0, 0); + // AGC adjust + if (CMP_DRV_GetOutputLogic(0)) { + if (g_cmpDacConf.dacValue < 63) { + g_cmpDacConf.dacValue++; + CMP_DRV_ConfigDacChn(0, &g_cmpDacConf); + } } else { - 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); + if (g_cmpDacConf.dacValue > 0) { + g_cmpDacConf.dacValue--; + CMP_DRV_ConfigDacChn(0, &g_cmpDacConf); + } } } - -void CMP0_IRQHandler(void) +void PORTA_IRQHandler(void) { - /* Clear flags. */ - if (CMP_DRV_GetFlag(0, kCmpFlagOfCoutRising)) { - CMP_DRV_ClearFlag(0, kCmpFlagOfCoutRising); - } - if (CMP_DRV_GetFlag(0, kCmpFlagOfCoutFalling)) { - CMP_DRV_ClearFlag(0, kCmpFlagOfCoutFalling); - } + /* Clear interrupt flag.*/ + PORT_HAL_ClearPortIntFlag(PORTA_BASE_PTR); - // AGC rise - if (CMP_DRV_GetOutputLogic(0)) { - if (g_cmpDacConf.dacValue < 63) { - g_cmpDacConf.dacValue++; - CMP_DRV_ConfigDacChn(0, &g_cmpDacConf); - } + if (GPIO_DRV_ReadPinInput(g_switch1.pinName)) { + PIT_DRV_StopTimer(0, 0); + DAC_DRV_Output(0, 0); + } else { + DMA_HAL_SetTransferCount(g_dmaBase[0], g_chan.channel, 0xffff0); + PIT_DRV_StartTimer(0, 0); } } @@ -215,7 +213,7 @@ int main (void) /* Initialize LPTMR */ lptmr_state_t lptmrState; LPTMR_DRV_Init(LPTMR0_IDX, &lptmrState, &g_lptmrConfig); - LPTMR_DRV_SetTimerPeriodUs(LPTMR0_IDX, 500000); + LPTMR_DRV_SetTimerPeriodUs(LPTMR0_IDX, 100000); LPTMR_DRV_InstallCallback(LPTMR0_IDX, lptmr_call_back); /* Initialize LCD backlight LED GPIO */ @@ -258,6 +256,9 @@ int main (void) PORT_HAL_SetMuxMode(g_portBase[GPIOE_IDX], 0, kPortMuxAlt5); CMP_DRV_Start(0); + /* Buttons */ + GPIO_DRV_InputPinInit(&g_switch1); + /* Start LPTMR */ LPTMR_DRV_Start(LPTMR0_IDX); |