mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
bogdanm
Date:
Thu Oct 01 15:25:22 2015 +0300
Revision:
0:9b334a45a8ff
Child:
144:ef7eb2e8f9f7
Initial commit on mbed-dev

Replaces mbed-src (now inactive)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:9b334a45a8ff 1 /*
bogdanm 0:9b334a45a8ff 2 * @brief LPC8xx I2C ROM API declarations and functions
bogdanm 0:9b334a45a8ff 3 *
bogdanm 0:9b334a45a8ff 4 * @note
bogdanm 0:9b334a45a8ff 5 * Copyright(C) NXP Semiconductors, 2012
bogdanm 0:9b334a45a8ff 6 * All rights reserved.
bogdanm 0:9b334a45a8ff 7 *
bogdanm 0:9b334a45a8ff 8 * @par
bogdanm 0:9b334a45a8ff 9 * Software that is described herein is for illustrative purposes only
bogdanm 0:9b334a45a8ff 10 * which provides customers with programming information regarding the
bogdanm 0:9b334a45a8ff 11 * LPC products. This software is supplied "AS IS" without any warranties of
bogdanm 0:9b334a45a8ff 12 * any kind, and NXP Semiconductors and its licensor disclaim any and
bogdanm 0:9b334a45a8ff 13 * all warranties, express or implied, including all implied warranties of
bogdanm 0:9b334a45a8ff 14 * merchantability, fitness for a particular purpose and non-infringement of
bogdanm 0:9b334a45a8ff 15 * intellectual property rights. NXP Semiconductors assumes no responsibility
bogdanm 0:9b334a45a8ff 16 * or liability for the use of the software, conveys no license or rights under any
bogdanm 0:9b334a45a8ff 17 * patent, copyright, mask work right, or any other intellectual property rights in
bogdanm 0:9b334a45a8ff 18 * or to any products. NXP Semiconductors reserves the right to make changes
bogdanm 0:9b334a45a8ff 19 * in the software without notification. NXP Semiconductors also makes no
bogdanm 0:9b334a45a8ff 20 * representation or warranty that such application will be suitable for the
bogdanm 0:9b334a45a8ff 21 * specified use without further testing or modification.
bogdanm 0:9b334a45a8ff 22 *
bogdanm 0:9b334a45a8ff 23 * @par
bogdanm 0:9b334a45a8ff 24 * Permission to use, copy, modify, and distribute this software and its
bogdanm 0:9b334a45a8ff 25 * documentation is hereby granted, under NXP Semiconductors' and its
bogdanm 0:9b334a45a8ff 26 * licensor's relevant copyrights in the software, without fee, provided that it
bogdanm 0:9b334a45a8ff 27 * is used in conjunction with NXP Semiconductors microcontrollers. This
bogdanm 0:9b334a45a8ff 28 * copyright, permission, and disclaimer notice must appear in all copies of
bogdanm 0:9b334a45a8ff 29 * this code.
bogdanm 0:9b334a45a8ff 30 */
bogdanm 0:9b334a45a8ff 31
bogdanm 0:9b334a45a8ff 32 #ifndef __ROM_I2C_8XX_H_
bogdanm 0:9b334a45a8ff 33 #define __ROM_I2C_8XX_H_
bogdanm 0:9b334a45a8ff 34
bogdanm 0:9b334a45a8ff 35 #ifdef __cplusplus
bogdanm 0:9b334a45a8ff 36 extern "C" {
bogdanm 0:9b334a45a8ff 37 #endif
bogdanm 0:9b334a45a8ff 38
bogdanm 0:9b334a45a8ff 39 /** @defgroup CHIP_I2CROM_8XX CHIP: LPC8xx I2C ROM API declarations and functions
bogdanm 0:9b334a45a8ff 40 * @ingroup CHIP_8XX_Drivers
bogdanm 0:9b334a45a8ff 41 * @{
bogdanm 0:9b334a45a8ff 42 */
bogdanm 0:9b334a45a8ff 43
bogdanm 0:9b334a45a8ff 44 /**
bogdanm 0:9b334a45a8ff 45 * @brief LPC8xx I2C ROM driver handle structure
bogdanm 0:9b334a45a8ff 46 */
bogdanm 0:9b334a45a8ff 47 typedef void *I2C_HANDLE_T;
bogdanm 0:9b334a45a8ff 48
bogdanm 0:9b334a45a8ff 49 typedef uint32_t ErrorCode_t;
bogdanm 0:9b334a45a8ff 50
bogdanm 0:9b334a45a8ff 51 /**
bogdanm 0:9b334a45a8ff 52 * @brief LPC8xx I2C ROM driver callback function
bogdanm 0:9b334a45a8ff 53 */
bogdanm 0:9b334a45a8ff 54 typedef void (*I2C_CALLBK_T)(uint32_t err_code, uint32_t n);
bogdanm 0:9b334a45a8ff 55
bogdanm 0:9b334a45a8ff 56 /**
bogdanm 0:9b334a45a8ff 57 * LPC8xx I2C ROM driver parameter structure
bogdanm 0:9b334a45a8ff 58 */
bogdanm 0:9b334a45a8ff 59 typedef struct I2C_PARAM {
bogdanm 0:9b334a45a8ff 60 uint32_t num_bytes_send; /*!< No. of bytes to send */
bogdanm 0:9b334a45a8ff 61 uint32_t num_bytes_rec; /*!< No. of bytes to receive */
bogdanm 0:9b334a45a8ff 62 uint8_t *buffer_ptr_send; /*!< Pointer to send buffer */
bogdanm 0:9b334a45a8ff 63 uint8_t *buffer_ptr_rec; /*!< Pointer to receive buffer */
bogdanm 0:9b334a45a8ff 64 I2C_CALLBK_T func_pt; /*!< Callback function */
bogdanm 0:9b334a45a8ff 65 uint8_t stop_flag; /*!< Stop flag */
bogdanm 0:9b334a45a8ff 66 uint8_t dummy[3];
bogdanm 0:9b334a45a8ff 67 } I2C_PARAM_T;
bogdanm 0:9b334a45a8ff 68
bogdanm 0:9b334a45a8ff 69 /**
bogdanm 0:9b334a45a8ff 70 * LPC8xx I2C ROM driver result structure
bogdanm 0:9b334a45a8ff 71 */
bogdanm 0:9b334a45a8ff 72 typedef struct I2C_RESULT {
bogdanm 0:9b334a45a8ff 73 uint32_t n_bytes_sent; /*!< No. of bytes sent */
bogdanm 0:9b334a45a8ff 74 uint32_t n_bytes_recd; /*!< No. of bytes received */
bogdanm 0:9b334a45a8ff 75 } I2C_RESULT_T;
bogdanm 0:9b334a45a8ff 76
bogdanm 0:9b334a45a8ff 77 /**
bogdanm 0:9b334a45a8ff 78 * LPC8xx I2C ROM driver modes enum
bogdanm 0:9b334a45a8ff 79 */
bogdanm 0:9b334a45a8ff 80 typedef enum CHIP_I2C_MODE {
bogdanm 0:9b334a45a8ff 81 IDLE, /*!< IDLE state */
bogdanm 0:9b334a45a8ff 82 MASTER_SEND, /*!< Master send state */
bogdanm 0:9b334a45a8ff 83 MASTER_RECEIVE, /*!< Master Receive state */
bogdanm 0:9b334a45a8ff 84 SLAVE_SEND, /*!< Slave send state */
bogdanm 0:9b334a45a8ff 85 SLAVE_RECEIVE /*!< Slave receive state */
bogdanm 0:9b334a45a8ff 86 } CHIP_I2C_MODE_T;
bogdanm 0:9b334a45a8ff 87
bogdanm 0:9b334a45a8ff 88 /**
bogdanm 0:9b334a45a8ff 89 * LPC8xx I2C ROM driver APIs structure
bogdanm 0:9b334a45a8ff 90 */
bogdanm 0:9b334a45a8ff 91 typedef struct I2CD_API {
bogdanm 0:9b334a45a8ff 92 /*!< Interrupt Support Routine */
bogdanm 0:9b334a45a8ff 93 void (*i2c_isr_handler)(I2C_HANDLE_T *handle);
bogdanm 0:9b334a45a8ff 94
bogdanm 0:9b334a45a8ff 95 /*!< MASTER functions */
bogdanm 0:9b334a45a8ff 96 ErrorCode_t (*i2c_master_transmit_poll)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
bogdanm 0:9b334a45a8ff 97 ErrorCode_t (*i2c_master_receive_poll)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
bogdanm 0:9b334a45a8ff 98 ErrorCode_t (*i2c_master_tx_rx_poll)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
bogdanm 0:9b334a45a8ff 99 ErrorCode_t (*i2c_master_transmit_intr)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
bogdanm 0:9b334a45a8ff 100 ErrorCode_t (*i2c_master_receive_intr)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
bogdanm 0:9b334a45a8ff 101 ErrorCode_t (*i2c_master_tx_rx_intr)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
bogdanm 0:9b334a45a8ff 102
bogdanm 0:9b334a45a8ff 103 /*!< SLAVE functions */
bogdanm 0:9b334a45a8ff 104 ErrorCode_t (*i2c_slave_receive_poll)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
bogdanm 0:9b334a45a8ff 105 ErrorCode_t (*i2c_slave_transmit_poll)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
bogdanm 0:9b334a45a8ff 106 ErrorCode_t (*i2c_slave_receive_intr)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
bogdanm 0:9b334a45a8ff 107 ErrorCode_t (*i2c_slave_transmit_intr)(I2C_HANDLE_T *handle, I2C_PARAM_T *param, I2C_RESULT_T *result);
bogdanm 0:9b334a45a8ff 108 ErrorCode_t (*i2c_set_slave_addr)(I2C_HANDLE_T *handle, uint32_t slave_addr_0_3, uint32_t slave_mask_0_3);
bogdanm 0:9b334a45a8ff 109
bogdanm 0:9b334a45a8ff 110 /*!< OTHER support functions */
bogdanm 0:9b334a45a8ff 111 uint32_t (*i2c_get_mem_size)(void);
bogdanm 0:9b334a45a8ff 112 I2C_HANDLE_T * (*i2c_setup)( uint32_t i2c_base_addr, uint32_t * start_of_ram);
bogdanm 0:9b334a45a8ff 113 ErrorCode_t (*i2c_set_bitrate)(I2C_HANDLE_T *handle, uint32_t p_clk_in_hz, uint32_t bitrate_in_bps);
bogdanm 0:9b334a45a8ff 114 uint32_t (*i2c_get_firmware_version)(void);
bogdanm 0:9b334a45a8ff 115 CHIP_I2C_MODE_T (*i2c_get_status)(I2C_HANDLE_T *handle);
bogdanm 0:9b334a45a8ff 116 ErrorCode_t (*i2c_set_timeout)(I2C_HANDLE_T *handle, uint32_t timeout);
bogdanm 0:9b334a45a8ff 117 } I2CD_API_T;
bogdanm 0:9b334a45a8ff 118
bogdanm 0:9b334a45a8ff 119 /**
bogdanm 0:9b334a45a8ff 120 * @}
bogdanm 0:9b334a45a8ff 121 */
bogdanm 0:9b334a45a8ff 122
bogdanm 0:9b334a45a8ff 123 #ifdef __cplusplus
bogdanm 0:9b334a45a8ff 124 }
bogdanm 0:9b334a45a8ff 125 #endif
bogdanm 0:9b334a45a8ff 126
bogdanm 0:9b334a45a8ff 127 #endif /* __ROM_I2C_8XX_H_ */