RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
bsps
arm
atsam
include
libchip
include
twid.h
1
/* ---------------------------------------------------------------------------- */
2
/* Atmel Microcontroller Software Support */
3
/* SAM Software Package License */
4
/* ---------------------------------------------------------------------------- */
5
/* Copyright (c) 2015, Atmel Corporation */
6
/* */
7
/* All rights reserved. */
8
/* */
9
/* Redistribution and use in source and binary forms, with or without */
10
/* modification, are permitted provided that the following condition is met: */
11
/* */
12
/* - Redistributions of source code must retain the above copyright notice, */
13
/* this list of conditions and the disclaimer below. */
14
/* */
15
/* Atmel's name may not be used to endorse or promote products derived from */
16
/* this software without specific prior written permission. */
17
/* */
18
/* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
19
/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
21
/* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */
22
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23
/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
24
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
25
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
26
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27
/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
28
/* ---------------------------------------------------------------------------- */
29
30
#ifndef _TWID_
31
#define _TWID_
32
33
/*----------------------------------------------------------------------------
34
* Headers
35
*----------------------------------------------------------------------------*/
36
37
#include "chip.h"
38
39
#include <stdint.h>
40
41
/*----------------------------------------------------------------------------
42
* Definition
43
*----------------------------------------------------------------------------*/
44
46
#define TWID_ERROR_BUSY 1
47
49
#define ASYNC_STATUS_PENDING 0xFF
50
#ifdef __cplusplus
51
extern
"C"
{
52
#endif
53
54
/*----------------------------------------------------------------------------
55
* Types
56
*----------------------------------------------------------------------------*/
57
58
/*----------------------------------------------------------------------------
59
* Type
60
*----------------------------------------------------------------------------*/
62
typedef
struct
_Async
{
64
volatile
uint32_t
status
;
66
void
*
callback
;
68
uint8_t
pStorage
[9];
69
} Async;
70
72
typedef
struct
_Twid
{
74
Twihs
*
pTwi
;
76
Async *
pTransfer
;
77
} Twid;
78
80
typedef
struct
{
81
uint8_t Twi_id;
83
Twid *
pTwid
;
85
sXdmad
*
pTwiDma
;
86
}
TwihsDma
;
87
88
/*----------------------------------------------------------------------------
89
* Export functions
90
*----------------------------------------------------------------------------*/
91
extern
void
TWID_Initialize(Twid *pTwid,
Twihs
*pTwi);
92
extern
void
TWID_DmaInitialize(
TwihsDma
*pTwidma,
Twihs
*pTwi,
93
uint8_t bPolling);
94
95
extern
void
TWID_Handler(Twid *pTwid);
96
97
extern
uint32_t ASYNC_IsFinished(Async *pAsync);
98
99
extern
uint8_t TWID_Read(
100
Twid *pTwid,
101
uint8_t address,
102
uint32_t iaddress,
103
uint8_t isize,
104
uint8_t *pData,
105
uint32_t num,
106
Async *pAsync);
107
108
extern
uint8_t TWID_Write(
109
Twid *pTwid,
110
uint8_t address,
111
uint32_t iaddress,
112
uint8_t isize,
113
uint8_t *pData,
114
uint32_t num,
115
Async *pAsync);
116
117
extern
uint8_t TWID_DmaRead(
118
TwihsDma
*pTwiXdma,
119
uint8_t address,
120
uint32_t iaddress,
121
uint8_t isize,
122
uint8_t *pData,
123
uint32_t num,
124
Async *pAsync);
125
126
extern
uint8_t TWID_DmaWrite(
127
TwihsDma
*pTwiXdma,
128
uint8_t address,
129
uint32_t iaddress,
130
uint8_t isize,
131
uint8_t *pData,
132
uint32_t num,
133
Async *pAsync);
134
135
#ifdef __cplusplus
136
}
137
#endif
138
139
#endif
//#ifndef TWID_H
140
sXdmad
struct _Xdmad sXdmad
TwihsDma
TWI driver structure. Holds the internal state of the driver.
Definition
twid.h:80
TwihsDma::pTwid
Twid * pTwid
Definition
twid.h:83
TwihsDma::pTwiDma
sXdmad * pTwiDma
Definition
twid.h:85
Twihs
Twihs hardware registers.
Definition
component_twihs.h:41
_Async
Asynchronous transfer descriptor.
Definition
twid.h:62
_Async::callback
void * callback
Definition
twid.h:66
_Async::status
volatile uint32_t status
Definition
twid.h:64
_Async::pStorage
uint8_t pStorage[9]
Definition
twid.h:68
_Twid
TWI driver structure. Holds the internal state of the driver.
Definition
twid.h:72
_Twid::pTransfer
Async * pTransfer
Definition
twid.h:76
_Twid::pTwi
Twihs * pTwi
Definition
twid.h:74
Generated by
1.18.0