1 /**
2  *
3  * \file
4  *
5  * \brief This module contains NMC1000 bus APIs implementation.
6  *
7  * Copyright (c) 2016-2017 Atmel Corporation. All rights reserved.
8  *
9  * \asf_license_start
10  *
11  * \page License
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions are met:
15  *
16  * 1. Redistributions of source code must retain the above copyright notice,
17  *    this list of conditions and the following disclaimer.
18  *
19  * 2. Redistributions in binary form must reproduce the above copyright notice,
20  *    this list of conditions and the following disclaimer in the documentation
21  *    and/or other materials provided with the distribution.
22  *
23  * 3. The name of Atmel may not be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
27  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
29  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
30  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  *
38  * \asf_license_stop
39  *
40  */
41 
42 #ifndef _NMBUS_H_
43 #define _NMBUS_H_
44 
45 #include "common/include/nm_common.h"
46 #include "bus_wrapper/include/nm_bus_wrapper.h"
47 
48 
49 
50 #ifdef __cplusplus
51 extern "C"{
52 #endif
53 /**
54 *	@fn		nm_bus_iface_init
55 *	@brief	Initialize bus interface
56 *	@return	M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
57 */
58 sint8 nm_bus_iface_init(void *);
59 
60 
61 /**
62 *	@fn		nm_bus_iface_deinit
63 *	@brief	Deinitialize bus interface
64 *	@return	M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
65 */
66 sint8 nm_bus_iface_deinit(void);
67 
68 /**
69 *	@fn		nm_bus_reset
70 *	@brief	reset bus interface
71 *	@return	M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
72 *	@version	1.0
73 */
74 sint8 nm_bus_reset(void);
75 
76 /**
77 *	@fn		nm_bus_iface_reconfigure
78 *	@brief	reconfigure bus interface
79 *	@return	M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
80 */
81 sint8 nm_bus_iface_reconfigure(void *ptr);
82 
83 /**
84 *	@fn		nm_read_reg
85 *	@brief	Read register
86 *	@param [in]	u32Addr
87 *				Register address
88 *	@return	Register value
89 */
90 uint32 nm_read_reg(uint32 u32Addr);
91 
92 /**
93 *	@fn		nm_read_reg_with_ret
94 *	@brief	Read register with error code return
95 *	@param [in]	u32Addr
96 *				Register address
97 *	@param [out]	pu32RetVal
98 *				Pointer to u32 variable used to return the read value
99 *	@return	ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
100 */
101 sint8 nm_read_reg_with_ret(uint32 u32Addr, uint32* pu32RetVal);
102 
103 /**
104 *	@fn		nm_write_reg
105 *	@brief	write register
106 *	@param [in]	u32Addr
107 *				Register address
108 *	@param [in]	u32Val
109 *				Value to be written to the register
110 *	@return	ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
111 */
112 sint8 nm_write_reg(uint32 u32Addr, uint32 u32Val);
113 
114 /**
115 *	@fn		nm_read_block
116 *	@brief	Read block of data
117 *	@param [in]	u32Addr
118 *				Start address
119 *	@param [out]	puBuf
120 *				Pointer to a buffer used to return the read data
121 *	@param [in]	u32Sz
122 *				Number of bytes to read. The buffer size must be >= u32Sz
123 *	@return	ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
124 */
125 sint8 nm_read_block(uint32 u32Addr, uint8 *puBuf, uint32 u32Sz);
126 
127 /**
128 *	@fn		nm_write_block
129 *	@brief	Write block of data
130 *	@param [in]	u32Addr
131 *				Start address
132 *	@param [in]	puBuf
133 *				Pointer to the buffer holding the data to be written
134 *	@param [in]	u32Sz
135 *				Number of bytes to write. The buffer size must be >= u32Sz
136 *	@return	ZERO in case of success and M2M_ERR_BUS_FAIL in case of failure
137 */
138 sint8 nm_write_block(uint32 u32Addr, uint8 *puBuf, uint32 u32Sz);
139 
140 
141 
142 
143 #ifdef __cplusplus
144 }
145 #endif
146 
147 #endif /* _NMBUS_H_ */
148