lmic fork for Senet NAMote

Dependents:   Senet NAMote

Fork of lmic_MOTE_L152RC_2 by Dave Kjendal

Committer:
dudmuck
Date:
Tue Jun 02 19:04:29 2015 +0000
Revision:
0:f2716e543d97
lmic-v1.5 for MOTE_L152RC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dudmuck 0:f2716e543d97 1 /*******************************************************************************
dudmuck 0:f2716e543d97 2 * Copyright (c) 2014-2015 IBM Corporation.
dudmuck 0:f2716e543d97 3 * All rights reserved. This program and the accompanying materials
dudmuck 0:f2716e543d97 4 * are made available under the terms of the Eclipse Public License v1.0
dudmuck 0:f2716e543d97 5 * which accompanies this distribution, and is available at
dudmuck 0:f2716e543d97 6 * http://www.eclipse.org/legal/epl-v10.html
dudmuck 0:f2716e543d97 7 *
dudmuck 0:f2716e543d97 8 * Contributors:
dudmuck 0:f2716e543d97 9 * IBM Zurich Research Lab - initial API, implementation and documentation
dudmuck 0:f2716e543d97 10 *******************************************************************************/
dudmuck 0:f2716e543d97 11
dudmuck 0:f2716e543d97 12 #ifndef _hal_hpp_
dudmuck 0:f2716e543d97 13 #define _hal_hpp_
dudmuck 0:f2716e543d97 14
dudmuck 0:f2716e543d97 15 /*
dudmuck 0:f2716e543d97 16 * initialize hardware (IO, SPI, TIMER, IRQ).
dudmuck 0:f2716e543d97 17 */
dudmuck 0:f2716e543d97 18 void hal_init (void);
dudmuck 0:f2716e543d97 19
dudmuck 0:f2716e543d97 20 /*
dudmuck 0:f2716e543d97 21 * drive radio NSS pin (0=low, 1=high).
dudmuck 0:f2716e543d97 22 */
dudmuck 0:f2716e543d97 23 void hal_pin_nss (u1_t val);
dudmuck 0:f2716e543d97 24
dudmuck 0:f2716e543d97 25 /*
dudmuck 0:f2716e543d97 26 * drive radio RX/TX pins (0=rx, 1=tx).
dudmuck 0:f2716e543d97 27 */
dudmuck 0:f2716e543d97 28 //void hal_pin_rxtx (u1_t val);
dudmuck 0:f2716e543d97 29 void hal_opmode(u1_t mode, u1_t pa_boost);
dudmuck 0:f2716e543d97 30
dudmuck 0:f2716e543d97 31 /*
dudmuck 0:f2716e543d97 32 * control radio RST pin (0=low, 1=high, 2=floating)
dudmuck 0:f2716e543d97 33 */
dudmuck 0:f2716e543d97 34 void hal_pin_rst (u1_t val);
dudmuck 0:f2716e543d97 35
dudmuck 0:f2716e543d97 36 /*
dudmuck 0:f2716e543d97 37 * perform 8-bit SPI transaction with radio.
dudmuck 0:f2716e543d97 38 * - write given byte 'outval'
dudmuck 0:f2716e543d97 39 * - read byte and return value
dudmuck 0:f2716e543d97 40 */
dudmuck 0:f2716e543d97 41 u1_t hal_spi (u1_t outval);
dudmuck 0:f2716e543d97 42
dudmuck 0:f2716e543d97 43 /*
dudmuck 0:f2716e543d97 44 * disable all CPU interrupts.
dudmuck 0:f2716e543d97 45 * - might be invoked nested
dudmuck 0:f2716e543d97 46 * - will be followed by matching call to hal_enableIRQs()
dudmuck 0:f2716e543d97 47 */
dudmuck 0:f2716e543d97 48 void hal_disableIRQs (void);
dudmuck 0:f2716e543d97 49
dudmuck 0:f2716e543d97 50 /*
dudmuck 0:f2716e543d97 51 * enable CPU interrupts.
dudmuck 0:f2716e543d97 52 */
dudmuck 0:f2716e543d97 53 void hal_enableIRQs (void);
dudmuck 0:f2716e543d97 54
dudmuck 0:f2716e543d97 55 /*
dudmuck 0:f2716e543d97 56 * put system and CPU in low-power mode, sleep until interrupt.
dudmuck 0:f2716e543d97 57 */
dudmuck 0:f2716e543d97 58 void hal_sleep (void);
dudmuck 0:f2716e543d97 59
dudmuck 0:f2716e543d97 60 /*
dudmuck 0:f2716e543d97 61 * return 32-bit system time in ticks.
dudmuck 0:f2716e543d97 62 */
dudmuck 0:f2716e543d97 63 u4_t hal_ticks (void);
dudmuck 0:f2716e543d97 64
dudmuck 0:f2716e543d97 65 /*
dudmuck 0:f2716e543d97 66 * busy-wait until specified timestamp (in ticks) is reached.
dudmuck 0:f2716e543d97 67 */
dudmuck 0:f2716e543d97 68 void hal_waitUntil (u4_t time);
dudmuck 0:f2716e543d97 69
dudmuck 0:f2716e543d97 70 /*
dudmuck 0:f2716e543d97 71 * check and rewind timer for target time.
dudmuck 0:f2716e543d97 72 * - return 1 if target time is close
dudmuck 0:f2716e543d97 73 * - otherwise rewind timer for target time or full period and return 0
dudmuck 0:f2716e543d97 74 */
dudmuck 0:f2716e543d97 75 u1_t hal_checkTimer (u4_t targettime);
dudmuck 0:f2716e543d97 76
dudmuck 0:f2716e543d97 77 /*
dudmuck 0:f2716e543d97 78 * perform fatal failure action.
dudmuck 0:f2716e543d97 79 * - called by assertions
dudmuck 0:f2716e543d97 80 * - action could be HALT or reboot
dudmuck 0:f2716e543d97 81 */
dudmuck 0:f2716e543d97 82 void hal_failed (void);
dudmuck 0:f2716e543d97 83
dudmuck 0:f2716e543d97 84 #ifndef OSTICKS_PER_SEC
dudmuck 0:f2716e543d97 85 #define OSTICKS_PER_SEC 16384
dudmuck 0:f2716e543d97 86 #elif OSTICKS_PER_SEC < 10000 || OSTICKS_PER_SEC > 64516
dudmuck 0:f2716e543d97 87 #error Illegal OSTICKS_PER_SEC - must be in range [10000:64516]. One tick must be 15.5us .. 100us long.
dudmuck 0:f2716e543d97 88 #endif
dudmuck 0:f2716e543d97 89
dudmuck 0:f2716e543d97 90 #endif // _hal_hpp_