/* * Copyright (c) 2014-2016 IBM Corporation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _hal_hpp_ #define _hal_hpp_ #include "oslmic.h" /* * initialize hardware (IO, SPI, TIMER, IRQ). */ void hal_init (void); /* * drive radio NSS pin (0=low, 1=high). */ void hal_pin_nss (u1_t val); /* * drive radio RX/TX pins (0=rx, 1=tx). */ void hal_pin_rxtx (u1_t val); /* * control radio RST pin (0=low, 1=high, 2=floating) */ void hal_pin_rst (u1_t val); /* * perform 8-bit SPI transaction with radio. * - write given byte 'outval' * - read byte and return value */ u1_t hal_spi (u1_t outval); /* * disable all CPU interrupts. * - might be invoked nested * - will be followed by matching call to hal_enableIRQs() */ void hal_disableIRQs (void); /* * enable CPU interrupts. */ void hal_enableIRQs (void); /* * put system and CPU in low-power mode, sleep until interrupt. */ void hal_sleep (void); /* * return 32-bit system time in ticks. */ u4_t hal_ticks (void); /* * busy-wait until specified timestamp (in ticks) is reached. */ void hal_waitUntil (u4_t time); /* * check and rewind timer for target time. * - return 1 if target time is close * - otherwise rewind timer for target time or full period and return 0 */ u1_t hal_checkTimer (u4_t targettime); /* * perform fatal failure action. * - called by assertions * - action could be HALT or reboot */ void hal_failed (void); void LmicTimer_IRQHandler (); #endif // _hal_hpp_