summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/usbFifoUsart.h
blob: 8725d3223c340299f9c4c96b6270d88cc0b10055 (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
/**************************************************************************//**
\file   usbFifoUsart.h

\brief  The public API of usb fifo vitual COM port driver based on FTDI FT245RL.

\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:
    12.07.11 A. Khromykh - Created
*******************************************************************************/
#ifndef _USBFIFOUSART_H
#define _USBFIFOUSART_H

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

/******************************************************************************
                   Define(s) section
******************************************************************************/
#define USART_CHANNEL_USBFIFO  ((UsartChannel_t)6)

/******************************************************************************
                   Prototypes section
******************************************************************************/
/**************************************************************************//**
\brief Opens driver and registers event handlers.

\param[in]
  descriptor - pointer to HAL_UartDescriptor_t structure

\return
  Returns positive uart descriptor on success or -1 in cases: \n
    - bad uart channel; \n
    - there are not enough resources; \n
    - receiving buffer is less bulk endpoint size;
******************************************************************************/
int USBFIFO_OpenUsart(HAL_UsartDescriptor_t *descriptor);

/*************************************************************************//**
\brief Releases the driver.

\param[in]
  descriptor - pointer to HAL_UartDescriptor_t structure

\return
 -1 - bad descriptor; \n
  0 - success.
*****************************************************************************/
int USBFIFO_CloseUsart(HAL_UsartDescriptor_t *descriptor);

/**************************************************************************//**
\brief Writes a number of bytes to driver.
txCallback function will be used to notify when the transmission is finished.

\param[in]
  descriptor - pointer to HAL_UartDescriptor_t structure;

\param[in]
  buffer - pointer to the application data buffer;

\param[in]
  length - number of bytes to transfer;

\return
  -1 - bad descriptor; \n
   Number of bytes placed to the buffer - success.
******************************************************************************/
int USBFIFO_WriteUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);

/*************************************************************************//**
\brief Reads a number of bytes from driver and places them to the buffer.

\param[in]
  descriptor - pointer to HAL_UartDescriptor_t structure;

\param[in]
  buffer - pointer to the application buffer;

\param[in]
  length - number of bytes to be placed to the buffer;

\return
  -1 - bad descriptor, or bad number of bytes to read; \n
  Number of bytes placed to the buffer - success.
*****************************************************************************/
int USBFIFO_ReadUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);

/**************************************************************************//**
\brief Checks the status of tx buffer (for polling mode).

\param[in]
  descriptor - pointer to HAL_UsartDescriptor_t structure;
\return
  -1 - bad descriptor, no tx buffer; \n
   1 - tx buffer is empty; \n
   0 - tx buffer is not empty;
******************************************************************************/
int USBFIFO_IsTxEmpty(HAL_UsartDescriptor_t *descriptor);

#endif /* _USBFIFOUSART_H */