A demo application for HXC900 LoRaWAN module using Nucleo-L053R8.

Dependencies:   mbed

Committer:
fahadmirza
Date:
Thu Jan 24 23:45:12 2019 +0000
Revision:
39:cb0e5a76ab15
Parent:
32:2d0678039a09
Doxygen style header

Who changed what in which revision?

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