1/******************************************************************************
2 *
3 *  Copyright (C) 2010-2014 Broadcom Corporation
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19
20/******************************************************************************
21 *
22 *  This file contains the call-in functions for NFC HAL HCI
23 *
24 ******************************************************************************/
25#include <string.h>
26#include "gki.h"
27#include "nfc_hal_api.h"
28#include "nfc_hal_int.h"
29
30#if (defined(NFC_HAL_HCI_INCLUDED) && (NFC_HAL_HCI_INCLUDED == TRUE))
31#include "nfc_hal_nv_ci.h"
32#include "nfc_hal_nv_co.h"
33
34/*******************************************************************************
35**
36** Function         nfc_hal_nv_ci_read
37**
38** Description      call-in function for non volatile memory read acess
39**
40** Returns          none
41**
42*******************************************************************************/
43void nfc_hal_nv_ci_read (UINT16 num_bytes_read, tNFC_HAL_NV_CO_STATUS status, UINT8 block)
44{
45    tNFC_HAL_HCI_EVENT_DATA *p_msg;
46
47    /* Send message to NCIT task */
48    if ((p_msg = (tNFC_HAL_HCI_EVENT_DATA *) GKI_getbuf (sizeof (tNFC_HAL_HCI_EVENT_DATA))) != NULL)
49    {
50        p_msg->nv_read.hdr.event  = NFC_HAL_HCI_RSP_NV_READ_EVT;
51        p_msg->hdr.offset         = 0;
52        p_msg->hdr.len            = sizeof (tNFC_HAL_HCI_RSP_NV_READ_EVT);
53        p_msg->hdr.layer_specific = 0;
54
55        if (  (status == NFC_HAL_NV_CO_OK)
56            &&(num_bytes_read != 0) )
57            p_msg->nv_read.status = HAL_NFC_STATUS_OK;
58        else
59            p_msg->nv_read.status = HAL_NFC_STATUS_FAILED;
60
61        p_msg->nv_read.size  = num_bytes_read;
62        p_msg->nv_read.block = block;
63
64        GKI_send_msg (NFC_HAL_TASK, NFC_HAL_TASK_MBOX, p_msg);
65    }
66}
67
68/*******************************************************************************
69**
70** Function         nfc_hal_nv_ci_write
71**
72** Description      call-in function for non volatile memory write acess
73**
74** Returns          none
75**
76*******************************************************************************/
77void nfc_hal_nv_ci_write (tNFC_HAL_NV_CO_STATUS status)
78{
79    tNFC_HAL_HCI_EVENT_DATA *p_msg;
80
81    if ((p_msg = (tNFC_HAL_HCI_EVENT_DATA *) GKI_getbuf (sizeof (tNFC_HAL_HCI_EVENT_DATA))) != NULL)
82    {
83        p_msg->nv_write.hdr.event          = NFC_HAL_HCI_RSP_NV_WRITE_EVT;
84        p_msg->nv_write.hdr.offset         = 0;
85        p_msg->nv_write.hdr.len            = sizeof (tNFC_HAL_HCI_RSP_NV_READ_EVT);
86        p_msg->nv_write.hdr.layer_specific = 0;
87        p_msg->nv_write.status             = HAL_NFC_STATUS_OK;
88
89        GKI_send_msg (NFC_HAL_TASK, NFC_HAL_TASK_MBOX, p_msg);
90    }
91}
92
93#endif
94