Example program for SDP-K1 SDP connector peripherals.

Committer:
Kjansen45
Date:
Fri Aug 07 16:07:18 2020 +0000
Revision:
0:689817250cb6
Repository Created;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kjansen45 0:689817250cb6 1 /*****************************************************************************
Kjansen45 0:689817250cb6 2 * Copyright (c) 2019 Analog Devices, Inc.
Kjansen45 0:689817250cb6 3 *
Kjansen45 0:689817250cb6 4 * All rights reserved.
Kjansen45 0:689817250cb6 5 *
Kjansen45 0:689817250cb6 6 * Redistribution and use in source and binary forms, with or without
Kjansen45 0:689817250cb6 7 * modification, are permitted provided that the following conditions are met:
Kjansen45 0:689817250cb6 8 * - Redistributions of source code must retain the above copyright notice,
Kjansen45 0:689817250cb6 9 * this list of conditions and the following disclaimer.
Kjansen45 0:689817250cb6 10 * - Redistributions in binary form must reproduce the above copyright notice,
Kjansen45 0:689817250cb6 11 * this list of conditions and the following disclaimer in the documentation
Kjansen45 0:689817250cb6 12 * and/or other materials provided with the distribution.
Kjansen45 0:689817250cb6 13 * - Modified versions of the software must be conspicuously marked as such.
Kjansen45 0:689817250cb6 14 * - This software is licensed solely and exclusively for use with
Kjansen45 0:689817250cb6 15 * processors/products manufactured by or for Analog Devices, Inc.
Kjansen45 0:689817250cb6 16 * - This software may not be combined or merged with other code in any manner
Kjansen45 0:689817250cb6 17 * that would cause the software to become subject to terms and
Kjansen45 0:689817250cb6 18 * conditions which differ from those listed here.
Kjansen45 0:689817250cb6 19 * - Neither the name of Analog Devices, Inc. nor the names of its
Kjansen45 0:689817250cb6 20 * contributors may be used to endorse or promote products derived
Kjansen45 0:689817250cb6 21 * from this software without specific prior written permission.
Kjansen45 0:689817250cb6 22 * - The use of this software may or may not infringe the patent rights
Kjansen45 0:689817250cb6 23 * of one or more patent holders. This license does not release you from
Kjansen45 0:689817250cb6 24 * the requirement that you obtain separate licenses from these patent
Kjansen45 0:689817250cb6 25 * holders to use this software.
Kjansen45 0:689817250cb6 26 *
Kjansen45 0:689817250cb6 27 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS"
Kjansen45 0:689817250cb6 28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
Kjansen45 0:689817250cb6 29 * NON-INFRINGEMENT, TITLE, MERCHANTABILITY AND FITNESS FOR A
Kjansen45 0:689817250cb6 30 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES,
Kjansen45 0:689817250cb6 31 * INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Kjansen45 0:689817250cb6 32 * SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES
Kjansen45 0:689817250cb6 33 * (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF
Kjansen45 0:689817250cb6 34 * INTELLECTUAL PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE
Kjansen45 0:689817250cb6 35 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Kjansen45 0:689817250cb6 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
Kjansen45 0:689817250cb6 37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
Kjansen45 0:689817250cb6 38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Kjansen45 0:689817250cb6 39 * POSSIBILITY OF SUCH DAMAGE.
Kjansen45 0:689817250cb6 40 *
Kjansen45 0:689817250cb6 41 * 20180927-7CBSD SLA
Kjansen45 0:689817250cb6 42 *****************************************************************************/
Kjansen45 0:689817250cb6 43
Kjansen45 0:689817250cb6 44 /*
Kjansen45 0:689817250cb6 45 The SDP connector is a 120 pin connector used on Analog Devices controller
Kjansen45 0:689817250cb6 46 boards to interface with ADI evaluation boards, over 450 ADI evaluation boards
Kjansen45 0:689817250cb6 47 utilise this connector, a list of these boards can be found at
Kjansen45 0:689817250cb6 48 https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-development-platforms/sdp.html#Compatible-Boards.
Kjansen45 0:689817250cb6 49
Kjansen45 0:689817250cb6 50 The following is an example program showing how to initialise and use SDP
Kjansen45 0:689817250cb6 51 connector peripherals (using SPI and GPIOs as an example) on the SDP-K1 in mbed.
Kjansen45 0:689817250cb6 52 Informtion on the pin name definitions for the SDP connector on the SDP-K1 can
Kjansen45 0:689817250cb6 53 be found at https://os.mbed.com/platforms/SDP_K1/.
Kjansen45 0:689817250cb6 54 The full list of peripherals available on the SDP connector include GPIOs,
Kjansen45 0:689817250cb6 55 Timers, SPI, I2C, and UART. For further information on how to enable these
Kjansen45 0:689817250cb6 56 peripherals, consult the mbed documentation https://os.mbed.com/docs/mbed-os/v5.15/apis/drivers.html
Kjansen45 0:689817250cb6 57 */
Kjansen45 0:689817250cb6 58 #include "mbed.h"
Kjansen45 0:689817250cb6 59 #include "platform/mbed_thread.h"
Kjansen45 0:689817250cb6 60
Kjansen45 0:689817250cb6 61 // Blinking rate in milliseconds
Kjansen45 0:689817250cb6 62 #define SLEEP_TIME 500
Kjansen45 0:689817250cb6 63
Kjansen45 0:689817250cb6 64 // Initialise the digital pin LED1 as an output
Kjansen45 0:689817250cb6 65 DigitalOut led1(LED1);
Kjansen45 0:689817250cb6 66
Kjansen45 0:689817250cb6 67 // Initialise the serial object with TX and RX pins
Kjansen45 0:689817250cb6 68 Serial pc(USBTX, USBRX);
Kjansen45 0:689817250cb6 69
Kjansen45 0:689817250cb6 70 // Initialise the SDP connector SPI peripheral (mosi, miso, clk)
Kjansen45 0:689817250cb6 71 SPI spi(SDP_SPI_MOSI, SDP_SPI_MISO, SDP_SPI_SCK); // SDP coonector pin no. (84, 83, 82)
Kjansen45 0:689817250cb6 72
Kjansen45 0:689817250cb6 73 // SDP SPI CS A (one of 3 available chip selects on the SDP connector)
Kjansen45 0:689817250cb6 74 DigitalOut cs_a(SDP_SPI_CS_A); // SDP connector pin no. 85
Kjansen45 0:689817250cb6 75
Kjansen45 0:689817250cb6 76 // Initialise GPIOs, there are 8 available SDP connector GPIO's (GPIO 0-7)
Kjansen45 0:689817250cb6 77 DigitalOut gpio1(SDP_GPIO_1); // GPIO pin 1 - SDP connector pin no. 78
Kjansen45 0:689817250cb6 78 DigitalOut gpio2(SDP_GPIO_2); // GPIO pin 2 - SDP connector pin no. 44
Kjansen45 0:689817250cb6 79
Kjansen45 0:689817250cb6 80 // main() runs in its own thread in the OS
Kjansen45 0:689817250cb6 81 int main()
Kjansen45 0:689817250cb6 82 {
Kjansen45 0:689817250cb6 83
Kjansen45 0:689817250cb6 84 uint8_t receive;
Kjansen45 0:689817250cb6 85
Kjansen45 0:689817250cb6 86 // Default chip select high
Kjansen45 0:689817250cb6 87 cs_a = 1;
Kjansen45 0:689817250cb6 88
Kjansen45 0:689817250cb6 89 // Setting GPIOs low initially
Kjansen45 0:689817250cb6 90 gpio1 = 0;
Kjansen45 0:689817250cb6 91 gpio2 = 0;
Kjansen45 0:689817250cb6 92
Kjansen45 0:689817250cb6 93 while(true){
Kjansen45 0:689817250cb6 94
Kjansen45 0:689817250cb6 95 // Toggling GPIOs
Kjansen45 0:689817250cb6 96 gpio1 = !gpio1;
Kjansen45 0:689817250cb6 97
Kjansen45 0:689817250cb6 98 gpio2 = !gpio2;
Kjansen45 0:689817250cb6 99
Kjansen45 0:689817250cb6 100 // Set CS low for SPI write
Kjansen45 0:689817250cb6 101 cs_a = 0;
Kjansen45 0:689817250cb6 102 // Performing SPI write/read (loopback if MOSI and MISO lines are connected)
Kjansen45 0:689817250cb6 103 receive = spi.write(0x0A);
Kjansen45 0:689817250cb6 104 // Set CS high after performing SPI write
Kjansen45 0:689817250cb6 105 cs_a = 1;
Kjansen45 0:689817250cb6 106
Kjansen45 0:689817250cb6 107 // Toggling GPIOs
Kjansen45 0:689817250cb6 108 gpio1 = !gpio1;
Kjansen45 0:689817250cb6 109
Kjansen45 0:689817250cb6 110 gpio2 = !gpio2;
Kjansen45 0:689817250cb6 111
Kjansen45 0:689817250cb6 112 // Blink LED and wait 500 ms
Kjansen45 0:689817250cb6 113 led1 = !led1;
Kjansen45 0:689817250cb6 114 thread_sleep_for(SLEEP_TIME);
Kjansen45 0:689817250cb6 115
Kjansen45 0:689817250cb6 116 }
Kjansen45 0:689817250cb6 117
Kjansen45 0:689817250cb6 118 }