Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

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