Simples setup for Don's board

Committer:
j3
Date:
Tue Oct 10 21:51:22 2017 +0000
Revision:
0:a30b2f6d5489
Init Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 0:a30b2f6d5489 1 /**********************************************************************
j3 0:a30b2f6d5489 2 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
j3 0:a30b2f6d5489 3 *
j3 0:a30b2f6d5489 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 0:a30b2f6d5489 5 * copy of this software and associated documentation files (the "Software"),
j3 0:a30b2f6d5489 6 * to deal in the Software without restriction, including without limitation
j3 0:a30b2f6d5489 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 0:a30b2f6d5489 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 0:a30b2f6d5489 9 * Software is furnished to do so, subject to the following conditions:
j3 0:a30b2f6d5489 10 *
j3 0:a30b2f6d5489 11 * The above copyright notice and this permission notice shall be included
j3 0:a30b2f6d5489 12 * in all copies or substantial portions of the Software.
j3 0:a30b2f6d5489 13 *
j3 0:a30b2f6d5489 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 0:a30b2f6d5489 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 0:a30b2f6d5489 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 0:a30b2f6d5489 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 0:a30b2f6d5489 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 0:a30b2f6d5489 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 0:a30b2f6d5489 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 0:a30b2f6d5489 21 *
j3 0:a30b2f6d5489 22 * Except as contained in this notice, the name of Maxim Integrated
j3 0:a30b2f6d5489 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 0:a30b2f6d5489 24 * Products, Inc. Branding Policy.
j3 0:a30b2f6d5489 25 *
j3 0:a30b2f6d5489 26 * The mere transfer of this software does not imply any licenses
j3 0:a30b2f6d5489 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 0:a30b2f6d5489 28 * trademarks, maskwork rights, or any other form of intellectual
j3 0:a30b2f6d5489 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 0:a30b2f6d5489 30 * ownership rights.
j3 0:a30b2f6d5489 31 ******************************************************************************/
j3 0:a30b2f6d5489 32
j3 0:a30b2f6d5489 33
j3 0:a30b2f6d5489 34 #include "mbed.h"
j3 0:a30b2f6d5489 35
j3 0:a30b2f6d5489 36
j3 0:a30b2f6d5489 37 PinName STATUS_RED = P1_2;
j3 0:a30b2f6d5489 38 PinName STATUS_GREEN = P1_3;
j3 0:a30b2f6d5489 39 PinName STATUS_BLUE = P1_4;
j3 0:a30b2f6d5489 40 PinName BOOST_EN = P2_2;
j3 0:a30b2f6d5489 41
j3 0:a30b2f6d5489 42
j3 0:a30b2f6d5489 43 int main()
j3 0:a30b2f6d5489 44 {
j3 0:a30b2f6d5489 45 //Enable 5V rail first, active high
j3 0:a30b2f6d5489 46 DigitalOut boostEN(BOOST_EN, 1);
j3 0:a30b2f6d5489 47
j3 0:a30b2f6d5489 48 //Instantiate led objects, active high via bjt pulldown
j3 0:a30b2f6d5489 49 DigitalOut rLED(STATUS_RED, 0);
j3 0:a30b2f6d5489 50 DigitalOut gLED(STATUS_GREEN, 0);
j3 0:a30b2f6d5489 51 DigitalOut bLED(STATUS_BLUE, 0);
j3 0:a30b2f6d5489 52
j3 0:a30b2f6d5489 53 //Simple array to rotate through
j3 0:a30b2f6d5489 54 DigitalOut leds[] = {rLED, gLED, bLED};
j3 0:a30b2f6d5489 55
j3 0:a30b2f6d5489 56 I2C i2c_bus(I2C1_SDA, I2C1_SCL);
j3 0:a30b2f6d5489 57
j3 0:a30b2f6d5489 58 uint32_t count = 0;
j3 0:a30b2f6d5489 59
j3 0:a30b2f6d5489 60 while(1)
j3 0:a30b2f6d5489 61 {
j3 0:a30b2f6d5489 62 leds[count % 3] = 1;
j3 0:a30b2f6d5489 63 wait(0.25);
j3 0:a30b2f6d5489 64 leds[count % 3] = 0;
j3 0:a30b2f6d5489 65 wait(0.25);
j3 0:a30b2f6d5489 66
j3 0:a30b2f6d5489 67 count++;
j3 0:a30b2f6d5489 68
j3 0:a30b2f6d5489 69 printf("Count = %d\r\n", count);
j3 0:a30b2f6d5489 70 }
j3 0:a30b2f6d5489 71 }