Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / src / telelco-v3.0 / ao_pins.h
index 312e8d0343b6a398eea8a0025180152c56f43ae7..b1af364fca3b9ee219fc23110e38b9be007b7718 100644 (file)
 #define BEEPER_CHANNEL         1
 #define BEEPER_PORT            (&stm_gpioc)
 #define BEEPER_PIN             6
 #define BEEPER_CHANNEL         1
 #define BEEPER_PORT            (&stm_gpioc)
 #define BEEPER_PIN             6
+#define AO_BEEP_MID_DEFAULT    179     /* 2100 Hz */
 #define HAS_RADIO              1
 #define HAS_RADIO_RATE         1
 #define HAS_TELEMETRY          0
 #define HAS_AES                        1
 #define HAS_STATIC_TEST                0
 
 #define HAS_RADIO              1
 #define HAS_RADIO_RATE         1
 #define HAS_TELEMETRY          0
 #define HAS_AES                        1
 #define HAS_STATIC_TEST                0
 
+#define HAS_USB_PULLUP         1
+#define AO_USB_PULLUP_PORT     (&stm_gpioa)
+#define AO_USB_PULLUP_PIN      10
+
 #define HAS_SPI_1              1       /* NHD-C12864LZ LCD Module */
 #define SPI_1_PA5_PA6_PA7      1
 #define HAS_SPI_1              1       /* NHD-C12864LZ LCD Module */
 #define SPI_1_PA5_PA6_PA7      1
-#define SPI_1_MODE_OUTPUT      STM_GPIO_CR_MODE_OUTPUT_10MHZ
+#define SPI_1_PA6_DISABLE      1
+#define SPI_1_MODE_OUTPUT      STM_GPIO_CR_MODE_OUTPUT_50MHZ
 #define SPI_1_PB3_PB4_PB5      0
 #define SPI_1_PE13_PE14_PE15   0
 
 #define SPI_1_PB3_PB4_PB5      0
 #define SPI_1_PE13_PE14_PE15   0
 
@@ -89,6 +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          4
 #define FAST_TIMER_FREQ                10000   /* .1ms for debouncing */
 
 /* LCD module */
 #define FAST_TIMER_FREQ                10000   /* .1ms for debouncing */
 
 /* LCD module */
 #define AO_ST7565_RESET_PIN    5
 #define AO_ST7565_A0_PORT      (&stm_gpioa)    /* pin 3 */
 #define AO_ST7565_A0_PIN       3
 #define AO_ST7565_RESET_PIN    5
 #define AO_ST7565_A0_PORT      (&stm_gpioa)    /* pin 3 */
 #define AO_ST7565_A0_PIN       3
-#define AO_ST7565_SPI_BUS      AO_SPI_1_PA5_PA6_PA7
+#define AO_ST7565_SPI_BUS      (AO_SPI_1_PA5_PA6_PA7 | AO_SPI_MODE_3)
 #define AO_ST7565_WIDTH                128
 #define AO_ST7565_HEIGHT       64
 #define AO_ST7565_BIAS         ST7565_LCD_BIAS_1_9
 #define AO_ST7565_WIDTH                128
 #define AO_ST7565_HEIGHT       64
 #define AO_ST7565_BIAS         ST7565_LCD_BIAS_1_9
 #define LED_2_PORT             (&stm_gpioc)
 #define LED_2_PIN              9
 
 #define LED_2_PORT             (&stm_gpioc)
 #define LED_2_PIN              9
 
-#define AO_LED_BOX             AO_LED_3        /* PA10 */
+#define AO_LED_BOX             AO_LED_3        /* PA9 */
 #define LED_3_PORT             (&stm_gpioa)
 #define LED_3_PORT             (&stm_gpioa)
-#define LED_3_PIN              10
+#define LED_3_PIN              9
 
 #define AO_LED_PAD             AO_LED_4        /* PA15 */
 #define LED_4_PORT             (&stm_gpioa)
 
 #define AO_LED_PAD             AO_LED_4        /* PA15 */
 #define LED_4_PORT             (&stm_gpioa)
 #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_QUADRATURE_0_A      12
 #define AO_QUADRATURE_0_B      11
 
 #define AO_QUADRATURE_0_A      12
 #define AO_QUADRATURE_0_B      11
 
-#define AO_QUADRATURE_SELECT   10
+#define AO_QUADRATURE_SELECT   0
 
 /*
  * Buttons
 
 /*
  * Buttons
 #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
 
-#define AO_ADC_V_BATT          0
+#define AO_ADC_V_BATT          2
 #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_RCC_AHBENR      (1 << STM_RCC_AHBENR_GPIOAEN)
+#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
@@ -290,4 +311,42 @@ struct ao_adc {
  */
 #define AO_ADC_REFERENCE_DV    33
 
  */
 #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_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_ */