Kashish Haresh Shah
/
HXCClientShield
HXC Client Shield Repository.
Driver/hxcclient_bsp.cpp@3:5e1a54378107, 2021-04-19 (annotated)
- Committer:
- kashish_mbed
- Date:
- Mon Apr 19 17:43:09 2021 +0000
- Revision:
- 3:5e1a54378107
- Parent:
- 0:bacc6e701fb4
Successful Build file with CmdProcess Functionality
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kashish_mbed | 0:bacc6e701fb4 | 1 | /* |
kashish_mbed | 0:bacc6e701fb4 | 2 | _ _ _____ _______ |
kashish_mbed | 0:bacc6e701fb4 | 3 | | | | | |_ _| |__ __| |
kashish_mbed | 0:bacc6e701fb4 | 4 | | |__| | __ ___ __ | | ___ | | |
kashish_mbed | 0:bacc6e701fb4 | 5 | | __ |/ _` \ \/ / | | / _ \| | |
kashish_mbed | 0:bacc6e701fb4 | 6 | | | | | (_| |> < _| || (_) | | |
kashish_mbed | 0:bacc6e701fb4 | 7 | |_| |_|\__,_/_/\_\_____\___/|_| |
kashish_mbed | 0:bacc6e701fb4 | 8 | (C)2019 HaxIoT |
kashish_mbed | 0:bacc6e701fb4 | 9 | */ |
kashish_mbed | 0:bacc6e701fb4 | 10 | /******************************************************************************* |
kashish_mbed | 0:bacc6e701fb4 | 11 | * File : hxcclient_bsp.c |
kashish_mbed | 0:bacc6e701fb4 | 12 | * Author : Fahad (Haxiot) |
kashish_mbed | 0:bacc6e701fb4 | 13 | * Version : V1.0.0 |
kashish_mbed | 0:bacc6e701fb4 | 14 | * Modified: 22-January-2019 |
kashish_mbed | 0:bacc6e701fb4 | 15 | * Brief : HXC Client Expansion Board LED, Slide Switch & Temperature sensor |
kashish_mbed | 0:bacc6e701fb4 | 16 | ****************************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 17 | * @attention |
kashish_mbed | 0:bacc6e701fb4 | 18 | * |
kashish_mbed | 0:bacc6e701fb4 | 19 | * <h2><center>© COPYRIGHT(c) 2019 Haxiot</center></h2> |
kashish_mbed | 0:bacc6e701fb4 | 20 | * |
kashish_mbed | 0:bacc6e701fb4 | 21 | * Redistribution and use in source and binary forms, with or without modification, |
kashish_mbed | 0:bacc6e701fb4 | 22 | * are permitted provided that the following conditions are met: |
kashish_mbed | 0:bacc6e701fb4 | 23 | * 1. Redistributions of source code must retain the above copyright notice, |
kashish_mbed | 0:bacc6e701fb4 | 24 | * this list of conditions and the following disclaimer. |
kashish_mbed | 0:bacc6e701fb4 | 25 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
kashish_mbed | 0:bacc6e701fb4 | 26 | * this list of conditions and the following disclaimer in the documentation |
kashish_mbed | 0:bacc6e701fb4 | 27 | * and/or other materials provided with the distribution. |
kashish_mbed | 0:bacc6e701fb4 | 28 | * 3. Neither the name of Haxiot nor the names of its contributors |
kashish_mbed | 0:bacc6e701fb4 | 29 | * may be used to endorse or promote products derived from this software |
kashish_mbed | 0:bacc6e701fb4 | 30 | * without specific prior written permission. |
kashish_mbed | 0:bacc6e701fb4 | 31 | * |
kashish_mbed | 0:bacc6e701fb4 | 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
kashish_mbed | 0:bacc6e701fb4 | 33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
kashish_mbed | 0:bacc6e701fb4 | 34 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
kashish_mbed | 0:bacc6e701fb4 | 35 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
kashish_mbed | 0:bacc6e701fb4 | 36 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
kashish_mbed | 0:bacc6e701fb4 | 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
kashish_mbed | 0:bacc6e701fb4 | 38 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
kashish_mbed | 0:bacc6e701fb4 | 39 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
kashish_mbed | 0:bacc6e701fb4 | 40 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
kashish_mbed | 0:bacc6e701fb4 | 41 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
kashish_mbed | 0:bacc6e701fb4 | 42 | * |
kashish_mbed | 0:bacc6e701fb4 | 43 | ****************************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 44 | */ |
kashish_mbed | 0:bacc6e701fb4 | 45 | |
kashish_mbed | 0:bacc6e701fb4 | 46 | /* Includes ------------------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 47 | #include "mbed.h" |
kashish_mbed | 0:bacc6e701fb4 | 48 | #include "hxcclient_bsp.h" |
kashish_mbed | 0:bacc6e701fb4 | 49 | |
kashish_mbed | 0:bacc6e701fb4 | 50 | // Mbed specific declaration |
kashish_mbed | 0:bacc6e701fb4 | 51 | AnalogIn temperatureSensor(A0); |
kashish_mbed | 0:bacc6e701fb4 | 52 | DigitalIn slideSwitch(D12); |
kashish_mbed | 0:bacc6e701fb4 | 53 | DigitalOut greenLED(D11); |
kashish_mbed | 0:bacc6e701fb4 | 54 | DigitalOut redLED(D10); |
kashish_mbed | 0:bacc6e701fb4 | 55 | DigitalOut blueLED(D9); |
kashish_mbed | 0:bacc6e701fb4 | 56 | |
kashish_mbed | 0:bacc6e701fb4 | 57 | |
kashish_mbed | 0:bacc6e701fb4 | 58 | void HXC_BSP_Init(void) |
kashish_mbed | 0:bacc6e701fb4 | 59 | { |
kashish_mbed | 0:bacc6e701fb4 | 60 | slideSwitch.mode(PullDown); |
kashish_mbed | 0:bacc6e701fb4 | 61 | } |
kashish_mbed | 0:bacc6e701fb4 | 62 | |
kashish_mbed | 0:bacc6e701fb4 | 63 | uint16_t HXC_BSP_GetTemperature(void) |
kashish_mbed | 0:bacc6e701fb4 | 64 | { |
kashish_mbed | 0:bacc6e701fb4 | 65 | // Converts and read the analog input value (value from 0.0 to 1.0) |
kashish_mbed | 0:bacc6e701fb4 | 66 | float tempFloat = temperatureSensor.read(); |
kashish_mbed | 0:bacc6e701fb4 | 67 | // Change the value to be in the 0 to 3300 range |
kashish_mbed | 0:bacc6e701fb4 | 68 | uint16_t tempInt = tempFloat * 3300; |
kashish_mbed | 0:bacc6e701fb4 | 69 | // Checkout our user manual to convert tempInt into degree Celcius |
kashish_mbed | 0:bacc6e701fb4 | 70 | |
kashish_mbed | 0:bacc6e701fb4 | 71 | return tempInt; |
kashish_mbed | 0:bacc6e701fb4 | 72 | } |
kashish_mbed | 0:bacc6e701fb4 | 73 | |
kashish_mbed | 0:bacc6e701fb4 | 74 | uint8_t HXC_BSP_GetSlideSwitchStatus(void) |
kashish_mbed | 0:bacc6e701fb4 | 75 | { |
kashish_mbed | 0:bacc6e701fb4 | 76 | return slideSwitch; |
kashish_mbed | 0:bacc6e701fb4 | 77 | } |
kashish_mbed | 0:bacc6e701fb4 | 78 | |
kashish_mbed | 0:bacc6e701fb4 | 79 | void HXC_BSP_RGB_On(eLedColor_t ledColor) |
kashish_mbed | 0:bacc6e701fb4 | 80 | { |
kashish_mbed | 0:bacc6e701fb4 | 81 | redLED = (ledColor & RED) ? 1 : 0; |
kashish_mbed | 0:bacc6e701fb4 | 82 | greenLED = (ledColor & GREEN) ? 1 : 0; |
kashish_mbed | 0:bacc6e701fb4 | 83 | blueLED = (ledColor & BLUE) ? 1 : 0; |
kashish_mbed | 0:bacc6e701fb4 | 84 | } |
kashish_mbed | 0:bacc6e701fb4 | 85 | |
kashish_mbed | 0:bacc6e701fb4 | 86 | void HXC_BSP_RGB_Off(void) |
kashish_mbed | 0:bacc6e701fb4 | 87 | { |
kashish_mbed | 0:bacc6e701fb4 | 88 | HXC_BSP_RGB_On(OFF); |
kashish_mbed | 0:bacc6e701fb4 | 89 | } |
kashish_mbed | 0:bacc6e701fb4 | 90 | |
kashish_mbed | 0:bacc6e701fb4 | 91 | void HXC_BSP_RGB_AllOn(void) |
kashish_mbed | 0:bacc6e701fb4 | 92 | { |
kashish_mbed | 0:bacc6e701fb4 | 93 | HXC_BSP_RGB_On(WHITE); |
kashish_mbed | 0:bacc6e701fb4 | 94 | } |