|
| 1 | +/** |
| 2 | + * @file i2c.h |
| 3 | + * @brief |
| 4 | + * |
| 5 | + * DAPLink Interface Firmware |
| 6 | + * Copyright 2020 NXP |
| 7 | + * Copyright 2021 Micro:bit Educational Foundation |
| 8 | + * SPDX-License-Identifier: Apache-2.0 |
| 9 | + * |
| 10 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 11 | + * not use this file except in compliance with the License. |
| 12 | + * You may obtain a copy of the License at |
| 13 | + * |
| 14 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | + * |
| 16 | + * Unless required by applicable law or agreed to in writing, software |
| 17 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 18 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | + * See the License for the specific language governing permissions and |
| 20 | + * limitations under the License. |
| 21 | + */ |
| 22 | + |
| 23 | +#ifndef I2C_H_ |
| 24 | +#define I2C_H_ |
| 25 | + |
| 26 | +#include <stdint.h> |
| 27 | +#include <stdbool.h> |
| 28 | + |
| 29 | +/*! i2c Read/Write Callback prototype */ |
| 30 | +typedef void (*i2cCallback_t) |
| 31 | +( |
| 32 | + uint8_t* pData, |
| 33 | + uint8_t size |
| 34 | +); |
| 35 | + |
| 36 | +typedef enum { |
| 37 | + I2C_STATUS_SUCCESS = 0, |
| 38 | + I2C_STATUS_FAIL |
| 39 | +} i2c_status_t; |
| 40 | + |
| 41 | +/* TX and RX buffer size */ |
| 42 | +#define I2C_DATA_LENGTH (1024U + 8U) |
| 43 | + |
| 44 | +void i2c_initialize(void); |
| 45 | +void i2c_deinitialize(void); |
| 46 | +i2c_status_t i2c_registerWriteCallback(i2cCallback_t writeCallback, uint8_t slaveAddress); |
| 47 | +i2c_status_t i2c_registerReadCallback(i2cCallback_t readCallback, uint8_t slaveAddress); |
| 48 | +void i2c_clearBuffers(void); |
| 49 | +void i2c_fillBuffer(uint8_t* data, uint32_t position, uint32_t size); |
| 50 | +bool i2c_isBusy(void); |
| 51 | +bool i2c_canSleep(void); |
| 52 | + |
| 53 | +#endif /* I2C_H_ */ |
0 commit comments