summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/mem.h
blob: 0197f13abda5083c0734994e0fd74cf99b7b6f0e (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
/****************************************************************************//**
  \file mem.h

  \brief Declaration of memory commands.

  \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:
    29/08/11 N. Fomin - Created
*******************************************************************************/
#ifndef _MEM_H
#define _MEM_H

/******************************************************************************
                   Includes section
******************************************************************************/
#include <types.h>
#include <hsmci.h>

/******************************************************************************
                   Define(s) section
******************************************************************************/
// block length
#define STANDARD_BLOCK_LENGTH 512

/******************************************************************************
                   Types section
******************************************************************************/
typedef enum
{
  memSuccess,
  hsmciError,
  voltageError,
  commandError,
  initTimeoutError,
  stateError,
  hsmciReadError,
  hsmciWriteError,
  setMaxFreqError
} MemStatus_t;

typedef struct
{
  uint32_t lastLogicalBlock;
  uint32_t logicalBlockLength;
} MemCapacityInfo_t;

/******************************************************************************
                   Prototypes section
******************************************************************************/
/**************************************************************************//**
\brief Writes one data block to memory at "address".
\param[in]
  descriptor - pointer to hsmci descriptor;
  address - address of block to write.
\return
  status of write procedure.
******************************************************************************/
MemStatus_t memWriteBlock(HAL_HsmciDescriptor_t *descriptor, uint32_t address, void (*callback)(MemStatus_t));

/**************************************************************************//**
\brief Reads one data block from memory at "address".
\param[in]
  descriptor - pointer to hsmci descriptor;
  address - address of block to read.
\return
  status of read procedure.
******************************************************************************/
MemStatus_t memReadBlock(HAL_HsmciDescriptor_t *descriptor, uint32_t address, void (*callback)(MemStatus_t));

/**************************************************************************//**
\brief Performs memory initialization.
\param[in]
  commandDescr - pointer to hsmci command descriptor.
\return
  status of initialization procedure.
******************************************************************************/
MemStatus_t memInit(HAL_HsmciDescriptor_t *commandDescr);

/**************************************************************************//**
\brief Reads memory capacity.
\param[in]
  descriptor - pointer to hsmci descriptor.
\param[out]
  capInfo - pointer to memory capacity structure.
\return
  status of read capacity procedure.
******************************************************************************/
MemStatus_t memGetCapacityInfo(HAL_HsmciDescriptor_t *descriptor, MemCapacityInfo_t *capInfo);

/**************************************************************************//**
\brief Checks if memory is ready for any data transfer.
\return
  false - memory is busy;
  true - memory is ready.
******************************************************************************/
bool memIsBusy(void);

#endif /* _MEM_H */
// eof mem.h