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