Commit a3e98fed authored by Bc. Petr Elexa's avatar Bc. Petr Elexa

panel: final open time

parent 1efbdc68
......@@ -57,7 +57,7 @@ static TimerHandle_t _act_timer = NULL;
static const uint32_t _act_timer_id = TERMINAL_TIMER_ID;
// Last door open(true) / close(false) status
static bool _last_door_state[ACS_READER_COUNT] = {false, false};
static bool _last_door_state[ACS_READER_MAXCOUNT] = {false, false};
// Signal request to clear cache.
static bool _cache_clear_req = false;
......@@ -170,7 +170,7 @@ void term_can_recv(uint8_t msg_obj_num)
else return;
// Stop processing if card reader not configured.
if (reader_idx >= ACS_READER_COUNT) return;
if (reader_idx >= ACS_READER_MAXCOUNT || !reader_conf[reader_idx].enabled) return;
// Continue deducing action and execute it.
if (head.fc == FC_USER_AUTH_RESP)
......@@ -289,7 +289,7 @@ static void terminal_user_identified(uint32_t user_id, uint8_t reader_idx)
term_cache_item_t user = {.key = user_id};
#endif
if (reader_idx < ACS_READER_COUNT)
if (reader_idx < ACS_READER_MAXCOUNT && reader_conf[reader_idx].enabled)
{
#if CACHING_ENABLED
// Read from cache online if master is offline.
......@@ -332,7 +332,7 @@ static void terminal_task(void *pvParameters)
uint8_t reader_idx = reader_get_request_from_buffer(&user_id, USER_REQUEST_WAIT_MS);
if (reader_idx < ACS_READER_COUNT)
if (reader_idx < ACS_READER_MAXCOUNT && reader_conf[reader_idx].enabled)
{
DEBUGSTR("user req\n");
terminal_user_identified(user_id, reader_idx);
......@@ -361,9 +361,9 @@ static void terminal_task(void *pvParameters)
if (send_door_status)
{
// Check if door open/close state changed
for (size_t idx = 0; idx < ACS_READER_COUNT; ++idx)
for (size_t idx = 0; idx < ACS_READER_MAXCOUNT; ++idx)
{
if (reader_is_door_open(idx) != _last_door_state[idx])
if (reader_conf[idx].enabled && (reader_is_door_open(idx) != _last_door_state[idx]))
{
DEBUGSTR("new door state\n");
_last_door_state[idx] = !_last_door_state[idx];
......@@ -411,8 +411,9 @@ void terminal_init(void)
ACS_DST_ADDR_MASK, true);
// Initialize card readers.
for (size_t id = 0; id < ACS_READER_COUNT; ++id)
for (size_t id = 0; id < ACS_READER_MAXCOUNT; ++id)
{
// Config only present CR
if (reader_conf[id].enabled) terminal_reconfigure(NULL, id);
}
......@@ -427,7 +428,7 @@ void terminal_init(void)
void terminal_reconfigure(reader_conf_t * reader_cfg, uint8_t reader_idx)
{
if (reader_idx >= ACS_READER_COUNT) return;
if (reader_idx >= ACS_READER_MAXCOUNT) return;
portENTER_CRITICAL(); // Effectively disables interrupts.
......
......@@ -35,14 +35,11 @@
#define STORE_I2C_BUS_FREQ 400000 // 100kHz or 400kHz
#define STORE_I2C_SLAVE_ADDR 0x50 // 7bit address
// Internal index of card readers (can be swapped).
// Internal index of card readers (can be only swapped).
#define ACS_READER_A_IDX 0
#define ACS_READER_B_IDX 1
// Number of card readers present 1 or 2.
#define ACS_READER_COUNT 2
#define BEEP_ON_SUCCESS false
#define BEEP_ON_SUCCESS true
#define OK_LED_ON_SUCCESS true
// Door sensor types (reed switch).
......@@ -117,8 +114,8 @@ void set_reader_addr(const uint16_t acs_addr);
#define ACS_READER_A_SENSOR_PORT 1 // Can be only 0 or 1.
#define ACS_READER_A_SENSOR_PIN 8
#define ACS_READER_A_OPEN_TIME_MS 8000
#define ACS_READER_A_OK_GLED_TIME_MS 4000
#define ACS_READER_A_OPEN_TIME_MS 5000
#define ACS_READER_A_OK_GLED_TIME_MS 500
//---------------------------------------------------------------------------------------------------------------------
// Settings for RFID reader B
......@@ -140,24 +137,20 @@ void set_reader_addr(const uint16_t acs_addr);
#define ACS_READER_B_SENSOR_PORT 1 // Can be only 0 or 1.
#define ACS_READER_B_SENSOR_PIN 5
#define ACS_READER_B_OPEN_TIME_MS 8000
#define ACS_READER_B_OK_GLED_TIME_MS 4000
#define ACS_READER_B_OPEN_TIME_MS 5000
#define ACS_READER_B_OK_GLED_TIME_MS 500
//---------------------------------------------------------------------------------------------------------------------
// Internal setting
//---------------------------------------------------------------------------------------------------------------------
// if following is changed it will need code modification
// Not user modifiable.
#define WEIGAND_DEVICE_LIMIT 4
#define SERIAL_DEVICE_LIMIT 0
#define ACS_READER_MAXCOUNT 2
#define TERMINAL_TIMER_ID 15
#if ACS_READER_COUNT > ACS_READER_MAXCOUNT
#error "reader max count limit"
#endif
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
......
......@@ -87,7 +87,7 @@ static void _timer_open_callback(TimerHandle_t pxTimer)
// Which timer expired
uint32_t id = (uint32_t) pvTimerGetTimerID(pxTimer);
if (id < ACS_READER_COUNT)
if (id < ACS_READER_MAXCOUNT && reader_conf[id].enabled)
{
// Lock state
Chip_GPIO_SetPinState(LPC_GPIO, _reader_wiring[id].relay_port, _reader_wiring[id].relay_pin, LOG_HIGH);
......@@ -102,7 +102,7 @@ static void _timer_ok_callback(TimerHandle_t pxTimer)
// Which timer expired
uint32_t id = (uint32_t) pvTimerGetTimerID(pxTimer);
if (id < ACS_READER_COUNT)
if (id < ACS_READER_MAXCOUNT && reader_conf[id].enabled)
{
// Lock state
Chip_GPIO_SetPinState(LPC_GPIO, _reader_wiring[id].beep_port, _reader_wiring[id].beep_pin, LOG_LOW);
......@@ -117,7 +117,7 @@ void reader_init(uint8_t idx)
//Create stream buffer to receive idx from all card readers
if (_reader_buffer == NULL)
{
_reader_buffer = xStreamBufferCreate(2 * ACS_READER_COUNT * WEIGAND26_BUFF_ITEM_SIZE, WEIGAND26_BUFF_ITEM_SIZE);
_reader_buffer = xStreamBufferCreate(2 * ACS_READER_MAXCOUNT * WEIGAND26_BUFF_ITEM_SIZE, WEIGAND26_BUFF_ITEM_SIZE);
}
configASSERT(_reader_buffer);
......
......@@ -55,7 +55,7 @@ typedef struct
/**
* @brief Configuration of readers
*/
extern reader_conf_t reader_conf[ACS_READER_COUNT];
extern reader_conf_t reader_conf[ACS_READER_MAXCOUNT];
/**
* @brief Initialize reader driver.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment