| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
i2cd_8xx.h
Go to the documentation of this file.
1 /*
2 * @brief LPC8xx I2C ROM API declarations and functions
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * All rights reserved.
7 *
8 * @par
9 * Software that is described herein is for illustrative purposes only
10 * which provides customers with programming information regarding the
11 * LPC products. This software is supplied "AS IS" without any warranties of
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
13 * all warranties, express or implied, including all implied warranties of
14 * merchantability, fitness for a particular purpose and non-infringement of
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
16 * or liability for the use of the software, conveys no license or rights under any
17 * patent, copyright, mask work right, or any other intellectual property rights in
18 * or to any products. NXP Semiconductors reserves the right to make changes
19 * in the software without notification. NXP Semiconductors also makes no
20 * representation or warranty that such application will be suitable for the
21 * specified use without further testing or modification.
22 *
23 * @par
24 * Permission to use, copy, modify, and distribute this software and its
25 * documentation is hereby granted, under NXP Semiconductors' and its
26 * licensor's relevant copyrights in the software, without fee, provided that it
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
28 * copyright, permission, and disclaimer notice must appear in all copies of
29 * this code.
30 */
31
32 #ifndef __I2CD_8XX_H_
33 #define __I2CD_8XX_H_
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
44 #define ERR_I2C_NAK (0x00060001UL)
45 #define ERR_I2C_BUFFER_OVERFLOW (0x00060002UL)
46 #define ERR_I2C_BYTE_COUNT_ERR (0x00060003UL)
47 #define ERR_I2C_LOSS_OF_ARBRITRATION (0x00060004UL)
48 #define ERR_I2C_SLAVE_NOT_ADDRESSED (0x00060005UL)
49 #define ERR_I2C_LOSS_OF_ARBRITRATION_NAK_BIT (0x00060006UL)
50 #define ERR_I2C_GENERAL_FAILURE (0x00060007UL)
51 #define ERR_I2C_REGS_SET_TO_DEFAULT (0x00060008UL)
52 #define ERR_I2C_TIMEOUT (0x00060009UL)
53
54 typedef void *I2C_HANDLE_T;
55 typedef void (*I2C_CALLBK_T)(uint32_t err_code, uint32_t n);
56
60 typedef struct I2C_PARAM {
61 uint32_t num_bytes_send;
62 uint32_t num_bytes_recv;
63 uint8_t *buffer_ptr_send;
64 uint8_t *buffer_ptr_recv;
65 I2C_CALLBK_T func_pt;
66 uint8_t stop_flag;
67 uint8_t unused[3];
68 } I2C_PARAM_T;
69
73 typedef struct I2C_RESULT {
74 uint32_t n_bytes_sent;
75 uint32_t n_bytes_recd;
76 } I2C_RESULT_T;
77
81 typedef enum CHIP_I2C_MODE {
82 IDLE,
83 MASTER_SEND,
84 MASTER_RECEIVE,
85 SLAVE_SEND,
86 SLAVE_RECEIVE
87 } CHIP_I2C_MODE_T;
88
92 typedef struct I2CD_API {
94 void (*i2c_isr_handler)(I2C_HANDLE_T *handle);
95
97 int32_t (*i2c_master_transmit_poll)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
98 int32_t (*i2c_master_receive_poll)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
99 int32_t (*i2c_master_tx_rx_poll)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
100 int32_t (*i2c_master_transmit_intr)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
101 int32_t (*i2c_master_receive_intr)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
102 int32_t (*i2c_master_tx_rx_intr)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
103
105 int32_t (*i2c_slave_receive_poll)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
106 int32_t (*i2c_slave_transmit_poll)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
107 int32_t (*i2c_slave_receive_intr)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
108 int32_t (*i2c_slave_transmit_intr)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
109 int32_t (*i2c_set_slave_addr)(I2C_HANDLE_T *handle, uint32_t slave_addr_0_3, uint32_t slave_mask_0);
110
112 uint32_t (*i2c_get_mem_size)(void);
113 I2C_HANDLE_T * (*i2c_setup)( uint32_t i2c_base_addr, uint32_t * start_of_ram);
114 int32_t (*i2c_set_bitrate)(I2C_HANDLE_T *handle, uint32_t P_clk_in_hz, uint32_t bitrate_in_bps);
115 uint32_t (*i2c_get_firmware_version)(void);
116 CHIP_I2C_MODE_T (*i2c_get_status)(I2C_HANDLE_T *handle);
117 int32_t (*i2c_set_timeout)(I2C_HANDLE_T *handle, uint32_t timeout);
118 } I2CD_API_T;
119
124 #ifdef __cplusplus
125 }
126 #endif
127
128 #endif /* __I2CD_8XX_H_ */