1 /* 2 * Copyright (c) 2020 Hubert Miś 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief FT8XX common functions 10 */ 11 12 #ifndef ZEPHYR_DRIVERS_MISC_FT8XX_FT8XX_COMMON_H_ 13 #define ZEPHYR_DRIVERS_MISC_FT8XX_FT8XX_COMMON_H_ 14 15 #include <stdint.h> 16 #include <zephyr/device.h> 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 /** 23 * @brief FT8xx functions to write and read memory 24 * @defgroup ft8xx_common FT8xx common functions 25 * @ingroup ft8xx_interface 26 * @{ 27 */ 28 29 /** 30 * @brief Write 1 byte (8 bits) to FT8xx memory 31 * 32 * @param dev Pointer to the device structure for the driver instance 33 * @param address Memory address to write to 34 * @param data Byte to write 35 */ 36 void ft8xx_wr8(const struct device *dev, uint32_t address, uint8_t data); 37 38 /** 39 * @brief Write 2 bytes (16 bits) to FT8xx memory 40 * 41 * @param dev Pointer to the device structure for the driver instance 42 * @param address Memory address to write to 43 * @param data Value to write 44 */ 45 void ft8xx_wr16(const struct device *dev, uint32_t address, uint16_t data); 46 47 /** 48 * @brief Write 4 bytes (32 bits) to FT8xx memory 49 * 50 * @param dev Pointer to the device structure for the driver instance 51 * @param address Memory address to write to 52 * @param data Value to write 53 */ 54 void ft8xx_wr32(const struct device *dev, uint32_t address, uint32_t data); 55 56 /** 57 * @brief Read 1 byte (8 bits) from FT8xx memory 58 * 59 * @param dev Pointer to the device structure for the driver instance 60 * @param address Memory address to read from 61 * 62 * @return Value read from memory 63 */ 64 uint8_t ft8xx_rd8(const struct device *dev, uint32_t address); 65 66 /** 67 * @brief Read 2 bytes (16 bits) from FT8xx memory 68 * 69 * @param dev Pointer to the device structure for the driver instance 70 * @param address Memory address to read from 71 * 72 * @return Value read from memory 73 */ 74 uint16_t ft8xx_rd16(const struct device *dev, uint32_t address); 75 76 /** 77 * @brief Read 4 bytes (32 bits) from FT8xx memory 78 * 79 * @param dev Pointer to the device structure for the driver instance 80 * @param address Memory address to read from 81 * 82 * @return Value read from memory 83 */ 84 uint32_t ft8xx_rd32(const struct device *dev, uint32_t address); 85 86 /** 87 * @} 88 */ 89 90 #ifdef __cplusplus 91 } 92 #endif 93 94 #endif /* ZEPHYR_DRIVERS_MISC_FT8XX_FT8XX_COMMON_H_ */ 95