diff options
| author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-01-26 21:36:09 +0100 | 
|---|---|---|
| committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-01-26 21:36:09 +0100 | 
| commit | b2eb48a00e3e7afaff3dfbbd76e9ea3dc948f43e (patch) | |
| tree | 0d2aef5ba1f7ae22feb9e2b7e7d796efbd12fbfc /src | |
| parent | 5541099ae5fb318fc2acf6979907a76a76967af6 (diff) | |
| download | glutte-o-matic-b2eb48a00e3e7afaff3dfbbd76e9ea3dc948f43e.tar.gz glutte-o-matic-b2eb48a00e3e7afaff3dfbbd76e9ea3dc948f43e.tar.bz2 glutte-o-matic-b2eb48a00e3e7afaff3dfbbd76e9ea3dc948f43e.zip | |
Update PIO usage for new board
Diffstat (limited to 'src')
| -rw-r--r-- | src/fsm/fsm.h | 3 | ||||
| -rw-r--r-- | src/fsm/main.c | 6 | ||||
| -rw-r--r-- | src/fsm/pio.c | 52 | ||||
| -rw-r--r-- | src/fsm/pio.h | 54 | ||||
| -rw-r--r-- | src/fsm/pio.txt | 34 | 
5 files changed, 88 insertions, 61 deletions
| diff --git a/src/fsm/fsm.h b/src/fsm/fsm.h index ed918bc..e9a5ba7 100644 --- a/src/fsm/fsm.h +++ b/src/fsm/fsm.h @@ -52,7 +52,6 @@ struct fsm_input_signals_t {      /* Signals coming from repeater electronics */      int sq;                // Squelch detection      int discrim_u;         // FM discriminator says RX is too high in frequency -    int carrier;           // RX carrier detection      int qrp;               // The relay is currently running with low power      int start_tm;          // 2-hour pulse      float temp;            // temperature in degrees C @@ -73,7 +72,7 @@ struct fsm_input_signals_t {  // All signals the FSM has to control  struct fsm_output_signals_t {      /* Signals to the repeater electronics */ -    int qrp;               // Place the repeater in QRP mode +    int qrp;               // Place the repeater in QRP mode // TODO move out of FSM      int tx_on;             // Enable TX circuitry      int modulation;        // Enable repeater RX to TX modulation diff --git a/src/fsm/main.c b/src/fsm/main.c index 516aace..b6f865e 100644 --- a/src/fsm/main.c +++ b/src/fsm/main.c @@ -300,8 +300,6 @@ static void exercise_fsm(void *pvParameters)          fsm_input.start_tm = (tm_trigger == 1 && last_tm_trigger == 0) ? 1 : 0;          last_tm_trigger = tm_trigger; -        fsm_input.sq = fsm_input.carrier; // TODO clarify -          fsm_input.cw_psk31_done = !cw_psk31_busy();          if (fsm_input.cw_psk31_done) { @@ -318,8 +316,8 @@ static void exercise_fsm(void *pvParameters)          fsm_get_outputs(&fsm_out);          pio_set_tx(fsm_out.tx_on); -        pio_set_led_yel(fsm_out.modulation); -        pio_set_led_grn(fsm_input.carrier); +        pio_set_mod_off(!fsm_out.modulation); +        pio_set_qrp(fsm_out.qrp); // TODO move out of FSM          // Add message to CW generator only on rising edge of trigger          if (fsm_out.cw_psk31_trigger && !cw_last_trigger) { diff --git a/src/fsm/pio.c b/src/fsm/pio.c index fba7ddc..418f24a 100644 --- a/src/fsm/pio.c +++ b/src/fsm/pio.c @@ -47,7 +47,7 @@ void pio_init()      GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;      GPIO_Init(GPIOC, &GPIO_InitStructure); -#if GPIOC_OPENDRAIN_PINS +#if defined(GPIOC_OPENDRAIN_PINS)      GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_OUT;      GPIO_InitStructure.GPIO_Pin   = GPIOC_OPENDRAIN_PINS;      GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP; @@ -56,12 +56,14 @@ void pio_init()      GPIO_Init(GPIOC, &GPIO_InitStructure);  #endif +#if defined(GPIOC_INPUT_PU_PINS)      GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IN;      GPIO_InitStructure.GPIO_Pin   = GPIOC_INPUT_PU_PINS;      GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;      GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;      GPIO_Init(GPIOC, &GPIO_InitStructure); +#endif      GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IN;      GPIO_InitStructure.GPIO_Pin   = GPIOC_INPUT_PINS; @@ -87,15 +89,26 @@ void pio_set_fsm_signals(struct fsm_input_signals_t* sig)  void read_fsm_input_task(void *pvParameters)  {      while (1) { -        pio_signals.qrp       = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_QRP_n) ? 0 : 1; -#if INVERTED_1750 -        pio_signals.tone_1750 = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_1750) ? 0 : 1; -#else -        pio_signals.tone_1750 = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_1750) ? 1 : 0; -#endif -        pio_signals.carrier   = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_RX_n) ? 0 : 1; -        pio_signals.discrim_u = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_U_n) ? 0 : 1; -        pio_signals.discrim_d = GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_D_n) ? 0 : 1; +        pio_signals.qrp = +            GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_QRP_n) ? 0 : 1; + +        pio_signals.tone_1750 = +            GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_1750_n) ? 0 : 1; + +        pio_signals.sq = +            GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_SQ_n) ? 0 : 1; + +        pio_signals.discrim_u = +            GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_U) ? 1 : 0; + +        pio_signals.discrim_d = +            GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_D) ? 1 : 0; + +        pio_signals.wind_generator_ok = +            GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_REPLIE_n) ? 1 : 0; + +        pio_signals.sstv_mode = +            GPIO_ReadInputDataBit(GPIOC, GPIO_PIN_FAX_n) ? 0 : 1;          vTaskDelay(100 / portTICK_RATE_MS);      } @@ -103,31 +116,30 @@ void read_fsm_input_task(void *pvParameters)  void pio_set_tx(int on)  { -    // Led is active high, TX_n is inverted logic      if (on) { -        GPIO_SetBits(GPIOC, GPIO_PIN_LED_red | GPIO_PIN_TX); +        GPIO_SetBits(GPIOC, GPIO_PIN_TX);      }      else { -        GPIO_ResetBits(GPIOC, GPIO_PIN_LED_red | GPIO_PIN_TX); +        GPIO_ResetBits(GPIOC, GPIO_PIN_TX);      }  } -void pio_set_led_grn(int on) +void pio_set_qrp(int on)  {      if (on) { -        GPIO_SetBits(GPIOC, GPIO_PIN_LED_grn); +        GPIO_SetBits(GPIOC, GPIO_PIN_QRP_out);      }      else { -        GPIO_ResetBits(GPIOC, GPIO_PIN_LED_grn); +        GPIO_ResetBits(GPIOC, GPIO_PIN_QRP_out);      }  } -void pio_set_led_yel(int on) +void pio_set_mod_off(int mod_off)  { -    if (on) { -        GPIO_SetBits(GPIOC, GPIO_PIN_LED_yel); +    if (mod_off) { +        GPIO_SetBits(GPIOC, GPIO_PIN_MOD_OFF);      }      else { -        GPIO_ResetBits(GPIOC, GPIO_PIN_LED_yel); +        GPIO_ResetBits(GPIOC, GPIO_PIN_MOD_OFF);      }  } diff --git a/src/fsm/pio.h b/src/fsm/pio.h index 181b08d..9e7d4fb 100644 --- a/src/fsm/pio.h +++ b/src/fsm/pio.h @@ -33,40 +33,46 @@  /* See pio.txt for PIO allocation details */ -#define INVERTED_1750 0 -  /* On GPIO C */ -#define GPIO_PIN_QRP_n   GPIO_Pin_1 -#define GPIO_PIN_LED_red GPIO_Pin_2 -#define GPIO_PIN_1750    GPIO_Pin_4 -#define GPIO_PIN_LED_yel GPIO_Pin_5 -#define GPIO_PIN_RX_n    GPIO_Pin_6 -#define GPIO_PIN_U_n     GPIO_Pin_8 -#define GPIO_PIN_LED_grn GPIO_Pin_9 -#define GPIO_PIN_D_n     GPIO_Pin_11 -#define GPIO_PIN_TX      GPIO_Pin_13 +#define GPIO_PIN_QRP_n    GPIO_Pin_1 +#define GPIO_PIN_TX       GPIO_Pin_2 +#define GPIO_PIN_1750_n   GPIO_Pin_4 +#define GPIO_PIN_MOD_OFF  GPIO_Pin_5 +#define GPIO_PIN_SQ_n     GPIO_Pin_6 +#define GPIO_PIN_U        GPIO_Pin_8 +#define GPIO_PIN_QRP_out  GPIO_Pin_9 +#define GPIO_PIN_D        GPIO_Pin_11 +#define GPIO_PIN_REPLIE_n GPIO_Pin_13 +#define GPIO_PIN_FAX_n    GPIO_Pin_14 -#define GPIOC_OUTPUT_PINS GPIO_PIN_LED_red | \ -                          GPIO_PIN_LED_yel | \ -                          GPIO_PIN_LED_grn | \ -                          GPIO_PIN_TX +#define GPIOC_OUTPUT_PINS ( \ +                           GPIO_PIN_TX | \ +                           GPIO_PIN_MOD_OFF | \ +                           GPIO_PIN_QRP_out | \ +                           0) -#define GPIOC_OPENDRAIN_PINS 0 +#undef GPIOC_OPENDRAIN_PINS +#undef GPIOC_INPUT_PU_PINS -#define GPIOC_INPUT_PINS 0 +#define GPIOC_INPUT_PINS ( \ +                          GPIO_PIN_QRP_n | \ +                          GPIO_PIN_1750_n | \ +                          GPIO_PIN_SQ_n | \ +                          GPIO_PIN_U | \ +                          GPIO_PIN_D | \ +                          GPIO_PIN_REPLIE_n | \ +                          0 ) -#define GPIOC_INPUT_PU_PINS GPIO_PIN_QRP_n | \ -                            GPIO_PIN_U_n | \ -                            GPIO_PIN_D_n | \ -                            GPIO_PIN_RX_n | \ -                            GPIO_PIN_1750 +/* Analog inputs */ +// TODO: SWR forward power +// TODO: SWR reflected power  void pio_init(void);  void pio_set_tx(int on); -void pio_set_led_yel(int on); -void pio_set_led_grn(int on); +void pio_set_mod_off(int mod_off); +void pio_set_qrp(int on);  void pio_set_fsm_signals(struct fsm_input_signals_t* sig); diff --git a/src/fsm/pio.txt b/src/fsm/pio.txt index cd29cd1..3464b28 100644 --- a/src/fsm/pio.txt +++ b/src/fsm/pio.txt @@ -1,9 +1,29 @@  Allocation of PIOs to functions  =============================== -Test logic ----------- --       out TX_ON               PC13 +TODO Connexions Relais +---------------------- +-       in   QRP_n              PC1 +-       out  TX_ON              PC2 +-       i/o  ?                  PC3 +-       in   1750_n             PC4 +-       out  MOD_OFF            PC5 +-       in   SQ_n               PC6 +-       in   U_n                PC8 +-       out  QRP                PC9 +-       in   D_n                PC11 +-       in   REPLIE_n           PC13 +-       in   FAX_n              PC14 + +-       i/o  ?                  PC15 + +-       i/o  Dallas 1-wire + +TODO Analog signals +------------------- +-       in   SWR forward +-       in   SWR reflected +-       in   Vcc 12V measurement  u-blox NEO-M8N GPS module connection  ------------------------------------ @@ -17,15 +37,7 @@ Debug USART  For the little test board with the 3 LEDs and switches  ------------------------------------------------------ -Blue    in   QRP_n              PC1 -Violet  out  LED red            PC2 -Grey    in   1750               PC4 -White   out  LED yel            PC5 -Black   -    GND                GND -Brown   in   RX_n               PC6 -Red     in   U_n                PC8  Orange  out  LED grn            PC9 -Green   in   D_n                PC11  I2C to Audio Codec  ------------------ | 
