summaryrefslogtreecommitdiffstats
path: root/radiator-plc/stm32/app/inputs.c
blob: 825a3fe1e9c29c705147022a28c7a95c4135d28f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "project.h"

#define N_INPUTS  14

static const uint32_t input_bank[N_INPUTS] = { GPIOC, GPIOC, GPIOB, GPIOA, GPIOA, GPIOC, GPIOD, GPIOD, 0, 0, GPIOD, GPIOD, GPIOD, GPIOD};
static const uint32_t input[N_INPUTS] = { GPIO7, GPIO6, GPIO15, GPIO1, GPIO0, GPIO4, GPIO15, GPIO14, 0, 0, GPIO13, GPIO12, GPIO11, GPIO10};

int input_get (unsigned r)
{
  if (r >= N_INPUTS) return 0;

  if (!input[r]) return 0;

  return !gpio_get (input_bank[r], input[r]);
}


void inputs_init (void)
{
  unsigned r;

  for (r = 0; r < N_INPUTS; ++r)
    if (input[r])
      gpio_set_mode (input_bank[r], GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, input[r]);

}