Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / src / telelco-v3.0 / ao_pins.h
index be253232ca26afa463982cdc582632e6944d4ab3..b1af364fca3b9ee219fc23110e38b9be007b7718 100644 (file)
@@ -95,7 +95,7 @@
 #define PACKET_HAS_SLAVE       0
 #define PACKET_HAS_MASTER      0
 
 #define PACKET_HAS_SLAVE       0
 #define PACKET_HAS_MASTER      0
 
-#define AO_FAST_TIMER          2
+#define AO_FAST_TIMER          4
 #define FAST_TIMER_FREQ                10000   /* .1ms for debouncing */
 
 /* LCD module */
 #define FAST_TIMER_FREQ                10000   /* .1ms for debouncing */
 
 /* LCD module */
 #define LED_11_PORT            (&stm_gpioa)
 #define LED_11_PIN             0
 
 #define LED_11_PORT            (&stm_gpioa)
 #define LED_11_PIN             0
 
-#define AO_LED_CONTINUITY_1    AO_LED_12       /* PA1 */
+#define AO_LED_CONTINUITY_1    AO_LED_12       /* PA6 */
 #define LED_12_PORT            (&stm_gpioa)
 #define LED_12_PORT            (&stm_gpioa)
-#define LED_12_PIN             1
+#define LED_12_PIN             6
 
 #define AO_LED_CONTINUITY_0    AO_LED_13       /* PB1 */
 #define LED_13_PORT            (&stm_gpiob)
 
 #define AO_LED_CONTINUITY_0    AO_LED_13       /* PB1 */
 #define LED_13_PORT            (&stm_gpiob)
 #define AO_BUTTON_0            1
 
 #define AO_BUTTON_DRAG_SELECT  1
 #define AO_BUTTON_0            1
 
 #define AO_BUTTON_DRAG_SELECT  1
-#define AO_BUTTON_1_PORT       &stm_gpioc
-#define AO_BUTTON_1            0
+#define AO_BUTTON_1_PORT       &stm_gpiod
+#define AO_BUTTON_1            2
 
 #define AO_BUTTON_SPARE1               2
 #define AO_BUTTON_2_PORT       &stm_gpiob
 
 #define AO_BUTTON_SPARE1               2
 #define AO_BUTTON_2_PORT       &stm_gpiob
 
 /* ADC */
 
 
 /* ADC */
 
-struct ao_adc {
-       int16_t         v_batt;
-};
-
-#define AO_ADC_DUMP(p) \
-       printf("batt: %5d\n", (p)->v_batt)
+#define AO_DATA_RING           8
 
 
-#define HAS_ADC_SINGLE         1
+#define HAS_ADC                        1
 #define HAS_ADC_TEMP           0
 #define HAS_BATTERY_REPORT     1
 
 #define HAS_ADC_TEMP           0
 #define HAS_BATTERY_REPORT     1
 
@@ -277,12 +272,33 @@ struct ao_adc {
 #define AO_ADC_V_BATT_PORT     (&stm_gpioa)
 #define AO_ADC_V_BATT_PIN      2
 
 #define AO_ADC_V_BATT_PORT     (&stm_gpioa)
 #define AO_ADC_V_BATT_PIN      2
 
+#define AO_ADC_V_ALS           10
+#define AO_ADC_V_ALS_PORT      (&stm_gpioc)
+#define AO_ADC_V_ALS_PIN       0
+
 #define AO_ADC_PIN0_PORT       AO_ADC_V_BATT_PORT
 #define AO_ADC_PIN0_PIN                AO_ADC_V_BATT_PIN
 
 #define AO_ADC_PIN0_PORT       AO_ADC_V_BATT_PORT
 #define AO_ADC_PIN0_PIN                AO_ADC_V_BATT_PIN
 
+#define AO_ADC_PIN1_PORT       AO_ADC_V_ALS_PORT
+#define AO_ADC_PIN1_PIN                AO_ADC_V_ALS_PIN
+
 #define AO_ADC_SQ1             AO_ADC_V_BATT
 #define AO_ADC_SQ1             AO_ADC_V_BATT
+#define AO_ADC_SQ2             AO_ADC_V_ALS
 
 
-#define AO_NUM_ADC             1
+#define AO_NUM_ADC             2
+
+struct ao_adc {
+       union {
+               struct {
+                       int16_t         v_batt;
+                       int16_t         v_als;
+               };
+               int16_t v_vals[AO_NUM_ADC];
+       };
+};
+
+#define AO_ADC_DUMP(p) \
+       printf("batt: %5d als %5d\n", (p)->adc.v_batt, (p)->adc.v_als)
 
 /*
  * Voltage divider on ADC battery sampler
 
 /*
  * Voltage divider on ADC battery sampler
@@ -296,9 +312,41 @@ struct ao_adc {
 #define AO_ADC_REFERENCE_DV    33
 
 #define AO_LCO_SEARCH_API
 #define AO_ADC_REFERENCE_DV    33
 
 #define AO_LCO_SEARCH_API
-#define AO_LCO_HAS_CONTRAST    1
-#define AO_LCO_MIN_CONTRAST    0
-#define AO_LCO_MAX_CONTRAST    63
-#define AO_LCO_CONTRAST_STEP   1
+
+//#define AO_LCO_HAS_CONTRAST  1
+//#define AO_LCO_MIN_CONTRAST  0
+//#define AO_LCO_MAX_CONTRAST  63
+//#define AO_LCO_CONTRAST_STEP 1
+
+#define AO_LCO_HAS_BACKLIGHT   1
+#define AO_LCO_MIN_BACKLIGHT   0
+#define AO_LCO_MAX_BACKLIGHT   65535
+#define AO_LCO_BACKLIGHT_STEP  771
+
+#define AO_LCO_HAS_LCO_INFO    1
+#define AO_LCO_MIN_INFO_PAGE   0
+#define AO_LCO_MAX_INFO_PAGE   0
+
+#define AO_LCO_HAS_PAD_INFO    1
+
+/*
+ * LCD Backlight via PWM.
+ *
+ * Pin PA1, TIM2_CH2
+ */
+
+#define NUM_PWM                        1
+#define PWM_MAX                        65535
+#define AO_PWM_TIMER           stm_tim2
+#define AO_LCD_BL_PWM_CHAN     1
+#define AO_PWM_0_GPIO          (&stm_gpioa)
+#define AO_PWM_0_PIN           1
+#define AO_PWM_TIMER_ENABLE    STM_RCC_APB1ENR_TIM2EN
+#define AO_PWM_TIMER_SCALE     1
+
+#define AO_AFIO_PWM_REMAP      STM_AFIO_MAPR_TIM2_REMAP
+#define AO_AFIO_PWM_REMAP_VAL  STM_AFIO_MAPR_TIM2_REMAP_PA0_PA1_PA2_PA3
+#define AO_AFIO_PWM_REMAP_MASK STM_AFIO_MAPR_TIM2_REMAP_MASK
+
 
 #endif /* _AO_PINS_H_ */
 
 #endif /* _AO_PINS_H_ */