Blinky program for SDP-K1.

Committer:
Kjansen45
Date:
Wed Feb 03 17:32:28 2021 +0000
Revision:
11:d5709648ce80
Parent:
10:b1071090cf50
Adding license file;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
malavikasaji 1:3d0efe79e629 1 /* Copyright (c) 2019 Analog Devices, Inc. All rights reserved.
malavikasaji 1:3d0efe79e629 2
malavikasaji 1:3d0efe79e629 3 Redistribution and use in source and binary forms, with or without modification,
malavikasaji 1:3d0efe79e629 4 are permitted provided that the following conditions are met:
malavikasaji 1:3d0efe79e629 5 - Redistributions of source code must retain the above copyright notice,
malavikasaji 1:3d0efe79e629 6 this list of conditions and the following disclaimer.
malavikasaji 1:3d0efe79e629 7 - Redistributions in binary form must reproduce the above copyright notice,
malavikasaji 1:3d0efe79e629 8 this list of conditions and the following disclaimer in the documentation
malavikasaji 1:3d0efe79e629 9 and/or other materials provided with the distribution.
malavikasaji 1:3d0efe79e629 10 - Modified versions of the software must be conspicuously marked as such.
malavikasaji 1:3d0efe79e629 11 - This software is licensed solely and exclusively for use with processors/products
malavikasaji 1:3d0efe79e629 12 manufactured by or for Analog Devices, Inc.
malavikasaji 1:3d0efe79e629 13 - This software may not be combined or merged with other code in any manner
malavikasaji 1:3d0efe79e629 14 that would cause the software to become subject to terms and conditions which
malavikasaji 1:3d0efe79e629 15 differ from those listed here.
malavikasaji 1:3d0efe79e629 16 - Neither the name of Analog Devices, Inc. nor the names of its contributors
malavikasaji 1:3d0efe79e629 17 may be used to endorse or promote products derived from this software without
malavikasaji 1:3d0efe79e629 18 specific prior written permission.
malavikasaji 1:3d0efe79e629 19 - The use of this software may or may not infringe the patent rights of one or
malavikasaji 1:3d0efe79e629 20 more patent holders. This license does not release you from the requirement
malavikasaji 1:3d0efe79e629 21 that you obtain separate licenses from these patent holders to use this software.
malavikasaji 1:3d0efe79e629 22
malavikasaji 1:3d0efe79e629 23 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND
malavikasaji 1:3d0efe79e629 24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
malavikasaji 1:3d0efe79e629 25 TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
malavikasaji 1:3d0efe79e629 26 NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
malavikasaji 1:3d0efe79e629 27 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES
malavikasaji 1:3d0efe79e629 28 (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL
malavikasaji 1:3d0efe79e629 29 PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
malavikasaji 1:3d0efe79e629 30 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
malavikasaji 1:3d0efe79e629 31 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
malavikasaji 1:3d0efe79e629 32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
malavikasaji 1:3d0efe79e629 33 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
malavikasaji 1:3d0efe79e629 34
malavikasaji 1:3d0efe79e629 35 2019-01-10-7CBSD SLA
Kjansen45 8:7f7b0fa6baad 36 */
malavikasaji 0:1d150cb7d8a5 37
malavikasaji 0:1d150cb7d8a5 38 #include "mbed.h"
malavikasaji 0:1d150cb7d8a5 39
Kjansen45 10:b1071090cf50 40 // LED Blinking rate in milliseconds (Note: need to define the unit of a time duration i.e. seconds(s) or milliseconds(ms))
Kjansen45 10:b1071090cf50 41 #define SLEEP_TIME 500ms
malavikasaji 4:25001877a575 42
Kjansen45 10:b1071090cf50 43 // Initialise the digital pin that controls LED1
Kjansen45 10:b1071090cf50 44 DigitalOut led(LED1);
malavikasaji 4:25001877a575 45 // Initialise the serial object with TX and RX pins
Kjansen45 10:b1071090cf50 46 static BufferedSerial serial_port(USBTX, USBRX);
malavikasaji 0:1d150cb7d8a5 47
Kjansen45 10:b1071090cf50 48 // The File handler is needed to allow printf commands to write to the terminal
Kjansen45 10:b1071090cf50 49 FileHandle *mbed::mbed_override_console(int fd)
Kjansen45 10:b1071090cf50 50 {
Kjansen45 10:b1071090cf50 51 return &serial_port;
Kjansen45 10:b1071090cf50 52 }
malavikasaji 0:1d150cb7d8a5 53
malavikasaji 1:3d0efe79e629 54 // main() runs in its own thread in the OS
malavikasaji 0:1d150cb7d8a5 55 int main()
malavikasaji 0:1d150cb7d8a5 56 {
Kjansen45 10:b1071090cf50 57 // printing the Mbed OS version this example was written to the console
Kjansen45 10:b1071090cf50 58 printf("This Application has been developed on Mbed OS version 6.4\r\n");
Kjansen45 10:b1071090cf50 59
Kjansen45 10:b1071090cf50 60 // printing the actual Mbed OS version that this application is using to the console.
Kjansen45 10:b1071090cf50 61 printf(
Kjansen45 10:b1071090cf50 62 "Mbed OS version %d.%d.%d is what this applicaiton is currently using\r\n",
Kjansen45 10:b1071090cf50 63 MBED_MAJOR_VERSION,
Kjansen45 10:b1071090cf50 64 MBED_MINOR_VERSION,
Kjansen45 10:b1071090cf50 65 MBED_PATCH_VERSION
Kjansen45 10:b1071090cf50 66 );
Kjansen45 10:b1071090cf50 67
Kjansen45 10:b1071090cf50 68 // The loop will toggle the LED every 500ms(SLEEP_TIME = 500ms) and print LED1s current state to the terminal
Kjansen45 10:b1071090cf50 69 while (1) {
Kjansen45 10:b1071090cf50 70 led = !led; // toggle LED1 state
Kjansen45 10:b1071090cf50 71 printf("LED1 state: %d \r\n", (uint8_t)led);
Kjansen45 10:b1071090cf50 72 ThisThread::sleep_for(SLEEP_TIME);
malavikasaji 0:1d150cb7d8a5 73 }
malavikasaji 0:1d150cb7d8a5 74 }
malavikasaji 0:1d150cb7d8a5 75