Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
card-access-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bc. Petr Elexa
card-access-system
Commits
efb38e6b
Commit
efb38e6b
authored
Jan 13, 2020
by
Bc. Petr Elexa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
panel: wiegand: change frame expiration
parent
37eca712
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
19 deletions
+22
-19
weigand.c
cardreader/bsp/weigand/weigand.c
+21
-18
weigand.h
cardreader/bsp/weigand/weigand.h
+1
-1
No files found.
cardreader/bsp/weigand/weigand.c
View file @
efb38e6b
...
...
@@ -42,14 +42,13 @@ static void weigand_frame_timeout(TimerHandle_t pxTimer)
// Which timer expired
uint32_t
id
=
(
int32_t
)
pvTimerGetTimerID
(
pxTimer
);
portENTER_CRITICAL
();
// Prevent weigand_int_handler from being invoked
if
(
device
[
id
].
frame_buffer_ptr
!=
WEIGAND26_FRAME_SIZE
)
{
// Empty the frame buffer
device
[
id
].
frame_buffer
.
value
=
0
;
device
[
id
].
frame_buffer_ptr
=
WEIGAND26_FRAME_SIZE
;
}
// Atomicity is guaranteed because when weigand_int_handler is invoked
// weigand_frame_timeout will not be called. But we need to prevent
// weigand_int_handler from being invoked.
portENTER_CRITICAL
();
// Empty the frame buffer because next bit period expired
device
[
id
].
frame_buffer
.
value
=
0
;
device
[
id
].
frame_buffer_ptr
=
WEIGAND26_FRAME_SIZE
;
portEXIT_CRITICAL
();
}
...
...
@@ -87,7 +86,7 @@ void weigand_init(StreamBufferHandle_t buffer, uint8_t id, uint8_t dx_port, uint
//Create timer
if
(
device
[
dx_port
].
timer
==
NULL
)
{
device
[
dx_port
].
timer
=
xTimerCreate
(
"WG"
,
(
WEIGAND26_
FRAME_TIME_LIMIT
/
portTICK_PERIOD_MS
),
pdFALSE
,
(
void
*
)(
uint32_t
)
dx_port
,
weigand_frame_timeout
);
device
[
dx_port
].
timer
=
xTimerCreate
(
"WG"
,
(
WEIGAND26_
MAX_BIT_PERIOD
/
portTICK_PERIOD_MS
),
pdFALSE
,
(
void
*
)(
uint32_t
)
dx_port
,
weigand_frame_timeout
);
}
configASSERT
(
device
[
dx_port
].
timer
);
...
...
@@ -129,12 +128,14 @@ bool weigand_is_parity_ok(weigand26_frame_t frame)
return
even_parity
==
((
frame
.
value
>>
25
)
&
0x1
)
&&
odd_parity
==
(
frame
.
value
&
0x1
);
}
static
inline
void
_
wake_timer_on_frame_start
(
weigand26_t
*
device
)
static
inline
void
_
refresh_frame_time
(
weigand26_t
*
device
)
{
if
(
device
->
frame_buffer_ptr
==
WEIGAND26_FRAME_SIZE
)
{
configASSERT
(
xTimerStart
(
device
->
timer
,
0
));
// Restarts timer if still running
}
configASSERT
(
xTimerStart
(
device
->
timer
,
0
));
// Restart frame expiration timer
}
static
inline
void
_stop_frame_time
(
weigand26_t
*
device
)
{
configASSERT
(
xTimerStop
(
device
->
timer
,
0
));
// Stop frame expiration timer
}
void
weigand_int_handler
(
weigand26_t
*
device
)
...
...
@@ -144,20 +145,20 @@ void weigand_int_handler(weigand26_t * device)
Chip_GPIO_ClearInts
(
LPC_GPIO
,
device
->
port
,
0xFFFFFFFF
);
//Resolve pin
if
(
int_states
&
(
1
<<
device
->
pin_d1
))
//
0
's
if
(
int_states
&
(
1
<<
device
->
pin_d1
))
//
1
's
{
if
(
Chip_GPIO_ReadPortBit
(
LPC_GPIO
,
device
->
port
,
device
->
pin_d1
)
==
0
)
{
_
wake_timer_on_frame_start
(
device
);
_
refresh_frame_time
(
device
);
device
->
frame_buffer_ptr
--
;
device
->
frame_buffer
.
value
|=
(
1
<<
device
->
frame_buffer_ptr
);
}
}
else
if
(
int_states
&
(
1
<<
device
->
pin_d0
))
//
1
's
else
if
(
int_states
&
(
1
<<
device
->
pin_d0
))
//
0
's
{
if
(
Chip_GPIO_ReadPortBit
(
LPC_GPIO
,
device
->
port
,
device
->
pin_d0
)
==
0
)
{
_wake_timer_on_frame_start
(
device
);
_refresh_frame_time
(
device
);
device
->
frame_buffer_ptr
--
;
device
->
frame_buffer
.
value
&=
~
(
1
<<
device
->
frame_buffer_ptr
);
}
...
...
@@ -169,6 +170,8 @@ void weigand_int_handler(weigand26_t * device)
//Whole frame received
if
(
device
->
frame_buffer_ptr
==
0
)
{
_stop_frame_time
(
device
);
BaseType_t
pxHigherPriorityTaskWoken
=
pdFALSE
;
// Check if not full
...
...
cardreader/bsp/weigand/weigand.h
View file @
efb38e6b
...
...
@@ -27,7 +27,7 @@
#include "stream_buffer.h"
#define WEIGAND26_FRAME_SIZE 26
#define WEIGAND26_
FRAME_TIME_LIMIT 125 // This limits data interval to maximum of 5ms!
#define WEIGAND26_
MAX_BIT_PERIOD 20 // Should be equal to upper limit of data interval.
typedef
union
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment