Forked repository for pushing changes to EVAL-AD4696

Dependencies:   platform_drivers

Committer:
Kjansen45
Date:
Wed Sep 29 11:39:40 2021 +0000
Revision:
0:721af8bb4b69
Repository created.

Who changed what in which revision?

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