
NXP Semiconductors
UM11038
OM27642 Smart Lock KIT
UM11038
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2018. All rights reserved.
User manual
COMPANY PUBLIC
Rev. 1.1 — 11 October 2018
407611
21 of 38
the QN is ready to accept commands from PN like reconfiguring the device name
(e.g. room number is changed).
The main handlers in active state are the functions
•
pn_uart_rx_ind_handler()
It processes messages sent from the pn driver and
thus evaluates the commands received from PN.
•
pn_ble_rx_ind_handler()
It forwards response APDUs from the Bluetooth Low
Energy client to the PN
11.2 src\driver\pn_nfc.c
This driver is responsible for:
•
wake-up QN in case PN wants to communicate
•
power on PN
•
receive and evaluate data from PN, build messages from incoming data and
forward these messages to the PN TASK
•
build and send messages to the PN
When PN starts a transaction (e.g. is powered due to proximity sensor) it will trigger a
GPIO interrupt on line BLE_DETECT. The GPIO interrupt handler calls
pn_nfc_gpio_interrupt_cb()
. This callback function processes the event and sends the
message PN_NFC_ACTIVATE_REQ to the PN TASK. Before it will block additional
GPIO events to avoid sending multiple messages (
allow_wakeup=0
).
ATTENTION: To be sure that the QN OS Kernel is active, the library function
sw_wakeup_ble_hw()
must be called. Otherwise the sent message could be processed
only after a considerable delay.
The PN_TASK will then activate the UART by calling the function
pn_nfc_activate()
The original uart driver from the QN SDK is modified to work with pn_nfc.c. The define
UART0_PN_EN
activates a different receive mode in uart.c (in contrast to the original QN
SDK procedure). All characters being received via UART are forwarded via callback
function to pn_nfc.c:
static void pn_uart_rx_data(uint8_t rx)
During initial handshake phase all characters different from ‘P’ are being ignored (static
variable
ignore
). This shall filter possible spurious signals on the serial line when PN is
powered on.
pn_uart_rx_data
processes all incoming data and assembles it to messages. After
having received a full message from PN it is forwarded to the PN TASK. It is then the
responsibility of the PN TASK to take appropriate actions.
If PN TASK wants to send messages to PN it uses the function
pn_nfc_send_response(uint8_t cmd, const uint8_t *data, uint16_t len)
After the transaction is finished PN TASK it calls pn_nfc_power_off(). This will also
deactivate the UART to save power. In fact, the PN has to power off itself. The BLE_OUT
line is set to low, so it can retrigger power for the PN later on.