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