Yihui Xiong
/
Seeed_nRF51822_Motion
initial
Embed:
(wiki syntax)
Show/hide line numbers
mbed_spi.h
Go to the documentation of this file.
00001 00002 /****************************************************************************** 00003 * $Id: mbed_spi.h $ 00004 *****************************************************************************/ 00005 /** 00006 * @defgroup MBED_System_Layer MBED System Layer 00007 * @brief MBED System Layer APIs. 00008 * To interface with any platform, eMPL needs access to various 00009 * system layer functions. 00010 * 00011 * @{ 00012 * @file mbed_spi.h 00013 * @brief Serial communication functions needed by eMPL to 00014 * communicate to the MPU devices. 00015 * @details This driver assumes that eMPL is with a sub-master clock set 00016 * to 20MHz. The following MBEDs are supported: 00017 */ 00018 #ifndef _MBED_SPI_H_ 00019 #define _MBED_SPI_H_ 00020 00021 #ifdef __cplusplus 00022 extern "C" { 00023 #endif 00024 00025 #include "spi_api.h" 00026 00027 /** 00028 * @brief Set up the SPI port and configure the MBED as the master. 00029 */ 00030 void mbed_spi_init(PinName mosi, PinName miso, PinName sclk, PinName cs); 00031 00032 /** 00033 * @brief Enable SPI port. 00034 */ 00035 void mbed_spi_enable(void); 00036 00037 /** 00038 * @brief Disable SPI communication. 00039 * This function will disable the SPI hardware and should be called prior to 00040 * entering low-power mode. 00041 */ 00042 void mbed_spi_disable(void); 00043 00044 /** 00045 * @brief Write to a device register. 00046 * 00047 * @param[in] reg_addr Slave register to be written to. 00048 * @param[in] length Number of bytes to write. 00049 * @param[out] data Data to be written to register. 00050 * 00051 * @return 0 if successful. 00052 */ 00053 int mbed_spi_write(unsigned char reg_addr, 00054 unsigned char length, 00055 unsigned char const *data); 00056 /** 00057 * @brief Read from a device. 00058 * 00059 * @param[in] reg_addr Slave register to be read from. 00060 * @param[in] length Number of bytes to read. 00061 * @param[out] data Data from register. 00062 * 00063 * @return 0 if successful. 00064 */ 00065 int mbed_spi_read(unsigned char reg_addr, 00066 unsigned char length, 00067 unsigned char *data); 00068 00069 #ifdef __cplusplus 00070 } 00071 #endif 00072 00073 #endif /* _MBED_I2C_H_ */ 00074 00075 /** 00076 * @} 00077 */
Generated on Wed Jul 13 2022 20:01:33 by 1.7.2