CardID Task

Card ID reading task.

This task uses on-board RFID reader module to try and read IDs of all cards present in the RF field. The underlying library is able to read IDs of all cards at once (if those cards behave properly).

The master task must explicitly request that this task starts polling for cards. When this task is polling for cards it may read one or more card IDs in one poll cycle. When that happens, this task will invoke a callback to the Master Task and will stop polling for cards until the Master Task reenables polling.

When this task is not polling for cards the RFID reader module is in low-power mode.

Functions

void dlTaskCardIDInit(uint8_t task_id, dl_task_cardid_callbacks *callbacks)

Task initializer.

This function initalizes internal data structure of the task and sets up callbacks to the Master Task

Parameters
  • task_id: Our identificator the Master Task has chosen
  • callbacks: Structure of function pointers to callbacks this task should use

void dlTaskCardIDStart(void)

Task starter.

This function starts the task thread.

void dlTaskCardIDStop(void)

Task stopper.

This function stops the task thread.

void dlTaskCardIDStartPolling(void)

Requests that this task starts polling for cards.

Note
Thread safety: This function can be called from any thread when the ChibiOS is in Normal state.

void dlTaskCardIDStopPolling(void)

Requests that this task stops polling for cards.

After this function is invoked, the poll that is already in progress is finished, however result of that poll will be discarded. It is guaranteed that after this function returns, callback card_detected won’t be invoked until dlTaskCardIDStartPolling is called. If this function is called during the card_detected callback invocation it will block until the callback returns.

Note
Thread safety: This function can be called from any thread when the ChibiOS is in Normal state.

struct dl_task_cardid_callbacks
#include <cardid-task.h>

A structure of Master Task callbacks.

Note
These callbacks must be thread safe

Public Members

void (*heartbeat)(uint8_t task_id)

A heartbeat callback.

A Heartbeat callback of the Master Task. See firmware documentation, section “Reader Firmware Architecture”, subsection “Watchdog”

Parameters
  • task_id: ID of this task, assigned to us by the Master Task

void (*card_detected)(dl_picc_uid *cards, uint8_t len)

Card Detected callback.

This callbacks informs the Master Task that one or more cards were detected in the RF field and sends their IDs. After this callback is invoked the task will stop polling for cards and won’t change contents of parameter cards. However, when the Master Task requests that this task should start polling for cards again, data pointed to by cards may change at any moment!

Parameters
  • cards: An array of IDs of detected cards
  • len: Length of the array of detected cards

void (*reader_error)(void)

RFID Reader Module error.

The reader module has experienced an unrecoverable error and can’t function. The task will automatically stop polling for cards.