lpc: More config beeper changes
authorKeith Packard <keithp@keithp.com>
Fri, 20 May 2022 23:41:04 +0000 (16:41 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 20 May 2022 23:41:04 +0000 (16:41 -0700)
Signed-off-by: Keith Packard <keithp@keithp.com>
src/easymini-v3.0/ao_pins.h
src/lpc/ao_beep_lpc.c

index 3ae384f75e4d7d2dc7725f2cd96b75755042dc78..c1a61611d4a5155075a2e930b80df61cc7999640 100644 (file)
 #define AO_LOG_FORMAT          AO_LOG_FORMAT_EASYMINI1
 
 /* Beeper */
-#define AO_LPC_CT_BEEP         lpc_ct32b0
-#define AO_LPC_CT_BEEP_CLKCTRL LPC_SCB_SYSAHBCLKCTRL_CT32B0
-#define AO_LPC_CT_BEEP_EMR     LPC_CT32B_EMR_EMC3
-#define AO_LPC_CT_BEEP_EM      3
-#define AO_LPC_CT_BEEP_PWMC    LPC_CT32B_PWMC_PWMEN3
+#define AO_LPC_BEEP_TIMER      0
+#define AO_LPC_BEEP_CHANNEL    3
 
 /* USART */
 
index 9186dc440678863acda723de2102cf490a11c5ca..af6281a5a8bfdcf3e94b66976b2ffecca8036377 100644 (file)
 
 #include "ao.h"
 
+#define _cat(a,b) a##b
+#define cat(a,b) _cat(a,b)
+
+#ifdef AO_LPC_BEEP_TIMER
+#define AO_LPC_BEEP_TIMER 1
+#define AO_LPC_BEEP_CHANNEL 1
+#endif
+
 #ifndef AO_LPC_CT_BEEP
-/* XXX need to adjust this for configurable beeper */
-#define AO_LPC_CT_BEEP                 lpc_ct32b1
-#define AO_LPC_CT_BEEP_CLKCTRL LPC_SCB_SYSAHBCLKCTRL_CT32B1
-#define AO_LPC_CT_BEEP_EMR     LPC_CT32B_EMR_EMC1
-#define AO_LPC_CT_BEEP_EM      1
-#define AO_LPC_CT_BEEP_PWMC    LPC_CT32B_PWMC_PWMEN1
+#define AO_LPC_CT_BEEP                 cat(lpc_ct32b, AO_LPC_BEEP_TIMER)
+#define AO_LPC_CT_BEEP_CLKCTRL cat(LPC_SCB_SYSAHBCLKCTRL_CT32B, AO_LPC_BEEP_TIMER)
+#define AO_LPC_CT_BEEP_EMR     cat(LPC_CT32B_EMR_EMC, AO_LPC_BEEP_CHANNEL)
+#define AO_LPC_CT_BEEP_MR      AO_LPC_BEEP_CHANNEL
+#define AO_LPC_CT_BEEP_PWMC    cat(LPC_CT32B_PWMC_PWMEN, AO_LPC_BEEP_CHANNEL)
 #endif
 
 void
@@ -47,7 +54,7 @@ ao_beep(uint8_t beep)
                AO_LPC_CT_BEEP.mr[0] = beep << 1;
 
                /* PWM width is half of that */
-               AO_LPC_CT_BEEP.mr[AO_LPC_CT_BEEP_EM] = beep;
+               AO_LPC_CT_BEEP.mr[AO_LPC_CT_BEEP_MR] = beep;
 
                /* Flip output on PWM match */
                AO_LPC_CT_BEEP.emr = (LPC_CT32B_EMR_EMC_TOGGLE << AO_LPC_CT_BEEP_EMR);
@@ -55,7 +62,7 @@ ao_beep(uint8_t beep)
                /* Reset on match 0 */
                AO_LPC_CT_BEEP.mcr = (1 << LPC_CT32B_MCR_MR0R);
 
-               /* PWM on match */
+               /* PWM on match */
                AO_LPC_CT_BEEP.pwmc = (1 << AO_LPC_CT_BEEP_PWMC);
 
                /* timer mode */