Example program for CN0535-FMCZ.

Dependencies:   platform_drivers AD77681

Committer:
Kjansen45
Date:
Thu Mar 04 15:34:19 2021 +0000
Revision:
0:ae894be1131f
Child:
1:f3b5e79a8488
Repository created.

Who changed what in which revision?

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