summaryrefslogtreecommitdiff
path: root/src/stm
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-08-20 11:40:17 -0700
committerKeith Packard <keithp@keithp.com>2013-08-27 21:56:42 -0600
commit7b0f9b25a56fa8b4aa1c2e9d79c43e6a97cab0c0 (patch)
treed6b0c692976bf8086c5fce18193a4624623d0835 /src/stm
parent3ded57394f6dfd7beb9526c031a5c6c6c9926917 (diff)
altos: Initial TeleMetrum v2.0 bits
Adds new telemetry and logging formats along with code for TeleMetrum v2.0 design. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/stm')
-rw-r--r--src/stm/ao_arch.h2
-rw-r--r--src/stm/ao_beep_stm.c48
-rw-r--r--src/stm/stm32l.h2
3 files changed, 47 insertions, 5 deletions
diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h
index adc288c3..42fe727a 100644
--- a/src/stm/ao_arch.h
+++ b/src/stm/ao_arch.h
@@ -34,6 +34,8 @@
#define AO_TICK_SIGNED int16_t
#endif
+#define AO_PORT_TYPE uint16_t
+
/* Various definitions to make GCC look more like SDCC */
#define ao_arch_naked_declare __attribute__((naked))
diff --git a/src/stm/ao_beep_stm.c b/src/stm/ao_beep_stm.c
index 4761fbfc..a95d869b 100644
--- a/src/stm/ao_beep_stm.c
+++ b/src/stm/ao_beep_stm.c
@@ -17,6 +17,10 @@
#include "ao.h"
+#ifndef BEEPER_CHANNEL
+#define BEEPER_CHANNEL 1
+#endif
+
void
ao_beep(uint8_t beep)
{
@@ -56,6 +60,7 @@ ao_beep(uint8_t beep)
* is enabled and active high.
*/
+#if BEEPER_CHANNEL == 1
stm_tim3.ccmr1 = ((0 << STM_TIM234_CCMR1_OC2CE) |
(STM_TIM234_CCMR1_OC2M_FROZEN << STM_TIM234_CCMR1_OC2M) |
(0 << STM_TIM234_CCMR1_OC2PE) |
@@ -68,7 +73,6 @@ ao_beep(uint8_t beep)
(0 << STM_TIM234_CCMR1_OC1FE) |
(STM_TIM234_CCMR1_CC1S_OUTPUT << STM_TIM234_CCMR1_CC1S));
-
stm_tim3.ccer = ((0 << STM_TIM234_CCER_CC4NP) |
(0 << STM_TIM234_CCER_CC4P) |
(0 << STM_TIM234_CCER_CC4E) |
@@ -81,6 +85,33 @@ ao_beep(uint8_t beep)
(0 << STM_TIM234_CCER_CC1NP) |
(0 << STM_TIM234_CCER_CC1P) |
(1 << STM_TIM234_CCER_CC1E));
+#endif
+#if BEEPER_CHANNEL == 4
+ stm_tim3.ccmr2 = ((0 << STM_TIM234_CCMR2_OC4CE) |
+ (STM_TIM234_CCMR2_OC4M_TOGGLE << STM_TIM234_CCMR2_OC4M) |
+ (0 << STM_TIM234_CCMR2_OC4PE) |
+ (0 << STM_TIM234_CCMR2_OC4FE) |
+ (STM_TIM234_CCMR2_CC4S_OUTPUT << STM_TIM234_CCMR2_CC4S) |
+
+ (0 << STM_TIM234_CCMR2_OC3CE) |
+ (STM_TIM234_CCMR2_OC3M_FROZEN << STM_TIM234_CCMR2_OC3M) |
+ (0 << STM_TIM234_CCMR2_OC3PE) |
+ (0 << STM_TIM234_CCMR2_OC3FE) |
+ (STM_TIM234_CCMR2_CC3S_OUTPUT << STM_TIM234_CCMR2_CC3S));
+
+ stm_tim3.ccer = ((0 << STM_TIM234_CCER_CC4NP) |
+ (0 << STM_TIM234_CCER_CC4P) |
+ (1 << STM_TIM234_CCER_CC4E) |
+ (0 << STM_TIM234_CCER_CC3NP) |
+ (0 << STM_TIM234_CCER_CC3P) |
+ (0 << STM_TIM234_CCER_CC3E) |
+ (0 << STM_TIM234_CCER_CC2NP) |
+ (0 << STM_TIM234_CCER_CC2P) |
+ (0 << STM_TIM234_CCER_CC2E) |
+ (0 << STM_TIM234_CCER_CC1NP) |
+ (0 << STM_TIM234_CCER_CC1P) |
+ (0 << STM_TIM234_CCER_CC1E));
+#endif
/* 5. Enable the counter by setting the CEN bit in the TIMx_CR1 register. */
@@ -110,13 +141,22 @@ ao_beep_for(uint8_t beep, uint16_t ticks) __reentrant
void
ao_beep_init(void)
{
- /* Our beeper is on PC6, which is hooked to TIM3_CH1,
- * which is on PC6
- */
+#if BEEPER_CHANNEL == 1
+ /* Our beeper is on PC6, which is hooked to TIM3_CH1.
+ */
stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOCEN);
stm_afr_set(&stm_gpioc, 6, STM_AFR_AF2);
+#endif
+#if BEEPER_CHANNEL == 4
+
+ /* Our beeper is on PB1, which is hooked to TIM3_CH4.
+ */
+ stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOBEN);
+
+ stm_afr_set(&stm_gpiob, 1, STM_AFR_AF2);
+#endif
/* Leave the timer off until requested */
diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h
index 1868468f..ff3f5336 100644
--- a/src/stm/stm32l.h
+++ b/src/stm/stm32l.h
@@ -1739,7 +1739,7 @@ extern struct stm_tim234 stm_tim2, stm_tim3, stm_tim4;
#define STM_TIM234_CCMR1_CC1S_INPUT_TRC 3
#define STM_TIM234_CCMR1_CC1S_MASK 3
-#define STM_TIM234_CCMR2_OC2CE 15
+#define STM_TIM234_CCMR2_OC4CE 15
#define STM_TIM234_CCMR2_OC4M 12
#define STM_TIM234_CCMR2_OC4M_FROZEN 0
#define STM_TIM234_CCMR2_OC4M_SET_HIGH_ON_MATCH 1