Commit 88346f9d authored by Bc. Petr Elexa's avatar Bc. Petr Elexa

WIP backup

parent 644c8c90
......@@ -49,6 +49,7 @@
<option id="com.crt.advproject.c.misc.dialect.907198308" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<option id="gnu.c.compiler.option.warnings.pedantic.257334611" name="Pedantic (-pedantic)" superClass="gnu.c.compiler.option.warnings.pedantic" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.warnings.extrawarn.21346167" name="Extra warnings (-Wextra)" superClass="gnu.c.compiler.option.warnings.extrawarn" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gcc.exe.debug.option.optimization.level.2073691341" name="Optimization Level" superClass="com.crt.advproject.gcc.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.none" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.834651089" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.gas.exe.debug.429375711" name="MCU Assembler" superClass="com.crt.advproject.gas.exe.debug">
......@@ -58,8 +59,6 @@
<option id="com.crt.advproject.gas.hdrlib.155260126" name="Library headers" superClass="com.crt.advproject.gas.hdrlib" useByScannerDiscovery="false" value="com.crt.advproject.gas.hdrlib.newlibnano" valueType="enumerated"/>
<option id="com.crt.advproject.gas.specs.978275111" name="Specs" superClass="com.crt.advproject.gas.specs" useByScannerDiscovery="false" value="com.crt.advproject.gas.specs.newlibnano" valueType="enumerated"/>
<option id="gnu.both.asm.option.include.paths.1819922491" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/nxp_lpcxpresso_11c24_board_lib/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_11cxx_lib/inc}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.469338895" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
......@@ -71,7 +70,7 @@
<tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="com.crt.advproject.link.exe.debug.843938519" name="MCU Linker" superClass="com.crt.advproject.link.exe.debug">
<option id="com.crt.advproject.link.thumb.686732510" name="Thumb mode" superClass="com.crt.advproject.link.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.link.memory.load.image.1714228801" name="Plain load image" superClass="com.crt.advproject.link.memory.load.image" useByScannerDiscovery="false" value="false;" valueType="string"/>
<option id="com.crt.advproject.link.memory.heapAndStack.657739555" name="Heap and Stack options" superClass="com.crt.advproject.link.memory.heapAndStack" useByScannerDiscovery="false" value="&amp;Heap:Default;Post Data;Default&amp;Stack:Default;End;Default" valueType="string"/>
<option id="com.crt.advproject.link.memory.heapAndStack.657739555" name="Heap and Stack options" superClass="com.crt.advproject.link.memory.heapAndStack" useByScannerDiscovery="false" value="&amp;Heap:Default;Post Data;0x400&amp;Stack:Default;End;Default" valueType="string"/>
<option id="com.crt.advproject.link.memory.data.1084767913" name="Global data placement" superClass="com.crt.advproject.link.memory.data" useByScannerDiscovery="false" value="Default" valueType="string"/>
<option id="com.crt.advproject.link.memory.sections.169757493" name="Extra linker script input sections" superClass="com.crt.advproject.link.memory.sections" useByScannerDiscovery="false" valueType="stringList"/>
<option id="com.crt.advproject.link.gcc.multicore.master.userobjs.540811877" name="Slave Objects (not visible)" superClass="com.crt.advproject.link.gcc.multicore.master.userobjs" useByScannerDiscovery="false" valueType="userObjs"/>
......@@ -93,7 +92,7 @@
</option>
<option id="com.crt.advproject.link.crpenable.1361098444" name="Enable automatic placement of Code Read Protection field in image" superClass="com.crt.advproject.link.crpenable" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.link.gcc.multicore.slave.1826238096" name="Multicore configuration" superClass="com.crt.advproject.link.gcc.multicore.slave" useByScannerDiscovery="false"/>
<option defaultValue="com.crt.advproject.heapAndStack.lpcXpressoStyle" id="com.crt.advproject.link.memory.heapAndStack.style.1305918220" name="Heap and Stack placement" superClass="com.crt.advproject.link.memory.heapAndStack.style" useByScannerDiscovery="false" value="com.crt.advproject.heapAndStack.lpcXpressoStyle" valueType="enumerated"/>
<option defaultValue="com.crt.advproject.heapAndStack.lpcXpressoStyle" id="com.crt.advproject.link.memory.heapAndStack.style.1305918220" name="Heap and Stack placement" superClass="com.crt.advproject.link.memory.heapAndStack.style" useByScannerDiscovery="false" value="com.crt.advproject.heapAndStack.mcuXpressoStyle" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1208716874" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
......
......@@ -9,6 +9,7 @@
*/
#include <terminal.h>
#include "board_config.h"
#include "board.h"
//#include "canopen_driver.h"
#include "FreeRTOS.h"
......@@ -24,7 +25,7 @@
/*****************************************************************************
* Public types/enumerations/variables
****************************************************************************/
unsigned int TERMINAL_UID[4] = {0, 0, 0, 0};
/*****************************************************************************
* Private functions
......@@ -32,29 +33,34 @@
static void setup_hardware(void)
{
// Read clock settings and update SystemCoreClock variable
SystemCoreClockUpdate();
// Set up and initialize all required blocks and
// functions related to the board hardware
Board_Init();
#ifdef DEVEL_BOARD
Board_LED_Set(0, false);
// Read clock settings and update SystemCoreClock variable
SystemCoreClockUpdate();
// Set up and initialize all required blocks and
// functions related to the board hardware
Board_Init();
#ifdef DEVEL_BOARD
Board_LED_Set(0, false);
Board_LED_Set(1, false);
Board_LED_Set(2, false);
#endif
// Enable INTs for all GPIO ports
NVIC_EnableIRQ(EINT0_IRQn);
NVIC_EnableIRQ(EINT1_IRQn);
NVIC_EnableIRQ(EINT2_IRQn);
NVIC_EnableIRQ(EINT3_IRQn);
//Read UID
unsigned int cmd_param[5] = {IAP_READ_UID, 0, 0, 0, 0};
iap_entry(cmd_param, TERMINAL_UID);
// Enable INTs for all GPIO ports
NVIC_EnableIRQ(EINT0_IRQn);
NVIC_EnableIRQ(EINT1_IRQn);
NVIC_EnableIRQ(EINT2_IRQn);
NVIC_EnableIRQ(EINT3_IRQn);
// Initialize card reading ability
card_reader_init();
// Initialize terminal ability
//can_driver_init();
terminal_init();
extern unsigned long _vStackTop[], _pvHeapStart[];
unsigned long ulInterruptStackSize;
extern unsigned long _vStackTop[], _pvHeapStart[];
unsigned long ulInterruptStackSize;
/* The size of the stack used by main and interrupts is not defined in
the linker, but just uses whatever RAM is left. Calculate the amount of
RAM available for the main/interrupt/system stack, and check it against
......@@ -92,12 +98,12 @@ int main(void)
xTaskCreate(alive_task, "alv_tsk",configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 1UL), NULL);
__enable_irq();
__enable_irq();
/* Start the kernel. From here on, only tasks and interrupts will run. */
vTaskStartScheduler();
/* Start the kernel. From here on, only tasks and interrupts will run. */
vTaskStartScheduler();
return 1;
return 1;
}
void vApplicationMallocFailedHook(void)
......
......@@ -51,19 +51,20 @@ extern uint32_t SystemCoreClock;
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configMAX_PRIORITIES ( 6 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 64 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048 ) )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048 + 1024 ) )
#define configMAX_TASK_NAME_LEN ( 8 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
#define configUSE_MUTEXES 0
#define configQUEUE_REGISTRY_SIZE 8
#define configCHECK_FOR_STACK_OVERFLOW 2
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 0
#define configUSE_MALLOC_FAILED_HOOK 1
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_COUNTING_SEMAPHORES 0
#define configGENERATE_RUN_TIME_STATS 0
#define configRECORD_STACK_HIGH_ADDRESS 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
/* Co-routine definitions. */
......@@ -71,7 +72,7 @@ extern uint32_t SystemCoreClock;
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 0
#define configUSE_TIMERS 0
#define configTIMER_TASK_PRIORITY ( 2 )
#define configTIMER_QUEUE_LENGTH 2
#define configTIMER_TASK_STACK_DEPTH ( 80 )
......@@ -86,6 +87,7 @@ to exclude the API function. */
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_eTaskGetState 1
#define INCLUDE_xTaskGetCurrentTaskHandle 1
/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
......
......@@ -61,7 +61,7 @@ extern "C" {
via semihosting. You may need to use a C library that supports
semihosting with this option.
*/
//#define DEBUG_SEMIHOSTING
#define DEBUG_SEMIHOSTING
/** Board UART used for debug output and input using the DEBUG* macros. This
is also the port used for Board_UARTPutChar, Board_UARTGetChar, and
......
......@@ -10,41 +10,67 @@
#include "chip.h"
#define DEVEL_BOARD
#define TERMINAL_ID 1
#define CARD_READER1 0
#define CARD_READER1_ID 1
#define CARD_READER1_PORT 1
#define CARD_READER1_D0_PIN 1
#define CARD_READER1_D1_PIN 2
#define CARD_READER1_RELAY_PORT 0
#define CARD_READER1_RELAY_PIN 0
#define CARD_READER2 0
#define CARD_READER2_ID 2
#define CARD_READER2_PORT 2
#define CARD_READER2_D0_PIN 0
#define CARD_READER2_D1_PIN 0
#define CARD_READER2_RELAY_PORT 0
#define CARD_READER2_RELAY_PIN 0
#define CARD_READER3 1
#define CARD_READER3_ID 3
#define CARD_READER3_PORT 3
#define CARD_READER3_D0_PIN 1
#define CARD_READER3_D1_PIN 2
#define CARD_READER3_RELAY_PORT 0
#define CARD_READER3_RELAY_PIN 0
#define CARD_READER_BEEPER_PORT 0
#define CARD_READER_BEEPER_PIN 0
#define CARD_READER_LED_PORT 0
#define CARD_READER_LED_PIN 0
#define CARD_READERS_MAX_COUNT 4
//#define CARD_READERS_COUNT (CARD_READER1 + CARD_READER2 + CARD_READER3)
//Use global UID from chip as terminal unique ID
#define IAP_READ_UID 58
extern unsigned int TERMINAL_UID[4];
//---------------------------------------------------------------------------------------------------------------------
//Default values for door 0
//---------------------------------------------------------------------------------------------------------------------
#define DOOR_0_ACC_PANEL_ON false
#define DOOR_0_ACC_PANEL_PORT 1
#define DOOR_0_ACC_PANEL_D0_PIN 1
#define DOOR_0_ACC_PANEL_D1_PIN 2
#define DOOR_0_ACC_PANEL_BEEP_PORT 0
#define DOOR_0_ACC_PANEL_BEEP_PIN 0
#define DOOR_0_ACC_PANEL_GLED_PORT 0
#define DOOR_0_ACC_PANEL_GLED_PIN 0
#define DOOR_0_RELAY_PORT 0
#define DOOR_0_RELAY_PIN 0
#define DOOR_0_OPEN_TIME_SEC 10
//---------------------------------------------------------------------------------------------------------------------
//Default values for door 1
//---------------------------------------------------------------------------------------------------------------------
#define DOOR_1_ACC_PANEL_ON false
#define DOOR_1_ACC_PANEL_PORT 2
#define DOOR_1_ACC_PANEL_D0_PIN 0
#define DOOR_1_ACC_PANEL_D1_PIN 0
#define DOOR_1_ACC_PANEL_BEEP_PORT 0
#define DOOR_1_ACC_PANEL_BEEP_PIN 0
#define DOOR_1_ACC_PANEL_GLED_PORT 0
#define DOOR_1_ACC_PANEL_GLED_PIN 0
#define DOOR_1_RELAY_PORT 0
#define DOOR_1_RELAY_PIN 0
#define DOOR_1_OPEN_TIME_SEC 10
//---------------------------------------------------------------------------------------------------------------------
//Default values for door 2
//---------------------------------------------------------------------------------------------------------------------
#define DOOR_2_ACC_PANEL_ON true
#define DOOR_2_ACC_PANEL_PORT 3
#define DOOR_2_ACC_PANEL_D0_PIN 1
#define DOOR_2_ACC_PANEL_D1_PIN 2
#define DOOR_2_ACC_PANEL_BEEP_PORT 0
#define DOOR_2_ACC_PANEL_BEEP_PIN 0
#define DOOR_2_ACC_PANEL_GLED_PORT 0
#define DOOR_2_ACC_PANEL_GLED_PIN 0
#define DOOR_2_RELAY_PORT 0
#define DOOR_2_RELAY_PIN 0
#define DOOR_2_OPEN_TIME_SEC 10
#define WEIGAND_DEVICE_LIMIT 3
#define SERIAL_DEVICE_LIMIT 0
#define DOOR_ACC_PANEL_MAX_COUNT (WEIGAND_DEVICE_LIMIT + SERIAL_DEVICE_LIMIT)
#endif /* BSP_BOARD_CONFIG_H_ */
......@@ -10,58 +10,136 @@
#include "FreeRTOS.h"
#include "task.h"
#include "stream_buffer.h"
#include <stdio.h>
static StreamBufferHandle_t cr_stream[CARD_READERS_MAX_COUNT];
#define ACC_PANEL_0 0
#define ACC_PANEL_1 1
#define ACC_PANEL_2 2
static void terminal_process_card(uint16_t card_number, uint8_t facility_code, uint8_t reader_id)
static StreamBufferHandle_t _cr_stream[DOOR_ACC_PANEL_MAX_COUNT] = {0};
static panel_conf_t _acc_panel[DOOR_ACC_PANEL_MAX_COUNT] =
{
printf("Facility: %u Card: %u Parity: %u\n", facility_code, card_number);
{
.acc_panel_on = DOOR_0_ACC_PANEL_ON,
.acc_panel_port = DOOR_0_ACC_PANEL_PORT,
.acc_panel_d0_pin = DOOR_0_ACC_PANEL_D0_PIN,
.acc_panel_d1_pin = DOOR_0_ACC_PANEL_D1_PIN,
.acc_panel_beep_port = DOOR_0_ACC_PANEL_BEEP_PORT,
.acc_panel_beep_pin = DOOR_0_ACC_PANEL_BEEP_PIN,
.acc_panel_gled_port = DOOR_0_ACC_PANEL_GLED_PORT,
.acc_panel_gled_pin = DOOR_0_ACC_PANEL_GLED_PIN,
.relay_port = DOOR_0_RELAY_PORT,
.relay_pin = DOOR_0_RELAY_PIN,
.open_time_sec = DOOR_0_OPEN_TIME_SEC,
},
{
.acc_panel_on = DOOR_1_ACC_PANEL_ON,
.acc_panel_port = DOOR_1_ACC_PANEL_PORT,
.acc_panel_d0_pin = DOOR_1_ACC_PANEL_D0_PIN,
.acc_panel_d1_pin = DOOR_1_ACC_PANEL_D1_PIN,
.acc_panel_beep_port = DOOR_1_ACC_PANEL_BEEP_PORT,
.acc_panel_beep_pin = DOOR_1_ACC_PANEL_BEEP_PIN,
.acc_panel_gled_port = DOOR_1_ACC_PANEL_GLED_PORT,
.acc_panel_gled_pin = DOOR_1_ACC_PANEL_GLED_PIN,
.relay_port = DOOR_1_RELAY_PORT,
.relay_pin = DOOR_1_RELAY_PIN,
.open_time_sec = DOOR_1_OPEN_TIME_SEC,
},
{
.acc_panel_on = DOOR_2_ACC_PANEL_ON,
.acc_panel_port = DOOR_2_ACC_PANEL_PORT,
.acc_panel_d0_pin = DOOR_2_ACC_PANEL_D0_PIN,
.acc_panel_d1_pin = DOOR_2_ACC_PANEL_D1_PIN,
.acc_panel_beep_port = DOOR_2_ACC_PANEL_BEEP_PORT,
.acc_panel_beep_pin = DOOR_2_ACC_PANEL_BEEP_PIN,
.acc_panel_gled_port = DOOR_2_ACC_PANEL_GLED_PORT,
.acc_panel_gled_pin = DOOR_2_ACC_PANEL_GLED_PIN,
.relay_port = DOOR_2_RELAY_PORT,
.relay_pin = DOOR_2_RELAY_PIN,
.open_time_sec = DOOR_2_OPEN_TIME_SEC,
}
};
static void terminal_process_card(uint8_t facility_code, uint16_t card_number, uint8_t reader_id)
{
#ifdef DEVEL_BOARD
printf("Facility: %u Card: %u Parity: %u\n", facility_code, card_number);
Board_LED_Set(1, true);
vTaskDelay(1000 / portTICK_PERIOD_MS);
Board_LED_Set(1, false);
#endif
}
static void card_reader_task(void *pvParameters)
static void terminal_reader_task(void *pvParameters)
{
weigand26_frame_t card_data;
size_t bytes_got;
//printf("test");
(void)pvParameters;
while (true)
{
weigand26_frame_t card_data;
size_t bytes_got;
printf("card_task\n");
if (_acc_panel[ACC_PANEL_0].acc_panel_on)
{
bytes_got = xStreamBufferReceive(_cr_stream[0], &card_data, sizeof card_data, pdMS_TO_TICKS(0));
if (bytes_got == sizeof card_data && weigand_is_parity_ok(card_data))
{
terminal_process_card(card_data.facility_code, card_data.card_number, ACC_PANEL_0);
}
}
if (_acc_panel[ACC_PANEL_1].acc_panel_on)
{
bytes_got = xStreamBufferReceive(_cr_stream[1], &card_data, sizeof card_data, pdMS_TO_TICKS(0));
if (bytes_got == sizeof card_data && weigand_is_parity_ok(card_data))
{
terminal_process_card(card_data.facility_code, card_data.card_number, ACC_PANEL_1);
}
}
if (_acc_panel[ACC_PANEL_2].acc_panel_on)
{
bytes_got = xStreamBufferReceive(_cr_stream[2], &card_data, sizeof card_data, pdMS_TO_TICKS(0));
if (bytes_got == sizeof card_data && weigand_is_parity_ok(card_data))
{
terminal_process_card(card_data.facility_code, card_data.card_number, ACC_PANEL_2);
}
}
}
}
void terminal_init(void)
{
for (int i = 0; i < DOOR_ACC_PANEL_MAX_COUNT; ++i)
{
if (_acc_panel[i].acc_panel_on) terminal_reconfigure(NULL, i);
}
while(true)
{
#if CARD_READER1
bytes_got = xStreamBufferReceive(cr_stream[CARD_READER1_ID], &card_data, sizeof card_data, pdMS_TO_TICKS(0));
if (bytes_got == sizeof card_data && weigand_is_parity_ok(card_data))
{
terminal_process_card(card_data.facility_code, card_data.card_number, CARD_READER1_ID);
}
#endif
#if CARD_READER2
bytes_got = xStreamBufferReceive(cr_stream[CARD_READER2_ID], &card_data, sizeof card_data, pdMS_TO_TICKS(0));
if (bytes_got == sizeof card_data && weigand_is_parity_ok(card_data))
{
terminal_process_card(card_data.facility_code, card_data.card_number, CARD_READER2_ID);
}
#endif
#if CARD_READER3
bytes_got = xStreamBufferReceive(cr_stream[CARD_READER3_ID], &card_data, sizeof card_data, pdMS_TO_TICKS(0));
if (bytes_got == sizeof card_data && weigand_is_parity_ok(card_data))
{
terminal_process_card(card_data.facility_code, card_data.card_number, CARD_READER3_ID);
}
#endif
}
xTaskCreate(terminal_reader_task, "term_tsk", configMINIMAL_STACK_SIZE + 128, NULL, (tskIDLE_PRIORITY + 1UL), NULL);
}
void card_reader_init(void)
void terminal_reconfigure(panel_conf_t * acc_panel, uint8_t id)
{
#if CARD_READER1
cr_stream[CARD_READER1_ID] = weigand_init(CARD_READER1_PORT, CARD_READER1_D0_PIN, CARD_READER1_D1_PIN);
#endif
#if CARD_READER2
cr_stream[CARD_READER2_ID] = weigand_init(CARD_READER2_PORT, CARD_READER2_D0_PIN, CARD_READER2_D1_PIN);
#endif
#if CARD_READER3
cr_stream[CARD_READER3_ID] = weigand_init(CARD_READER3_PORT, CARD_READER3_D0_PIN, CARD_READER3_D1_PIN);
#endif
if (id >= DOOR_ACC_PANEL_MAX_COUNT) return;
xTaskCreate(card_reader_task, "crd_tsk", configMINIMAL_STACK_SIZE + 64, NULL, (tskIDLE_PRIORITY + 1UL), NULL);
portENTER_CRITICAL();
if (acc_panel != NULL)
{
memcpy(&_acc_panel[id], acc_panel, sizeof(_acc_panel[id]));
}
//reconfigure interface to card reader
if (acc_panel[id].acc_panel_on)
{
_cr_stream[id] = xStreamBufferCreate(CONSUMER_BUFF_SIZE, CONSUMER_BUFF_SIZE);
configASSERT(_cr_stream[id]);
weigand_init(_cr_stream[id], _acc_panel[id].acc_panel_port, _acc_panel[id].acc_panel_d0_pin, _acc_panel[id].acc_panel_d1_pin);
}
//disable interface
else
{
vStreamBufferDelete(_cr_stream[id]);
_cr_stream[id] = NULL;
weigand_disable(_acc_panel[id].acc_panel_port, _acc_panel[id].acc_panel_d0_pin, _acc_panel[id].acc_panel_d1_pin);
}
portEXIT_CRITICAL();
}
......@@ -8,6 +8,27 @@
#ifndef BSP_TERMINAL_H_
#define BSP_TERMINAL_H_
void card_reader_init(void);
#include <stdint.h>
#pragma pack(push, 1)
typedef struct
{
uint8_t acc_panel_on : 1;
uint8_t acc_panel_port : 4;
uint8_t acc_panel_d0_pin : 4;
uint8_t acc_panel_d1_pin : 4;
uint8_t acc_panel_beep_port : 4;
uint8_t acc_panel_beep_pin : 4;
uint8_t acc_panel_gled_port : 4;
uint8_t acc_panel_gled_pin : 4;
uint8_t relay_port : 4;
uint8_t relay_pin : 4;
uint8_t open_time_sec : 8;
} panel_conf_t; //TOTAL SIZE 6B
#pragma pack(pop)
void terminal_init(void);
void terminal_reconfigure(panel_conf_t * acc_panel, uint8_t id);
#endif /* BSP_TERMINAL_H_ */
......@@ -27,6 +27,8 @@ typedef union{
uint32_t value;
}weigand26_frame_t;
#define CONSUMER_BUFF_SIZE sizeof(weigand26_frame_t)
typedef struct {
weigand26_frame_t frame_buffer;
uint8_t frame_buffer_ptr;
......@@ -37,7 +39,9 @@ typedef struct {
}weigand26_t;
StreamBufferHandle_t weigand_init(uint8_t dx_port, uint8_t d0_pin, uint8_t d1_pin);
void weigand_init(StreamBufferHandle_t buffer, uint8_t dx_port, uint8_t d0_pin, uint8_t d1_pin);
void weigand_disable(uint8_t dx_port, uint8_t d0_pin, uint8_t d1_pin);
bool weigand_pending_frame(weigand26_t * instance);
......
......@@ -17,12 +17,12 @@
#include <assert.h>
static weigand26_t device[CARD_READERS_MAX_COUNT];
static weigand26_t device[WEIGAND_DEVICE_LIMIT];
StreamBufferHandle_t weigand_init(uint8_t dx_port, uint8_t d0_pin, uint8_t d1_pin)
void weigand_init(StreamBufferHandle_t buffer, uint8_t dx_port, uint8_t d0_pin, uint8_t d1_pin)
{
if (dx_port > 3) return NULL;
if (dx_port > 3) return;
//Save device information
device[dx_port].port = dx_port;
......@@ -31,7 +31,7 @@ StreamBufferHandle_t weigand_init(uint8_t dx_port, uint8_t d0_pin, uint8_t d1_pi
device[dx_port].frame_buffer.value = 0;
device[dx_port].frame_buffer_ptr = WEIGAND26_FRAME_SIZE;
//Enable pullups
//Enable pull-ups
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO3_1, IOCON_MODE_PULLUP);
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO3_2, IOCON_MODE_PULLUP);
......@@ -48,13 +48,15 @@ StreamBufferHandle_t weigand_init(uint8_t dx_port, uint8_t d0_pin, uint8_t d1_pi
Chip_GPIO_ClearInts(LPC_GPIO, dx_port, (1 << d1_pin));
//Create stream
device[dx_port].consumer_buffer = xStreamBufferCreate(sizeof(weigand26_frame_t), sizeof(weigand26_frame_t));
assert(device[dx_port].consumer_buffer);
device[dx_port].consumer_buffer = buffer;
//Enable INT for both pins
Chip_GPIO_EnableInt(LPC_GPIO, dx_port, (1 << d0_pin) | (1 << d1_pin));
Chip_GPIO_EnableInt(LPC_GPIO, dx_port, (1 << d0_pin) | (1 << d1_pin));
}
return device[dx_port].consumer_buffer;
void weigand_disable(uint8_t dx_port, uint8_t d0_pin, uint8_t d1_pin)
{
Chip_GPIO_DisableInt(LPC_GPIO, dx_port, (1 << d0_pin) | (1 << d1_pin));
}
bool weigand_pending_frame(weigand26_t * device)
......
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