summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/HAL/include/hsmci.h
blob: 6e9dd2ea216668962343df65c5dfbf23c2ec76d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/****************************************************************************//**
  \file hsmci.h

  \brief The header file describes the HSMCI interface.

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
  History:
    24/08/11 N. Fomin - Created
 ******************************************************************************/
#ifndef _HSMCI_H
#define _HSMCI_H

/******************************************************************************
                   Includes section
******************************************************************************/
#include <halHsmci.h>

/******************************************************************************
                   Types section
******************************************************************************/
/** \brief Hsmci descriptor */
typedef struct
{
  /** \brief HSMCI bus clock rate. */
  HsmciClockRate_t clockRate;
  /** \brief HSMCI bus width. */
  HsmciBusWidth_t  busWidth;
  /** \brief HSMCI high speed mode. */
  bool  highSpeedMode;
  /** \brief HSMCI command desciptor.
  Take a look into halHsmci.h platform specific file fore more details. */
  HAL_HsmciCommandDescriptor_t *commandDescriptor;
  /** \brief HSMCI data transfer descriptor.
  Take a look into halHsmci.h platform specific file fore more details. */
  HAL_HsmciDataTransferDescriptor_t *dataTransferDescriptor;
  /** \brief Address of the function to notify the upper layer when
             a transfer was completed. */
  void (*callback)(void);
} HAL_HsmciDescriptor_t;

/**************************************************************************//**
\brief Open the HSMCI interface and configure pins.
\param[in]
    descriptor - pointer to the hsmci descriptor.
\return
   -1 - there are no free resources;
    0 - HSMCI is ready.
******************************************************************************/
int HAL_OpenHsmci(HAL_HsmciDescriptor_t *descriptor);

/**************************************************************************//**
\brief Close the HSMCI interface.
\param[in]
  descriptor - pointer to the hsmci descriptor.
\return
  Returns 0 on success or -1 if interface was not opened.
******************************************************************************/
int HAL_CloseHsmci(HAL_HsmciDescriptor_t *descriptor);

/**************************************************************************//**
\brief Sends HSMCI command.
 Callback function will be used to notify about the finishing transmitting.
\param[in]
  descriptor - pointer to hsmci descriptor.
\return
  -1 - hsmci interface was not opened, there is unsent data,
       or command response buffer is zero;
   0 - on succes.
******************************************************************************/
int HAL_WriteHsmciCommand(HAL_HsmciDescriptor_t *descriptor);

/**************************************************************************//**
\brief Writes data to the HSMCI.
 Callback function will be used to notify about the finishing transmitting.
\param[in]
  descriptor - pointer to hsmci descriptor.
\return
  -1 - hsmci interface was not opened, there is unsent data, pointer to the data,
       the length are zero or command response buffer is zero;
   0 - on success.
******************************************************************************/
int HAL_WriteHsmci(HAL_HsmciDescriptor_t *descriptor);

/**************************************************************************//**
\brief Reads data from the HSMCI.
 Callback function will be used to notify about the finishing transmitting.
\param[in]
  descriptor - pointer to hsmci descriptor.
\return
  -1 - hsmci module was not opened, there is unsent data, pointer to the data,
       the interface are zero or command response buffer is zero;
   0 - on success.
******************************************************************************/
int HAL_ReadHsmci(HAL_HsmciDescriptor_t *descriptor);

/**************************************************************************//**
\brief Sets HSMCI bus speed.
\param[in]
  descriptor - pointer to hsmci descriptor.
\return
  -1 - hsmci interface was not opened or there is unsent data;
   0 - on success.
******************************************************************************/
int HAL_SetHsmciSpeed(HAL_HsmciDescriptor_t *descriptor);

/**************************************************************************//**
\brief Sets HSMCI bus width.
\param[in]
  descriptor - pointer to hsmci descriptor.
\return
  -1 - hsmci interface was not opened or there is unsent data;
   0 - on success.
******************************************************************************/
int HAL_SetHsmciBusWidth(HAL_HsmciDescriptor_t *descriptor);

/**************************************************************************//**
\brief Sets HSMCI high speed mode.
\param[in]
  descriptor - pointer to hsmci descriptor.
\return
  -1 - hsmci interface was not opened or there is unsent data;
   0 - on success.
******************************************************************************/
int HAL_SetHsmciHighSpeedMode(HAL_HsmciDescriptor_t *descriptor);

/**************************************************************************//**
\brief Checks if HSMCI interface is free and ready.
\return
   false - hsmci interface was not opened or there is unsent data;
   true - hsmci interface is ready.
******************************************************************************/
bool HAL_HsmciCheckReady(void);

#endif /* _HSMCI_H */
// eof hsmci.h