]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC82X/rom_i2c_8xx.h
2 * @brief LPC8xx I2C ROM API declarations and functions
5 * Copyright(C) NXP Semiconductors, 2012
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.
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
32 #ifndef __ROM_I2C_8XX_H_
33 #define __ROM_I2C_8XX_H_
39 /** @defgroup CHIP_I2CROM_8XX CHIP: LPC8xx I2C ROM API declarations and functions
40 * @ingroup CHIP_8XX_Drivers
45 * @brief LPC8xx I2C ROM driver handle structure
47 typedef void *I2C_HANDLE_T
;
49 typedef uint32_t ErrorCode_t
;
52 * @brief LPC8xx I2C ROM driver callback function
54 typedef void (*I2C_CALLBK_T
)(uint32_t err_code
, uint32_t n
);
57 * LPC8xx I2C ROM driver parameter structure
59 typedef struct I2C_PARAM
{
60 uint32_t num_bytes_send
; /*!< No. of bytes to send */
61 uint32_t num_bytes_rec
; /*!< No. of bytes to receive */
62 uint8_t *buffer_ptr_send
; /*!< Pointer to send buffer */
63 uint8_t *buffer_ptr_rec
; /*!< Pointer to receive buffer */
64 I2C_CALLBK_T func_pt
; /*!< Callback function */
65 uint8_t stop_flag
; /*!< Stop flag */
70 * LPC8xx I2C ROM driver result structure
72 typedef struct I2C_RESULT
{
73 uint32_t n_bytes_sent
; /*!< No. of bytes sent */
74 uint32_t n_bytes_recd
; /*!< No. of bytes received */
78 * LPC8xx I2C ROM driver modes enum
80 typedef enum CHIP_I2C_MODE
{
81 IDLE
, /*!< IDLE state */
82 MASTER_SEND
, /*!< Master send state */
83 MASTER_RECEIVE
, /*!< Master Receive state */
84 SLAVE_SEND
, /*!< Slave send state */
85 SLAVE_RECEIVE
/*!< Slave receive state */
89 * LPC8xx I2C ROM driver APIs structure
91 typedef struct I2CD_API
{
92 /*!< Interrupt Support Routine */
93 void (*i2c_isr_handler
)(I2C_HANDLE_T
*handle
);
95 /*!< MASTER functions */
96 ErrorCode_t (*i2c_master_transmit_poll
)(I2C_HANDLE_T
*handle
, I2C_PARAM_T
*param
, I2C_RESULT_T
*result
);
97 ErrorCode_t (*i2c_master_receive_poll
)(I2C_HANDLE_T
*handle
, I2C_PARAM_T
*param
, I2C_RESULT_T
*result
);
98 ErrorCode_t (*i2c_master_tx_rx_poll
)(I2C_HANDLE_T
*handle
, I2C_PARAM_T
*param
, I2C_RESULT_T
*result
);
99 ErrorCode_t (*i2c_master_transmit_intr
)(I2C_HANDLE_T
*handle
, I2C_PARAM_T
*param
, I2C_RESULT_T
*result
);
100 ErrorCode_t (*i2c_master_receive_intr
)(I2C_HANDLE_T
*handle
, I2C_PARAM_T
*param
, I2C_RESULT_T
*result
);
101 ErrorCode_t (*i2c_master_tx_rx_intr
)(I2C_HANDLE_T
*handle
, I2C_PARAM_T
*param
, I2C_RESULT_T
*result
);
103 /*!< SLAVE functions */
104 ErrorCode_t (*i2c_slave_receive_poll
)(I2C_HANDLE_T
*handle
, I2C_PARAM_T
*param
, I2C_RESULT_T
*result
);
105 ErrorCode_t (*i2c_slave_transmit_poll
)(I2C_HANDLE_T
*handle
, I2C_PARAM_T
*param
, I2C_RESULT_T
*result
);
106 ErrorCode_t (*i2c_slave_receive_intr
)(I2C_HANDLE_T
*handle
, I2C_PARAM_T
*param
, I2C_RESULT_T
*result
);
107 ErrorCode_t (*i2c_slave_transmit_intr
)(I2C_HANDLE_T
*handle
, I2C_PARAM_T
*param
, I2C_RESULT_T
*result
);
108 ErrorCode_t (*i2c_set_slave_addr
)(I2C_HANDLE_T
*handle
, uint32_t slave_addr_0_3
, uint32_t slave_mask_0_3
);
110 /*!< OTHER support functions */
111 uint32_t (*i2c_get_mem_size
)(void);
112 I2C_HANDLE_T
* (*i2c_setup
)( uint32_t i2c_base_addr
, uint32_t * start_of_ram
);
113 ErrorCode_t (*i2c_set_bitrate
)(I2C_HANDLE_T
*handle
, uint32_t p_clk_in_hz
, uint32_t bitrate_in_bps
);
114 uint32_t (*i2c_get_firmware_version
)(void);
115 CHIP_I2C_MODE_T (*i2c_get_status
)(I2C_HANDLE_T
*handle
);
116 ErrorCode_t (*i2c_set_timeout
)(I2C_HANDLE_T
*handle
, uint32_t timeout
);
127 #endif /* __ROM_I2C_8XX_H_ */