liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | /** |
| 2 | @file |
| 3 | ql_spi.h |
| 4 | |
| 5 | @brief |
| 6 | This file provides the definitions for spi driver, and declares the |
| 7 | API functions. |
| 8 | |
| 9 | */ |
| 10 | /*============================================================================ |
| 11 | Copyright (c) 2017 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. |
| 12 | Quectel Wireless Solution Proprietary and Confidential. |
| 13 | =============================================================================*/ |
| 14 | /*=========================================================================== |
| 15 | |
| 16 | EDIT HISTORY FOR MODULE |
| 17 | |
| 18 | This section contains comments describing changes made to the module. |
| 19 | Notice that changes are listed in reverse chronological order. |
| 20 | |
| 21 | |
| 22 | WHEN WHO WHAT, WHERE, WHY |
| 23 | ---------- ------------ ---------------------------------------------------- |
| 24 | 2019/08/20 Juson create |
| 25 | =============================================================================*/ |
| 26 | #ifndef __QL_SPI_H__ |
| 27 | #define __QL_SPI_H__ |
| 28 | |
| 29 | #define SPI_CPHA 0x01 |
| 30 | #define SPI_CPOL 0x02 |
| 31 | |
| 32 | typedef enum |
| 33 | { |
| 34 | SPIMODE0 = (0|0), |
| 35 | SPIMODE1 = (0|SPI_CPHA), |
| 36 | SPIMODE2 = (SPI_CPOL|0), |
| 37 | SPIMODE3 = (SPI_CPOL|SPI_CPHA), |
| 38 | }SPI_MODE; |
| 39 | |
| 40 | typedef enum |
| 41 | { |
| 42 | S_6_5M = 6500000, |
| 43 | S_13M = 13000000, |
| 44 | S_26M = 26000000, |
| 45 | S_52M = 50000000, |
| 46 | }SPI_SPEED; |
| 47 | |
| 48 | /** |
| 49 | * Function: Ql_SPI_Init |
| 50 | * Description: spi init |
| 51 | * Parameters: dev_name---device name |
| 52 | * mode---spi mode |
| 53 | * bits---spi per word |
| 54 | * speed---spi transfer clock |
| 55 | * Return: spi fd |
| 56 | **/ |
| 57 | int Ql_SPI_Init(const char *dev_name, SPI_MODE mode, unsigned char bits, SPI_SPEED speed); |
| 58 | |
| 59 | /** |
| 60 | * Function: Ql_SPI_DeInit |
| 61 | * Description: spi deinit |
| 62 | * Parameters: fd---spi fd |
| 63 | * Return: |
| 64 | */ |
| 65 | int Ql_SPI_DeInit(int fd); |
| 66 | |
| 67 | /** |
| 68 | * Function: Ql_SPI_Write_Read |
| 69 | * Description: spi write read function |
| 70 | * Parameters: fd---spi fd |
| 71 | * w_buf---write buffer |
| 72 | * r_buf---read buffer |
| 73 | * len---spi transfer length |
| 74 | * Return: 0---transfer success |
| 75 | * other---failed |
| 76 | **/ |
| 77 | int Ql_SPI_Write_Read(int fd, unsigned char *w_buf, unsigned char *r_buf, unsigned int len); |
| 78 | |
| 79 | #endif/* __QL_SPI_H__ */ |