test

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers QuadSpi.cpp Source File

QuadSpi.cpp

00001 
00002 /*******************************************************************************
00003  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
00004  *
00005  * Permission is hereby granted, free of charge, to any person obtaining a
00006  * copy of this software and associated documentation files (the "Software"),
00007  * to deal in the Software without restriction, including without limitation
00008  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00009  * and/or sell copies of the Software, and to permit persons to whom the
00010  * Software is furnished to do so, subject to the following conditions:
00011  *
00012  * The above copyright notice and this permission notice shall be included
00013  * in all copies or substantial portions of the Software.
00014  *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00019  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00020  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00021  * OTHER DEALINGS IN THE SOFTWARE.
00022  *
00023  * Except as contained in this notice, the name of Maxim Integrated
00024  * Products, Inc. shall not be used except as stated in the Maxim Integrated
00025  * Products, Inc. Branding Policy.
00026  *
00027  * The mere transfer of this software does not imply any licenses
00028  * of trade secrets, proprietary technology, copyrights, patents,
00029  * trademarks, maskwork rights, or any other form of intellectual
00030  * property whatsoever. Maxim Integrated Products, Inc. retains all
00031  * ownership rights.
00032  *******************************************************************************
00033  */
00034 
00035 
00036 #include "QuadSpi.h"
00037 #include "spi_multi_api.h"
00038 
00039 /** Initialize a SPI master for Quad SPI
00040  *
00041  * @param[in] mosi   Pin used for Master Out Slave In
00042  * @param[in] miso   Pin used for Master In Slave Out
00043  * @param[in] sclk   Pin used for Clock
00044  * @param[in] ssel   Pin used for Chip Select
00045  */
00046 QuadSPI::QuadSPI(PinName mosi, PinName miso, PinName sclk, PinName ssel) : SPI(mosi,miso,sclk,ssel) {    
00047     spi_master_width(&_spi, WidthQuad);
00048 }
00049 
00050 /** Write a byte out in master mode and receive a value
00051  *
00052  * @param[in] value   Byte Value to send
00053  * @return Returns Zero
00054  */
00055 int QuadSPI::write(int value) {
00056     aquire();
00057     spi_master_write(&_spi, value);
00058     return 0;
00059 }
00060 
00061 /** Read a byte in master mode using Quad SPI simplex transfer
00062  *
00063  * @return Returns the value received from Quad SPI
00064  */
00065 int QuadSPI::read() {
00066     aquire();
00067     return spi_master_read(&_spi);
00068 }
00069 
00070 
00071 
00072 
00073 
00074