Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Application by
mbed-dev/targets/TARGET_ONSEMI/TARGET_NCS36510/spi.h@15:2a20c3d2616e, 2018-02-15 (annotated)
- Committer:
- Zaitsev
- Date:
- Thu Feb 15 14:29:23 2018 +0000
- Revision:
- 15:2a20c3d2616e
- Parent:
- 10:41552d038a69
j
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Zaitsev | 10:41552d038a69 | 1 | /** |
| Zaitsev | 10:41552d038a69 | 2 | ****************************************************************************** |
| Zaitsev | 10:41552d038a69 | 3 | * @file spi.h |
| Zaitsev | 10:41552d038a69 | 4 | * @brief Inlcude file of a SPI master driver |
| Zaitsev | 10:41552d038a69 | 5 | * @internal |
| Zaitsev | 10:41552d038a69 | 6 | * @author ON Semiconductor |
| Zaitsev | 10:41552d038a69 | 7 | * @version $Rev: $ |
| Zaitsev | 10:41552d038a69 | 8 | * @date $Date: 2016-02-05 $ |
| Zaitsev | 10:41552d038a69 | 9 | ****************************************************************************** |
| Zaitsev | 10:41552d038a69 | 10 | * Copyright 2016 Semiconductor Components Industries LLC (d/b/a ON Semiconductor). |
| Zaitsev | 10:41552d038a69 | 11 | * All rights reserved. This software and/or documentation is licensed by ON Semiconductor |
| Zaitsev | 10:41552d038a69 | 12 | * under limited terms and conditions. The terms and conditions pertaining to the software |
| Zaitsev | 10:41552d038a69 | 13 | * and/or documentation are available at http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf |
| Zaitsev | 10:41552d038a69 | 14 | * (ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software) and |
| Zaitsev | 10:41552d038a69 | 15 | * if applicable the software license agreement. Do not use this software and/or |
| Zaitsev | 10:41552d038a69 | 16 | * documentation unless you have carefully read and you agree to the limited terms and |
| Zaitsev | 10:41552d038a69 | 17 | * conditions. By using this software and/or documentation, you agree to the limited |
| Zaitsev | 10:41552d038a69 | 18 | * terms and conditions. |
| Zaitsev | 10:41552d038a69 | 19 | * |
| Zaitsev | 10:41552d038a69 | 20 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
| Zaitsev | 10:41552d038a69 | 21 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
| Zaitsev | 10:41552d038a69 | 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
| Zaitsev | 10:41552d038a69 | 23 | * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, |
| Zaitsev | 10:41552d038a69 | 24 | * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
| Zaitsev | 10:41552d038a69 | 25 | * @endinternal |
| Zaitsev | 10:41552d038a69 | 26 | * |
| Zaitsev | 10:41552d038a69 | 27 | * @ingroup spi_h |
| Zaitsev | 10:41552d038a69 | 28 | * |
| Zaitsev | 10:41552d038a69 | 29 | * @details |
| Zaitsev | 10:41552d038a69 | 30 | * |
| Zaitsev | 10:41552d038a69 | 31 | */ |
| Zaitsev | 10:41552d038a69 | 32 | #ifndef SPI_H_ |
| Zaitsev | 10:41552d038a69 | 33 | #define SPI_H_ |
| Zaitsev | 10:41552d038a69 | 34 | |
| Zaitsev | 10:41552d038a69 | 35 | #include "device.h" |
| Zaitsev | 10:41552d038a69 | 36 | #include "spi_api.h" |
| Zaitsev | 10:41552d038a69 | 37 | |
| Zaitsev | 10:41552d038a69 | 38 | #if DEVICE_SPI |
| Zaitsev | 10:41552d038a69 | 39 | |
| Zaitsev | 10:41552d038a69 | 40 | #ifdef __cplusplus |
| Zaitsev | 10:41552d038a69 | 41 | extern "C" { |
| Zaitsev | 10:41552d038a69 | 42 | #endif |
| Zaitsev | 10:41552d038a69 | 43 | |
| Zaitsev | 10:41552d038a69 | 44 | /* Miscellaneous I/O and control operations codes */ |
| Zaitsev | 10:41552d038a69 | 45 | #define SPI_IPC7207_IOCTL_GET_SLAVE_SELECT (0x1) /**< <b>Ioctl request code</b>: Reading slaveSelect register */ |
| Zaitsev | 10:41552d038a69 | 46 | #define SPI_IPC7207_IOCTL_SET_SLAVE_SELECT (0x2) /**< <b>Ioctl request code</b>: Setting slaveSelect register */ |
| Zaitsev | 10:41552d038a69 | 47 | #define SPI_IPC7207_IOCTL_FLUSH (0x3) /**< <b>Ioctl request code</b>: Flushin FIFOs and serial shift registers */ |
| Zaitsev | 10:41552d038a69 | 48 | |
| Zaitsev | 10:41552d038a69 | 49 | /* Control register bit positions */ |
| Zaitsev | 10:41552d038a69 | 50 | #define SPI_WORD_WIDTH_BIT_POS 6 |
| Zaitsev | 10:41552d038a69 | 51 | #define SPI_SLAVE_MASTER_BIT_POS 5 |
| Zaitsev | 10:41552d038a69 | 52 | #define SPI_CPOL_BIT_POS 4 |
| Zaitsev | 10:41552d038a69 | 53 | #define SPI_CPHA_BIT_POS 3 |
| Zaitsev | 10:41552d038a69 | 54 | #define SPI_ENDIAN_BIT_POS 2 |
| Zaitsev | 10:41552d038a69 | 55 | #define SPI_SAMPLE_EDGE_BIT_POS 1 |
| Zaitsev | 10:41552d038a69 | 56 | #define SPI_PORT_ENABLE_BIT_POS 0 |
| Zaitsev | 10:41552d038a69 | 57 | |
| Zaitsev | 10:41552d038a69 | 58 | /* COntrol register bits */ |
| Zaitsev | 10:41552d038a69 | 59 | #define SPI_ENDIAN_MSB_FIRST 1 |
| Zaitsev | 10:41552d038a69 | 60 | #define SPI_CPOL_IDLE_LOW 0 |
| Zaitsev | 10:41552d038a69 | 61 | #define SPI_CPHA_BEFORE_1ST_EDGE 0 |
| Zaitsev | 10:41552d038a69 | 62 | #define SPI_MASTER_MODE 1 |
| Zaitsev | 10:41552d038a69 | 63 | #define SPI_WORD_WIDTH_8_BITS 0 |
| Zaitsev | 10:41552d038a69 | 64 | #define SPI_SAMPLE_OPP_CLK_EDGE_DATA 0 |
| Zaitsev | 10:41552d038a69 | 65 | #define SPI_SLAVE_SELECT_NORM_BEHAVE 0 |
| Zaitsev | 10:41552d038a69 | 66 | #define SPI_PORT_ENABLE 1 |
| Zaitsev | 10:41552d038a69 | 67 | |
| Zaitsev | 10:41552d038a69 | 68 | #define SPI_SLAVE_SELECT_DEFAULT 0x10 |
| Zaitsev | 10:41552d038a69 | 69 | |
| Zaitsev | 10:41552d038a69 | 70 | #define SPI_DEFAULT_CONFIG 0x25 |
| Zaitsev | 10:41552d038a69 | 71 | |
| Zaitsev | 10:41552d038a69 | 72 | #define SPI_DEFAULT_SPEED 1000000 |
| Zaitsev | 10:41552d038a69 | 73 | #define SPI_BYTE_MASK 0xFF |
| Zaitsev | 10:41552d038a69 | 74 | |
| Zaitsev | 10:41552d038a69 | 75 | extern void fSpiInit(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel); |
| Zaitsev | 10:41552d038a69 | 76 | extern void fSpiClose(spi_t *obj); |
| Zaitsev | 10:41552d038a69 | 77 | extern int fSpiWriteB(spi_t *obj, uint32_t const buf); |
| Zaitsev | 10:41552d038a69 | 78 | |
| Zaitsev | 10:41552d038a69 | 79 | #ifdef __cplusplus |
| Zaitsev | 10:41552d038a69 | 80 | } |
| Zaitsev | 10:41552d038a69 | 81 | #endif /* __cplusplus */ |
| Zaitsev | 10:41552d038a69 | 82 | |
| Zaitsev | 10:41552d038a69 | 83 | #endif /* DEVICE_SPI */ |
| Zaitsev | 10:41552d038a69 | 84 | |
| Zaitsev | 10:41552d038a69 | 85 | #endif /* SPI_H_ */ |
