RTEMS 6.1-rc4
Loading...
Searching...
No Matches
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
51extern "C" {
52#endif
53
54/*----------------------------------------------------------------------------
55 * Types
56 *----------------------------------------------------------------------------*/
57
58/*----------------------------------------------------------------------------
59* Type
60*----------------------------------------------------------------------------*/
62typedef struct _Async {
64 volatile uint32_t status;
66 void *callback;
68 uint8_t pStorage[9];
69} Async;
70
72typedef struct _Twid {
77} Twid;
78
80typedef struct {
81 uint8_t Twi_id;
86} TwihsDma;
87
88/*----------------------------------------------------------------------------
89 * Export functions
90 *----------------------------------------------------------------------------*/
91extern void TWID_Initialize(Twid *pTwid, Twihs *pTwi);
92extern void TWID_DmaInitialize(TwihsDma *pTwidma, Twihs *pTwi,
93 uint8_t bPolling);
94
95extern void TWID_Handler(Twid *pTwid);
96
97extern uint32_t ASYNC_IsFinished(Async *pAsync);
98
99extern 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
108extern 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
117extern 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
126extern 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
TWI driver structure. Holds the internal state of the driver.
Definition: twid.h:80
Twid * pTwid
Definition: twid.h:83
sXdmad * pTwiDma
Definition: twid.h:85
Twihs hardware registers.
Definition: component_twihs.h:41
Asynchronous transfer descriptor.
Definition: twid.h:62
void * callback
Definition: twid.h:66
volatile uint32_t status
Definition: twid.h:64
uint8_t pStorage[9]
Definition: twid.h:68
TWI driver structure. Holds the internal state of the driver.
Definition: twid.h:72
Async * pTransfer
Definition: twid.h:76
Twihs * pTwi
Definition: twid.h:74
Definition: xdmad.h:127