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 *  This file contains the call-in functions for NFC HAL HCI
22 *
23 ******************************************************************************/
24#include <string.h>
25#include "gki.h"
26#include "nfc_hal_api.h"
27#include "nfc_hal_int.h"
28
29#if (NFC_HAL_HCI_INCLUDED == TRUE)
30#include "nfc_hal_nv_ci.h"
31#include "nfc_hal_nv_co.h"
32
33/*******************************************************************************
34**
35** Function         nfc_hal_nv_ci_read
36**
37** Description      call-in function for non volatile memory read acess
38**
39** Returns          none
40**
41*******************************************************************************/
42void nfc_hal_nv_ci_read(uint16_t num_bytes_read, tNFC_HAL_NV_CO_STATUS status,
43                        uint8_t block) {
44  tNFC_HAL_HCI_EVENT_DATA* p_msg;
45
46  /* Send message to NCIT task */
47  p_msg = (tNFC_HAL_HCI_EVENT_DATA*)GKI_getbuf(sizeof(tNFC_HAL_HCI_EVENT_DATA));
48  if (p_msg != NULL) {
49    p_msg->nv_read.hdr.event = NFC_HAL_HCI_RSP_NV_READ_EVT;
50    p_msg->hdr.offset = 0;
51    p_msg->hdr.len = sizeof(tNFC_HAL_HCI_RSP_NV_READ_EVT);
52    p_msg->hdr.layer_specific = 0;
53
54    if ((status == NFC_HAL_NV_CO_OK) && (num_bytes_read != 0))
55      p_msg->nv_read.status = HAL_NFC_STATUS_OK;
56    else
57      p_msg->nv_read.status = HAL_NFC_STATUS_FAILED;
58
59    p_msg->nv_read.size = num_bytes_read;
60    p_msg->nv_read.block = block;
61
62    GKI_send_msg(NFC_HAL_TASK, NFC_HAL_TASK_MBOX, p_msg);
63  }
64}
65
66/*******************************************************************************
67**
68** Function         nfc_hal_nv_ci_write
69**
70** Description      call-in function for non volatile memory write acess
71**
72** Returns          none
73**
74*******************************************************************************/
75void nfc_hal_nv_ci_write(tNFC_HAL_NV_CO_STATUS status) {
76  tNFC_HAL_HCI_EVENT_DATA* p_msg;
77
78  p_msg = (tNFC_HAL_HCI_EVENT_DATA*)GKI_getbuf(sizeof(tNFC_HAL_HCI_EVENT_DATA));
79  if (p_msg != NULL) {
80    p_msg->nv_write.hdr.event = NFC_HAL_HCI_RSP_NV_WRITE_EVT;
81    p_msg->nv_write.hdr.offset = 0;
82    p_msg->nv_write.hdr.len = sizeof(tNFC_HAL_HCI_RSP_NV_READ_EVT);
83    p_msg->nv_write.hdr.layer_specific = 0;
84    p_msg->nv_write.status = HAL_NFC_STATUS_OK;
85
86    GKI_send_msg(NFC_HAL_TASK, NFC_HAL_TASK_MBOX, p_msg);
87  }
88}
89
90#endif
91